summaryrefslogtreecommitdiffstats
path: root/api/logic/modplatform/FtbPackDownloader.h
blob: c5cc9bd23a986c992509104f05c16f61d45f6a47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <QString>
#include <QUrl>
#include <QList>
#include <QObject>
#include "FtbPackFetchTask.h"
#include "tasks/Task.h"
#include "net/NetJob.h"

#include "PackHelpers.h"
#include "Env.h"

#pragma once

class FtbPackDownloader;
class MULTIMC_LOGIC_EXPORT FtbPackDownloader : public QObject {

	Q_OBJECT

private:
	QMap<QString, FtbModpack> fetchedPacks;
	bool fetching = false;
	bool done = false;

	FtbModpack selected;
	QString selectedVersion;
	QString downloadPath;

	FtbPackFetchTask *fetchTask = 0;
	NetJobPtr netJobContainer;

	void _downloadSucceeded();
	void _downloadFailed(QString reason);
	void _downloadProgress(qint64 current, qint64 total);

private slots:
	void fetchSuccess(FtbModpackList modlist);
	void fetchFailed(QString reason);

public:
	FtbPackDownloader();
	~FtbPackDownloader();

	bool isValidPackSelected();
	void selectPack(FtbModpack modpack, QString version);

	FtbModpack getSelectedPack();

	void fetchModpacks(bool force);
	void downloadSelected(MetaEntryPtr cache);

	QString getSuggestedInstanceName();

	FtbModpackList getModpacks();
	NetJobPtr getNetJob();

signals:
	void ready();
	void packFetchFailed();

	void downloadSucceded(QString archivePath);
	void downloadFailed(QString reason);
	void downloadProgress(qint64 current, qint64 total);

};