2026-05-07 14:34:40 +03:00
|
|
|
#ifndef PAIRINGCONTROLLER_H
|
|
|
|
|
#define PAIRINGCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
|
|
#include "core/utils/errorCodes.h"
|
|
|
|
|
|
|
|
|
|
class SecureAppSettingsRepository;
|
|
|
|
|
|
|
|
|
|
class PairingController
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
struct QrPairingConfigPayload
|
|
|
|
|
{
|
|
|
|
|
QString config;
|
|
|
|
|
QJsonObject serviceInfo;
|
|
|
|
|
QJsonArray supportedProtocols;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit PairingController(SecureAppSettingsRepository *appSettingsRepository);
|
|
|
|
|
|
|
|
|
|
int pairingLongPollTimeoutMsecs() const;
|
|
|
|
|
|
|
|
|
|
QJsonObject buildGenerateQrPayload(const QString &qrUuid) const;
|
|
|
|
|
QJsonObject buildScanQrPayload(const QString &qrUuid, const QString &vpnConfig, const QJsonObject &serviceInfo,
|
2026-05-13 12:48:06 +03:00
|
|
|
const QJsonArray &supportedProtocols, const QString &apiKey, const QString &serviceType,
|
|
|
|
|
const QString &userCountryCode) const;
|
2026-05-07 14:34:40 +03:00
|
|
|
|
|
|
|
|
static amnezia::ErrorCode parseGenerateQrResponseBody(const QByteArray &responseBody, QrPairingConfigPayload &outPayload);
|
2026-05-08 09:56:04 +03:00
|
|
|
static amnezia::ErrorCode parseScanQrResponseBody(const QByteArray &responseBody, QString *outOptionalDisplayName = nullptr);
|
2026-05-07 14:34:40 +03:00
|
|
|
|
2026-05-13 12:48:06 +03:00
|
|
|
static amnezia::ErrorCode validatePairingScanFields(const QString &qrUuid, const QString &vpnConfig, const QString &apiKey,
|
|
|
|
|
const QString &serviceType, const QString &userCountryCode);
|
2026-05-07 19:15:28 +03:00
|
|
|
|
2026-05-18 16:02:51 +03:00
|
|
|
static QJsonArray gatewayStringMetadataArray(const QString &value);
|
|
|
|
|
|
2026-05-07 14:34:40 +03:00
|
|
|
private:
|
|
|
|
|
SecureAppSettingsRepository *m_appSettingsRepository;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PAIRINGCONTROLLER_H
|