From afaa1dc223ec87b685778ee0aed81cb6caaa05c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 7 Aug 2013 01:38:18 +0200 Subject: Get rid of QNAM (now subclassed and less needy). Basic LWJGL download and extraction. --- backend/net/DownloadJob.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backend/net/DownloadJob.h (limited to 'backend/net/DownloadJob.h') diff --git a/backend/net/DownloadJob.h b/backend/net/DownloadJob.h new file mode 100644 index 00000000..cbde3852 --- /dev/null +++ b/backend/net/DownloadJob.h @@ -0,0 +1,51 @@ +#pragma once +#include "JobQueue.h" +#include + +/** + * A single file for the downloader/cache to process. + */ +class LIBUTIL_EXPORT DownloadJob : public Job +{ + Q_OBJECT +public: + DownloadJob(QUrl url, + QString rel_target_path = QString(), + QString expected_md5 = QString() + ); + static JobPtr create(QUrl url, QString rel_target_path = QString(), QString expected_md5 = QString()); +public slots: + virtual void start(); + +private slots: + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);; + void downloadError(QNetworkReply::NetworkError error); + void downloadFinished(); + void downloadReadyRead(); + +public: + /// the network reply + QSharedPointer m_reply; + /// source URL + QUrl m_url; + + /// if true, check the md5sum against a provided md5sum + /// also, if a file exists, perform an md5sum first and don't download only if they don't match + bool m_check_md5; + /// the expected md5 checksum + QString m_expected_md5; + + /// save to file? + bool m_save_to_file; + /// is the saving file already open? + bool m_opened_for_saving; + /// if saving to file, use the one specified in this string + QString m_target_path; + /// this is the output file, if any + QFile m_output_file; + /// if not saving to file, downloaded data is placed here + QByteArray m_data; + + /// The file's status + JobStatus m_status; +}; -- cgit v1.2.3