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.

279 lines
7.0 KiB

  1. //+------------------------------------------------------------
  2. //
  3. // Copyright (C) 2001, Microsoft Corporation
  4. //
  5. // File: dsninternal.h
  6. //
  7. // Contents: Classes used internally in the DSN code
  8. //
  9. // Classes:
  10. //
  11. // Functions:
  12. //
  13. // History:
  14. // jstamerj 2001/05/10 20:34:19: Created.
  15. //
  16. //-------------------------------------------------------------
  17. #ifndef __DSNINTERNAL_H__
  18. #define __DSNINTERNAL_H__
  19. #define RECIPITER_SIG (DWORD)'IpRD'
  20. #define RECIPITER_SIG_INVALID (DWORD)'XpRD'
  21. //
  22. // The default implementation of the DSN Recipient iterator
  23. //
  24. class CDefaultDSNRecipientIterator :
  25. public IDSNRecipientIterator
  26. {
  27. public: //IUnknown
  28. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj);
  29. //
  30. // This class is allocated as a part of another object. Pass
  31. // AddRef/Release to the parent object
  32. //
  33. STDMETHOD_(ULONG, AddRef)(void)
  34. {
  35. return m_pUnk->AddRef();
  36. }
  37. STDMETHOD_(ULONG, Release)(void)
  38. {
  39. return m_pUnk->Release();
  40. }
  41. public:
  42. STDMETHOD(HrReset) ();
  43. STDMETHOD(HrGetNextRecipient) (
  44. OUT DWORD *piRecipient,
  45. OUT DWORD *pdwDSNAction);
  46. STDMETHOD(HrNotifyActionHandled) (
  47. IN DWORD iRecipient,
  48. IN DWORD dwDSNAction);
  49. public:
  50. CDefaultDSNRecipientIterator(
  51. IUnknown *pUnk)
  52. {
  53. m_dwStartDomain = 0;
  54. m_dwDSNActions = 0;
  55. m_pIRecips = NULL;
  56. m_fFilterInit = NULL;
  57. m_pUnk = pUnk;
  58. m_dwSig = RECIPITER_SIG;
  59. }
  60. ~CDefaultDSNRecipientIterator();
  61. HRESULT HrInit(
  62. IN IMailMsgProperties *pIMsg,
  63. IN DWORD dwStartDomain,
  64. IN DWORD dwDSNActions);
  65. private:
  66. VOID GetFilterMaskAndFlags(
  67. IN DWORD dwDSNActions,
  68. OUT DWORD *pdwRecipMask,
  69. OUT DWORD *pdwRecipFlags);
  70. VOID GetDSNAction(
  71. IN DWORD dwDSNAction,
  72. IN DWORD dwCurrentRecipFlags,
  73. OUT DWORD *pdwCurrentDSNAction);
  74. VOID GetRecipientFlagsForActions(
  75. IN DWORD dwDSNAction,
  76. OUT DWORD *pdwRecipientFlags);
  77. VOID TerminateFilter();
  78. private:
  79. DWORD m_dwSig;
  80. IUnknown *m_pUnk;
  81. DWORD m_dwStartDomain;
  82. DWORD m_dwDSNActions;
  83. IMailMsgRecipients *m_pIRecips;
  84. BOOL m_fFilterInit;
  85. RECIPIENT_FILTER_CONTEXT m_rpfctxt;
  86. };
  87. class CPostDSNHandler :
  88. public IDSNSubmission
  89. {
  90. #define SIGNATURE_CPOSTDSNHANDLER (DWORD)'SDPC'
  91. #define SIGNATURE_CPOSTDSNHANDLER_INVALID (DWORD)'SDPX'
  92. public:
  93. CPostDSNHandler(
  94. IN IUnknown *pUnk,
  95. IN CDSNGenerator *pDSNGenerator,
  96. IN IAQServerEvent *pIServerEvent,
  97. IN DWORD dwVSID,
  98. IN ISMTPServer *pISMTPServer,
  99. IN IMailMsgProperties *pIMsgOrig,
  100. IN IDSNSubmission *pIAQDSNSubmission,
  101. IN IDSNGenerationSink *pDefaultSink);
  102. ~CPostDSNHandler();
  103. VOID SetPropInterface(
  104. IN IMailMsgPropertyBag *pIDSNProps)
  105. {
  106. if(m_pIDSNProps)
  107. m_pIDSNProps->Release();
  108. m_pIDSNProps = pIDSNProps;
  109. m_pIDSNProps->AddRef();
  110. }
  111. VOID ReleaseAQDSNSubmission()
  112. {
  113. if(m_pIAQDSNSubmission)
  114. {
  115. m_pIAQDSNSubmission->Release();
  116. m_pIAQDSNSubmission = NULL;
  117. }
  118. }
  119. public:
  120. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj);
  121. //
  122. // This class is allocated as a part of another object. Pass
  123. // AddRef/Release to the parent object
  124. //
  125. STDMETHOD_(ULONG, AddRef)(void)
  126. {
  127. return m_pUnk->AddRef();
  128. }
  129. STDMETHOD_(ULONG, Release)(void)
  130. {
  131. return m_pUnk->Release();
  132. }
  133. STDMETHOD(HrAllocBoundMessage)(
  134. OUT IMailMsgProperties **ppMsg,
  135. OUT PFIO_CONTEXT *phContent);
  136. STDMETHOD(HrSubmitDSN)(
  137. IN DWORD dwDSNAction,
  138. IN DWORD cRecipsDSNd,
  139. IN IMailMsgProperties *pDSNMsg);
  140. private:
  141. DWORD m_dwSig;
  142. IUnknown *m_pUnk;
  143. CDSNGenerator *m_pDSNGenerator;
  144. IAQServerEvent *m_pIServerEvent;
  145. DWORD m_dwVSID;
  146. ISMTPServer *m_pISMTPServer;
  147. IMailMsgProperties *m_pIMsgOrig;
  148. IMailMsgPropertyBag *m_pIDSNProps;
  149. IDSNSubmission *m_pIAQDSNSubmission;
  150. IDSNGenerationSink *m_pDefaultSink;
  151. };
  152. //
  153. // The class will control the refcounting and lifetime of all the
  154. // per-DSN classes
  155. //
  156. #define SIGNATURE_CDSNPOOL (DWORD)'PSDC'
  157. #define SIGNATURE_CDSNPOOL_INVALID (DWORD)'PSDX'
  158. class CDSNPool :
  159. public IUnknown
  160. {
  161. public:
  162. //
  163. // Disable the warning that we are using "this" in the
  164. // constructor. Since All we do is save the pointer for later
  165. // use, we are safe.
  166. //
  167. #pragma warning( disable : 4355)
  168. CDSNPool(
  169. IN CDSNGenerator *pDSNGenerator,
  170. IN IAQServerEvent *pIServerEvent,
  171. IN DWORD dwVSID,
  172. IN ISMTPServer *pISMTPServer,
  173. IN IMailMsgProperties *pIMsgOrig,
  174. IN IDSNSubmission *pIAQDSNSubmission,
  175. IN IDSNGenerationSink *pDefaultSink) :
  176. m_DefaultRecipIter(this),
  177. m_PostDSNHandler(
  178. this,
  179. pDSNGenerator,
  180. pIServerEvent,
  181. dwVSID,
  182. pISMTPServer,
  183. pIMsgOrig,
  184. pIAQDSNSubmission,
  185. pDefaultSink)
  186. {
  187. m_dwSig = SIGNATURE_CDSNPOOL;
  188. m_lRef = 1;
  189. }
  190. #pragma warning( default : 4355 )
  191. ~CDSNPool()
  192. {
  193. _ASSERT(m_dwSig == SIGNATURE_CDSNPOOL);
  194. m_dwSig = SIGNATURE_CDSNPOOL_INVALID;
  195. }
  196. void *operator new(size_t size)
  197. {
  198. return sm_Pool.Alloc();
  199. }
  200. void operator delete(void *p, size_t size)
  201. {
  202. return sm_Pool.Free(p);
  203. }
  204. public:
  205. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj)
  206. {
  207. if(riid == IID_IUnknown)
  208. {
  209. *ppvObj = (IUnknown *)this;
  210. AddRef();
  211. return S_OK;
  212. }
  213. else
  214. {
  215. return E_NOINTERFACE;
  216. }
  217. }
  218. STDMETHOD_(ULONG, AddRef)(void)
  219. {
  220. return InterlockedIncrement(&m_lRef);
  221. }
  222. STDMETHOD_(ULONG, Release)(void)
  223. {
  224. ULONG ulRet = InterlockedDecrement(&m_lRef);
  225. if(ulRet == 0)
  226. {
  227. delete this;
  228. }
  229. return ulRet;
  230. }
  231. CDefaultDSNRecipientIterator * GetDefaultIter()
  232. {
  233. return &m_DefaultRecipIter;
  234. }
  235. CPostDSNHandler * GetPostDSNHandler()
  236. {
  237. return &m_PostDSNHandler;
  238. }
  239. CMailMsgPropertyBag * GetDSNProperties()
  240. {
  241. return &m_PropBag;
  242. }
  243. static HRESULT HrStaticInit();
  244. static VOID StaticDeinit();
  245. private:
  246. static CPool sm_Pool;
  247. DWORD m_dwSig;
  248. LONG m_lRef;
  249. CDefaultDSNRecipientIterator m_DefaultRecipIter;
  250. CPostDSNHandler m_PostDSNHandler;
  251. CMailMsgPropertyBag m_PropBag;
  252. };
  253. #endif //__DSNINTERNAL_H__