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.

200 lines
6.5 KiB

  1. //=============================================================================
  2. //
  3. // Copyright (c) 1996-1999, Microsoft Corporation, All rights reserved
  4. //
  5. // ESSSINK.H
  6. //
  7. // This files defines the class that implements IWbemObjectSink for the ESS.
  8. //
  9. // Classes defined:
  10. //
  11. // CEssObjectSink
  12. //
  13. // History:
  14. //
  15. // 11/27/96 a-levn Compiles
  16. //
  17. //=============================================================================
  18. #ifndef __ESSSINK__H_
  19. #define __ESSSINK__H_
  20. #include <wbemidl.h>
  21. #include <wbemint.h>
  22. #include <unk.h>
  23. #include <comutl.h>
  24. #include "parmdefs.h"
  25. #include "essutils.h"
  26. //*****************************************************************************
  27. //
  28. // class CEssObjectSink
  29. //
  30. // This class implements IWbemObjectSink interface for ESS, including the
  31. // automation part. A pointer to this object is given to WinMgmt at startup
  32. // and it serves as the only communication port into the ESS.
  33. //
  34. //*****************************************************************************
  35. class CEss;
  36. class CEssObjectSink : public CUnk
  37. {
  38. private:
  39. CEss* m_pEss;
  40. BOOL m_bShutdown;
  41. CEssSharedLock m_Lock;
  42. _IWmiCoreServices* m_pCoreServices;
  43. protected:
  44. typedef CImpl<IWbemEventSubsystem_m4, CEssObjectSink> TImplESS;
  45. class XESS : public TImplESS
  46. {
  47. public:
  48. XESS(CEssObjectSink* pObject) : TImplESS(pObject)
  49. {}
  50. STDMETHOD(ProcessInternalEvent)(long lSendType, LPCWSTR str1, LPCWSTR str2,
  51. LPCWSTR str3, DWORD dw1, DWORD dw2, DWORD dwObjectCount,
  52. _IWmiObject** apObjects, IWbemContext* pContext);
  53. STDMETHOD(VerifyInternalEvent)(long lSendType, LPCWSTR str1, LPCWSTR str2,
  54. LPCWSTR str3, DWORD dw1, DWORD dw2, DWORD dwObjectCount,
  55. _IWmiObject** apObjects, IWbemContext* pContext);
  56. STDMETHOD(SetStatus)(long, long, BSTR, IWbemClassObject*)
  57. {return WBEM_S_NO_ERROR;}
  58. STDMETHOD(RegisterNotificationSink)(LPCWSTR wszNamespace,
  59. LPCWSTR wszQueryLanguage, LPCWSTR wszQuery, long lFlags,
  60. IWbemContext* pContext, IWbemObjectSink* pSink);
  61. STDMETHOD(RemoveNotificationSink)(IWbemObjectSink* pSink);
  62. STDMETHOD(GetNamespaceSink)(LPCWSTR wszNamespace,
  63. IWbemObjectSink** ppSink);
  64. STDMETHOD(Initialize)(LPCWSTR wszServer, IWbemLocator* pAdminLocator,
  65. IUnknown* pServices);
  66. STDMETHOD(Shutdown)();
  67. STDMETHOD(LastCallForCore)(LONG lSystemShutDown);
  68. } m_XESS;
  69. friend XESS;
  70. typedef CImpl<_IWmiESS, CEssObjectSink> TImplNewESS;
  71. class XNewESS : public TImplNewESS
  72. {
  73. public:
  74. XNewESS(CEssObjectSink* pObject) : TImplNewESS(pObject)
  75. {}
  76. STDMETHOD(Initialize)(long lFlags, IWbemContext* pCtx,
  77. _IWmiCoreServices* pServices);
  78. STDMETHOD(ExecNotificationQuery)(LPCWSTR wszNamespace,
  79. LPCWSTR wszQueryText, long lFlags,
  80. IWbemContext* pContext, IWbemObjectSink* pSink);
  81. STDMETHOD(CancelAsyncCall)(IWbemObjectSink* pSink);
  82. STDMETHOD(QueryObjectSink)(LPCWSTR wszNamespace,
  83. IWbemObjectSink** ppSink);
  84. } m_XNewESS;
  85. friend XNewESS;
  86. typedef CImpl<IWbemShutdown, CEssObjectSink> TImplShutdown;
  87. class XShutdown : public TImplShutdown
  88. {
  89. public:
  90. XShutdown(CEssObjectSink* pObject) : TImplShutdown(pObject)
  91. {}
  92. STDMETHOD(Shutdown)( long lFlags,
  93. ULONG uMaxMilliseconds,
  94. IWbemContext* pCtx );
  95. } m_XShutdown;
  96. friend XShutdown;
  97. typedef CImpl<_IWmiCoreWriteHook, CEssObjectSink> TImplHook;
  98. class XHook : public TImplHook
  99. {
  100. public:
  101. XHook(CEssObjectSink* pObject) : TImplHook(pObject)
  102. {}
  103. STDMETHOD(PrePut)(long lFlags, long lUserFlags, IWbemContext* pContext,
  104. IWbemPath* pPath, LPCWSTR wszNamespace,
  105. LPCWSTR wszClass, _IWmiObject* pCopy);
  106. STDMETHOD(PostPut)(long lFlags, HRESULT hApiResult,
  107. IWbemContext* pContext,
  108. IWbemPath* pPath, LPCWSTR wszNamespace,
  109. LPCWSTR wszClass, _IWmiObject* pNew,
  110. _IWmiObject* pOld);
  111. STDMETHOD(PreDelete)(long lFlags, long lUserFlags,
  112. IWbemContext* pContext,
  113. IWbemPath* pPath, LPCWSTR wszNamespace,
  114. LPCWSTR wszClass);
  115. STDMETHOD(PostDelete)(long lFlags, HRESULT hApiResult,
  116. IWbemContext* pContext,
  117. IWbemPath* pPath, LPCWSTR wszNamespace,
  118. LPCWSTR wszClass, _IWmiObject* pOld);
  119. } m_XHook;
  120. friend XHook;
  121. public:
  122. CEssObjectSink(CLifeControl* pControl, IUnknown* pOuter = NULL);
  123. ~CEssObjectSink();
  124. void* GetInterface(REFIID riid);
  125. };
  126. class CEssNamespaceSink : public CUnk
  127. {
  128. CEss* m_pEss;
  129. BSTR m_strNamespace;
  130. protected:
  131. typedef CImpl<IWbemObjectSink, CEssNamespaceSink> TImplSink;
  132. class XSink : public TImplSink
  133. {
  134. public:
  135. XSink(CEssNamespaceSink* pObject) : TImplSink(pObject){}
  136. STDMETHOD(Indicate)(long lObjectCount, IWbemClassObject** pObjArray);
  137. STDMETHOD(SetStatus)(long, long, BSTR, IWbemClassObject*)
  138. {return WBEM_S_NO_ERROR;}
  139. } m_XSink;
  140. friend XSink;
  141. public:
  142. CEssNamespaceSink(CEss* pEss, CLifeControl* pControl,
  143. IUnknown* pOuter = NULL);
  144. HRESULT Initialize(LPCWSTR wszNamespace);
  145. ~CEssNamespaceSink();
  146. void* GetInterface(REFIID riid);
  147. };
  148. /****************************************************************************
  149. CEssInternalOperationSink
  150. This sink handles the setting up of a new ess thread object and then
  151. delegates calls to the specified sink. The purpose of this is so that
  152. internal ess operations can be performed asynchronously. For example,
  153. for class change notifications we register a sink that reactivates the
  154. associated filter. In order to actually perform the reactivation, the
  155. calling thread must be set up appropriately.
  156. *****************************************************************************/
  157. class CEssInternalOperationSink
  158. : public CUnkBase< IWbemObjectSink, &IID_IWbemObjectSink >
  159. {
  160. CWbemPtr<IWbemObjectSink> m_pSink;
  161. public:
  162. CEssInternalOperationSink( IWbemObjectSink* pSink ) : m_pSink( pSink ) {}
  163. STDMETHOD(Indicate)( long cObjects, IWbemClassObject** ppObjs );
  164. STDMETHOD(SetStatus)(long, long, BSTR, IWbemClassObject*);
  165. };
  166. #endif