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-11-25 17:53:46 +05:30
|
|
|
EnsureMetadataTask(Mod*, QDir, ModPlatform::ResourceProvider = ModPlatform::ResourceProvider::MODRINTH);
|
|
|
|
EnsureMetadataTask(QList<Mod*>&, QDir, ModPlatform::ResourceProvider = ModPlatform::ResourceProvider::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
|
2023-01-03 22:28:27 +05:30
|
|
|
auto modrinthVersionsTask() -> Task::Ptr;
|
|
|
|
auto modrinthProjectsTask() -> Task::Ptr;
|
2022-06-16 20:15:29 +05:30
|
|
|
|
2023-01-03 22:28:27 +05:30
|
|
|
auto flameVersionsTask() -> Task::Ptr;
|
|
|
|
auto flameProjectsTask() -> Task::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-11-25 17:53:46 +05:30
|
|
|
ModPlatform::ResourceProvider m_provider;
|
2022-06-04 03:38:01 +05:30
|
|
|
|
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;
|
2023-01-03 22:28:27 +05:30
|
|
|
Task::Ptr m_current_task;
|
2022-06-04 03:38:01 +05:30
|
|
|
};
|