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.

259 lines
7.6 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // EventProv.h
  7. //
  8. // Implementation File:
  9. // EventProv.cpp
  10. //
  11. // Description:
  12. // Definition of event provider class
  13. //
  14. // Author:
  15. // Henry Wang (HenryWa) 19-JAN-2000
  16. //
  17. // Notes:
  18. //
  19. //////////////////////////////////////////////////////////////////////////////
  20. #define EVENT_TABLE_SIZE 32
  21. #pragma once
  22. //////////////////////////////////////////////////////////////////////////////
  23. // Include Files
  24. //////////////////////////////////////////////////////////////////////////////
  25. //////////////////////////////////////////////////////////////////////////////
  26. // Forward Declarations
  27. //////////////////////////////////////////////////////////////////////////////
  28. class CEventProv;
  29. //////////////////////////////////////////////////////////////////////////////
  30. //++
  31. //
  32. // class CEventProv
  33. //
  34. // Description:
  35. // Event provider
  36. //
  37. //--
  38. //////////////////////////////////////////////////////////////////////////////
  39. class CEventProv
  40. : public IWbemEventProvider
  41. , public IWbemProviderInit
  42. {
  43. public:
  44. enum EEventStatus
  45. {
  46. esPENDING,
  47. esRUNNING,
  48. esPENDING_STOP,
  49. esSTOPPPED,
  50. esMX
  51. };
  52. enum EClusterNotificationType
  53. {
  54. cntCLUSTER_STATE_CHANGE =
  55. CLUSTER_CHANGE_NODE_STATE |
  56. CLUSTER_CHANGE_RESOURCE_STATE |
  57. CLUSTER_CHANGE_NETWORK_STATE |
  58. CLUSTER_CHANGE_NETINTERFACE_STATE |
  59. CLUSTER_CHANGE_QUORUM_STATE |
  60. CLUSTER_CHANGE_CLUSTER_STATE,
  61. cntGROUP_STATE_CHANGE =
  62. CLUSTER_CHANGE_GROUP_STATE,
  63. cntRESOURCE_STATE_CHANGE =
  64. CLUSTER_CHANGE_RESOURCE_STATE,
  65. cntOBJECT_ADD =
  66. CLUSTER_CHANGE_NODE_ADDED |
  67. CLUSTER_CHANGE_RESOURCE_ADDED |
  68. CLUSTER_CHANGE_GROUP_ADDED |
  69. CLUSTER_CHANGE_RESOURCE_TYPE_ADDED |
  70. CLUSTER_CHANGE_NETWORK_ADDED |
  71. CLUSTER_CHANGE_NETINTERFACE_ADDED,
  72. cntOBJECT_REMOVE =
  73. CLUSTER_CHANGE_NODE_DELETED |
  74. CLUSTER_CHANGE_RESOURCE_DELETED |
  75. CLUSTER_CHANGE_GROUP_DELETED |
  76. CLUSTER_CHANGE_RESOURCE_TYPE_DELETED |
  77. CLUSTER_CHANGE_NETWORK_DELETED |
  78. CLUSTER_CHANGE_NETINTERFACE_DELETED,
  79. cntPROPERTY_CHANGE =
  80. CLUSTER_CHANGE_NODE_PROPERTY |
  81. CLUSTER_CHANGE_RESOURCE_PROPERTY |
  82. CLUSTER_CHANGE_GROUP_PROPERTY |
  83. CLUSTER_CHANGE_RESOURCE_TYPE_PROPERTY |
  84. CLUSTER_CHANGE_NETWORK_PROPERTY |
  85. CLUSTER_CHANGE_NETINTERFACE_PROPERTY |
  86. CLUSTER_CHANGE_CLUSTER_PROPERTY
  87. };
  88. enum EEventObjectType
  89. {
  90. eotHANDLE = 0,
  91. eotCLUSTER,
  92. eotNODE,
  93. eotGROUP,
  94. eotRESOURCE,
  95. eotRESOURCE_TYPE,
  96. eotNETWORK,
  97. eotNET_INTERFACE,
  98. eotREGISTRY,
  99. eotQUORUM,
  100. eotMX
  101. };
  102. typedef void (*FPSETPROP)(
  103. CWbemClassObject & pwcoIn,
  104. LPCWSTR pwszMofClassNameIn,
  105. LPCWSTR pwszObjectNameIn,
  106. EEventObjectType eotObjectTypeIn,
  107. DWORD dwEventMinorIn
  108. );
  109. struct SEventTypeTable
  110. {
  111. CLUSTER_CHANGE m_eType;
  112. EEventObjectType m_eotObjectType;
  113. LPCWSTR m_pwszMof;
  114. IWbemClassObject * m_pwco;
  115. FPSETPROP m_pfn;
  116. };
  117. void InsertTable(
  118. DWORD dwIdxIn,
  119. CLUSTER_CHANGE eTypeIn,
  120. EEventObjectType eotObjectTypeIn,
  121. LPCWSTR pwszMofIn,
  122. IWbemClassObject * pwcoIn,
  123. FPSETPROP pfnIn
  124. );
  125. SEventTypeTable m_EventTypeTable[ 32 ];
  126. CEventProv( void );
  127. ~CEventProv( void );
  128. //
  129. // IUnknown members
  130. //
  131. STDMETHODIMP QueryInterface( REFIID riid, LPVOID * ppv );
  132. STDMETHODIMP_( ULONG ) AddRef( void );
  133. STDMETHODIMP_( ULONG ) Release( void );
  134. // Inherited from IWbemEventProvider
  135. HRESULT STDMETHODCALLTYPE ProvideEvents(
  136. IWbemObjectSink * pSinkIn,
  137. long lFlagsIn
  138. );
  139. // Inherited from IWbemProviderInit
  140. HRESULT STDMETHODCALLTYPE Initialize(
  141. LPWSTR pwszUserIn,
  142. LONG lFlagsIn,
  143. LPWSTR pwszNamespaceIn,
  144. LPWSTR pwszLocaleIn,
  145. IWbemServices * pNamespaceIn,
  146. IWbemContext * pCtxIn,
  147. IWbemProviderInitSink * pInitSinkIn
  148. );
  149. static HRESULT S_HrCreateThis(
  150. IUnknown * pUnknownOuterIn,
  151. VOID ** ppvOut
  152. );
  153. protected:
  154. ULONG m_cRef;
  155. IWbemServices * m_pNs;
  156. IWbemObjectSink * m_pSink;
  157. IWbemClassObject * m_pEventAdd;
  158. IWbemClassObject * m_pEventRemove;
  159. IWbemClassObject * m_pEventProperty;
  160. IWbemClassObject * m_pEventState;
  161. IWbemClassObject * m_pEventGroupState;
  162. IWbemClassObject * m_pEventResourceState;
  163. EEventStatus m_esStatus;
  164. HANDLE m_hThread;
  165. BOOL m_fStopped;
  166. HCHANGE m_hChange;
  167. static void S_SetEventProperty(
  168. CWbemClassObject & pwcoInout,
  169. LPCWSTR pwszMofClassNameIn,
  170. LPCWSTR pwszObjectNameIn,
  171. EEventObjectType eotObjectTypeIn,
  172. DWORD dwEventMinorIn
  173. );
  174. static void S_AddEvent(
  175. CWbemClassObject & pwcoInout,
  176. LPCWSTR pwszMofClassNameIn,
  177. LPCWSTR pwszObjectNameIn,
  178. EEventObjectType eotObjectTypeIn,
  179. DWORD dwEventMinorIn
  180. );
  181. static void S_DeleteEvent(
  182. CWbemClassObject & pwcoInout,
  183. LPCWSTR pwszMofClassNameIn,
  184. LPCWSTR pwszObjectNameIn,
  185. EEventObjectType eotObjectTypeIn,
  186. DWORD dwEventMinorIn
  187. );
  188. static void S_SetNodeStateProperty(
  189. CWbemClassObject & pwcoInout,
  190. LPCWSTR pwszMofClassNameIn,
  191. LPCWSTR pwszObjectNameIn,
  192. EEventObjectType eotObjectTypeIn,
  193. DWORD dwEventMinorIn
  194. );
  195. static void S_SetGroupStateProperty(
  196. CWbemClassObject & pwcoInout,
  197. LPCWSTR pwszMofClassNameIn,
  198. LPCWSTR pwszObjectNameIn,
  199. EEventObjectType eotObjectTypeIn,
  200. DWORD dwEventMinorIn
  201. );
  202. static void S_SetResourceStateProperty(
  203. CWbemClassObject & pwcoInout,
  204. LPCWSTR pwszMofClassNameIn,
  205. LPCWSTR pwszObjectNameIn,
  206. EEventObjectType eotObjectTypeIn,
  207. DWORD dwEventMinorIn
  208. );
  209. static void S_SetNetworkStateProperty(
  210. CWbemClassObject & pwcoInout,
  211. LPCWSTR pwszMofClassNameIn,
  212. LPCWSTR pwszObjectNameIn,
  213. EEventObjectType eotObjectTypeIn,
  214. DWORD dwEventMinorIn
  215. );
  216. static void S_SetNetInterfaceStateProperty(
  217. CWbemClassObject & pwcoInout,
  218. LPCWSTR pwszMofClassNameIn,
  219. LPCWSTR pwszObjectNameIn,
  220. EEventObjectType eotObjectTypeIn,
  221. DWORD dwEventMinorIn
  222. );
  223. static DWORD WINAPI S_EventThread(
  224. LPVOID pArgIn
  225. );
  226. void InstanceThread( void );
  227. }; //*** class CEventProv