You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include <stdio.h>
  2. #ifdef _NO_STDIO_IOB_FUNC_
  3. extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }
  4. #endif
  5. #include "mainwindow.h"
  6. #include <QApplication>
  7. #include "../../components/base/basicSettingsProvider.h"
  8. #include "../../components/base/basicEventHeap.h"
  9. #include "../../data/media/mediaVideoSourceManager.h"
  10. #include "../../components/object/objectFileLoggingService.h"
  11. #include "../../components/object/objectSystemAnchor.h"
  12. #include "../../data/media/video/videoAVLIBSource.h"
  13. #include "../../data/net/onvifDeviceNode.h"
  14. #include "../../components/object/objectEventReport.h"
  15. #define LOG(X) mpLog->Log( "Main", NULL, X )
  16. #define LOG_DEBUG( X ) mpLog->Log( "Main", NULL, _LOG_DEBUG, X )
  17. #define LOG_ERROR( X ) mpLog->Log( "Main", NULL, _LOG_ERROR, X )
  18. int main(int argc, char *argv[]){
  19. QApplication a(argc, argv);
  20. systemAnchor *ANCH;
  21. ANCH = systemAnchor::getInstance();
  22. basicLogCollection *mpLog = basicLogCollection::getInstance();
  23. objectFileLoggingService *fLog;
  24. char tPath[1024];
  25. char *ttPtz=NULL;
  26. //ttPtz = (char *)GUI->getApp()->applicationDirPath().toStdString().c_str();
  27. if( ttPtz!= NULL ){
  28. sprintf(tPath, "%s/my.log", ttPtz);
  29. } else {
  30. sprintf(tPath, "my.log" );
  31. };
  32. fLog = new objectFileLoggingService(tPath);
  33. mpLog->addHandler((basicLoggingService *)fLog);
  34. printf("From now - refer to log file\n");
  35. LOG_DEBUG("ENTER APPLICATION");
  36. basicSettingsProvider *mpSettingsProvider = basicSettingsProvider::getInstance();
  37. basicEventHeap *mpEventHeap = basicEventHeap::getInstance();
  38. mediaVideoSourceManager *LS = mediaVideoSourceManager::getInstance();
  39. //sprintf(tPath, "%s/data/storage", a.applicationDirPath().toStdString().c_str());
  40. sprintf(tPath, "data/storage");
  41. //ToDO: Check Report Object!
  42. objectEventReport *mpReporter = objectEventReport::getInstance();
  43. storageProvider *mpStorPro = storageProvider::getInstance(tPath);
  44. config_setting_t *mpSettings;
  45. //mpStorPro->startNewSeries(); // Each prog start starts new Series
  46. #ifdef __linux__
  47. LOG_DEBUG("SS Disabled");
  48. #else
  49. //UINT lActiveFlag = 0;
  50. //SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, NULL, NULL);
  51. //SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lActiveFlag, NULL, NULL);
  52. UINT timeoutLowPower;
  53. UINT timeoutPowerOff;
  54. UINT timeoutScreenSave;
  55. {
  56. SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT, 0, &(timeoutLowPower), 0);
  57. SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0, &(timeoutPowerOff), 0);
  58. SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &(timeoutScreenSave), 0);
  59. SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
  60. SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
  61. SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
  62. }
  63. LOG_DEBUG("SS Disabled");
  64. #endif
  65. mpSettings = mpSettingsProvider->getSubNode(NULL, "APPLICATION_GUI");
  66. MainWindow *window;
  67. window = new MainWindow();// mainWinow::getInstance();
  68. //Check Startup Mode
  69. int gAppStartupMode;
  70. config_setting_t *pSetting;
  71. if (!config_setting_lookup_int(mpSettings, "STARTUP_WINDOW_MODE", &gAppStartupMode )){
  72. gAppStartupMode = 0;
  73. pSetting = config_setting_add(mpSettings, "STARTUP_WINDOW_MODE", CONFIG_TYPE_INT);
  74. config_setting_set_int(pSetting, gAppStartupMode);
  75. mpSettingsProvider->compromise();
  76. };
  77. switch( gAppStartupMode ){
  78. case 0: window->show(); break;
  79. case 1: window->showMaximized(); break;
  80. case 2: window->showFullScreen(); break;
  81. default:
  82. gAppStartupMode = 0;
  83. pSetting = config_setting_lookup(mpSettings, "STARTUP_WINDOW_MODE");
  84. config_setting_set_int(pSetting, gAppStartupMode);
  85. mpSettingsProvider->compromise();
  86. window->showMaximized();
  87. };
  88. joysticObject::getInstance();
  89. //delete GUI;
  90. a.exec();
  91. delete window;
  92. delete LS;
  93. delete mpEventHeap;
  94. delete mpSettingsProvider;
  95. #ifdef __linux__
  96. LOG_DEBUG("SS Enabled");
  97. #else
  98. {
  99. SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, timeoutLowPower, NULL, 0);
  100. SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, timeoutPowerOff, NULL, 0);
  101. SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeoutScreenSave, NULL, 0);
  102. }
  103. LOG_DEBUG("SS Enabled");
  104. //lActiveFlag = 1;
  105. //SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0);
  106. //lActiveFlag = 20;
  107. //SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lActiveFlag, NULL, NULL);
  108. //LOG_DEBUG("SS Enabled");
  109. #endif
  110. LOG_DEBUG("EXIT APPLICATION");
  111. delete mpLog;
  112. }
  113. #undef LOG
  114. #undef LOG_DEBUG
  115. #undef LOG_ERROR