|
|
#ifndef __linux__
#include <winsock2.h>
#endif
#include <stdio.h>
//https://autotire.co.il/%D7%92%D7%A0%D7%98%D7%99%D7%9D-%D7%92%D7%A0%D7%98%D7%99%D7%9D-5x114.3-15
#ifdef _NO_STDIO_IOB_FUNC_
extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }#endif
#include "main_window.h"
#include "../../components/base/basicSettingsProvider.h"
#include "../../components/base/basicEventHeap.h"
#include "../../data/media/mediaVideoSourceManager.h"
#include "../../components/object/objectFileLoggingService.h"
#include "../../components/object/objectSystemAnchor.h"
#include "../../data/media/video/videoAVLIBSource.h"
#include "../../data/net/onvifDeviceNode.h"
#include "../../components/object/objectEventReport.h"
#define LOG(X) mpLog->Log( "Main", NULL, X )
#define LOG_DEBUG( X ) mpLog->Log( "Main", NULL, _LOG_DEBUG, X )
#define LOG_ERROR( X ) mpLog->Log( "Main", NULL, _LOG_ERROR, X )
#ifdef __linux__
int main(int argc, char *argv[]) {#else
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){ Beep(512, 512); Beep(256, 512); Beep(128, 1024);#endif
guiClass * GUI; systemAnchor * ANCH; GUI = guiClass::getInstance();#ifdef __linux__
GUI->init( argc, argv);#else
GUI->init(0, NULL);#endif
ANCH = systemAnchor::getInstance(); basicLogCollection *mpLog = basicLogCollection::getInstance(); objectFileLoggingService *fLog; char tPath[1024]; char *ttPtz=NULL; //ttPtz = (char *)GUI->getApp()->applicationDirPath().toStdString().c_str();
if( ttPtz!= NULL ){ sprintf(tPath, "%s/my.log", ttPtz); } else { sprintf(tPath, "my.log" ); }; fLog = new objectFileLoggingService(tPath); mpLog->addHandler((basicLoggingService *)fLog); printf("From now - refer to log file\n"); LOG_DEBUG("ENTER APPLICATION"); basicSettingsProvider *mpSettingsProvider = basicSettingsProvider::getInstance(); basicEventHeap *mpEventHeap = basicEventHeap::getInstance(); mediaVideoSourceManager *LS = mediaVideoSourceManager::getInstance(); //sprintf(tPath, "%s/data/storage", GUI->getApp()->applicationDirPath().toStdString().c_str());
sprintf(tPath, "data/storage"); //ToDO: Check Report Object!
//objectEventReport *mpReporter = objectEventReport::getInstance();
//storageProvider *mpStorPro = storageProvider::getInstance(tPath);
config_setting_t *mpSettings; //mpStorPro->startNewSeries(); // Each prog start starts new Series
#ifdef __linux__
LOG_DEBUG("SS Disabled");#else
//UINT lActiveFlag = 0;
//SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, NULL, NULL);
//SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lActiveFlag, NULL, NULL);
UINT timeoutLowPower; UINT timeoutPowerOff; UINT timeoutScreenSave; { SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT, 0, &(timeoutLowPower), 0); SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0, &(timeoutPowerOff), 0); SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &(timeoutScreenSave), 0); SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0); SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0); SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0); } LOG_DEBUG("SS Disabled"); #endif
mpSettings = mpSettingsProvider->getSubNode(NULL, "APPLICATION_GUI");
mainWinow *window; window = mainWinow::getInstance(); //Check Startup Mode
int gAppStartupMode; config_setting_t *pSetting;
if (!config_setting_lookup_int(mpSettings, "STARTUP_WINDOW_MODE", &gAppStartupMode )){ gAppStartupMode = 0; pSetting = config_setting_add(mpSettings, "STARTUP_WINDOW_MODE", CONFIG_TYPE_INT); config_setting_set_int(pSetting, gAppStartupMode); mpSettingsProvider->compromise(); };
switch( gAppStartupMode ){ case 0: window->show(); break; case 1: window->showMaximized(); break; case 2: window->showFullScreen(); break; default: gAppStartupMode = 0; pSetting = config_setting_lookup(mpSettings, "STARTUP_WINDOW_MODE"); config_setting_set_int(pSetting, gAppStartupMode); mpSettingsProvider->compromise(); window->showMaximized(); }; joysticObject::getInstance();
delete GUI; delete window; delete LS; delete mpEventHeap; delete mpSettingsProvider;#ifdef __linux__
LOG_DEBUG("SS Enabled");#else
{ SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, timeoutLowPower, NULL, 0); SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, timeoutPowerOff, NULL, 0); SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeoutScreenSave, NULL, 0); } LOG_DEBUG("SS Enabled"); //lActiveFlag = 1;
//SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0);
//lActiveFlag = 20;
//SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lActiveFlag, NULL, NULL);
//LOG_DEBUG("SS Enabled");
#endif
LOG_DEBUG("EXIT APPLICATION"); delete mpLog; return 0;};
#undef LOG
#undef LOG_DEBUG
#undef LOG_ERROR
/*---------------------------------------*//* A sample program to play C major *//* through a PC speaker *//*---------------------------------------*//* This won't work if standard output is *//* re-directed to a non-tty device, or *//* PC speaker wave output is active *//*---------------------------------------*//* M.G. 27-Nov-99 *//*---------------------------------------*/
/*
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/kd.h>
int main(void){ int freq[] = { // C D E F G A B C
523, 587, 659, 698, 784, 880, 988, 1046 }; int i;
for (i = 0; i<8; i++) { ioctl(STDOUT_FILENO, KIOCSOUND, 1193180 / freq[i]); usleep(500000); } ioctl(STDOUT_FILENO, KIOCSOUND, 0); // Stop silly sound
return 0;}
*/
|