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.

136 lines
4.3 KiB

  1. #pragma once
  2. #include "nmbase.h"
  3. #include "nmres.h"
  4. #include "nmhnet.h"
  5. extern LONG g_CountLanConnectionObjects;
  6. class ATL_NO_VTABLE CLanConnection :
  7. public CComObjectRootEx <CComMultiThreadModel>,
  8. public CComCoClass <CLanConnection, &CLSID_LanConnection>,
  9. public INetConnection,
  10. public IPersistNetConnection,
  11. public INetLanConnection,
  12. public INetConnectionSysTray,
  13. public INetConnection2
  14. {
  15. private:
  16. HKEY m_hkeyConn; // hkey for connection root
  17. BOOL m_fInitialized;
  18. HDEVINFO m_hdi;
  19. SP_DEVINFO_DATA m_deid;
  20. // This is required for checking permission on Firewall etc.
  21. CComPtr<INetMachinePolicies> m_pNetMachinePolicies;
  22. // Home networking support. m_fHNetPropertiesCached is set to TRUE
  23. // after the first successful call to HrEnsureHNetPropertiesCached.
  24. //
  25. BOOL m_fHNetPropertiesCached;
  26. LONG m_lHNetModifiedEra;
  27. LONG m_lUpdatingHNetProperties;
  28. HNET_CONN_PROPERTIES *m_pHNetProperties;
  29. public:
  30. CLanConnection()
  31. {
  32. m_hkeyConn = NULL;
  33. m_fInitialized = FALSE;
  34. m_hdi = NULL;
  35. m_fHNetPropertiesCached = FALSE;
  36. m_lHNetModifiedEra = 0;
  37. m_pHNetProperties = NULL;
  38. m_lUpdatingHNetProperties = 0;
  39. m_pNetMachinePolicies = NULL;
  40. InterlockedIncrement(&g_CountLanConnectionObjects);
  41. }
  42. ~CLanConnection();
  43. DECLARE_REGISTRY_RESOURCEID(IDR_LAN_CONNECTION)
  44. BEGIN_COM_MAP(CLanConnection)
  45. COM_INTERFACE_ENTRY(INetConnection)
  46. COM_INTERFACE_ENTRY(IPersistNetConnection)
  47. COM_INTERFACE_ENTRY(INetLanConnection)
  48. COM_INTERFACE_ENTRY(INetConnectionSysTray)
  49. COM_INTERFACE_ENTRY(INetConnection2)
  50. END_COM_MAP()
  51. // INetConnection
  52. HRESULT GetDeviceName(PWSTR* ppszwDeviceName);
  53. HRESULT GetStatus(NETCON_STATUS* pStatus);
  54. HRESULT GetCharacteristics(NETCON_MEDIATYPE ncm, DWORD* pdwFlags);
  55. STDMETHOD(Connect)();
  56. STDMETHOD(Disconnect)();
  57. STDMETHOD(Delete)();
  58. STDMETHOD(Duplicate) (PCWSTR pszwDuplicateName, INetConnection** ppCon);
  59. STDMETHOD(GetProperties) (NETCON_PROPERTIES** ppProps);
  60. STDMETHOD(GetUiObjectClassId)(CLSID *pclsid);
  61. STDMETHOD(Rename)(PCWSTR pszwNewName);
  62. //
  63. // INetLanConnection
  64. //
  65. STDMETHOD(GetInfo)(DWORD dwMask, LANCON_INFO* pLanConInfo);
  66. STDMETHOD(SetInfo)(DWORD dwMask, const LANCON_INFO* pLanConInfo);
  67. STDMETHOD(GetDeviceGuid)(GUID *pguid);
  68. //
  69. // IPersistNetConnection
  70. //
  71. STDMETHOD(GetClassID)(CLSID *pclsid);
  72. STDMETHOD(GetSizeMax)(ULONG *pcbSize);
  73. STDMETHOD(Load)(const BYTE *pbBuf, ULONG cbSize);
  74. STDMETHOD(Save)(BYTE *pbBuf, ULONG cbSize);
  75. // INetConnectionSysTray
  76. STDMETHOD (ShowIcon) (const BOOL bShowIcon);
  77. // INetConnectionSysTray
  78. STDMETHOD (IconStateChanged) ();
  79. // INetConnection2
  80. STDMETHOD (GetPropertiesEx)(OUT NETCON_PROPERTIES_EX** ppConnectionPropertiesEx);
  81. //
  82. // Overrides
  83. //
  84. static HRESULT CreateInstance(HDEVINFO hdi, const SP_DEVINFO_DATA &deid,
  85. PCWSTR pszPnpId,
  86. REFIID riid, LPVOID *ppv);
  87. private:
  88. HRESULT HrIsConnectionActive(VOID);
  89. HRESULT HrPutName(PCWSTR szwName);
  90. HRESULT HrInitialize(PCWSTR pszPnpId);
  91. HRESULT HrLoad(const GUID &guid);
  92. HRESULT HrOpenRegistryKeys(const GUID &guid);
  93. HRESULT HrConnectOrDisconnect(BOOL fConnect);
  94. HRESULT HrCallSens(BOOL fConnect);
  95. HRESULT HrLoadDevInfoFromGuid(const GUID &guid);
  96. HRESULT HrIsAtmAdapterFromHkey(HKEY hkey);
  97. HRESULT HrIsAtmElanFromHkey(HKEY hkey);
  98. BOOL FIsMediaPresent(VOID);
  99. HRESULT HrIsConnectionBridged(BOOL* pfBridged);
  100. HRESULT HrIsConnectionFirewalled(BOOL* pfFirewalled);
  101. HRESULT HrIsConnectionNetworkBridge(BOOL* pfBridged);
  102. HRESULT HrIsConnectionIcsPublic(BOOL* pfIcsPublic);
  103. HRESULT HrEnsureHNetPropertiesCached(VOID);
  104. HRESULT HrGetIHNetConnection(IHNetConnection **ppHNetConnection);
  105. HRESULT HrEnsureValidNlaPolicyEngine();
  106. };
  107. //
  108. // Globals
  109. //
  110. HRESULT HrGetInstanceGuid(HDEVINFO hdi, const SP_DEVINFO_DATA &deid,
  111. LPGUID pguid);
  112. VOID EnsureUniqueConnectionName(PCWSTR pszPotentialName, PWSTR pszNewName);