1 #ifndef FTPFUNCTIONS_H
2 #define FTPFUNCTIONS_H
3 
4 #include <QString>
5 #include <QObject>
6 #include <QMessageBox>
7 #include <QTemporaryFile>
8 #include "ftpthread.h"
9 
10 class ftpThread;
11 
12 class ftpFunctions: public QObject
13 {
14   Q_OBJECT
15 public:
16   ftpFunctions();
17   ~ftpFunctions();
18   bool test(QString name, QString tHost, int tPort, QString tUser, QString tPasswd, QString tDirectory, bool doSetup);
19   void uploadFile(QString source, QString destination, bool wait, bool closeWhenDone);
20   void uploadData(QByteArray ba, QString destination, bool wait, bool closeWhenDone);
21   void downloadFile(QString source, QString destination, bool wait, bool closeWhenDone);
22   void remove(QString source, bool wait, bool closeWhenDone);
23   void rename(QString tSource,QString tDestination,bool wait,bool closeDone);
24   void setupFtp(QString name, QString tHost, int tPort, QString tUser, QString tPasswd, QString tDirectory);
25   void listFiles(QString mask, bool closeWhenDone);
26   void mremove(QString mask,bool wait,bool closeWhenDone);
27   void disconnectFtp();
getLastError()28   eftpError getLastError() {return lastError;}
getLastErrorStr(QString & lastErrorString)29   eftpError getLastErrorStr(QString &lastErrorString)
30   {
31     lastErrorString=lastErrorStr;
32     return lastError;}
33   QList<QUrlInfo> getListing();
isBusy()34   bool isBusy() {return busy;}
35   void changePath(QString source, bool wait);
36   void changeThreadName(QString tidName);
37 
38 
39 private slots:
40   void slotCommandsDone(int err, QString errStr);
41   void slotThreadFinished();
42   void slotDownloadFinished(bool err,QString filename);
43   void slotListingFinished(bool err);
44 
45 
46 signals:
47   void downloadDone(bool,QString);
48   void listingDone(bool err);
49 private:
50   void setupFtp();
51 
52   bool checkUpload(QString fn, QString rfn);
53   bool checkRemove(QString rfn);
54   bool checkStart();
55   void checkWait(bool wait);
56 
57   ftpThread *ftpThr;
58   QString idName;
59   QString host;
60   int port;
61   QString user;
62   QString passwd;
63   QString directory;
64 
65   QMessageBox mb;
66   bool endOfCommands;
67   eftpError lastError;
68   QString lastErrorStr;
69   QThread* thread;
70   QTemporaryFile ftmp;
71   int commandID;
72   bool busy;
73   bool mremoveCmd;
74 
75 
76 };
77 
78 #endif // FTPFUNCTIONS_H
79 
80