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.

288 lines
12 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. DataCollection.h
  5. Abstract:
  6. This file contains the declaration of the classes used to implement
  7. the Data Collection system.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 07/21/99
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___SAF___DATACOLLECTION_H___)
  13. #define __INCLUDED___SAF___DATACOLLECTION_H___
  14. #include <MPC_COM.h>
  15. #include <MPC_security.h>
  16. #include <WMIParser.h>
  17. #include <History.h>
  18. /////////////////////////////////////////////////////////////////////////////
  19. //
  20. // Forward declarations.
  21. //
  22. class CSAFDataCollection;
  23. class CSAFDataCollectionReport;
  24. class CSAFDataCollectionEvents;
  25. /////////////////////////////////////////////////////////////////////////////
  26. class ATL_NO_VTABLE CSAFDataCollectionReport : // Hungarian: hchdcr
  27. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  28. public IDispatchImpl<ISAFDataCollectionReport, &IID_ISAFDataCollectionReport, &LIBID_HelpServiceTypeLib>
  29. {
  30. friend CSAFDataCollection;
  31. CComBSTR m_bstrNamespace;
  32. CComBSTR m_bstrClass;
  33. CComBSTR m_bstrWQL;
  34. DWORD m_dwErrorCode;
  35. CComBSTR m_bstrDescription;
  36. public:
  37. BEGIN_COM_MAP(CSAFDataCollectionReport)
  38. COM_INTERFACE_ENTRY(IDispatch)
  39. COM_INTERFACE_ENTRY(ISAFDataCollectionReport)
  40. END_COM_MAP()
  41. CSAFDataCollectionReport();
  42. // ISAFDataCollectionReport
  43. STDMETHOD(get_Namespace )( /*[out, retval]*/ BSTR *pValURL );
  44. STDMETHOD(get_Class )( /*[out, retval]*/ BSTR *pValTitle );
  45. STDMETHOD(get_WQL )( /*[out, retval]*/ BSTR *pValLastVisited);
  46. STDMETHOD(get_ErrorCode )( /*[out, retval]*/ long *pValDuration );
  47. STDMETHOD(get_Description)( /*[out, retval]*/ BSTR *pValNumOfHits );
  48. };
  49. /////////////////////////////////////////////////////////////////////////////
  50. class ATL_NO_VTABLE CSAFDataCollection : // Hungarian: hcpdc
  51. public MPC::Thread < CSAFDataCollection, ISAFDataCollection >,
  52. public MPC::ConnectionPointImpl< CSAFDataCollection, &DIID_DSAFDataCollectionEvents, MPC::CComSafeMultiThreadModel >,
  53. public IDispatchImpl < ISAFDataCollection, &IID_ISAFDataCollection, &LIBID_HelpServiceTypeLib >
  54. {
  55. typedef std::list< WMIParser::Snapshot* > QueryResults;
  56. typedef QueryResults::iterator QueryResultsIter;
  57. typedef QueryResults::const_iterator QueryResultsIterConst;
  58. typedef std::list< CSAFDataCollectionReport* > List;
  59. typedef List::iterator Iter;
  60. typedef List::const_iterator IterConst;
  61. private:
  62. MPC::Impersonation m_imp;
  63. DC_STATUS m_dsStatus;
  64. long m_lPercent;
  65. DWORD m_dwErrorCode;
  66. bool m_fScheduled; // Internal flag indicating that this is a low-priority, scheduled data collection.
  67. bool m_fCompleted; // Internal flag indicating that someone has already called Fire_onComplete.
  68. bool m_fWorking; // Internal flag indicating that an operation is currently performed.
  69. List m_lstReports;
  70. CSAFDataCollectionReport* m_hcpdcrcCurrentReport;
  71. CComBSTR m_bstrMachineData;
  72. CComBSTR m_bstrHistory;
  73. long m_lHistory;
  74. CComPtr<IStream> m_streamMachineData;
  75. CComPtr<IStream> m_streamHistory;
  76. CComBSTR m_bstrFilenameT0;
  77. CComBSTR m_bstrFilenameT1;
  78. CComBSTR m_bstrFilenameDiff;
  79. CComPtr<IDispatch> m_sink_onStatusChange;
  80. CComPtr<IDispatch> m_sink_onProgress;
  81. CComPtr<IDispatch> m_sink_onComplete;
  82. long m_lQueries_Done;
  83. long m_lQueries_Total;
  84. static void CleanQueryResult( QueryResults& qr );
  85. static HRESULT StreamFromXML( /*[in]*/ IXMLDOMDocument* xdd, /*[in]*/ bool fDelete, /*[in/out]*/ CComPtr<IStream>& val );
  86. void EraseReports ();
  87. void StartOperations();
  88. void StopOperations ();
  89. HRESULT ImpersonateCaller();
  90. HRESULT EndImpersonation ();
  91. public:
  92. DECLARE_NO_REGISTRY()
  93. DECLARE_NOT_AGGREGATABLE(CSAFDataCollection)
  94. DECLARE_GET_CONTROLLING_UNKNOWN()
  95. DECLARE_PROTECT_FINAL_CONSTRUCT()
  96. BEGIN_COM_MAP(CSAFDataCollection)
  97. COM_INTERFACE_ENTRY(IDispatch)
  98. COM_INTERFACE_ENTRY(ISAFDataCollection)
  99. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  100. END_COM_MAP()
  101. CSAFDataCollection();
  102. HRESULT FinalConstruct();
  103. void FinalRelease ();
  104. HRESULT ExecLoopCollect();
  105. HRESULT ExecLoopCompare();
  106. //
  107. // Data collection "core" methods.
  108. //
  109. HRESULT FilterDataSpec ( /*[in]*/ WMIHistory::Database& wmihdQuery ,
  110. /*[in]*/ WMIHistory::Database* wmihdFilter ,
  111. /*[in]*/ WMIHistory::Database::ProvList& lstQueries );
  112. HRESULT ExecDataSpec ( /*[in/out]*/ QueryResults& qr ,
  113. /*[in/out]*/ WMIParser::ClusterByClassMap& cluster ,
  114. /*[in]*/ WMIHistory::Database::ProvList& lstQueries ,
  115. /*[in]*/ bool fImpersonate );
  116. HRESULT CollectUsingTranslator ( /*[in] */ MPC::wstring& szNamespace ,
  117. /*[in] */ MPC::wstring& szWQL ,
  118. /*[out]*/ IXMLDOMDocument* *ppxddDoc );
  119. HRESULT CollectUsingEncoder ( /*[in] */ MPC::wstring& szNamespace ,
  120. /*[in] */ MPC::wstring& szWQL ,
  121. /*[out]*/ IXMLDOMDocument* *ppxddDoc );
  122. HRESULT Distribute ( /*[in] */ IXMLDOMDocument* pxddDoc ,
  123. /*[in/out]*/ QueryResults& qr ,
  124. /*[in/out]*/ WMIParser::ClusterByClassMap& cluster );
  125. HRESULT ComputeDelta ( /*[in]*/ QueryResults& qr ,
  126. /*[in]*/ WMIParser::ClusterByClassMap& cluster ,
  127. /*[in]*/ WMIHistory::Database::ProvList& lstQueries ,
  128. /*[in]*/ bool fPersist );
  129. HRESULT CollateMachineData ( /*[in] */ QueryResults& qr ,
  130. /*[in] */ WMIParser::ClusterByClassMap& cluster ,
  131. /*[in] */ MPC::wstring* pszNamespace ,
  132. /*[in] */ MPC::wstring* pszClass ,
  133. /*[in] */ bool fGenerate ,
  134. /*[out]*/ IXMLDOMDocument* *ppxddDoc );
  135. HRESULT CollateMachineDataWithTimestamp( /*[in] */ QueryResults& qr ,
  136. /*[in] */ WMIParser::ClusterByClassMap& cluster ,
  137. /*[in] */ MPC::wstring* pszNamespace ,
  138. /*[in] */ MPC::wstring* pszClass ,
  139. /*[out]*/ IXMLDOMDocument* *ppxddDoc );
  140. HRESULT CollateHistory ( /*[in] */ WMIHistory::Database& wmihdQuery ,
  141. /*[in] */ WMIHistory::Database& wmphdFilter ,
  142. /*[out]*/ IXMLDOMDocument* *ppxddDoc );
  143. //
  144. // Event firing methods.
  145. //
  146. HRESULT Fire_onStatusChange( ISAFDataCollection* hcpdc, tagDC_STATUS dsStatus );
  147. HRESULT Fire_onProgress ( ISAFDataCollection* hcpdc, LONG lDone, LONG lTotal );
  148. HRESULT Fire_onComplete ( ISAFDataCollection* hcpdc, HRESULT hrRes );
  149. //
  150. // Utility methods.
  151. //
  152. HRESULT CanModifyProperties();
  153. HRESULT IsCollectionAborted();
  154. public:
  155. HRESULT put_Status ( /*[in]*/ DC_STATUS newVal ); // INTERNAL METHOD.
  156. HRESULT try_Status ( /*[in]*/ DC_STATUS preVal, /*[in]*/ DC_STATUS postVal ); // INTERNAL METHOD.
  157. HRESULT put_ErrorCode( /*[in]*/ DWORD newVal ); // INTERNAL METHOD.
  158. // ISAFDataCollection
  159. STDMETHOD(get_Status )( /*[out]*/ DC_STATUS *pVal );
  160. STDMETHOD(get_PercentDone )( /*[out]*/ long *pVal );
  161. STDMETHOD(get_ErrorCode )( /*[out]*/ long *pVal );
  162. STDMETHOD(get_MachineData_DataSpec )( /*[out]*/ BSTR *pVal );
  163. STDMETHOD(put_MachineData_DataSpec )( /*[in] */ BSTR pVal );
  164. STDMETHOD(get_History_DataSpec )( /*[out]*/ BSTR *pVal );
  165. STDMETHOD(put_History_DataSpec )( /*[in] */ BSTR pVal );
  166. STDMETHOD(get_History_MaxDeltas )( /*[out]*/ long *pVal );
  167. STDMETHOD(put_History_MaxDeltas )( /*[in] */ long pVal );
  168. STDMETHOD(get_History_MaxSupportedDeltas)( /*[out]*/ long *pVal );
  169. STDMETHOD(put_onStatusChange )( /*[in] */ IDispatch* function );
  170. STDMETHOD(put_onProgress )( /*[in] */ IDispatch* function );
  171. STDMETHOD(put_onComplete )( /*[in] */ IDispatch* function );
  172. STDMETHOD(get_Reports )( /*[out]*/ IPCHCollection* *ppC );
  173. STDMETHOD(ExecuteSync )();
  174. STDMETHOD(ExecuteAsync)();
  175. STDMETHOD(Abort )();
  176. STDMETHOD(MachineData_GetStream)( /*[in]*/ IUnknown* *stream );
  177. STDMETHOD(History_GetStream )( /*[in]*/ IUnknown* *stream );
  178. STDMETHOD(CompareSnapshots)( /*[in]*/ BSTR bstrFilenameT0, /*[in]*/ BSTR bstrFilenameT1, /*[in]*/ BSTR bstrFilenameDiff );
  179. //////////
  180. HRESULT ExecScheduledCollection();
  181. };
  182. class ATL_NO_VTABLE CSAFDataCollectionEvents : // Hungarian: hcpdce
  183. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  184. public IDispatchImpl<DSAFDataCollectionEvents, &DIID_DSAFDataCollectionEvents, &LIBID_HelpServiceTypeLib>
  185. {
  186. ISAFDataCollection* m_hcpdc;
  187. DWORD m_dwCookie;
  188. HANDLE m_hEvent;
  189. void UnregisterForEvents( );
  190. HRESULT RegisterForEvents ( /*[in]*/ ISAFDataCollection* hcpdc );
  191. public:
  192. CSAFDataCollectionEvents();
  193. HRESULT FinalConstruct();
  194. void FinalRelease();
  195. HRESULT WaitForCompletion( /*[in]*/ ISAFDataCollection* hcpdc );
  196. BEGIN_COM_MAP(CSAFDataCollectionEvents)
  197. COM_INTERFACE_ENTRY(IDispatch)
  198. COM_INTERFACE_ENTRY(DSAFDataCollectionEvents)
  199. END_COM_MAP()
  200. public:
  201. STDMETHOD(Invoke)( /*[in] */ DISPID dispIdMember,
  202. /*[in] */ REFIID riid ,
  203. /*[in] */ LCID lcid ,
  204. /*[in] */ WORD wFlags ,
  205. /*[in/out]*/ DISPPARAMS *pDispParams ,
  206. /*[out] */ VARIANT *pVarResult ,
  207. /*[out] */ EXCEPINFO *pExcepInfo ,
  208. /*[out] */ UINT *puArgErr );
  209. };
  210. #endif // !defined(__INCLUDED___SAF___DATACOLLECTION_H___)