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.

262 lines
6.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: N O T I F Y . H
  7. //
  8. // Contents: Implements the interface to a component's optional notify
  9. // object. The object defined here is meant to be a member
  10. // of CComponent. This object encapsulates all of its internal
  11. // data in a separate allocation made only if the component
  12. // actually has a notify object.
  13. //
  14. // Notes:
  15. //
  16. // Author: shaunco 15 Jan 1999
  17. //
  18. //----------------------------------------------------------------------------
  19. #pragma once
  20. #include "netcfgn.h"
  21. #include "netcfgx.h"
  22. #include "ncnetcfg.h"
  23. class CBindPath;
  24. class CBindingSet;
  25. class CComponent;
  26. class CImplINetCfg;
  27. struct NOTIFY_OBJECT_DATA
  28. {
  29. INetCfgComponentControl* pCc;
  30. INetCfgComponentNotifyBinding* pNb;
  31. INetCfgComponentPropertyUi* pCp;
  32. INetCfgComponentSetup* pCs;
  33. INetCfgComponentUpperEdge* pUe;
  34. INetCfgComponentNotifyGlobal* pNg;
  35. DWORD dwNotifyGlobalFlags;
  36. };
  37. enum QN_FLAG
  38. {
  39. QN_QUERY,
  40. QN_NOTIFY
  41. };
  42. // CComponent has a member called Notify that is of this type.
  43. //
  44. // pComponent = CONTAINING_RECORD(this, CComponent, Notify)
  45. //
  46. class CNotifyObjectInterface
  47. {
  48. friend class CGlobalNotifyInterface;
  49. friend class CImplINetCfgComponent;
  50. private:
  51. NOTIFY_OBJECT_DATA* m_pNod;
  52. BOOLEAN m_fInitialized;
  53. public:
  54. ~CNotifyObjectInterface ()
  55. {
  56. ReleaseNotifyObject (NULL, FALSE);
  57. AssertH (!m_pNod);
  58. AssertH (!m_fInitialized);
  59. }
  60. VOID
  61. ApplyPnpChanges (
  62. IN CImplINetCfg* pINetCfg,
  63. OUT BOOL* pfNeedReboot) const;
  64. VOID
  65. ApplyRegistryChanges (
  66. IN CImplINetCfg* pINetCfg,
  67. OUT BOOL* pfNeedReboot) const;
  68. HRESULT
  69. HrGetInterfaceIdsForAdapter (
  70. IN CImplINetCfg* pINetCfg,
  71. IN const CComponent* pAdapter,
  72. OUT DWORD* pcInterfaces,
  73. OUT GUID** ppguidInterfaceIds) const;
  74. HRESULT
  75. HrQueryPropertyUi (
  76. IN CImplINetCfg* pINetCfg,
  77. IN IUnknown* punkContext OPTIONAL);
  78. HRESULT
  79. HrShowPropertyUi (
  80. IN CImplINetCfg* pINetCfg,
  81. IN HWND hwndParent,
  82. IN IUnknown* punkContext OPTIONAL);
  83. HRESULT
  84. QueryNotifyObject (
  85. IN CImplINetCfg* pINetCfg,
  86. IN REFIID riid,
  87. OUT VOID** ppvObject);
  88. VOID
  89. ReleaseNotifyObject (
  90. IN CImplINetCfg* pINetCfg,
  91. IN BOOL fCancel);
  92. private:
  93. // If not m_fInitialized, looks under component's instance key
  94. // for CLSID and, if found, CoCreates it and initializes m_pNod.
  95. //
  96. HRESULT
  97. HrEnsureNotifyObjectInitialized (
  98. IN CImplINetCfg* pINetCfg,
  99. IN BOOL fInstalling);
  100. VOID
  101. SetUiContext (
  102. IN CImplINetCfg* pINetCfg,
  103. IN IUnknown* punkContext);
  104. VOID
  105. NbQueryOrNotifyBindingPath (
  106. IN CImplINetCfg* pINetCfg,
  107. IN QN_FLAG Flag,
  108. IN DWORD dwChangeFlag,
  109. IN INetCfgBindingPath* pIPath,
  110. OUT BOOL* pfDisabled);
  111. HRESULT
  112. NewlyAdded (
  113. IN CImplINetCfg* pINetCfg,
  114. IN const NETWORK_INSTALL_PARAMS* pnip);
  115. VOID
  116. Removed (
  117. IN CImplINetCfg* pINetCfg);
  118. VOID
  119. Updated (
  120. IN CImplINetCfg* pINetCfg,
  121. IN DWORD dwSetupFlags,
  122. IN DWORD dwUpgradeFromBuildNo);
  123. };
  124. // CNetCfg has a member called GlobalNotify that is of this type.
  125. //
  126. // pConfig = CONTAINING_RECORD(this, CNetConfig, GlobalNotify)
  127. //
  128. class CGlobalNotifyInterface
  129. {
  130. friend class CNotifyObjectInterface;
  131. friend class CNetCfgInternalDiagnostic;
  132. private:
  133. // TRUE if all notify objects have been loaded and QI'd for
  134. // INetCfgComponentNotifyGlobal.
  135. //
  136. BOOL m_fInitialized;
  137. // A pointer to INetCfg is needed because we hand this to notify objects.
  138. //
  139. CImplINetCfg* m_pINetCfg;
  140. private:
  141. // INetCfgComponentNotifyGlobal
  142. //
  143. // (each method calls HrEnsureNotifyObjectsInitialized and then
  144. // for each component in CNetCfg that has non-NULL Notify.m_pNod,
  145. // calls through Notify.m_pNod->pNg)
  146. //
  147. VOID
  148. NgSysQueryOrNotifyBindingPath (
  149. IN QN_FLAG Flag,
  150. IN DWORD dwChangeFlag,
  151. IN INetCfgBindingPath* pIPath,
  152. IN BOOL* pfDisabled);
  153. // Called when a component is added, removed, updated, or has its
  154. // properties changed.
  155. //
  156. HRESULT
  157. NgSysNotifyComponent (
  158. IN DWORD dwChangeFlag,
  159. IN CComponent* pComponent);
  160. HRESULT
  161. QueryAndNotifyBindPaths (
  162. IN DWORD dwBaseChangeFlag,
  163. IN CBindingSet* pBindSet,
  164. IN UINT cSkipFirstBindPaths);
  165. public:
  166. ~CGlobalNotifyInterface ()
  167. {
  168. ReleaseINetCfg ();
  169. AssertH (!m_pINetCfg);
  170. }
  171. VOID
  172. HoldINetCfg (
  173. CImplINetCfg* pINetCfg);
  174. VOID
  175. ReleaseINetCfg ();
  176. CImplINetCfg*
  177. PINetCfg ()
  178. {
  179. AssertH (m_pINetCfg);
  180. return m_pINetCfg;
  181. }
  182. // If not m_fInitialized, calls into CNetConfig to load every component's
  183. // notify object.
  184. //
  185. HRESULT
  186. HrEnsureNotifyObjectsInitialized ();
  187. HRESULT
  188. ComponentAdded (
  189. IN CComponent* pComponent,
  190. IN const NETWORK_INSTALL_PARAMS* pnip);
  191. HRESULT
  192. ComponentRemoved (
  193. IN CComponent* pComponent);
  194. HRESULT
  195. ComponentUpdated (
  196. IN CComponent* pComponent,
  197. IN DWORD dwSetupFlags,
  198. IN DWORD dwUpgradeFromBuildNo);
  199. HRESULT
  200. NotifyRemovedBindPaths (
  201. IN CBindingSet* pBindSet,
  202. IN UINT cSkipFirstBindPaths)
  203. {
  204. return QueryAndNotifyBindPaths (NCN_REMOVE, pBindSet, cSkipFirstBindPaths);
  205. }
  206. HRESULT
  207. QueryAndNotifyForAddedBindPaths (
  208. IN CBindingSet* pBindSet,
  209. IN UINT cSkipFirstBindPaths)
  210. {
  211. return QueryAndNotifyBindPaths (NCN_ADD, pBindSet, cSkipFirstBindPaths);
  212. }
  213. VOID
  214. NotifyBindPath (
  215. IN DWORD dwChangeFlag,
  216. IN CBindPath* pBindPath,
  217. IN INetCfgBindingPath* pIPath);
  218. VOID
  219. ReleaseAllNotifyObjects (
  220. IN CComponentList& Components,
  221. IN BOOL fCancel);
  222. };