-
Notifications
You must be signed in to change notification settings - Fork 12
/
DownloadFtpJet.h
129 lines (104 loc) · 3.41 KB
/
DownloadFtpJet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#if !defined(AFX_DownloadFtpJet_H__BB70E295_43B2_41A6_80DC_5F4C0C89B2BB__INCLUDED_)
#define AFX_DownloadFtpJet_H__BB70E295_43B2_41A6_80DC_5F4C0C89B2BB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DownloadFtpJet.h : header file
//
#include "Ftp.h"
class CDownloadItemManager;
#include "DownloadJet.h"
/////////////////////////////////////////////////////////////////////////////
// CDownloadFtpJet
class CDownloadFtpJet;
typedef void (CDownloadFtpJet::*JET_STATE_HANDLER)(SOCKET aSocket);
typedef struct
{
JET_STATE_HANDLER fStateHandlers[3]; /*fSucceed, fFailed, fError*/;
}JET_STATE_ENTRY, *P_JET_STATE_ENTRY;
class CDownloadFtpJet : public CDownloadJet
{
//DECLARE_DYNCREATE(CDownloadFtpJet)
public:
CDownloadFtpJet(CDownloadItemManager *pParent = NULL);
virtual ~CDownloadFtpJet();
public:
// DWONLOADº¯Êý
BOOL ParseURL(LPCTSTR lpszURL,CString& strServer,CString& strObject,USHORT& nPort);
public:
virtual void StopDownload();
virtual void StartDownload();
virtual void SetProxy(LPCTSTR lpszProxyServer, USHORT nProxyPort,BOOL bProxy=TRUE,BOOL bProxyAuthorization = FALSE,LPCTSTR lpszProxyUsername = NULL,LPCTSTR lpszProxyPassword = NULL,UINT nProxyType = PROXY_HTTPGET);
private:
int prv_Send(SOCKET hSocket, char const * pszBuffer, int iBufferSize, DWORD dwTimeout);
void prv_UnregisterTimeout();
enum JET_STATUS{
none = 0,
connected,
user_name,
password,
rest_0,
rest_1,
type_0,
pasv_0,
get_list,
list,
type_1,
size,
type_2,
pasv_1,
rest_2,
retr,
close} m_JetStatus;
enum REPLY_STATUS
{
nSucceed = 0,
nFailed,
nError,
nUncompletedCommand
};
void prv_ConnectServer(SOCKET aSocket);
void prv_Connected(SOCKET aSocket);
void prv_SentUserName(SOCKET aSocket);
void prv_SentPassword(SOCKET aSocket);
void prv_SentRest(SOCKET aSocket);
void prv_SentType(SOCKET aSocket);
void prv_SentPasv(SOCKET aSocket);
void prv_SentList(SOCKET aSocket);
void prv_SentSize(SOCKET aSocket);
void prv_SentRetr(SOCKET aSocket);
void prv_Failed(SOCKET aSocket);
void prv_Error(SOCKET aSocket);
void prv_GetList(SOCKET aSocket);
BOOL GetIPandPort(char *pszIP, UINT *puiPort);
int prv_GetReplyEndPosition(char *pszBuf, int iBufLen);
enum REPLY_STATUS prv_CheckReply(WPARAM wParam, LPARAM lParam);
static JET_STATE_ENTRY m_JetStatesTable[];
static int m_nSizeOfStatesTable;
//int prv_GetHeader(SOCKET aSocket, char *pszBuffer, int iBufferSize, int* iStatus);
// UINT prv_SendRequest(BOOL bHead = FALSE);
//UINT prv_GetInfo(LPCTSTR lpszHeader,DWORD& dwContentLength,DWORD& dwStatusCode,CTime& TimeLastModified);
//CTime prv_GetTime(LPCTSTR lpszTime);
void prv_StartDownload();
int prv_ConnectEx(SOCKET hSocket, char const * pszServer, int nPort,DWORD dwTimeout,BOOL fFixNtDNS = FALSE);
public:
// Operations
public:
BOOL OwnSocket(SOCKET aSocket);
void prv_StopDownload();
virtual void Timeout();
virtual int DownloadHandler(WPARAM wParam, LPARAM lParam);
private:
BOOL m_bDataSocketReady;
BOOL m_bControlSocketReady;
CFtp m_Ftp;
//CArray<BYTE, BYTE> m_arData;
char *m_szBuffer;
int m_iBufferSize;
int m_iDataLen;
SOCKET m_hDataSocket;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DownloadFtpJet_H__BB70E295_43B2_41A6_80DC_5F4C0C89B2BB__INCLUDED_)