-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMudletInstaller.h
More file actions
83 lines (70 loc) · 1.8 KB
/
MudletInstaller.h
File metadata and controls
83 lines (70 loc) · 1.8 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef MUDLETINSTALLER_H
#define MUDLETINSTALLER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QWidget>
#include <QProgressBar>
#include <QLabel>
#include <QStateMachine>
#include <QState>
#include <QFinalState>
struct DownloadInfo {
QString url;
QString appName;
QString sha256;
};
class MudletInstaller : public QObject {
Q_OBJECT
public:
explicit MudletInstaller(QObject *parent = nullptr);
void start();
private slots:
void fetchPlatformFeed();
void onFetchPlatformFeedFinished();
void checkExistingFile();
void startDownload();
void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void onDownloadFinished();
void onDownloadError(QNetworkReply::NetworkError error);
void verifyHash();
void installApplication();
void handleError();
void cleanup();
void retryDownload();
signals:
void feedFetched();
void fileExists();
void fileNotExists();
void downloadComplete();
void hashValid();
void hashInvalid();
void installComplete();
void errorOccurred();
void finished();
private:
QNetworkAccessManager networkManager;
QNetworkReply *currentReply;
void initStateMachine();
QWidget *progressWindow;
QProgressBar *progressBar;
QLabel *statusLabel;
QString fetchedHtml;
QString downloadLink;
QString outputFile;
DownloadInfo info;
int retryCount;
qint64 bytesAlreadyDownloaded;
static const int MAX_RETRIES = 3;
QString gameName;
QStateMachine *m_stateMachine;
QState *m_downloadFeedState;
QState *m_checkExistingState;
QState *m_downloadState;
QState *m_retryState;
QState *m_verifyHashState;
QState *m_installState;
QState *m_errorState;
QFinalState *m_doneState;
};
#endif