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.

151 lines
4.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include <winsock2.h>
  2. #include "main_window.h"
  3. #include "../../components/base/basicSettingsProvider.h"
  4. #include "../../components/object/objectFileLoggingService.h"
  5. #define LOG(X) mpLog->Log( "Main", NULL, X )
  6. #define LOG_DEBUG( X ) mpLog->Log( "Main", NULL, _LOG_DEBUG, X )
  7. #define LOG_ERROR( X ) mpLog->Log( "Main", NULL, _LOG_ERROR, X )
  8. //int main(int argc, char *argv[]) {
  9. int APIENTRY _tWinMain(HINSTANCE hInstance,
  10. HINSTANCE hPrevInstance,
  11. LPTSTR lpCmdLine,
  12. int nCmdShow){
  13. //Beep(512, 512);
  14. //Beep(256, 256);
  15. //Beep(128, 128);
  16. guiClass *GUI;
  17. GUI = guiClass::getInstance();
  18. GUI->init(0, NULL);//argc, argv);
  19. basicLogCollection *mpLog = basicLogCollection::getInstance();
  20. objectFileLoggingService *fLog;
  21. char tPath[1024];
  22. char *ttPtz=NULL;
  23. //ttPtz = (char *)GUI->getApp()->applicationDirPath().toStdString().c_str();
  24. if( ttPtz!= NULL ){
  25. sprintf(tPath, "%s/my.log", ttPtz);
  26. } else {
  27. sprintf(tPath, "my.log" );
  28. };
  29. fLog = new objectFileLoggingService(tPath);
  30. mpLog->addHandler((basicLoggingService *)fLog);
  31. printf("From now - refer to log file\n");
  32. LOG_DEBUG("ENTER APPLICATION");
  33. basicSettingsProvider *mpSettingsProvider = basicSettingsProvider::getInstance();
  34. config_setting_t *mpSettings;
  35. //mpStorPro->startNewSeries(); // Each prog start starts new Series
  36. #ifdef __linux__
  37. LOG_DEBUG("SS Disabled");
  38. #else
  39. UINT lActiveFlag = 0;
  40. SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, NULL, NULL);
  41. SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lActiveFlag, NULL, NULL);
  42. UINT timeoutLowPower;
  43. UINT timeoutPowerOff;
  44. UINT timeoutScreenSave;
  45. {
  46. SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT, 0, &(timeoutLowPower), 0);
  47. SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0, &(timeoutPowerOff), 0);
  48. SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &(timeoutScreenSave), 0);
  49. SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
  50. SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
  51. SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
  52. }
  53. LOG_DEBUG("SS Disabled");
  54. #endif
  55. mpSettings = mpSettingsProvider->getSubNode(NULL, "APPLICATION_GUI");
  56. mainWinow *window;
  57. window = mainWinow::getInstance();
  58. //Check Startup Mode
  59. int gAppStartupMode;
  60. config_setting_t *pSetting;
  61. if (!config_setting_lookup_int(mpSettings, "STARTUP_WINDOW_MODE", &gAppStartupMode )){
  62. gAppStartupMode = 1;
  63. pSetting = config_setting_add(mpSettings, "STARTUP_WINDOW_MODE", CONFIG_TYPE_INT);
  64. config_setting_set_int(pSetting, gAppStartupMode);
  65. mpSettingsProvider->compromise();
  66. };
  67. switch( gAppStartupMode ){
  68. case 0: window->show(); break;
  69. case 1: window->showMaximized(); break;
  70. case 2: window->showFullScreen(); break;
  71. default:
  72. gAppStartupMode = 1;
  73. pSetting = config_setting_lookup(mpSettings, "STARTUP_WINDOW_MODE");
  74. config_setting_set_int(pSetting, gAppStartupMode);
  75. mpSettingsProvider->compromise();
  76. window->showMaximized();
  77. };
  78. #ifdef __linux__
  79. LOG_DEBUG("SS Enabled");
  80. #else
  81. {
  82. SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, timeoutLowPower, NULL, 0);
  83. SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, timeoutPowerOff, NULL, 0);
  84. SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeoutScreenSave, NULL, 0);
  85. }
  86. LOG_DEBUG("SS Enabled");
  87. #endif
  88. delete GUI;
  89. delete window;
  90. delete mpSettingsProvider;
  91. #ifdef __linux__
  92. #else
  93. lActiveFlag = 1;
  94. SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0);
  95. lActiveFlag = 20;
  96. SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lActiveFlag, NULL, NULL);
  97. LOG_DEBUG("SS Enabled");
  98. #endif
  99. LOG_DEBUG("EXIT APPLICATION");
  100. delete mpLog;
  101. return 0;
  102. };
  103. #undef LOG
  104. #undef LOG_DEBUG
  105. #undef LOG_ERROR
  106. /*---------------------------------------*/
  107. /* A sample program to play C major */
  108. /* through a PC speaker */
  109. /*---------------------------------------*/
  110. /* This won't work if standard output is */
  111. /* re-directed to a non-tty device, or */
  112. /* PC speaker wave output is active */
  113. /*---------------------------------------*/
  114. /* M.G. 27-Nov-99 */
  115. /*---------------------------------------*/
  116. /*
  117. #include <sys/ioctl.h>
  118. #include <unistd.h>
  119. #include <linux/kd.h>
  120. int main(void)
  121. {
  122. int freq[] = { // C D E F G A B C
  123. 523, 587, 659, 698, 784, 880, 988, 1046 };
  124. int i;
  125. for (i = 0; i<8; i++)
  126. {
  127. ioctl(STDOUT_FILENO, KIOCSOUND, 1193180 / freq[i]);
  128. usleep(500000);
  129. }
  130. ioctl(STDOUT_FILENO, KIOCSOUND, 0); // Stop silly sound
  131. return 0;
  132. }
  133. */