2018-02-28 18:42:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QObject>
|
2023-06-23 17:13:52 +01:00
|
|
|
#include <QTemporaryDir>
|
|
|
|
#include <memory>
|
2018-02-28 18:42:30 +00:00
|
|
|
#include "PackHelpers.h"
|
2023-06-23 17:13:52 +01:00
|
|
|
#include "net/NetJob.h"
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2019-11-03 22:48:12 +00:00
|
|
|
namespace LegacyFTB {
|
|
|
|
|
2021-07-25 18:11:59 +01:00
|
|
|
class PackFetchTask : public QObject {
|
2018-02-28 18:42:30 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
public:
|
|
|
|
PackFetchTask(shared_qobject_ptr<QNetworkAccessManager> network) : QObject(nullptr), m_network(network){};
|
2019-11-03 22:48:12 +00:00
|
|
|
virtual ~PackFetchTask() = default;
|
2018-02-28 18:42:30 +00:00
|
|
|
|
|
|
|
void fetch();
|
2023-06-23 17:13:52 +01:00
|
|
|
void fetchPrivate(const QStringList& toFetch);
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
private:
|
2021-11-21 22:21:12 +00:00
|
|
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
|
|
|
NetJob::Ptr jobPtr;
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
std::shared_ptr<QByteArray> publicModpacksXmlFileData = std::make_shared<QByteArray>();
|
|
|
|
std::shared_ptr<QByteArray> thirdPartyModpacksXmlFileData = std::make_shared<QByteArray>();
|
2018-04-01 19:24:28 +01:00
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
bool parseAndAddPacks(QByteArray& data, PackType packType, ModpackList& list);
|
2019-11-03 22:48:12 +00:00
|
|
|
ModpackList publicPacks;
|
|
|
|
ModpackList thirdPartyPacks;
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
protected slots:
|
2018-02-28 18:42:30 +00:00
|
|
|
void fileDownloadFinished();
|
|
|
|
void fileDownloadFailed(QString reason);
|
2022-07-28 19:58:04 +01:00
|
|
|
void fileDownloadAborted();
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
signals:
|
2019-11-03 22:48:12 +00:00
|
|
|
void finished(ModpackList publicPacks, ModpackList thirdPartyPacks);
|
2018-02-28 18:42:30 +00:00
|
|
|
void failed(QString reason);
|
2022-07-28 19:58:04 +01:00
|
|
|
void aborted();
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2019-11-03 22:48:12 +00:00
|
|
|
void privateFileDownloadFinished(Modpack modpack);
|
2018-08-01 23:52:31 +01:00
|
|
|
void privateFileDownloadFailed(QString reason, QString packCode);
|
2018-02-28 18:42:30 +00:00
|
|
|
};
|
2019-11-03 22:48:12 +00:00
|
|
|
|
2023-06-23 17:13:52 +01:00
|
|
|
} // namespace LegacyFTB
|