Source code of Windows XP (NT5)
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.

150 lines
3.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: idle.h
  7. //
  8. // Contents: Idle notification routines.
  9. //
  10. // Classes:
  11. //
  12. // Notes:
  13. //
  14. // History: 23-Feb-98 rogerg Created.
  15. //
  16. //--------------------------------------------------------------------------
  17. #ifndef _SYNCMGRIDLE_
  18. #define _SYNCMGRIDLE_
  19. // this is a copy of msidle.h routines we need since msidle.h is not defined in public
  20. typedef void (WINAPI* _IDLECALLBACK) (DWORD dwState);
  21. #define STATE_USER_IDLE_BEGIN 1
  22. #define STATE_USER_IDLE_END 2
  23. //
  24. // BeginIdleDetection - start monitoring idleness
  25. //
  26. // pfnCallback - function to call back when idle state changes
  27. // dwIdleMin - minutes of inactivity before idle callback
  28. // dwReserved - must be 0
  29. //
  30. // Returns: 0 on success, error code on failure
  31. //
  32. // Note: Exported as ordinal 3
  33. //
  34. DWORD BeginIdleDetection(_IDLECALLBACK pfnCallback, DWORD dwIdleMin, DWORD dwReserved);
  35. typedef DWORD (WINAPI* _BEGINIDLEDETECTION) (_IDLECALLBACK, DWORD, DWORD);
  36. //
  37. // EndIdleDetection - stop monitoring idleness
  38. //
  39. // Returns: TRUE on success, FALSE on failure
  40. //
  41. // Note: Exported as ordinal 4
  42. //
  43. BOOL EndIdleDetection(DWORD dwReserved);
  44. typedef BOOL (WINAPI* _ENDIDLEDETECTION) (DWORD);
  45. //
  46. // SetIdleTimeout - Set minutes for idle timeout and reset idle state
  47. //
  48. // dwMinutes - new minutes threshold for idleness
  49. // fResetState - flag to return to non-idle state to retrigger idle callback
  50. // dwReserved - must be 0
  51. //
  52. // Note: Exported as ordinal 5
  53. //
  54. BOOL SetIdleTimeout(DWORD dwMinutes, DWORD dwReserved);
  55. typedef BOOL (WINAPI* _SETIDLETIMEOUT) (DWORD, DWORD);
  56. //
  57. // SetIdleNotify - Turns on or off notification when idle
  58. //
  59. // fNotify - flag whether to notify or not
  60. // dwReserved - must be 0
  61. //
  62. // Note: Exported as ordinal 6
  63. //
  64. void SetIdleNotify(BOOL fNotify, DWORD dwReserved);
  65. typedef void (WINAPI* _SETIDLENOTIFY) (BOOL, DWORD);
  66. //
  67. // SetBusyNotify - Turns on or off notification when busy
  68. //
  69. // fNotify - flag whether to notify or not
  70. // dwReserved - must be 0
  71. //
  72. // Note: Exported as ordinal 7
  73. //
  74. void SetBusyNotify(BOOL fNotify, DWORD dwReserved);
  75. typedef void (WINAPI* _SETBUSYNOTIFY) (BOOL, DWORD);
  76. //
  77. // GetIdleMinutes
  78. //
  79. // dwReserved - must be 0
  80. //
  81. // Returns number of minutes since user's last activity
  82. //
  83. // Note: Exported as ordinal 8
  84. //
  85. DWORD GetIdleMinutes(DWORD dwReserved);
  86. typedef DWORD (WINAPI* _GETIDLEMINUTES) (DWORD);
  87. // end of msidle.h copy
  88. class CProgressDlg;
  89. void WINAPI IdleCallback(DWORD dwState); // callback for registering with Idle.
  90. class CSyncMgrIdle
  91. {
  92. public:
  93. CSyncMgrIdle();
  94. ~CSyncMgrIdle();
  95. BOOL Initialize();
  96. DWORD BeginIdleDetection(CProgressDlg *pProgressDlg,DWORD dwIdleMin, DWORD dwReserved);
  97. DWORD ReRegisterIdleDetection(CProgressDlg *pProgressDlg);
  98. DWORD ResetIdle(ULONG ulIdleRetryMinutes);
  99. void OffIdle();
  100. void OnIdle();
  101. void CheckForIdle();
  102. private:
  103. BOOL LoadMsIdle();
  104. HINSTANCE m_hInstMsIdleDll;
  105. _BEGINIDLEDETECTION m_pBeginIdleDetection;
  106. _ENDIDLEDETECTION m_pEndIdleDetection;
  107. _GETIDLEMINUTES m_pGetIdleMinutes;
  108. _SETBUSYNOTIFY m_pSetBusyNotify;
  109. _SETIDLENOTIFY m_pSetIdleNotify;
  110. _SETIDLETIMEOUT m_pSetIdleTimeout;
  111. BOOL m_fInBeginIdleDetection;
  112. DWORD_PTR m_dwRegisteredTimer;
  113. BOOL m_fReceivedOffIdle;
  114. CProgressDlg *m_pProgressDlg;
  115. friend void WINAPI IdleCallback(DWORD dwState);
  116. friend VOID CALLBACK IdleOnTimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime);
  117. };
  118. #endif // _SYNCMGRIDLE_