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.

131 lines
4.5 KiB

  1. // Msg.h : Declaration of the CMsg
  2. #ifndef __MSG_H_
  3. #define __MSG_H_
  4. #include "imsg.h"
  5. #include "props.h"
  6. // This template is used for declaring objects on the stack. It is just like
  7. // CComObjectStack<>, except that it does not assert on Addref(), Release(), or
  8. // QueryInterface().
  9. template <class Base>
  10. class CComObjectStackLoose : public Base
  11. {
  12. public:
  13. CComObjectStackLoose() { m_dwRef=1; };
  14. ~CComObjectStackLoose() { FinalRelease(); };
  15. STDMETHOD_(ULONG, AddRef)() { return (InternalAddRef()); };
  16. STDMETHOD_(ULONG, Release)() {return (InternalRelease()); };
  17. STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
  18. { return _InternalQueryInterface(iid,ppvObject); }
  19. };
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CMsg
  22. class ATL_NO_VTABLE __declspec(uuid("2DF59670-3D15-11d1-AA51-00AA006BC80B")) CMsg :
  23. public CComObjectRoot,
  24. // public CComCoClass<CMsg, &CLSID_Msg>,
  25. public ISupportErrorInfo,
  26. public IDispatchImpl<IMsg, &IID_IMsg, &LIBID_IMSGLib>,
  27. public IMsgLog
  28. {
  29. public:
  30. HRESULT FinalConstruct();
  31. void FinalRelease();
  32. void Init(CGenericPTable *pPTable, LPVOID pDefaultContext=NULL);
  33. static HRESULT CreateInstance(CGenericPTable *pPTable, LPVOID pDefaultContext, CMsg **ppCMsg);
  34. void SetLogging(LPVOID pvLogHandle, DWORD (*pLogInformation)(LPVOID,const INETLOG_INFORMATION *));
  35. DECLARE_NOT_AGGREGATABLE(CMsg);
  36. DECLARE_PROTECT_FINAL_CONSTRUCT();
  37. // DECLARE_REGISTRY_RESOURCEID_EX(IDR_StdAfx,
  38. // L"SMTP CMsg Class",
  39. // L"SMTP.CMsg.1",
  40. // L"SMTP.CMsg");
  41. DECLARE_GET_CONTROLLING_UNKNOWN();
  42. BEGIN_COM_MAP(CMsg)
  43. COM_INTERFACE_ENTRY(IMsg)
  44. COM_INTERFACE_ENTRY(IMsgLog)
  45. COM_INTERFACE_ENTRY(IDispatch)
  46. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  47. COM_INTERFACE_ENTRY_IID(__uuidof(CMsg),CMsg)
  48. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  49. END_COM_MAP()
  50. // ISupportsErrorInfo
  51. public:
  52. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  53. // IMsg
  54. public:
  55. STDMETHOD(SetInterfaceW)(LPCWSTR pszName, IUnknown *punkValue);
  56. STDMETHOD(SetInterfaceA)(LPCSTR pszName, IUnknown *punkValue);
  57. // STDMETHOD(GetInterfaceW)(LPCWSTR pszName, IUnknown **ppunkResult);
  58. // STDMETHOD(GetInterfaceA)(LPCSTR pszName, IUnknown **ppunkResult);
  59. STDMETHOD(GetInterfaceW)(LPCWSTR pszName, const GUID &guid, IUnknown **ppunkResult);
  60. STDMETHOD(GetInterfaceA)(LPCSTR pszName, const GUID &guid, IUnknown **ppunkResult);
  61. STDMETHOD(SetDwordW)(LPCWSTR pszName, DWORD dwValue);
  62. STDMETHOD(SetDwordA)(LPCSTR pszName, DWORD dwValue);
  63. STDMETHOD(GetDwordW)(LPCWSTR pszName, DWORD *pdwResult);
  64. STDMETHOD(GetDwordA)(LPCSTR pszName, DWORD *pdwResult);
  65. STDMETHOD(SetStringW)(LPCWSTR pszName, DWORD chCount, LPCWSTR pszValue);
  66. STDMETHOD(SetStringA)(LPCSTR pszName, DWORD chCount, LPCSTR pszValue);
  67. STDMETHOD(GetStringW)(LPCWSTR pszName, DWORD *pchCount, LPWSTR pszResult);
  68. STDMETHOD(GetStringA)(LPCSTR pszName, DWORD *pchCount, LPSTR pszResult);
  69. STDMETHOD(SetVariantW)(LPCWSTR pszName, VARIANT *pvarValue);
  70. STDMETHOD(SetVariantA)(LPCSTR pszName, VARIANT *pvarValue);
  71. STDMETHOD(GetVariantW)(LPCWSTR pszName, VARIANT *pvarResult);
  72. STDMETHOD(GetVariantA)(LPCSTR pszName, VARIANT *pvarResult);
  73. STDMETHOD(get_Value)(BSTR bstrValue, /*[out, retval]*/ VARIANT *pVal);
  74. STDMETHOD(put_Value)(BSTR bstrValue, /*[in]*/ VARIANT newVal);
  75. // This method is called by the source after all sink processing
  76. // to commit all changes to the media. Only changed properties
  77. // are updated.
  78. BOOL CommitChanges() { return(m_PTable.CommitChanges() == S_OK?TRUE:FALSE); }
  79. // This method is called by the source to rollback
  80. BOOL Rollback() { return(m_PTable.Invalidate() == S_OK?TRUE:FALSE); }
  81. // IMsgLog
  82. public:
  83. STDMETHOD(WriteToLog)(LPCSTR pszClientHostName,
  84. LPCSTR pszClientUserName,
  85. LPCSTR pszServerAddress,
  86. LPCSTR pszOperation,
  87. LPCSTR pszTarget,
  88. LPCSTR pszParameters,
  89. LPCSTR pszVersion,
  90. DWORD dwBytesSent,
  91. DWORD dwBytesReceived,
  92. DWORD dwProcessingTimeMS,
  93. DWORD dwWin32Status,
  94. DWORD dwProtocolStatus,
  95. DWORD dwPort,
  96. LPCSTR pszHTTPHeader);
  97. private:
  98. // We have an instance of CPropertyTable
  99. CPropertyTable m_PTable; // Property table
  100. LPVOID m_pContext; // Context pointer
  101. CComPtr<IUnknown> m_pUnkMarshaler;
  102. DWORD (*m_pLogInformation)(LPVOID,const INETLOG_INFORMATION *);
  103. LPVOID m_pvLogHandle;
  104. };
  105. class CMsgStack : public CComObjectStackLoose<CMsg> {
  106. public:
  107. CMsgStack(CGenericPTable *pPTable, LPVOID pDefaultContext=NULL) {
  108. Init(pPTable,pDefaultContext);
  109. };
  110. };
  111. #endif //__MSG_H_