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