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.

215 lines
7.6 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: mailadmq.h
  5. //
  6. // Description:
  7. // Header file that provides basic functionality of the QAPI for mailmsg
  8. // based links.
  9. //
  10. // All internal queues (precat, prerouting,...) are thread-pool fed
  11. // async queues of the type CAsyncAdminMailMsgQueue. This corresponds
  12. // to the concept of a "queue" (final destination).
  13. //
  14. // For each internal queue exposed by the API, there is an corresponding
  15. // CMailMsgAdminLink that represents a "link" and provides the
  16. // link-level functionality.
  17. //
  18. // Author: Gautam Pulla(GPulla)
  19. //
  20. // History:
  21. // 6/23/1999 - GPulla Created
  22. // 12/7/2000 - MikeSwa Adding CAsyncAdminMailMsgQueue
  23. // Rename CMailMsgAdminQueue to CMailMsgAdminLink
  24. //
  25. // Copyright (C) 1999, 2000 Microsoft Corporation
  26. //
  27. //-----------------------------------------------------------------------------
  28. #ifndef __MAILMSGADMQ_H__
  29. #define __MAILMSGADMQ_H__
  30. #include <asyncadm.h>
  31. //---[ CAsyncAdminMailMSgQueue ]-----------------------------------------------
  32. //
  33. //
  34. // Description:
  35. // Implements QAPI queue-level functionality that is specific to the
  36. // IMailMsgProperties object.
  37. //
  38. // Also implements handle-throttling logic on enqueue
  39. // Hungarian:
  40. // asyncmmq, pasyncmmq
  41. //
  42. //
  43. //-----------------------------------------------------------------------------
  44. class CAsyncAdminMailMsgQueue :
  45. public CAsyncAdminQueue<IMailMsgProperties *, ASYNC_QUEUE_MAILMSG_SIG>
  46. {
  47. private:
  48. //Send Delay or NDR DSN's if the message has expired
  49. HRESULT HrSendDelayOrNDR(IMailMsgProperties *pIMailMsgProperties);
  50. public:
  51. CAsyncAdminMailMsgQueue(LPCSTR szDomain, LPCSTR szLinkName,
  52. const GUID *pguid, DWORD dwID, CAQSvrInst *paqinst) :
  53. CAsyncAdminQueue<IMailMsgProperties *, ASYNC_QUEUE_MAILMSG_SIG>(szDomain,
  54. szLinkName, pguid, dwID, paqinst,
  55. HrQADMApplyActionToIMailMessages) {};
  56. //
  57. // The following methods are IMailMsgProperties specific QAPI function.
  58. // The MsgRef-specific versions of these functions are implemented by the
  59. // CMsgRef object itself
  60. //
  61. static BOOL fMatchesQueueAdminFilter(IMailMsgProperties *pIMailMsgProperties,
  62. CAQAdminMessageFilter *paqmf);
  63. static HRESULT HrGetQueueAdminMsgInfo(IMailMsgProperties *pIMailMsgProperties,
  64. MESSAGE_INFO *pMsgInfo,
  65. PVOID pvContext);
  66. protected: // Virutal functions used to implement msg specific actions
  67. virtual HRESULT HrDeleteMsgFromQueueNDR(IUnknown *pIUnknownMsg);
  68. virtual HRESULT HrDeleteMsgFromQueueSilent(IUnknown *pIUnknownMsg);
  69. virtual HRESULT HrFreezeMsg(IUnknown *pIUnknownMsg);
  70. virtual HRESULT HrThawMsg(IUnknown *pIUnknownMsg);
  71. virtual HRESULT HrGetStatsForMsg(IUnknown *pIUnknownMsg, CAQStats *paqstats);
  72. virtual HRESULT HrInternalQuerySupportedActions(
  73. DWORD *pdwSupportedActions,
  74. DWORD *pdwSupportedFilterFlags);
  75. //
  76. // Statics used to dynamically adjust mailmsg load
  77. //
  78. static DWORD s_cTotalAsyncMailMsgQs;
  79. static DWORD s_cTotalAsyncMailMsgQsBelowLowThreshold;
  80. static DWORD s_cTotalasyncMailMsgQsAboveMaxThreshold;
  81. //
  82. // The possible states for this queue to be in (depending on
  83. // how much work is left for this queue)
  84. //
  85. typedef enum _eAsyncMailMsgQThreshold
  86. {
  87. ASYNC_MAILMSG_Q_BELOW_LOW_THRESHOLD,
  88. ASYNC_MAILMSG_Q_BETWEEN_THRESHOLDS,
  89. ASYNC_MAILMSG_Q_ABOVE_MAX_THRESHOLD
  90. } eAsyncMailMsgQThreahold;
  91. public:
  92. // We override this fnct so that we can check to see if the message
  93. // has expired (and possibly NDR) before putting it in the retry queue
  94. BOOL fHandleCompletionFailure(IMailMsgProperties *pIMailMsgProperties);
  95. //Queues request & closes handles if total number of messages
  96. //in system is over the limit.
  97. HRESULT HrQueueRequest(IMailMsgProperties *pIMailMsgProperties,
  98. BOOL fRetry,
  99. DWORD cMsgsInSystem);
  100. //Since we inherit from someone who implmenents this, assert so that
  101. //a dev adding a new call later on, will use the version that
  102. //closes handles
  103. HRESULT HrQueueRequest(IMailMsgProperties *pIMailMsgProperties,
  104. BOOL fRetry = FALSE);
  105. STDMETHOD(HrApplyQueueAdminFunction)(
  106. IQueueAdminMessageFilter *pIQueueAdminMessageFilter);
  107. };
  108. #define MAIL_MSG_ADMIN_QUEUE_VALID_SIGNATURE 'QAMM'
  109. #define MAIL_MSG_ADMIN_QUEUE_INVALID_SIGNATURE '!QAM'
  110. //-----------------------------------------------------------------------------
  111. //
  112. // CMailMsgAdminLink
  113. //
  114. // Hungarian: pmmaq, mmaq
  115. //
  116. // This class is a wrapper for CAsyncAdminMailMsgQueue to provide objects of that
  117. // class (precat, prerouting) with an admin interface. Only a limited amount
  118. // of the admin functionality (compared to the locallink or other links) is
  119. // provided.
  120. //-----------------------------------------------------------------------------
  121. class CMailMsgAdminLink :
  122. public CBaseObject,
  123. public IQueueAdminAction,
  124. public IQueueAdminLink,
  125. public IAQNotify,
  126. public CQueueAdminRetryNotify
  127. {
  128. protected:
  129. DWORD m_dwSignature;
  130. GUID m_guid;
  131. DWORD m_cbQueueName;
  132. LPSTR m_szQueueName;
  133. CAsyncAdminMailMsgQueue *m_pasyncmmq;
  134. DWORD m_dwLinkType;
  135. CAQScheduleID m_aqsched;
  136. CAQSvrInst *m_paqinst;
  137. FILETIME m_ftRetry;
  138. public:
  139. CMailMsgAdminLink (GUID guid,
  140. LPSTR szLinkName,
  141. CAsyncAdminMailMsgQueue *pasyncmmq,
  142. DWORD dwLinkType,
  143. CAQSvrInst *paqinst);
  144. ~CMailMsgAdminLink();
  145. public: //IUnknown
  146. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj);
  147. STDMETHOD_(ULONG, AddRef)(void) {return CBaseObject::AddRef();};
  148. STDMETHOD_(ULONG, Release)(void) {return CBaseObject::Release();};
  149. public: //IQueueAdminAction
  150. STDMETHOD(HrApplyQueueAdminFunction)(
  151. IQueueAdminMessageFilter *pIQueueAdminMessageFilter);
  152. STDMETHOD(HrApplyActionToMessage)(
  153. IUnknown *pIUnknownMsg,
  154. MESSAGE_ACTION ma,
  155. PVOID pvContext,
  156. BOOL *pfShouldDelete);
  157. STDMETHOD_(BOOL, fMatchesID)
  158. (QUEUELINK_ID *QueueLinkID);
  159. STDMETHOD(QuerySupportedActions)(DWORD *pdwSupportedActions,
  160. DWORD *pdwSupportedFilterFlags);
  161. public: //IQueueAdminLink
  162. STDMETHOD(HrGetLinkInfo)(
  163. LINK_INFO *pliLinkInfo, HRESULT *phrDiagnosticError);
  164. STDMETHOD(HrApplyActionToLink)(
  165. LINK_ACTION la);
  166. STDMETHOD(HrGetLinkID)(
  167. QUEUELINK_ID *pLinkID);
  168. STDMETHOD(HrGetNumQueues)(
  169. DWORD *pcQueues);
  170. STDMETHOD(HrGetQueueIDs)(
  171. DWORD *pcQueues,
  172. QUEUELINK_ID *rgQueues);
  173. public: //IAQNotify
  174. virtual HRESULT HrNotify(CAQStats *aqstats, BOOL fAdd);
  175. public: //CQueueAdminRetryNotify
  176. virtual void SetNextRetry(FILETIME *pft);
  177. public:
  178. DWORD GetLinkType() { return m_dwLinkType; }
  179. BOOL fRPCCopyName(OUT LPWSTR *pwszLinkName);
  180. BOOL fIsSameScheduleID(CAQScheduleID *paqsched);
  181. };
  182. #endif __MAILMSGADMQ_H__