diff options
Diffstat (limited to 'launcher/meta')
-rw-r--r-- | launcher/meta/BaseEntity.cpp | 20 | ||||
-rw-r--r-- | launcher/meta/BaseEntity.h | 6 | ||||
-rw-r--r-- | launcher/meta/Index_test.cpp | 7 | ||||
-rw-r--r-- | launcher/meta/VersionList.cpp | 2 | ||||
-rw-r--r-- | launcher/meta/VersionList.h | 2 |
5 files changed, 13 insertions, 24 deletions
diff --git a/launcher/meta/BaseEntity.cpp b/launcher/meta/BaseEntity.cpp index 5ff7a59a..a9d62fcd 100644 --- a/launcher/meta/BaseEntity.cpp +++ b/launcher/meta/BaseEntity.cpp @@ -15,16 +15,13 @@ #include "BaseEntity.h" -#include "Json.h" - #include "net/Download.h" #include "net/HttpMetaCache.h" #include "net/NetJob.h" - -#include "Env.h" #include "Json.h" #include "BuildConfig.h" +#include "Application.h" class ParsingValidator : public Net::Validator { @@ -120,9 +117,9 @@ void Meta::BaseEntity::load(Net::Mode loadType) { return; } - NetJob *job = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename())); + m_updateTask = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename())); auto url = this->url(); - auto entry = ENV.metacache()->resolveEntry("meta", localFilename()); + auto entry = APPLICATION->metacache()->resolveEntry("meta", localFilename()); entry->setStale(true); auto dl = Net::Download::makeCached(url, entry); /* @@ -130,21 +127,20 @@ void Meta::BaseEntity::load(Net::Mode loadType) * If that fails, the file is not written to storage. */ dl->addValidator(new ParsingValidator(this)); - job->addNetAction(dl); + m_updateTask->addNetAction(dl); m_updateStatus = UpdateStatus::InProgress; - m_updateTask.reset(job); - QObject::connect(job, &NetJob::succeeded, [&]() + QObject::connect(m_updateTask.get(), &NetJob::succeeded, [&]() { m_loadStatus = LoadStatus::Remote; m_updateStatus = UpdateStatus::Succeeded; m_updateTask.reset(); }); - QObject::connect(job, &NetJob::failed, [&]() + QObject::connect(m_updateTask.get(), &NetJob::failed, [&]() { m_updateStatus = UpdateStatus::Failed; m_updateTask.reset(); }); - m_updateTask->start(); + m_updateTask->start(APPLICATION->network()); } bool Meta::BaseEntity::isLoaded() const @@ -158,7 +154,7 @@ bool Meta::BaseEntity::shouldStartRemoteUpdate() const return m_updateStatus != UpdateStatus::InProgress; } -shared_qobject_ptr<Task> Meta::BaseEntity::getCurrentTask() +Task::Ptr Meta::BaseEntity::getCurrentTask() { if(m_updateStatus == UpdateStatus::InProgress) { diff --git a/launcher/meta/BaseEntity.h b/launcher/meta/BaseEntity.h index eff43879..75fa384a 100644 --- a/launcher/meta/BaseEntity.h +++ b/launcher/meta/BaseEntity.h @@ -20,8 +20,8 @@ #include "QObjectPtr.h" #include "net/Mode.h" +#include "net/NetJob.h" -class Task; namespace Meta { class BaseEntity @@ -54,7 +54,7 @@ public: bool shouldStartRemoteUpdate() const; void load(Net::Mode loadType); - shared_qobject_ptr<Task> getCurrentTask(); + Task::Ptr getCurrentTask(); protected: /* methods */ bool loadLocalFile(); @@ -62,6 +62,6 @@ protected: /* methods */ private: LoadStatus m_loadStatus = LoadStatus::NotLoaded; UpdateStatus m_updateStatus = UpdateStatus::NotDone; - shared_qobject_ptr<Task> m_updateTask; + NetJob::Ptr m_updateTask; }; } diff --git a/launcher/meta/Index_test.cpp b/launcher/meta/Index_test.cpp index b0892070..5d3ddc50 100644 --- a/launcher/meta/Index_test.cpp +++ b/launcher/meta/Index_test.cpp @@ -3,19 +3,12 @@ #include "meta/Index.h" #include "meta/VersionList.h" -#include "Env.h" class IndexTest : public QObject { Q_OBJECT private slots: - void test_isProvidedByEnv() - { - QVERIFY(ENV.metadataIndex()); - QCOMPARE(ENV.metadataIndex(), ENV.metadataIndex()); - } - void test_hasUid_and_getList() { Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")}); diff --git a/launcher/meta/VersionList.cpp b/launcher/meta/VersionList.cpp index 607007eb..6d23ce9a 100644 --- a/launcher/meta/VersionList.cpp +++ b/launcher/meta/VersionList.cpp @@ -29,7 +29,7 @@ VersionList::VersionList(const QString &uid, QObject *parent) setObjectName("Version list: " + uid); } -shared_qobject_ptr<Task> VersionList::getLoadTask() +Task::Ptr VersionList::getLoadTask() { load(Net::Mode::Online); return getCurrentTask(); diff --git a/launcher/meta/VersionList.h b/launcher/meta/VersionList.h index 58cdafe7..378255df 100644 --- a/launcher/meta/VersionList.h +++ b/launcher/meta/VersionList.h @@ -41,7 +41,7 @@ public: VersionPtrRole }; - shared_qobject_ptr<Task> getLoadTask() override; + Task::Ptr getLoadTask() override; bool isLoaded() override; const BaseVersionPtr at(int i) const override; int count() const override; |