-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfclientupdater.h
118 lines (95 loc) · 2.6 KB
/
fclientupdater.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef FCLIENTUPDATER_H
#define FCLIENTUPDATER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QUrl>
#include <QString>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QFile>
#include <QDir>
#include <QFile>
#include <QDataStream>
#include "flogging.h"
#include <QDebug>
#include "fdb.h"
#include "libfusion_global.h"
enum FUpdaterResult { UpToDate, ErrorOnCheckingOnline, ErrorOnCheckingLocal, StableAvailable, NightlyAvailable };
enum FusionVersions { Stable, Beta, Nightly };
enum FusionSources { srcStable, srcStable_Alt, srcNightly, srcNightly_Alt };
struct FusionVersion {
int Major = 0;
int Minor = 0;
int Build = 0;
QString Name = "";
bool initialized = false;
bool operator==(FusionVersion a) {
return a.Build == Build && a.Minor == Minor && a.Major == Major;
}
bool operator>(FusionVersion a) {
if (Major > a.Major)
return true;
else
{
if(Minor > a.Minor )
return true;
else
{
if(Build > a.Build)
return true;
}
}
return false;
}
bool operator<(FusionVersion a) {
if (Major < a.Major)
return true;
else
{
if(Minor < a.Minor )
return true;
else
{
if(Build < a.Build)
return true;
}
}
return false;
}
QString toString() {
return QString::number(Major) + "." + QString::number(Minor) + "." + QString::number(Build);
}
};
struct VersionCheckResult {
FusionVersion VersionOnline;
FusionVersion VersionLocal;
FusionSources Source;
FUpdaterResult Status;
QString Error;
};
class LIBFUSIONSHARED_EXPORT FClientUpdater : public QObject
{
Q_OBJECT
public:
explicit FClientUpdater(QObject *parent = 0);
VersionCheckResult getLatestVersion(FusionVersions version);
//Get downloaded client version.
FusionVersion getInstalledVersion();
bool fileExists(QString filePath);
//Read/Write version info
void writeVersion(QString version, QString currentPath);
QString readVersion(QString filePath);
QString readPath();
FusionVersion strToVersion(QString VStr);
QString VersionToStr(FusionVersion v);
VersionCheckResult checkForUpdate(bool useNightly);
private:
QNetworkAccessManager *manager;
QDir *qd = new QDir();
FDB db;
VersionCheckResult readOnlineVersionFile(QString URL);
signals:
public slots:
};
#endif // FCLIENTUPDATER_H