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.

204 lines
9.1 KiB

  1. // --------------------------------------------------------------------------------
  2. // Ixppop3.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #ifndef __IXPPOP3_H
  7. #define __IXPPOP3_H
  8. // ------------------------------------------------------------------------------------
  9. // Depends
  10. // ------------------------------------------------------------------------------------
  11. #include "ixpbase.h"
  12. #include "asynconn.h"
  13. #include "sicily.h"
  14. // ------------------------------------------------------------------------------------
  15. // AUTHSTATE
  16. // ------------------------------------------------------------------------------------
  17. typedef enum {
  18. AUTH_NONE,
  19. AUTH_ENUMPACKS,
  20. AUTH_ENUMPACKS_DATA,
  21. AUTH_TRYING_PACKAGE,
  22. AUTH_NEGO_RESP,
  23. AUTH_RESP_RESP,
  24. AUTH_CANCELED,
  25. AUTH_SMTP_LOGIN,
  26. AUTH_SMTP_LOGIN_USERNAME,
  27. AUTH_SMTP_LOGIN_PASSWORD
  28. } AUTHSTATE;
  29. // ------------------------------------------------------------------------------------
  30. // UIDLTYPE
  31. // ------------------------------------------------------------------------------------
  32. typedef enum {
  33. UIDL_NONE,
  34. UIDL_BY_UIDL,
  35. UIDL_BY_TOP
  36. } UIDLTYPE;
  37. // ------------------------------------------------------------------------------------
  38. // FETCHINFO
  39. // ------------------------------------------------------------------------------------
  40. typedef struct tagFETCHINFO {
  41. DWORD cbSoFar; // Number of bytes downloaded so far
  42. BOOL fLastLineCRLF; // Last line ended with a CRLF
  43. BOOL fGotResponse; // First response after issuing the POP3_TOP or POP3_RETR command
  44. BOOL fHeader; // Header has been downloaded
  45. BOOL fBody; // Body has been downloaded
  46. } FETCHINFO, *LPFETCHINFO;
  47. #define MAX_AUTH_TOKENS 32
  48. // ------------------------------------------------------------------------------------
  49. // AUTHINFO
  50. // ------------------------------------------------------------------------------------
  51. typedef struct tagAUTHINFO {
  52. AUTHSTATE authstate; // Sicily Authorization State
  53. BOOL fRetryPackage; // Retry sicily package with differenty isc flags
  54. SSPICONTEXT rSicInfo; // Data used for logging onto a sicily server
  55. LPSTR rgpszAuthTokens[MAX_AUTH_TOKENS]; // AUTH security package tokens
  56. UINT cAuthToken; // count of server packages
  57. UINT iAuthToken; // current package being tried
  58. LPSSPIPACKAGE pPackages; // Array of installed security packages
  59. ULONG cPackages; // Number of installed security packages (pPackages)
  60. } AUTHINFO, *LPAUTHINFO;
  61. void FreeAuthInfo(LPAUTHINFO pAuth);
  62. // ------------------------------------------------------------------------------------
  63. // POP3INFO
  64. // ------------------------------------------------------------------------------------
  65. typedef struct tagPOP3INFO {
  66. BOOL fStatDone; // Has the stat command been issued on this session
  67. DWORD cList; // Number of messages listed in the full UIDL or LIST command
  68. DWORD cMarked; // Number of messages in the prgMarked array, set after STAT is issued
  69. LPDWORD prgMarked; // Array of marked messages
  70. FETCHINFO rFetch; // Information for the POP3_TOP or POP3_RETR command
  71. AUTHINFO rAuth; // Sicily Authorization Information
  72. POP3CMDTYPE cmdtype; // Current command type
  73. ULONG cPreviewLines; // Number of lines to retrieve on the preview command
  74. DWORD dwPopIdCurrent; // Current PopId
  75. } POP3INFO, *LPPOP3INFO;
  76. // ------------------------------------------------------------------------------------
  77. // CPOP3Transport
  78. // ------------------------------------------------------------------------------------
  79. class CPOP3Transport : public IPOP3Transport, public CIxpBase
  80. {
  81. private:
  82. POP3INFO m_rInfo; // Structure containing pop3 information
  83. POP3COMMAND m_command; // Current state
  84. BYTE m_fHotmail; // Are we connected to hotmail ?
  85. private:
  86. // Processes POP3 command responses
  87. HRESULT HrGetResponse(void);
  88. void FillRetrieveResponse(LPPOP3RESPONSE pResponse, LPSTR pszLines, ULONG cbRead, BOOL *pfMessageDone);
  89. // Response Dispatcher for general command
  90. void DispatchResponse(HRESULT hrResult, BOOL fDone=TRUE, LPPOP3RESPONSE pResponse=NULL);
  91. // Sends sicily data to the server
  92. HRESULT HrSendSicilyString(LPSTR pszData);
  93. // Build parameterized command
  94. HRESULT HrBuildParams(POP3CMDTYPE cmdtype, DWORD dwp1, DWORD dwp2);
  95. // Frees the current message array
  96. void FreeMessageArray(void);
  97. // Logon retry
  98. void LogonRetry(HRESULT hrLogon);
  99. // Socket data receive handler
  100. void OnSocketReceive(void);
  101. // Initiates the logon process
  102. void StartLogon(void);
  103. // Response Handler
  104. void ResponseAUTH(HRESULT hrResponse);
  105. void ResponseSTAT(void);
  106. void ResponseGenericList(void);
  107. void ResponseGenericRetrieve(void);
  108. void ResponseDELE(void);
  109. // Issues a parameterized command
  110. DWORD DwGetCommandMarkedFlag(POP3COMMAND command);
  111. ULONG CountMarked(POP3COMMAND command);
  112. HRESULT HrCommandGetPopId(POP3COMMAND command, DWORD dwPopId);
  113. HRESULT HrSplitPop3Response(LPSTR pszLine, LPSTR *ppszPart1, LPSTR *ppszPart2);
  114. HRESULT HrComplexCommand(POP3COMMAND command, POP3CMDTYPE cmdtype, DWORD dwPopId, ULONG cPreviewLines);
  115. HRESULT HrCommandGetNext(POP3COMMAND command, BOOL *pfDone);
  116. HRESULT HrCommandGetAll(POP3COMMAND command);
  117. BOOL FEndRetrRecvHeader(LPSTR pszLines, ULONG cbRead);
  118. HRESULT HrCancelAuthInProg();
  119. // Moved to ixputil.cpp
  120. // BOOL FEndRetrRecvBody(LPSTR pszLines, ULONG cbRead, ULONG *pcbSubtract);
  121. public:
  122. // ----------------------------------------------------------------------------
  123. // Construction
  124. // ----------------------------------------------------------------------------
  125. CPOP3Transport(void);
  126. ~CPOP3Transport(void);
  127. // ----------------------------------------------------------------------------
  128. // IUnknown methods
  129. // ----------------------------------------------------------------------------
  130. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  131. STDMETHODIMP_(ULONG) AddRef(void);
  132. STDMETHODIMP_(ULONG) Release(void);
  133. // ----------------------------------------------------------------------------
  134. // IAsyncConnCB methods
  135. // ----------------------------------------------------------------------------
  136. void OnNotify(ASYNCSTATE asOld, ASYNCSTATE asNew, ASYNCEVENT ae);
  137. // ----------------------------------------------------------------------------
  138. // IInternetTransport methods
  139. // ----------------------------------------------------------------------------
  140. STDMETHODIMP InitNew(LPSTR pszLogFilePath, IPOP3Callback *pCallback);
  141. STDMETHODIMP Connect(LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging);
  142. STDMETHODIMP DropConnection(void);
  143. STDMETHODIMP Disconnect(void);
  144. STDMETHODIMP IsState(IXPISSTATE isstate);
  145. STDMETHODIMP GetServerInfo(LPINETSERVER pInetServer);
  146. STDMETHODIMP_(IXPTYPE) GetIXPType(void);
  147. STDMETHODIMP InetServerFromAccount(IImnAccount *pAccount, LPINETSERVER pInetServer);
  148. STDMETHODIMP HandsOffCallback(void);
  149. STDMETHODIMP GetStatus(IXPSTATUS *pCurrentStatus);
  150. // ----------------------------------------------------------------------------
  151. // IPOP3Transport methods
  152. // ----------------------------------------------------------------------------
  153. STDMETHODIMP MarkItem(POP3MARKTYPE marktype, DWORD dwPopId, boolean fMarked);
  154. STDMETHODIMP CommandAUTH(LPSTR pszAuthType);
  155. STDMETHODIMP CommandUSER(LPSTR pszUserName);
  156. STDMETHODIMP CommandPASS(LPSTR pszPassword);
  157. STDMETHODIMP CommandLIST(POP3CMDTYPE cmdtype, DWORD dwPopId);
  158. STDMETHODIMP CommandTOP (POP3CMDTYPE cmdtype, DWORD dwPopId, DWORD cPreviewLines);
  159. STDMETHODIMP CommandUIDL(POP3CMDTYPE cmdtype, DWORD dwPopId);
  160. STDMETHODIMP CommandDELE(POP3CMDTYPE cmdtype, DWORD dwPopId);
  161. STDMETHODIMP CommandRETR(POP3CMDTYPE cmdtype, DWORD dwPopId);
  162. STDMETHODIMP CommandRSET(void);
  163. STDMETHODIMP CommandQUIT(void);
  164. STDMETHODIMP CommandSTAT(void);
  165. STDMETHODIMP CommandNOOP(void);
  166. // ----------------------------------------------------------------------------
  167. // CIxpBase methods
  168. // ----------------------------------------------------------------------------
  169. virtual void ResetBase(void);
  170. virtual void DoQuit(void);
  171. virtual void OnConnected(void);
  172. virtual void OnDisconnected(void);
  173. virtual void OnEnterBusy(void);
  174. virtual void OnLeaveBusy(void);
  175. };
  176. #endif // __IXPPOP3_H