2022-06-04 03:38:01 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ModIndex.h"
|
2022-06-16 20:15:29 +05:30
|
|
|
#include "net/NetJob.h"
|
2022-06-04 03:38:01 +05:30
|
|
|
|
2022-07-24 23:43:42 +05:30
|
|
|
#include "modplatform/helpers/HashUtils.h"
|
|
|
|
|
|
|
|
#include "tasks/ConcurrentTask.h"
|
|
|
|
|
2022-06-04 03:38:01 +05:30
|
|
|
class Mod;
|
|
|
|
class QDir;
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-07-24 23:43:42 +05:30
|
|
|
Task::Ptr getHashingTask() { return m_hashing_task; }
|
|
|
|
|
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-07-24 23:43:42 +05:30
|
|
|
enum class RemoveFromList {
|
|
|
|
Yes,
|
|
|
|
No
|
|
|
|
};
|
2022-08-03 00:08:51 +05:30
|
|
|
void emitReady(Mod*, QString key = {}, RemoveFromList = RemoveFromList::Yes);
|
|
|
|
void emitFail(Mod*, QString key = {}, RemoveFromList = RemoveFromList::Yes);
|
2022-06-16 20:15:29 +05:30
|
|
|
|
2022-07-24 23:43:42 +05:30
|
|
|
// Hashes and stuff
|
|
|
|
auto createNewHash(Mod*) -> Hashing::Hasher::Ptr;
|
|
|
|
auto getExistingHash(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;
|
2022-07-24 23:43:42 +05:30
|
|
|
ConcurrentTask* m_hashing_task;
|
2022-06-16 20:15:29 +05:30
|
|
|
NetJob* m_current_task;
|
2022-06-04 03:38:01 +05:30
|
|
|
};
|