2022-06-04 03:38:01 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ModIndex.h"
|
|
|
|
#include "tasks/SequentialTask.h"
|
2022-06-16 20:15:29 +05:30
|
|
|
#include "net/NetJob.h"
|
2022-06-04 03:38:01 +05:30
|
|
|
|
|
|
|
class Mod;
|
|
|
|
class QDir;
|
|
|
|
class MultipleOptionsTask;
|
|
|
|
|
|
|
|
class EnsureMetadataTask : public Task {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-06-26 22:47:15 +05:30
|
|
|
EnsureMetadataTask(Mod*, QDir, ModPlatform::Provider = ModPlatform::Provider::MODRINTH);
|
2022-07-10 23:45:25 +05:30
|
|
|
EnsureMetadataTask(QList<Mod*>&, QDir, ModPlatform::Provider = ModPlatform::Provider::MODRINTH);
|
2022-06-16 20:15:29 +05:30
|
|
|
|
|
|
|
~EnsureMetadataTask() = default;
|
2022-06-04 03:38:01 +05:30
|
|
|
|
|
|
|
public slots:
|
|
|
|
bool abort() override;
|
|
|
|
protected slots:
|
|
|
|
void executeTask() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// FIXME: Move to their own namespace
|
2022-06-16 20:15:29 +05:30
|
|
|
auto modrinthVersionsTask() -> NetJob::Ptr;
|
|
|
|
auto modrinthProjectsTask() -> NetJob::Ptr;
|
|
|
|
|
|
|
|
auto flameVersionsTask() -> NetJob::Ptr;
|
|
|
|
auto flameProjectsTask() -> NetJob::Ptr;
|
2022-06-04 03:38:01 +05:30
|
|
|
|
|
|
|
// Helpers
|
2022-06-26 22:47:15 +05:30
|
|
|
void emitReady(Mod*);
|
|
|
|
void emitFail(Mod*);
|
2022-06-16 20:15:29 +05:30
|
|
|
|
2022-06-26 22:47:15 +05:30
|
|
|
auto getHash(Mod*) -> QString;
|
2022-06-16 20:15:29 +05:30
|
|
|
|
|
|
|
private slots:
|
2022-06-26 22:47:15 +05:30
|
|
|
void modrinthCallback(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& ver, Mod*);
|
|
|
|
void flameCallback(ModPlatform::IndexedPack& pack, ModPlatform::IndexedVersion& ver, Mod*);
|
2022-06-04 03:38:01 +05:30
|
|
|
|
|
|
|
signals:
|
2022-06-26 22:47:15 +05:30
|
|
|
void metadataReady(Mod*);
|
|
|
|
void metadataFailed(Mod*);
|
2022-06-04 03:38:01 +05:30
|
|
|
|
|
|
|
private:
|
2022-06-26 22:47:15 +05:30
|
|
|
QHash<QString, Mod*> m_mods;
|
2022-06-16 20:15:29 +05:30
|
|
|
QDir m_index_dir;
|
2022-06-04 03:38:01 +05:30
|
|
|
ModPlatform::Provider m_provider;
|
|
|
|
|
2022-06-16 20:15:29 +05:30
|
|
|
QHash<QString, ModPlatform::IndexedVersion> m_temp_versions;
|
|
|
|
NetJob* m_current_task;
|
2022-06-04 03:38:01 +05:30
|
|
|
};
|