comparison data/fileio/RemoteFile.h @ 0:fc9323a41f5a

start base : Sonic Visualiser sv1-1.0rc1
author lbajardsilogic
date Fri, 11 May 2007 09:08:14 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fc9323a41f5a
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 #include <QTimer>
23
24 class QFtp;
25 class QHttp;
26 class QFile;
27 class QProgressDialog;
28 class QHttpResponseHeader;
29
30 class RemoteFile : public QObject
31 {
32 Q_OBJECT
33
34 public:
35 RemoteFile(QUrl url);
36 virtual ~RemoteFile();
37
38 bool isAvailable();
39
40 void wait();
41
42 bool isOK() const;
43 bool isDone() const;
44
45 QString getLocalFilename() const;
46 QString getErrorString() const;
47
48 void deleteLocalFile();
49
50 static bool canHandleScheme(QUrl url);
51
52 signals:
53 void progress(int percent);
54 void ready();
55
56 protected slots:
57 void dataReadProgress(int done, int total);
58 void httpResponseHeaderReceived(const QHttpResponseHeader &resp);
59 void ftpCommandFinished(int, bool);
60 void dataTransferProgress(qint64 done, qint64 total);
61 void done(bool error);
62 void showProgressDialog();
63 void cancelled();
64
65 protected:
66 QFtp *m_ftp;
67 QHttp *m_http;
68 QFile *m_localFile;
69 QString m_localFilename;
70 QString m_errorString;
71 bool m_ok;
72 int m_lastStatus;
73 bool m_done;
74 QProgressDialog *m_progressDialog;
75 QTimer m_progressShowTimer;
76
77 void cleanup();
78
79 QString createLocalFile(QUrl url);
80
81 static QMutex m_fileCreationMutex;
82 static int m_count;
83 };
84
85 #endif