comparison data/fileio/RemoteFile.h @ 208:8a3d68910b37

* Framework for retrieving files from remote locations
author Chris Cannam
date Mon, 08 Jan 2007 17:04:35 +0000
parents
children a06afefe45ee
comparison
equal deleted inserted replaced
207:8ee6cf529c4e 208:8a3d68910b37
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2007 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _REMOTE_FILE_H_
17 #define _REMOTE_FILE_H_
18
19 #include <QUrl>
20 #include <QMutex>
21 #include <QString>
22
23 class QFtp;
24 class QHttp;
25 class QFile;
26 class QProgressDialog;
27
28 class RemoteFile : public QObject
29 {
30 Q_OBJECT
31
32 public:
33 RemoteFile(QUrl url);
34 virtual ~RemoteFile();
35
36 void wait();
37
38 bool isOK() const;
39 bool isDone() const;
40 QString getLocalFilename() const;
41 QString getErrorString() const;
42
43 static bool canHandleScheme(QUrl url);
44
45 signals:
46 void progress(int percent);
47 void ready();
48
49 protected slots:
50 void dataReadProgress(int done, int total);
51 void dataTransferProgress(qint64 done, qint64 total);
52 void done(bool error);
53
54 protected:
55 QFtp *m_ftp;
56 QHttp *m_http;
57 QFile *m_localFile;
58 QString m_localFilename;
59 QString m_errorString;
60 bool m_ok;
61 bool m_done;
62 QProgressDialog *m_progressDialog;
63
64 QString createLocalFile(QUrl url);
65
66 static QMutex m_fileCreationMutex;
67 static int m_count;
68 };
69
70 #endif