summaryrefslogtreecommitdiffstats
path: root/logic/net/Download.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-09-08 02:15:20 +0200
committerPetr Mrázek <peterix@gmail.com>2013-09-08 02:15:20 +0200
commit6bea4ec988b7caeac63353fb9d2a354f2fd47dad (patch)
tree77dc597c82ff3952d9f34f4ca13da1c36ca89bd8 /logic/net/Download.h
parent6892c11e9f287dcfb1e698f8f46233a01fb7abb6 (diff)
downloadMultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar.gz
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar.lz
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.tar.xz
MultiMC-6bea4ec988b7caeac63353fb9d2a354f2fd47dad.zip
Use HttpMetaCache to minimize network use.
Diffstat (limited to 'logic/net/Download.h')
-rw-r--r--logic/net/Download.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/logic/net/Download.h b/logic/net/Download.h
new file mode 100644
index 00000000..91f09dec
--- /dev/null
+++ b/logic/net/Download.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <QObject>
+#include <QUrl>
+#include <QSharedPointer>
+#include <QNetworkReply>
+
+
+enum JobStatus
+{
+ Job_NotStarted,
+ Job_InProgress,
+ Job_Finished,
+ Job_Failed
+};
+
+class Download : public QObject
+{
+ Q_OBJECT
+protected:
+ explicit Download(): QObject(0){};
+public:
+ virtual ~Download() {};
+
+public:
+ /// the network reply
+ QSharedPointer<QNetworkReply> m_reply;
+
+ /// source URL
+ QUrl m_url;
+
+ /// The file's status
+ JobStatus m_status;
+
+ /// index within the parent job
+ int index_within_job = 0;
+
+signals:
+ void started(int index);
+ void progress(int index, qint64 current, qint64 total);
+ void succeeded(int index);
+ void failed(int index);
+
+protected slots:
+ virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) = 0;
+ virtual void downloadError(QNetworkReply::NetworkError error) = 0;
+ virtual void downloadFinished() = 0;
+ virtual void downloadReadyRead() = 0;
+
+public slots:
+ virtual void start() = 0;
+};
+
+typedef QSharedPointer<Download> DownloadPtr;