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.

153 lines
4.7 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994-1995 **
  4. //*********************************************************************
  5. //
  6. // DIALMON.H - central header file for dial monitor app
  7. //
  8. // HISTORY:
  9. //
  10. // 4/18/95 jeremys Created.
  11. //
  12. #ifndef _DIALMON_H_
  13. #define _DIALMON_H_
  14. #include <regstr.h>
  15. // We need winver 4.00 so ras doesn't puke on our new structure sizes in
  16. // RasEnumConnections.
  17. #undef WINVER
  18. #define WINVER 0x400
  19. #include <ras.h>
  20. #include <raserror.h>
  21. // how to tell dialmon that something is going on
  22. void IndicateDialmonActivity(void);
  23. // give user 30 seconds to respond to dialog
  24. #define DISCONNECT_DLG_COUNTDOWN 30
  25. // truncate and add "..." if connectoid name longer than 20 characters
  26. #define MAX_CONNECTOID_DISPLAY_LEN 50
  27. // private message sent to disconnect dialog to dismiss it
  28. #define WM_QUIT_DISCONNECT_DLG WM_USER+50
  29. // sizes of various unknown things
  30. #define MAX_RES_LEN 255
  31. #define DEF_CONN_BUF_SIZE 4096
  32. // class name used for dial monitoring
  33. #define AUTODIAL_MONITOR_CLASS_NAME "MS_AutodialMonitor"
  34. // max ras connections we care about
  35. #define MAX_CONNECTION 8
  36. // forward declaration
  37. class BUFFER;
  38. ///////////////////////////////////////////////////////////////////////////
  39. //
  40. // CDialMon class definition
  41. //
  42. ///////////////////////////////////////////////////////////////////////////
  43. class CDialMon
  44. {
  45. private:
  46. BOOL _fInDisconnectFunction; // prevent dialog reentrancy
  47. DWORD _dwTimeoutMins; // timeout value, in minutes
  48. DWORD _dwElapsedTicks; // elapsed ticks with no activity
  49. BOOL _fNoTimeout; // monitor idle or just exit?
  50. BOOL _fDisconnectOnExit;
  51. BOOL _fConnected;
  52. TCHAR _pszConnectoidName[RAS_MaxEntryName+1];
  53. // name of connectoid of interest
  54. UINT_PTR _uIdleTimerID; // timer id on parent window
  55. HWND _hwndDialmon;
  56. public:
  57. HWND _hDisconnectDlg;
  58. CDialMon();
  59. ~CDialMon();
  60. void OnSetConnectoid(BOOL fNoTimeout);
  61. void OnActivity(void);
  62. void OnTimer(UINT_PTR uTimerID);
  63. void OnExplorerExit();
  64. void ResetElapsedTicks(){ _dwElapsedTicks = 0; }
  65. // Set DEBUG_KV to 1 here if you need to test hangup logic
  66. // without actually having a dailup connection.
  67. //#define DEBUG_KV 1
  68. #ifdef DEBUG_KV
  69. // wrapper over private fn. StartMonitoring when we need to debug without
  70. // actually having a dial-up connection.
  71. void kvStartMonitoring(){ StartMonitoring(); }
  72. #endif
  73. private:
  74. BOOL StartMonitoring(void);
  75. void StopMonitoring(void);
  76. INT_PTR StartIdleTimer(void);
  77. void StopIdleTimer(void);
  78. void CheckForDisconnect(BOOL fTimer);
  79. BOOL PromptForDisconnect(BOOL fTimer, BOOL *pfDisconnectDisabled);
  80. BOOL RefreshTimeoutSettings(void);
  81. BOOL LoadRNADll(void);
  82. void UnloadRNADll(void);
  83. };
  84. // structure for passing params to disconnect prompt dialog
  85. typedef struct tagDISCONNECTDLGINFO {
  86. LPTSTR pszConnectoidName; // input: name of connectoid
  87. DWORD dwTimeout; // input: idle timeout in minutes
  88. BOOL fTimer; // input: timer or shutdown?
  89. DWORD dwCountdownVal; // internal: state of countdown in dialog
  90. BOOL fDisconnectDisabled; // output: TRUE if disconnect disabled
  91. CDialMon *pDialMon; // pointer back to dialmon class
  92. } DISCONNECTDLGINFO;
  93. ///////////////////////////////////////////////////////////////////////////
  94. //
  95. // BUFFER class and helpers
  96. //
  97. ///////////////////////////////////////////////////////////////////////////
  98. class BUFFER_BASE
  99. {
  100. protected:
  101. UINT _cch;
  102. virtual BOOL Alloc( UINT cchBuffer ) = 0;
  103. virtual BOOL Realloc( UINT cchBuffer ) = 0;
  104. public:
  105. BUFFER_BASE() { _cch = 0; }
  106. ~BUFFER_BASE() { _cch = 0; }
  107. BOOL Resize( UINT cchNew );
  108. UINT QuerySize() const { return _cch; };
  109. };
  110. class BUFFER : public BUFFER_BASE
  111. {
  112. protected:
  113. TCHAR *_lpBuffer;
  114. virtual BOOL Alloc( UINT cchBuffer );
  115. virtual BOOL Realloc( UINT cchBuffer );
  116. public:
  117. BUFFER( UINT cchInitial=0 );
  118. ~BUFFER();
  119. BOOL Resize( UINT cchNew );
  120. TCHAR * QueryPtr() const { return (TCHAR *)_lpBuffer; }
  121. operator TCHAR *() const { return (TCHAR *)_lpBuffer; }
  122. };
  123. #endif