-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhumblebundleapi.h
More file actions
97 lines (76 loc) · 1.85 KB
/
Copy pathhumblebundleapi.h
File metadata and controls
97 lines (76 loc) · 1.85 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
#include <QObject>
class QNetworkAccessManager;
class QNetworkReply;
class HumbleDownload
{
public:
QString machine_name;
QString platform;
QString url;
QString toString() const {
return
"machine_name: " + machine_name + "\n" +
"platform: " + platform + "\n" +
"url: " + url + "\n"
;
}
};
class HumbleProduct
{
public:
QString human_name;
QString machine_name;
QString iconUrl;
QList<HumbleDownload> downloads;
QString toString() const {
QString retval =
"human_name: " + human_name + "\n" +
"machine_name: " + machine_name + "\n" +
"iconUrl: " + iconUrl + "\n"
;
foreach(const HumbleDownload & download, downloads) {
retval += "download: " + download.toString();
}
return retval;
}
};
class HumbleOrder
{
public:
HumbleOrder() : isBundle(false) {}
QString toString () const {
return
"isBundle: " + QString::number((int) isBundle) + "\n" +
"human_name: " + human_name + "\n" +
"orderId: " + orderId + "\n"
;
}
public:
bool isBundle;
QString human_name;
QString orderId;
};
class HumbleBundleAPI : public QObject
{
public:
HumbleBundleAPI();
void setCredentials(const QString & login, const QString & password);
void updateOrderList();
bool isLoggedIn() { return isLoggedIn_; }
void updateOrder(const QString & orderId);
signals:
void orderListUpdated();
void error(const QString & error);
private slots:
void onFinished(QNetworkReply * reply);
private:
void login();
QList<HumbleOrder> parseOrderList(const QByteArray & json);
QList<HumbleProduct> parseProductList(const QByteArray & json);
private:
QString username_;
QString password_;
QNetworkAccessManager * networkAccessManager_;
bool isLoggedIn_;
};