aboutsummaryrefslogtreecommitdiff
path: root/launcher/meta
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-11-21 23:21:12 +0100
committerPetr Mrázek <peterix@gmail.com>2021-11-21 23:21:12 +0100
commit69213b1206e97f7d4db4270a4b3b0af41dc9e6fc (patch)
treeb53ca69422ce22cceee9e648171a678679075c1a /launcher/meta
parentc2c56a2f6ceaedb8a3fa88c848b345db0fec7f9c (diff)
downloadPrismLauncher-69213b1206e97f7d4db4270a4b3b0af41dc9e6fc.tar.gz
PrismLauncher-69213b1206e97f7d4db4270a4b3b0af41dc9e6fc.tar.bz2
PrismLauncher-69213b1206e97f7d4db4270a4b3b0af41dc9e6fc.zip
NOISSUE continue refactoring things to make tests pass
Diffstat (limited to 'launcher/meta')
-rw-r--r--launcher/meta/BaseEntity.cpp18
-rw-r--r--launcher/meta/BaseEntity.h6
-rw-r--r--launcher/meta/Index_test.cpp7
3 files changed, 10 insertions, 21 deletions
diff --git a/launcher/meta/BaseEntity.cpp b/launcher/meta/BaseEntity.cpp
index 1618c999..9aa4a3dd 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
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 d5d477e8..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")});