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.

189 lines
5.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: SMTPConn.h
  5. //
  6. // Description: Declaration of the CSMTPConn class which implements the
  7. // ISMTPConnection interface
  8. //
  9. // Author: mikeswa
  10. //
  11. // Copyright (C) 1997 Microsoft Corporation
  12. //
  13. //-----------------------------------------------------------------------------
  14. #ifndef __SMTPCONN_H_
  15. #define __SMTPCONN_H_
  16. #include <cpoolmac.h>
  17. #include <baseobj.h>
  18. #include <aqueue.h>
  19. #include "linkmsgq.h"
  20. #include "dcontext.h"
  21. class CConnMgr;
  22. class CAQSvrInst;
  23. class CInternalDomainInfo;
  24. #define SMTP_CONNECTION_SIG 'nocS'
  25. //---[ CSMTPConn ]-------------------------------------------------------------
  26. //
  27. //
  28. // Hungarian: SMTPConn, pSMTPConn
  29. //
  30. //
  31. //-----------------------------------------------------------------------------
  32. class CSMTPConn :
  33. public ISMTPConnection,
  34. public IConnectionPropertyManagement,
  35. public CBaseObject
  36. {
  37. protected:
  38. DWORD m_dwSignature;
  39. CLinkMsgQueue *m_plmq;
  40. CConnMgr *m_pConnMgr;
  41. CInternalDomainInfo *m_pIntDomainInfo;
  42. DWORD m_cFailedMsgs;
  43. DWORD m_cTriedMsgs;
  44. DWORD m_cMaxMessagesPerConnection;
  45. DWORD m_dwConnectionStatus;
  46. LPSTR m_szDomainName;
  47. DWORD m_cbDomainName;
  48. CDeliveryContext m_dcntxtCurrentDeliveryContext;
  49. LIST_ENTRY m_liConnections;
  50. DWORD m_cAcks;
  51. DWORD m_dwTickCountOfLastAck;
  52. //IP addrss protocol used to connect
  53. // enough from for IPv4 or IPv6 xxx.xxx.xxx.xxx or XX:XX:XX:XX:XX:XX:XX:XX
  54. CHAR m_szConnectedIPAddress[40];
  55. public:
  56. static CPool s_SMTPConnPool;
  57. void *operator new(size_t size);
  58. void operator delete(void *p, size_t size);
  59. CSMTPConn(CConnMgr *pConnMgr, CLinkMsgQueue *plmq, DWORD cMaxMessagesPerConnection);
  60. ~CSMTPConn();
  61. DWORD cGetFailedMsgCount() {return m_cFailedMsgs;};
  62. DWORD cGetTriedMsgCount() {return m_cTriedMsgs;};
  63. DWORD dwGetConnectionStatus() {return m_dwConnectionStatus;};
  64. inline CLinkMsgQueue *plmqGetLink();
  65. inline void InsertConnectionInList(PLIST_ENTRY pliHead);
  66. inline void RemoveConnectionFromList();
  67. LPSTR szGetConnectedIPAddress() {return m_szConnectedIPAddress;};
  68. // IUnknown
  69. public:
  70. //CBaseObject handles addref and release
  71. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj);
  72. STDMETHOD_(ULONG, AddRef)(void) {return CBaseObject::AddRef();};
  73. STDMETHOD_(ULONG, Release)(void) {return CBaseObject::Release();};
  74. // ISMTPConnection
  75. public:
  76. STDMETHOD(GetDomainInfo)(/*[in, out]*/ DomainInfo *pDomainInfo);
  77. STDMETHOD(AckConnection)(/*[in]*/ DWORD dwConnectionStatus)
  78. {m_dwConnectionStatus = dwConnectionStatus;return S_OK;};
  79. STDMETHOD(AckMessage)(/*[in]*/ MessageAck *pMsgAck);
  80. STDMETHOD(GetNextMessage)(
  81. /*[out]*/ IMailMsgProperties **ppIMailMsgProperties,
  82. /*[out]*/ DWORD **ppvMsgContext,
  83. /*[out]*/ DWORD *pcIndexes,
  84. /*[out, size_is(*pcIndexes)]*/ DWORD *prgdwRecipIndex[]);
  85. STDMETHOD(SetDiagnosticInfo)(
  86. IN HRESULT hrDiagnosticError,
  87. IN LPCSTR szDiagnosticVerb,
  88. IN LPCSTR szDiagnosticResponse);
  89. public: //IConnectionPropertyManagement
  90. STDMETHOD(CopyQueuePropertiesToSession)(
  91. IN IUnknown *pISession);
  92. STDMETHOD(CopySessionPropertiesToQueue)(
  93. IN IUnknown *pISession);
  94. };
  95. //---[ CSMTPConn::plmqGetLink ]-------------------------------------------------
  96. //
  97. //
  98. // Description:
  99. // Returns an AddRef'd link pointer for this connection. Caller must call
  100. // Release.
  101. // Parameters:
  102. // -
  103. // Returns:
  104. // link pointer for this connection (if there is one)
  105. // NULL if no link pointer
  106. // History:
  107. // 6/11/98 - MikeSwa Added check for NULL link
  108. //
  109. //-----------------------------------------------------------------------------
  110. CLinkMsgQueue *CSMTPConn::plmqGetLink()
  111. {
  112. if (m_plmq)
  113. {
  114. m_plmq->AddRef();
  115. return m_plmq;
  116. }
  117. else
  118. {
  119. return NULL;
  120. }
  121. };
  122. //---[ CSMTPConn::InsertConnectionInList ]---------------------------------------
  123. //
  124. //
  125. // Description:
  126. // Inserts link in given linked list
  127. // Parameters:
  128. // pliHead - Head of list to insert in
  129. // Returns:
  130. // -
  131. // History:
  132. // 6/16/98 - MikeSwa Created
  133. //
  134. //-----------------------------------------------------------------------------
  135. void CSMTPConn::InsertConnectionInList(PLIST_ENTRY pliHead)
  136. {
  137. _ASSERT(pliHead);
  138. _ASSERT(NULL == m_liConnections.Flink);
  139. _ASSERT(NULL == m_liConnections.Blink);
  140. InsertHeadList(pliHead, &m_liConnections);
  141. };
  142. //---[ CSMTPConn::RemoveConnectionFromList ]-------------------------------------
  143. //
  144. //
  145. // Description:
  146. // Remove link from link list
  147. // Parameters:
  148. // -
  149. // Returns:
  150. // -
  151. // History:
  152. // 6/16/98 - MikeSwa Created
  153. //
  154. //-----------------------------------------------------------------------------
  155. void CSMTPConn::RemoveConnectionFromList()
  156. {
  157. RemoveEntryList(&m_liConnections);
  158. m_liConnections.Flink = NULL;
  159. m_liConnections.Blink = NULL;
  160. };
  161. inline void *CSMTPConn::operator new(size_t size)
  162. {
  163. return s_SMTPConnPool.Alloc();
  164. }
  165. inline void CSMTPConn::operator delete(void *p, size_t size)
  166. {
  167. s_SMTPConnPool.Free(p);
  168. }
  169. #endif //__SMTPCONN_H_