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.

182 lines
3.8 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 1999--2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CAlertEmailConsumer.h
  7. //
  8. // Description:
  9. // Implement the interface of IWbemUnboundObjectSink
  10. //
  11. // [Implementation Files:]
  12. // CAlertEmailConsumer.cpp
  13. //
  14. // History:
  15. // Xing Jin (i-xingj) 23-Dec-2000
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. #pragma once
  19. const ULONG MAX_EMAILADDRESS = 1024; // Including the NULL.
  20. //////////////////////////////////////////////////////////////////////////////
  21. //
  22. //
  23. // class CAlertEmailConsumer
  24. //
  25. // Description:
  26. // Physical event of consumer for Alert Event.
  27. //
  28. // History
  29. // Xing Jin (i-xingj) 23-Dec-2000
  30. //
  31. //////////////////////////////////////////////////////////////////////////////
  32. class CAlertEmailConsumer :
  33. public IWbemUnboundObjectSink
  34. {
  35. //
  36. // Public data
  37. //
  38. public:
  39. //
  40. // Constructors & Destructors
  41. //
  42. CAlertEmailConsumer();
  43. ~CAlertEmailConsumer();
  44. //
  45. // Initial function called by consumer provider.
  46. //
  47. HRESULT Initialize();
  48. //
  49. // IUnknown members
  50. //
  51. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  52. STDMETHODIMP_(ULONG) AddRef(void);
  53. STDMETHODIMP_(ULONG) Release(void);
  54. //
  55. // IWbemUnboundObjectSink members
  56. //
  57. STDMETHOD(IndicateToConsumer)(
  58. IWbemClassObject *pLogicalConsumer,
  59. long lNumObjects,
  60. IWbemClassObject **ppObjects
  61. );
  62. static DWORD WINAPI RegThreadProc( PVOID pIn );
  63. void RegThread();
  64. //
  65. // private data
  66. //
  67. private:
  68. //
  69. // Method for email sending.
  70. //
  71. HRESULT
  72. SendMail(
  73. BSTR bstrSubject,
  74. BSTR bstrMessage
  75. );
  76. //
  77. // Method to get alert's resource information and send mail.
  78. //
  79. HRESULT
  80. SendMailFromResource(
  81. LPWSTR lpszSource,
  82. LONG lSourceID,
  83. VARIANT* pvtReplaceStr
  84. );
  85. //
  86. // Method to get FullyQualifiedDomainName.
  87. //
  88. BOOL
  89. GetComputerName(
  90. LPWSTR* pstrFullyQualifiedDomainName,
  91. COMPUTER_NAME_FORMAT nametype
  92. );
  93. //
  94. // Get the port local server appliance is using.
  95. //
  96. HRESULT
  97. GetAppliancePort(
  98. LPWSTR* pstrPort
  99. );
  100. BOOL RetrieveRegInfo();
  101. //
  102. // Method to intialize CDO.
  103. //
  104. HRESULT InitializeCDOMessage(void);
  105. //
  106. // Method to intialize Element Manager.
  107. //
  108. HRESULT InitializeElementManager(void);
  109. //
  110. // Method to intialize CDO interface.
  111. //
  112. HRESULT InitializeLocalManager(void);
  113. //
  114. // Handler for raised alert event.
  115. //
  116. HRESULT RaiseAlert(IWbemClassObject *pObject);
  117. //
  118. // Get SMTP "Fully Qualified Domain Name" from metabase
  119. //
  120. HRESULT GetSMTPFromDomainName( BSTR* bstrDomainName );
  121. //
  122. // Handler for cleared alert event.
  123. //
  124. HRESULT ClearAlert(IWbemClassObject *pObject);
  125. LONG m_cRef; // Reference counter.
  126. HKEY m_hAlertKey; // Handle of AlertEmail key.
  127. LONG m_lCurAlertType; // Current alert type.
  128. LONG m_lAlertEmailDisabled;
  129. WCHAR m_pstrMailAddress[MAX_EMAILADDRESS];
  130. LPWSTR m_pstrFullyQualifiedDomainName;
  131. LPWSTR m_pstrNetBIOSName;
  132. HANDLE m_hCloseThreadEvent;
  133. HANDLE m_hThread;
  134. //
  135. // Reference to Local Manager.
  136. //
  137. ISALocInfo* m_pLocInfo;
  138. //
  139. // Reference to CDO::IMessage.
  140. //
  141. IMessage* m_pcdoIMessage;
  142. //
  143. // Reference to Element Manager.
  144. //
  145. IWebElementEnum* m_pElementEnum;
  146. };