forked from CMon/QHumble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhumblebundleapi.h
59 lines (46 loc) · 1.5 KB
/
humblebundleapi.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
#pragma once
#include <QObject>
#include "humbledb.h"
#include <QSqlQueryModel>
#include <QApplication>
class QNetworkAccessManager;
class QNetworkReply;
class HumbleBundleAPI : public QObject
{
Q_OBJECT
public:
HumbleBundleAPI(QApplication *parent);
Q_INVOKABLE void setCredentials(const QString & login, const QString & password, const QString & twoFactor, const QString & reCaptchaResponse);
Q_INVOKABLE void updateOrderList();
Q_INVOKABLE bool isLoggedIn() { return isLoggedIn_; }
Q_INVOKABLE bool isRefreshNeeded();
Q_INVOKABLE void updateOrder(const QString & orderId);
Q_INVOKABLE QVariant purchaseModel();
Q_INVOKABLE QVariant productsModel(int purchaseId);
Q_INVOKABLE QVariant productPlatforms(int product);
Q_INVOKABLE QVariant downloadsModel(int product);
Q_INVOKABLE QVariant filesModel(int download);
Q_INVOKABLE QVariant filterablePurchaseModel();
signals:
void orderListUpdated();
void loginSucceeded();
void loginError(const QString & error);
void error(const QString & error);
private slots:
void onFinished(QNetworkReply * reply);
private:
void login();
void parseOrderList(const QByteArray & json);
void parseProductList(const QByteArray & json);
void completedParsingOnePurchase();
HumbleDB db;
private:
QString username_;
QString password_;
QString twoFactor_;
QString reCaptcha_;
int refreshCounter = 0;
QApplication *parentApp;
QNetworkAccessManager * networkAccessManager_;
bool isLoggedIn_;
};