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.

323 lines
6.9 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. ProvFact.h
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef _Server_ProviderEvent_H
  9. #define _Server_ProviderEvent_H
  10. #include "Globals.h"
  11. #include "ProvRegistrar.h"
  12. #include "ProvEvt.h"
  13. #include <lockst.h>
  14. /******************************************************************************
  15. *
  16. * Name:
  17. *
  18. *
  19. * Description:
  20. *
  21. *
  22. *****************************************************************************/
  23. class CDecoupledChild_IWbemObjectSink ;
  24. class CDecoupledRoot_IWbemObjectSink ;
  25. typedef WmiContainerController <CDecoupledChild_IWbemObjectSink *> CWbemGlobal_Decoupled_IWmiObjectSinkController ;
  26. typedef CWbemGlobal_Decoupled_IWmiObjectSinkController :: Container CWbemGlobal_Decoupled_IWmiObjectSinkController_Container ;
  27. typedef CWbemGlobal_Decoupled_IWmiObjectSinkController :: Container_Iterator CWbemGlobal_Decoupled_IWmiObjectSinkController_Container_Iterator ;
  28. typedef CWbemGlobal_Decoupled_IWmiObjectSinkController :: WmiContainerElement Decoupled_ObjectSinkContainerElement ;
  29. /******************************************************************************
  30. *
  31. * Name:
  32. *
  33. *
  34. * Description:
  35. *
  36. *
  37. *****************************************************************************/
  38. class CDecoupled_IWbemObjectSink : public IWbemEventSink ,
  39. public IWbemShutdown
  40. {
  41. private:
  42. protected:
  43. long m_SecurityDescriptorLength ;
  44. BYTE *m_SecurityDescriptor ;
  45. CriticalSection m_CriticalSection ;
  46. IWbemObjectSink *m_InterceptedSink ;
  47. IWbemEventSink *m_EventSink ;
  48. LONG m_GateClosed ;
  49. LONG m_InProgress ;
  50. LONG m_StatusCalled ;
  51. public:
  52. CDecoupled_IWbemObjectSink () ;
  53. ~CDecoupled_IWbemObjectSink () ;
  54. //Non-delegating object IUnknown
  55. STDMETHODIMP QueryInterface ( REFIID , LPVOID FAR * ) ;
  56. HRESULT STDMETHODCALLTYPE Indicate (
  57. long a_ObjectCount ,
  58. IWbemClassObject **a_ObjectArray
  59. ) ;
  60. HRESULT STDMETHODCALLTYPE SetStatus (
  61. long a_Flags ,
  62. HRESULT a_Result ,
  63. BSTR a_StringParamater ,
  64. IWbemClassObject *a_ObjectParameter
  65. ) ;
  66. HRESULT STDMETHODCALLTYPE IndicateWithSD (
  67. long a_ObjectsCount ,
  68. IUnknown **a_Objects ,
  69. long a_SecurityDescriptorLength ,
  70. BYTE *a_SecurityDescriptor
  71. ) ;
  72. HRESULT STDMETHODCALLTYPE SetSinkSecurity (
  73. long a_SecurityDescriptorLength ,
  74. BYTE *a_SecurityDescriptor
  75. ) ;
  76. HRESULT STDMETHODCALLTYPE IsActive () ;
  77. HRESULT STDMETHODCALLTYPE SetBatchingParameters (
  78. LONG a_Flags,
  79. DWORD a_MaxBufferSize,
  80. DWORD a_MaxSendLatency
  81. ) ;
  82. HRESULT STDMETHODCALLTYPE Shutdown (
  83. LONG a_Flags ,
  84. ULONG a_MaxMilliSeconds ,
  85. IWbemContext *a_Context
  86. ) ;
  87. } ;
  88. /******************************************************************************
  89. *
  90. * Name:
  91. *
  92. *
  93. * Description:
  94. *
  95. *
  96. *****************************************************************************/
  97. class CDecoupledRoot_IWbemObjectSink : public CDecoupled_IWbemObjectSink ,
  98. public CWbemGlobal_Decoupled_IWmiObjectSinkController
  99. {
  100. private:
  101. LONG m_ReferenceCount ;
  102. WmiAllocator &m_Allocator ;
  103. public:
  104. CDecoupledRoot_IWbemObjectSink (
  105. WmiAllocator &a_Allocator
  106. ) : CWbemGlobal_Decoupled_IWmiObjectSinkController ( a_Allocator ) ,
  107. m_Allocator ( a_Allocator ) ,
  108. m_ReferenceCount ( 0 )
  109. { ; }
  110. ~CDecoupledRoot_IWbemObjectSink ()
  111. {
  112. CWbemGlobal_Decoupled_IWmiObjectSinkController :: UnInitialize () ;
  113. }
  114. STDMETHODIMP_( ULONG ) AddRef () ;
  115. STDMETHODIMP_( ULONG ) Release () ;
  116. HRESULT SinkInitialize () ;
  117. HRESULT SetSink ( IWbemObjectSink *a_Sink ) ;
  118. HRESULT STDMETHODCALLTYPE GetRestrictedSink (
  119. long a_QueryCount ,
  120. const LPCWSTR *a_Queries ,
  121. IUnknown *a_Callback ,
  122. IWbemEventSink **a_Sink
  123. ) ;
  124. } ;
  125. /******************************************************************************
  126. *
  127. * Name:
  128. *
  129. *
  130. * Description:
  131. *
  132. *
  133. *****************************************************************************/
  134. class CDecoupledChild_IWbemObjectSink : public CDecoupled_IWbemObjectSink ,
  135. public Decoupled_ObjectSinkContainerElement
  136. {
  137. private:
  138. CDecoupledRoot_IWbemObjectSink *m_RootSink ;
  139. long m_QueryCount ;
  140. LPWSTR *m_Queries ;
  141. IUnknown *m_Callback ;
  142. public:
  143. CDecoupledChild_IWbemObjectSink (
  144. CDecoupledRoot_IWbemObjectSink *a_RootSink
  145. ) ;
  146. ~CDecoupledChild_IWbemObjectSink () ;
  147. STDMETHODIMP_( ULONG ) AddRef () ;
  148. STDMETHODIMP_( ULONG ) Release () ;
  149. HRESULT SinkInitialize (
  150. long a_QueryCount ,
  151. const LPCWSTR *a_Queries ,
  152. IUnknown *a_Callback
  153. ) ;
  154. HRESULT STDMETHODCALLTYPE GetRestrictedSink (
  155. long a_QueryCount ,
  156. const LPCWSTR *a_Queries ,
  157. IUnknown *a_Callback ,
  158. IWbemEventSink **a_Sink
  159. ) ;
  160. HRESULT SetSink ( IWbemObjectSink *a_Sink ) ;
  161. } ;
  162. /******************************************************************************
  163. *
  164. * Name:
  165. *
  166. *
  167. * Description:
  168. *
  169. *
  170. *****************************************************************************/
  171. class CServerObject_ProviderEvents : public CServerObject_ProviderRegistrar_Base ,
  172. public IWbemDecoupledBasicEventProvider
  173. {
  174. private:
  175. WmiAllocator &m_Allocator ;
  176. CriticalSection m_SinkCriticalSection ;
  177. long m_ReferenceCount ;
  178. long m_InternalReferenceCount ;
  179. CDecoupledRoot_IWbemObjectSink *m_ObjectSink ;
  180. CEventProvider *m_Provider ;
  181. IWbemServices *m_Service ;
  182. protected:
  183. public: /* Internal */
  184. HRESULT SetSink ( IWbemObjectSink *a_Sink )
  185. {
  186. WmiHelper :: EnterCriticalSection ( & m_SinkCriticalSection ) ;
  187. if ( m_ObjectSink )
  188. {
  189. CDecoupledRoot_IWbemObjectSink *t_Sink = m_ObjectSink ;
  190. t_Sink->AddRef () ;
  191. WmiHelper :: LeaveCriticalSection ( & m_SinkCriticalSection ) ;
  192. HRESULT t_Result = t_Sink->SetSink ( a_Sink ) ;
  193. t_Sink->Release () ;
  194. return t_Result ;
  195. }
  196. else
  197. {
  198. WmiHelper :: LeaveCriticalSection ( & m_SinkCriticalSection ) ;
  199. return WBEM_E_NOT_AVAILABLE ;
  200. }
  201. }
  202. STDMETHODIMP_( ULONG ) InternalAddRef () ;
  203. STDMETHODIMP_( ULONG ) InternalRelease () ;
  204. public: /* External */
  205. CServerObject_ProviderEvents ( WmiAllocator &a_Allocator ) ;
  206. ~CServerObject_ProviderEvents () ;
  207. //IUnknown members
  208. STDMETHODIMP QueryInterface ( REFIID , LPVOID FAR * ) ;
  209. STDMETHODIMP_( ULONG ) AddRef () ;
  210. STDMETHODIMP_( ULONG ) Release () ;
  211. HRESULT STDMETHODCALLTYPE Register (
  212. long a_Flags ,
  213. IWbemContext *a_Context ,
  214. LPCWSTR a_User ,
  215. LPCWSTR a_Locale ,
  216. LPCWSTR a_Scope ,
  217. LPCWSTR a_Registration ,
  218. IUnknown *a_Unknown
  219. ) ;
  220. HRESULT STDMETHODCALLTYPE UnRegister () ;
  221. HRESULT STDMETHODCALLTYPE GetSink (
  222. long a_Flags ,
  223. IWbemContext *a_Context ,
  224. IWbemObjectSink **a_Sink
  225. ) ;
  226. HRESULT STDMETHODCALLTYPE GetService (
  227. long a_Flags ,
  228. IWbemContext *a_Context ,
  229. IWbemServices **a_Service
  230. ) ;
  231. };
  232. #endif // _Server_ProviderEvent_H