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.

230 lines
8.9 KiB

  1. // --------------------------------------------------------------------------------
  2. // Ixpnntp.h
  3. // Copyright (c)1993-1996 Microsoft Corporation, All Rights Reserved
  4. //
  5. // Eric Andrews
  6. // Steve Serdy
  7. // --------------------------------------------------------------------------------
  8. #ifndef __IXPNNTP_H__
  9. #define __IXPNNTP_H__
  10. #include "imnxport.h"
  11. #include "ixpbase.h"
  12. #include "asynconn.h"
  13. #include "sicily.h"
  14. #define MAX_SEC_PKGS 32 // most sec pkgs we will try
  15. // --------------------------------------------------------------------------------
  16. // Sub states that aren't exposed to the user
  17. // --------------------------------------------------------------------------------
  18. typedef enum {
  19. // These are generic substates that a lot of commands use to differenitate
  20. // between the response ("200 article follows") and the data (the actual
  21. // article text).
  22. NS_RESP,
  23. NS_DATA,
  24. // These substates are specific to handling posting
  25. NS_SEND_ENDPOST,
  26. NS_ENDPOST_RESP,
  27. // These substates are specific to connecting or authorizing
  28. NS_CONNECT_RESP, // awaiting the banner that is sent after a connection is made
  29. NS_MODE_READER_RESP, // awaiting MODE READER response
  30. NS_GENERIC_TEST, // awaiting AUTHINFO GENERIC response
  31. NS_GENERIC_PKG_DATA, // awaiting AUTHINFO_GENERIC data
  32. NS_TRANSACT_TEST, // awaiting AUTHINFO TRANSACT TEST response
  33. NS_TRANSACT_PACKAGE, // awaiting AUTHINFO TRANSACT <package> response
  34. NS_TRANSACT_NEGO, // awaiting AUTHINFO TRANSACT <negotiation> response
  35. NS_TRANSACT_RESP, // awaiting AUTHINFO TRANSACT <response> response
  36. NS_AUTHINFO_USER_RESP, // awaiting AUTHINFO USER XXXX response
  37. NS_AUTHINFO_PASS_RESP, // awaiting AUTHINFO PASS XXXX response
  38. NS_AUTHINFO_SIMPLE_RESP, // awaiting AUTHINFO SIMPLE response
  39. NS_AUTHINFO_SIMPLE_USERPASS_RESP,
  40. NS_RECONNECTING // in the process of doing an internal reconnect
  41. } NNTPSUBSTATE;
  42. typedef enum {
  43. AUTHINFO_NONE = 0,
  44. AUTHINFO_GENERIC,
  45. AUTHINFO_TRANSACT,
  46. } AUTH_TYPE;
  47. typedef enum {
  48. GETHDR_XOVER,
  49. GETHDR_XHDR
  50. } GETHDR_TYPE;
  51. enum {
  52. HDR_SUBJECT = 0,
  53. HDR_FROM,
  54. HDR_DATE,
  55. HDR_MSGID,
  56. HDR_REFERENCES,
  57. HDR_LINES,
  58. HDR_XREF,
  59. HDR_MAX
  60. };
  61. typedef struct tagMEMORYINFO
  62. {
  63. DWORD cPointers;
  64. LPVOID rgPointers[1];
  65. } MEMORYINFO, *PMEMORYINFO;
  66. class CNNTPTransport : public INNTPTransport2, public CIxpBase
  67. {
  68. public:
  69. // ----------------------------------------------------------------------------
  70. // Contstruction
  71. // ----------------------------------------------------------------------------
  72. CNNTPTransport(void);
  73. ~CNNTPTransport(void);
  74. // ----------------------------------------------------------------------------
  75. // IUnknown methods
  76. // ----------------------------------------------------------------------------
  77. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  78. STDMETHODIMP_(ULONG) AddRef(void);
  79. STDMETHODIMP_(ULONG) Release(void);
  80. // ----------------------------------------------------------------------------
  81. // IAsyncConnCB methods
  82. // ----------------------------------------------------------------------------
  83. void OnNotify(ASYNCSTATE asOld, ASYNCSTATE asNew, ASYNCEVENT ae);
  84. // ----------------------------------------------------------------------------
  85. // IInternetTransport methods
  86. // ----------------------------------------------------------------------------
  87. STDMETHODIMP InitNew(LPSTR pszLogFilePath, INNTPCallback *pCallback);
  88. STDMETHODIMP InetServerFromAccount(IImnAccount *pAccount, LPINETSERVER pInetServer);
  89. STDMETHODIMP Connect(LPINETSERVER pInetServer, boolean fAuthenticate, boolean fCommandLogging);
  90. STDMETHODIMP DropConnection(void);
  91. STDMETHODIMP Disconnect(void);
  92. STDMETHODIMP Stop(void);
  93. STDMETHODIMP IsState(IXPISSTATE isstate);
  94. STDMETHODIMP GetServerInfo(LPINETSERVER pInetServer);
  95. STDMETHODIMP_(IXPTYPE) GetIXPType(void);
  96. STDMETHODIMP HandsOffCallback(void);
  97. STDMETHODIMP GetStatus(IXPSTATUS *pCurrentStatus);
  98. // ----------------------------------------------------------------------------
  99. // INNTPTransport2 methods
  100. // ----------------------------------------------------------------------------
  101. STDMETHODIMP SetWindow(void);
  102. STDMETHODIMP ResetWindow(void);
  103. // ----------------------------------------------------------------------------
  104. // CIxpBase methods
  105. // ----------------------------------------------------------------------------
  106. virtual void ResetBase(void);
  107. virtual void DoQuit(void);
  108. virtual void OnConnected(void);
  109. virtual void OnDisconnected(void);
  110. virtual void OnEnterBusy(void);
  111. virtual void OnLeaveBusy(void);
  112. // ----------------------------------------------------------------------------
  113. // INNTPTransport methods
  114. // ----------------------------------------------------------------------------
  115. STDMETHODIMP CommandAUTHINFO(LPNNTPAUTHINFO pAuthInfo);
  116. STDMETHODIMP CommandGROUP(LPSTR pszGroup);
  117. STDMETHODIMP CommandLAST(void);
  118. STDMETHODIMP CommandNEXT(void);
  119. STDMETHODIMP CommandSTAT(LPARTICLEID pArticleId);
  120. STDMETHODIMP CommandARTICLE(LPARTICLEID pArticleId);
  121. STDMETHODIMP CommandHEAD(LPARTICLEID pArticleId);
  122. STDMETHODIMP CommandBODY(LPARTICLEID pArticleId);
  123. STDMETHODIMP CommandPOST(LPNNTPMESSAGE pMessage);
  124. STDMETHODIMP CommandLIST(LPSTR pszArgs);
  125. STDMETHODIMP CommandLISTGROUP(LPSTR pszGroup);
  126. STDMETHODIMP CommandNEWGROUPS(SYSTEMTIME *pstLast, LPSTR pszDist);
  127. STDMETHODIMP CommandDATE(void);
  128. STDMETHODIMP CommandMODE(LPSTR pszMode);
  129. STDMETHODIMP CommandXHDR(LPSTR pszHeader, LPRANGE pRange, LPSTR pszMessageId);
  130. STDMETHODIMP CommandQUIT(void);
  131. STDMETHODIMP GetHeaders(LPRANGE pRange);
  132. STDMETHODIMP ReleaseResponse(LPNNTPRESPONSE pResp);
  133. private:
  134. // ----------------------------------------------------------------------------
  135. // Private Member functions
  136. // ----------------------------------------------------------------------------
  137. void OnSocketReceive(void);
  138. void DispatchResponse(HRESULT hrResult, BOOL fDone=TRUE, LPNNTPRESPONSE pResponse=NULL);
  139. HRESULT HrGetResponse(void);
  140. void StartLogon(void);
  141. HRESULT LogonRetry(HRESULT hrLogon);
  142. HRESULT TryNextSecPkg(void);
  143. HRESULT MaybeTryAuthinfo(void);
  144. HRESULT HandleConnectResponse(void);
  145. HRESULT ProcessGenericTestResponse(void);
  146. HRESULT ProcessTransactTestResponse(void);
  147. HRESULT ProcessGroupResponse(void);
  148. HRESULT ProcessNextResponse(void);
  149. HRESULT ProcessListData(void);
  150. HRESULT ProcessListGroupData(void);
  151. HRESULT ProcessDateResponse(void);
  152. HRESULT ProcessArticleData(void);
  153. HRESULT ProcessXoverData(void);
  154. HRESULT ProcessXhdrData(void);
  155. HRESULT BuildHeadersFromXhdr(BOOL fFirst);
  156. LPSTR GetNextField(LPSTR pszField);
  157. HRESULT SendNextXhdrCommand(void);
  158. HRESULT ProcessNextXhdrResponse(BOOL* pfDone);
  159. HRESULT HrPostMessage(void);
  160. // ----------------------------------------------------------------------------
  161. // Private member variables
  162. // ----------------------------------------------------------------------------
  163. // Various state variables
  164. NNTPSTATE m_state;
  165. NNTPSUBSTATE m_substate;
  166. GETHDR_TYPE m_gethdr;
  167. DWORD m_hdrtype;
  168. // Sicily information
  169. SSPICONTEXT m_sicinfo;
  170. SSPIBUFFER m_sicmsg;
  171. int m_cSecPkg; // number of sec pkgs to try, -1 if not inited
  172. int m_iSecPkg; // current sec pkg being tried
  173. AUTH_TYPE m_iAuthType;
  174. LPSTR m_rgszSecPkg[MAX_SEC_PKGS]; // pointers into m_szSecPkgs
  175. LPSTR m_szSecPkgs; // string returned by "AUTHINFO TRANSACT TEST"
  176. BOOL m_fRetryPkg;
  177. // From the GetHeaders() command in case the XOVER request fails
  178. RANGE m_rRange;
  179. RANGE m_rRangeCur;
  180. LPNNTPHEADER m_rgHeaders;
  181. DWORD m_iHeader;
  182. DWORD m_cHeaders;
  183. PMEMORYINFO m_pMemInfo;
  184. // Posting
  185. NNTPMESSAGE m_rMessage;
  186. // Flags
  187. BOOL m_fSupportsXRef; // TRUE if this server's XOver records contain the XRef: field
  188. BOOL m_fNoXover; // TRUE if the server does not support XOVER
  189. // Connection info
  190. HRESULT m_hrPostingAllowed;
  191. // Authentication
  192. LPNNTPAUTHINFO m_pAuthInfo;
  193. };
  194. #endif // __IXPNNTP_H__