-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftpclient.h
56 lines (49 loc) · 1.52 KB
/
ftpclient.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
#ifndef FTPCLIENT_H
#define FTPCLIENT_H
#include <QObject>
#include <QtNetwork>
#include <QString>
#include <QHash>
#include <QProgressDialog>
class Ftpclient : public QObject
{
Q_OBJECT
public:
explicit Ftpclient(QObject *parent = 0);
virtual ~Ftpclient();
void ftpConnect();
void ftpLogout();
void initConnection();
void setServerName(const QString &server) { strSrvName = server; }
void setServerPort(const QString &port) { strSrvPort = port; }
void setUserName(const QString &userName) { strUser = userName; }
void setPwd(const QString &pwd) { strPwd = pwd; }
void setCurrentPath(QString &path);
QString getCurrentPath() const { return curPath; }
QString getUrlStr(const QUrl &url);
bool isDir(const QString &str) const;
void downloadFile(const QString &filename);
signals:
void cmdAddToList(const QUrlInfo &urlInfo);
void currentPathChanged(const QString &path);
public slots:
void ftpcommandStarted(int id);
void ftpcommandFinished(int id, bool error);
void addToList(const QUrlInfo &urlInfo);
void changeDir(const QString &dir);
void updateProgressBar(int done, int total);
private:
QFtp ftp;
QUrl url;
bool connected;
QFile *file;
QProgressDialog *progressDlg;
/* 服务器、端口、用户名和密码 */
QString strSrvName, strSrvPort, strUser, strPwd;
/* 当前路径 */
QString curPath;
/* 记录是文件还是路径 */
QHash<QString, bool> isDirHash;
int connectId, loginId, closeId;
};
#endif // FTPCLIENT_H