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.

260 lines
7.0 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CAlertEmailConsumerProvider.cpp
  7. //
  8. // Description:
  9. // Implementation of CAlertEmailConsumerProvider class methods
  10. //
  11. // [Header File:]
  12. // CAlertEmailConsumerProvider.h
  13. //
  14. // History:
  15. // Xing Jin (i-xingj) 23-Dec-2000
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "stdafx.h"
  19. //#include <cdosys_i.c>
  20. //#include <SALOCMGR_I.C>
  21. //#include <ELEMENTMGR_I.C>
  22. #include "CAlertEmailConsumerProvider.h"
  23. #include "CAlertEmailConsumer.h"
  24. #include "AlertEmailProviderGuid.h"
  25. //////////////////////////////////////////////////////////////////////////////
  26. //
  27. // CAlertEmailConsumerProvider::CAlertEmailConsumerProvider
  28. //
  29. // Description:
  30. // Class constructor.
  31. //
  32. // History:
  33. // Xing Jin (i-xingj) 23-Dec-2000
  34. //
  35. //////////////////////////////////////////////////////////////////////////////
  36. CAlertEmailConsumerProvider::CAlertEmailConsumerProvider()
  37. {
  38. m_cRef = 0L;
  39. }
  40. //////////////////////////////////////////////////////////////////////////////
  41. //
  42. // CAlertEmailConsumerProvider::~CAlertEmailConsumerProvider
  43. //
  44. // Description:
  45. // Class deconstructor.
  46. //
  47. // History:
  48. // Xing Jin (i-xingj) 23-Dec-2000
  49. //
  50. //////////////////////////////////////////////////////////////////////////////
  51. CAlertEmailConsumerProvider::~CAlertEmailConsumerProvider()
  52. {
  53. }
  54. //////////////////////////////////////////////////////////////////////////////
  55. //
  56. // CAlertEmailConsumerProvider::QueryInterface
  57. //
  58. // Description:
  59. // An method implement of IUnkown interface.
  60. //
  61. // Arguments:
  62. // [in] riid Identifier of the requested interface
  63. // [out] ppv Address of output variable that receives the
  64. // interface pointer requested in iid
  65. //
  66. // Returns:
  67. // NOERROR if the interface is supported
  68. // E_NOINTERFACE if not
  69. //
  70. // History:
  71. // Xing Jin (i-xingj) 23-Dec-2000
  72. //
  73. //////////////////////////////////////////////////////////////////////////////
  74. STDMETHODIMP
  75. CAlertEmailConsumerProvider::QueryInterface(
  76. IN REFIID riid,
  77. OUT LPVOID FAR *ppv
  78. )
  79. {
  80. *ppv = NULL;
  81. if ( ( IID_IUnknown==riid ) ||
  82. (IID_IWbemEventConsumerProvider == riid ) )
  83. {
  84. *ppv = (IWbemEventConsumerProvider *) this;
  85. AddRef();
  86. return NOERROR;
  87. }
  88. if (IID_IWbemProviderInit==riid)
  89. {
  90. *ppv = (IWbemProviderInit *) this;
  91. AddRef();
  92. return NOERROR;
  93. }
  94. SATraceString(
  95. "AlertEmail:CAlertEmailConsumerProvider QueryInterface failed"
  96. );
  97. return E_NOINTERFACE;
  98. }
  99. //////////////////////////////////////////////////////////////////////////////
  100. //
  101. // CAlertEmailConsumerProvider::AddRef
  102. //
  103. // Description:
  104. // increments the reference count for an interface on an object
  105. //
  106. // Returns:
  107. // The new reference count.
  108. //
  109. // History:
  110. // Xing Jin (i-xingj) 23-Dec-2000
  111. //
  112. //////////////////////////////////////////////////////////////////////////////
  113. STDMETHODIMP_(ULONG)
  114. CAlertEmailConsumerProvider::AddRef(void)
  115. {
  116. InterlockedIncrement( &m_cRef );
  117. return m_cRef;
  118. }
  119. //////////////////////////////////////////////////////////////////////////////
  120. //
  121. // CAlertEmailConsumerProvider::Release
  122. //
  123. // Description:
  124. // decrements the reference count for an interface on an object.
  125. //
  126. // Returns:
  127. // The new reference count.
  128. //
  129. // History:
  130. // Xing Jin (i-xingj) 23-Dec-2000
  131. //
  132. //////////////////////////////////////////////////////////////////////////////
  133. STDMETHODIMP_(ULONG)
  134. CAlertEmailConsumerProvider::Release(void)
  135. {
  136. InterlockedDecrement( &m_cRef );
  137. if (0 != m_cRef)
  138. {
  139. return m_cRef;
  140. }
  141. delete this;
  142. return 0;
  143. }
  144. //////////////////////////////////////////////////////////////////////////////
  145. //
  146. // CAlertEmailConsumerProvider::Initialize
  147. //
  148. // Description:
  149. // An method implement of IWbemProviderInit interface.
  150. //
  151. // Arguments:
  152. // [in] wszUser Pointer to the user name
  153. // [in] lFlags Reserved
  154. // [in] wszNamespace Namespace name for which the provider is being
  155. // initialized
  156. // [in] wszLocale Locale name for which the provider is being
  157. // initialized
  158. // [in] IWbemServices An IWbemServices pointer back into Windows
  159. // Management
  160. // [in] pCtx An IWbemContext pointer associated with initialization
  161. // [in] pInitSink An IWbemProviderInitSink pointer that is used by
  162. // the provider to report initialization status.
  163. //
  164. //
  165. // Returns:
  166. // WBEM_S_NO_ERROR if successful
  167. // WBEM_E_FAILED if not
  168. //
  169. // History:
  170. // Xing Jin (i-xingj) 23-Dec-2000
  171. //
  172. //////////////////////////////////////////////////////////////////////////////
  173. STDMETHODIMP
  174. CAlertEmailConsumerProvider::Initialize(
  175. LPWSTR wszUser,
  176. LONG lFlags,
  177. LPWSTR wszNamespace,
  178. LPWSTR wszLocale,
  179. IWbemServices __RPC_FAR *pNamespace,
  180. IWbemContext __RPC_FAR *pCtx,
  181. IWbemProviderInitSink __RPC_FAR *pInitSink
  182. )
  183. {
  184. HRESULT hr;
  185. //
  186. // Tell CIMOM that we are initialized
  187. //
  188. pInitSink->SetStatus(WBEM_S_INITIALIZED, 0);
  189. return WBEM_S_NO_ERROR;
  190. }
  191. //////////////////////////////////////////////////////////////////////////////
  192. //
  193. // CAlertEmailConsumerProvider::FindConsumer
  194. //
  195. // Description:
  196. // An method implement of IWbemEventConsumerProvider interface.
  197. //
  198. // Arguments:
  199. // [in] pLogicalConsumer Pointer to the logical consumer object to
  200. // which the event objects are to be delivered
  201. // [out] ppConsumer Returns an event object sink to Windows
  202. // Management.
  203. //
  204. // Returns:
  205. // WBEM_S_NO_ERROR if successful
  206. // WBEM_E_FAILED if not
  207. //
  208. // History:
  209. // Xing Jin (i-xingj) 23-Dec-2000
  210. //
  211. //////////////////////////////////////////////////////////////////////////////
  212. STDMETHODIMP
  213. CAlertEmailConsumerProvider::FindConsumer(
  214. IWbemClassObject* pLogicalConsumer,
  215. IWbemUnboundObjectSink** ppConsumer
  216. )
  217. {
  218. HRESULT hr = WBEM_S_NO_ERROR;
  219. //
  220. // Allocate an IWembUnboundedSink object.
  221. //
  222. CAlertEmailConsumer* pSink = new CAlertEmailConsumer();
  223. //
  224. // Initialize the sink object.
  225. //
  226. hr = pSink->Initialize();
  227. if( FAILED(hr) )
  228. {
  229. SATraceString(
  230. "AlertEmail:FindConsumer Initialize failed"
  231. );
  232. delete pSink;
  233. return WBEM_E_NOT_FOUND;
  234. }
  235. return pSink->QueryInterface(
  236. IID_IWbemUnboundObjectSink,
  237. ( void** )ppConsumer
  238. );
  239. }