-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapiv3.h
77 lines (56 loc) · 2.28 KB
/
apiv3.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
//Copyright (C) 2020 Illotros GmbH
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License.
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//You should have received a copy of the GNU General Public License
//along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef APIV3_H
#define APIV3_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonObject>
#include <qtimer.h>
#include "userdata.h"
#include "zkacrypto.h"
#include "urlencoding.h"
class APIV3: public QObject
{
Q_OBJECT
public:
explicit APIV3(QObject *parent = nullptr);
void mastersecretRequest(const QHash<QString, QString> ¶meters);
void VPNProfileRequest(UserData &user);
signals:
void serverResponseMasterSecretReady(QByteArray mastersecret);
void wrongCredentials();
void networkError(int);
void serverResponseTokensReady(QByteArray tokens, QByteArray separator);
void invalidSubscription();
void publicKeyNotRegistered();
void repeateVPNProfileRequest();
void openVPNObjectReady(QJsonValue ovpn_object);
void updateIp(QString host, QString ip);
public slots:
void getPublicIP(bool check_ip, QString host);
void tokensRequest(UserData &user);
private:
QNetworkAccessManager network_access_manager;
QNetworkRequest generateRequest(QUrl url);
QUrl m_api_url;
private slots:
void mastersecretHandleReply();
void tokensHandleReply(UserData &user, bool retry);
void revalidateHandleReply(UserData &user);
void serverKeyRequest(UserData &user, bool retry, bool revalidate);
void serverKeyHandleReply(UserData &user, bool retry, bool revalidate);
void VPNProfileHandleReply();
void getPublicIpHandleReply(QString host);
void initiateTokenFetch(UserData &user, bool retry, QJsonValue server_token, QByteArray server_key);
void initiateRevalidate(UserData &user, QJsonValue server_token, QByteArray server_key);
};
#endif // APIV3_H