2018-02-28 18:42:30 +00:00
|
|
|
#pragma once
|
2018-03-19 01:36:12 +00:00
|
|
|
#include "InstanceTask.h"
|
2018-02-28 18:42:30 +00:00
|
|
|
#include "net/NetJob.h"
|
2022-01-24 21:55:57 +00:00
|
|
|
#include <quazip/quazip.h>
|
|
|
|
#include <quazip/quazipdir.h>
|
2018-03-03 20:22:00 +00:00
|
|
|
#include "meta/Index.h"
|
|
|
|
#include "meta/Version.h"
|
|
|
|
#include "meta/VersionList.h"
|
2019-11-03 22:48:12 +00:00
|
|
|
#include "PackHelpers.h"
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2021-11-21 22:21:12 +00:00
|
|
|
#include "net/NetJob.h"
|
|
|
|
|
2022-07-20 13:21:44 +01:00
|
|
|
#include <optional>
|
2021-02-09 04:04:23 +00:00
|
|
|
|
2019-11-03 22:48:12 +00:00
|
|
|
namespace LegacyFTB {
|
|
|
|
|
2021-07-25 18:11:59 +01:00
|
|
|
class PackInstallTask : public InstanceTask
|
2018-08-01 23:52:31 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
Q_OBJECT
|
2018-02-28 18:42:30 +00:00
|
|
|
|
|
|
|
public:
|
2021-11-21 22:21:12 +00:00
|
|
|
explicit PackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, Modpack pack, QString version);
|
2019-11-03 22:48:12 +00:00
|
|
|
virtual ~PackInstallTask(){}
|
2018-03-19 01:36:12 +00:00
|
|
|
|
2021-07-06 15:10:35 +01:00
|
|
|
bool canAbort() const override { return true; }
|
2018-07-15 13:51:05 +01:00
|
|
|
bool abort() override;
|
2018-02-28 18:42:30 +00:00
|
|
|
|
|
|
|
protected:
|
2018-07-15 13:51:05 +01:00
|
|
|
//! Entry point for tasks.
|
|
|
|
virtual void executeTask() override;
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2018-03-19 01:36:12 +00:00
|
|
|
private:
|
2018-07-15 13:51:05 +01:00
|
|
|
void downloadPack();
|
|
|
|
void unzip();
|
|
|
|
void install();
|
2018-02-28 18:42:30 +00:00
|
|
|
|
|
|
|
private slots:
|
2018-07-15 13:51:05 +01:00
|
|
|
void onDownloadSucceeded();
|
|
|
|
void onDownloadFailed(QString reason);
|
|
|
|
void onDownloadProgress(qint64 current, qint64 total);
|
2022-07-28 19:58:04 +01:00
|
|
|
void onDownloadAborted();
|
2018-02-28 18:42:30 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
void onUnzipFinished();
|
|
|
|
void onUnzipCanceled();
|
2018-03-03 20:22:00 +00:00
|
|
|
|
2018-03-19 01:36:12 +00:00
|
|
|
private: /* data */
|
2021-11-21 22:21:12 +00:00
|
|
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
2018-07-15 13:51:05 +01:00
|
|
|
bool abortable = false;
|
|
|
|
std::unique_ptr<QuaZip> m_packZip;
|
2022-07-20 13:21:44 +01:00
|
|
|
QFuture<std::optional<QStringList>> m_extractFuture;
|
|
|
|
QFutureWatcher<std::optional<QStringList>> m_extractFutureWatcher;
|
2021-11-21 22:21:12 +00:00
|
|
|
NetJob::Ptr netJobContainer;
|
2018-07-15 13:51:05 +01:00
|
|
|
QString archivePath;
|
|
|
|
|
2019-11-03 22:48:12 +00:00
|
|
|
Modpack m_pack;
|
2018-07-15 13:51:05 +01:00
|
|
|
QString m_version;
|
2018-02-28 18:42:30 +00:00
|
|
|
};
|
2019-11-03 22:48:12 +00:00
|
|
|
|
|
|
|
}
|