ZIMA CAD Parts
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ftpdatasource.h
Go to the documentation of this file.
1 /*
2  ZIMA-CAD-Parts
3  http://www.zima-construction.cz/software/ZIMA-Parts
4 
5  Copyright (C) 2011-2012 Jakub Skokan <aither@havefun.cz>
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef FTPDATASOURCE_H
22 #define FTPDATASOURCE_H
23 
24 #include <QString>
25 #include <QFtp>
26 #include <QList>
27 #include <QStringList>
28 #include <QUrl>
29 
30 #include "baseremotedatasource.h"
31 
32 struct File;
33 
35 {
36  Q_OBJECT
37 public:
38  FtpDataSource();
40  QString internalName();
41 
42  // FIXME: make private
44 
45 public slots:
46  void loadRootItem(Item *item);
47  void loadDirectory(Item* item);
48  void changeSettings(QString remoteHost, int remotePort, bool ftpPassiveMode, QString remoteLogin, QString remotePassword, QString remoteBaseDir);
49  void reset();
50  void deleteFiles(QList<File*> files);
51  void addFileToDownload(File *f);
52  void downloadFiles(QList<File*> files, QString dir);
53  void downloadFile(File* file);
54  void resumeDownload();
55  void abort();
56  void deleteDownloadQueue();
57  void assignTechSpecUrlToItem(QString url, Item *item, QString lang, bool overwrite = false);
58  void assignPartsIndexUrlToItem(QString url, Item *item, QString lang, bool overwrite = false);
59 
60 protected:
61  void checkAndSendTechSpecUrl(Item *item);
62 
63 private slots:
64  void ftpListInfo(const QUrlInfo&);
65  void ftpCommandFinished(int, bool);
66  void ftpStateChanged(int);
67  void ftpDataTransferProgress(qint64 done, qint64 total);
68  void ftpFileDownloadFinished(int, bool);
69 
70 private:
71  void checkConnection(QFtp *f);
72  void ftpListItemInQueue();
73  void checkLoadedItem();
74 
75 // QList<QString> paramList;
76  QList<Item*> loadItemQueue;
77 
78  Item *ftpCurrentItem; //the 'directory part' of the current (while listing) directory
79  QString ftpCurrentDir;
80  QList<Item*> dirsToList; //list of subdirectories that need to be searched and listed
81  int ftpListId; //the command id used to identify the listing command in ftpCommandDone
82 // int dbFilesQueued; //number of .db files for which active ftp tasks exist
83  int browseDepth;
84  bool hasTechSpecDir;
85  int techSpecListId;
86  bool hasMetadata;
87  bool metadataChanged;
88  bool hasLogo;
89  bool hasLogoText;
90  QList<File*> thumbnails;
91 
92  QMap<int, QFile*> techSpecFiles;
93  QMap<int, Item*> partTasks; //maps ftp task indexes to parts for .db file transfer
94  QMap<int, File*> partPicTasks; //the same thing as above, but for picture file transfer
95  QMap<int, File*> fileTasks; //for actual files file transfer
96  QList<File*> filesToDownload;
97  QString targetDir;
98  QStringList techSpecIndexes;
99 
100  QFtp *ftp;
101  QFtp *dlFtp;
102 };
103 
104 #endif // FTPDATASOURCE_H
void changeSettings(QString remoteHost, int remotePort, bool ftpPassiveMode, QString remoteLogin, QString remotePassword, QString remoteBaseDir)
Definition: ftpdatasource.cpp:160
void assignPartsIndexUrlToItem(QString url, Item *item, QString lang, bool overwrite=false)
Definition: ftpdatasource.cpp:760
void deleteDownloadQueue()
Definition: ftpdatasource.cpp:703
void abort()
Definition: ftpdatasource.cpp:710
bool ftpPassiveMode
Definition: ftpdatasource.h:43
int remotePort
Definition: baseremotedatasource.h:45
void addFileToDownload(File *f)
Definition: ftpdatasource.cpp:660
void downloadFiles(QList< File * > files, QString dir)
Definition: ftpdatasource.cpp:665
Definition: item.h:130
QString internalName()
Definition: ftpdatasource.cpp:62
Definition: baseremotedatasource.h:29
void downloadFile(File *file)
Definition: ftpdatasource.cpp:678
void checkAndSendTechSpecUrl(Item *item)
Definition: ftpdatasource.cpp:102
void loadDirectory(Item *item)
Definition: ftpdatasource.cpp:110
Definition: item.h:41
~FtpDataSource()
Definition: ftpdatasource.cpp:52
void loadRootItem(Item *item)
Definition: ftpdatasource.cpp:97
void assignTechSpecUrlToItem(QString url, Item *item, QString lang, bool overwrite=false)
Definition: ftpdatasource.cpp:726
void reset()
Definition: ftpdatasource.cpp:67
QString remoteHost
Definition: baseremotedatasource.h:44
Definition: ftpdatasource.h:34
QString remoteLogin
Definition: baseremotedatasource.h:44
void resumeDownload()
Definition: ftpdatasource.cpp:692
QString remoteBaseDir
Definition: baseremotedatasource.h:44
void deleteFiles(QList< File * > files)
Definition: ftpdatasource.cpp:652
QString remotePassword
Definition: baseremotedatasource.h:44
FtpDataSource()
Definition: ftpdatasource.cpp:28