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.

340 lines
7.6 KiB

  1. #ifndef _CONNMGR_H_
  2. #define _CONNMGR_H_
  3. //////////////////////////////////////////////////////////////////////////////
  4. //
  5. // Copyright (c) 2000 Microsoft Corporation
  6. //
  7. // Module: ConnMgr.h
  8. //
  9. // Author: Dan Elliott
  10. //
  11. // Abstract:
  12. //
  13. // Environment:
  14. // Whistler
  15. //
  16. // Revision History:
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19. #include <obcomm.h>
  20. #include <util.h>
  21. #include <netcon.h>
  22. #include <netcfgp.h>
  23. #define NUM_PROXY_OPTIONS 6
  24. class CObCommunicationManager;
  25. //////////////////////////////////////////////////////////////////////////////
  26. //
  27. // CConnectionManager
  28. //
  29. class CConnectionManager
  30. {
  31. public: // operations
  32. CConnectionManager();
  33. ~CConnectionManager( );
  34. STDMETHOD(GetCapabilities)(
  35. DWORD* pdwCapabilities
  36. );
  37. STDMETHOD(SetPreferredConnection)(
  38. const DWORD dwType,
  39. BOOL* pfSupportedType
  40. );
  41. STDMETHOD(GetPreferredConnection)(
  42. DWORD* pdwPreferred
  43. )
  44. {
  45. if (NULL == pdwPreferred)
  46. {
  47. MYASSERT(NULL != pdwPreferred);
  48. return E_POINTER;
  49. }
  50. *pdwPreferred = m_dwPreferredConnection;
  51. return S_OK;
  52. }
  53. HRESULT
  54. CConnectionManager::GetPreferredConnectionName(
  55. LPWSTR szConnectionName,
  56. DWORD cchConnectionName
  57. );
  58. STDMETHOD(ConnectedToInternet)(
  59. BOOL* pfConnected
  60. );
  61. STDMETHOD(ConnectedToInternetEx)(
  62. BOOL* pfConnected
  63. );
  64. STDMETHOD(AsyncConnectedToInternetEx)(
  65. const HWND hwnd
  66. );
  67. STDMETHOD(GetConnectionCount)(
  68. DWORD* pcConnections
  69. )
  70. {
  71. if (NULL == pcConnections)
  72. {
  73. MYASSERT(NULL != pcConnections);
  74. return E_POINTER;
  75. }
  76. // Currently phone connections are supported via CEnumModems and RAS.
  77. // Until they are supported via this object only return count of LAN
  78. // connections.
  79. //
  80. *pcConnections = m_cLanConnections;
  81. return S_OK;
  82. }
  83. STDMETHOD(SetPreferredConnectionTcpipProperties)(
  84. BOOL fAutoIPAddress,
  85. DWORD StaticIp_A,
  86. DWORD StaticIp_B,
  87. DWORD StaticIp_C,
  88. DWORD StaticIp_D,
  89. DWORD SubnetMask_A,
  90. DWORD SubnetMask_B,
  91. DWORD SubnetMask_C,
  92. DWORD SubnetMask_D,
  93. DWORD DefGateway_A,
  94. DWORD DefGateway_B,
  95. DWORD DefGateway_C,
  96. DWORD DefGateway_D,
  97. BOOL fAutoDns,
  98. DWORD DnsPref_A,
  99. DWORD DnsPref_B,
  100. DWORD DnsPref_C,
  101. DWORD DnsPref_D,
  102. DWORD DnsAlt_A,
  103. DWORD DnsAlt_B,
  104. DWORD DnsAlt_C,
  105. DWORD DnsAlt_D
  106. );
  107. BOOL IsValid( ) const
  108. {
  109. return (CONNECTIONTYPE_INVALID != m_dwConnectionCapabilities);
  110. } // IsValid
  111. void UseWinntProxySettings();
  112. void DisableWinntProxySettings();
  113. STDMETHOD(GetProxySettings)(
  114. BOOL* pbUseAuto,
  115. BOOL* pbUseScript,
  116. BSTR* pszScriptUrl,
  117. BOOL* pbUseProxy,
  118. BSTR* pszProxy
  119. );
  120. STDMETHOD(SetProxySettings)(
  121. BOOL bUseAuto,
  122. BOOL bUseScript,
  123. BSTR szScriptUrl,
  124. BOOL bUseProxy,
  125. BSTR szProxy
  126. );
  127. STDMETHOD(GetPublicLanCount)(
  128. int* pcPublicLan
  129. );
  130. void SetExclude1394(
  131. BOOL bExclude
  132. )
  133. {
  134. m_bExclude1394 = bExclude;
  135. }
  136. HRESULT EnumPublicConnections(
  137. OUT PSTRINGLIST* pList
  138. );
  139. protected: // operations
  140. protected: // data
  141. private: // operations
  142. BOOL LanConnectionReady();
  143. HRESULT SetProxyBlanket(
  144. IUnknown* pUnk
  145. );
  146. void DeterminePreferredConnection();
  147. void GetPreferredConnection();
  148. HRESULT SetTcpipProperties(
  149. GUID guid,
  150. REMOTE_IPINFO* pipInfo
  151. );
  152. HRESULT GetNetCfgInterface(
  153. BOOL fNeedWriteLock,
  154. INetCfg** ppNetCfg
  155. );
  156. void ReleaseNetCfgInterface(
  157. INetCfg* pNetCfg,
  158. BOOL fHasWriteLock
  159. );
  160. HRESULT GetTcpipPrivateInterface(
  161. INetCfg* pNetCfg,
  162. ITcpipProperties** ppTcpipProperties
  163. );
  164. BOOL IsEnabledConnection(
  165. NETCON_PROPERTIES* pprops
  166. );
  167. BOOL GetInternetHandleForPinging(
  168. HINTERNET* phInternet
  169. );
  170. BOOL ApplyWinntProxySettings();
  171. BOOL SaveProxySettings();
  172. void RestoreProxySettings();
  173. BOOL AllocProxyOptionList(
  174. INTERNET_PER_CONN_OPTION_LIST* pList
  175. );
  176. void FreeProxyOptionList(
  177. INTERNET_PER_CONN_OPTION_LIST* pList
  178. );
  179. void DisableRasAutodial();
  180. void RestoreRasAutoDial();
  181. HRESULT Enum1394Adapters(
  182. OUT PSTRINGLIST* pList
  183. );
  184. BOOL Is1394Adapter(
  185. IN GUID* pguid
  186. );
  187. HRESULT
  188. EnumPublicAdapters(
  189. OUT PSTRINGLIST* pList
  190. );
  191. inline BOOL HasModem()
  192. {
  193. return (BOOL)(CONNECTIONTYPE_MODEM & m_dwConnectionCapabilities);
  194. }
  195. inline BOOL HasIcs()
  196. {
  197. return (BOOL)(CONNECTIONTYPE_LAN_ICS & m_dwConnectionCapabilities);
  198. }
  199. inline BOOL HasBroadband()
  200. {
  201. return (BOOL)(CONNECTIONTYPE_LAN_BROADBAND & m_dwConnectionCapabilities);
  202. }
  203. inline BOOL HasConnection(
  204. const DWORD dwType
  205. )
  206. {
  207. return (BOOL)(dwType & m_dwConnectionCapabilities);
  208. }
  209. inline void AddConnectionCapability(
  210. DWORD dwType
  211. )
  212. {
  213. m_dwConnectionCapabilities |= dwType;
  214. }
  215. inline void ClearConnectionCapability(
  216. DWORD dwType
  217. )
  218. {
  219. m_dwConnectionCapabilities &= ~dwType;
  220. }
  221. // Explicitly disallow copy constructor and assignment operator.
  222. //
  223. CConnectionManager(
  224. const CConnectionManager& rhs
  225. );
  226. CConnectionManager&
  227. operator=(
  228. const CConnectionManager& rhs
  229. );
  230. private: // data
  231. // Bitmask of connection types supported by the system
  232. //
  233. DWORD m_dwConnectionCapabilities;
  234. // Preferred connection type to use.
  235. //
  236. DWORD m_dwPreferredConnection;
  237. // Preferred connection
  238. //
  239. INetConnection* m_pPreferredConnection;
  240. // Count of the LAN connections in the system (includes ICS)
  241. //
  242. DWORD m_cLanConnections;
  243. // Count of the phone connections in the system
  244. //
  245. DWORD m_cPhoneConnections;
  246. HINTERNET m_hInternetPing;
  247. // Proxy settings
  248. //
  249. BOOL m_bUseProxy;
  250. BOOL m_bProxySaved;
  251. BOOL m_bProxyApplied;
  252. INTERNET_PER_CONN_OPTION_LIST m_CurrentProxySettings;
  253. DWORD m_dwRasAutodialDisable;
  254. static const DWORD RAS_AUTODIAL_DISABLED;
  255. static const DWORD RAS_AUTODIAL_ENABLED;
  256. static const DWORD RAS_AUTODIAL_DONT_KNOW;
  257. BOOL m_bForceOnline;
  258. BOOL m_bExclude1394;
  259. }; // CConnectionManager
  260. #endif // _CONNMGR_H_
  261. //
  262. ///// End of file: ConnMgr.h ////////////////////////////////////////////////