diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-04 04:19:10 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-04 04:19:10 +0200 |
commit | 0adf1828b047699b9d15e2abf08a1ae0b89da73b (patch) | |
tree | b29fd7a91a33a1706367560288d67fb12329fd4c /libutil/src | |
parent | 4f73091bb5bdbdb91329b9a4ef647fc8286d423c (diff) | |
download | MultiMC-0adf1828b047699b9d15e2abf08a1ae0b89da73b.tar MultiMC-0adf1828b047699b9d15e2abf08a1ae0b89da73b.tar.gz MultiMC-0adf1828b047699b9d15e2abf08a1ae0b89da73b.tar.lz MultiMC-0adf1828b047699b9d15e2abf08a1ae0b89da73b.tar.xz MultiMC-0adf1828b047699b9d15e2abf08a1ae0b89da73b.zip |
Download assets for 1.6 on application start (background task).
Diffstat (limited to 'libutil/src')
-rw-r--r-- | libutil/src/dlqueue.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/libutil/src/dlqueue.cpp b/libutil/src/dlqueue.cpp index 1ef8e212..d73dc356 100644 --- a/libutil/src/dlqueue.cpp +++ b/libutil/src/dlqueue.cpp @@ -1,6 +1,8 @@ #include "include/dlqueue.h" -DownloadJob::DownloadJob ( QUrl url, QString target_path, QString expected_md5 ) +DownloadJob::DownloadJob (QUrl url, + QString target_path, + QString expected_md5 ) :Job() { m_url = url; @@ -11,13 +13,41 @@ DownloadJob::DownloadJob ( QUrl url, QString target_path, QString expected_md5 ) m_save_to_file = m_target_path.size(); m_status = Job_NotStarted; m_opened_for_saving = false; + m_manager.reset(new QNetworkAccessManager()); } -JobPtr DownloadJob::create ( QUrl url, QString target_path, QString expected_md5 ) +JobPtr DownloadJob::create (QUrl url, + QString target_path, + QString expected_md5 ) { return JobPtr ( new DownloadJob ( url, target_path, expected_md5 ) ); } +DownloadJob::DownloadJob (QSharedPointer<QNetworkAccessManager> net_mgr, + QUrl url, + QString target_path, + QString expected_md5 ) + :Job() +{ + m_url = url; + m_target_path = target_path; + m_expected_md5 = expected_md5; + + m_check_md5 = m_expected_md5.size(); + m_save_to_file = m_target_path.size(); + m_status = Job_NotStarted; + m_opened_for_saving = false; + m_manager = net_mgr; +} + +JobPtr DownloadJob::create (QSharedPointer<QNetworkAccessManager> net_mgr, + QUrl url, + QString target_path, + QString expected_md5 ) +{ + return JobPtr ( new DownloadJob ( net_mgr, url, target_path, expected_md5 ) ); +} + bool DownloadJob::ensurePathExists(QString filenamepath) { QFileInfo a ( filenamepath ); @@ -27,7 +57,6 @@ bool DownloadJob::ensurePathExists(QString filenamepath) void DownloadJob::start() { - m_manager.reset ( new QNetworkAccessManager() ); if ( m_save_to_file ) { QString filename = m_target_path; |