-
Notifications
You must be signed in to change notification settings - Fork 14
/
googleplayapi.h
87 lines (61 loc) · 2.15 KB
/
googleplayapi.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
#ifndef GOOGLEPLAYAPI_H
#define GOOGLEPLAYAPI_H
#include <QFuture>
#include <QObject>
#include <QMutex>
#include <QThread>
#include <QSettings>
#include <future>
#include <playapi/api.h>
class GoogleLoginHelper;
class GooglePlayApi : public QObject {
Q_OBJECT
Q_PROPERTY(GoogleLoginHelper* login READ getLogin WRITE setLogin)
Q_PROPERTY(GooglePlayApiStatus status READ getStatus NOTIFY statusChanged)
public:
enum class GooglePlayApiStatus {
NOT_READY, PENDING, FAILED, SUCCEDED
};
Q_ENUM(GooglePlayApiStatus)
private:
QScopedPointer<playapi::api> api;
GoogleLoginHelper* loginHelper = nullptr;
QMutex checkinMutex;
playapi::checkin_result checkinResult;
std::promise<std::pair<bool, bool>> tosApprovalPromise;
GooglePlayApiStatus status = GooglePlayApiStatus::NOT_READY;
QFuture<void> updateLoginTask;
QString CheckinInfoGroup();
void loadCheckinInfo();
void saveCheckinInfo();
void loadApiInfo();
void saveApiInfo();
void setStatus(GooglePlayApiStatus status) {
if (this->status != status) {
this->status = status;
statusChanged();
}
}
void updateLogin();
public:
explicit GooglePlayApi(QObject *parent = nullptr);
void setLogin(GoogleLoginHelper* helper);
GoogleLoginHelper* getLogin() { return loginHelper; }
playapi::api* getApi() { return api.data(); }
GooglePlayApiStatus getStatus() const { return status; }
signals:
void ready();
void initError(QString const& text);
void tosApprovalRequired(QString const& tosText, QString const& marketingText);
void appInfoReceived(QString const& packageName, QString const& version, int versionCode, bool isBeta);
void appInfoFailed(QString const& packageName, QString errorMessage);
void statusChanged();
public slots:
void requestAppInfo(QString const& packageName);
void validateLicense(std::string packagename, int versionscode, std::function<void (bool)> callback);
void setTosApproved(bool approved, bool marketing) {
tosApprovalPromise.set_value({approved, marketing});
}
void cleanupLogin();
};
#endif // GOOGLEPLAYAPI_H