summaryrefslogtreecommitdiffstats
path: root/src/fileDownloader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/fileDownloader.h')
-rw-r--r--src/fileDownloader.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/fileDownloader.h b/src/fileDownloader.h
new file mode 100644
index 0000000..621f2b7
--- /dev/null
+++ b/src/fileDownloader.h
@@ -0,0 +1,52 @@
+/*
+ * fileDownloader.h
+ *
+ * Created on: Mar 7, 2014
+ * Author: nils
+ */
+
+#ifndef FILEDOWNLOADER_H_
+#define FILEDOWNLOADER_H_
+
+#include <QObject>
+#include <QByteArray>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+
+class FileDownloader : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ explicit FileDownloader(const QUrl& fileUrl, QObject *parent = 0);
+
+ virtual ~FileDownloader();
+
+ bool downloadFile();
+
+signals:
+
+ /**
+ * Triggered when the download has finished.
+ * On error, downloadedData will be empty.
+ */
+ void downloaded(const QUrl& url, const QByteArray& downloadedData);
+
+private slots:
+
+ void fileDownloaded();
+ void downloadFailed(QNetworkReply::NetworkError code);
+ void downloadProgress(qint64 received, qint64 totalSize);
+
+private:
+
+ void killReply(QNetworkReply *reply);
+
+ bool started;
+ QUrl url;
+
+};
+
+#endif /* FILEDOWNLOADER_H_ */