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.

111 lines
3.6 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: contable.h
  4. //
  5. // Module: CMCONTBL.LIB
  6. //
  7. // Synopsis: Header file declaring CConnectionTable
  8. //
  9. // Copyright (c) 1998-1999 Microsoft Corporation
  10. //
  11. // Author: nickball Created 02/02/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #include <ras.h>
  15. #include <raserror.h>
  16. const int MAX_CM_CONNECTIONS = 32;
  17. //
  18. // Data types used by Connection Table and clients
  19. //
  20. typedef enum _CmConnectState {
  21. CM_DISCONNECTED, // unused entry
  22. CM_DISCONNECTING, // in the process of disconnecting
  23. CM_RECONNECTPROMPT, // prompting user to reconnect
  24. CM_CONNECTING, // actively connecting
  25. CM_CONNECTED, // fully connected
  26. } CmConnectState;
  27. typedef struct Cm_Connection
  28. {
  29. DWORD dwUsage; // Reference count
  30. TCHAR szEntry[RAS_MaxEntryName + 1]; // Name of entry/profile
  31. BOOL fAllUser; // Is the entry "All user"
  32. CmConnectState CmState; // Current state
  33. HRASCONN hDial; // Dial-up RAS handle
  34. HRASCONN hTunnel; // Tunnel RAS handle
  35. } CM_CONNECTION, * LPCM_CONNECTION;
  36. typedef struct Cm_Connection_Table
  37. {
  38. HWND hwndCmMon; // the CMMON32.EXE window handle
  39. CM_CONNECTION Connections[MAX_CM_CONNECTIONS]; // a list of connections.
  40. } CM_CONNECTION_TABLE, * LPCM_CONNECTION_TABLE;
  41. //
  42. // Class declaration
  43. //
  44. class CConnectionTable
  45. {
  46. private:
  47. HANDLE m_hMap; // Handle of file mapping
  48. LPCM_CONNECTION_TABLE m_pConnTable; // Pointer to mapped view of file
  49. BOOL m_fLocked; // Internal error checking
  50. HANDLE m_hEvent; // Event handle for locking
  51. protected:
  52. HRESULT LockTable();
  53. HRESULT UnlockTable();
  54. HRESULT FindEntry(LPCTSTR pszEntry,
  55. LPINT piID);
  56. HRESULT FindEntry(HRASCONN hRasConn,
  57. LPINT piID);
  58. HRESULT FindUnused(LPINT piID);
  59. public:
  60. CConnectionTable(); // ctor
  61. ~CConnectionTable(); // dtor
  62. HRESULT Create(); // creates a new table, fails if existing
  63. HRESULT Open(); // opens an existing table
  64. HRESULT Close(); // closes an existing table
  65. HRESULT AddEntry(LPCTSTR pszEntry, BOOL fAllUser); // adds a connection entry to the table
  66. HRESULT RemoveEntry(LPCTSTR pszEntry); // removes a connection entry from the table
  67. HRESULT GetMonitorWnd(HWND *phWnd); // fills phWnd with HWND of CMMON in the table
  68. HRESULT SetMonitorWnd(HWND hwndMonitor); // assigns the hwnd of CMMON in the table
  69. HRESULT GetEntry(LPCTSTR pszEntry, // Fills the specified CM_CONNECTION structure
  70. LPCM_CONNECTION pConnection); // with the data for pszEntry
  71. HRESULT GetEntry(HRASCONN hRasConn, // Fills the specified CM_CONNECTION structure
  72. LPCM_CONNECTION pConnection); // with the data for hRasConn
  73. HRESULT SetConnected(LPCTSTR pszEntry, // sets the connection to the connected state, hDial required
  74. HRASCONN hDial,
  75. HRASCONN hTunnel);
  76. HRESULT SetDisconnecting(LPCTSTR pszEntry); // sets the connection to the disconnected state
  77. HRESULT SetPrompting(LPCTSTR pszEntry); // sets the connection to the prompting state
  78. HRESULT ClearEntry(LPCTSTR pszEntry); // clears the entry regardless of usage count
  79. };