2023-05-22 22:11:20 +08:00
|
|
|
#ifndef IMPORTCONTROLLER_H
|
|
|
|
|
#define IMPORTCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
#include "containers/containers_defs.h"
|
2023-07-24 16:31:04 +09:00
|
|
|
#include "core/defs.h"
|
2023-05-22 22:11:20 +08:00
|
|
|
#include "ui/models/containers_model.h"
|
2023-07-24 16:31:04 +09:00
|
|
|
#include "ui/models/servers_model.h"
|
2023-05-22 22:11:20 +08:00
|
|
|
|
|
|
|
|
class ImportController : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit ImportController(const QSharedPointer<ServersModel> &serversModel,
|
|
|
|
|
const QSharedPointer<ContainersModel> &containersModel,
|
2023-07-24 16:31:04 +09:00
|
|
|
const std::shared_ptr<Settings> &settings, QObject *parent = nullptr);
|
2023-05-22 22:11:20 +08:00
|
|
|
|
|
|
|
|
public slots:
|
2023-06-05 15:49:10 +08:00
|
|
|
void importConfig();
|
2023-07-24 16:31:04 +09:00
|
|
|
void extractConfigFromFile();
|
|
|
|
|
void extractConfigFromData(QString &data);
|
2023-06-05 15:49:10 +08:00
|
|
|
void extractConfigFromCode(QString code);
|
2023-07-24 16:31:04 +09:00
|
|
|
void extractConfigFromQr();
|
2023-06-05 15:49:10 +08:00
|
|
|
QString getConfig();
|
|
|
|
|
QString getConfigFileName();
|
2023-05-22 22:11:20 +08:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void importFinished();
|
2023-06-05 15:49:10 +08:00
|
|
|
void importErrorOccurred(QString errorMessage);
|
2023-06-13 20:03:20 +09:00
|
|
|
|
2023-05-22 22:11:20 +08:00
|
|
|
private:
|
2023-06-05 15:49:10 +08:00
|
|
|
QJsonObject extractAmneziaConfig(QString &data);
|
|
|
|
|
QJsonObject extractOpenVpnConfig(const QString &data);
|
|
|
|
|
QJsonObject extractWireGuardConfig(const QString &data);
|
2023-05-22 22:11:20 +08:00
|
|
|
|
|
|
|
|
QSharedPointer<ServersModel> m_serversModel;
|
|
|
|
|
QSharedPointer<ContainersModel> m_containersModel;
|
|
|
|
|
std::shared_ptr<Settings> m_settings;
|
|
|
|
|
|
2023-06-05 15:49:10 +08:00
|
|
|
QJsonObject m_config;
|
|
|
|
|
QString m_configFileName;
|
2023-05-22 22:11:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // IMPORTCONTROLLER_H
|