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.

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