2023-12-05 17:38:38 +07:00
|
|
|
#ifndef APICONTROLLER_H
|
|
|
|
|
#define APICONTROLLER_H
|
2023-10-12 20:48:03 +05:00
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
2023-12-05 17:38:38 +07:00
|
|
|
#include "configurators/openvpn_configurator.h"
|
2023-10-12 20:48:03 +05:00
|
|
|
|
2024-05-16 06:19:56 -07:00
|
|
|
#ifdef Q_OS_IOS
|
|
|
|
|
#include "platforms/ios/ios_controller.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-12-05 17:38:38 +07:00
|
|
|
class ApiController : public QObject
|
2023-10-12 20:48:03 +05:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2024-09-09 16:27:29 +04:00
|
|
|
explicit ApiController(const QString &gatewayEndpoint, bool isDevEnvironment, QObject *parent = nullptr);
|
2023-10-12 20:48:03 +05:00
|
|
|
|
|
|
|
|
public slots:
|
2024-05-16 06:19:56 -07:00
|
|
|
void updateServerConfigFromApi(const QString &installationUuid, const int serverIndex, QJsonObject serverConfig);
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
ErrorCode getServicesList(QByteArray &responseBody);
|
|
|
|
|
ErrorCode getConfigForService(const QString &installationUuid, const QString &userCountryCode, const QString &serviceType,
|
|
|
|
|
const QString &protocol, const QString &serverCountryCode, QJsonObject &serverConfig);
|
|
|
|
|
|
2024-05-16 06:19:56 -07:00
|
|
|
signals:
|
2024-05-25 13:00:51 +03:00
|
|
|
void errorOccurred(ErrorCode errorCode);
|
2024-08-20 16:54:05 +07:00
|
|
|
void finished(const QJsonObject &config, const int serverIndex);
|
2023-10-12 20:48:03 +05:00
|
|
|
|
|
|
|
|
private:
|
2024-05-16 06:19:56 -07:00
|
|
|
struct ApiPayloadData
|
|
|
|
|
{
|
2024-01-22 16:51:11 +03:00
|
|
|
OpenVpnConfigurator::ConnectionData certRequest;
|
2023-10-12 20:48:03 +05:00
|
|
|
|
2024-01-22 16:51:11 +03:00
|
|
|
QString wireGuardClientPrivKey;
|
2024-01-30 00:47:22 +07:00
|
|
|
QString wireGuardClientPubKey;
|
2024-01-22 16:51:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ApiPayloadData generateApiPayloadData(const QString &protocol);
|
|
|
|
|
QJsonObject fillApiPayload(const QString &protocol, const ApiController::ApiPayloadData &apiPayloadData);
|
2024-08-20 16:54:05 +07:00
|
|
|
void fillServerConfig(const QString &protocol, const ApiController::ApiPayloadData &apiPayloadData, const QByteArray &apiResponseBody,
|
|
|
|
|
QJsonObject &serverConfig);
|
|
|
|
|
QStringList getProxyUrls();
|
|
|
|
|
|
|
|
|
|
QString m_gatewayEndpoint;
|
|
|
|
|
QStringList m_proxyUrls;
|
2024-09-10 22:03:10 +04:00
|
|
|
bool m_isDevEnvironment = false;
|
2023-10-12 20:48:03 +05:00
|
|
|
};
|
|
|
|
|
|
2023-12-05 17:38:38 +07:00
|
|
|
#endif // APICONTROLLER_H
|