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