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.

183 lines
4.2 KiB

  1. #include "ras.h"
  2. #include "raserror.h"
  3. //
  4. // Useful registry constants
  5. //
  6. extern const TCHAR c_szRASKey[];
  7. extern const TCHAR c_szProfile[];
  8. //
  9. // Data for the dialer and property sheet is loaded and saved
  10. // in this format
  11. //
  12. struct _dialpropdata {
  13. BOOL fEnabled;
  14. BOOL fUnattended;
  15. TCHAR pszConnection[RAS_MaxEntryName + 1];
  16. TCHAR pszUsername[UNLEN + 1];
  17. TCHAR pszPassword[PWLEN + 1];
  18. TCHAR pszDomain[DNLEN + 1];
  19. UINT uRedialAttempts;
  20. UINT uRedialDelay;
  21. };
  22. typedef struct _dialpropdata DIALPROPDATA;
  23. //
  24. // Forward declaration
  25. //
  26. class CConnectionAgent;
  27. // the various states that a client can be in
  28. typedef enum {
  29. CLIENT_NEW,
  30. CLIENT_CONNECTING,
  31. CLIENT_CONNECTED,
  32. CLIENT_ABORT,
  33. CLIENT_DISCONNECTED,
  34. } ClientState;
  35. //
  36. // Connection client object
  37. //
  38. class CConnClient : public INotificationSink,
  39. public IOleCommandTarget
  40. {
  41. private:
  42. ~CConnClient() {};
  43. public:
  44. CConnClient();
  45. //
  46. // IUnknown members
  47. //
  48. STDMETHODIMP QueryInterface(REFIID, void **);
  49. STDMETHODIMP_(ULONG) AddRef(void);
  50. STDMETHODIMP_(ULONG) Release(void);
  51. //
  52. // INotificationSink members
  53. //
  54. STDMETHODIMP OnNotification(
  55. LPNOTIFICATION pNotification,
  56. LPNOTIFICATIONREPORT pNotificationReport,
  57. DWORD dwReserved
  58. );
  59. //
  60. // IOleCommandTarget members
  61. //
  62. STDMETHODIMP QueryStatus(
  63. const GUID __RPC_FAR *pguidCmdGroup,
  64. ULONG cCmds,
  65. OLECMD __RPC_FAR prgCmds[ ],
  66. OLECMDTEXT __RPC_FAR *pCmdText
  67. );
  68. STDMETHODIMP Exec(
  69. const GUID __RPC_FAR *pguidCmdGroup,
  70. DWORD nCmdID,
  71. DWORD nCmdexecopt,
  72. VARIANT __RPC_FAR *pvaIn,
  73. VARIANT __RPC_FAR *pvaOut
  74. );
  75. HRESULT SetConnAgent(IUnknown *punk);
  76. protected:
  77. long m_cRef;
  78. IOleCommandTarget * m_poctAgent;
  79. BSTR m_bstrURL;
  80. ClientState m_State;
  81. LPNOTIFICATIONREPORT m_pReport;
  82. long m_iCookie;
  83. HRESULT Connect(void);
  84. HRESULT Disconnect(void);
  85. HRESULT DeliverProgressReport(SCODE, BSTR);
  86. };
  87. //
  88. // Main dialer agent object
  89. //
  90. class CConnectionAgent : public IOleCommandTarget
  91. {
  92. private:
  93. ~CConnectionAgent();
  94. public:
  95. CConnectionAgent();
  96. //
  97. // IUnknown members
  98. //
  99. STDMETHODIMP QueryInterface(REFIID, void **);
  100. STDMETHODIMP_(ULONG) AddRef(void);
  101. STDMETHODIMP_(ULONG) Release(void);
  102. //
  103. // IOleCommandTarget members
  104. //
  105. STDMETHODIMP QueryStatus(
  106. const GUID __RPC_FAR *pguidCmdGroup,
  107. ULONG cCmds,
  108. OLECMD __RPC_FAR prgCmds[ ],
  109. OLECMDTEXT __RPC_FAR *pCmdText
  110. );
  111. STDMETHODIMP Exec(
  112. const GUID __RPC_FAR *pguidCmdGroup,
  113. DWORD nCmdID,
  114. DWORD nCmdexecopt,
  115. VARIANT __RPC_FAR *pvaIn,
  116. VARIANT __RPC_FAR *pvaOut
  117. );
  118. //
  119. // Other public members
  120. //
  121. DWORD m_dwRegisterHandle;
  122. protected:
  123. long m_cRef;
  124. BOOL IsDialPossible(void);
  125. BOOL IsDialExisting(void);
  126. void Notify(HRESULT hr, TCHAR *pszErrorText);
  127. void Connect(void);
  128. void Disconnect(void);
  129. void Clean(void);
  130. INotificationMgr *m_pMgr;
  131. DIALPROPDATA * m_pData;
  132. DWORD m_dwFlags;
  133. long m_lConnectionCount;
  134. HDPA m_hdpaClient;
  135. };
  136. // Connection agent flags
  137. #define CA_CONNECTING_NOW 1
  138. #define CA_OFFLINE_STATE_READ 2
  139. #define CA_OFFLINE 4
  140. #define CA_DIALED 8
  141. #define CA_LOADED_RAS 16
  142. // IOleCommandTarget commands
  143. #define AGENT_CONNECT 0x00
  144. #define AGENT_DISCONNECT 0x01
  145. #define AGENT_NOTIFY 0x10
  146. // CLIENTINFO struct - info about each client
  147. typedef struct _ci {
  148. IOleCommandTarget * poctClient;
  149. DWORD dwFlags;
  150. } CLIENTINFO;
  151. // flags for CLIENTINFO
  152. #define CLIENT_DISCONNECT 1
  153. #define CLIENT_NOTIFIED 2