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.

110 lines
3.1 KiB

  1. #ifndef __FCONNSPC_H__
  2. #define __FCONNSPC_H__
  3. #include <wbemcli.h>
  4. #include <wbemprov.h>
  5. #include <comutl.h>
  6. #include <unk.h>
  7. #include <wmimsg.h>
  8. #include <wstring.h>
  9. /*****************************************************************************
  10. CFwdContext - we use this context object to thread information through
  11. the senders.
  12. ****************************************************************************/
  13. struct CFwdContext : public CUnk
  14. {
  15. //
  16. // is true when a successful send has been performed by an msmq sender.
  17. //
  18. BOOL m_bQueued;
  19. //
  20. // contains the name of the sender that performed a successful send.
  21. // is empty if no senders succeed.
  22. //
  23. WString m_wsTarget;
  24. //
  25. // contains the events that are indicated to the consumer. Used for
  26. // tracing.
  27. //
  28. ULONG m_cEvents;
  29. IWbemClassObject** m_apEvents;
  30. //
  31. // for each execution of a fwding consumer a new guid is created. this
  32. // allows us to correlate target trace events with a given execution.
  33. //
  34. GUID m_guidExecution;
  35. CWbemPtr<IWbemClassObject> m_pCons;
  36. CFwdContext( GUID& guidExecution,
  37. IWbemClassObject* pCons,
  38. ULONG cEvents,
  39. IWbemClassObject** apEvents )
  40. : m_guidExecution( guidExecution ), m_pCons(pCons),
  41. m_bQueued(FALSE), m_cEvents(cEvents), m_apEvents(apEvents) {}
  42. void* GetInterface( REFIID riid ) { return NULL; }
  43. };
  44. /*************************************************************************
  45. CFwdConsNamespace
  46. **************************************************************************/
  47. class CFwdConsNamespace
  48. : public CUnkBase<IWmiMessageTraceSink,&IID_IWmiMessageTraceSink>
  49. {
  50. CWbemPtr<IWbemDecoupledBasicEventProvider> m_pDES;
  51. CWbemPtr<IWbemServices> m_pSvc;
  52. CWbemPtr<IWbemEventSink> m_pTraceSuccessSink;
  53. CWbemPtr<IWbemEventSink> m_pTraceFailureSink;
  54. CWbemPtr<IWbemClassObject> m_pTargetTraceClass;
  55. CWbemPtr<IWbemClassObject> m_pTraceClass;
  56. WString m_wsName;
  57. long m_lTrace;
  58. ~CFwdConsNamespace();
  59. HRESULT InitializeTraceEventBase( IWbemClassObject* pTrace,
  60. HRESULT hres,
  61. CFwdContext* pCtx );
  62. public:
  63. HRESULT Initialize( LPCWSTR wszNamespace );
  64. IWbemServices* GetSvc() { return m_pSvc; }
  65. LPCWSTR GetName() { return m_wsName; }
  66. CFwdConsNamespace()
  67. : CUnkBase<IWmiMessageTraceSink,&IID_IWmiMessageTraceSink>(NULL),
  68. m_lTrace(0) {}
  69. void* GetInterface( REFIID riid );
  70. HRESULT NewQuery( DWORD dwId, LPWSTR wszQuery )
  71. {
  72. InterlockedIncrement(&m_lTrace);
  73. return WBEM_S_NO_ERROR;
  74. }
  75. HRESULT CancelQuery( DWORD dwId )
  76. {
  77. InterlockedDecrement( &m_lTrace );
  78. return WBEM_S_NO_ERROR;
  79. }
  80. HRESULT HandleTrace( HRESULT hres, CFwdContext* pCtx );
  81. STDMETHOD(Notify)( HRESULT hRes,
  82. GUID guidSource,
  83. LPCWSTR wszTrace,
  84. IUnknown* pContext );
  85. };
  86. #endif // __FCONNSPC_H__