Leaked source code of windows server 2003
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.

107 lines
2.4 KiB

  1. /*
  2. *
  3. * NOTES:
  4. *
  5. * REVISIONS:
  6. * pcy18Feb93: Spilt server app and client app to separate files
  7. * TSC20May93: Substituted nttimmn.* for os2timmn.*
  8. * TSC28May93: Added defines for object pointers, see ntthrdbl.cxx for details
  9. * pam04Apr96: Changed to accomodate CWC (nt timer manager)
  10. * pam15Jul96: Added Sockets startup and shutdown
  11. * pam15Jul96: Changed utils.h to w32utils.h
  12. * awm14Jan98: Added performance monitor object and code to initialize it
  13. * tjg29Jan98: Clean up if performance monitor object fails to start
  14. * mds24Aug98: Set thePerformanceMonitors to NULL in constructor. This stops
  15. * back-end crash if the service is started without rengs.dll
  16. * file or pwrchute.ini file (SIR #7059)
  17. * mholly12May1999: add UPSTurnOff method
  18. */
  19. #include "cdefine.h"
  20. #include <windows.h>
  21. #include "codes.h"
  22. #include "nttimmn.h"
  23. #include "ntsrvap.h"
  24. #include "err.h"
  25. #include "w32utils.h"
  26. /*
  27. Name :NTServerApplication
  28. Synop :The constructor for the main application object.
  29. */
  30. NTServerApplication::NTServerApplication(VOID)
  31. {
  32. }
  33. NTServerApplication::~NTServerApplication(VOID)
  34. {
  35. }
  36. /*
  37. Name :Start
  38. Synop :This starts the application running.
  39. */
  40. INT NTServerApplication::Start()
  41. {
  42. /* Construct the timer manager before the host object
  43. because it is needed when the host is constructed */
  44. _theTimerManager = theTimerManager = new NTTimerManager(this);
  45. // Construct everything before calling start on the parent class
  46. ServerApplication::Start();
  47. return (ErrNO_ERROR);
  48. }
  49. /*
  50. Name :Idle
  51. Synop :Idle is called whenever idle time exists in the system.
  52. */
  53. VOID NTServerApplication::Idle()
  54. {
  55. Sleep((DWORD)2000);
  56. }
  57. /*
  58. Name :Quit
  59. Synop :Quits the application immediately.
  60. */
  61. VOID NTServerApplication::Quit()
  62. {
  63. ServerApplication::Quit();
  64. }
  65. VOID NTServerApplication::UPSTurnOff()
  66. {
  67. if (theDeviceController) {
  68. //
  69. // first stop the polling of the UPS
  70. //
  71. theDeviceController->Stop();
  72. }
  73. if (theTimerManager) {
  74. //
  75. // don't want the timermanager sending
  76. // anymore events
  77. //
  78. theTimerManager->Stop();
  79. }
  80. if (theDeviceController) {
  81. theDeviceController->Set(TURN_OFF_UPS_ON_BATTERY, NULL);
  82. Sleep(7000);
  83. theDeviceController->Set(TURN_OFF_SMART_MODE, NULL);
  84. }
  85. }