src/MyFtp/myftp.h

00001 /****************************************************************************
00002 ** Simplification et complétion de la classe QFtp
00003 ** Créé par Anacr0x : anacr0x@free.fr
00004 **
00005 ** Sous licence GPL v2 ou plus
00006 ****************************************************************************/
00007 
00008 #ifndef MYFTP_H
00009 #define MYFTP_H
00010 
00011 #include <QtCore>
00012 #include <QtGui>
00013 #include <QtNetwork>
00014 #include "mytreewidget.h"
00015 #include "myftptransfercontrol.h"
00016 #include "mydd.h"
00017 
00018 /*************************************************************************/
00020 
00024 /*************************************************************************/
00025 
00026 struct FileList
00027 {
00029         QUrlInfo ui;
00031         FileList *before;
00032 };
00033 
00034 
00035 /*************************************************************************/
00037 
00052 /*************************************************************************/
00053 
00054 class MyFtp : public MyFtpTransferControl
00055 {
00056         Q_OBJECT
00057 
00058 private:
00060         QString path;
00061 
00062 public:
00064         MyDD *dd;
00065 
00068         enum FtpCurrentAction {None, ChangePath, DelDir, Download, DownloadDir, Upload, UploadDir, Abort};
00069 
00077         MyFtp(MyTreeWidget *ftp, MyTreeWidget *local, QLineEdit *ftpPath = NULL, QLineEdit *localPath = NULL);
00078 
00079         /*-----------Voici les fonctions utilisables dans un programme extérieur-------------*/
00080         /*-----------------------( ne pas s'occuper pas du reste )---------------------------*/
00081 
00083         void connectFtp(QString host, int port, QString username, QString password, bool showFiles = true);
00084 
00086         void disconnectFtp();
00087 
00089         inline const QString& getPath()
00090         {
00091                 return path;
00092         }
00093 
00096         void changePath(bool display = true);
00097 
00100         void changePath(const QString &FtpPath, bool display = true);
00101 
00103         inline void changePath(const char *FtpPath, bool display = true)
00104         {
00105                 changePath(QString(FtpPath), display);
00106         };
00107 
00109         void getList(bool display = true);
00110 
00112         void displayList();
00113 
00116         void scanDir(QString FtpPath);
00117 
00120         void scanDirBis();
00121 
00124         FileList* isFileExist(const QString &file);
00125 
00128         void downloadSelection(const QString &destDir);
00129 
00135         bool downloadFile(const QString &filename, const QString &dest);
00136 
00138         void downloadDir(const QString &dir);
00139 
00142         void uploadSelection(const QString &destDir);
00143 
00149         bool uploadFile(const QString &filename, const QString &dest);
00150 
00152         void uploadDir(const QString &absLocalDir);
00153 
00155         void delSelection();
00156 
00158         void delDir(const QString &dir);
00159 
00163         void renameSelection(QString newName, bool restoreExt = true);
00164 
00166         MyFtp::FtpCurrentAction getCurrentAction();
00167 
00169         inline void changeCurrentAction(FtpCurrentAction state);
00170 
00171 signals:
00173         void currentActionChanged(MyFtp::FtpCurrentAction state);
00174 
00177         void scanDirFinished(const QString &list);
00178 
00180         void changePathFinished();
00181 
00183         void listFinished(int id);
00184 
00186         void delSelectionFinished();
00187 
00189         void detailledError(const QString &error);
00190 
00191         /*-----------------------------------------------------------------------------------*/
00192 
00193 private:
00195         MyTreeWidget *lvFtp;
00196 
00198         QLineEdit *leFtpPath;
00199 
00201         bool bDisplayListOrNot;
00202 
00204         FileList *lastFile;
00205 
00207         QTimer noDeco;
00208 
00210         QList <int> idList;
00211 
00213         QMessageBox::StandardButton eraseStateBtn;
00214 
00216         FtpCurrentAction currentAction;
00217 
00219         bool isScanning;
00220 
00222         QString ScanDirList;
00223 
00225         QString TmpPath;
00226 
00228         QString dirToMake;
00229 
00231         QString queueAction;
00232 
00236         int myListFunction(bool display = true, const QString &dir = QString::null);
00237 
00239         void downloadDirBis(const QString &list);
00240 
00242         void uploadDirBis();
00243 
00245         void delDirBis(const QString &list);
00246 
00249         bool deleteOneFile(FileList *file);
00250 
00252         void deleteAllFile();
00253 
00254 
00255 private slots:
00257         void slotNoDecoTimer();
00258 
00260         void startNextQueueAction();
00261 
00263         void slotListInfo(const QUrlInfo &i);
00264 
00266         void slotCommandStarted(int id);
00267 
00269         void slotCommandFinished(int id, bool error);
00270 
00272         void slotRawCommandReply(int replyCode, const QString &detail);
00273 };
00274 
00275 #endif

Generated on Wed Jan 2 20:39:34 2008 for Scythia by  doxygen 1.5.4