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.

123 lines
2.6 KiB

  1. // tmpcnsmr.cpp: implementation of the CConsumer class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "HMAgent.h"
  5. #include "system.h"
  6. #include "tmpcnsmr.h"
  7. extern CSystem* g_pSystem;
  8. //////////////////////////////////////////////////////////////////////
  9. // Construction/Destruction
  10. //////////////////////////////////////////////////////////////////////
  11. CTempConsumer::CTempConsumer(HMTEMPEVENT_TYPE eventType)
  12. {
  13. m_cRef = 1;
  14. m_hmTempEventType = eventType;
  15. }
  16. CTempConsumer::CTempConsumer(LPTSTR szGUID)
  17. {
  18. m_cRef = 1;
  19. m_hmTempEventType = HMTEMPEVENT_ACTION;
  20. wcscpy(m_szGUID, szGUID);
  21. }
  22. CTempConsumer::CTempConsumer(CEventQueryDataCollector *pEQDC)
  23. {
  24. MY_ASSERT(pEQDC);
  25. m_cRef = 1;
  26. m_hmTempEventType = HMTEMPEVENT_EQDC;
  27. m_pEQDC = pEQDC;
  28. }
  29. CTempConsumer::~CTempConsumer()
  30. {
  31. }
  32. //////////////////////////////////////////////////////////////////////
  33. // IUnknown Implementation
  34. //////////////////////////////////////////////////////////////////////
  35. STDMETHODIMP CTempConsumer::QueryInterface(REFIID riid, LPVOID* ppv)
  36. {
  37. *ppv = 0;
  38. if (IID_IUnknown==riid || IID_IWbemObjectSink == riid)
  39. {
  40. *ppv = (IWbemEventProvider *) this;
  41. AddRef();
  42. return S_OK;
  43. }
  44. return E_NOINTERFACE;
  45. }
  46. STDMETHODIMP_(ULONG) CTempConsumer::AddRef(void)
  47. {
  48. return InterlockedIncrement((long*)&m_cRef);
  49. }
  50. STDMETHODIMP_(ULONG) CTempConsumer::Release(void)
  51. {
  52. LONG lCount = InterlockedDecrement((long*)&m_cRef);
  53. if (0 != lCount)
  54. {
  55. return lCount;
  56. }
  57. delete this;
  58. return 0L;
  59. }
  60. //////////////////////////////////////////////////////////////////////
  61. // IWbemObjectSink Implementation
  62. //////////////////////////////////////////////////////////////////////
  63. STDMETHODIMP CTempConsumer::Indicate(long lObjectCount, IWbemClassObject** ppObjArray)
  64. {
  65. if (!g_pSystem)
  66. {
  67. return WBEM_E_NOT_AVAILABLE;
  68. }
  69. for (long i = 0; i < lObjectCount; i++)
  70. {
  71. IWbemClassObject *pObj = ppObjArray[i];
  72. switch(m_hmTempEventType)
  73. {
  74. case HMTEMPEVENT_ACTION:
  75. g_pSystem->HandleTempActionEvent(m_szGUID, pObj);
  76. break;
  77. case HMTEMPEVENT_EQDC:
  78. g_pSystem->HandleTempEvent(m_pEQDC, pObj);
  79. break;
  80. case HMTEMPEVENT_ACTIONERROR:
  81. g_pSystem->HandleTempActionErrorEvent(pObj);
  82. break;
  83. case HMTEMPEVENT_ACTIONSID:
  84. g_pSystem->HandleTempActionSIDEvent(pObj);
  85. break;
  86. default:
  87. MY_ASSERT(FALSE);
  88. }
  89. }
  90. return WBEM_NO_ERROR;
  91. }
  92. //***************************************************************************
  93. STDMETHODIMP CTempConsumer::SetStatus(
  94. long lFlags,
  95. HRESULT hResult,
  96. BSTR strParam,
  97. IWbemClassObject* pObjParam
  98. )
  99. {
  100. // Not called during event delivery.
  101. return WBEM_NO_ERROR;
  102. }