App refactoring
This commit is contained in:
parent
b36517babb
commit
510a564797
36 changed files with 526 additions and 443 deletions
212
client/amnezia_application.cpp
Normal file
212
client/amnezia_application.cpp
Normal file
|
@ -0,0 +1,212 @@
|
|||
#include "amnezia_application.h"
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QTimer>
|
||||
#include <QTranslator>
|
||||
|
||||
|
||||
#include "QZXing.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
#include "platforms/ios/QRCodeReaderBase.h"
|
||||
//#include "platforms/ios/MobileUtils.h"
|
||||
|
||||
#include "ui/pages.h"
|
||||
|
||||
#include "ui/pages_logic/AppSettingsLogic.h"
|
||||
#include "ui/pages_logic/GeneralSettingsLogic.h"
|
||||
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
||||
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
||||
#include "ui/pages_logic/QrDecoderLogic.h"
|
||||
#include "ui/pages_logic/ServerConfiguringProgressLogic.h"
|
||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||
#include "ui/pages_logic/ServerListLogic.h"
|
||||
#include "ui/pages_logic/ServerSettingsLogic.h"
|
||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||
#include "ui/pages_logic/ShareConnectionLogic.h"
|
||||
#include "ui/pages_logic/SitesLogic.h"
|
||||
#include "ui/pages_logic/StartPageLogic.h"
|
||||
#include "ui/pages_logic/VpnLogic.h"
|
||||
#include "ui/pages_logic/WizardLogic.h"
|
||||
|
||||
#include "ui/pages_logic/protocols/CloakLogic.h"
|
||||
#include "ui/pages_logic/protocols/OpenVpnLogic.h"
|
||||
#include "ui/pages_logic/protocols/ShadowSocksLogic.h"
|
||||
|
||||
|
||||
AmneziaApplication::AmneziaApplication(int &argc, char *argv[], bool allowSecondary,
|
||||
SingleApplication::Options options, int timeout, const QString &userData):
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
QAPPLICATION_CLASS(argc, argv);
|
||||
#else
|
||||
SingleApplication(argc, argv, allowSecondary, options, timeout, userData)
|
||||
#endif
|
||||
|
||||
|
||||
{
|
||||
setQuitOnLastWindowClosed(false);
|
||||
m_settings = std::shared_ptr<Settings>(new Settings);
|
||||
|
||||
// QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){
|
||||
// QObject::disconnect(engine, 0,0,0);
|
||||
// delete engine;
|
||||
|
||||
// QObject::disconnect(uiLogic, 0,0,0);
|
||||
// delete uiLogic;
|
||||
// });
|
||||
}
|
||||
|
||||
AmneziaApplication::~AmneziaApplication()
|
||||
{
|
||||
QObject::disconnect(m_engine, 0,0,0);
|
||||
delete m_engine;
|
||||
|
||||
QObject::disconnect(m_uiLogic, 0,0,0);
|
||||
delete m_uiLogic;
|
||||
}
|
||||
|
||||
void AmneziaApplication::init()
|
||||
{
|
||||
m_engine = new QQmlApplicationEngine;
|
||||
m_uiLogic = new UiLogic(m_settings);
|
||||
|
||||
const QUrl url(QStringLiteral("qrc:/ui/qml/main.qml"));
|
||||
QObject::connect(m_engine, &QQmlApplicationEngine::objectCreated,
|
||||
this, [url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
QCoreApplication::exit(-1);
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
m_engine->rootContext()->setContextProperty("Debug", &Debug::Instance());
|
||||
|
||||
m_engine->rootContext()->setContextProperty("UiLogic", m_uiLogic);
|
||||
|
||||
m_engine->rootContext()->setContextProperty("AppSettingsLogic", m_uiLogic->appSettingsLogic());
|
||||
m_engine->rootContext()->setContextProperty("GeneralSettingsLogic", m_uiLogic->generalSettingsLogic());
|
||||
m_engine->rootContext()->setContextProperty("NetworkSettingsLogic", m_uiLogic->networkSettingsLogic());
|
||||
m_engine->rootContext()->setContextProperty("NewServerProtocolsLogic", m_uiLogic->newServerProtocolsLogic());
|
||||
m_engine->rootContext()->setContextProperty("QrDecoderLogic", m_uiLogic->qrDecoderLogic());
|
||||
m_engine->rootContext()->setContextProperty("ServerConfiguringProgressLogic", m_uiLogic->serverConfiguringProgressLogic());
|
||||
m_engine->rootContext()->setContextProperty("ServerListLogic", m_uiLogic->serverListLogic());
|
||||
m_engine->rootContext()->setContextProperty("ServerSettingsLogic", m_uiLogic->serverSettingsLogic());
|
||||
m_engine->rootContext()->setContextProperty("ServerContainersLogic", m_uiLogic->serverprotocolsLogic());
|
||||
m_engine->rootContext()->setContextProperty("ShareConnectionLogic", m_uiLogic->shareConnectionLogic());
|
||||
m_engine->rootContext()->setContextProperty("SitesLogic", m_uiLogic->sitesLogic());
|
||||
m_engine->rootContext()->setContextProperty("StartPageLogic", m_uiLogic->startPageLogic());
|
||||
m_engine->rootContext()->setContextProperty("VpnLogic", m_uiLogic->vpnLogic());
|
||||
m_engine->rootContext()->setContextProperty("WizardLogic", m_uiLogic->wizardLogic());
|
||||
|
||||
#if defined(Q_OS_IOS)
|
||||
setStartPageLogic(uiLogic->startPageLogic());
|
||||
#endif
|
||||
|
||||
m_engine->load(url);
|
||||
|
||||
if (m_engine->rootObjects().size() > 0) {
|
||||
m_uiLogic->setQmlRoot(m_engine->rootObjects().at(0));
|
||||
}
|
||||
|
||||
if (m_settings->isSaveLogs()) {
|
||||
if (!Debug::init()) {
|
||||
qWarning() << "Initialization of debug subsystem failed";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (m_parser.isSet("a")) m_uiLogic->showOnStartup();
|
||||
else emit m_uiLogic->show();
|
||||
#else
|
||||
uiLogic->showOnStartup();
|
||||
#endif
|
||||
|
||||
// TODO - fix
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
if (isPrimary()) {
|
||||
QObject::connect(this, &SingleApplication::instanceStarted, m_uiLogic, [this](){
|
||||
qDebug() << "Secondary instance started, showing this window instead";
|
||||
emit m_uiLogic->show();
|
||||
emit m_uiLogic->raise();
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AmneziaApplication::registerTypes()
|
||||
{
|
||||
QZXing::registerQMLTypes();
|
||||
|
||||
qRegisterMetaType<VpnProtocol::VpnConnectionState>("VpnProtocol::VpnConnectionState");
|
||||
qRegisterMetaType<ServerCredentials>("ServerCredentials");
|
||||
|
||||
qRegisterMetaType<DockerContainer>("DockerContainer");
|
||||
qRegisterMetaType<TransportProto>("TransportProto");
|
||||
qRegisterMetaType<Proto>("Proto");
|
||||
qRegisterMetaType<ServiceType>("ServiceType");
|
||||
qRegisterMetaType<Page>("Page");
|
||||
qRegisterMetaType<VpnProtocol::VpnConnectionState>("ConnectionState");
|
||||
|
||||
qRegisterMetaType<PageProtocolLogicBase *>("PageProtocolLogicBase *");
|
||||
|
||||
|
||||
|
||||
declareQmlPageEnum();
|
||||
declareQmlProtocolEnum();
|
||||
declareQmlContainerEnum();
|
||||
|
||||
qmlRegisterType<PageType>("PageType", 1, 0, "PageType");
|
||||
qmlRegisterType<QRCodeReader>("QRCodeReader", 1, 0, "QRCodeReader");
|
||||
|
||||
QScopedPointer<ContainerProps> containerProps(new ContainerProps);
|
||||
qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", containerProps.get());
|
||||
|
||||
QScopedPointer<ProtocolProps> protocolProps(new ProtocolProps);
|
||||
qmlRegisterSingletonInstance("ProtocolProps", 1, 0, "ProtocolProps", protocolProps.get());
|
||||
}
|
||||
|
||||
void AmneziaApplication::loadFonts()
|
||||
{
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-BlackItalic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Bold.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-BoldItalic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Italic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Light.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-LightItalic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Regular.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Thin.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-ThinItalic.ttf");
|
||||
}
|
||||
|
||||
void AmneziaApplication::loadTranslator()
|
||||
{
|
||||
m_translator = new QTranslator;
|
||||
if (m_translator->load(QLocale(), QString("amneziavpn"), QLatin1String("_"), QLatin1String(":/translations"))) {
|
||||
installTranslator(m_translator);
|
||||
}
|
||||
}
|
||||
|
||||
void AmneziaApplication::parseCommands()
|
||||
{
|
||||
m_parser.setApplicationDescription(APPLICATION_NAME);
|
||||
m_parser.addHelpOption();
|
||||
m_parser.addVersionOption();
|
||||
|
||||
QCommandLineOption c_autostart {{"a", "autostart"}, "System autostart"};
|
||||
m_parser.addOption(c_autostart);
|
||||
|
||||
QCommandLineOption c_cleanup {{"c", "cleanup"}, "Cleanup logs"};
|
||||
m_parser.addOption(c_cleanup);
|
||||
|
||||
m_parser.process(*this);
|
||||
|
||||
if (m_parser.isSet(c_cleanup)) {
|
||||
Debug::cleanUp();
|
||||
QTimer::singleShot(100,[this]{
|
||||
quit();
|
||||
});
|
||||
exec();
|
||||
}
|
||||
}
|
52
client/amnezia_application.h
Normal file
52
client/amnezia_application.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
#ifndef AMNEZIA_APPLICATION_H
|
||||
#define AMNEZIA_APPLICATION_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include "ui/uilogic.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
#define AMNEZIA_BASE_CLASS SingleApplication
|
||||
#define QAPPLICATION_CLASS QGuiApplication
|
||||
#include "singleapplication.h"
|
||||
//#undef QAPPLICATION_CLASS
|
||||
#else
|
||||
#define AMNEZIA_BASE_CLASS QApplication
|
||||
#endif
|
||||
|
||||
class AmneziaApplication : public AMNEZIA_BASE_CLASS
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
AmneziaApplication(int &argc, char *argv[]);
|
||||
#else
|
||||
AmneziaApplication(int &argc, char *argv[], bool allowSecondary = false,
|
||||
SingleApplication::Options options = SingleApplication::User, int timeout = 1000, const QString &userData = {} );
|
||||
#endif
|
||||
virtual ~AmneziaApplication();
|
||||
|
||||
void init();
|
||||
void registerTypes();
|
||||
void loadFonts();
|
||||
void loadTranslator();
|
||||
void parseCommands();
|
||||
|
||||
private:
|
||||
QQmlApplicationEngine *m_engine;
|
||||
UiLogic *m_uiLogic;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
QTranslator* m_translator;
|
||||
QCommandLineParser m_parser;
|
||||
|
||||
};
|
||||
|
||||
#endif // AMNEZIA_APPLICATION_H
|
|
@ -24,6 +24,7 @@ DEPENDPATH += $$PWD/3rd/OpenSSL/include
|
|||
|
||||
HEADERS += \
|
||||
../ipc/ipc.h \
|
||||
amnezia_application.h \
|
||||
configurators/cloak_configurator.h \
|
||||
configurators/ikev2_configurator.h \
|
||||
configurators/shadowsocks_configurator.h \
|
||||
|
@ -84,6 +85,7 @@ HEADERS += \
|
|||
platforms/ios/QRCodeReaderBase.h
|
||||
|
||||
SOURCES += \
|
||||
amnezia_application.cpp \
|
||||
configurators/cloak_configurator.cpp \
|
||||
configurators/ikev2_configurator.cpp \
|
||||
configurators/shadowsocks_configurator.cpp \
|
||||
|
|
214
client/main.cpp
214
client/main.cpp
|
@ -1,54 +1,10 @@
|
|||
#include <QApplication>
|
||||
#include <QFontDatabase>
|
||||
#include <QCommandLineParser>
|
||||
#include <QMessageBox>
|
||||
#include <QTranslator>
|
||||
#include <QTimer>
|
||||
#include <QLoggingCategory>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include "ui/uilogic.h"
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ui/pages.h"
|
||||
|
||||
#include "ui/pages_logic/AppSettingsLogic.h"
|
||||
#include "ui/pages_logic/GeneralSettingsLogic.h"
|
||||
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
||||
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
||||
#include "ui/pages_logic/QrDecoderLogic.h"
|
||||
#include "ui/pages_logic/ServerConfiguringProgressLogic.h"
|
||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||
#include "ui/pages_logic/ServerListLogic.h"
|
||||
#include "ui/pages_logic/ServerSettingsLogic.h"
|
||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||
#include "ui/pages_logic/ShareConnectionLogic.h"
|
||||
#include "ui/pages_logic/SitesLogic.h"
|
||||
#include "ui/pages_logic/StartPageLogic.h"
|
||||
#include "ui/pages_logic/VpnLogic.h"
|
||||
#include "ui/pages_logic/WizardLogic.h"
|
||||
|
||||
#include "ui/pages_logic/protocols/CloakLogic.h"
|
||||
#include "ui/pages_logic/protocols/OpenVpnLogic.h"
|
||||
#include "ui/pages_logic/protocols/ShadowSocksLogic.h"
|
||||
|
||||
#include "ui/uilogic.h"
|
||||
|
||||
#include "QZXing.h"
|
||||
|
||||
#include "platforms/ios/QRCodeReaderBase.h"
|
||||
#include "platforms/ios/MobileUtils.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "amnezia_application.h"
|
||||
#include "defines.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
#define QAPPLICATION_CLASS QGuiApplication
|
||||
#include "singleapplication.h"
|
||||
#undef QAPPLICATION_CLASS
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "Windows.h"
|
||||
|
@ -62,26 +18,21 @@
|
|||
#include "QtAppDelegate-C-Interface.h"
|
||||
#endif
|
||||
|
||||
static void loadTranslator()
|
||||
{
|
||||
QTranslator* translator = new QTranslator;
|
||||
if (translator->load(QLocale(), QString("amneziavpn"), QLatin1String("_"), QLatin1String(":/translations"))) {
|
||||
qApp->installTranslator(translator);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QLoggingCategory::setFilterRules(QStringLiteral("qtc.ssh=false"));
|
||||
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
AllowSetForegroundWindow(ASFW_ANY);
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
SingleApplication app(argc, argv, true, SingleApplication::Mode::User | SingleApplication::Mode::SecondaryNotification);
|
||||
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
AmneziaApplication app(argc, argv);
|
||||
#else
|
||||
AmneziaApplication app(argc, argv, true, SingleApplication::Mode::User | SingleApplication::Mode::SecondaryNotification);
|
||||
|
||||
if (!app.isPrimary()) {
|
||||
QTimer::singleShot(1000, &app, [&](){
|
||||
|
@ -89,10 +40,9 @@ int main(int argc, char *argv[])
|
|||
});
|
||||
return app.exec();
|
||||
}
|
||||
#else
|
||||
QApplication app(argc, argv);
|
||||
#endif
|
||||
|
||||
// Allow to raise app window if secondary instance launched
|
||||
#ifdef Q_OS_WIN
|
||||
AllowSetForegroundWindow(0);
|
||||
#endif
|
||||
|
@ -105,155 +55,17 @@ int main(int argc, char *argv[])
|
|||
QtAppDelegateInitialize();
|
||||
#endif
|
||||
|
||||
loadTranslator();
|
||||
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-BlackItalic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Bold.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-BoldItalic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Italic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Light.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-LightItalic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Regular.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-Thin.ttf");
|
||||
QFontDatabase::addApplicationFont(":/fonts/Lato-ThinItalic.ttf");
|
||||
app.registerTypes();
|
||||
|
||||
app.setApplicationName(APPLICATION_NAME);
|
||||
app.setOrganizationName(ORGANIZATION_NAME);
|
||||
app.setApplicationDisplayName(APPLICATION_NAME);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(APPLICATION_NAME);
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
app.loadTranslator();
|
||||
app.loadFonts();
|
||||
|
||||
QCommandLineOption c_autostart {{"a", "autostart"}, "System autostart"};
|
||||
parser.addOption(c_autostart);
|
||||
|
||||
QCommandLineOption c_cleanup {{"c", "cleanup"}, "Cleanup logs"};
|
||||
parser.addOption(c_cleanup);
|
||||
|
||||
parser.process(app);
|
||||
|
||||
if (parser.isSet(c_cleanup)) {
|
||||
Debug::cleanUp();
|
||||
QTimer::singleShot(100,[&app]{
|
||||
app.quit();
|
||||
});
|
||||
app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
||||
{
|
||||
Settings settingsTemp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MobileUtils::writeToKeychain("testKey", "12345");
|
||||
// qDebug() << "MobileUtils::readFromKeychain(\"testKey\"):" << MobileUtils::readFromKeychain("testKey");
|
||||
|
||||
Settings settings;
|
||||
if (settings.isSaveLogs()) {
|
||||
if (!Debug::init()) {
|
||||
qWarning() << "Initialization of debug subsystem failed";
|
||||
}
|
||||
}
|
||||
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
QZXing::registerQMLTypes();
|
||||
|
||||
qRegisterMetaType<VpnProtocol::VpnConnectionState>("VpnProtocol::VpnConnectionState");
|
||||
qRegisterMetaType<ServerCredentials>("ServerCredentials");
|
||||
|
||||
qRegisterMetaType<DockerContainer>("DockerContainer");
|
||||
qRegisterMetaType<TransportProto>("TransportProto");
|
||||
qRegisterMetaType<Proto>("Proto");
|
||||
qRegisterMetaType<ServiceType>("ServiceType");
|
||||
qRegisterMetaType<Page>("Page");
|
||||
qRegisterMetaType<VpnProtocol::VpnConnectionState>("ConnectionState");
|
||||
|
||||
qRegisterMetaType<PageProtocolLogicBase *>("PageProtocolLogicBase *");
|
||||
|
||||
UiLogic *uiLogic = new UiLogic;
|
||||
|
||||
QQmlApplicationEngine *engine = new QQmlApplicationEngine;
|
||||
|
||||
declareQmlPageEnum();
|
||||
declareQmlProtocolEnum();
|
||||
declareQmlContainerEnum();
|
||||
|
||||
qmlRegisterType<PageType>("PageType", 1, 0, "PageType");
|
||||
qmlRegisterType<QRCodeReader>("QRCodeReader", 1, 0, "QRCodeReader");
|
||||
|
||||
QScopedPointer<ContainerProps> containerProps(new ContainerProps);
|
||||
qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", containerProps.get());
|
||||
|
||||
QScopedPointer<ProtocolProps> protocolProps(new ProtocolProps);
|
||||
qmlRegisterSingletonInstance("ProtocolProps", 1, 0, "ProtocolProps", protocolProps.get());
|
||||
|
||||
const QUrl url(QStringLiteral("qrc:/ui/qml/main.qml"));
|
||||
QObject::connect(engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
QCoreApplication::exit(-1);
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
engine->rootContext()->setContextProperty("Debug", &Debug::Instance());
|
||||
|
||||
engine->rootContext()->setContextProperty("UiLogic", uiLogic);
|
||||
|
||||
engine->rootContext()->setContextProperty("AppSettingsLogic", uiLogic->appSettingsLogic());
|
||||
engine->rootContext()->setContextProperty("GeneralSettingsLogic", uiLogic->generalSettingsLogic());
|
||||
engine->rootContext()->setContextProperty("NetworkSettingsLogic", uiLogic->networkSettingsLogic());
|
||||
engine->rootContext()->setContextProperty("NewServerProtocolsLogic", uiLogic->newServerProtocolsLogic());
|
||||
engine->rootContext()->setContextProperty("QrDecoderLogic", uiLogic->qrDecoderLogic());
|
||||
engine->rootContext()->setContextProperty("ServerConfiguringProgressLogic", uiLogic->serverConfiguringProgressLogic());
|
||||
engine->rootContext()->setContextProperty("ServerListLogic", uiLogic->serverListLogic());
|
||||
engine->rootContext()->setContextProperty("ServerSettingsLogic", uiLogic->serverSettingsLogic());
|
||||
engine->rootContext()->setContextProperty("ServerContainersLogic", uiLogic->serverprotocolsLogic());
|
||||
engine->rootContext()->setContextProperty("ShareConnectionLogic", uiLogic->shareConnectionLogic());
|
||||
engine->rootContext()->setContextProperty("SitesLogic", uiLogic->sitesLogic());
|
||||
engine->rootContext()->setContextProperty("StartPageLogic", uiLogic->startPageLogic());
|
||||
engine->rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic());
|
||||
engine->rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic());
|
||||
|
||||
#if defined(Q_OS_IOS)
|
||||
setStartPageLogic(uiLogic->startPageLogic());
|
||||
#endif
|
||||
|
||||
engine->load(url);
|
||||
|
||||
QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){
|
||||
QObject::disconnect(engine, 0,0,0);
|
||||
delete engine;
|
||||
|
||||
QObject::disconnect(uiLogic, 0,0,0);
|
||||
delete uiLogic;
|
||||
});
|
||||
|
||||
if (engine->rootObjects().size() > 0) {
|
||||
uiLogic->setQmlRoot(engine->rootObjects().at(0));
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (parser.isSet("a")) uiLogic->showOnStartup();
|
||||
else emit uiLogic->show();
|
||||
#else
|
||||
uiLogic->showOnStartup();
|
||||
#endif
|
||||
|
||||
// TODO - fix
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
if (app.isPrimary()) {
|
||||
QObject::connect(&app, &SingleApplication::instanceStarted, uiLogic, [&](){
|
||||
qDebug() << "Secondary instance started, showing this window instead";
|
||||
emit uiLogic->show();
|
||||
emit uiLogic->raise();
|
||||
});
|
||||
}
|
||||
#endif
|
||||
app.parseCommands();
|
||||
app.init();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QMutex>
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
@ -116,6 +117,7 @@ public:
|
|||
|
||||
private:
|
||||
SecureQSettings m_settings;
|
||||
QMutex m_mutex;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "containers_model.h"
|
||||
|
||||
ContainersModel::ContainersModel(QObject *parent) :
|
||||
ContainersModel::ContainersModel(std::shared_ptr<Settings> settings, QObject *parent) :
|
||||
m_settings(settings),
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
|
@ -37,13 +38,13 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
|||
return ContainerProps::containerDescriptions().value(c);
|
||||
}
|
||||
if (role == DefaultRole) {
|
||||
return c == m_settings.defaultContainer(m_selectedServerIndex);
|
||||
return c == m_settings->defaultContainer(m_selectedServerIndex);
|
||||
}
|
||||
if (role == ServiceTypeRole) {
|
||||
return ContainerProps::containerService(c);
|
||||
}
|
||||
if (role == IsInstalledRole) {
|
||||
return m_settings.containers(m_selectedServerIndex).contains(c);
|
||||
return m_settings->containers(m_selectedServerIndex).contains(c);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class ContainersModel : public QAbstractListModel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ContainersModel(QObject *parent = nullptr);
|
||||
ContainersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
public:
|
||||
enum SiteRoles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
|
@ -33,7 +33,7 @@ protected:
|
|||
|
||||
private:
|
||||
int m_selectedServerIndex;
|
||||
Settings m_settings;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
};
|
||||
|
||||
#endif // CONTAINERS_MODEL_H
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "protocols_model.h"
|
||||
|
||||
ProtocolsModel::ProtocolsModel(QObject *parent) :
|
||||
ProtocolsModel::ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent) :
|
||||
m_settings(settings),
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class ProtocolsModel : public QAbstractListModel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProtocolsModel(QObject *parent = nullptr);
|
||||
ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
public:
|
||||
enum SiteRoles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
|
@ -34,7 +34,7 @@ protected:
|
|||
private:
|
||||
int m_selectedServerIndex;
|
||||
DockerContainer m_selectedDockerContainer;
|
||||
Settings m_settings;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
};
|
||||
|
||||
#endif // PROTOCOLS_MODEL_H
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "sites_model.h"
|
||||
|
||||
SitesModel::SitesModel(Settings::RouteMode mode, QObject *parent)
|
||||
SitesModel::SitesModel(std::shared_ptr<Settings> settings, Settings::RouteMode mode, QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
m_settings(settings),
|
||||
m_mode(mode)
|
||||
{
|
||||
}
|
||||
|
@ -68,7 +69,7 @@ void SitesModel::genCache() const
|
|||
qDebug() << "SitesModel::genCache";
|
||||
m_ipsCache.clear();
|
||||
|
||||
const QVariantMap &sites = m_settings.vpnSites(m_mode);
|
||||
const QVariantMap &sites = m_settings->vpnSites(m_mode);
|
||||
auto i = sites.constBegin();
|
||||
while (i != sites.constEnd()) {
|
||||
m_ipsCache.append(qMakePair(i.key(), i.value().toString()));
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
IpRole
|
||||
};
|
||||
|
||||
explicit SitesModel(Settings::RouteMode mode, QObject *parent = nullptr);
|
||||
explicit SitesModel(std::shared_ptr<Settings> settings, Settings::RouteMode mode, QObject *parent = nullptr);
|
||||
void resetCache();
|
||||
|
||||
// Basic functionality:
|
||||
|
@ -32,7 +32,7 @@ private:
|
|||
|
||||
private:
|
||||
Settings::RouteMode m_mode;
|
||||
Settings m_settings;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
mutable QVector<QPair<QString, QString>> m_ipsCache;
|
||||
mutable bool m_cacheReady = false;
|
||||
|
|
|
@ -25,9 +25,9 @@ AppSettingsLogic::AppSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
void AppSettingsLogic::onUpdatePage()
|
||||
{
|
||||
set_checkBoxAutostartChecked(Autostart::isAutostart());
|
||||
set_checkBoxAutoConnectChecked(m_settings.isAutoConnect());
|
||||
set_checkBoxStartMinimizedChecked(m_settings.isStartMinimized());
|
||||
set_checkBoxSaveLogsChecked(m_settings.isSaveLogs());
|
||||
set_checkBoxAutoConnectChecked(m_settings->isAutoConnect());
|
||||
set_checkBoxStartMinimizedChecked(m_settings->isStartMinimized());
|
||||
set_checkBoxSaveLogsChecked(m_settings->isSaveLogs());
|
||||
|
||||
QString ver = QString("%1: %2 (%3)")
|
||||
.arg(tr("Software version"))
|
||||
|
@ -46,17 +46,17 @@ void AppSettingsLogic::onCheckBoxAutostartToggled(bool checked)
|
|||
|
||||
void AppSettingsLogic::onCheckBoxAutoconnectToggled(bool checked)
|
||||
{
|
||||
m_settings.setAutoConnect(checked);
|
||||
m_settings->setAutoConnect(checked);
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onCheckBoxStartMinimizedToggled(bool checked)
|
||||
{
|
||||
m_settings.setStartMinimized(checked);
|
||||
m_settings->setStartMinimized(checked);
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onCheckBoxSaveLogsCheckedToggled(bool checked)
|
||||
{
|
||||
m_settings.setSaveLogs(checked);
|
||||
m_settings->setSaveLogs(checked);
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonOpenLogsClicked()
|
||||
|
@ -77,7 +77,7 @@ void AppSettingsLogic::onPushButtonClearLogsClicked()
|
|||
|
||||
void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
||||
{
|
||||
uiLogic()->saveTextFile("Backup application config", "AmneziaVPN.backup", ".backup", m_settings.backupAppConfig());
|
||||
uiLogic()->saveTextFile("Backup application config", "AmneziaVPN.backup", ".backup", m_settings->backupAppConfig());
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||
|
@ -91,7 +91,7 @@ void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
|||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray data = file.readAll();
|
||||
|
||||
m_settings.restoreAppConfig(data);
|
||||
m_settings->restoreAppConfig(data);
|
||||
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
|
|
|
@ -12,24 +12,24 @@ GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void GeneralSettingsLogic::onUpdatePage()
|
||||
{
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
set_pushButtonGeneralSettingsShareConnectionEnable(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||
set_pushButtonGeneralSettingsShareConnectionEnable(m_settings->haveAuthData(m_settings->defaultServerIndex()));
|
||||
}
|
||||
|
||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
||||
{
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerSettings);
|
||||
}
|
||||
|
||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
||||
{
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
|
||||
|
||||
qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel())->setSelectedServerIndex(uiLogic()->selectedServerIndex);
|
||||
qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel())->setSelectedDockerContainer(uiLogic()->selectedDockerContainer);
|
||||
|
|
|
@ -13,39 +13,39 @@ NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void NetworkSettingsLogic::onUpdatePage()
|
||||
{
|
||||
set_checkBoxUseAmneziaDnsChecked(m_settings.useAmneziaDns());
|
||||
set_checkBoxUseAmneziaDnsChecked(m_settings->useAmneziaDns());
|
||||
|
||||
set_lineEditDns1Text(m_settings.primaryDns());
|
||||
set_lineEditDns2Text(m_settings.secondaryDns());
|
||||
set_lineEditDns1Text(m_settings->primaryDns());
|
||||
set_lineEditDns2Text(m_settings->secondaryDns());
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onLineEditDns1EditFinished(const QString &text)
|
||||
{
|
||||
if (ipAddressRegex().exactMatch(text)) {
|
||||
m_settings.setPrimaryDns(text);
|
||||
m_settings->setPrimaryDns(text);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onLineEditDns2EditFinished(const QString &text)
|
||||
{
|
||||
if (ipAddressRegex().exactMatch(text)) {
|
||||
m_settings.setSecondaryDns(text);
|
||||
m_settings->setSecondaryDns(text);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onPushButtonResetDns1Clicked()
|
||||
{
|
||||
m_settings.setPrimaryDns(m_settings.cloudFlareNs1);
|
||||
m_settings->setPrimaryDns(m_settings->cloudFlareNs1);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onPushButtonResetDns2Clicked()
|
||||
{
|
||||
m_settings.setSecondaryDns(m_settings.cloudFlareNs2);
|
||||
m_settings->setSecondaryDns(m_settings->cloudFlareNs2);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onCheckBoxUseAmneziaDnsToggled(bool checked)
|
||||
{
|
||||
m_settings.setUseAmneziaDns(checked);
|
||||
m_settings->setUseAmneziaDns(checked);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "PageLogicBase.h"
|
||||
#include "ui/uilogic.h"
|
||||
|
||||
|
||||
PageLogicBase::PageLogicBase(UiLogic *logic, QObject *parent):
|
||||
|
@ -6,6 +7,7 @@ PageLogicBase::PageLogicBase(UiLogic *logic, QObject *parent):
|
|||
m_pageEnabled{true},
|
||||
m_uiLogic(logic)
|
||||
{
|
||||
|
||||
m_settings = logic->m_settings;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
|
||||
protected:
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -36,21 +36,21 @@ void ServerContainersLogic::onPushButtonProtoSettingsClicked(DockerContainer c,
|
|||
{
|
||||
qDebug()<< "ServerContainersLogic::onPushButtonProtoSettingsClicked" << c << p;
|
||||
uiLogic()->selectedDockerContainer = c;
|
||||
uiLogic()->protocolLogic(p)->updateProtocolPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p),
|
||||
uiLogic()->protocolLogic(p)->updateProtocolPage(m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p),
|
||||
uiLogic()->selectedDockerContainer,
|
||||
m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
|
||||
emit uiLogic()->goToProtocolPage(p);
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonDefaultClicked(DockerContainer c)
|
||||
{
|
||||
if (m_settings.defaultContainer(uiLogic()->selectedServerIndex) == c) return;
|
||||
if (m_settings->defaultContainer(uiLogic()->selectedServerIndex) == c) return;
|
||||
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
if (uiLogic()->selectedServerIndex != m_settings.defaultServerIndex()) return;
|
||||
if (uiLogic()->selectedServerIndex != m_settings->defaultServerIndex()) return;
|
||||
if (!uiLogic()->m_vpnConnection) return;
|
||||
if (!uiLogic()->m_vpnConnection->isConnected()) return;
|
||||
|
||||
|
@ -67,14 +67,14 @@ void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c)
|
|||
void ServerContainersLogic::onPushButtonRemoveClicked(DockerContainer container)
|
||||
{
|
||||
//buttonSetEnabledFunc(false);
|
||||
ErrorCode e = ServerController::removeContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), container);
|
||||
m_settings.removeContainerConfig(uiLogic()->selectedServerIndex, container);
|
||||
ErrorCode e = ServerController::removeContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), container);
|
||||
m_settings->removeContainerConfig(uiLogic()->selectedServerIndex, container);
|
||||
//buttonSetEnabledFunc(true);
|
||||
|
||||
if (m_settings.defaultContainer(uiLogic()->selectedServerIndex) == container) {
|
||||
const auto &c = m_settings.containers(uiLogic()->selectedServerIndex);
|
||||
if (c.isEmpty()) m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
else m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c.keys().first());
|
||||
if (m_settings->defaultContainer(uiLogic()->selectedServerIndex) == container) {
|
||||
const auto &c = m_settings->containers(uiLogic()->selectedServerIndex);
|
||||
if (c.isEmpty()) m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
else m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, c.keys().first());
|
||||
}
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
|
@ -87,13 +87,13 @@ void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int p
|
|||
qApp->processEvents();
|
||||
|
||||
ErrorCode e = uiLogic()->serverConfiguringProgressLogic()->doInstallAction([this, c, &config](){
|
||||
return ServerController::setupContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), c, config);
|
||||
return ServerController::setupContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), c, config);
|
||||
});
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, c, config);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, c, config);
|
||||
if (ContainerProps::containerService(c) == ServiceType::Vpn) {
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
|
||||
{
|
||||
m_settings.setDefaultServer(index);
|
||||
m_settings->setDefaultServer(index);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
|
|||
|
||||
void ServerListLogic::onUpdatePage()
|
||||
{
|
||||
const QJsonArray &servers = m_settings.serversArray();
|
||||
int defaultServer = m_settings.defaultServerIndex();
|
||||
const QJsonArray &servers = m_settings->serversArray();
|
||||
int defaultServer = m_settings->defaultServerIndex();
|
||||
std::vector<ServerModelContent> serverListContent;
|
||||
for(int i = 0; i < servers.size(); i++) {
|
||||
ServerModelContent c;
|
||||
|
|
|
@ -26,10 +26,10 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
{
|
||||
set_labelWaitInfoVisible(false);
|
||||
set_labelWaitInfoText("");
|
||||
set_pushButtonClearVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonClearClientCacheVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonShareFullVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
const QJsonObject &server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
set_pushButtonClearVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonClearClientCacheVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
const QJsonObject &server = m_settings->server(uiLogic()->selectedServerIndex);
|
||||
const QString &port = server.value(config_key::port).toString();
|
||||
set_labelServerText(QString("%1@%2%3%4")
|
||||
.arg(server.value(config_key::userName).toString())
|
||||
|
@ -38,7 +38,7 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
.arg(port));
|
||||
set_lineEditDescriptionText(server.value(config_key::description).toString());
|
||||
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
|
||||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName);
|
||||
}
|
||||
|
@ -48,12 +48,12 @@ void ServerSettingsLogic::onPushButtonClearServer()
|
|||
set_pageEnabled(false);
|
||||
set_pushButtonClearText(tr("Uninstalling Amnezia software..."));
|
||||
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
}
|
||||
|
||||
ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||
ServerController::disconnectFromHost(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||
ErrorCode e = ServerController::removeAllContainers(m_settings->serverCredentials(uiLogic()->selectedServerIndex));
|
||||
ServerController::disconnectFromHost(m_settings->serverCredentials(uiLogic()->selectedServerIndex));
|
||||
if (e) {
|
||||
uiLogic()->setDialogConnectErrorText(
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
|
@ -66,8 +66,8 @@ void ServerSettingsLogic::onPushButtonClearServer()
|
|||
set_labelWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
||||
}
|
||||
|
||||
m_settings.setContainers(uiLogic()->selectedServerIndex, {});
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
m_settings->setContainers(uiLogic()->selectedServerIndex, {});
|
||||
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
|
||||
set_pageEnabled(true);
|
||||
set_pushButtonClearText(tr("Clear server from Amnezia software"));
|
||||
|
@ -75,27 +75,27 @@ void ServerSettingsLogic::onPushButtonClearServer()
|
|||
|
||||
void ServerSettingsLogic::onPushButtonForgetServer()
|
||||
{
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
}
|
||||
m_settings.removeServer(uiLogic()->selectedServerIndex);
|
||||
m_settings->removeServer(uiLogic()->selectedServerIndex);
|
||||
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
m_settings.setDefaultServer(0);
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
m_settings->setDefaultServer(0);
|
||||
}
|
||||
else if (m_settings.defaultServerIndex() > uiLogic()->selectedServerIndex) {
|
||||
m_settings.setDefaultServer(m_settings.defaultServerIndex() - 1);
|
||||
else if (m_settings->defaultServerIndex() > uiLogic()->selectedServerIndex) {
|
||||
m_settings->setDefaultServer(m_settings->defaultServerIndex() - 1);
|
||||
}
|
||||
|
||||
if (m_settings.serversCount() == 0) {
|
||||
m_settings.setDefaultServer(-1);
|
||||
if (m_settings->serversCount() == 0) {
|
||||
m_settings->setDefaultServer(-1);
|
||||
}
|
||||
|
||||
|
||||
uiLogic()->selectedServerIndex = -1;
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
if (m_settings.serversCount() == 0) {
|
||||
if (m_settings->serversCount() == 0) {
|
||||
uiLogic()->setStartPage(Page::Start);
|
||||
}
|
||||
else {
|
||||
|
@ -107,9 +107,9 @@ void ServerSettingsLogic::onPushButtonClearClientCacheClicked()
|
|||
{
|
||||
set_pushButtonClearClientCacheText(tr("Cache cleared"));
|
||||
|
||||
const auto &containers = m_settings.containers(uiLogic()->selectedServerIndex);
|
||||
const auto &containers = m_settings->containers(uiLogic()->selectedServerIndex);
|
||||
for (DockerContainer container: containers.keys()) {
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
|
||||
}
|
||||
|
||||
QTimer::singleShot(3000, this, [this]() {
|
||||
|
@ -120,9 +120,9 @@ void ServerSettingsLogic::onPushButtonClearClientCacheClicked()
|
|||
void ServerSettingsLogic::onLineEditDescriptionEditingFinished()
|
||||
{
|
||||
const QString &newText = lineEditDescriptionText();
|
||||
QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
QJsonObject server = m_settings->server(uiLogic()->selectedServerIndex);
|
||||
server.insert(config_key::description, newText);
|
||||
m_settings.editServer(uiLogic()->selectedServerIndex, server);
|
||||
m_settings->editServer(uiLogic()->selectedServerIndex, server);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,17 +73,17 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
|
||||
// Full access
|
||||
if (shareFullAccess()) {
|
||||
serverConfig = m_settings.server(serverIndex);
|
||||
serverConfig = m_settings->server(serverIndex);
|
||||
}
|
||||
// Container share
|
||||
else {
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
containerConfig.insert(config_key::container, ContainerProps::containerToString(container));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
for (Proto p: ContainerProps::protocolsForContainer(container)) {
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, p);
|
||||
QJsonObject protoConfig = m_settings->protocolConfig(serverIndex, container, p);
|
||||
|
||||
QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, container, containerConfig, p, &e);
|
||||
if (e) {
|
||||
|
@ -96,7 +96,7 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
|
||||
QByteArray ba;
|
||||
if (!e) {
|
||||
serverConfig = m_settings.server(serverIndex);
|
||||
serverConfig = m_settings->server(serverIndex);
|
||||
serverConfig.remove(config_key::userName);
|
||||
serverConfig.remove(config_key::password);
|
||||
serverConfig.remove(config_key::port);
|
||||
|
@ -129,9 +129,9 @@ void ShareConnectionLogic::onPushButtonShareOpenVpnGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, container, containerConfig, &e);
|
||||
|
@ -144,13 +144,13 @@ void ShareConnectionLogic::onPushButtonShareShadowSocksGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Proto::ShadowSocks);
|
||||
QJsonObject protoConfig = m_settings->protocolConfig(serverIndex, container, Proto::ShadowSocks);
|
||||
QString cfg = protoConfig.value(config_key::last_config).toString();
|
||||
|
||||
if (cfg.isEmpty()) {
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
cfg = ShadowSocksConfigurator::genShadowSocksConfig(credentials, container, containerConfig, &e);
|
||||
|
@ -186,13 +186,13 @@ void ShareConnectionLogic::onPushButtonShareCloakGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Proto::Cloak);
|
||||
QJsonObject protoConfig = m_settings->protocolConfig(serverIndex, container, Proto::Cloak);
|
||||
QString cfg = protoConfig.value(config_key::last_config).toString();
|
||||
|
||||
if (cfg.isEmpty()) {
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
cfg = CloakConfigurator::genCloakConfig(credentials, container, containerConfig, &e);
|
||||
|
@ -209,9 +209,9 @@ void ShareConnectionLogic::onPushButtonShareWireGuardGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = WireguardConfigurator::genWireguardConfig(credentials, container, containerConfig, &e);
|
||||
|
@ -235,9 +235,9 @@ void ShareConnectionLogic::onPushButtonShareIkev2GenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
//const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
//const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
Ikev2Configurator::ConnectionData connData = Ikev2Configurator::prepareIkev2Config(credentials, container);
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ SitesLogic::SitesLogic(UiLogic *logic, QObject *parent):
|
|||
m_tableViewSitesModel{nullptr},
|
||||
m_lineEditSitesAddCustomText{}
|
||||
{
|
||||
sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites));
|
||||
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites));
|
||||
sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(m_settings, Settings::VpnOnlyForwardSites));
|
||||
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(m_settings, Settings::VpnAllExceptSites));
|
||||
}
|
||||
|
||||
void SitesLogic::onUpdatePage()
|
||||
{
|
||||
Settings::RouteMode m = m_settings.routeMode();
|
||||
Settings::RouteMode m = m_settings->routeMode();
|
||||
if (m == Settings::VpnAllSites) return;
|
||||
|
||||
if (m == Settings::VpnOnlyForwardSites) {
|
||||
|
@ -43,7 +43,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
|||
if (uiLogic()->vpnLogic()->radioButtonVpnModeAllSitesChecked()) {
|
||||
return;
|
||||
}
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
QString newSite = lineEditSitesAddCustomText();
|
||||
|
||||
|
@ -60,7 +60,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
|||
}
|
||||
|
||||
const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) {
|
||||
m_settings.addVpnSite(mode, newSite, ip);
|
||||
m_settings->addVpnSite(mode, newSite, ip);
|
||||
|
||||
if (!ip.isEmpty()) {
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ip);
|
||||
|
@ -100,7 +100,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
|||
|
||||
void SitesLogic::onPushButtonSitesDeleteClicked(QStringList items)
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
auto siteModel = qobject_cast<SitesModel*> (tableViewSitesModel());
|
||||
if (!siteModel || items.isEmpty()) {
|
||||
|
@ -121,7 +121,7 @@ void SitesLogic::onPushButtonSitesDeleteClicked(QStringList items)
|
|||
}
|
||||
}
|
||||
|
||||
m_settings.removeVpnSites(mode, sites);
|
||||
m_settings->removeVpnSites(mode, sites);
|
||||
|
||||
if (uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
||||
uiLogic()->m_vpnConnection->deleteRoutes(ips);
|
||||
|
@ -139,7 +139,7 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
return;
|
||||
}
|
||||
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
QStringList ips;
|
||||
QMap<QString, QString> sites;
|
||||
|
@ -187,8 +187,8 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
|
||||
}
|
||||
|
||||
m_settings.addVpnIps(mode, ips);
|
||||
m_settings.addVpnSites(mode, sites);
|
||||
m_settings->addVpnIps(mode, ips);
|
||||
m_settings->addVpnSites(mode, sites);
|
||||
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
|
@ -198,9 +198,9 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
|
||||
void SitesLogic::onPushButtonSitesExportClicked()
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
QVariantMap sites = m_settings.vpnSites(mode);
|
||||
QVariantMap sites = m_settings->vpnSites(mode);
|
||||
|
||||
QString data;
|
||||
for (auto s : sites.keys()) {
|
||||
|
|
|
@ -159,8 +159,8 @@ bool StartPageLogic::importConnection(const QJsonObject &profile)
|
|||
//qDebug() << QString("Password") << credentials.password;
|
||||
|
||||
if (credentials.isValid() || profile.contains(config_key::containers)) {
|
||||
m_settings.addServer(profile);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
m_settings->addServer(profile);
|
||||
m_settings->setDefaultServer(m_settings->serversCount() - 1);
|
||||
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
|
@ -172,8 +172,8 @@ bool StartPageLogic::importConnection(const QJsonObject &profile)
|
|||
}
|
||||
|
||||
if (!profile.contains(config_key::containers)) {
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerContainers);
|
||||
|
|
|
@ -33,7 +33,7 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
|||
connect(this, &VpnLogic::connectToVpn, uiLogic()->m_vpnConnection, &VpnConnection::connectToVpn, Qt::QueuedConnection);
|
||||
connect(this, &VpnLogic::disconnectFromVpn, uiLogic()->m_vpnConnection, &VpnConnection::disconnectFromVpn, Qt::QueuedConnection);
|
||||
|
||||
if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) {
|
||||
if (m_settings->isAutoConnect() && m_settings->defaultServerIndex() >= 0) {
|
||||
QTimer::singleShot(1000, this, [this](){
|
||||
set_pushButtonConnectEnabled(false);
|
||||
onConnect();
|
||||
|
@ -47,20 +47,20 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void VpnLogic::onUpdatePage()
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
DockerContainer selectedContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
set_isCustomRoutesSupported (selectedContainer == DockerContainer::OpenVpn ||
|
||||
selectedContainer == DockerContainer::ShadowSocks||
|
||||
selectedContainer == DockerContainer::Cloak);
|
||||
|
||||
set_isContainerHaveAuthData(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||
set_isContainerHaveAuthData(m_settings->haveAuthData(m_settings->defaultServerIndex()));
|
||||
|
||||
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites || !isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites && isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites && isCustomRoutesSupported());
|
||||
|
||||
const QJsonObject &server = uiLogic()->m_settings.defaultServer();
|
||||
const QJsonObject &server = uiLogic()->m_settings->defaultServer();
|
||||
QString serverString = QString("%2 (%3)")
|
||||
.arg(server.value(config_key::description).toString())
|
||||
.arg(server.value(config_key::hostName).toString());
|
||||
|
@ -69,7 +69,7 @@ void VpnLogic::onUpdatePage()
|
|||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentService(selectedContainerName);
|
||||
|
||||
auto dns = VpnConfigurator::getDnsForConfig(m_settings.defaultServerIndex());
|
||||
auto dns = VpnConfigurator::getDnsForConfig(m_settings->defaultServerIndex());
|
||||
set_amneziaDnsEnabled(dns.first == protocols::dns::amneziaDnsIp);
|
||||
if (dns.first == protocols::dns::amneziaDnsIp) {
|
||||
set_labelCurrentDns("On your server");
|
||||
|
@ -93,19 +93,19 @@ void VpnLogic::onUpdatePage()
|
|||
|
||||
void VpnLogic::onRadioButtonVpnModeAllSitesClicked()
|
||||
{
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
m_settings->setRouteMode(Settings::VpnAllSites);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeForwardSitesClicked()
|
||||
{
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
m_settings->setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeExceptSitesClicked()
|
||||
{
|
||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
||||
m_settings->setRouteMode(Settings::VpnAllExceptSites);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
|
@ -203,11 +203,11 @@ void VpnLogic::onPushButtonConnectClicked()
|
|||
|
||||
void VpnLogic::onConnect()
|
||||
{
|
||||
int serverIndex = m_settings.defaultServerIndex();
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
DockerContainer container = m_settings.defaultContainer(serverIndex);
|
||||
int serverIndex = m_settings->defaultServerIndex();
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
DockerContainer container = m_settings->defaultContainer(serverIndex);
|
||||
|
||||
if (m_settings.containers(serverIndex).isEmpty()) {
|
||||
if (m_settings->containers(serverIndex).isEmpty()) {
|
||||
set_labelErrorText(tr("VPN Protocols is not installed.\n Please install VPN container at first"));
|
||||
set_pushButtonConnectChecked(false);
|
||||
return;
|
||||
|
@ -220,7 +220,7 @@ void VpnLogic::onConnect()
|
|||
}
|
||||
|
||||
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
onConnectWorker(serverIndex, credentials, container, containerConfig);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,9 +55,9 @@ void WizardLogic::onPushButtonVpnModeFinishClicked()
|
|||
auto containers = getInstallConfigsFromWizardPage();
|
||||
uiLogic()->installServer(containers);
|
||||
if (checkBoxVpnModeChecked()) {
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
m_settings->setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
} else {
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
m_settings->setRouteMode(Settings::VpnAllSites);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ QJsonObject CloakLogic::getProtocolConfigFromPage(QJsonObject oldConfig)
|
|||
|
||||
void CloakLogic::onPushButtonSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::Cloak);
|
||||
QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::Cloak);
|
||||
protocolConfig = getProtocolConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Proto::Cloak), protocolConfig);
|
||||
|
||||
|
@ -89,14 +89,14 @@ void CloakLogic::onPushButtonSaveClicked()
|
|||
};
|
||||
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
return ServerController::updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_func, progressBar_reset,
|
||||
pushButton_save_func, label_info_func);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
|
|
|
@ -32,7 +32,6 @@ public:
|
|||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
};
|
||||
|
|
|
@ -81,10 +81,10 @@ void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerCo
|
|||
|
||||
void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::OpenVpn);
|
||||
QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::OpenVpn);
|
||||
protocolConfig = getProtocolConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Proto::OpenVpn), protocolConfig);
|
||||
|
||||
|
@ -118,14 +118,14 @@ void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
|
|||
};
|
||||
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
return ServerController::updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_openvpn, progressBar_proto_openvpn_reset,
|
||||
pushButton_proto_openvpn_save, label_proto_openvpn_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
};
|
||||
|
|
|
@ -82,7 +82,7 @@ void OtherProtocolsLogic::onPushButtonSftpMountDriveClicked()
|
|||
{
|
||||
QString mountPath;
|
||||
QString cmd;
|
||||
QString host = m_settings.serverCredentials(uiLogic()->selectedServerIndex).hostName;
|
||||
QString host = m_settings->serverCredentials(uiLogic()->selectedServerIndex).hostName;
|
||||
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
|
|
@ -31,7 +31,6 @@ public:
|
|||
//QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
|
|
|
@ -46,10 +46,10 @@ QJsonObject ShadowSocksLogic::getProtocolConfigFromPage(QJsonObject oldConfig)
|
|||
|
||||
void ShadowSocksLogic::onPushButtonSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::ShadowSocks);
|
||||
QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::ShadowSocks);
|
||||
//protocolConfig = getShadowSocksConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Proto::ShadowSocks), protocolConfig);
|
||||
UiLogic::PageFunc page_proto_shadowsocks;
|
||||
|
@ -82,14 +82,14 @@ void ShadowSocksLogic::onPushButtonSaveClicked()
|
|||
};
|
||||
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
return ServerController::updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_shadowsocks, progressBar_reset,
|
||||
pushButton_proto_shadowsocks_save, label_proto_shadowsocks_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ public:
|
|||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
};
|
||||
|
|
|
@ -74,13 +74,14 @@
|
|||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
UiLogic::UiLogic(QObject *parent) :
|
||||
UiLogic::UiLogic(std::shared_ptr<Settings> settings, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_settings(settings),
|
||||
m_dialogConnectErrorText{}
|
||||
{
|
||||
m_containersModel = new ContainersModel(this);
|
||||
m_protocolsModel = new ProtocolsModel(this);
|
||||
m_vpnConnection = new VpnConnection();
|
||||
m_containersModel = new ContainersModel(settings, this);
|
||||
m_protocolsModel = new ProtocolsModel(settings, this);
|
||||
m_vpnConnection = new VpnConnection(settings);
|
||||
m_vpnConnection->moveToThread(&m_vpnConnectionThread);
|
||||
m_vpnConnectionThread.start();
|
||||
|
||||
|
@ -158,15 +159,15 @@ void UiLogic::initalizeUiLogic()
|
|||
connect(m_notificationHandler, &NotificationHandler::connectRequested, vpnLogic(), &VpnLogic::onConnect);
|
||||
connect(m_notificationHandler, &NotificationHandler::disconnectRequested, vpnLogic(), &VpnLogic::onDisconnect);
|
||||
|
||||
if (m_settings.serversCount() > 0) {
|
||||
if (m_settings.defaultServerIndex() < 0) m_settings.setDefaultServer(0);
|
||||
if (m_settings->serversCount() > 0) {
|
||||
if (m_settings->defaultServerIndex() < 0) m_settings->setDefaultServer(0);
|
||||
emit goToPage(Page::Vpn, true, false);
|
||||
}
|
||||
else {
|
||||
emit goToPage(Page::Start, true, false);
|
||||
}
|
||||
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
selectedServerIndex = m_settings->defaultServerIndex();
|
||||
|
||||
qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION);
|
||||
qInfo().noquote() << QString("%1 (%2)").arg(QSysInfo::prettyProductName()).arg(QSysInfo::currentCpuArchitecture());
|
||||
|
@ -187,7 +188,7 @@ void UiLogic::setDialogConnectErrorText(const QString &dialogConnectErrorText)
|
|||
|
||||
void UiLogic::showOnStartup()
|
||||
{
|
||||
if (! m_settings.isStartMinimized()) {
|
||||
if (! m_settings->isStartMinimized()) {
|
||||
emit show();
|
||||
}
|
||||
else {
|
||||
|
@ -235,30 +236,30 @@ void UiLogic::keyPressEvent(Qt::Key key)
|
|||
qApp->quit();
|
||||
break;
|
||||
case Qt::Key_H:
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||
selectedServerIndex = m_settings->defaultServerIndex();
|
||||
selectedDockerContainer = m_settings->defaultContainer(selectedServerIndex);
|
||||
|
||||
//updateSharingPage(selectedServerIndex, m_settings.serverCredentials(selectedServerIndex), selectedDockerContainer);
|
||||
//updateSharingPage(selectedServerIndex, m_settings->serverCredentials(selectedServerIndex), selectedDockerContainer);
|
||||
emit goToPage(Page::ShareConnection);
|
||||
break;
|
||||
#endif
|
||||
case Qt::Key_C:
|
||||
qDebug().noquote() << "Def server" << m_settings.defaultServerIndex() << m_settings.defaultContainerName(m_settings.defaultServerIndex());
|
||||
//qDebug().noquote() << QJsonDocument(m_settings.containerConfig(m_settings.defaultServerIndex(), m_settings.defaultContainer(m_settings.defaultServerIndex()))).toJson();
|
||||
qDebug().noquote() << QJsonDocument(m_settings.defaultServer()).toJson();
|
||||
qDebug().noquote() << "Def server" << m_settings->defaultServerIndex() << m_settings->defaultContainerName(m_settings->defaultServerIndex());
|
||||
//qDebug().noquote() << QJsonDocument(m_settings->containerConfig(m_settings->defaultServerIndex(), m_settings->defaultContainer(m_settings->defaultServerIndex()))).toJson();
|
||||
qDebug().noquote() << QJsonDocument(m_settings->defaultServer()).toJson();
|
||||
break;
|
||||
case Qt::Key_A:
|
||||
emit goToPage(Page::Start);
|
||||
break;
|
||||
case Qt::Key_S:
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
selectedServerIndex = m_settings->defaultServerIndex();
|
||||
emit goToPage(Page::ServerSettings);
|
||||
break;
|
||||
case Qt::Key_P:
|
||||
onGotoCurrentProtocolsPage();
|
||||
break;
|
||||
case Qt::Key_T:
|
||||
SshConfigurator::openSshTerminal(m_settings.serverCredentials(m_settings.defaultServerIndex()));
|
||||
SshConfigurator::openSshTerminal(m_settings->serverCredentials(m_settings->defaultServerIndex()));
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
case Qt::Key_Back:
|
||||
|
@ -280,7 +281,7 @@ void UiLogic::keyPressEvent(Qt::Key key)
|
|||
|
||||
void UiLogic::onCloseWindow()
|
||||
{
|
||||
if (m_settings.serversCount() == 0) qApp->quit();
|
||||
if (m_settings->serversCount() == 0) qApp->quit();
|
||||
else {
|
||||
hide();
|
||||
}
|
||||
|
@ -299,8 +300,8 @@ QString UiLogic::containerDesc(int container)
|
|||
|
||||
void UiLogic::onGotoCurrentProtocolsPage()
|
||||
{
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||
selectedServerIndex = m_settings->defaultServerIndex();
|
||||
selectedDockerContainer = m_settings->defaultContainer(selectedServerIndex);
|
||||
emit goToPage(Page::ServerContainers);
|
||||
}
|
||||
|
||||
|
@ -385,7 +386,7 @@ void UiLogic::installServer(QMap<DockerContainer, QJsonObject> &containers)
|
|||
server.insert(config_key::userName, installCredentials.userName);
|
||||
server.insert(config_key::password, installCredentials.password);
|
||||
server.insert(config_key::port, installCredentials.port);
|
||||
server.insert(config_key::description, m_settings.nextAvailableServerName());
|
||||
server.insert(config_key::description, m_settings->nextAvailableServerName());
|
||||
|
||||
QJsonArray containerConfigs;
|
||||
for (const QJsonObject &cfg : containers) {
|
||||
|
@ -394,8 +395,8 @@ void UiLogic::installServer(QMap<DockerContainer, QJsonObject> &containers)
|
|||
server.insert(config_key::containers, containerConfigs);
|
||||
server.insert(config_key::defaultContainer, ContainerProps::containerToString(containers.firstKey()));
|
||||
|
||||
m_settings.addServer(server);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
m_settings->addServer(server);
|
||||
m_settings->setDefaultServer(m_settings->serversCount() - 1);
|
||||
onUpdateAllPages();
|
||||
|
||||
emit setStartPage(Page::Vpn);
|
||||
|
|
|
@ -58,10 +58,12 @@ class UiLogic : public QObject
|
|||
Q_PROPERTY(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged)
|
||||
|
||||
public:
|
||||
explicit UiLogic(QObject *parent = nullptr);
|
||||
explicit UiLogic(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
~UiLogic();
|
||||
void showOnStartup();
|
||||
|
||||
friend class PageLogicBase;
|
||||
|
||||
friend class AppSettingsLogic;
|
||||
friend class GeneralSettingsLogic;
|
||||
friend class NetworkSettingsLogic;
|
||||
|
@ -212,7 +214,7 @@ private:
|
|||
|
||||
VpnConnection* m_vpnConnection;
|
||||
QThread m_vpnConnectionThread;
|
||||
Settings m_settings;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
NotificationHandler* m_notificationHandler;
|
||||
|
||||
|
|
|
@ -29,9 +29,8 @@
|
|||
#include "utils.h"
|
||||
#include "vpnconnection.h"
|
||||
|
||||
VpnConnection::VpnConnection(QObject* parent) : QObject(parent),
|
||||
m_settings(this)
|
||||
|
||||
VpnConnection::VpnConnection(std::shared_ptr<Settings> settings, QObject* parent) : QObject(parent),
|
||||
m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -56,7 +55,7 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
|
|||
IpcClient::Interface()->resetIpStack();
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
||||
if (m_settings.routeMode() != Settings::VpnAllSites) {
|
||||
if (m_settings->routeMode() != Settings::VpnAllSites) {
|
||||
IpcClient::Interface()->routeDeleteList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0");
|
||||
//qDebug() << "VpnConnection::onConnectionStateChanged :: adding custom routes, count:" << forwardIps.size();
|
||||
}
|
||||
|
@ -67,17 +66,17 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
|
|||
QStringList() << dns1 << dns2);
|
||||
|
||||
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
QTimer::singleShot(1000, m_vpnProtocol.data(), [this](){
|
||||
addSitesRoutes(m_vpnProtocol->vpnGateway(), m_settings.routeMode());
|
||||
addSitesRoutes(m_vpnProtocol->vpnGateway(), m_settings->routeMode());
|
||||
});
|
||||
}
|
||||
else if (m_settings.routeMode() == Settings::VpnAllExceptSites) {
|
||||
else if (m_settings->routeMode() == Settings::VpnAllExceptSites) {
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0/1");
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << "128.0.0.0/1");
|
||||
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->routeGateway(), QStringList() << remoteAddress());
|
||||
addSitesRoutes(m_vpnProtocol->routeGateway(), m_settings.routeMode());
|
||||
addSitesRoutes(m_vpnProtocol->routeGateway(), m_settings->routeMode());
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +84,7 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
|
|||
else if (state == VpnProtocol::Error) {
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->clearSavedRoutes();
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode)
|
|||
#ifdef AMNEZIA_DESKTOP
|
||||
QStringList ips;
|
||||
QStringList sites;
|
||||
const QVariantMap &m = m_settings.vpnSites(mode);
|
||||
const QVariantMap &m = m_settings->vpnSites(mode);
|
||||
for (auto i = m.constBegin(); i != m.constEnd(); ++i) {
|
||||
if (Utils::checkIpSubnetFormat(i.key())) {
|
||||
ips.append(i.key());
|
||||
|
@ -132,7 +131,7 @@ void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode)
|
|||
//qDebug() << "VpnConnection::addSitesRoutes updating site" << site << ip;
|
||||
if (!ips.contains(ip)) {
|
||||
IpcClient::Interface()->routeAddList(gw, QStringList() << ip);
|
||||
m_settings.addVpnSite(mode, site, ip);
|
||||
m_settings->addVpnSite(mode, site, ip);
|
||||
}
|
||||
flushDns();
|
||||
break;
|
||||
|
@ -153,10 +152,10 @@ void VpnConnection::addRoutes(const QStringList &ips)
|
|||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (connectionState() == VpnProtocol::Connected && IpcClient::Interface()) {
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(), ips);
|
||||
}
|
||||
else if (m_settings.routeMode() == Settings::VpnAllExceptSites) {
|
||||
else if (m_settings->routeMode() == Settings::VpnAllExceptSites) {
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->routeGateway(), ips);
|
||||
}
|
||||
}
|
||||
|
@ -167,10 +166,10 @@ void VpnConnection::deleteRoutes(const QStringList &ips)
|
|||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (connectionState() == VpnProtocol::Connected && IpcClient::Interface()) {
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->routeDeleteList(vpnProtocol()->vpnGateway(), ips);
|
||||
}
|
||||
else if (m_settings.routeMode() == Settings::VpnAllExceptSites) {
|
||||
else if (m_settings->routeMode() == Settings::VpnAllExceptSites) {
|
||||
IpcClient::Interface()->routeDeleteList(m_vpnProtocol->routeGateway(), ips);
|
||||
}
|
||||
}
|
||||
|
@ -237,9 +236,9 @@ QString VpnConnection::createVpnConfigurationForProto(int serverIndex,
|
|||
|
||||
if (serverIndex >= 0) {
|
||||
qDebug() << "VpnConnection::createVpnConfiguration: saving config for server #" << serverIndex << container << proto;
|
||||
QJsonObject protoObject = m_settings.protocolConfig(serverIndex, container, proto);
|
||||
QJsonObject protoObject = m_settings->protocolConfig(serverIndex, container, proto);
|
||||
protoObject.insert(config_key::last_config, configDataBeforeLocalProcessing);
|
||||
m_settings.setProtocolConfig(serverIndex, container, proto, protoObject);
|
||||
m_settings->setProtocolConfig(serverIndex, container, proto, protoObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,7 +283,7 @@ void VpnConnection::connectToVpn(int serverIndex,
|
|||
const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig)
|
||||
{
|
||||
qDebug() << QString("СonnectToVpn, Server index is %1, container is %2, route mode is")
|
||||
.arg(serverIndex).arg(ContainerProps::containerToString(container)) << m_settings.routeMode();
|
||||
.arg(serverIndex).arg(ContainerProps::containerToString(container)) << m_settings->routeMode();
|
||||
|
||||
#if !defined (Q_OS_ANDROID) && !defined (Q_OS_IOS)
|
||||
if (!m_IpcClient) {
|
||||
|
|
|
@ -21,7 +21,7 @@ class VpnConnection : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VpnConnection(QObject* parent = nullptr);
|
||||
explicit VpnConnection(std::shared_ptr<Settings> settings, QObject* parent = nullptr);
|
||||
~VpnConnection() override;
|
||||
|
||||
static QString bytesPerSecToText(quint64 bytes);
|
||||
|
@ -73,7 +73,7 @@ protected:
|
|||
QSharedPointer<VpnProtocol> m_vpnProtocol;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
QJsonObject m_vpnConfiguration;
|
||||
QJsonObject m_routeMode;
|
||||
QString m_remoteAddress;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue