This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiclient.h
111 lines (88 loc) · 2.49 KB
/
apiclient.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef APICLIENT_H
#define APICLIENT_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
namespace VRChad {
class ApiClient : public QObject {
Q_OBJECT
public:
enum class LoginStatus
{
LoggedOut,
LoggingOut,
LoggingIn,
LoggedIn
};
enum class Privacy
{
Public,
FriendsPlus,
Friends,
InvitePlus,
Invite
};
enum class Region
{
US,
EU,
JP
};
static QString genAuthCookie(const QString& username, const QString& password);
static QString genHardwareId();
ApiClient(QObject* parent = nullptr);
LoginStatus loginStatus() const;
QString currentHwid() const;
QString currentUserId() const;
QString photonAuthToken() const;
QString clientVersion() const;
QString photonServerName() const;
void login(QString authCookie);
signals:
void gotApiConfig();
void gotPhotonConfig();
void loginStatusChanged(VRChad::ApiClient::LoginStatus);
private:
void setLoginStatus(LoginStatus status);
enum HttpContentType {
UrlEncoded,
Json,
};
QNetworkRequest createApiRequest(const QString& ext, HttpContentType contentType, std::uint32_t contentLength, bool addQueries);
void ensureConfigs(std::function<void()> needsConfigs);
void getPhotonConfig(std::function<void()> needsConfig);
void apiGetConfig(std::function<void()> needsConfig);
void apiGetLogin();
void apiGetUserInfo(const QString& userId);
void apiGetWorldMetadata(const QString& worldId);
void apiPutPingWorld(const QString& userId, const QString& worldId);
void onSslError(const QList<QSslError>&);
void onNetworkError(QNetworkReply::NetworkError);
QUrl m_baseUrl;
QString m_apiPath;
QNetworkAccessManager* m_networkManager;
LoginStatus m_loginStatus;
QString m_pendingAuth;
QString m_hwid;
QString m_userAgent;
QString m_unityVersion;
QString m_clientVersion;
QString m_photonServerName;
bool m_apiGotConfig;
bool m_photonGotConfig;
QString m_serverName;
QString m_buildVersionTag;
QString m_token_apiKey;
QString m_token_2fa;
QString m_token_auth;
int m_updateRateMsMaximum;
int m_updateRateMsMinimum;
int m_updateRateMsNormal;
int m_updateRateMsUdonManual;
QString m_releaseServerVersionStandalone;
QString m_photonAuthToken;
QString m_currentUserId;
QString m_currentAvatarId;
};
}
#endif // APICLIENT_H