2023-06-13 20:03:20 +09:00
|
|
|
#ifndef EXPORTCONTROLLER_H
|
|
|
|
|
#define EXPORTCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
2024-04-01 20:20:02 +07:00
|
|
|
#include "ui/models/clientManagementModel.h"
|
2023-06-13 20:03:20 +09:00
|
|
|
#include "ui/models/containers_model.h"
|
|
|
|
|
#include "ui/models/servers_model.h"
|
|
|
|
|
|
|
|
|
|
class ExportController : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2024-04-01 20:20:02 +07:00
|
|
|
explicit ExportController(const QSharedPointer<ServersModel> &serversModel, const QSharedPointer<ContainersModel> &containersModel,
|
|
|
|
|
const QSharedPointer<ClientManagementModel> &clientManagementModel, const std::shared_ptr<Settings> &settings,
|
|
|
|
|
QObject *parent = nullptr);
|
2023-06-13 20:03:20 +09:00
|
|
|
|
2023-06-16 13:43:55 +09:00
|
|
|
Q_PROPERTY(QList<QString> qrCodes READ getQrCodes NOTIFY exportConfigChanged)
|
|
|
|
|
Q_PROPERTY(int qrCodesCount READ getQrCodesCount NOTIFY exportConfigChanged)
|
2023-07-14 13:14:50 +09:00
|
|
|
Q_PROPERTY(QString config READ getConfig NOTIFY exportConfigChanged)
|
2023-11-25 13:02:02 +07:00
|
|
|
Q_PROPERTY(QString nativeConfigString READ getNativeConfigString NOTIFY exportConfigChanged)
|
2023-06-16 13:43:55 +09:00
|
|
|
|
2023-06-13 20:03:20 +09:00
|
|
|
public slots:
|
|
|
|
|
void generateFullAccessConfig();
|
2023-11-21 20:13:51 +07:00
|
|
|
void generateConnectionConfig(const QString &clientName);
|
|
|
|
|
void generateOpenVpnConfig(const QString &clientName);
|
|
|
|
|
void generateWireGuardConfig(const QString &clientName);
|
2024-02-23 19:55:59 +02:00
|
|
|
void generateAwgConfig(const QString &clientName);
|
2023-10-30 14:20:21 +05:00
|
|
|
void generateShadowSocksConfig();
|
|
|
|
|
void generateCloakConfig();
|
2024-12-10 03:17:16 +01:00
|
|
|
void generateXrayConfig(const QString &clientName);
|
2023-06-16 13:43:55 +09:00
|
|
|
|
2023-07-14 13:14:50 +09:00
|
|
|
QString getConfig();
|
2023-11-25 13:02:02 +07:00
|
|
|
QString getNativeConfigString();
|
2023-06-13 20:03:20 +09:00
|
|
|
QList<QString> getQrCodes();
|
|
|
|
|
|
2023-09-07 22:45:01 +05:00
|
|
|
void exportConfig(const QString &fileName);
|
2023-06-13 20:03:20 +09:00
|
|
|
|
2023-11-23 14:32:16 +07:00
|
|
|
void updateClientManagementModel(const DockerContainer container, ServerCredentials credentials);
|
2023-11-21 20:13:51 +07:00
|
|
|
void revokeConfig(const int row, const DockerContainer container, ServerCredentials credentials);
|
|
|
|
|
void renameClient(const int row, const QString &clientName, const DockerContainer container, ServerCredentials credentials);
|
|
|
|
|
|
2023-06-13 20:03:20 +09:00
|
|
|
signals:
|
2023-07-05 10:15:38 +09:00
|
|
|
void generateConfig(int type);
|
2025-09-03 06:56:08 +03:00
|
|
|
void revokeConfigCompleted();
|
2023-08-08 19:10:14 +05:00
|
|
|
void exportErrorOccurred(const QString &errorMessage);
|
2024-05-25 13:00:51 +03:00
|
|
|
void exportErrorOccurred(ErrorCode errorCode);
|
2023-06-16 13:43:55 +09:00
|
|
|
|
|
|
|
|
void exportConfigChanged();
|
2023-06-13 20:03:20 +09:00
|
|
|
|
2023-09-07 22:45:01 +05:00
|
|
|
void saveFile(const QString &fileName, const QString &data);
|
|
|
|
|
|
2023-06-13 20:03:20 +09:00
|
|
|
private:
|
2023-06-16 13:43:55 +09:00
|
|
|
int getQrCodesCount();
|
|
|
|
|
|
2023-07-05 10:15:38 +09:00
|
|
|
void clearPreviousConfig();
|
|
|
|
|
|
2024-04-01 20:20:02 +07:00
|
|
|
ErrorCode generateNativeConfig(const DockerContainer container, const QString &clientName, const Proto &protocol,
|
|
|
|
|
QJsonObject &jsonNativeConfig);
|
|
|
|
|
|
2023-06-13 20:03:20 +09:00
|
|
|
QSharedPointer<ServersModel> m_serversModel;
|
|
|
|
|
QSharedPointer<ContainersModel> m_containersModel;
|
2023-11-21 20:13:51 +07:00
|
|
|
QSharedPointer<ClientManagementModel> m_clientManagementModel;
|
2023-06-13 20:03:20 +09:00
|
|
|
std::shared_ptr<Settings> m_settings;
|
|
|
|
|
|
2023-07-14 13:14:50 +09:00
|
|
|
QString m_config;
|
2023-11-25 13:02:02 +07:00
|
|
|
QString m_nativeConfigString;
|
2023-06-13 20:03:20 +09:00
|
|
|
QList<QString> m_qrCodes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // EXPORTCONTROLLER_H
|