comparison data/fileio/RemoteFile.h @ 210:a06afefe45ee

* Cancel when downloading file * Handle status codes (404 etc) * Add RemoteFile::isAvailable * Start on FileFinder for looking up files referred to in distant sessions
author Chris Cannam
date Wed, 10 Jan 2007 17:26:39 +0000
parents 8a3d68910b37
children e2bbb58e6df6
comparison
equal deleted inserted replaced
209:6576a208e8e7 210:a06afefe45ee
17 #define _REMOTE_FILE_H_ 17 #define _REMOTE_FILE_H_
18 18
19 #include <QUrl> 19 #include <QUrl>
20 #include <QMutex> 20 #include <QMutex>
21 #include <QString> 21 #include <QString>
22 #include <QTimer>
22 23
23 class QFtp; 24 class QFtp;
24 class QHttp; 25 class QHttp;
25 class QFile; 26 class QFile;
26 class QProgressDialog; 27 class QProgressDialog;
28 class QHttpResponseHeader;
27 29
28 class RemoteFile : public QObject 30 class RemoteFile : public QObject
29 { 31 {
30 Q_OBJECT 32 Q_OBJECT
31 33
32 public: 34 public:
33 RemoteFile(QUrl url); 35 RemoteFile(QUrl url);
34 virtual ~RemoteFile(); 36 virtual ~RemoteFile();
35 37
38 bool isAvailable();
39
36 void wait(); 40 void wait();
37 41
38 bool isOK() const; 42 bool isOK() const;
39 bool isDone() const; 43 bool isDone() const;
44
40 QString getLocalFilename() const; 45 QString getLocalFilename() const;
41 QString getErrorString() const; 46 QString getErrorString() const;
42 47
43 static bool canHandleScheme(QUrl url); 48 static bool canHandleScheme(QUrl url);
44 49
46 void progress(int percent); 51 void progress(int percent);
47 void ready(); 52 void ready();
48 53
49 protected slots: 54 protected slots:
50 void dataReadProgress(int done, int total); 55 void dataReadProgress(int done, int total);
56 void responseHeaderReceived(const QHttpResponseHeader &resp);
51 void dataTransferProgress(qint64 done, qint64 total); 57 void dataTransferProgress(qint64 done, qint64 total);
52 void done(bool error); 58 void done(bool error);
59 void showProgressDialog();
60 void cancelled();
53 61
54 protected: 62 protected:
55 QFtp *m_ftp; 63 QFtp *m_ftp;
56 QHttp *m_http; 64 QHttp *m_http;
57 QFile *m_localFile; 65 QFile *m_localFile;
58 QString m_localFilename; 66 QString m_localFilename;
59 QString m_errorString; 67 QString m_errorString;
60 bool m_ok; 68 bool m_ok;
69 int m_lastStatus;
61 bool m_done; 70 bool m_done;
62 QProgressDialog *m_progressDialog; 71 QProgressDialog *m_progressDialog;
72 QTimer m_progressShowTimer;
63 73
64 QString createLocalFile(QUrl url); 74 QString createLocalFile(QUrl url);
65 75
66 static QMutex m_fileCreationMutex; 76 static QMutex m_fileCreationMutex;
67 static int m_count; 77 static int m_count;