home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / include / afxinet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  20.4 KB  |  708 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFXINET_H_
  12. #define __AFXINET_H_
  13.  
  14. #ifndef __AFX_H__
  15.     #include <afx.h>
  16. #endif
  17.  
  18. #ifndef _WININET_
  19. #include <wininet.h>
  20. #endif
  21.  
  22. #if defined(_WIN32_WCE)
  23. #pragma comment(lib, WCE_WININET_LIB)
  24. #else // _WIN32_WCE
  25. #pragma comment(lib, "wininet.lib")
  26. #endif // _WIN32_WCE
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // classes that are declared in this file
  30.  
  31. class CInternetSession; // from CObject
  32.  
  33. class CGopherLocator;   // from CObject
  34.  
  35. class CInternetFile;    // from CStdioFile (FILETXT.CPP)
  36.     class CHttpFile;
  37.     class CGopherFile;
  38.  
  39. class CInternetConnection;
  40.     class CFtpConnection;
  41.     class CGopherConnection;
  42.     class CHttpConnection;
  43.  
  44. class CFtpFileFind;     // from CFileFind (FILEFIND.CPP)
  45. class CGopherFileFind;
  46.  
  47. class CInternetException;
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50.  
  51. #undef AFX_DATA
  52. #define AFX_DATA AFX_CORE_DATA
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Global Functions
  56.  
  57. BOOL AFXAPI AfxParseURL(LPCTSTR pstrURL, DWORD& dwServiceType,
  58.     CString& strServer, CString& strObject, INTERNET_PORT& nPort);
  59. BOOL AFXAPI AfxParseURLEx(LPCTSTR pstrURL, DWORD& dwServiceType,
  60.     CString& strServer, CString& strObject, INTERNET_PORT& nPort,
  61.     CString& strUsername, CString& strPassword, DWORD dwFlags = 0);
  62.  
  63. DWORD AFXAPI AfxGetInternetHandleType(HINTERNET hQuery);
  64.  
  65. // see CInternetException at the bottom of this file
  66.  
  67. void AFXAPI AfxThrowInternetException(DWORD dwContext, DWORD dwError = 0);
  68.  
  69. // these are defined by WININET.H
  70.  
  71. #define AFX_INET_SERVICE_FTP        INTERNET_SERVICE_FTP
  72. #define AFX_INET_SERVICE_HTTP       INTERNET_SERVICE_HTTP
  73. #define AFX_INET_SERVICE_GOPHER     INTERNET_SERVICE_GOPHER
  74.  
  75. // these are types that MFC parsing functions understand
  76.  
  77. #define AFX_INET_SERVICE_UNK        0x1000
  78. #define AFX_INET_SERVICE_FILE       (AFX_INET_SERVICE_UNK+1)
  79. #define AFX_INET_SERVICE_MAILTO     (AFX_INET_SERVICE_UNK+2)
  80. #define AFX_INET_SERVICE_MID        (AFX_INET_SERVICE_UNK+3)
  81. #define AFX_INET_SERVICE_CID        (AFX_INET_SERVICE_UNK+4)
  82. #define AFX_INET_SERVICE_NEWS       (AFX_INET_SERVICE_UNK+5)
  83. #define AFX_INET_SERVICE_NNTP       (AFX_INET_SERVICE_UNK+6)
  84. #define AFX_INET_SERVICE_PROSPERO   (AFX_INET_SERVICE_UNK+7)
  85. #define AFX_INET_SERVICE_TELNET     (AFX_INET_SERVICE_UNK+8)
  86. #define AFX_INET_SERVICE_WAIS       (AFX_INET_SERVICE_UNK+9)
  87. #define AFX_INET_SERVICE_AFS        (AFX_INET_SERVICE_UNK+10)
  88. #define AFX_INET_SERVICE_HTTPS      (AFX_INET_SERVICE_UNK+11)
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. // classes that are declared in this file
  92.  
  93. class CInternetSession : public CObject
  94. {
  95. public:
  96.     CInternetSession(LPCTSTR pstrAgent = NULL,
  97.         DWORD dwContext = 1,
  98.         DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS,
  99.         LPCTSTR pstrProxyName = NULL,
  100.         LPCTSTR pstrProxyBypass = NULL,
  101.         DWORD dwFlags = 0);
  102.  
  103.     BOOL QueryOption(DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufLen) const;
  104.     BOOL QueryOption(DWORD dwOption, DWORD& dwValue) const;
  105.     BOOL QueryOption(DWORD dwOption, CString& refString) const;
  106.  
  107.     BOOL SetOption(DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength,
  108.             DWORD dwFlags = 0);
  109.     BOOL SetOption(DWORD dwOption, DWORD dwValue, DWORD dwFlags = 0);
  110.  
  111.     CStdioFile* OpenURL(LPCTSTR pstrURL,
  112.         DWORD dwContext = 1, DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII,
  113.         LPCTSTR pstrHeaders = NULL, DWORD dwHeadersLength = 0);
  114.  
  115.     CFtpConnection* GetFtpConnection(LPCTSTR pstrServer,
  116.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  117.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  118.         BOOL bPassive = FALSE);
  119.  
  120.     CHttpConnection* GetHttpConnection(LPCTSTR pstrServer,
  121.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  122.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL);
  123.     CHttpConnection* GetHttpConnection(LPCTSTR pstrServer, DWORD dwFlags,
  124.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  125.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL);
  126.  
  127.     CGopherConnection* GetGopherConnection(LPCTSTR pstrServer,
  128.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  129.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
  130.  
  131.     BOOL EnableStatusCallback(BOOL bEnable = TRUE);
  132.  
  133.     DWORD ServiceTypeFromHandle(HINTERNET hQuery);
  134.  
  135. // operations
  136.  
  137.     DWORD GetContext() const;
  138.     operator HINTERNET() const;
  139.     virtual void Close();
  140.  
  141.     // cookies
  142. WCE_DEL    static BOOL SetCookie(LPCSTR pstrUrl, LPCTSTR pstrCookieName, LPCTSTR pstrCookieData);
  143. WCE_DEL    static BOOL GetCookie(LPCSTR pstrUrl, LPCTSTR pstrCookieName, LPTSTR pstrCookieData, DWORD dwBufLen);
  144. WCE_DEL    static DWORD GetCookieLength(LPCSTR pstrUrl, LPCTSTR pstrCookieName);
  145. WCE_DEL    static BOOL GetCookie(LPCSTR pstrUrl, LPCTSTR pstrCookieName, CString& strCookieData);
  146.  
  147. // overridables
  148.     virtual void OnStatusCallback(DWORD dwContext, DWORD dwInternetStatus,
  149.         LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
  150.  
  151. // implementation
  152.     DECLARE_DYNAMIC(CInternetSession)
  153.     ~CInternetSession();
  154.  
  155. protected:
  156.     DWORD m_dwContext;
  157.     HINTERNET m_hSession;
  158.     INTERNET_STATUS_CALLBACK m_pOldCallback;
  159.     BOOL m_bCallbackEnabled;
  160.  
  161. public:
  162. #ifdef _DEBUG
  163.     virtual void Dump(CDumpContext& dc) const;
  164. #endif
  165. };
  166.  
  167.  
  168. ////////////////////////////////////////////////////////////////////////////
  169. // Internet File Access Wrapper
  170.  
  171. class CInternetFile : public CStdioFile
  172. {
  173. // Constructors
  174. protected:
  175.     CInternetFile(HINTERNET hFile, LPCTSTR pstrFileName,
  176.         CInternetConnection* pConnection, BOOL bReadMode);
  177.     CInternetFile(HINTERNET hFile, HINTERNET hSession,
  178.         LPCTSTR pstrFileName, LPCTSTR pstrServer, DWORD dwContext,
  179.         BOOL bReadMode);
  180.  
  181. // Attributes
  182. protected:
  183.     HINTERNET m_hFile;
  184. public:
  185.     operator HINTERNET() const;
  186.     DWORD GetContext() const;
  187.  
  188. // Operations
  189. WCE_DEL BOOL SetWriteBufferSize(UINT nWriteSize);
  190.     BOOL SetReadBufferSize(UINT nReadSize);
  191.  
  192.     BOOL QueryOption(DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufLen) const;
  193.     BOOL QueryOption(DWORD dwOption, DWORD& dwValue) const;
  194.     BOOL QueryOption(DWORD dwOption, CString& refString) const;
  195.  
  196.     BOOL SetOption(DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength,
  197.             DWORD dwFlags = 0);
  198.     BOOL SetOption(DWORD dwOption, DWORD dwValue, DWORD dwFlags = 0);
  199.  
  200. // Overridables
  201. WCE_DEL virtual LONG Seek(LONG lOffset, UINT nFrom);
  202.  
  203.     virtual UINT Read(void* lpBuf, UINT nCount);
  204. WCE_DEL virtual void Write(const void* lpBuf, UINT nCount);
  205.  
  206.     virtual void Abort();
  207. WCE_DEL virtual void Flush();
  208.  
  209.     virtual void Close();
  210.     virtual DWORD GetLength() const;
  211.  
  212.     virtual BOOL ReadString(CString& rString);
  213.     virtual LPTSTR ReadString(LPTSTR pstr, UINT nMax);
  214. WCE_DEL virtual void WriteString(LPCTSTR pstr);
  215.  
  216.     // Not supported by CInternetFile
  217.     void LockRange(DWORD dwPos, DWORD dwCount);
  218.     void UnlockRange(DWORD dwPos, DWORD dwCount);
  219.     CFile* Duplicate() const;
  220.     virtual void SetLength(DWORD dwNewLen);
  221.  
  222. // Implementation
  223. public:
  224.     virtual ~CInternetFile();
  225.  
  226. protected:
  227.     BOOL m_bReadMode;
  228.     DWORD m_dwContext;
  229.     HINTERNET m_hConnection;
  230.  
  231.     CString m_strServerName;
  232.  
  233.     UINT m_nWriteBufferSize;
  234.     UINT m_nWriteBufferPos;
  235.     LPBYTE m_pbWriteBuffer;
  236.  
  237.     UINT m_nReadBufferSize;
  238.     UINT m_nReadBufferPos;
  239.     LPBYTE m_pbReadBuffer;
  240.     UINT m_nReadBufferBytes;
  241.  
  242. #ifdef _DEBUG
  243.     virtual void AssertValid() const;
  244.     virtual void Dump(CDumpContext& dc) const;
  245. #endif
  246.  
  247.     friend class CInternetSession;
  248.     friend class CFtpConnection;
  249.     friend class CHttpConnection;
  250.     friend class CGopherConnection;
  251.     DECLARE_DYNAMIC(CInternetFile)
  252. };
  253.  
  254.  
  255. class CHttpFile : public CInternetFile
  256. {
  257. // Constructors
  258. protected:
  259.     CHttpFile(HINTERNET hFile, HINTERNET hSession, LPCTSTR pstrObject,
  260.         LPCTSTR pstrServer, LPCTSTR pstrVerb, DWORD dwContext);
  261.     CHttpFile(HINTERNET hFile, LPCTSTR pstrVerb, LPCTSTR pstrObject,
  262.         CHttpConnection* pConnection);
  263.  
  264. // Operations
  265. public:
  266.     BOOL AddRequestHeaders(LPCTSTR pstrHeaders,
  267.         DWORD dwFlags = HTTP_ADDREQ_FLAG_ADD_IF_NEW, int dwHeadersLen = -1);
  268.     BOOL AddRequestHeaders(CString& str,
  269.         DWORD dwFlags = HTTP_ADDREQ_FLAG_ADD_IF_NEW);
  270.  
  271.     BOOL SendRequest(LPCTSTR pstrHeaders = NULL, DWORD dwHeadersLen = 0,
  272.         LPVOID lpOptional = NULL, DWORD dwOptionalLen = 0);
  273.     BOOL SendRequest(CString& strHeaders,
  274.         LPVOID lpOptional = NULL, DWORD dwOptionalLen = 0);
  275. #if !defined(_WIN32_WCE)
  276.     BOOL SendRequestEx(DWORD dwTotalLen,
  277.         DWORD dwFlags = HSR_INITIATE,    DWORD dwContext = 1);
  278.     BOOL SendRequestEx(LPINTERNET_BUFFERS lpBuffIn,
  279.         LPINTERNET_BUFFERS lpBuffOut, DWORD dwFlags = HSR_INITIATE,
  280.         DWORD dwContext = 1);
  281.     BOOL EndRequest(DWORD dwFlags = 0,
  282.         LPINTERNET_BUFFERS lpBuffIn = NULL, DWORD dwContext = 1);
  283. #endif // _WIN32_WCE
  284.     BOOL QueryInfo(DWORD dwInfoLevel, LPVOID lpvBuffer,
  285.         LPDWORD lpdwBufferLength, LPDWORD lpdwIndex = NULL) const;
  286.     BOOL QueryInfo(DWORD dwInfoLevel, CString& str,
  287.         LPDWORD dwIndex = NULL) const;
  288.     BOOL QueryInfo(DWORD dwInfoLevel, SYSTEMTIME* pSysTime,
  289.         LPDWORD dwIndex = NULL) const;
  290.     BOOL QueryInfo(DWORD dwInfoLevel, DWORD& dwResult,
  291.         LPDWORD dwIndex = NULL) const;
  292.     BOOL QueryInfoStatusCode(DWORD& dwStatusCode) const;
  293.  
  294. #if !defined(_WIN32_WCE)
  295.     DWORD ErrorDlg(CWnd* pParent = NULL,
  296.         DWORD dwError = ERROR_INTERNET_INCORRECT_PASSWORD,
  297.         DWORD dwFlags = FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
  298.         LPVOID* lppvData = NULL);
  299. #endif // _WIN32_WCE
  300.  
  301. // Attributes
  302. public:
  303.     CString GetVerb() const;
  304.     CString GetObject() const;
  305.     virtual CString GetFileURL() const;
  306.     virtual void Close();
  307.  
  308. // Implementation
  309. public:
  310.     virtual ~CHttpFile();
  311. protected:
  312.     CString m_strObject;
  313.     CString m_strVerb;
  314.  
  315. #ifdef _DEBUG
  316.     virtual void AssertValid() const;
  317.     virtual void Dump(CDumpContext& dc) const;
  318. #endif
  319.  
  320.     friend class CHttpConnection;
  321.     friend class CInternetSession;
  322.     DECLARE_DYNAMIC(CHttpFile)
  323. };
  324.  
  325. // class CGopherFile is declared after CGopherLocator, below
  326.  
  327.  
  328. ////////////////////////////////////////////////////////////////////////////
  329. // Connection types
  330.  
  331. class CInternetConnection : public CObject
  332. {
  333. public:
  334.     CInternetConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  335.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  336.         DWORD dwContext = 1);
  337.  
  338. // Operations
  339.     operator HINTERNET() const;
  340.     DWORD GetContext() const;
  341.     CInternetSession* GetSession() const;
  342.  
  343.     CString GetServerName() const;
  344.  
  345.     BOOL QueryOption(DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufLen) const;
  346.     BOOL QueryOption(DWORD dwOption, DWORD& dwValue) const;
  347.     BOOL QueryOption(DWORD dwOption, CString& refString) const;
  348.  
  349.     BOOL SetOption(DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength,
  350.             DWORD dwFlags = 0);
  351.     BOOL SetOption(DWORD dwOption, DWORD dwValue, DWORD dwFlags = 0);
  352.  
  353. // Implementation
  354. protected:
  355.     HINTERNET m_hConnection;
  356.     DWORD m_dwContext;
  357.     CInternetSession* m_pSession;
  358.     virtual void Close();
  359.  
  360.     CString m_strServerName;
  361.     INTERNET_PORT m_nPort;
  362.  
  363. public:
  364.     ~CInternetConnection();
  365.     DECLARE_DYNAMIC(CInternetConnection)
  366.  
  367. #ifdef _DEBUG
  368.     virtual void Dump(CDumpContext& dc) const;
  369.     void AssertValid() const;
  370. #endif
  371. };
  372.  
  373. #if !defined(_WIN32_WCE_NO_FTP)
  374. class CFtpConnection : public CInternetConnection
  375. {
  376. public:
  377.     CFtpConnection(CInternetSession* pSession, HINTERNET hConnected,
  378.         LPCTSTR pstrServer, DWORD dwContext);
  379.     CFtpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  380.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  381.         DWORD dwContext = 0,
  382.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  383.         BOOL bPassive = FALSE);
  384.  
  385.     BOOL SetCurrentDirectory(LPCTSTR pstrDirName);
  386.  
  387.     BOOL GetCurrentDirectory(CString& strDirName) const;
  388.     BOOL GetCurrentDirectory(LPTSTR pstrDirName, LPDWORD lpdwLen) const;
  389.     BOOL GetCurrentDirectoryAsURL(LPTSTR pstrName, LPDWORD lpdwLen) const;
  390.     BOOL GetCurrentDirectoryAsURL(CString& strDirName) const;
  391.  
  392.     BOOL RemoveDirectory(LPCTSTR pstrDirName);
  393.     BOOL CreateDirectory(LPCTSTR pstrDirName);
  394.     BOOL Rename(LPCTSTR pstrExisting, LPCTSTR pstrNew);
  395.     BOOL Remove(LPCTSTR pstrFileName);
  396.  
  397.     BOOL PutFile(LPCTSTR pstrLocalFile, LPCTSTR pstrRemoteFile,
  398.         DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1);
  399.  
  400.     BOOL GetFile(LPCTSTR pstrRemoteFile, LPCTSTR pstrLocalFile,
  401.         BOOL bFailIfExists = TRUE,
  402.         DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL,
  403.         DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1);
  404.  
  405.     CInternetFile* OpenFile(LPCTSTR pstrFileName,
  406.         DWORD dwAccess = GENERIC_READ,
  407.         DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1);
  408.  
  409.     virtual void Close();
  410.  
  411. // implementation
  412.     ~CFtpConnection();
  413.  
  414. protected:
  415.     CString m_strServerName;
  416.  
  417. public:
  418. #ifdef _DEBUG
  419.     virtual void Dump(CDumpContext& dc) const;
  420.     virtual void AssertValid() const;
  421. #endif
  422.  
  423.     DECLARE_DYNAMIC(CFtpConnection)
  424. };
  425. #endif // _WIN32_WCE_NO_FTP
  426.  
  427. class CHttpConnection : public CInternetConnection
  428. {
  429. public:
  430.     enum {
  431.         _HTTP_VERB_MIN      = 0,
  432.         HTTP_VERB_POST      = 0,
  433.         HTTP_VERB_GET       = 1,
  434.         HTTP_VERB_HEAD      = 2,
  435.         HTTP_VERB_PUT       = 3,
  436.         HTTP_VERB_LINK      = 4,
  437.         HTTP_VERB_DELETE    = 5,
  438.         HTTP_VERB_UNLINK    = 6,
  439.         _HTTP_VERB_MAX      = 6,
  440.     };
  441.  
  442. public:
  443.     CHttpConnection(CInternetSession* pSession, HINTERNET hConnected,
  444.         LPCTSTR pstrServer, DWORD dwContext);
  445.     CHttpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  446.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  447.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  448.         DWORD dwContext = 1);
  449.     CHttpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  450.         DWORD dwFlags = 0, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
  451.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  452.         DWORD dwContext = 1);
  453.  
  454.     CHttpFile* OpenRequest(LPCTSTR pstrVerb,    LPCTSTR pstrObjectName,
  455.         LPCTSTR pstrReferer = NULL,DWORD dwContext = 1,
  456.         LPCTSTR* ppstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,
  457.         DWORD dwFlags = WCE_IF(0, INTERNET_FLAG_EXISTING_CONNECT));
  458.  
  459.     CHttpFile* OpenRequest(int nVerb, LPCTSTR pstrObjectName,
  460.         LPCTSTR pstrReferer = NULL, DWORD dwContext = 1,
  461.         LPCTSTR* ppstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,
  462.         DWORD dwFlags = WCE_IF(0,INTERNET_FLAG_EXISTING_CONNECT));
  463.  
  464. // implementation
  465.     ~CHttpConnection();
  466.     virtual void Close();
  467.  
  468. protected:
  469.     CString m_strServerName;
  470.     static const LPCTSTR szHtmlVerbs[];
  471.  
  472. public:
  473. #ifdef _DEBUG
  474.     virtual void Dump(CDumpContext& dc) const;
  475.     virtual void AssertValid() const;
  476. #endif
  477.  
  478.     friend class CInternetSession;  // just to access szHtmlVerbs
  479.     DECLARE_DYNAMIC(CHttpConnection)
  480. };
  481.  
  482. #if !defined(_WIN32_WCE)
  483. class CGopherConnection : public CInternetConnection
  484. {
  485. public:
  486.     CGopherConnection(CInternetSession* pSession,
  487.         HINTERNET hConnected, LPCTSTR pstrServer, DWORD dwContext);
  488.  
  489.     CGopherConnection(CInternetSession* pSession, LPCTSTR pstrServer,
  490.         LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
  491.         DWORD dwContext = 0,
  492.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
  493.  
  494.     CGopherFile* OpenFile(CGopherLocator& refLocator, DWORD dwFlags = 0,
  495.         LPCTSTR pstrView = NULL, DWORD dwContext = 1);
  496.  
  497.     CGopherLocator CreateLocator(LPCTSTR pstrDisplayString,
  498.         LPCTSTR pstrSelectorString, DWORD dwGopherType);
  499.  
  500.     BOOL CGopherConnection::GetAttribute(CGopherLocator& refLocator,
  501.         CString strRequestedAttributes, CString& strResult);
  502.  
  503.     static CGopherLocator CreateLocator(LPCTSTR pstrLocator);
  504.     static CGopherLocator CreateLocator(LPCTSTR pstrServerName,
  505.         LPCTSTR pstrDisplayString,
  506.         LPCTSTR pstrSelectorString, DWORD dwGopherType,
  507.         INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
  508.  
  509. // implementation
  510.     ~CGopherConnection();
  511.     virtual void Close();
  512.  
  513. public:
  514. #ifdef _DEBUG
  515.     virtual void Dump(CDumpContext& dc) const;
  516.     virtual void AssertValid() const;
  517. #endif
  518.     DECLARE_DYNAMIC(CGopherConnection)
  519. };
  520.  
  521.  
  522. /////////////////////////////////////////////////////////////////////////////
  523. // CFtpFileFind
  524.  
  525. class CFtpFileFind : public CFileFind
  526. {
  527. public:
  528.     CFtpFileFind(CFtpConnection* pConnection, DWORD dwContext = 1);
  529.     virtual ~CFtpFileFind();
  530.  
  531.     virtual BOOL FindFile(LPCTSTR pstrName = NULL,
  532.         DWORD dwFlags = INTERNET_FLAG_RELOAD);
  533.     virtual BOOL FindNextFile();
  534.     CString GetFileURL() const;
  535.  
  536. // implementation
  537. protected:
  538.     virtual void CloseContext();
  539.     CFtpConnection* m_pConnection;
  540.     DWORD m_dwContext;
  541.  
  542. public:
  543. #ifdef _DEBUG
  544.     virtual void Dump(CDumpContext& dc) const;
  545.     virtual void AssertValid() const;
  546. #endif
  547.  
  548.     DECLARE_DYNAMIC(CFtpFileFind)
  549. };
  550.  
  551.  
  552. /////////////////////////////////////////////////////////////////////////////
  553. // CGopherLocator
  554.  
  555. class CGopherLocator : public CObject
  556. {
  557. public:
  558.     ~CGopherLocator();
  559.     operator LPCTSTR() const;
  560.     CGopherLocator(const CGopherLocator& ref);
  561.     BOOL GetLocatorType(DWORD& dwRef) const;
  562.  
  563. private:
  564.     // this only created by CGopherConnection::CreateLocator or by serialization
  565.     CGopherLocator(LPCTSTR pstrLocator, DWORD dwLocLen);
  566.  
  567.     CString m_Locator;  // _not_ a zero-terminated string!
  568.     DWORD m_dwBufferLength;
  569.  
  570.     friend class CGopherConnection;
  571.     friend class CGopherFile;
  572. };
  573.  
  574.  
  575. /////////////////////////////////////////////////////////////////////////////
  576. // CGopherFile
  577.  
  578. class CGopherFile : public CInternetFile
  579. {
  580. // Constructors
  581. protected:
  582.     CGopherFile(HINTERNET hFile, CGopherLocator& refLocator,
  583.         CGopherConnection* pConnection);
  584.     CGopherFile(HINTERNET hFile, HINTERNET hSession,
  585.         LPCTSTR pstrLocator, DWORD dwLocLen, DWORD dwContext);
  586.  
  587. // Operations
  588. public:
  589.     virtual void Close();
  590.     virtual void Write(const void* lpBuf, UINT nCount);
  591.     void WriteString(LPCTSTR pstr);
  592.  
  593. // Implementation
  594. protected:
  595.     CGopherLocator m_Locator;
  596. public:
  597.     virtual ~CGopherFile();
  598.  
  599. #ifdef _DEBUG
  600.     virtual void AssertValid() const;
  601.     virtual void Dump(CDumpContext& dc) const;
  602. #endif
  603.  
  604.     friend class CInternetSession;
  605.     friend class CGopherConnection;
  606.     DECLARE_DYNAMIC(CGopherFile)
  607. };
  608.  
  609.  
  610. /////////////////////////////////////////////////////////////////////////////
  611. // CGopherFileFind
  612.  
  613. class CGopherFileFind : public CFileFind
  614. {
  615. public:
  616.     CGopherFileFind(CGopherConnection* pConnection, DWORD dwContext = 1);
  617.     virtual ~CGopherFileFind();
  618.  
  619.     virtual BOOL FindFile(CGopherLocator& refLocator, LPCTSTR pstrString,
  620.         DWORD dwFlags = INTERNET_FLAG_RELOAD);
  621.     virtual BOOL FindFile(LPCTSTR pstrString,
  622.         DWORD dwFlags = INTERNET_FLAG_RELOAD);
  623.     virtual BOOL FindNextFile();
  624.  
  625.     virtual BOOL IsDots() const;
  626.  
  627.     virtual BOOL GetLastWriteTime(FILETIME* pTimeStamp) const;
  628.     virtual BOOL GetLastAccessTime(FILETIME* pTimeStamp) const;
  629.     virtual BOOL GetCreationTime(FILETIME* pTimeStamp) const;
  630.     virtual BOOL GetLastWriteTime(CTime& refTime) const;
  631.     virtual BOOL GetLastAccessTime(CTime& refTime) const;
  632.     virtual BOOL GetCreationTime(CTime& refTime) const;
  633.  
  634.     CGopherLocator GetLocator() const;
  635.     CString GetScreenName() const;
  636.  
  637.     virtual DWORD GetLength() const;
  638. #if defined(_X86_) || defined(_ALPHA_)
  639.     virtual __int64 GetLength64() const;
  640. #endif
  641.  
  642. protected:
  643.     virtual void CloseContext();
  644.     CGopherConnection* m_pConnection;
  645.     DWORD m_dwContext;
  646.  
  647. // implementation
  648. public:
  649.     // Unsupported APIs
  650.     CString GetFileName() const;
  651.     CString GetFilePath() const;
  652.     CString GetFileTitle() const;
  653.     CString GetFileURL() const;
  654.     CString GetRoot() const;
  655.  
  656. #ifdef _DEBUG
  657.     virtual void Dump(CDumpContext& dc) const;
  658.     virtual void AssertValid() const;
  659. #endif
  660.     DECLARE_DYNAMIC(CGopherFileFind)
  661. };
  662. #endif // _WIN32_WCE
  663.  
  664.  
  665. ///////////////////////////////////////////////////////////////////////
  666. // CInternetException
  667.  
  668. class CInternetException : public CException
  669. {
  670. public:
  671. // Constructor
  672.     CInternetException(DWORD dwError);
  673.  
  674. // Attributes
  675.     DWORD m_dwError;
  676.     DWORD m_dwContext;
  677.  
  678. // Implementation
  679. public:
  680.     ~CInternetException();
  681. #ifdef _DEBUG
  682.     virtual void Dump(CDumpContext& dc) const;
  683. #endif
  684.     virtual BOOL GetErrorMessage(LPTSTR lpstrError, UINT nMaxError,
  685.         PUINT pnHelpContext = NULL);
  686.     DECLARE_DYNAMIC(CInternetException)
  687. };
  688.  
  689. /////////////////////////////////////////////////////////////////////////////
  690. // Inline function declarations
  691.  
  692. #ifdef _AFX_ENABLE_INLINES
  693. #define _AFXINET_INLINE AFX_INLINE
  694. #include <afxinet.inl>
  695. #endif
  696.  
  697. #undef AFX_DATA
  698. #define AFX_DATA
  699.  
  700. #ifdef _AFX_MINREBUILD
  701. #pragma component(minrebuild, on)
  702. #endif
  703. #ifndef _AFX_FULLTYPEINFO
  704. #pragma component(mintypeinfo, off)
  705. #endif
  706.  
  707. #endif // __AFXINET_H__
  708.