Download assets for 1.6 on application start (background task).
This commit is contained in:
@ -9,9 +9,22 @@ class LIBUTIL_EXPORT DownloadJob : public Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DownloadJob(QUrl url, QString rel_target_path = QString(), QString expected_md5 = QString());
|
||||
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());
|
||||
|
||||
DownloadJob(QSharedPointer<QNetworkAccessManager> net_mgr,
|
||||
QUrl url,
|
||||
QString rel_target_path = QString(),
|
||||
QString expected_md5 = QString()
|
||||
);
|
||||
static JobPtr create(QSharedPointer<QNetworkAccessManager> net_mgr,
|
||||
QUrl url,
|
||||
QString rel_target_path = QString(),
|
||||
QString expected_md5 = QString()
|
||||
);
|
||||
|
||||
public:
|
||||
static bool ensurePathExists(QString filenamepath);
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user