-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgoogleversionchannel.h
80 lines (65 loc) · 2.74 KB
/
googleversionchannel.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
#ifndef GOOGLEVERSIONCHANNEL_H
#define GOOGLEVERSIONCHANNEL_H
#include <QObject>
#include <QSettings>
#include "googleplayapi.h"
class GooglePlayApi;
class GoogleVersionChannel : public QObject {
Q_OBJECT
Q_PROPERTY(GooglePlayApi* playApi MEMBER m_playApi WRITE setPlayApi)
Q_PROPERTY(QString latestVersion READ latestVersion NOTIFY latestVersionChanged)
Q_PROPERTY(qint32 latestVersionCode READ latestVersionCode NOTIFY latestVersionChanged)
Q_PROPERTY(bool latestVersionIsBeta READ latestVersionIsBeta NOTIFY latestVersionChanged)
Q_PROPERTY(GoogleVersionChannelStatus status READ getStatus NOTIFY statusChanged)
Q_PROPERTY(bool trialMode MEMBER m_trialMode WRITE setTrialMode NOTIFY statusChanged)
Q_PROPERTY(bool hasVerifiedLicense MEMBER m_hasVerifiedLicense NOTIFY statusChanged)
Q_PROPERTY(GoogleVersionChannelLicenceStatus licenseStatus READ getLicenseStatus NOTIFY statusChanged)
public:
enum class GoogleVersionChannelStatus {
NOT_READY, PENDING, FAILED, SUCCEDED
};
Q_ENUM(GoogleVersionChannelStatus)
enum class GoogleVersionChannelLicenceStatus {
NOT_READY, PENDING, FAILED, SUCCEDED, OFFLINE
};
Q_ENUM(GoogleVersionChannelLicenceStatus)
private:
QSettings m_settings;
GooglePlayApi* m_playApi = nullptr;
QString m_latestVersion;
qint32 m_latestVersionCode;
qint32 m_latestVersionIsBeta;
bool m_hasVerifiedLicense = false;
bool m_trialMode = false;
GoogleVersionChannelStatus status = GoogleVersionChannelStatus::NOT_READY;
GoogleVersionChannelLicenceStatus licenseStatus = GoogleVersionChannelLicenceStatus::NOT_READY;
void onApiReady();
void onStatusChanged();
void onAppInfoReceived(QString const& packageName, QString const& version, int versionCode, bool isBeta);
void onAppInfoFailed(QString const& packageName, const QString &errorMessage);
void setStatus(GoogleVersionChannelStatus status) {
if (this->status != status) {
this->status = status;
statusChanged();
}
}
void setTrialMode(bool trialMode) {
if (m_trialMode != trialMode ) {
m_trialMode = trialMode;
onStatusChanged();
}
}
public:
GoogleVersionChannel();
void setPlayApi(GooglePlayApi* value);
QString const& latestVersion() const { return m_latestVersion; }
qint32 latestVersionCode() const { return m_latestVersionCode; }
bool latestVersionIsBeta() const { return m_latestVersionIsBeta; }
GoogleVersionChannelStatus getStatus() const { return status; }
GoogleVersionChannelLicenceStatus getLicenseStatus() const { return licenseStatus; }
public slots:
signals:
void latestVersionChanged();
void statusChanged();
};
#endif // GOOGLEVERSIONCHANNEL_H