afxinet.h 20 KB

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