From 4baa003c0dc4995ba7dfacb898ff11b1dfe34280 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 31 Aug 2023 16:00:41 +0500 Subject: [PATCH] removed old ui files --- client/CMakeLists.txt | 2 - client/amnezia_application.cpp | 2 +- client/amnezia_application.h | 2 +- client/configurators/ikev2_configurator.cpp | 48 +- client/configurators/openvpn_configurator.cpp | 128 ++-- client/configurators/ssh_configurator.cpp | 59 +- .../configurators/wireguard_configurator.cpp | 98 +-- client/fileUtilites.cpp | 4 +- client/platforms/android/androidutils.cpp | 81 +-- .../platforms/android/androidvpnactivity.cpp | 112 ++-- client/resources.qrc | 73 --- .../ui/controllers/connectionController.cpp | 6 +- client/ui/controllers/pageController.cpp | 7 +- client/ui/controllers/settingsController.cpp | 4 - client/ui/controllers/sitesController.cpp | 5 +- .../AdvancedServerSettingsLogic.cpp | 88 --- .../pages_logic/AdvancedServerSettingsLogic.h | 31 - client/ui/pages_logic/AppSettingsLogic.cpp | 119 ---- client/ui/pages_logic/AppSettingsLogic.h | 37 -- client/ui/pages_logic/ClientInfoLogic.cpp | 213 ------ client/ui/pages_logic/ClientInfoLogic.h | 42 -- .../ui/pages_logic/ClientManagementLogic.cpp | 143 ---- client/ui/pages_logic/ClientManagementLogic.h | 33 - .../ui/pages_logic/GeneralSettingsLogic.cpp | 40 -- client/ui/pages_logic/GeneralSettingsLogic.h | 25 - .../ui/pages_logic/NetworkSettingsLogic.cpp | 52 -- client/ui/pages_logic/NetworkSettingsLogic.h | 35 - .../pages_logic/NewServerProtocolsLogic.cpp | 34 - .../ui/pages_logic/NewServerProtocolsLogic.h | 25 - client/ui/pages_logic/PageLogicBase.cpp | 16 - client/ui/pages_logic/PageLogicBase.h | 35 - client/ui/pages_logic/QrDecoderLogic.cpp | 125 ---- client/ui/pages_logic/QrDecoderLogic.h | 41 -- .../ServerConfiguringProgressLogic.cpp | 187 ------ .../ServerConfiguringProgressLogic.h | 73 --- .../ui/pages_logic/ServerContainersLogic.cpp | 128 ---- client/ui/pages_logic/ServerContainersLogic.h | 29 - client/ui/pages_logic/ServerListLogic.cpp | 47 -- client/ui/pages_logic/ServerListLogic.h | 30 - client/ui/pages_logic/ServerSettingsLogic.cpp | 144 ----- client/ui/pages_logic/ServerSettingsLogic.h | 62 -- .../ui/pages_logic/ShareConnectionLogic.cpp | 293 --------- client/ui/pages_logic/ShareConnectionLogic.h | 54 -- client/ui/pages_logic/SitesLogic.cpp | 211 ------ client/ui/pages_logic/SitesLogic.h | 33 - client/ui/pages_logic/StartPageLogic.cpp | 374 ----------- client/ui/pages_logic/StartPageLogic.h | 56 -- client/ui/pages_logic/ViewConfigLogic.cpp | 93 --- client/ui/pages_logic/ViewConfigLogic.h | 47 -- client/ui/pages_logic/VpnLogic.cpp | 245 ------- client/ui/pages_logic/VpnLogic.h | 70 -- client/ui/pages_logic/WizardLogic.cpp | 70 -- client/ui/pages_logic/WizardLogic.h | 31 - .../ui/pages_logic/protocols/CloakLogic.cpp | 137 ---- client/ui/pages_logic/protocols/CloakLogic.h | 46 -- .../ui/pages_logic/protocols/OpenVpnLogic.cpp | 203 ------ .../ui/pages_logic/protocols/OpenVpnLogic.h | 63 -- .../protocols/OtherProtocolsLogic.cpp | 169 ----- .../protocols/OtherProtocolsLogic.h | 45 -- .../protocols/PageProtocolLogicBase.cpp | 8 - .../protocols/PageProtocolLogicBase.h | 24 - .../protocols/ShadowSocksLogic.cpp | 127 ---- .../pages_logic/protocols/ShadowSocksLogic.h | 44 -- .../pages_logic/protocols/WireGuardLogic.cpp | 30 - .../ui/pages_logic/protocols/WireGuardLogic.h | 26 - client/ui/qml/Controls/BackButton.qml | 33 - client/ui/qml/Controls/BasicButtonType.qml | 17 - client/ui/qml/Controls/BlueButtonType.qml | 28 - client/ui/qml/Controls/Caption.qml | 17 - client/ui/qml/Controls/CheckBoxType.qml | 27 - client/ui/qml/Controls/ComboBoxType.qml | 11 - client/ui/qml/Controls/ContextMenu.qml | 33 - client/ui/qml/Controls/FadeBehavior.qml | 35 - client/ui/qml/Controls/FlickableType.qml | 26 - client/ui/qml/Controls/ImageButtonType.qml | 17 - client/ui/qml/Controls/LabelType.qml | 17 - client/ui/qml/Controls/Logo.qml | 8 - client/ui/qml/Controls/PopupWarning.qml | 34 - client/ui/qml/Controls/PopupWithQuestion.qml | 62 -- client/ui/qml/Controls/PopupWithTextField.qml | 62 -- client/ui/qml/Controls/RadioButtonType.qml | 36 -- client/ui/qml/Controls/RichLabelType.qml | 17 - client/ui/qml/Controls/SettingButtonType.qml | 33 - .../ShareConnectionButtonCopyType.qml | 26 - .../Controls/ShareConnectionButtonType.qml | 27 - .../qml/Controls/ShareConnectionContent.qml | 65 -- client/ui/qml/Controls/SvgButtonType.qml | 16 - client/ui/qml/Controls/SvgImageType.qml | 23 - client/ui/qml/Controls/TextAreaType.qml | 63 -- client/ui/qml/Controls/TextFieldType.qml | 52 -- client/ui/qml/Controls/UrlButtonType.qml | 25 - client/ui/qml/Controls/VisibleBehavior.qml | 6 - .../Pages/ClientInfo/PageClientInfoBase.qml | 15 - .../ClientInfo/PageClientInfoOpenVPN.qml | 115 ---- .../ClientInfo/PageClientInfoWireGuard.qml | 100 --- .../InstallSettings/InstallSettingsBase.qml | 75 --- .../Pages/InstallSettings/SelectContainer.qml | 200 ------ client/ui/qml/Pages/PageAbout.qml | 90 --- .../qml/Pages/PageAdvancedServerSettings.qml | 118 ---- client/ui/qml/Pages/PageAppSetting.qml | 152 ----- client/ui/qml/Pages/PageBase.qml | 20 - client/ui/qml/Pages/PageClientManagement.qml | 119 ---- client/ui/qml/Pages/PageGeneralSettings.qml | 166 ----- client/ui/qml/Pages/PageNetworkSetting.qml | 113 ---- client/ui/qml/Pages/PageNewServer.qml | 61 -- .../ui/qml/Pages/PageNewServerProtocols.qml | 154 ----- client/ui/qml/Pages/PageQrDecoderIos.qml | 94 --- .../Pages/PageServerConfiguringProgress.qml | 121 ---- client/ui/qml/Pages/PageServerContainers.qml | 434 ------------- client/ui/qml/Pages/PageServerList.qml | 185 ------ client/ui/qml/Pages/PageServerSettings.qml | 140 ---- client/ui/qml/Pages/PageSetupWizard.qml | 108 ---- .../ui/qml/Pages/PageSetupWizardHighLevel.qml | 96 --- .../ui/qml/Pages/PageSetupWizardLowLevel.qml | 65 -- .../qml/Pages/PageSetupWizardMediumLevel.qml | 60 -- .../ui/qml/Pages/PageSetupWizardVPNMode.qml | 65 -- client/ui/qml/Pages/PageShareConnection.qml | 87 --- client/ui/qml/Pages/PageSites.qml | 315 --------- client/ui/qml/Pages/PageStart.qml | 356 ---------- client/ui/qml/Pages/PageVPN.qml | 387 ----------- client/ui/qml/Pages/PageViewConfig.qml | 138 ---- .../ui/qml/Pages/Protocols/PageProtoCloak.qml | 194 ------ .../qml/Pages/Protocols/PageProtoOpenVPN.qml | 454 ------------- .../ui/qml/Pages/Protocols/PageProtoSftp.qml | 140 ---- .../Pages/Protocols/PageProtoShadowSocks.qml | 175 ----- .../Pages/Protocols/PageProtoTorWebSite.qml | 69 -- .../Pages/Protocols/PageProtoWireGuard.qml | 60 -- .../qml/Pages/Protocols/PageProtocolBase.qml | 13 - .../qml/Pages/Share/PageShareProtoAmnezia.qml | 145 ----- .../qml/Pages/Share/PageShareProtoCloak.qml | 99 --- .../qml/Pages/Share/PageShareProtoIkev2.qml | 131 ---- .../qml/Pages/Share/PageShareProtoOpenVPN.qml | 96 --- .../ui/qml/Pages/Share/PageShareProtoSftp.qml | 21 - .../Pages/Share/PageShareProtoShadowSocks.qml | 115 ---- .../Pages/Share/PageShareProtoTorWebSite.qml | 20 - .../Pages/Share/PageShareProtoWireGuard.qml | 103 --- .../qml/Pages/Share/PageShareProtocolBase.qml | 19 - client/ui/qml/main.qml | 387 ----------- client/ui/uilogic.cpp | 609 ------------------ client/ui/uilogic.h | 201 ------ 140 files changed, 285 insertions(+), 12695 deletions(-) delete mode 100644 client/ui/pages_logic/AdvancedServerSettingsLogic.cpp delete mode 100644 client/ui/pages_logic/AdvancedServerSettingsLogic.h delete mode 100644 client/ui/pages_logic/AppSettingsLogic.cpp delete mode 100644 client/ui/pages_logic/AppSettingsLogic.h delete mode 100644 client/ui/pages_logic/ClientInfoLogic.cpp delete mode 100644 client/ui/pages_logic/ClientInfoLogic.h delete mode 100644 client/ui/pages_logic/ClientManagementLogic.cpp delete mode 100644 client/ui/pages_logic/ClientManagementLogic.h delete mode 100644 client/ui/pages_logic/GeneralSettingsLogic.cpp delete mode 100644 client/ui/pages_logic/GeneralSettingsLogic.h delete mode 100644 client/ui/pages_logic/NetworkSettingsLogic.cpp delete mode 100644 client/ui/pages_logic/NetworkSettingsLogic.h delete mode 100644 client/ui/pages_logic/NewServerProtocolsLogic.cpp delete mode 100644 client/ui/pages_logic/NewServerProtocolsLogic.h delete mode 100644 client/ui/pages_logic/PageLogicBase.cpp delete mode 100644 client/ui/pages_logic/PageLogicBase.h delete mode 100644 client/ui/pages_logic/QrDecoderLogic.cpp delete mode 100644 client/ui/pages_logic/QrDecoderLogic.h delete mode 100644 client/ui/pages_logic/ServerConfiguringProgressLogic.cpp delete mode 100644 client/ui/pages_logic/ServerConfiguringProgressLogic.h delete mode 100644 client/ui/pages_logic/ServerContainersLogic.cpp delete mode 100644 client/ui/pages_logic/ServerContainersLogic.h delete mode 100644 client/ui/pages_logic/ServerListLogic.cpp delete mode 100644 client/ui/pages_logic/ServerListLogic.h delete mode 100644 client/ui/pages_logic/ServerSettingsLogic.cpp delete mode 100644 client/ui/pages_logic/ServerSettingsLogic.h delete mode 100644 client/ui/pages_logic/ShareConnectionLogic.cpp delete mode 100644 client/ui/pages_logic/ShareConnectionLogic.h delete mode 100644 client/ui/pages_logic/SitesLogic.cpp delete mode 100644 client/ui/pages_logic/SitesLogic.h delete mode 100644 client/ui/pages_logic/StartPageLogic.cpp delete mode 100644 client/ui/pages_logic/StartPageLogic.h delete mode 100644 client/ui/pages_logic/ViewConfigLogic.cpp delete mode 100644 client/ui/pages_logic/ViewConfigLogic.h delete mode 100644 client/ui/pages_logic/VpnLogic.cpp delete mode 100644 client/ui/pages_logic/VpnLogic.h delete mode 100644 client/ui/pages_logic/WizardLogic.cpp delete mode 100644 client/ui/pages_logic/WizardLogic.h delete mode 100644 client/ui/pages_logic/protocols/CloakLogic.cpp delete mode 100644 client/ui/pages_logic/protocols/CloakLogic.h delete mode 100644 client/ui/pages_logic/protocols/OpenVpnLogic.cpp delete mode 100644 client/ui/pages_logic/protocols/OpenVpnLogic.h delete mode 100644 client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp delete mode 100644 client/ui/pages_logic/protocols/OtherProtocolsLogic.h delete mode 100644 client/ui/pages_logic/protocols/PageProtocolLogicBase.cpp delete mode 100644 client/ui/pages_logic/protocols/PageProtocolLogicBase.h delete mode 100644 client/ui/pages_logic/protocols/ShadowSocksLogic.cpp delete mode 100644 client/ui/pages_logic/protocols/ShadowSocksLogic.h delete mode 100644 client/ui/pages_logic/protocols/WireGuardLogic.cpp delete mode 100644 client/ui/pages_logic/protocols/WireGuardLogic.h delete mode 100644 client/ui/qml/Controls/BackButton.qml delete mode 100644 client/ui/qml/Controls/BasicButtonType.qml delete mode 100644 client/ui/qml/Controls/BlueButtonType.qml delete mode 100644 client/ui/qml/Controls/Caption.qml delete mode 100644 client/ui/qml/Controls/CheckBoxType.qml delete mode 100644 client/ui/qml/Controls/ComboBoxType.qml delete mode 100644 client/ui/qml/Controls/ContextMenu.qml delete mode 100644 client/ui/qml/Controls/FadeBehavior.qml delete mode 100644 client/ui/qml/Controls/FlickableType.qml delete mode 100644 client/ui/qml/Controls/ImageButtonType.qml delete mode 100644 client/ui/qml/Controls/LabelType.qml delete mode 100644 client/ui/qml/Controls/Logo.qml delete mode 100644 client/ui/qml/Controls/PopupWarning.qml delete mode 100644 client/ui/qml/Controls/PopupWithQuestion.qml delete mode 100644 client/ui/qml/Controls/PopupWithTextField.qml delete mode 100644 client/ui/qml/Controls/RadioButtonType.qml delete mode 100644 client/ui/qml/Controls/RichLabelType.qml delete mode 100644 client/ui/qml/Controls/SettingButtonType.qml delete mode 100644 client/ui/qml/Controls/ShareConnectionButtonCopyType.qml delete mode 100644 client/ui/qml/Controls/ShareConnectionButtonType.qml delete mode 100644 client/ui/qml/Controls/ShareConnectionContent.qml delete mode 100644 client/ui/qml/Controls/SvgButtonType.qml delete mode 100644 client/ui/qml/Controls/SvgImageType.qml delete mode 100644 client/ui/qml/Controls/TextAreaType.qml delete mode 100644 client/ui/qml/Controls/TextFieldType.qml delete mode 100644 client/ui/qml/Controls/UrlButtonType.qml delete mode 100644 client/ui/qml/Controls/VisibleBehavior.qml delete mode 100644 client/ui/qml/Pages/ClientInfo/PageClientInfoBase.qml delete mode 100644 client/ui/qml/Pages/ClientInfo/PageClientInfoOpenVPN.qml delete mode 100644 client/ui/qml/Pages/ClientInfo/PageClientInfoWireGuard.qml delete mode 100644 client/ui/qml/Pages/InstallSettings/InstallSettingsBase.qml delete mode 100644 client/ui/qml/Pages/InstallSettings/SelectContainer.qml delete mode 100644 client/ui/qml/Pages/PageAbout.qml delete mode 100644 client/ui/qml/Pages/PageAdvancedServerSettings.qml delete mode 100644 client/ui/qml/Pages/PageAppSetting.qml delete mode 100644 client/ui/qml/Pages/PageBase.qml delete mode 100644 client/ui/qml/Pages/PageClientManagement.qml delete mode 100644 client/ui/qml/Pages/PageGeneralSettings.qml delete mode 100644 client/ui/qml/Pages/PageNetworkSetting.qml delete mode 100644 client/ui/qml/Pages/PageNewServer.qml delete mode 100644 client/ui/qml/Pages/PageNewServerProtocols.qml delete mode 100644 client/ui/qml/Pages/PageQrDecoderIos.qml delete mode 100644 client/ui/qml/Pages/PageServerConfiguringProgress.qml delete mode 100644 client/ui/qml/Pages/PageServerContainers.qml delete mode 100644 client/ui/qml/Pages/PageServerList.qml delete mode 100644 client/ui/qml/Pages/PageServerSettings.qml delete mode 100644 client/ui/qml/Pages/PageSetupWizard.qml delete mode 100644 client/ui/qml/Pages/PageSetupWizardHighLevel.qml delete mode 100644 client/ui/qml/Pages/PageSetupWizardLowLevel.qml delete mode 100644 client/ui/qml/Pages/PageSetupWizardMediumLevel.qml delete mode 100644 client/ui/qml/Pages/PageSetupWizardVPNMode.qml delete mode 100644 client/ui/qml/Pages/PageShareConnection.qml delete mode 100644 client/ui/qml/Pages/PageSites.qml delete mode 100644 client/ui/qml/Pages/PageStart.qml delete mode 100644 client/ui/qml/Pages/PageVPN.qml delete mode 100644 client/ui/qml/Pages/PageViewConfig.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtoCloak.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtoOpenVPN.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtoSftp.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtoShadowSocks.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtoWireGuard.qml delete mode 100644 client/ui/qml/Pages/Protocols/PageProtocolBase.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoAmnezia.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoCloak.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoIkev2.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoOpenVPN.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoSftp.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoShadowSocks.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtoWireGuard.qml delete mode 100644 client/ui/qml/Pages/Share/PageShareProtocolBase.qml delete mode 100644 client/ui/qml/main.qml delete mode 100644 client/ui/uilogic.cpp delete mode 100644 client/ui/uilogic.h diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 47264fe60..ca5161cff 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -95,7 +95,6 @@ set(HEADERS ${HEADERS} ${CMAKE_CURRENT_LIST_DIR}/ui/notificationhandler.h ${CMAKE_CURRENT_LIST_DIR}/ui/pages.h ${CMAKE_CURRENT_LIST_DIR}/ui/property_helper.h - ${CMAKE_CURRENT_LIST_DIR}/ui/uilogic.h ${CMAKE_CURRENT_LIST_DIR}/ui/qautostart.h ${CMAKE_CURRENT_LIST_DIR}/protocols/vpnprotocol.h ${CMAKE_CURRENT_BINARY_DIR}/version.h @@ -132,7 +131,6 @@ set(SOURCES ${SOURCES} ${CMAKE_CURRENT_LIST_DIR}/core/servercontroller.cpp ${CMAKE_CURRENT_LIST_DIR}/protocols/protocols_defs.cpp ${CMAKE_CURRENT_LIST_DIR}/ui/notificationhandler.cpp - ${CMAKE_CURRENT_LIST_DIR}/ui/uilogic.cpp ${CMAKE_CURRENT_LIST_DIR}/ui/qautostart.cpp ${CMAKE_CURRENT_LIST_DIR}/protocols/vpnprotocol.cpp ${CMAKE_CURRENT_LIST_DIR}/core/sshclient.cpp diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index c45867484..d14917f01 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -156,7 +156,7 @@ void AmneziaApplication::init() // Android TextField clipboard workaround // https://bugreports.qt.io/browse/QTBUG-113461 #ifdef Q_OS_ANDROID - QObject::connect(qApp, &QApplication::applicationStateChanged, [](Qt::ApplicationState state) { + QObject::connect(qApp, &QGuiApplication::applicationStateChanged, [](Qt::ApplicationState state) { if (state == Qt::ApplicationActive) { if (qApp->clipboard()->mimeData()->formats().contains("text/html")) { QTextDocument doc; diff --git a/client/amnezia_application.h b/client/amnezia_application.h index e18fb70ce..40ea81b49 100644 --- a/client/amnezia_application.h +++ b/client/amnezia_application.h @@ -41,7 +41,7 @@ #define amnApp (static_cast(QCoreApplication::instance())) #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) - #define AMNEZIA_BASE_CLASS QGuiApp + #define AMNEZIA_BASE_CLASS QGuiApplication #else #define AMNEZIA_BASE_CLASS SingleApplication #define QAPPLICATION_CLASS QApplication diff --git a/client/configurators/ikev2_configurator.cpp b/client/configurators/ikev2_configurator.cpp index 7ed83da10..4ca0e5dac 100644 --- a/client/configurators/ikev2_configurator.cpp +++ b/client/configurators/ikev2_configurator.cpp @@ -1,28 +1,26 @@ #include "ikev2_configurator.h" -#include + +#include +#include #include #include #include -#include #include -#include #include #include "containers/containers_defs.h" -#include "core/server_defs.h" #include "core/scripts_registry.h" -#include "utilities.h" +#include "core/server_defs.h" #include "core/servercontroller.h" +#include "utilities.h" - -Ikev2Configurator::Ikev2Configurator(std::shared_ptr settings, QObject *parent): - ConfiguratorBase(settings, parent) +Ikev2Configurator::Ikev2Configurator(std::shared_ptr settings, QObject *parent) + : ConfiguratorBase(settings, parent) { - } Ikev2Configurator::ConnectionData Ikev2Configurator::prepareIkev2Config(const ServerCredentials &credentials, - DockerContainer container, ErrorCode *errorCode) + DockerContainer container, ErrorCode *errorCode) { Ikev2Configurator::ConnectionData connData; connData.host = credentials.hostName; @@ -32,26 +30,27 @@ Ikev2Configurator::ConnectionData Ikev2Configurator::prepareIkev2Config(const Se QString certFileName = "/opt/amnezia/ikev2/clients/" + connData.clientId + ".p12"; - QString scriptCreateCert = QString("certutil -z <(head -c 1024 /dev/urandom) "\ - "-S -c \"IKEv2 VPN CA\" -n \"%1\" "\ - "-s \"O=IKEv2 VPN,CN=%1\" "\ - "-k rsa -g 3072 -v 120 "\ - "-d sql:/etc/ipsec.d -t \",,\" "\ - "--keyUsage digitalSignature,keyEncipherment "\ - "--extKeyUsage serverAuth,clientAuth -8 \"%1\"") - .arg(connData.clientId); + QString scriptCreateCert = QString("certutil -z <(head -c 1024 /dev/urandom) " + "-S -c \"IKEv2 VPN CA\" -n \"%1\" " + "-s \"O=IKEv2 VPN,CN=%1\" " + "-k rsa -g 3072 -v 120 " + "-d sql:/etc/ipsec.d -t \",,\" " + "--keyUsage digitalSignature,keyEncipherment " + "--extKeyUsage serverAuth,clientAuth -8 \"%1\"") + .arg(connData.clientId); ServerController serverController(m_settings); ErrorCode e = serverController.runContainerScript(credentials, container, scriptCreateCert); QString scriptExportCert = QString("pk12util -W \"%1\" -d sql:/etc/ipsec.d -n \"%2\" -o \"%3\"") - .arg(connData.password) - .arg(connData.clientId) - .arg(certFileName); + .arg(connData.password) + .arg(connData.clientId) + .arg(certFileName); e = serverController.runContainerScript(credentials, container, scriptExportCert); connData.clientCert = serverController.getTextFileFromContainer(container, credentials, certFileName, &e); - connData.caCert = serverController.getTextFileFromContainer(container, credentials, "/etc/ipsec.d/ca_cert_base64.p12", &e); + connData.caCert = + serverController.getTextFileFromContainer(container, credentials, "/etc/ipsec.d/ca_cert_base64.p12", &e); qDebug() << "Ikev2Configurator::ConnectionData client cert size:" << connData.clientCert.size(); qDebug() << "Ikev2Configurator::ConnectionData ca cert size:" << connData.caCert.size(); @@ -59,8 +58,8 @@ Ikev2Configurator::ConnectionData Ikev2Configurator::prepareIkev2Config(const Se return connData; } -QString Ikev2Configurator::genIkev2Config(const ServerCredentials &credentials, - DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode) +QString Ikev2Configurator::genIkev2Config(const ServerCredentials &credentials, DockerContainer container, + const QJsonObject &containerConfig, ErrorCode *errorCode) { Q_UNUSED(containerConfig) @@ -120,4 +119,3 @@ QString Ikev2Configurator::genStrongSwanConfig(const ConnectionData &connData) return config; } - diff --git a/client/configurators/openvpn_configurator.cpp b/client/configurators/openvpn_configurator.cpp index 3bc6676a4..bfde4a913 100644 --- a/client/configurators/openvpn_configurator.cpp +++ b/client/configurators/openvpn_configurator.cpp @@ -1,82 +1,89 @@ #include "openvpn_configurator.h" -#include + +#include +#include +#include #include #include #include -#include #include -#include -#include #include "containers/containers_defs.h" +#include "core/scripts_registry.h" #include "core/server_defs.h" #include "core/servercontroller.h" -#include "core/scripts_registry.h" -#include "utilities.h" #include "settings.h" +#include "utilities.h" +#include #include #include -#include -OpenVpnConfigurator::OpenVpnConfigurator(std::shared_ptr settings, QObject *parent): - ConfiguratorBase(settings, parent) +OpenVpnConfigurator::OpenVpnConfigurator(std::shared_ptr settings, QObject *parent) + : ConfiguratorBase(settings, parent) { - } OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::prepareOpenVpnConfig(const ServerCredentials &credentials, - DockerContainer container, ErrorCode *errorCode) + DockerContainer container, + ErrorCode *errorCode) { OpenVpnConfigurator::ConnectionData connData = OpenVpnConfigurator::createCertRequest(); connData.host = credentials.hostName; if (connData.privKey.isEmpty() || connData.request.isEmpty()) { - if (errorCode) *errorCode = ErrorCode::OpenSslFailed; + if (errorCode) + *errorCode = ErrorCode::OpenSslFailed; return connData; } - QString reqFileName = QString("%1/%2.req"). - arg(amnezia::protocols::openvpn::clientsDirPath). - arg(connData.clientId); + QString reqFileName = QString("%1/%2.req").arg(amnezia::protocols::openvpn::clientsDirPath).arg(connData.clientId); ServerController serverController(m_settings); ErrorCode e = serverController.uploadTextFileToContainer(container, credentials, connData.request, reqFileName); if (e) { - if (errorCode) *errorCode = e; + if (errorCode) + *errorCode = e; return connData; } e = signCert(container, credentials, connData.clientId); if (e) { - if (errorCode) *errorCode = e; + if (errorCode) + *errorCode = e; return connData; } - connData.caCert = serverController.getTextFileFromContainer(container, credentials, amnezia::protocols::openvpn::caCertPath, &e); - connData.clientCert = serverController.getTextFileFromContainer(container, credentials, - QString("%1/%2.crt").arg(amnezia::protocols::openvpn::clientCertPath).arg(connData.clientId), &e); + connData.caCert = serverController.getTextFileFromContainer(container, credentials, + amnezia::protocols::openvpn::caCertPath, &e); + connData.clientCert = serverController.getTextFileFromContainer( + container, credentials, + QString("%1/%2.crt").arg(amnezia::protocols::openvpn::clientCertPath).arg(connData.clientId), &e); if (e) { - if (errorCode) *errorCode = e; + if (errorCode) + *errorCode = e; return connData; } - connData.taKey = serverController.getTextFileFromContainer(container, credentials, amnezia::protocols::openvpn::taKeyPath, &e); + connData.taKey = serverController.getTextFileFromContainer(container, credentials, + amnezia::protocols::openvpn::taKeyPath, &e); if (connData.caCert.isEmpty() || connData.clientCert.isEmpty() || connData.taKey.isEmpty()) { - if (errorCode) *errorCode = ErrorCode::SshSftpFailureError; + if (errorCode) + *errorCode = ErrorCode::SshSftpFailureError; } return connData; } -QString OpenVpnConfigurator::genOpenVpnConfig(const ServerCredentials &credentials, - DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode) +QString OpenVpnConfigurator::genOpenVpnConfig(const ServerCredentials &credentials, DockerContainer container, + const QJsonObject &containerConfig, ErrorCode *errorCode) { ServerController serverController(m_settings); - QString config = serverController.replaceVars(amnezia::scriptData(ProtocolScriptType::openvpn_template, container), - serverController.genVarsForScript(credentials, container, containerConfig)); + QString config = + serverController.replaceVars(amnezia::scriptData(ProtocolScriptType::openvpn_template, container), + serverController.genVarsForScript(credentials, container, containerConfig)); ConnectionData connData = prepareOpenVpnConfig(credentials, container, errorCode); if (errorCode && *errorCode) { @@ -89,8 +96,7 @@ QString OpenVpnConfigurator::genOpenVpnConfig(const ServerCredentials &credentia if (config.contains("$OPENVPN_TA_KEY")) { config.replace("$OPENVPN_TA_KEY", connData.taKey); - } - else { + } else { config.replace("", ""); config.replace("", ""); } @@ -133,12 +139,11 @@ QString OpenVpnConfigurator::processConfigWithLocalSettings(QString jsonConfig) config.replace("block-outside-dns", ""); #endif -#if (defined (MZ_MACOS) || defined(MZ_LINUX)) - QString dnsConf = QString( - "\nscript-security 2\n" - "up %1/update-resolv-conf.sh\n" - "down %1/update-resolv-conf.sh\n"). - arg(qApp->applicationDirPath()); +#if (defined(MZ_MACOS) || defined(MZ_LINUX)) + QString dnsConf = QString("\nscript-security 2\n" + "up %1/update-resolv-conf.sh\n" + "down %1/update-resolv-conf.sh\n") + .arg(qApp->applicationDirPath()); config.append(dnsConf); #endif @@ -168,23 +173,23 @@ QString OpenVpnConfigurator::processConfigWithExportSettings(QString jsonConfig) return QJsonDocument(json).toJson(); } -ErrorCode OpenVpnConfigurator::signCert(DockerContainer container, - const ServerCredentials &credentials, QString clientId) +ErrorCode OpenVpnConfigurator::signCert(DockerContainer container, const ServerCredentials &credentials, QString clientId) { QString script_import = QString("sudo docker exec -i %1 bash -c \"cd /opt/amnezia/openvpn && " - "easyrsa import-req %2/%3.req %3\"") - .arg(ContainerProps::containerToString(container)) - .arg(amnezia::protocols::openvpn::clientsDirPath) - .arg(clientId); + "easyrsa import-req %2/%3.req %3\"") + .arg(ContainerProps::containerToString(container)) + .arg(amnezia::protocols::openvpn::clientsDirPath) + .arg(clientId); QString script_sign = QString("sudo docker exec -i %1 bash -c \"export EASYRSA_BATCH=1; cd /opt/amnezia/openvpn && " - "easyrsa sign-req client %2\"") - .arg(ContainerProps::containerToString(container)) - .arg(clientId); + "easyrsa sign-req client %2\"") + .arg(ContainerProps::containerToString(container)) + .arg(clientId); ServerController serverController(m_settings); - QStringList scriptList {script_import, script_sign}; - QString script = serverController.replaceVars(scriptList.join("\n"), serverController.genVarsForScript(credentials, container)); + QStringList scriptList { script_import, script_sign }; + QString script = serverController.replaceVars(scriptList.join("\n"), + serverController.genVarsForScript(credentials, container)); return serverController.runScript(credentials, script); } @@ -194,18 +199,17 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() ConnectionData connData; connData.clientId = Utils::getRandomString(32); - int ret = 0; - int nVersion = 1; + int ret = 0; + int nVersion = 1; QByteArray clientIdUtf8 = connData.clientId.toUtf8(); - EVP_PKEY * pKey = EVP_PKEY_new(); + EVP_PKEY *pKey = EVP_PKEY_new(); q_check_ptr(pKey); - RSA * rsa = RSA_generate_key(2048, RSA_F4, nullptr, nullptr); + RSA *rsa = RSA_generate_key(2048, RSA_F4, nullptr, nullptr); q_check_ptr(rsa); EVP_PKEY_assign_RSA(pKey, rsa); - // 2. set version of x509 req X509_REQ *x509_req = X509_REQ_new(); ret = X509_REQ_set_version(x509_req, nVersion); @@ -219,16 +223,14 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() // 3. set subject of x509 req X509_NAME *x509_name = X509_REQ_get_subject_name(x509_req); - X509_NAME_add_entry_by_txt(x509_name, "C", MBSTRING_ASC, - (unsigned char *)"ORG", -1, -1, 0); - X509_NAME_add_entry_by_txt(x509_name, "O", MBSTRING_ASC, - (unsigned char *)"", -1, -1, 0); + X509_NAME_add_entry_by_txt(x509_name, "C", MBSTRING_ASC, (unsigned char *)"ORG", -1, -1, 0); + X509_NAME_add_entry_by_txt(x509_name, "O", MBSTRING_ASC, (unsigned char *)"", -1, -1, 0); X509_NAME_add_entry_by_txt(x509_name, "CN", MBSTRING_ASC, reinterpret_cast(clientIdUtf8.data()), clientIdUtf8.size(), -1, 0); // 4. set public key of x509 req ret = X509_REQ_set_pubkey(x509_req, pKey); - if (ret != 1){ + if (ret != 1) { qWarning() << "Could not set pubkey!"; X509_REQ_free(x509_req); EVP_PKEY_free(pKey); @@ -236,8 +238,8 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() } // 5. set sign key of x509 req - ret = X509_REQ_sign(x509_req, pKey, EVP_sha256()); // return x509_req->signature->length - if (ret <= 0){ + ret = X509_REQ_sign(x509_req, pKey, EVP_sha256()); // return x509_req->signature->length + if (ret <= 0) { qWarning() << "Could not sign request!"; X509_REQ_free(x509_req); EVP_PKEY_free(pKey); @@ -245,10 +247,9 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() } // save private key - BIO * bp_private = BIO_new(BIO_s_mem()); + BIO *bp_private = BIO_new(BIO_s_mem()); q_check_ptr(bp_private); - if (PEM_write_bio_PrivateKey(bp_private, pKey, nullptr, nullptr, 0, nullptr, nullptr) != 1) - { + if (PEM_write_bio_PrivateKey(bp_private, pKey, nullptr, nullptr, 0, nullptr, nullptr) != 1) { qFatal("PEM_write_bio_PrivateKey"); EVP_PKEY_free(pKey); BIO_free_all(bp_private); @@ -256,7 +257,7 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() return connData; } - const char * buffer = nullptr; + const char *buffer = nullptr; size_t size = BIO_get_mem_data(bp_private, &buffer); q_check_ptr(buffer); connData.privKey = QByteArray(buffer, size); @@ -270,7 +271,7 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() BIO_free_all(bp_private); // save req - BIO * bio_req = BIO_new(BIO_s_mem()); + BIO *bio_req = BIO_new(BIO_s_mem()); PEM_write_bio_X509_REQ(bio_req, x509_req); BUF_MEM *bio_buf; @@ -278,7 +279,6 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::createCertRequest() connData.request = QByteArray(bio_buf->data, bio_buf->length); BIO_free(bio_req); - EVP_PKEY_free(pKey); // this will also free the rsa key return connData; diff --git a/client/configurators/ssh_configurator.cpp b/client/configurators/ssh_configurator.cpp index d94e44684..42e7eb476 100644 --- a/client/configurators/ssh_configurator.cpp +++ b/client/configurators/ssh_configurator.cpp @@ -1,24 +1,25 @@ #include "ssh_configurator.h" -#include + +#include +#include #include #include #include -#include #include #include -#include -#include -#include #include +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) + #include +#else + #include +#endif #include "core/server_defs.h" #include "utilities.h" - -SshConfigurator::SshConfigurator(std::shared_ptr settings, QObject *parent): - ConfiguratorBase(settings, parent) +SshConfigurator::SshConfigurator(std::shared_ptr settings, QObject *parent) + : ConfiguratorBase(settings, parent) { - } QString SshConfigurator::convertOpenSShKey(const QString &key) @@ -28,23 +29,30 @@ QString SshConfigurator::convertOpenSShKey(const QString &key) p.setProcessChannelMode(QProcess::MergedChannels); QTemporaryFile tmp; -#ifdef QT_DEBUG + #ifdef QT_DEBUG tmp.setAutoRemove(false); -#endif + #endif tmp.open(); tmp.write(key.toUtf8()); tmp.close(); // ssh-keygen -p -P "" -N "" -m pem -f id_ssh -#ifdef Q_OS_WIN + #ifdef Q_OS_WIN p.setProcessEnvironment(prepareEnv()); p.setProgram("cmd.exe"); p.setNativeArguments(QString("/C \"ssh-keygen.exe -p -P \"\" -N \"\" -m pem -f \"%1\"\"").arg(tmp.fileName())); -#else + #else p.setProgram("ssh-keygen"); - p.setArguments(QStringList() << "-p" << "-P" << "" << "-N" << "" << "-m" << "pem" << "-f" << tmp.fileName()); -#endif + p.setArguments(QStringList() << "-p" + << "-P" + << "" + << "-N" + << "" + << "-m" + << "pem" + << "-f" << tmp.fileName()); + #endif p.start(); p.waitForFinished(); @@ -65,22 +73,21 @@ void SshConfigurator::openSshTerminal(const ServerCredentials &credentials) QProcess *p = new QProcess(); p->setProcessChannelMode(QProcess::SeparateChannels); -#ifdef Q_OS_WIN + #ifdef Q_OS_WIN p->setProcessEnvironment(prepareEnv()); p->setProgram(qApp->applicationDirPath() + "\\cygwin\\putty.exe"); if (credentials.secretData.contains("PRIVATE KEY")) { // todo: connect by key -// p->setNativeArguments(QString("%1@%2") -// .arg(credentials.userName).arg(credentials.hostName).arg(credentials.secretData)); + // p->setNativeArguments(QString("%1@%2") + // .arg(credentials.userName).arg(credentials.hostName).arg(credentials.secretData)); + } else { + p->setNativeArguments( + QString("%1@%2 -pw %3").arg(credentials.userName).arg(credentials.hostName).arg(credentials.secretData)); } - else { - p->setNativeArguments(QString("%1@%2 -pw %3") - .arg(credentials.userName).arg(credentials.hostName).arg(credentials.secretData)); - } -#else + #else p->setProgram("/bin/bash"); -#endif + #endif p->startDetached(); #endif @@ -95,11 +102,11 @@ QProcessEnvironment SshConfigurator::prepareEnv() pathEnvVar.clear(); pathEnvVar.prepend(QDir::toNativeSeparators(QApplication::applicationDirPath()) + "\\cygwin;"); pathEnvVar.prepend(QDir::toNativeSeparators(QApplication::applicationDirPath()) + "\\openvpn;"); -#else +#elif defined(Q_OS_MACX) pathEnvVar.prepend(QDir::toNativeSeparators(QApplication::applicationDirPath()) + "/Contents/MacOS"); #endif env.insert("PATH", pathEnvVar); - //qDebug().noquote() << "ENV PATH" << pathEnvVar; + // qDebug().noquote() << "ENV PATH" << pathEnvVar; return env; } diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index 54ee320cd..14059977b 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -1,30 +1,27 @@ #include "wireguard_configurator.h" -#include + +#include +#include #include #include #include -#include #include -#include - +#include #include #include #include -#include - #include "containers/containers_defs.h" -#include "core/server_defs.h" #include "core/scripts_registry.h" -#include "utilities.h" +#include "core/server_defs.h" #include "core/servercontroller.h" #include "settings.h" +#include "utilities.h" -WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, QObject *parent): - ConfiguratorBase(settings, parent) +WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, QObject *parent) + : ConfiguratorBase(settings, parent) { - } WireguardConfigurator::ConnectionData WireguardConfigurator::genClientKeys() @@ -36,37 +33,40 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::genClientKeys() unsigned char buff[EDDSA_KEY_LENGTH]; int ret = RAND_priv_bytes(buff, EDDSA_KEY_LENGTH); - if (ret <=0) return connData; + if (ret <= 0) + return connData; - EVP_PKEY * pKey = EVP_PKEY_new(); + EVP_PKEY *pKey = EVP_PKEY_new(); q_check_ptr(pKey); pKey = EVP_PKEY_new_raw_private_key(EVP_PKEY_X25519, NULL, &buff[0], EDDSA_KEY_LENGTH); - size_t keySize = EDDSA_KEY_LENGTH; // save private key unsigned char priv[EDDSA_KEY_LENGTH]; EVP_PKEY_get_raw_private_key(pKey, priv, &keySize); - connData.clientPrivKey = QByteArray::fromRawData((char*)priv, keySize).toBase64(); + connData.clientPrivKey = QByteArray::fromRawData((char *)priv, keySize).toBase64(); // save public key unsigned char pub[EDDSA_KEY_LENGTH]; EVP_PKEY_get_raw_public_key(pKey, pub, &keySize); - connData.clientPubKey = QByteArray::fromRawData((char*)pub, keySize).toBase64(); + connData.clientPubKey = QByteArray::fromRawData((char *)pub, keySize).toBase64(); return connData; } WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardConfig(const ServerCredentials &credentials, - DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode) + DockerContainer container, + const QJsonObject &containerConfig, + ErrorCode *errorCode) { WireguardConfigurator::ConnectionData connData = WireguardConfigurator::genClientKeys(); connData.host = credentials.hostName; connData.port = containerConfig.value(config_key::port).toString(protocols::wireguard::defaultPort); if (connData.clientPrivKey.isEmpty() || connData.clientPubKey.isEmpty()) { - if (errorCode) *errorCode = ErrorCode::InternalError; + if (errorCode) + *errorCode = ErrorCode::InternalError; return connData; } @@ -96,22 +96,24 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon // Calc next IP address if (ips.isEmpty()) { nextIpNumber = "2"; - } - else { + } else { int next = ips.last().split(".").last().toInt() + 1; if (next > 254) { - if (errorCode) *errorCode = ErrorCode::AddressPoolError; + if (errorCode) + *errorCode = ErrorCode::AddressPoolError; return connData; } nextIpNumber = QString::number(next); } } - QString subnetIp = containerConfig.value(config_key::subnet_address).toString(protocols::wireguard::defaultSubnetAddress); + QString subnetIp = + containerConfig.value(config_key::subnet_address).toString(protocols::wireguard::defaultSubnetAddress); { QStringList l = subnetIp.split(".", Qt::SkipEmptyParts); if (l.isEmpty()) { - if (errorCode) *errorCode = ErrorCode::AddressPoolError; + if (errorCode) + *errorCode = ErrorCode::AddressPoolError; return connData; } l.removeLast(); @@ -121,52 +123,60 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon } // Get keys - connData.serverPubKey = serverController.getTextFileFromContainer(container, credentials, amnezia::protocols::wireguard::serverPublicKeyPath, &e); + connData.serverPubKey = serverController.getTextFileFromContainer( + container, credentials, amnezia::protocols::wireguard::serverPublicKeyPath, &e); connData.serverPubKey.replace("\n", ""); if (e) { - if (errorCode) *errorCode = e; + if (errorCode) + *errorCode = e; return connData; } - connData.pskKey = serverController.getTextFileFromContainer(container, credentials, amnezia::protocols::wireguard::serverPskKeyPath, &e); + connData.pskKey = serverController.getTextFileFromContainer(container, credentials, + amnezia::protocols::wireguard::serverPskKeyPath, &e); connData.pskKey.replace("\n", ""); if (e) { - if (errorCode) *errorCode = e; + if (errorCode) + *errorCode = e; return connData; } // Add client to config - QString configPart = QString( - "[Peer]\n" - "PublicKey = %1\n" - "PresharedKey = %2\n" - "AllowedIPs = %3/32\n\n"). - arg(connData.clientPubKey). - arg(connData.pskKey). - arg(connData.clientIP); + QString configPart = QString("[Peer]\n" + "PublicKey = %1\n" + "PresharedKey = %2\n" + "AllowedIPs = %3/32\n\n") + .arg(connData.clientPubKey) + .arg(connData.pskKey) + .arg(connData.clientIP); e = serverController.uploadTextFileToContainer(container, credentials, configPart, - protocols::wireguard::serverConfigPath, libssh::SftpOverwriteMode::SftpAppendToExisting); + protocols::wireguard::serverConfigPath, + libssh::SftpOverwriteMode::SftpAppendToExisting); if (e) { - if (errorCode) *errorCode = e; + if (errorCode) + *errorCode = e; return connData; } - e = serverController.runScript(credentials, - serverController.replaceVars("sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick strip /opt/amnezia/wireguard/wg0.conf)'", - serverController.genVarsForScript(credentials, container))); + e = serverController.runScript( + credentials, + serverController.replaceVars("sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick " + "strip /opt/amnezia/wireguard/wg0.conf)'", + serverController.genVarsForScript(credentials, container))); return connData; } -QString WireguardConfigurator::genWireguardConfig(const ServerCredentials &credentials, - DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode) +QString WireguardConfigurator::genWireguardConfig(const ServerCredentials &credentials, DockerContainer container, + const QJsonObject &containerConfig, ErrorCode *errorCode) { ServerController serverController(m_settings); - QString config = serverController.replaceVars(amnezia::scriptData(ProtocolScriptType::wireguard_template, container), - serverController.genVarsForScript(credentials, container, containerConfig)); + QString config = + serverController.replaceVars(amnezia::scriptData(ProtocolScriptType::wireguard_template, container), + serverController.genVarsForScript(credentials, container, containerConfig)); ConnectionData connData = prepareWireguardConfig(credentials, container, containerConfig, errorCode); if (errorCode && *errorCode) { diff --git a/client/fileUtilites.cpp b/client/fileUtilites.cpp index c1b60966f..b3c65216c 100644 --- a/client/fileUtilites.cpp +++ b/client/fileUtilites.cpp @@ -1,7 +1,9 @@ #include "fileUtilites.h" -#include "platforms/ios/MobileUtils.h" #include +#include +#include +#include #include #ifdef Q_OS_ANDROID diff --git a/client/platforms/android/androidutils.cpp b/client/platforms/android/androidutils.cpp index 5e9f094cf..7cc39824f 100644 --- a/client/platforms/android/androidutils.cpp +++ b/client/platforms/android/androidutils.cpp @@ -4,23 +4,25 @@ #include "androidutils.h" -#include +#include #include #include #include #include #include -#include #include +#include #include "jni.h" -namespace { - AndroidUtils* s_instance = nullptr; -} // namespace +namespace +{ + AndroidUtils *s_instance = nullptr; +} // namespace // static -QString AndroidUtils::GetDeviceName() { +QString AndroidUtils::GetDeviceName() +{ QJniEnvironment env; jclass BUILD = env->FindClass("android/os/Build"); jfieldID model = env->GetStaticFieldID(BUILD, "MODEL", "Ljava/lang/String;"); @@ -30,7 +32,7 @@ QString AndroidUtils::GetDeviceName() { return QString("Android Device"); } - const char* buffer = env->GetStringUTFChars(value, nullptr); + const char *buffer = env->GetStringUTFChars(value, nullptr); if (!buffer) { return QString("Android Device"); } @@ -42,7 +44,8 @@ QString AndroidUtils::GetDeviceName() { }; // static -AndroidUtils* AndroidUtils::instance() { +AndroidUtils *AndroidUtils::instance() +{ if (!s_instance) { Q_ASSERT(qApp); s_instance = new AndroidUtils(qApp); @@ -51,19 +54,22 @@ AndroidUtils* AndroidUtils::instance() { return s_instance; } -AndroidUtils::AndroidUtils(QObject* parent) : QObject(parent) { +AndroidUtils::AndroidUtils(QObject *parent) : QObject(parent) +{ Q_ASSERT(!s_instance); s_instance = this; } -AndroidUtils::~AndroidUtils() { +AndroidUtils::~AndroidUtils() +{ Q_ASSERT(s_instance == this); s_instance = nullptr; } // static -void AndroidUtils::dispatchToMainThread(std::function callback) { - QTimer* timer = new QTimer(); +void AndroidUtils::dispatchToMainThread(std::function callback) +{ + QTimer *timer = new QTimer(); timer->moveToThread(qApp->thread()); timer->setSingleShot(true); QObject::connect(timer, &QTimer::timeout, [=]() { @@ -74,8 +80,9 @@ void AndroidUtils::dispatchToMainThread(std::function callback) { } // static -QByteArray AndroidUtils::getQByteArrayFromJString(JNIEnv* env, jstring data) { - const char* buffer = env->GetStringUTFChars(data, nullptr); +QByteArray AndroidUtils::getQByteArrayFromJString(JNIEnv *env, jstring data) +{ + const char *buffer = env->GetStringUTFChars(data, nullptr); if (!buffer) { qDebug() << "getQByteArrayFromJString - failed to parse data."; return QByteArray(); @@ -87,8 +94,9 @@ QByteArray AndroidUtils::getQByteArrayFromJString(JNIEnv* env, jstring data) { } // static -QString AndroidUtils::getQStringFromJString(JNIEnv* env, jstring data) { - const char* buffer = env->GetStringUTFChars(data, nullptr); +QString AndroidUtils::getQStringFromJString(JNIEnv *env, jstring data) +{ + const char *buffer = env->GetStringUTFChars(data, nullptr); if (!buffer) { qDebug() << "getQStringFromJString - failed to parse data."; return QString(); @@ -100,15 +108,14 @@ QString AndroidUtils::getQStringFromJString(JNIEnv* env, jstring data) { } // static -QJsonObject AndroidUtils::getQJsonObjectFromJString(JNIEnv* env, jstring data) { +QJsonObject AndroidUtils::getQJsonObjectFromJString(JNIEnv *env, jstring data) +{ QByteArray raw(getQByteArrayFromJString(env, data)); QJsonParseError jsonError; QJsonDocument json = QJsonDocument::fromJson(raw, &jsonError); if (QJsonParseError::NoError != jsonError.error) { - qDebug() << "getQJsonObjectFromJstring - error parsing json. Code: " - << jsonError.error << "Offset: " << jsonError.offset - << "Message: " << jsonError.errorString() - << "Data: " << raw; + qDebug() << "getQJsonObjectFromJstring - error parsing json. Code: " << jsonError.error + << "Offset: " << jsonError.offset << "Message: " << jsonError.errorString() << "Data: " << raw; return QJsonObject(); } @@ -120,11 +127,13 @@ QJsonObject AndroidUtils::getQJsonObjectFromJString(JNIEnv* env, jstring data) { return json.object(); } -QJniObject AndroidUtils::getActivity() { +QJniObject AndroidUtils::getActivity() +{ return QNativeInterface::QAndroidApplication::context(); } -int AndroidUtils::GetSDKVersion() { +int AndroidUtils::GetSDKVersion() +{ QJniEnvironment env; jclass versionClass = env->FindClass("android/os/Build$VERSION"); jfieldID sdkIntFieldID = env->GetStaticFieldID(versionClass, "SDK_INT", "I"); @@ -133,15 +142,14 @@ int AndroidUtils::GetSDKVersion() { return sdk; } -QString AndroidUtils::GetManufacturer() { +QString AndroidUtils::GetManufacturer() +{ QJniEnvironment env; jclass buildClass = env->FindClass("android/os/Build"); - jfieldID manuFacturerField = - env->GetStaticFieldID(buildClass, "MANUFACTURER", "Ljava/lang/String;"); - jstring value = - (jstring)env->GetStaticObjectField(buildClass, manuFacturerField); + jfieldID manuFacturerField = env->GetStaticFieldID(buildClass, "MANUFACTURER", "Ljava/lang/String;"); + jstring value = (jstring)env->GetStaticObjectField(buildClass, manuFacturerField); - const char* buffer = env->GetStringUTFChars(value, nullptr); + const char *buffer = env->GetStringUTFChars(value, nullptr); if (!buffer) { qDebug() << "Failed to fetch MANUFACTURER"; @@ -154,21 +162,22 @@ QString AndroidUtils::GetManufacturer() { return res; } -void AndroidUtils::runOnAndroidThreadSync(const std::function runnable) { - QNativeInterface::QAndroidApplication::runOnAndroidMainThread(runnable) - .waitForFinished(); +void AndroidUtils::runOnAndroidThreadSync(const std::function runnable) +{ + QNativeInterface::QAndroidApplication::runOnAndroidMainThread(runnable).waitForFinished(); } -void AndroidUtils::runOnAndroidThreadAsync(const std::function runnable) { +void AndroidUtils::runOnAndroidThreadAsync(const std::function runnable) +{ QNativeInterface::QAndroidApplication::runOnAndroidMainThread(runnable); } // Static // Creates a copy of the passed QByteArray in the JVM and passes back a ref -jbyteArray AndroidUtils::tojByteArray(const QByteArray& data) { +jbyteArray AndroidUtils::tojByteArray(const QByteArray &data) +{ QJniEnvironment env; jbyteArray out = env->NewByteArray(data.size()); - env->SetByteArrayRegion(out, 0, data.size(), - reinterpret_cast(data.constData())); + env->SetByteArrayRegion(out, 0, data.size(), reinterpret_cast(data.constData())); return out; } diff --git a/client/platforms/android/androidvpnactivity.cpp b/client/platforms/android/androidvpnactivity.cpp index 2076280d7..e81e694b3 100644 --- a/client/platforms/android/androidvpnactivity.cpp +++ b/client/platforms/android/androidvpnactivity.cpp @@ -4,7 +4,6 @@ #include "androidvpnactivity.h" -#include #include #include #include @@ -13,19 +12,21 @@ #include "androidutils.h" #include "jni.h" -namespace { - AndroidVPNActivity* s_instance = nullptr; +namespace +{ + AndroidVPNActivity *s_instance = nullptr; constexpr auto CLASSNAME = "org.amnezia.vpn.qt.VPNActivity"; } -AndroidVPNActivity::AndroidVPNActivity() { +AndroidVPNActivity::AndroidVPNActivity() +{ AndroidUtils::runOnAndroidThreadAsync([]() { - JNINativeMethod methods[]{ - {"handleBackButton", "()Z", reinterpret_cast(handleBackButton)}, - {"onServiceMessage", "(ILjava/lang/String;)V", reinterpret_cast(onServiceMessage)}, - {"qtOnServiceConnected", "()V", reinterpret_cast(onServiceConnected)}, - {"qtOnServiceDisconnected", "()V", reinterpret_cast(onServiceDisconnected)}, - {"onActivityMessage", "(ILjava/lang/String;)V", reinterpret_cast(onAndroidVpnActivityMessage)} + JNINativeMethod methods[] { + { "handleBackButton", "()Z", reinterpret_cast(handleBackButton) }, + { "onServiceMessage", "(ILjava/lang/String;)V", reinterpret_cast(onServiceMessage) }, + { "qtOnServiceConnected", "()V", reinterpret_cast(onServiceConnected) }, + { "qtOnServiceDisconnected", "()V", reinterpret_cast(onServiceDisconnected) }, + { "onActivityMessage", "(ILjava/lang/String;)V", reinterpret_cast(onAndroidVpnActivityMessage) } }; QJniObject javaClass(CLASSNAME); @@ -36,19 +37,22 @@ AndroidVPNActivity::AndroidVPNActivity() { }); } -void AndroidVPNActivity::maybeInit() { +void AndroidVPNActivity::maybeInit() +{ if (s_instance == nullptr) { s_instance = new AndroidVPNActivity(); } } // static -bool AndroidVPNActivity::handleBackButton(JNIEnv* env, jobject thiz) { +bool AndroidVPNActivity::handleBackButton(JNIEnv *env, jobject thiz) +{ Q_UNUSED(env); Q_UNUSED(thiz); } -void AndroidVPNActivity::connectService() { +void AndroidVPNActivity::connectService() +{ QJniObject::callStaticMethod(CLASSNAME, "connectService", "()V"); } @@ -57,16 +61,16 @@ void AndroidVPNActivity::startQrCodeReader() QJniObject::callStaticMethod(CLASSNAME, "startQrCodeReader", "()V"); } -void AndroidVPNActivity::saveFileAs(QString fileContent, QString suggestedFilename) { - QJniObject::callStaticMethod( - CLASSNAME, - "saveFileAs", "(Ljava/lang/String;Ljava/lang/String;)V", - QJniObject::fromString(fileContent).object(), - QJniObject::fromString(suggestedFilename).object()); +void AndroidVPNActivity::saveFileAs(QString fileContent, QString suggestedFilename) +{ + QJniObject::callStaticMethod(CLASSNAME, "saveFileAs", "(Ljava/lang/String;Ljava/lang/String;)V", + QJniObject::fromString(fileContent).object(), + QJniObject::fromString(suggestedFilename).object()); } // static -AndroidVPNActivity* AndroidVPNActivity::instance() { +AndroidVPNActivity *AndroidVPNActivity::instance() +{ if (s_instance == nullptr) { AndroidVPNActivity::maybeInit(); } @@ -75,21 +79,19 @@ AndroidVPNActivity* AndroidVPNActivity::instance() { } // static -void AndroidVPNActivity::sendToService(ServiceAction type, const QString& data) { +void AndroidVPNActivity::sendToService(ServiceAction type, const QString &data) +{ int messageType = (int)type; - QJniObject::callStaticMethod( - CLASSNAME, - "sendToService", "(ILjava/lang/String;)V", - static_cast(messageType), - QJniObject::fromString(data).object()); + QJniObject::callStaticMethod(CLASSNAME, "sendToService", "(ILjava/lang/String;)V", + static_cast(messageType), QJniObject::fromString(data).object()); } // static -void AndroidVPNActivity::onServiceMessage(JNIEnv* env, jobject thiz, - jint messageType, jstring body) { +void AndroidVPNActivity::onServiceMessage(JNIEnv *env, jobject thiz, jint messageType, jstring body) +{ Q_UNUSED(thiz); - const char* buffer = env->GetStringUTFChars(body, nullptr); + const char *buffer = env->GetStringUTFChars(body, nullptr); if (!buffer) { return; } @@ -97,38 +99,23 @@ void AndroidVPNActivity::onServiceMessage(JNIEnv* env, jobject thiz, QString parcelBody(buffer); env->ReleaseStringUTFChars(body, buffer); AndroidUtils::dispatchToMainThread([messageType, parcelBody] { - AndroidVPNActivity::instance()->handleServiceMessage(messageType, - parcelBody); + AndroidVPNActivity::instance()->handleServiceMessage(messageType, parcelBody); }); } -void AndroidVPNActivity::handleServiceMessage(int code, const QString& data) { +void AndroidVPNActivity::handleServiceMessage(int code, const QString &data) +{ auto mode = (ServiceEvents)code; switch (mode) { - case ServiceEvents::EVENT_INIT: - emit eventInitialized(data); - break; - case ServiceEvents::EVENT_CONNECTED: - emit eventConnected(data); - break; - case ServiceEvents::EVENT_DISCONNECTED: - emit eventDisconnected(data); - break; - case ServiceEvents::EVENT_STATISTIC_UPDATE: - emit eventStatisticUpdate(data); - break; - case ServiceEvents::EVENT_BACKEND_LOGS: - emit eventBackendLogs(data); - break; - case ServiceEvents::EVENT_ACTIVATION_ERROR: - emit eventActivationError(data); - break; - case ServiceEvents::EVENT_CONFIG_IMPORT: - emit eventConfigImport(data); - break; - default: - Q_ASSERT(false); + case ServiceEvents::EVENT_INIT: emit eventInitialized(data); break; + case ServiceEvents::EVENT_CONNECTED: emit eventConnected(data); break; + case ServiceEvents::EVENT_DISCONNECTED: emit eventDisconnected(data); break; + case ServiceEvents::EVENT_STATISTIC_UPDATE: emit eventStatisticUpdate(data); break; + case ServiceEvents::EVENT_BACKEND_LOGS: emit eventBackendLogs(data); break; + case ServiceEvents::EVENT_ACTIVATION_ERROR: emit eventActivationError(data); break; + case ServiceEvents::EVENT_CONFIG_IMPORT: emit eventConfigImport(data); break; + default: Q_ASSERT(false); } } @@ -137,22 +124,21 @@ void AndroidVPNActivity::handleActivityMessage(int code, const QString &data) auto mode = (UIEvents)code; switch (mode) { - case UIEvents::QR_CODED_DECODED: - emit eventQrCodeReceived(data); - break; - default: - Q_ASSERT(false); + case UIEvents::QR_CODED_DECODED: emit eventQrCodeReceived(data); break; + default: Q_ASSERT(false); } } -void AndroidVPNActivity::onServiceConnected(JNIEnv* env, jobject thiz) { +void AndroidVPNActivity::onServiceConnected(JNIEnv *env, jobject thiz) +{ Q_UNUSED(env); Q_UNUSED(thiz); emit AndroidVPNActivity::instance()->serviceConnected(); } -void AndroidVPNActivity::onServiceDisconnected(JNIEnv* env, jobject thiz) { +void AndroidVPNActivity::onServiceDisconnected(JNIEnv *env, jobject thiz) +{ Q_UNUSED(env); Q_UNUSED(thiz); @@ -162,7 +148,7 @@ void AndroidVPNActivity::onServiceDisconnected(JNIEnv* env, jobject thiz) { void AndroidVPNActivity::onAndroidVpnActivityMessage(JNIEnv *env, jobject thiz, jint messageType, jstring message) { Q_UNUSED(thiz); - const char* buffer = env->GetStringUTFChars(message, nullptr); + const char *buffer = env->GetStringUTFChars(message, nullptr); if (!buffer) { return; } diff --git a/client/resources.qrc b/client/resources.qrc index 782b64462..d0ff176f7 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -56,75 +56,6 @@ server_scripts/wireguard/template.conf server_scripts/website_tor/configure_container.sh server_scripts/website_tor/run_container.sh - ui/qml/main.qml - ui/qml/Pages/PageBase.qml - ui/qml/Pages/PageAppSetting.qml - ui/qml/Pages/PageGeneralSettings.qml - ui/qml/Pages/PageNetworkSetting.qml - ui/qml/Pages/PageNewServer.qml - ui/qml/Pages/PageServerConfiguringProgress.qml - ui/qml/Pages/PageNewServerProtocols.qml - ui/qml/Pages/PageServerList.qml - ui/qml/Pages/PageServerContainers.qml - ui/qml/Pages/PageServerSettings.qml - ui/qml/Pages/PageSetupWizard.qml - ui/qml/Pages/PageSetupWizardHighLevel.qml - ui/qml/Pages/PageSetupWizardLowLevel.qml - ui/qml/Pages/PageSetupWizardMediumLevel.qml - ui/qml/Pages/PageSetupWizardVPNMode.qml - ui/qml/Pages/PageShareConnection.qml - ui/qml/Pages/PageSites.qml - ui/qml/Pages/PageStart.qml - ui/qml/Pages/PageVPN.qml - ui/qml/Pages/PageAbout.qml - ui/qml/Pages/PageQrDecoderIos.qml - ui/qml/Pages/PageViewConfig.qml - ui/qml/Pages/PageClientManagement.qml - ui/qml/Pages/ClientInfo/PageClientInfoBase.qml - ui/qml/Pages/ClientInfo/PageClientInfoOpenVPN.qml - ui/qml/Pages/ClientInfo/PageClientInfoWireGuard.qml - ui/qml/Pages/Protocols/PageProtoCloak.qml - ui/qml/Pages/Protocols/PageProtoOpenVPN.qml - ui/qml/Pages/Protocols/PageProtoShadowSocks.qml - ui/qml/Pages/Protocols/PageProtoSftp.qml - ui/qml/Pages/Protocols/PageProtoTorWebSite.qml - ui/qml/Pages/Protocols/PageProtocolBase.qml - ui/qml/Pages/Protocols/PageProtoWireGuard.qml - ui/qml/Pages/InstallSettings/InstallSettingsBase.qml - ui/qml/Pages/InstallSettings/SelectContainer.qml - ui/qml/Pages/Share/PageShareProtoCloak.qml - ui/qml/Pages/Share/PageShareProtocolBase.qml - ui/qml/Pages/Share/PageShareProtoOpenVPN.qml - ui/qml/Pages/Share/PageShareProtoSftp.qml - ui/qml/Pages/Share/PageShareProtoShadowSocks.qml - ui/qml/Pages/Share/PageShareProtoTorWebSite.qml - ui/qml/Pages/Share/PageShareProtoAmnezia.qml - ui/qml/Pages/Share/PageShareProtoWireGuard.qml - ui/qml/Pages/Share/PageShareProtoIkev2.qml - ui/qml/Controls/BasicButtonType.qml - ui/qml/Controls/BlueButtonType.qml - ui/qml/Controls/CheckBoxType.qml - ui/qml/Controls/ComboBoxType.qml - ui/qml/Controls/ImageButtonType.qml - ui/qml/Controls/LabelType.qml - ui/qml/Controls/RadioButtonType.qml - ui/qml/Controls/SettingButtonType.qml - ui/qml/Controls/ShareConnectionButtonType.qml - ui/qml/Controls/ShareConnectionContent.qml - ui/qml/Controls/TextFieldType.qml - ui/qml/Controls/RichLabelType.qml - ui/qml/Controls/SvgImageType.qml - ui/qml/Controls/FlickableType.qml - ui/qml/Controls/UrlButtonType.qml - ui/qml/Controls/TextAreaType.qml - ui/qml/Controls/ContextMenu.qml - ui/qml/Controls/FadeBehavior.qml - ui/qml/Controls/VisibleBehavior.qml - ui/qml/Controls/Caption.qml - ui/qml/Controls/Logo.qml - ui/qml/Controls/BackButton.qml - ui/qml/Controls/ShareConnectionButtonCopyType.qml - ui/qml/Controls/SvgButtonType.qml ui/qml/Config/GlobalConfig.qml ui/qml/Config/qmldir server_scripts/check_server_is_busy.sh @@ -161,10 +92,6 @@ images/svg/control_point_black_24dp.svg images/svg/settings_suggest_black_24dp.svg server_scripts/website_tor/Dockerfile - ui/qml/Controls/PopupWithQuestion.qml - ui/qml/Pages/PageAdvancedServerSettings.qml - ui/qml/Controls/PopupWarning.qml - ui/qml/Controls/PopupWithTextField.qml server_scripts/check_user_in_sudo.sh ui/qml/Controls2/BasicButtonType.qml ui/qml/Controls2/TextFieldWithHeaderType.qml diff --git a/client/ui/controllers/connectionController.cpp b/client/ui/controllers/connectionController.cpp index d38130868..0754b024e 100644 --- a/client/ui/controllers/connectionController.cpp +++ b/client/ui/controllers/connectionController.cpp @@ -1,6 +1,10 @@ #include "connectionController.h" -#include +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) + #include +#else + #include +#endif #include "core/errorstrings.h" diff --git a/client/ui/controllers/pageController.cpp b/client/ui/controllers/pageController.cpp index 84d2ebf29..46a1b1fdd 100644 --- a/client/ui/controllers/pageController.cpp +++ b/client/ui/controllers/pageController.cpp @@ -1,6 +1,11 @@ #include "pageController.h" -#include +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) + #include +#else + #include +#endif + #ifdef Q_OS_ANDROID #include "../../platforms/android/androidutils.h" #include diff --git a/client/ui/controllers/settingsController.cpp b/client/ui/controllers/settingsController.cpp index 203d53bdb..7c7402e02 100644 --- a/client/ui/controllers/settingsController.cpp +++ b/client/ui/controllers/settingsController.cpp @@ -2,10 +2,6 @@ #include -#ifdef Q_OS_IOS - #include -#endif - #include "fileUtilites.h" #include "logger.h" #include "ui/qautostart.h" diff --git a/client/ui/controllers/sitesController.cpp b/client/ui/controllers/sitesController.cpp index 16225aa88..5821b3719 100644 --- a/client/ui/controllers/sitesController.cpp +++ b/client/ui/controllers/sitesController.cpp @@ -1,12 +1,9 @@ #include "sitesController.h" +#include #include #include -#ifdef Q_OS_IOS - #include -#endif - #include "fileUtilites.h" #include "utilities.h" diff --git a/client/ui/pages_logic/AdvancedServerSettingsLogic.cpp b/client/ui/pages_logic/AdvancedServerSettingsLogic.cpp deleted file mode 100644 index a96827b67..000000000 --- a/client/ui/pages_logic/AdvancedServerSettingsLogic.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "AdvancedServerSettingsLogic.h" - -#include "VpnLogic.h" -#include "ui/uilogic.h" -#include "core/errorstrings.h" -#include "core/servercontroller.h" - -AdvancedServerSettingsLogic::AdvancedServerSettingsLogic(UiLogic *uiLogic, QObject *parent): PageLogicBase(uiLogic, parent), - m_labelWaitInfoVisible{true}, - m_pushButtonClearVisible{true}, - m_pushButtonClearText{tr("Clear server from Amnezia software")} -{ -} - -void AdvancedServerSettingsLogic::onUpdatePage() -{ - set_labelWaitInfoVisible(false); - set_labelWaitInfoText(""); - set_pushButtonClearVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex)); - const QJsonObject &server = m_settings->server(uiLogic()->m_selectedServerIndex); - const QString &port = server.value(config_key::port).toString(); - - const QString &userName = server.value(config_key::userName).toString(); - const QString &hostName = server.value(config_key::hostName).toString(); - QString name = QString("%1%2%3%4%5").arg(userName, - userName.isEmpty() ? "" : "@", - hostName, - port.isEmpty() ? "" : ":", - port); - - set_labelServerText(name); - - DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer); - set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName); -} - -void AdvancedServerSettingsLogic::onPushButtonClearServerClicked() -{ - set_pageEnabled(false); - set_pushButtonClearText(tr("Uninstalling Amnezia software...")); - - if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex) { - uiLogic()->pageLogic()->onDisconnect(); - } - - ServerController serverController(m_settings); - ErrorCode errorCode = serverController.removeAllContainers(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex)); - if (errorCode) { - emit uiLogic()->showWarningMessage(tr("Error occurred while cleaning the server.") + "\n" + - tr("Error message: ") + errorString(errorCode) + "\n" + - tr("See logs for details.")); - } else { - set_labelWaitInfoVisible(true); - set_labelWaitInfoText(tr("Amnezia server successfully uninstalled")); - } - - m_settings->setContainers(uiLogic()->m_selectedServerIndex, {}); - m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, DockerContainer::None); - - set_pageEnabled(true); - set_pushButtonClearText(tr("Clear server from Amnezia software")); -} - -void AdvancedServerSettingsLogic::onPushButtonScanServerClicked() -{ - set_labelWaitInfoVisible(false); - set_pageEnabled(false); - - bool isServerCreated; - auto containersCount = m_settings->containers(uiLogic()->m_selectedServerIndex).size(); - ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated); - if (errorCode != ErrorCode::NoError) { - emit uiLogic()->showWarningMessage(tr("Error occurred while scanning the server.") + "\n" + - tr("Error message: ") + errorString(errorCode) + "\n" + - tr("See logs for details.")); - } - auto newContainersCount = m_settings->containers(uiLogic()->m_selectedServerIndex).size(); - if (containersCount != newContainersCount) { - emit uiLogic()->showWarningMessage(tr("All containers installed on the server are added to the GUI")); - } else { - emit uiLogic()->showWarningMessage(tr("No installed containers found on the server")); - } - - - onUpdatePage(); - set_pageEnabled(true); -} diff --git a/client/ui/pages_logic/AdvancedServerSettingsLogic.h b/client/ui/pages_logic/AdvancedServerSettingsLogic.h deleted file mode 100644 index 692968f1b..000000000 --- a/client/ui/pages_logic/AdvancedServerSettingsLogic.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef ADVANCEDSERVERSETTINGSLOGIC_H -#define ADVANCEDSERVERSETTINGSLOGIC_H - -#include "PageLogicBase.h" - -class UiLogic; - -class AdvancedServerSettingsLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, labelWaitInfoVisible) - AUTO_PROPERTY(QString, labelWaitInfoText) - - AUTO_PROPERTY(QString, pushButtonClearText) - AUTO_PROPERTY(bool, pushButtonClearVisible) - - AUTO_PROPERTY(QString, labelServerText) - AUTO_PROPERTY(QString, labelCurrentVpnProtocolText) - -public: - explicit AdvancedServerSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~AdvancedServerSettingsLogic() = default; - - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onPushButtonClearServerClicked(); - Q_INVOKABLE void onPushButtonScanServerClicked(); -}; - -#endif // ADVANCEDSERVERSETTINGSLOGIC_H diff --git a/client/ui/pages_logic/AppSettingsLogic.cpp b/client/ui/pages_logic/AppSettingsLogic.cpp deleted file mode 100644 index 044b97b80..000000000 --- a/client/ui/pages_logic/AppSettingsLogic.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "AppSettingsLogic.h" - -#include "logger.h" -#include "version.h" -#include "ui/qautostart.h" -#include "ui/uilogic.h" - -#include -#include -#include -#include - -#ifdef Q_OS_IOS -#include -#endif - -using namespace amnezia; -using namespace PageEnumNS; - -AppSettingsLogic::AppSettingsLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_checkBoxAutostartChecked{false}, - m_checkBoxAutoConnectChecked{false}, - m_checkBoxStartMinimizedChecked{false}, - m_checkBoxSaveLogsChecked{false} -{ - -} - -void AppSettingsLogic::onUpdatePage() -{ - set_checkBoxAutostartChecked(Autostart::isAutostart()); - 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")) - .arg(QString(APP_MAJOR_VERSION)) - .arg(__DATE__); - set_labelVersionText(ver); -} - -void AppSettingsLogic::onCheckBoxAutostartToggled(bool checked) -{ - if (!checked) { - set_checkBoxAutoConnectChecked(false); - } - Autostart::setAutostart(checked); -} - -void AppSettingsLogic::onCheckBoxAutoconnectToggled(bool checked) -{ - m_settings->setAutoConnect(checked); -} - -void AppSettingsLogic::onCheckBoxStartMinimizedToggled(bool checked) -{ - m_settings->setStartMinimized(checked); -} - -void AppSettingsLogic::onCheckBoxSaveLogsCheckedToggled(bool checked) -{ - m_settings->setSaveLogs(checked); -} - -void AppSettingsLogic::onPushButtonOpenLogsClicked() -{ - Logger::openLogsFolder(); -} - -void AppSettingsLogic::onPushButtonExportLogsClicked() -{ - uiLogic()->saveTextFile(tr("Save log"), "AmneziaVPN.log", ".log", Logger::getLogFile()); -} - -void AppSettingsLogic::onPushButtonClearLogsClicked() -{ - Logger::clearLogs(); - Logger::clearServiceLogs(); -} - -void AppSettingsLogic::onPushButtonBackupAppConfigClicked() -{ - uiLogic()->saveTextFile("Backup application config", "AmneziaVPN.backup", ".backup", m_settings->backupAppConfig()); -} - -void AppSettingsLogic::onPushButtonRestoreAppConfigClicked() -{ - QString fileName = UiLogic::getOpenFileName(Q_NULLPTR, tr("Open backup"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup"); - - if (fileName.isEmpty()) return; - - QFile file(fileName); - -#ifdef Q_OS_IOS - CFURLRef url = CFURLCreateWithFileSystemPath( - kCFAllocatorDefault, CFStringCreateWithCharacters(0, reinterpret_cast(fileName.unicode()), - fileName.length()), - kCFURLPOSIXPathStyle, 0); - - if (!CFURLStartAccessingSecurityScopedResource(url)) { - qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString(); - } -#endif - - file.open(QIODevice::ReadOnly); - QByteArray data = file.readAll(); - - bool ok = m_settings->restoreAppConfig(data); - if (ok) { - emit uiLogic()->goToPage(Page::Vpn); - emit uiLogic()->setStartPage(Page::Vpn); - } else { - emit uiLogic()->showWarningMessage(tr("Can't import config, file is corrupted.")); - } -} - diff --git a/client/ui/pages_logic/AppSettingsLogic.h b/client/ui/pages_logic/AppSettingsLogic.h deleted file mode 100644 index fc9f0da7e..000000000 --- a/client/ui/pages_logic/AppSettingsLogic.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef APP_SETTINGS_LOGIC_H -#define APP_SETTINGS_LOGIC_H - -#include "PageLogicBase.h" - -class UiLogic; - -class AppSettingsLogic : public PageLogicBase -{ - Q_OBJECT - AUTO_PROPERTY(bool, checkBoxAutostartChecked) - AUTO_PROPERTY(bool, checkBoxAutoConnectChecked) - AUTO_PROPERTY(bool, checkBoxStartMinimizedChecked) - AUTO_PROPERTY(bool, checkBoxSaveLogsChecked) - AUTO_PROPERTY(QString, labelVersionText) - -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onCheckBoxAutostartToggled(bool checked); - Q_INVOKABLE void onCheckBoxAutoconnectToggled(bool checked); - Q_INVOKABLE void onCheckBoxStartMinimizedToggled(bool checked); - Q_INVOKABLE void onCheckBoxSaveLogsCheckedToggled(bool checked); - Q_INVOKABLE void onPushButtonOpenLogsClicked(); - Q_INVOKABLE void onPushButtonExportLogsClicked(); - Q_INVOKABLE void onPushButtonClearLogsClicked(); - - Q_INVOKABLE void onPushButtonBackupAppConfigClicked(); - Q_INVOKABLE void onPushButtonRestoreAppConfigClicked(); - - -public: - explicit AppSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~AppSettingsLogic() = default; - -}; -#endif // APP_SETTINGS_LOGIC_H diff --git a/client/ui/pages_logic/ClientInfoLogic.cpp b/client/ui/pages_logic/ClientInfoLogic.cpp deleted file mode 100644 index dca0b9fdd..000000000 --- a/client/ui/pages_logic/ClientInfoLogic.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#include "ClientInfoLogic.h" - -#include - -#include "version.h" -#include "core/errorstrings.h" -#include "core/servercontroller.h" -#include "ui/models/clientManagementModel.h" -#include "ui/uilogic.h" - -namespace { - bool isErrorOccured(ErrorCode error) { - if (error != ErrorCode::NoError) { - QMessageBox::warning(nullptr, APPLICATION_NAME, - QObject::tr("An error occurred while saving the list of clients.") + "\n" + errorString(error)); - return true; - } - return false; - } -} - -ClientInfoLogic::ClientInfoLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent) -{ - -} - -void ClientInfoLogic::setCurrentClientId(int index) -{ - m_currentClientIndex = index; -} - -void ClientInfoLogic::onUpdatePage() -{ - set_pageContentVisible(false); - set_busyIndicatorIsRunning(true); - - const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex); - const DockerContainer container = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - const QString containerNameString = ContainerProps::containerHumanNames().value(container); - set_labelCurrentVpnProtocolText(tr("Service: ") + containerNameString); - - const QVector protocols = ContainerProps::protocolsForContainer(container); - if (!protocols.empty()) { - const Proto currentMainProtocol = protocols.front(); - - auto model = qobject_cast(uiLogic()->clientManagementModel()); - const QModelIndex modelIndex = model->index(m_currentClientIndex); - - set_lineEditNameAliasText(model->data(modelIndex, ClientManagementModel::ClientRoles::NameRole).toString()); - if (currentMainProtocol == Proto::OpenVpn) { - const QString certId = model->data(modelIndex, ClientManagementModel::ClientRoles::OpenVpnCertIdRole).toString(); - QString certData = model->data(modelIndex, ClientManagementModel::ClientRoles::OpenVpnCertDataRole).toString(); - - if (certData.isEmpty() && !certId.isEmpty()) { - QString stdOut; - auto cbReadStdOut = [&](const QString &data, libssh::Client &) { - stdOut += data + "\n"; - return ErrorCode::NoError; - }; - - const QString getOpenVpnCertData = QString("sudo docker exec -i $CONTAINER_NAME bash -c 'cat /opt/amnezia/openvpn/pki/issued/%1.crt'") - .arg(certId); - ServerController serverController(m_settings); - const QString script = serverController.replaceVars(getOpenVpnCertData, serverController.genVarsForScript(credentials, container)); - ErrorCode error = serverController.runScript(credentials, script, cbReadStdOut); - certData = stdOut; - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - emit uiLogic()->closePage(); - return; - } - } - set_labelOpenVpnCertId(certId); - set_textAreaOpenVpnCertData(certData); - } else if (currentMainProtocol == Proto::WireGuard) { - set_textAreaWireGuardKeyData(model->data(modelIndex, ClientManagementModel::ClientRoles::WireGuardPublicKey).toString()); - } - } - set_pageContentVisible(true); - set_busyIndicatorIsRunning(false); -} - -void ClientInfoLogic::onLineEditNameAliasEditingFinished() -{ - set_busyIndicatorIsRunning(true); - - auto model = qobject_cast(uiLogic()->clientManagementModel()); - const QModelIndex modelIndex = model->index(m_currentClientIndex); - model->setData(modelIndex, m_lineEditNameAliasText, ClientManagementModel::ClientRoles::NameRole); - - const DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex); - const QVector protocols = ContainerProps::protocolsForContainer(selectedContainer); - if (!protocols.empty()) { - const Proto currentMainProtocol = protocols.front(); - const QJsonObject clientsTable = model->getContent(currentMainProtocol); - ErrorCode error = setClientsList(credentials, - selectedContainer, - currentMainProtocol, - clientsTable); - isErrorOccured(error); - } - - set_busyIndicatorIsRunning(false); -} - -void ClientInfoLogic::onRevokeOpenVpnCertificateClicked() -{ - set_busyIndicatorIsRunning(true); - const DockerContainer container = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex); - - auto model = qobject_cast(uiLogic()->clientManagementModel()); - const QModelIndex modelIndex = model->index(m_currentClientIndex); - const QString certId = model->data(modelIndex, ClientManagementModel::ClientRoles::OpenVpnCertIdRole).toString(); - - const QString getOpenVpnCertData = QString("sudo docker exec -i $CONTAINER_NAME bash -c '" - "cd /opt/amnezia/openvpn ;\\" - "easyrsa revoke %1 ;\\" - "easyrsa gen-crl ;\\" - "cp pki/crl.pem .'").arg(certId); - ServerController serverController(m_settings); - const QString script = serverController.replaceVars(getOpenVpnCertData, - serverController.genVarsForScript(credentials, container)); - auto error = serverController.runScript(credentials, script); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - emit uiLogic()->goToPage(Page::ServerSettings); - return; - } - - model->removeRows(m_currentClientIndex); - const QJsonObject clientsTable = model->getContent(Proto::OpenVpn); - error = setClientsList(credentials, container, Proto::OpenVpn, clientsTable); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - return; - } - - const QJsonObject &containerConfig = m_settings->containerConfig(uiLogic()->m_selectedServerIndex, container); - error = serverController.startupContainerWorker(credentials, container, containerConfig); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - return; - } - - set_busyIndicatorIsRunning(false); -} - -void ClientInfoLogic::onRevokeWireGuardKeyClicked() -{ - set_busyIndicatorIsRunning(true); - ErrorCode error; - const DockerContainer container = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex); - - ServerController serverController(m_settings); - - const QString wireGuardConfigFile = "opt/amnezia/wireguard/wg0.conf"; - const QString wireguardConfigString = serverController.getTextFileFromContainer(container, credentials, wireGuardConfigFile, &error); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - return; - } - - auto model = qobject_cast(uiLogic()->clientManagementModel()); - const QModelIndex modelIndex = model->index(m_currentClientIndex); - const QString key = model->data(modelIndex, ClientManagementModel::ClientRoles::WireGuardPublicKey).toString(); - - auto configSections = wireguardConfigString.split("[", Qt::SkipEmptyParts); - for (auto §ion : configSections) { - if (section.contains(key)) { - configSections.removeOne(section); - } - } - QString newWireGuardConfig = configSections.join("["); - newWireGuardConfig.insert(0, "["); - error = serverController.uploadTextFileToContainer(container, credentials, newWireGuardConfig, - protocols::wireguard::serverConfigPath, - libssh::SftpOverwriteMode::SftpOverwriteExisting); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - return; - } - - model->removeRows(m_currentClientIndex); - const QJsonObject clientsTable = model->getContent(Proto::WireGuard); - error = setClientsList(credentials, container, Proto::WireGuard, clientsTable); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - return; - } - - const QString script = "sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick strip /opt/amnezia/wireguard/wg0.conf)'"; - error = serverController.runScript(credentials, - serverController.replaceVars(script, serverController.genVarsForScript(credentials, container))); - if (isErrorOccured(error)) { - set_busyIndicatorIsRunning(false); - return; - } - - set_busyIndicatorIsRunning(false); -} - -ErrorCode ClientInfoLogic::setClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, const QJsonObject &clietns) -{ - const QString mainProtocolString = ProtocolProps::protoToString(mainProtocol); - const QString clientsTableFile = QString("opt/amnezia/%1/clientsTable").arg(mainProtocolString); - ServerController serverController(m_settings); - ErrorCode error = serverController.uploadTextFileToContainer(container, credentials, QJsonDocument(clietns).toJson(), clientsTableFile); - return error; -} diff --git a/client/ui/pages_logic/ClientInfoLogic.h b/client/ui/pages_logic/ClientInfoLogic.h deleted file mode 100644 index 5ba19887d..000000000 --- a/client/ui/pages_logic/ClientInfoLogic.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CLIENTINFOLOGIC_H -#define CLIENTINFOLOGIC_H - -#include "PageLogicBase.h" - -#include "core/defs.h" -#include "containers/containers_defs.h" -#include "protocols/protocols_defs.h" - -class UiLogic; - -class ClientInfoLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, lineEditNameAliasText) - AUTO_PROPERTY(QString, labelOpenVpnCertId) - AUTO_PROPERTY(QString, textAreaOpenVpnCertData) - AUTO_PROPERTY(QString, labelCurrentVpnProtocolText) - AUTO_PROPERTY(QString, textAreaWireGuardKeyData) - AUTO_PROPERTY(bool, busyIndicatorIsRunning); - AUTO_PROPERTY(bool, pageContentVisible); - -public: - ClientInfoLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ClientInfoLogic() = default; - - void setCurrentClientId(int index); - -public slots: - void onUpdatePage() override; - void onLineEditNameAliasEditingFinished(); - void onRevokeOpenVpnCertificateClicked(); - void onRevokeWireGuardKeyClicked(); - -private: - ErrorCode setClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, const QJsonObject &clietns); - - int m_currentClientIndex; -}; - -#endif // CLIENTINFOLOGIC_H diff --git a/client/ui/pages_logic/ClientManagementLogic.cpp b/client/ui/pages_logic/ClientManagementLogic.cpp deleted file mode 100644 index 673ee9aba..000000000 --- a/client/ui/pages_logic/ClientManagementLogic.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "ClientManagementLogic.h" - -#include - -#include "version.h" -#include "core/errorstrings.h" -#include "core/servercontroller.h" -#include "ui/pages_logic/ClientInfoLogic.h" -#include "ui/models/clientManagementModel.h" -#include "ui/uilogic.h" - -ClientManagementLogic::ClientManagementLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent) -{ - -} - -void ClientManagementLogic::onUpdatePage() -{ - set_busyIndicatorIsRunning(true); - - qobject_cast(uiLogic()->clientManagementModel())->clearData(); - DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer); - set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName); - - QJsonObject clients; - - auto protocols = ContainerProps::protocolsForContainer(selectedContainer); - if (!protocols.empty()) { - m_currentMainProtocol = protocols.front(); - - const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex); - - ErrorCode error = getClientsList(credentials, selectedContainer, m_currentMainProtocol, clients); - if (error != ErrorCode::NoError) { - QMessageBox::warning(nullptr, APPLICATION_NAME, - tr("An error occurred while getting the list of clients.") + "\n" + errorString(error)); - set_busyIndicatorIsRunning(false); - return; - } - } - QVector clientsArray; - for (auto &clientId : clients.keys()) { - clientsArray.push_back(clients[clientId].toObject()); - } - qobject_cast(uiLogic()->clientManagementModel())->setContent(clientsArray); - - set_busyIndicatorIsRunning(false); -} - -void ClientManagementLogic::onClientItemClicked(int index) -{ - uiLogic()->pageLogic()->setCurrentClientId(index); - emit uiLogic()->goToClientInfoPage(m_currentMainProtocol); -} - -ErrorCode ClientManagementLogic::getClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, QJsonObject &clietns) -{ - ErrorCode error = ErrorCode::NoError; - QString stdOut; - auto cbReadStdOut = [&](const QString &data, libssh::Client &) { - stdOut += data + "\n"; - return ErrorCode::NoError; - }; - - const QString mainProtocolString = ProtocolProps::protoToString(mainProtocol); - - ServerController serverController(m_settings); - - const QString clientsTableFile = QString("/opt/amnezia/%1/clientsTable").arg(mainProtocolString); - const QByteArray clientsTableString = serverController.getTextFileFromContainer(container, credentials, clientsTableFile, &error); - if (error != ErrorCode::NoError) { - return error; - } - QJsonObject clientsTable = QJsonDocument::fromJson(clientsTableString).object(); - int count = 0; - - if (mainProtocol == Proto::OpenVpn) { - const QString getOpenVpnClientsList = "sudo docker exec -i $CONTAINER_NAME bash -c 'ls /opt/amnezia/openvpn/pki/issued'"; - QString script = serverController.replaceVars(getOpenVpnClientsList, serverController.genVarsForScript(credentials, container)); - error = serverController.runScript(credentials, script, cbReadStdOut); - if (error != ErrorCode::NoError) { - return error; - } - - if (!stdOut.isEmpty()) { - QStringList certsIds = stdOut.split("\n", Qt::SkipEmptyParts); - certsIds.removeAll("AmneziaReq.crt"); - - for (auto &openvpnCertId : certsIds) { - openvpnCertId.replace(".crt", ""); - if (!clientsTable.contains(openvpnCertId)) { - - QJsonObject client; - client["openvpnCertId"] = openvpnCertId; - client["clientName"] = QString("Client %1").arg(count); - client["openvpnCertData"] = ""; - clientsTable[openvpnCertId] = client; - count++; - } - } - } - } else if (mainProtocol == Proto::WireGuard) { - const QString wireGuardConfigFile = "opt/amnezia/wireguard/wg0.conf"; - const QString wireguardConfigString = serverController.getTextFileFromContainer(container, credentials, wireGuardConfigFile, &error); - if (error != ErrorCode::NoError) { - return error; - } - - auto configLines = wireguardConfigString.split("\n", Qt::SkipEmptyParts); - QStringList wireguardKeys; - for (const auto &line : configLines) { - auto configPair = line.split(" = ", Qt::SkipEmptyParts); - if (configPair.front() == "PublicKey") { - wireguardKeys.push_back(configPair.back()); - } - } - - for (auto &wireguardKey : wireguardKeys) { - if (!clientsTable.contains(wireguardKey)) { - QJsonObject client; - client["clientName"] = QString("Client %1").arg(count); - client["wireguardPublicKey"] = wireguardKey; - clientsTable[wireguardKey] = client; - count++; - } - } - } - - const QByteArray newClientsTableString = QJsonDocument(clientsTable).toJson(); - if (clientsTableString != newClientsTableString) { - error = serverController.uploadTextFileToContainer(container, credentials, newClientsTableString, clientsTableFile); - } - - if (error != ErrorCode::NoError) { - return error; - } - - clietns = clientsTable; - - return error; -} diff --git a/client/ui/pages_logic/ClientManagementLogic.h b/client/ui/pages_logic/ClientManagementLogic.h deleted file mode 100644 index 9c1817160..000000000 --- a/client/ui/pages_logic/ClientManagementLogic.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CLIENTMANAGMENTLOGIC_H -#define CLIENTMANAGMENTLOGIC_H - -#include "PageLogicBase.h" - -#include "core/defs.h" -#include "containers/containers_defs.h" -#include "protocols/protocols_defs.h" - -class UiLogic; - -class ClientManagementLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, labelCurrentVpnProtocolText) - AUTO_PROPERTY(bool, busyIndicatorIsRunning); - -public: - ClientManagementLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ClientManagementLogic() = default; - -public slots: - void onUpdatePage() override; - void onClientItemClicked(int index); - -private: - ErrorCode getClientsList(const ServerCredentials &credentials, DockerContainer container, Proto mainProtocol, QJsonObject &clietns); - - amnezia::Proto m_currentMainProtocol; -}; - -#endif // CLIENTMANAGMENTLOGIC_H diff --git a/client/ui/pages_logic/GeneralSettingsLogic.cpp b/client/ui/pages_logic/GeneralSettingsLogic.cpp deleted file mode 100644 index 141308f40..000000000 --- a/client/ui/pages_logic/GeneralSettingsLogic.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "GeneralSettingsLogic.h" -#include "ShareConnectionLogic.h" - -#include "../models/protocols_model.h" -#include "../uilogic.h" - -GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent) : PageLogicBase(logic, parent) -{ -} - -void GeneralSettingsLogic::onUpdatePage() -{ - uiLogic()->m_selectedServerIndex = m_settings->defaultServerIndex(); - set_existsAnyServer(m_settings->serversCount() > 0); - uiLogic()->m_selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex()); - - set_pushButtonGeneralSettingsShareConnectionEnable(m_settings->haveAuthData(m_settings->defaultServerIndex())); -} - -void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked() -{ - uiLogic()->m_selectedServerIndex = m_settings->defaultServerIndex(); - uiLogic()->m_selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex()); - - emit uiLogic()->goToPage(Page::ServerSettings); -} - -void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked() -{ - uiLogic()->m_selectedServerIndex = m_settings->defaultServerIndex(); - uiLogic()->m_selectedDockerContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - - // qobject_cast(uiLogic()->protocolsModel())->setSelectedServerIndex(uiLogic()->m_selectedServerIndex); qobject_cast(uiLogic()->protocolsModel())->setSelectedDockerContainer(uiLogic()->m_selectedDockerContainer); - - uiLogic()->pageLogic()->updateSharingPage(uiLogic()->m_selectedServerIndex, - uiLogic()->m_selectedDockerContainer); - emit uiLogic()->goToPage(Page::ShareConnection); -} diff --git a/client/ui/pages_logic/GeneralSettingsLogic.h b/client/ui/pages_logic/GeneralSettingsLogic.h deleted file mode 100644 index a0cff3337..000000000 --- a/client/ui/pages_logic/GeneralSettingsLogic.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GENERAL_SETTINGS_LOGIC_H -#define GENERAL_SETTINGS_LOGIC_H - -#include "PageLogicBase.h" - -class UiLogic; - -class GeneralSettingsLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, pushButtonGeneralSettingsShareConnectionEnable) - AUTO_PROPERTY(bool, existsAnyServer) - -public: - Q_INVOKABLE void onUpdatePage() override; - Q_INVOKABLE void onPushButtonGeneralSettingsServerSettingsClicked(); - Q_INVOKABLE void onPushButtonGeneralSettingsShareConnectionClicked(); - -public: - explicit GeneralSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~GeneralSettingsLogic() = default; - -}; -#endif // GENERAL_SETTINGS_LOGIC_H diff --git a/client/ui/pages_logic/NetworkSettingsLogic.cpp b/client/ui/pages_logic/NetworkSettingsLogic.cpp deleted file mode 100644 index 1315aa108..000000000 --- a/client/ui/pages_logic/NetworkSettingsLogic.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "NetworkSettingsLogic.h" - -#include "version.h" -#include "utilities.h" -#include "settings.h" - -NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_checkBoxUseAmneziaDnsChecked{false}, - m_ipAddressRegex{Utils::ipAddressRegExp()} -{ - -} - -void NetworkSettingsLogic::onUpdatePage() -{ - set_checkBoxUseAmneziaDnsChecked(m_settings->useAmneziaDns()); - - set_lineEditDns1Text(m_settings->primaryDns()); - set_lineEditDns2Text(m_settings->secondaryDns()); -} - -void NetworkSettingsLogic::onLineEditDns1EditFinished(const QString &text) -{ - if (ipAddressRegex().match(text).hasMatch()) { - m_settings->setPrimaryDns(text); - } -} - -void NetworkSettingsLogic::onLineEditDns2EditFinished(const QString &text) -{ - if (ipAddressRegex().match(text).hasMatch()) { - m_settings->setSecondaryDns(text); - } -} - -void NetworkSettingsLogic::onPushButtonResetDns1Clicked() -{ - m_settings->setPrimaryDns(m_settings->cloudFlareNs1); - onUpdatePage(); -} - -void NetworkSettingsLogic::onPushButtonResetDns2Clicked() -{ - m_settings->setSecondaryDns(m_settings->cloudFlareNs2); - onUpdatePage(); -} - -void NetworkSettingsLogic::onCheckBoxUseAmneziaDnsToggled(bool checked) -{ - m_settings->setUseAmneziaDns(checked); -} diff --git a/client/ui/pages_logic/NetworkSettingsLogic.h b/client/ui/pages_logic/NetworkSettingsLogic.h deleted file mode 100644 index 237706eb3..000000000 --- a/client/ui/pages_logic/NetworkSettingsLogic.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef NETWORK_SETTINGS_LOGIC_H -#define NETWORK_SETTINGS_LOGIC_H - -#include "PageLogicBase.h" - -#include - -class UiLogic; - -class NetworkSettingsLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, checkBoxUseAmneziaDnsChecked) - - AUTO_PROPERTY(QString, lineEditDns1Text) - AUTO_PROPERTY(QString, lineEditDns2Text) - READONLY_PROPERTY(QRegularExpression, ipAddressRegex) - -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onLineEditDns1EditFinished(const QString& text); - Q_INVOKABLE void onLineEditDns2EditFinished(const QString& text); - Q_INVOKABLE void onPushButtonResetDns1Clicked(); - Q_INVOKABLE void onPushButtonResetDns2Clicked(); - - Q_INVOKABLE void onCheckBoxUseAmneziaDnsToggled(bool checked); - -public: - explicit NetworkSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~NetworkSettingsLogic() = default; - -}; -#endif // NETWORK_SETTINGS_LOGIC_H diff --git a/client/ui/pages_logic/NewServerProtocolsLogic.cpp b/client/ui/pages_logic/NewServerProtocolsLogic.cpp deleted file mode 100644 index a1db75655..000000000 --- a/client/ui/pages_logic/NewServerProtocolsLogic.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "NewServerProtocolsLogic.h" -#include "../uilogic.h" - -NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_progressBarConnectionMinimum{0}, - m_progressBarConnectionMaximum{100} -{ -} - - -void NewServerProtocolsLogic::onUpdatePage() -{ - set_progressBarConnectionMinimum(0); - set_progressBarConnectionMaximum(300); -} - -void NewServerProtocolsLogic::onPushButtonConfigureClicked(DockerContainer c, int port, TransportProto tp) -{ - Proto mainProto = ContainerProps::defaultProtocol(c); - - QJsonObject config { - { config_key::container, ContainerProps::containerToString(c) }, - { ProtocolProps::protoToString(mainProto), QJsonObject { - { config_key::port, QString::number(port) }, - { config_key::transport_proto, ProtocolProps::transportProtoToString(tp, mainProto) }} - } - }; - - QPair container(c, config); - - uiLogic()->installServer(container); -} - diff --git a/client/ui/pages_logic/NewServerProtocolsLogic.h b/client/ui/pages_logic/NewServerProtocolsLogic.h deleted file mode 100644 index abf3d1029..000000000 --- a/client/ui/pages_logic/NewServerProtocolsLogic.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NEW_SERVER_PROTOCOLS_LOGIC_H -#define NEW_SERVER_PROTOCOLS_LOGIC_H - -#include "PageLogicBase.h" -#include "containers/containers_defs.h" - -class UiLogic; - -class NewServerProtocolsLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(double, progressBarConnectionMinimum) - AUTO_PROPERTY(double, progressBarConnectionMaximum) - -public: - Q_INVOKABLE void onUpdatePage() override; - Q_INVOKABLE void onPushButtonConfigureClicked(DockerContainer c, int port, TransportProto tp); - -public: - explicit NewServerProtocolsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~NewServerProtocolsLogic() = default; - -}; -#endif // NEW_SERVER_PROTOCOLS_LOGIC_H diff --git a/client/ui/pages_logic/PageLogicBase.cpp b/client/ui/pages_logic/PageLogicBase.cpp deleted file mode 100644 index 05c4e3a1b..000000000 --- a/client/ui/pages_logic/PageLogicBase.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "PageLogicBase.h" - -#include "ui/uilogic.h" -#include "settings.h" -#include "configurators/vpn_configurator.h" - -PageLogicBase::PageLogicBase(UiLogic *logic, QObject *parent): - QObject(parent), - m_pageEnabled{true}, - m_uiLogic(logic) -{ - m_settings = logic->m_settings; - m_configurator = logic->m_configurator; -} - - diff --git a/client/ui/pages_logic/PageLogicBase.h b/client/ui/pages_logic/PageLogicBase.h deleted file mode 100644 index 6616de9d9..000000000 --- a/client/ui/pages_logic/PageLogicBase.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef PAGE_LOGIC_BASE_H -#define PAGE_LOGIC_BASE_H - -#include "../pages.h" -#include "../property_helper.h" - -using namespace PageEnumNS; - -class UiLogic; -class Settings; -class VpnConfigurator; -class ServerController; - -class PageLogicBase : public QObject -{ - Q_OBJECT - AUTO_PROPERTY(bool, pageEnabled) - -public: - explicit PageLogicBase(UiLogic *uiLogic, QObject *parent = nullptr); - ~PageLogicBase() = default; - - Q_INVOKABLE virtual void onUpdatePage() {} - -protected: - UiLogic *m_uiLogic; - UiLogic *uiLogic() const { return m_uiLogic; } - - std::shared_ptr m_settings; - std::shared_ptr m_configurator; - -signals: - void updatePage(); -}; -#endif // PAGE_LOGIC_BASE_H diff --git a/client/ui/pages_logic/QrDecoderLogic.cpp b/client/ui/pages_logic/QrDecoderLogic.cpp deleted file mode 100644 index e1845c77b..000000000 --- a/client/ui/pages_logic/QrDecoderLogic.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "QrDecoderLogic.h" - -#include "ui/uilogic.h" -#include "ui/pages_logic/StartPageLogic.h" - -#ifdef Q_OS_ANDROID -#include -#include -#include "../../platforms/android/androidutils.h" -#endif - -using namespace amnezia; -using namespace PageEnumNS; - -namespace { - QrDecoderLogic* mInstance = nullptr; - constexpr auto CLASSNAME = "org.amnezia.vpn.qt.CameraActivity"; -} - -QrDecoderLogic::QrDecoderLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent) -{ - mInstance = this; - - #if (defined(Q_OS_ANDROID)) - AndroidUtils::runOnAndroidThreadAsync([]() { - JNINativeMethod methods[]{ - {"passDataToDecoder", "(Ljava/lang/String;)V", reinterpret_cast(onNewDataChunk)}, - }; - - QJniObject javaClass(CLASSNAME); - QJniEnvironment env; - jclass objectClass = env->GetObjectClass(javaClass.object()); - env->RegisterNatives(objectClass, methods, sizeof(methods) / sizeof(methods[0])); - env->DeleteLocalRef(objectClass); - }); - #endif -} - -void QrDecoderLogic::stopDecodingQr() -{ - #if (defined(Q_OS_ANDROID)) - QJniObject::callStaticMethod(CLASSNAME, "stopQrCodeReader", "()V"); - #endif - - emit stopDecode(); -} - -#ifdef Q_OS_ANDROID -void QrDecoderLogic::onNewDataChunk(JNIEnv *env, jobject thiz, jstring data) -{ - Q_UNUSED(thiz); - const char* buffer = env->GetStringUTFChars(data, nullptr); - if (!buffer) { - return; - } - - QString parcelBody(buffer); - env->ReleaseStringUTFChars(data, buffer); - - if (mInstance != nullptr) { - if (!mInstance->m_detectingEnabled) { - mInstance->onUpdatePage(); - } - mInstance->onDetectedQrCode(parcelBody); - } -} -#endif - -void QrDecoderLogic::onUpdatePage() -{ - m_chunks.clear(); - set_detectingEnabled(true); - set_totalChunksCount(0); - set_receivedChunksCount(0); - emit startDecode(); -} - -void QrDecoderLogic::onDetectedQrCode(const QString &code) -{ - //qDebug() << code; - if (!detectingEnabled()) return; - - // check if chunk received - QByteArray ba = QByteArray::fromBase64(code.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - QDataStream s(&ba, QIODevice::ReadOnly); - qint16 magic; s >> magic; - - if (magic == amnezia::qrMagicCode) { - quint8 chunksCount; s >> chunksCount; - if (totalChunksCount() != chunksCount) { - m_chunks.clear(); - } - - set_totalChunksCount(chunksCount); - - quint8 chunkId; s >> chunkId; - s >> m_chunks[chunkId]; - set_receivedChunksCount(m_chunks.size()); - - if (m_chunks.size() == totalChunksCount()) { - QByteArray data; - - for (int i = 0; i < totalChunksCount(); ++i) { - data.append(m_chunks.value(i)); - } - - bool ok = uiLogic()->pageLogic()->importConnectionFromQr(data); - if (ok) { - set_detectingEnabled(false); - stopDecodingQr(); - } else { - m_chunks.clear(); - set_totalChunksCount(0); - set_receivedChunksCount(0); - } - } - } else { - bool ok = uiLogic()->pageLogic()->importConnectionFromQr(ba); - if (ok) { - set_detectingEnabled(false); - stopDecodingQr(); - } - } -} diff --git a/client/ui/pages_logic/QrDecoderLogic.h b/client/ui/pages_logic/QrDecoderLogic.h deleted file mode 100644 index 2b24bf27e..000000000 --- a/client/ui/pages_logic/QrDecoderLogic.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef QR_DECODER_LOGIC_H -#define QR_DECODER_LOGIC_H - -#include "PageLogicBase.h" - -#ifdef Q_OS_ANDROID -#include "jni.h" -#endif - -class UiLogic; - -class QrDecoderLogic : public PageLogicBase -{ - Q_OBJECT - AUTO_PROPERTY(bool, detectingEnabled) - AUTO_PROPERTY(int, totalChunksCount) - AUTO_PROPERTY(int, receivedChunksCount) - -public: - Q_INVOKABLE void onUpdatePage() override; - Q_INVOKABLE void onDetectedQrCode(const QString &code); - -#ifdef Q_OS_ANDROID - static void onNewDataChunk(JNIEnv *env, jobject thiz, jstring data); -#endif - -public: - explicit QrDecoderLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~QrDecoderLogic() = default; - -private: - void stopDecodingQr(); - -signals: - void startDecode(); - void stopDecode(); - -private: - QMap m_chunks; -}; -#endif // QR_DECODER_LOGIC_H diff --git a/client/ui/pages_logic/ServerConfiguringProgressLogic.cpp b/client/ui/pages_logic/ServerConfiguringProgressLogic.cpp deleted file mode 100644 index 2b42fac97..000000000 --- a/client/ui/pages_logic/ServerConfiguringProgressLogic.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "ServerConfiguringProgressLogic.h" -#include "version.h" -#include "core/errorstrings.h" -#include -#include - -#include "core/servercontroller.h" - -ServerConfiguringProgressLogic::ServerConfiguringProgressLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_progressBarValue{0}, - m_labelWaitInfoVisible{true}, - m_labelWaitInfoText{tr("Please wait, configuring process may take up to 5 minutes")}, - m_progressBarVisible{true}, - m_progressBarMaximum{100}, - m_progressBarTextVisible{true}, - m_progressBarText{tr("Configuring...")}, - m_labelServerBusyVisible{false}, - m_labelServerBusyText{""} -{ - -} - -void ServerConfiguringProgressLogic::onUpdatePage() -{ - set_progressBarValue(0); -} - - -ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function &action) -{ - PageFunc page; - page.setEnabledFunc = [this] (bool enabled) -> void { - set_pageEnabled(enabled); - }; - ButtonFunc noButton; - LabelFunc noWaitInfo; - ProgressFunc progress; - progress.setVisibleFunc = [this] (bool visible) -> void { - set_progressBarVisible(visible); - }; - - progress.setValueFunc = [this] (int value) -> void { - set_progressBarValue(value); - }; - progress.getValueFunc = [this] (void) -> int { - return progressBarValue(); - }; - progress.getMaximumFunc = [this] (void) -> int { - return progressBarMaximum(); - }; - - LabelFunc busyInfo; - busyInfo.setTextFunc = [this] (const QString& text) -> void { - set_labelServerBusyText(text); - }; - busyInfo.setVisibleFunc = [this] (bool visible) -> void { - set_labelServerBusyVisible(visible); - }; - - ButtonFunc cancelButton; - cancelButton.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonCancelVisible(visible); - }; - - return doInstallAction(action, page, progress, noButton, noWaitInfo, busyInfo, cancelButton); -} - -ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function &action, - const PageFunc &page, - const ProgressFunc &progress, - const ButtonFunc &saveButton, - const LabelFunc &waitInfo, - const LabelFunc &serverBusyInfo, - const ButtonFunc &cancelButton) -{ - progress.setVisibleFunc(true); - if (page.setEnabledFunc) { - page.setEnabledFunc(false); - } - if (saveButton.setVisibleFunc) { - saveButton.setVisibleFunc(false); - } - if (waitInfo.setVisibleFunc) { - waitInfo.setVisibleFunc(true); - } - if (waitInfo.setTextFunc) { - waitInfo.setTextFunc(tr("Please wait, configuring process may take up to 5 minutes")); - } - - QTimer timer; - connect(&timer, &QTimer::timeout, [progress](){ - progress.setValueFunc(progress.getValueFunc() + 1); - }); - - progress.setValueFunc(0); - timer.start(1000); - - ServerController serverController(m_settings); - - QMetaObject::Connection cancelDoInstallActionConnection; - if (cancelButton.setVisibleFunc) { - cancelDoInstallActionConnection = connect(this, &ServerConfiguringProgressLogic::cancelDoInstallAction, - &serverController, &ServerController::setCancelInstallation); - } - - - QMetaObject::Connection serverBusyConnection; - if (serverBusyInfo.setVisibleFunc && serverBusyInfo.setTextFunc) { - auto onServerIsBusy = [&serverBusyInfo, &timer, &cancelButton](const bool isBusy) { - isBusy ? timer.stop() : timer.start(1000); - serverBusyInfo.setVisibleFunc(isBusy); - serverBusyInfo.setTextFunc(isBusy ? "Amnesia has detected that your server is currently " - "busy installing other software. Amnesia installation " - "will pause until the server finishes installing other software" - : ""); - if (cancelButton.setVisibleFunc) { - cancelButton.setVisibleFunc(isBusy ? true : false); - } - }; - - serverBusyConnection = connect(&serverController, &ServerController::serverIsBusy, this, onServerIsBusy); - } - - ErrorCode e = action(); - qDebug() << "doInstallAction finished with code" << e; - if (cancelButton.setVisibleFunc) { - disconnect(cancelDoInstallActionConnection); - } - - if (serverBusyInfo.setVisibleFunc && serverBusyInfo.setTextFunc) { - disconnect(serverBusyConnection); - } - - if (e) { - if (page.setEnabledFunc) { - page.setEnabledFunc(true); - } - if (saveButton.setVisibleFunc) { - saveButton.setVisibleFunc(true); - } - if (waitInfo.setVisibleFunc) { - waitInfo.setVisibleFunc(false); - } - - progress.setVisibleFunc(false); - return e; - } - - // just ui progressbar tweak - timer.stop(); - - int remainingVal = progress.getMaximumFunc() - progress.getValueFunc(); - - if (remainingVal > 0) { - QTimer timer1; - QEventLoop loop1; - - connect(&timer1, &QTimer::timeout, [&](){ - progress.setValueFunc(progress.getValueFunc() + 1); - if (progress.getValueFunc() >= progress.getMaximumFunc()) { - loop1.quit(); - } - }); - - timer1.start(5); - loop1.exec(); - } - - - progress.setVisibleFunc(false); - if (saveButton.setVisibleFunc) { - saveButton.setVisibleFunc(true); - } - if (page.setEnabledFunc) { - page.setEnabledFunc(true); - } - if (waitInfo.setTextFunc) { - waitInfo.setTextFunc(tr("Operation finished")); - } - return ErrorCode::NoError; -} - -void ServerConfiguringProgressLogic::onPushButtonCancelClicked() -{ - emit cancelDoInstallAction(true); -} diff --git a/client/ui/pages_logic/ServerConfiguringProgressLogic.h b/client/ui/pages_logic/ServerConfiguringProgressLogic.h deleted file mode 100644 index 9f10bc877..000000000 --- a/client/ui/pages_logic/ServerConfiguringProgressLogic.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef SERVER_CONFIGURING_PROGRESS_LOGIC_H -#define SERVER_CONFIGURING_PROGRESS_LOGIC_H - -#include -#include "PageLogicBase.h" -#include "core/defs.h" - -using namespace amnezia; - -class UiLogic; - -class ServerConfiguringProgressLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(double, progressBarValue) - AUTO_PROPERTY(bool, labelWaitInfoVisible) - AUTO_PROPERTY(QString, labelWaitInfoText) - AUTO_PROPERTY(bool, progressBarVisible) - AUTO_PROPERTY(int, progressBarMaximum) - AUTO_PROPERTY(bool, progressBarTextVisible) - AUTO_PROPERTY(QString, progressBarText) - AUTO_PROPERTY(bool, labelServerBusyVisible) - AUTO_PROPERTY(QString, labelServerBusyText) - AUTO_PROPERTY(bool, pushButtonCancelVisible) - -public: - Q_INVOKABLE void onPushButtonCancelClicked(); - -private: - struct ProgressFunc { - std::function setVisibleFunc; - std::function setValueFunc; - std::function getValueFunc; - std::function getMaximumFunc; - std::function setTextVisibleFunc; - std::function setTextFunc; - }; - struct PageFunc { - std::function setEnabledFunc; - }; - struct ButtonFunc { - std::function setVisibleFunc; - }; - struct LabelFunc { - std::function setVisibleFunc; - std::function setTextFunc; - }; - -public: - explicit ServerConfiguringProgressLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ServerConfiguringProgressLogic() = default; - - friend class OpenVpnLogic; - friend class ShadowSocksLogic; - friend class CloakLogic; - friend class UiLogic; - - void onUpdatePage() override; - ErrorCode doInstallAction(const std::function &action); - ErrorCode doInstallAction(const std::function &action, - const PageFunc &page, - const ProgressFunc &progress, - const ButtonFunc &saveButton, - const LabelFunc &waitInfo, - const LabelFunc &serverBusyInfo, - const ButtonFunc &cancelButton); - -signals: - void cancelDoInstallAction(const bool cancel); - -}; -#endif // SERVER_CONFIGURING_PROGRESS_LOGIC_H diff --git a/client/ui/pages_logic/ServerContainersLogic.cpp b/client/ui/pages_logic/ServerContainersLogic.cpp deleted file mode 100644 index 89eeb6c80..000000000 --- a/client/ui/pages_logic/ServerContainersLogic.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "ServerContainersLogic.h" -#include "ServerConfiguringProgressLogic.h" -#include "ShareConnectionLogic.h" - -#include - -#include "protocols/PageProtocolLogicBase.h" - -#include "core/servercontroller.h" -#include - -#include "../pages_logic/VpnLogic.h" -#include "../uilogic.h" -#include "core/errorstrings.h" -#include "vpnconnection.h" - -ServerContainersLogic::ServerContainersLogic(UiLogic *logic, QObject *parent) : PageLogicBase(logic, parent) -{ -} - -void ServerContainersLogic::onUpdatePage() -{ - // ContainersModel *c_model = qobject_cast(uiLogic()->containersModel()); - // c_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex); - - ProtocolsModel *p_model = qobject_cast(uiLogic()->protocolsModel()); - // p_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex); - - set_isManagedServer(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex)); - uiLogic()->m_installCredentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex); - emit updatePage(); -} - -void ServerContainersLogic::onPushButtonProtoSettingsClicked(DockerContainer c, Proto p) -{ - qDebug() << "ServerContainersLogic::onPushButtonProtoSettingsClicked" << c << p; - uiLogic()->m_selectedDockerContainer = c; - uiLogic()->protocolLogic(p)->updateProtocolPage( - m_settings->protocolConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, p), - uiLogic()->m_selectedDockerContainer, m_settings->haveAuthData(uiLogic()->m_selectedServerIndex)); - - emit uiLogic()->goToProtocolPage(p); -} - -void ServerContainersLogic::onPushButtonDefaultClicked(DockerContainer c) -{ - if (m_settings->defaultContainer(uiLogic()->m_selectedServerIndex) == c) - return; - - m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, c); - uiLogic()->onUpdateAllPages(); - - if (uiLogic()->m_selectedServerIndex != m_settings->defaultServerIndex()) - return; - if (!uiLogic()->m_vpnConnection) - return; - if (!uiLogic()->m_vpnConnection->isConnected()) - return; - - uiLogic()->pageLogic()->onDisconnect(); - uiLogic()->pageLogic()->onConnect(); -} - -void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c) -{ - uiLogic()->pageLogic()->updateSharingPage(uiLogic()->m_selectedServerIndex, c); - emit uiLogic()->goToPage(Page::ShareConnection); -} - -void ServerContainersLogic::onPushButtonRemoveClicked(DockerContainer container) -{ - // buttonSetEnabledFunc(false); - ServerController serverController(m_settings); - ErrorCode e = - serverController.removeContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), container); - m_settings->removeContainerConfig(uiLogic()->m_selectedServerIndex, container); - // buttonSetEnabledFunc(true); - - if (m_settings->defaultContainer(uiLogic()->m_selectedServerIndex) == container) { - const auto &c = m_settings->containers(uiLogic()->m_selectedServerIndex); - if (c.isEmpty()) - m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, DockerContainer::None); - else - m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, c.keys().first()); - } - uiLogic()->onUpdateAllPages(); -} - -void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp) -{ - ServerController serverController(m_settings); - QJsonObject config; // = serverController.createContainerInitialConfig(c, port, tp); - - emit uiLogic()->goToPage(Page::ServerConfiguringProgress); - qApp->processEvents(); - - bool isServerCreated = false; - ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated); - - if (errorCode == ErrorCode::NoError) { - if (!uiLogic()->isContainerAlreadyAddedToGui(c)) { - auto installAction = [this, c, &config]() { - ServerController serverController(m_settings); - return serverController.setupContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), - c, config); - }; - errorCode = uiLogic()->pageLogic()->doInstallAction(installAction); - - if (errorCode == ErrorCode::NoError) { - m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, c, config); - if (ContainerProps::containerService(c) == ServiceType::Vpn) { - m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, c); - } - } - } else { - emit uiLogic()->showWarningMessage( - "Attention! The container you are trying to install is already installed on the server. " - "All installed containers have been added to the application "); - } - - uiLogic()->onUpdateAllPages(); - } - if (errorCode != ErrorCode::NoError) { - emit uiLogic()->showWarningMessage(tr("Error occurred while configuring server.") + "\n" + tr("Error message: ") - + errorString(errorCode) + "\n" + tr("See logs for details.")); - } - emit uiLogic()->closePage(); -} diff --git a/client/ui/pages_logic/ServerContainersLogic.h b/client/ui/pages_logic/ServerContainersLogic.h deleted file mode 100644 index d0081516c..000000000 --- a/client/ui/pages_logic/ServerContainersLogic.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SERVER_CONTAINERS_LOGIC_H -#define SERVER_CONTAINERS_LOGIC_H - -#include "PageLogicBase.h" -#include "containers/containers_defs.h" - -class UiLogic; - -class ServerContainersLogic : public PageLogicBase -{ - Q_OBJECT - -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onPushButtonProtoSettingsClicked(DockerContainer c, Proto p); - Q_INVOKABLE void onPushButtonDefaultClicked(DockerContainer c); - Q_INVOKABLE void onPushButtonShareClicked(DockerContainer c); - Q_INVOKABLE void onPushButtonRemoveClicked(DockerContainer c); - Q_INVOKABLE void onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp); - - AUTO_PROPERTY(bool, isManagedServer) - -public: - explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ServerContainersLogic() = default; - -}; -#endif // SERVER_CONTAINERS_LOGIC_H diff --git a/client/ui/pages_logic/ServerListLogic.cpp b/client/ui/pages_logic/ServerListLogic.cpp deleted file mode 100644 index 16775bc0d..000000000 --- a/client/ui/pages_logic/ServerListLogic.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "ServerListLogic.h" - -#include "../models/servers_model.h" -#include "../uilogic.h" -#include "vpnconnection.h" - -ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent) - : PageLogicBase(logic, parent), m_serverListModel { new ServersModel(m_settings, this) } -{ -} - -void ServerListLogic::onServerListPushbuttonDefaultClicked(int index) -{ - m_settings->setDefaultServer(index); - uiLogic()->onUpdateAllPages(); - emit currServerIdxChanged(); -} - -void ServerListLogic::onServerListPushbuttonSettingsClicked(int index) -{ - uiLogic()->m_selectedServerIndex = index; - uiLogic()->goToPage(Page::ServerSettings); -} - -int ServerListLogic::currServerIdx() const -{ - return m_settings->defaultServerIndex(); -} - -void ServerListLogic::onUpdatePage() -{ - // const QJsonArray &servers = m_settings->serversArray(); - // int defaultServer = m_settings->defaultServerIndex(); - // QVector serverListContent; - // for(int i = 0; i < servers.size(); i++) { - // ServerModelContent c; - // auto server = servers.at(i).toObject(); - // c.desc = server.value(config_key::description).toString(); - // c.address = server.value(config_key::hostName).toString(); - // if (c.desc.isEmpty()) { - // c.desc = c.address; - // } - // c.isDefault = (i == defaultServer); - // serverListContent.push_back(c); - // } - // qobject_cast(m_serverListModel)->setContent(serverListContent); -} diff --git a/client/ui/pages_logic/ServerListLogic.h b/client/ui/pages_logic/ServerListLogic.h deleted file mode 100644 index b4f475471..000000000 --- a/client/ui/pages_logic/ServerListLogic.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef SERVER_LIST_LOGIC_H -#define SERVER_LIST_LOGIC_H - -#include "PageLogicBase.h" - -class UiLogic; - -class ServerListLogic : public PageLogicBase -{ - Q_OBJECT - - READONLY_PROPERTY(QObject *, serverListModel) - Q_PROPERTY(int currServerIdx READ currServerIdx NOTIFY currServerIdxChanged) - -public: - int currServerIdx() const; - - Q_INVOKABLE void onUpdatePage() override; - Q_INVOKABLE void onServerListPushbuttonDefaultClicked(int index); - Q_INVOKABLE void onServerListPushbuttonSettingsClicked(int index); - -public: - explicit ServerListLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ServerListLogic() = default; - -signals: - void currServerIdxChanged(); - -}; -#endif // SERVER_LIST_LOGIC_H diff --git a/client/ui/pages_logic/ServerSettingsLogic.cpp b/client/ui/pages_logic/ServerSettingsLogic.cpp deleted file mode 100644 index 4c68b5498..000000000 --- a/client/ui/pages_logic/ServerSettingsLogic.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "ServerSettingsLogic.h" -#include "vpnconnection.h" - -#include "../uilogic.h" -#include "ShareConnectionLogic.h" -#include "VpnLogic.h" - -#include "core/errorstrings.h" -#include -#include - -#if defined(Q_OS_ANDROID) - #include "../../platforms/android/androidutils.h" -#endif - -ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent) - : PageLogicBase(logic, parent), - m_labelWaitInfoVisible { true }, - m_pushButtonClearClientCacheVisible { true }, - m_pushButtonShareFullVisible { true }, - m_pushButtonClearClientCacheText { tr("Clear client cached profile") } -{ -} - -void ServerSettingsLogic::onUpdatePage() -{ - set_labelWaitInfoVisible(false); - set_labelWaitInfoText(""); - set_pushButtonClearClientCacheVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex)); - set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex)); - const QJsonObject &server = m_settings->server(uiLogic()->m_selectedServerIndex); - const QString &port = server.value(config_key::port).toString(); - - const QString &userName = server.value(config_key::userName).toString(); - const QString &hostName = server.value(config_key::hostName).toString(); - QString name = QString("%1%2%3%4%5") - .arg(userName) - .arg(userName.isEmpty() ? "" : "@") - .arg(hostName) - .arg(port.isEmpty() ? "" : ":") - .arg(port); - - set_labelServerText(name); - set_lineEditDescriptionText(server.value(config_key::description).toString()); - - DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer); - set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName); -} - -void ServerSettingsLogic::onPushButtonForgetServer() -{ - if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex - && uiLogic()->m_vpnConnection->isConnected()) { - uiLogic()->pageLogic()->onDisconnect(); - } - m_settings->removeServer(uiLogic()->m_selectedServerIndex); - - if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex) { - m_settings->setDefaultServer(0); - } else if (m_settings->defaultServerIndex() > uiLogic()->m_selectedServerIndex) { - m_settings->setDefaultServer(m_settings->defaultServerIndex() - 1); - } - - if (m_settings->serversCount() == 0) { - m_settings->setDefaultServer(-1); - } - - uiLogic()->m_selectedServerIndex = -1; - uiLogic()->onUpdateAllPages(); - - if (m_settings->serversCount() == 0) { - uiLogic()->setStartPage(Page::Start); - } else { - uiLogic()->closePage(); - } -} - -void ServerSettingsLogic::onPushButtonClearClientCacheClicked() -{ - set_pushButtonClearClientCacheText(tr("Cache cleared")); - - const auto &containers = m_settings->containers(uiLogic()->m_selectedServerIndex); - for (DockerContainer container : containers.keys()) { - m_settings->clearLastConnectionConfig(uiLogic()->m_selectedServerIndex, container); - } - - QTimer::singleShot(3000, this, [this]() { set_pushButtonClearClientCacheText(tr("Clear client cached profile")); }); -} - -void ServerSettingsLogic::onLineEditDescriptionEditingFinished() -{ - const QString &newText = lineEditDescriptionText(); - QJsonObject server = m_settings->server(uiLogic()->m_selectedServerIndex); - server.insert(config_key::description, newText); - m_settings->editServer(uiLogic()->m_selectedServerIndex, server); - uiLogic()->onUpdateAllPages(); -} - -bool ServerSettingsLogic::isCurrentServerHasCredentials() -{ - return m_settings->haveAuthData(uiLogic()->m_selectedServerIndex); -} - -#if defined(Q_OS_ANDROID) -/* Auth result handler for Android */ -void authResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QJniObject &data) -{ - qDebug() << "receiverRequestCode" << receiverRequestCode << "resultCode" << resultCode; - - if (resultCode == -1) { // ResultOK - uiLogic()->pageLogic()->updateSharingPage(m_serverIndex, DockerContainer::None); - emit uiLogic()->goToShareProtocolPage(Proto::Any); - } -} -#endif - -void ServerSettingsLogic::onPushButtonShareFullClicked() -{ -#if defined(Q_OS_ANDROID) - /* We use builtin keyguard for ssh key export protection on Android */ - QJniObject activity = AndroidUtils::getActivity(); - auto appContext = activity.callObjectMethod("getApplicationContext", "()Landroid/content/Context;"); - if (appContext.isValid()) { - QAndroidActivityResultReceiver *receiver = new authResultReceiver(uiLogic(), uiLogic()->m_selectedServerIndex); - auto intent = QJniObject::callStaticObjectMethod("org/amnezia/vpn/AuthHelper", "getAuthIntent", - "(Landroid/content/Context;)Landroid/content/Intent;", - appContext.object()); - if (intent.isValid()) { - if (intent.object() != nullptr) { - QtAndroidPrivate::startActivity(intent.object(), 1, receiver); - } - } else { - uiLogic()->pageLogic()->updateSharingPage(uiLogic()->m_selectedServerIndex, - DockerContainer::None); - emit uiLogic()->goToShareProtocolPage(Proto::Any); - } - } -#else - uiLogic()->pageLogic()->updateSharingPage(uiLogic()->m_selectedServerIndex, - DockerContainer::None); - emit uiLogic()->goToShareProtocolPage(Proto::Any); -#endif -} diff --git a/client/ui/pages_logic/ServerSettingsLogic.h b/client/ui/pages_logic/ServerSettingsLogic.h deleted file mode 100644 index 3ce26164b..000000000 --- a/client/ui/pages_logic/ServerSettingsLogic.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef SERVER_SETTINGS_LOGIC_H -#define SERVER_SETTINGS_LOGIC_H - -#include "PageLogicBase.h" - -#if defined(Q_OS_ANDROID) -#include -#include -#endif - -class UiLogic; - -class ServerSettingsLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, labelWaitInfoVisible) - AUTO_PROPERTY(QString, labelWaitInfoText) - AUTO_PROPERTY(QString, pushButtonClearClientCacheText) - AUTO_PROPERTY(bool, pushButtonClearClientCacheVisible) - AUTO_PROPERTY(bool, pushButtonShareFullVisible) - AUTO_PROPERTY(QString, labelServerText) - AUTO_PROPERTY(QString, lineEditDescriptionText) - AUTO_PROPERTY(QString, labelCurrentVpnProtocolText) - -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onPushButtonForgetServer(); - Q_INVOKABLE void onPushButtonShareFullClicked(); - Q_INVOKABLE void onPushButtonClearClientCacheClicked(); - Q_INVOKABLE void onLineEditDescriptionEditingFinished(); - - Q_INVOKABLE bool isCurrentServerHasCredentials(); - -public: - explicit ServerSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ServerSettingsLogic() = default; - -}; - -#if defined(Q_OS_ANDROID) -/* Auth result handler for Android */ -class authResultReceiver final : public PageLogicBase, public QAndroidActivityResultReceiver -{ -Q_OBJECT - -public: - authResultReceiver(UiLogic *uiLogic, int serverIndex , QObject *parent = nullptr) : PageLogicBase(uiLogic, parent) { - m_serverIndex = serverIndex; - } - ~authResultReceiver() {} - -public: - void handleActivityResult(int receiverRequestCode, int resultCode, const QJniObject &data) override; - -private: - int m_serverIndex; -}; -#endif - -#endif // SERVER_SETTINGS_LOGIC_H diff --git a/client/ui/pages_logic/ShareConnectionLogic.cpp b/client/ui/pages_logic/ShareConnectionLogic.cpp deleted file mode 100644 index 911c872c2..000000000 --- a/client/ui/pages_logic/ShareConnectionLogic.cpp +++ /dev/null @@ -1,293 +0,0 @@ -#include -#include -#include - -#include "qrcodegen.hpp" - -#include "ShareConnectionLogic.h" - -#include "configurators/cloak_configurator.h" -#include "configurators/vpn_configurator.h" -#include "configurators/openvpn_configurator.h" -#include "configurators/shadowsocks_configurator.h" -#include "configurators/wireguard_configurator.h" -#include "configurators/ikev2_configurator.h" -#include "configurators/ssh_configurator.h" - -#include "version.h" -#include "core/defs.h" -#include "core/errorstrings.h" -#include "core/servercontroller.h" -#include - -#include "../uilogic.h" - -#ifdef __linux__ - #include -#endif - -using namespace qrcodegen; - -ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_textEditShareOpenVpnCodeText{}, - m_lineEditShareShadowSocksStringText{}, - m_shareShadowSocksQrCodeText{}, - m_textEditShareCloakText{}, - m_textEditShareAmneziaCodeText{} -{ -} - -void ShareConnectionLogic::onUpdatePage() -{ - set_textEditShareAmneziaCodeText(tr("")); - set_shareAmneziaQrCodeTextSeries({}); - set_shareAmneziaQrCodeTextSeriesLength(0); - - set_textEditShareOpenVpnCodeText(""); - - set_shareShadowSocksQrCodeText(""); - set_textEditShareShadowSocksText(""); - set_lineEditShareShadowSocksStringText(""); - - set_textEditShareCloakText(""); - - set_textEditShareWireGuardCodeText(""); - set_shareWireGuardQrCodeText(""); - - set_textEditShareIkev2CertText(""); - set_textEditShareIkev2MobileConfigText(""); - set_textEditShareIkev2StrongSwanConfigText(""); -} - -void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked() -{ - set_textEditShareAmneziaCodeText(""); - set_shareAmneziaQrCodeTextSeries({}); - set_shareAmneziaQrCodeTextSeriesLength(0); - - QJsonObject serverConfig; - int serverIndex = uiLogic()->m_selectedServerIndex; - DockerContainer container = uiLogic()->m_selectedDockerContainer; - - // Full access - if (shareFullAccess()) { - serverConfig = m_settings->server(serverIndex); - } - // Container share - else { - 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); - - QString cfg = m_configurator->genVpnProtocolConfig(credentials, container, containerConfig, p, &e); - if (e) { - cfg = "Error generating config"; - break; - } - protoConfig.insert(config_key::last_config, cfg); - containerConfig.insert(ProtocolProps::protoToString(p), protoConfig); - } - - QByteArray ba; - if (!e) { - serverConfig = m_settings->server(serverIndex); - serverConfig.remove(config_key::userName); - serverConfig.remove(config_key::password); - serverConfig.remove(config_key::port); - serverConfig.insert(config_key::containers, QJsonArray {containerConfig}); - serverConfig.insert(config_key::defaultContainer, ContainerProps::containerToString(container)); - - auto dns = m_configurator->getDnsForConfig(serverIndex); - serverConfig.insert(config_key::dns1, dns.first); - serverConfig.insert(config_key::dns2, dns.second); - - } - else { - set_textEditShareAmneziaCodeText(tr("Error while generating connection profile")); - return; - } - } - - QByteArray ba = QJsonDocument(serverConfig).toJson(); - ba = qCompress(ba, 8); - QString code = QString("vpn://%1").arg(QString(ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals))); - set_textEditShareAmneziaCodeText(code); - - - QList qrChunks = genQrCodeImageSeries(ba); - set_shareAmneziaQrCodeTextSeries(qrChunks); - set_shareAmneziaQrCodeTextSeriesLength(qrChunks.size()); -} - -void ShareConnectionLogic::onPushButtonShareOpenVpnGenerateClicked() -{ - int serverIndex = uiLogic()->m_selectedServerIndex; - DockerContainer container = uiLogic()->m_selectedDockerContainer; - ServerCredentials credentials = m_settings->serverCredentials(serverIndex); - - const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container); - - ErrorCode e = ErrorCode::NoError; - QString cfg = m_configurator->openVpnConfigurator->genOpenVpnConfig(credentials, container, containerConfig, &e); - cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::OpenVpn, cfg); - - set_textEditShareOpenVpnCodeText(QJsonDocument::fromJson(cfg.toUtf8()).object()[config_key::config].toString()); -} - -void ShareConnectionLogic::onPushButtonShareShadowSocksGenerateClicked() -{ - int serverIndex = uiLogic()->m_selectedServerIndex; - DockerContainer container = uiLogic()->m_selectedDockerContainer; - ServerCredentials credentials = m_settings->serverCredentials(serverIndex); - - 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); - - ErrorCode e = ErrorCode::NoError; - cfg = m_configurator->shadowSocksConfigurator->genShadowSocksConfig(credentials, container, containerConfig, &e); - } - - QJsonObject ssConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); - - QString ssString = QString("%1:%2@%3:%4") - .arg(ssConfig.value("method").toString()) - .arg(ssConfig.value("password").toString()) - .arg(ssConfig.value("server").toString()) - .arg(ssConfig.value("server_port").toString()); - - ssString = "ss://" + ssString.toUtf8().toBase64(); - set_lineEditShareShadowSocksStringText(ssString); - - QrCode qr = QrCode::encodeText(ssString.toUtf8(), QrCode::Ecc::LOW); - QString svg = QString::fromStdString(toSvgString(qr, 0)); - - set_shareShadowSocksQrCodeText(svgToBase64(svg)); - - QString humanString = QString("Server: %3\n" - "Port: %4\n" - "Encryption: %1\n" - "Password: %2") - .arg(ssConfig.value("method").toString()) - .arg(ssConfig.value("password").toString()) - .arg(ssConfig.value("server").toString()) - .arg(ssConfig.value("server_port").toString()); - - set_textEditShareShadowSocksText(humanString); -} - -void ShareConnectionLogic::onPushButtonShareCloakGenerateClicked() -{ - int serverIndex = uiLogic()->m_selectedServerIndex; - DockerContainer container = uiLogic()->m_selectedDockerContainer; - ServerCredentials credentials = m_settings->serverCredentials(serverIndex); - - 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); - - ErrorCode e = ErrorCode::NoError; - cfg = m_configurator->cloakConfigurator->genCloakConfig(credentials, container, containerConfig, &e); - } - - QJsonObject cloakConfig = QJsonDocument::fromJson(cfg.toUtf8()).object(); - cloakConfig.remove(config_key::transport_proto); - cloakConfig.insert("ProxyMethod", "shadowsocks"); - - set_textEditShareCloakText(QJsonDocument(cloakConfig).toJson()); -} - -void ShareConnectionLogic::onPushButtonShareWireGuardGenerateClicked() -{ - int serverIndex = uiLogic()->m_selectedServerIndex; - DockerContainer container = uiLogic()->m_selectedDockerContainer; - ServerCredentials credentials = m_settings->serverCredentials(serverIndex); - - const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container); - - ErrorCode e = ErrorCode::NoError; - QString cfg = m_configurator->wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, &e); - if (e) { - emit uiLogic()->showWarningMessage(tr("Error occurred while generating the config.") + "\n" + - tr("Error message: ") + errorString(e) + "\n" + - tr("See logs for details.")); - return; - } - cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::WireGuard, cfg); - cfg = QJsonDocument::fromJson(cfg.toUtf8()).object()[config_key::config].toString(); - - set_textEditShareWireGuardCodeText(cfg); - - QrCode qr = QrCode::encodeText(cfg.toUtf8(), QrCode::Ecc::LOW); - QString svg = QString::fromStdString(toSvgString(qr, 0)); - - set_shareWireGuardQrCodeText(svgToBase64(svg)); -} - -void ShareConnectionLogic::onPushButtonShareIkev2GenerateClicked() -{ - int serverIndex = uiLogic()->m_selectedServerIndex; - DockerContainer container = uiLogic()->m_selectedDockerContainer; - ServerCredentials credentials = m_settings->serverCredentials(serverIndex); - - Ikev2Configurator::ConnectionData connData = m_configurator->ikev2Configurator->prepareIkev2Config(credentials, container); - - QString cfg = m_configurator->ikev2Configurator->genIkev2Config(connData); - cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::Ikev2, cfg); - cfg = QJsonDocument::fromJson(cfg.toUtf8()).object()[config_key::cert].toString(); - - set_textEditShareIkev2CertText(cfg); - - QString mobileCfg = m_configurator->ikev2Configurator->genMobileConfig(connData); - set_textEditShareIkev2MobileConfigText(mobileCfg); - - QString strongSwanCfg = m_configurator->ikev2Configurator->genStrongSwanConfig(connData); - set_textEditShareIkev2StrongSwanConfigText(strongSwanCfg); - -} - - -void ShareConnectionLogic::updateSharingPage(int serverIndex, DockerContainer container) -{ - uiLogic()->m_selectedDockerContainer = container; - uiLogic()->m_selectedServerIndex = serverIndex; - set_shareFullAccess(container == DockerContainer::None); - - m_shareAmneziaQrCodeTextSeries.clear(); - set_shareAmneziaQrCodeTextSeriesLength(0); -} - -QList ShareConnectionLogic::genQrCodeImageSeries(const QByteArray &data) -{ - double k = 850; - - quint8 chunksCount = std::ceil(data.size() / k); - QList chunks; - for (int i = 0; i < data.size(); i = i + k) { - QByteArray chunk; - QDataStream s(&chunk, QIODevice::WriteOnly); - s << amnezia::qrMagicCode << chunksCount << (quint8)std::round(i/k) << data.mid(i, k); - - QByteArray ba = chunk.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - - QrCode qr = QrCode::encodeText(ba, QrCode::Ecc::LOW); - QString svg = QString::fromStdString(toSvgString(qr, 0)); - chunks.append(svgToBase64(svg)); - } - - return chunks; -} - -QString ShareConnectionLogic::svgToBase64(const QString &image) -{ - return "data:image/svg;base64," + QString::fromLatin1(image.toUtf8().toBase64().data()); -} diff --git a/client/ui/pages_logic/ShareConnectionLogic.h b/client/ui/pages_logic/ShareConnectionLogic.h deleted file mode 100644 index 3b9655aab..000000000 --- a/client/ui/pages_logic/ShareConnectionLogic.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SHARE_CONNECTION_LOGIC_H -#define SHARE_CONNECTION_LOGIC_H - -#include "PageLogicBase.h" -#include "containers/containers_defs.h" - -class UiLogic; - -class ShareConnectionLogic: public PageLogicBase -{ - Q_OBJECT - -public: - AUTO_PROPERTY(bool, shareFullAccess) - - AUTO_PROPERTY(QString, textEditShareAmneziaCodeText) - AUTO_PROPERTY(QStringList, shareAmneziaQrCodeTextSeries) - AUTO_PROPERTY(int, shareAmneziaQrCodeTextSeriesLength) - - AUTO_PROPERTY(QString, textEditShareOpenVpnCodeText) - - AUTO_PROPERTY(QString, textEditShareShadowSocksText) - AUTO_PROPERTY(QString, lineEditShareShadowSocksStringText) - AUTO_PROPERTY(QString, shareShadowSocksQrCodeText) - - AUTO_PROPERTY(QString, textEditShareCloakText) - - AUTO_PROPERTY(QString, textEditShareWireGuardCodeText) - AUTO_PROPERTY(QString, shareWireGuardQrCodeText) - - AUTO_PROPERTY(QString, textEditShareIkev2CertText) - AUTO_PROPERTY(QString, textEditShareIkev2MobileConfigText) - AUTO_PROPERTY(QString, textEditShareIkev2StrongSwanConfigText) - -public: - Q_INVOKABLE void onPushButtonShareAmneziaGenerateClicked(); - Q_INVOKABLE void onPushButtonShareOpenVpnGenerateClicked(); - Q_INVOKABLE void onPushButtonShareShadowSocksGenerateClicked(); - Q_INVOKABLE void onPushButtonShareCloakGenerateClicked(); - Q_INVOKABLE void onPushButtonShareWireGuardGenerateClicked(); - Q_INVOKABLE void onPushButtonShareIkev2GenerateClicked(); - - Q_INVOKABLE virtual void onUpdatePage() override; - -public: - explicit ShareConnectionLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ShareConnectionLogic() = default; - - void updateSharingPage(int serverIndex, DockerContainer container); - QList genQrCodeImageSeries(const QByteArray &data); - - QString svgToBase64(const QString &image); -}; -#endif // SHARE_CONNECTION_LOGIC_H diff --git a/client/ui/pages_logic/SitesLogic.cpp b/client/ui/pages_logic/SitesLogic.cpp deleted file mode 100644 index aaf8f73d9..000000000 --- a/client/ui/pages_logic/SitesLogic.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include -#include -#include -#include - -#include "SitesLogic.h" -#include "VpnLogic.h" -#include "utilities.h" -#include "vpnconnection.h" -#include - -#include "../models/sites_model.h" -#include "../uilogic.h" - -SitesLogic::SitesLogic(UiLogic *logic, QObject *parent) - : PageLogicBase(logic, parent), - m_labelSitesAddCustomText {}, - m_tableViewSitesModel { nullptr }, - m_lineEditSitesAddCustomText {} -{ - // 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(); - if (m == Settings::VpnAllSites) - return; - - if (m == Settings::VpnOnlyForwardSites) { - set_labelSitesAddCustomText(tr("These sites will be opened using VPN")); - } - if (m == Settings::VpnAllExceptSites) { - set_labelSitesAddCustomText(tr("These sites will be excepted from VPN")); - } - - set_tableViewSitesModel(sitesModels.value(m)); - // sitesModels.value(m)->resetCache(); -} - -void SitesLogic::onPushButtonAddCustomSitesClicked() -{ - if (uiLogic()->pageLogic()->radioButtonVpnModeAllSitesChecked()) { - return; - } - Settings::RouteMode mode = m_settings->routeMode(); - - QString newSite = lineEditSitesAddCustomText(); - - if (newSite.isEmpty()) - return; - if (!newSite.contains(".")) - return; - - if (!Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { - // get domain name if it present - newSite.replace("https://", ""); - newSite.replace("http://", ""); - newSite.replace("ftp://", ""); - - newSite = newSite.split("/", Qt::SkipEmptyParts).first(); - } - - const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) { - m_settings->addVpnSite(mode, newSite, ip); - - if (!ip.isEmpty()) { - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes", Qt::QueuedConnection, - Q_ARG(QStringList, QStringList() << ip)); - } else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes", Qt::QueuedConnection, - Q_ARG(QStringList, QStringList() << newSite)); - } - - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns", Qt::QueuedConnection); - - onUpdatePage(); - }; - - const auto &cbResolv = [this, cbProcess](const QHostInfo &hostInfo) { - const QList &addresses = hostInfo.addresses(); - QString ipv4Addr; - for (const QHostAddress &addr : hostInfo.addresses()) { - if (addr.protocol() == QAbstractSocket::NetworkLayerProtocol::IPv4Protocol) { - cbProcess(hostInfo.hostName(), addr.toString()); - break; - } - } - }; - - set_lineEditSitesAddCustomText(""); - - if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) { - cbProcess(newSite, ""); - return; - } else { - cbProcess(newSite, ""); - onUpdatePage(); - QHostInfo::lookupHost(newSite, this, cbResolv); - } -} - -void SitesLogic::onPushButtonSitesDeleteClicked(QStringList items) -{ - Settings::RouteMode mode = m_settings->routeMode(); - - auto siteModel = qobject_cast(tableViewSitesModel()); - if (!siteModel || items.isEmpty()) { - return; - } - - QStringList sites; - QStringList ips; - - for (const QString &s : items) { - bool ok; - int row = s.toInt(&ok); - if (!ok || row < 0 || row >= siteModel->rowCount()) - return; - // sites.append(siteModel->data(row, 0).toString()); - - // if (uiLogic()->m_vpnConnection && uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) { - // ips.append(siteModel->data(row, 1).toString()); - // } - } - - m_settings->removeVpnSites(mode, sites); - - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "deleteRoutes", Qt::QueuedConnection, Q_ARG(QStringList, ips)); - - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns", Qt::QueuedConnection); - - onUpdatePage(); -} - -void SitesLogic::onPushButtonSitesImportClicked(const QString &fileName) -{ - QFile file(QUrl { fileName }.toLocalFile()); - if (!file.open(QIODevice::ReadOnly)) { - qDebug() << "Can't open file " << QUrl { fileName }.toLocalFile(); - return; - } - - Settings::RouteMode mode = m_settings->routeMode(); - - QStringList ips; - QMap sites; - - while (!file.atEnd()) { - QString line = file.readLine(); - QStringList line_ips; - QStringList line_sites; - - int posDomain = 0; - QRegExp domainRx = Utils::domainRegExp(); - while ((posDomain = domainRx.indexIn(line, posDomain)) != -1) { - line_sites.append(domainRx.cap(0)); - posDomain += domainRx.matchedLength(); - } - - int posIp = 0; - QRegExp ipRx = Utils::ipAddressWithSubnetRegExp(); - while ((posIp = ipRx.indexIn(line, posIp)) != -1) { - line_ips.append(ipRx.cap(0)); - posIp += ipRx.matchedLength(); - } - - // domain regex cover ip regex, so remove ips from sites - for (const QString &ip : line_ips) { - line_sites.removeAll(ip); - } - - if (line_sites.size() == 1 && line_ips.size() == 1) { - sites.insert(line_sites.at(0), line_ips.at(0)); - } else if (line_sites.size() > 0 && line_ips.size() == 0) { - for (const QString &site : line_sites) { - sites.insert(site, ""); - } - } else { - for (const QString &site : line_sites) { - sites.insert(site, ""); - } - for (const QString &ip : line_ips) { - ips.append(ip); - } - } - } - - m_settings->addVpnIps(mode, ips); - m_settings->addVpnSites(mode, sites); - - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "addRoutes", Qt::QueuedConnection, Q_ARG(QStringList, ips)); - - QMetaObject::invokeMethod(uiLogic()->m_vpnConnection, "flushDns", Qt::QueuedConnection); - - onUpdatePage(); -} - -void SitesLogic::onPushButtonSitesExportClicked() -{ - Settings::RouteMode mode = m_settings->routeMode(); - - QVariantMap sites = m_settings->vpnSites(mode); - - QString data; - for (auto s : sites.keys()) { - data += s + "\t" + sites.value(s).toString() + "\n"; - } - uiLogic()->saveTextFile("Export Sites", "sites.txt", ".txt", data); -} diff --git a/client/ui/pages_logic/SitesLogic.h b/client/ui/pages_logic/SitesLogic.h deleted file mode 100644 index 35bf1f90c..000000000 --- a/client/ui/pages_logic/SitesLogic.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SITES_LOGIC_H -#define SITES_LOGIC_H - -#include "PageLogicBase.h" -#include "settings.h" - -class UiLogic; -class SitesModel; - -class SitesLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, labelSitesAddCustomText) - AUTO_PROPERTY(QObject*, tableViewSitesModel) - AUTO_PROPERTY(QString, lineEditSitesAddCustomText) - -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onPushButtonAddCustomSitesClicked(); - Q_INVOKABLE void onPushButtonSitesDeleteClicked(QStringList items); - Q_INVOKABLE void onPushButtonSitesImportClicked(const QString &fileName); - Q_INVOKABLE void onPushButtonSitesExportClicked(); - - -public: - explicit SitesLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~SitesLogic() = default; - - QMap sitesModels; -}; -#endif // SITES_LOGIC_H diff --git a/client/ui/pages_logic/StartPageLogic.cpp b/client/ui/pages_logic/StartPageLogic.cpp deleted file mode 100644 index 891d67fbf..000000000 --- a/client/ui/pages_logic/StartPageLogic.cpp +++ /dev/null @@ -1,374 +0,0 @@ -#include "StartPageLogic.h" -#include "ViewConfigLogic.h" - -#include "../uilogic.h" -#include "configurators/ssh_configurator.h" -#include "configurators/vpn_configurator.h" -#include "core/errorstrings.h" -#include "core/servercontroller.h" -#include "utilities.h" - -#include -#include -#include - -#ifdef Q_OS_ANDROID - #include "../../platforms/android/android_controller.h" - #include "../../platforms/android/androidutils.h" - #include -#endif - -#ifdef Q_OS_IOS - #include -#endif - -namespace -{ - enum class ConfigTypes { - Amnezia, - OpenVpn, - WireGuard - }; - - ConfigTypes checkConfigFormat(const QString &config) - { - const QString openVpnConfigPatternCli = "client"; - const QString openVpnConfigPatternProto1 = "proto tcp"; - const QString openVpnConfigPatternProto2 = "proto udp"; - const QString openVpnConfigPatternDriver1 = "dev tun"; - const QString openVpnConfigPatternDriver2 = "dev tap"; - - const QString wireguardConfigPatternSectionInterface = "[Interface]"; - const QString wireguardConfigPatternSectionPeer = "[Peer]"; - - if (config.contains(openVpnConfigPatternCli) - && (config.contains(openVpnConfigPatternProto1) || config.contains(openVpnConfigPatternProto2)) - && (config.contains(openVpnConfigPatternDriver1) || config.contains(openVpnConfigPatternDriver2))) { - return ConfigTypes::OpenVpn; - } else if (config.contains(wireguardConfigPatternSectionInterface) - && config.contains(wireguardConfigPatternSectionPeer)) - return ConfigTypes::WireGuard; - return ConfigTypes::Amnezia; - } - -} - -StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent) - : PageLogicBase(logic, parent), - m_pushButtonConnectEnabled { true }, - m_pushButtonConnectText { tr("Connect") }, - m_pushButtonConnectKeyChecked { false }, - m_labelWaitInfoVisible { true }, - m_pushButtonBackFromStartVisible { true }, - m_ipAddressPortRegex { Utils::ipAddressPortRegExp() } -{ -#ifdef Q_OS_ANDROID - // Set security screen for Android app - AndroidUtils::runOnAndroidThreadSync([]() { - QJniObject activity = AndroidUtils::getActivity(); - QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;"); - if (window.isValid()) { - const int FLAG_SECURE = 8192; - window.callMethod("addFlags", "(I)V", FLAG_SECURE); - } - }); -#endif -} - -void StartPageLogic::onUpdatePage() -{ - set_lineEditStartExistingCodeText(""); - set_textEditSshKeyText(""); - set_lineEditIpText(""); - set_lineEditPasswordText(""); - set_textEditSshKeyText(""); - set_lineEditLoginText(""); - - set_labelWaitInfoVisible(false); - set_labelWaitInfoText(""); - - set_pushButtonConnectKeyChecked(false); - - set_pushButtonBackFromStartVisible(uiLogic()->pagesStackDepth() > 0); -} - -void StartPageLogic::onPushButtonConnect() -{ - if (pushButtonConnectKeyChecked()) { - if (lineEditIpText().isEmpty() || lineEditLoginText().isEmpty() || textEditSshKeyText().isEmpty()) { - set_labelWaitInfoText(tr("Please fill in all fields")); - return; - } - } else { - if (lineEditIpText().isEmpty() || lineEditLoginText().isEmpty() || lineEditPasswordText().isEmpty()) { - set_labelWaitInfoText(tr("Please fill in all fields")); - return; - } - } - - ServerCredentials serverCredentials; - serverCredentials.hostName = lineEditIpText(); - if (serverCredentials.hostName.contains(":")) { - serverCredentials.port = serverCredentials.hostName.split(":").at(1).toInt(); - serverCredentials.hostName = serverCredentials.hostName.split(":").at(0); - } - serverCredentials.userName = lineEditLoginText(); - if (pushButtonConnectKeyChecked()) { - QString key = textEditSshKeyText(); - if (key.startsWith("ssh-rsa")) { - emit uiLogic()->showPublicKeyWarning(); - return; - } - - if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) { - key = m_configurator->sshConfigurator->convertOpenSShKey(key); - } - - serverCredentials.secretData = key; - } else { - serverCredentials.secretData = lineEditPasswordText(); - } - - set_pushButtonConnectEnabled(false); - set_pushButtonConnectText(tr("Connecting...")); - - ServerController serverController(m_settings); - ErrorCode errorCode = ErrorCode::NoError; - - if (pushButtonConnectKeyChecked()) { - auto passphraseCallback = [this, &serverController]() { - emit showPassphraseRequestMessage(); - QEventLoop loop; - QObject::connect(this, &StartPageLogic::passphraseDialogClosed, &loop, &QEventLoop::quit); - loop.exec(); - - return m_privateKeyPassphrase; - }; - - QString decryptedPrivateKey; - errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey, passphraseCallback); - if (errorCode == ErrorCode::NoError) { - serverCredentials.secretData = decryptedPrivateKey; - } - } - - QString output; - if (errorCode == ErrorCode::NoError) { - output = serverController.checkSshConnection(serverCredentials, &errorCode); - } - - bool ok = true; - if (errorCode) { - set_labelWaitInfoVisible(true); - set_labelWaitInfoText(errorString(errorCode)); - ok = false; - } else { - if (output.contains("Please login as the user")) { - output.replace("\n", ""); - set_labelWaitInfoVisible(true); - set_labelWaitInfoText(output); - ok = false; - } - } - - set_pushButtonConnectEnabled(true); - set_pushButtonConnectText(tr("Connect")); - - uiLogic()->m_installCredentials = serverCredentials; - if (ok) - emit uiLogic()->goToPage(Page::NewServer); -} - -void StartPageLogic::onPushButtonImport() -{ - importConnectionFromCode(lineEditStartExistingCodeText()); -} - -void StartPageLogic::onPushButtonImportOpenFile() -{ - QString fileName = UiLogic::getOpenFileName(Q_NULLPTR, tr("Open config file"), - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), - "*.vpn *.ovpn *.conf"); - if (fileName.isEmpty()) - return; - - QFile file(fileName); - -#ifdef Q_OS_IOS - CFURLRef url = CFURLCreateWithFileSystemPath( - kCFAllocatorDefault, - CFStringCreateWithCharacters(0, reinterpret_cast(fileName.unicode()), fileName.length()), - kCFURLPOSIXPathStyle, 0); - - if (!CFURLStartAccessingSecurityScopedResource(url)) { - qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString(); - } -#endif - - file.open(QIODevice::ReadOnly); - QByteArray data = file.readAll(); - - importAnyFile(QString(data)); -} - -#ifdef Q_OS_ANDROID -void StartPageLogic::startQrDecoder() -{ - AndroidController::instance()->startQrReaderActivity(); -} -#endif - -void StartPageLogic::importAnyFile(const QString &configData) -{ - auto configFormat = checkConfigFormat(configData); - if (configFormat == ConfigTypes::OpenVpn) { - importConnectionFromOpenVpnConfig(configData); - } else if (configFormat == ConfigTypes::WireGuard) { - importConnectionFromWireguardConfig(configData); - } else { - importConnectionFromCode(configData); - } -} - -bool StartPageLogic::importConnection(const QJsonObject &profile) -{ - ServerCredentials credentials; - credentials.hostName = profile.value(config_key::hostName).toString(); - credentials.port = profile.value(config_key::port).toInt(); - credentials.userName = profile.value(config_key::userName).toString(); - credentials.secretData = profile.value(config_key::password).toString(); - - if (credentials.isValid() || profile.contains(config_key::containers)) { - // check config - uiLogic()->pageLogic()->set_configJson(profile); - emit uiLogic()->goToPage(Page::ViewConfig); - } else { - qDebug() << "Failed to import profile"; - qDebug().noquote() << QJsonDocument(profile).toJson(); - return false; - } - - return true; -} - -bool StartPageLogic::importConnectionFromCode(QString code) -{ - code.replace("vpn://", ""); - QByteArray ba = QByteArray::fromBase64(code.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - - QByteArray ba_uncompressed = qUncompress(ba); - if (!ba_uncompressed.isEmpty()) { - ba = ba_uncompressed; - } - - QJsonObject o; - o = QJsonDocument::fromJson(ba).object(); - if (!o.isEmpty()) { - return importConnection(o); - } - - return false; -} - -bool StartPageLogic::importConnectionFromQr(const QByteArray &data) -{ - QJsonObject dataObj = QJsonDocument::fromJson(data).object(); - if (!dataObj.isEmpty()) { - return importConnection(dataObj); - } - - QByteArray ba_uncompressed = qUncompress(data); - if (!ba_uncompressed.isEmpty()) { - return importConnection(QJsonDocument::fromJson(ba_uncompressed).object()); - } - - return false; -} - -bool StartPageLogic::importConnectionFromOpenVpnConfig(const QString &config) -{ - QJsonObject openVpnConfig; - openVpnConfig[config_key::config] = config; - - QJsonObject lastConfig; - lastConfig[config_key::last_config] = QString(QJsonDocument(openVpnConfig).toJson()); - lastConfig[config_key::isThirdPartyConfig] = true; - - QJsonObject containers; - containers.insert(config_key::container, QJsonValue("amnezia-openvpn")); - containers.insert(config_key::openvpn, QJsonValue(lastConfig)); - - QJsonArray arr; - arr.push_back(containers); - - QString hostName; - const static QRegularExpression hostNameRegExp("remote (.*) [0-9]*"); - QRegularExpressionMatch hostNameMatch = hostNameRegExp.match(config); - if (hostNameMatch.hasMatch()) { - hostName = hostNameMatch.captured(1); - } - - QJsonObject o; - o[config_key::containers] = arr; - o[config_key::defaultContainer] = "amnezia-openvpn"; - o[config_key::description] = m_settings->nextAvailableServerName(); - - const static QRegularExpression dnsRegExp("dhcp-option DNS (\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)"); - QRegularExpressionMatchIterator dnsMatch = dnsRegExp.globalMatch(config); - if (dnsMatch.hasNext()) { - o[config_key::dns1] = dnsMatch.next().captured(1); - } - if (dnsMatch.hasNext()) { - o[config_key::dns2] = dnsMatch.next().captured(1); - } - - o[config_key::hostName] = hostName; - - return importConnection(o); -} - -bool StartPageLogic::importConnectionFromWireguardConfig(const QString &config) -{ - QJsonObject lastConfig; - lastConfig[config_key::config] = config; - - const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*):([0-9]*)"); - QRegularExpressionMatch hostNameAndPortMatch = hostNameAndPortRegExp.match(config); - QString hostName; - QString port; - if (hostNameAndPortMatch.hasMatch()) { - hostName = hostNameAndPortMatch.captured(1); - port = hostNameAndPortMatch.captured(2); - } - - QJsonObject wireguardConfig; - wireguardConfig[config_key::last_config] = QString(QJsonDocument(lastConfig).toJson()); - wireguardConfig[config_key::isThirdPartyConfig] = true; - wireguardConfig[config_key::port] = port; - wireguardConfig[config_key::transport_proto] = "udp"; - - QJsonObject containers; - containers.insert(config_key::container, QJsonValue("amnezia-wireguard")); - containers.insert(config_key::wireguard, QJsonValue(wireguardConfig)); - - QJsonArray arr; - arr.push_back(containers); - - QJsonObject o; - o[config_key::containers] = arr; - o[config_key::defaultContainer] = "amnezia-wireguard"; - o[config_key::description] = m_settings->nextAvailableServerName(); - - const static QRegularExpression dnsRegExp( - "DNS = " - "(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b).*(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)"); - QRegularExpressionMatch dnsMatch = dnsRegExp.match(config); - if (dnsMatch.hasMatch()) { - o[config_key::dns1] = dnsMatch.captured(1); - o[config_key::dns2] = dnsMatch.captured(2); - } - - o[config_key::hostName] = hostName; - - return importConnection(o); -} diff --git a/client/ui/pages_logic/StartPageLogic.h b/client/ui/pages_logic/StartPageLogic.h deleted file mode 100644 index 9025a052c..000000000 --- a/client/ui/pages_logic/StartPageLogic.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef START_PAGE_LOGIC_H -#define START_PAGE_LOGIC_H - -#include "PageLogicBase.h" - -#include - -class UiLogic; - -class StartPageLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, pushButtonConnectEnabled) - AUTO_PROPERTY(bool, pushButtonConnectKeyChecked) - AUTO_PROPERTY(QString, pushButtonConnectText) - AUTO_PROPERTY(QString, lineEditStartExistingCodeText) - AUTO_PROPERTY(QString, textEditSshKeyText) - AUTO_PROPERTY(QString, lineEditIpText) - AUTO_PROPERTY(QString, lineEditPasswordText) - AUTO_PROPERTY(QString, lineEditLoginText) - AUTO_PROPERTY(bool, labelWaitInfoVisible) - AUTO_PROPERTY(QString, labelWaitInfoText) - AUTO_PROPERTY(bool, pushButtonBackFromStartVisible) - - AUTO_PROPERTY(QString, privateKeyPassphrase) - - READONLY_PROPERTY(QRegularExpression, ipAddressPortRegex) -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onPushButtonConnect(); - Q_INVOKABLE void onPushButtonImport(); - Q_INVOKABLE void onPushButtonImportOpenFile(); - -#ifdef Q_OS_ANDROID - Q_INVOKABLE void startQrDecoder(); -#endif - - void importAnyFile(const QString &configData); - - bool importConnection(const QJsonObject &profile); - bool importConnectionFromCode(QString code); - bool importConnectionFromQr(const QByteArray &data); - bool importConnectionFromOpenVpnConfig(const QString &config); - bool importConnectionFromWireguardConfig(const QString &config); - -public: - explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~StartPageLogic() = default; - -signals: - void showPassphraseRequestMessage(); - void passphraseDialogClosed(); -}; -#endif // START_PAGE_LOGIC_H diff --git a/client/ui/pages_logic/ViewConfigLogic.cpp b/client/ui/pages_logic/ViewConfigLogic.cpp deleted file mode 100644 index 5f7114985..000000000 --- a/client/ui/pages_logic/ViewConfigLogic.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "ViewConfigLogic.h" -#include "core/errorstrings.h" -#include "../uilogic.h" - - -ViewConfigLogic::ViewConfigLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent) -{ - -} - -void ViewConfigLogic::onUpdatePage() -{ - set_configText(QJsonDocument(configJson()).toJson()); - - auto s = configJson()[config_key::isThirdPartyConfig].toBool(); - - m_openVpnLastConfigs = m_openVpnMalStrings = - "
"; - - m_warningStringNumber = 3; - m_warningActive = false; - - const QJsonArray &containers = configJson()[config_key::containers].toArray(); - int i = 0; - for (const QJsonValue &v: containers) { - auto containerName = v.toObject()[config_key::container].toString(); - QJsonObject containerConfig = v.toObject()[containerName.replace("amnezia-", "")].toObject(); - if (containerConfig[config_key::isThirdPartyConfig].toBool()) { - auto lastConfig = containerConfig.value(config_key::last_config).toString(); - auto lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object(); - QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n"); - QString lastConfigText; - for (const QString &l: lines) { - lastConfigText.append(l + "\n"); - } - set_configText(lastConfigText); - } - - - if (v.toObject()[config_key::container].toString() == "amnezia-openvpn") { - QString lastConfig = v.toObject()[ProtocolProps::protoToString(Proto::OpenVpn)] - .toObject()[config_key::last_config].toString(); - - QString lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object()[config_key::config] - .toString(); - - QStringList lines = lastConfigJson.replace("\r", "").split("\n"); - for (const QString &l: lines) { - i++; - QRegularExpressionMatch match = m_re.match(l); - if (dangerousTags.contains(match.captured(0))) { - QString t = QString("

%1").arg(l); - m_openVpnLastConfigs.append(t + "\n"); - m_openVpnMalStrings.append(t); - if (m_warningStringNumber == 3) m_warningStringNumber = i - 3; - m_warningActive = true; - qDebug() << "ViewConfigLogic : malicious scripts warning:" << l; - } - else { - m_openVpnLastConfigs.append("

" + l + " \n"); - } - } - } - } - - emit openVpnLastConfigsChanged(m_openVpnLastConfigs); - emit openVpnMalStringsChanged(m_openVpnMalStrings); - emit warningStringNumberChanged(m_warningStringNumber); - emit warningActiveChanged(m_warningActive); -} - -void ViewConfigLogic::importConfig() -{ - m_settings->addServer(configJson()); - m_settings->setDefaultServer(m_settings->serversCount() - 1); - - - if (!configJson().contains(config_key::containers) || configJson().value(config_key::containers).toArray().isEmpty()) { - uiLogic()->m_selectedServerIndex = m_settings->defaultServerIndex(); - uiLogic()->m_selectedDockerContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex); - uiLogic()->onUpdateAllPages(); - emit uiLogic()->goToPage(Page::Vpn); - emit uiLogic()->setStartPage(Page::Vpn); - emit uiLogic()->goToPage(Page::ServerContainers); - } else { - emit uiLogic()->goToPage(Page::Vpn); - emit uiLogic()->setStartPage(Page::Vpn); - } -} - diff --git a/client/ui/pages_logic/ViewConfigLogic.h b/client/ui/pages_logic/ViewConfigLogic.h deleted file mode 100644 index 4713158ec..000000000 --- a/client/ui/pages_logic/ViewConfigLogic.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef VIEW_CONFIG_LOGIC_H -#define VIEW_CONFIG_LOGIC_H - -#include "PageLogicBase.h" - -#include - -class UiLogic; - -class ViewConfigLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, configText) - AUTO_PROPERTY(QString, openVpnLastConfigs) - AUTO_PROPERTY(QString, openVpnMalStrings) - AUTO_PROPERTY(QJsonObject, configJson) - AUTO_PROPERTY(int, warningStringNumber) - AUTO_PROPERTY(bool, warningActive) - -public: - Q_INVOKABLE void onUpdatePage() override; - Q_INVOKABLE void importConfig(); - - -public: - explicit ViewConfigLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ViewConfigLogic() = default; - -private: - QRegularExpression m_re {"(\\w+-\\w+|\\w+)"}; - - // https://github.com/OpenVPN/openvpn/blob/master/doc/man-sections/script-options.rst - QStringList dangerousTags { - "up", - "tls-verify", - "ipchange", - "client-connect", - "route-up", - "route-pre-down", - "client-disconnect", - "down", - "learn-address", - "auth-user-pass-verify" - }; -}; -#endif // VIEW_CONFIG_LOGIC_H diff --git a/client/ui/pages_logic/VpnLogic.cpp b/client/ui/pages_logic/VpnLogic.cpp deleted file mode 100644 index 2f5e7b650..000000000 --- a/client/ui/pages_logic/VpnLogic.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include - -#include "VpnLogic.h" - -#include "core/errorstrings.h" -#include "vpnconnection.h" -#include -#include -#include "../uilogic.h" -#include "version.h" -#include - - -VpnLogic::VpnLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_pushButtonConnectChecked{false}, - - m_radioButtonVpnModeAllSitesChecked{true}, - m_radioButtonVpnModeForwardSitesChecked{false}, - m_radioButtonVpnModeExceptSitesChecked{false}, - - m_labelSpeedReceivedText{tr("0 Mbps")}, - m_labelSpeedSentText{tr("0 Mbps")}, - m_labelStateText{}, - m_isContainerHaveAuthData{false}, - m_isContainerSupportedByCurrentPlatform{false}, - m_widgetVpnModeEnabled{false} -{ - connect(uiLogic()->m_vpnConnection, &VpnConnection::bytesChanged, this, &VpnLogic::onBytesChanged); - connect(uiLogic()->m_vpnConnection, &VpnConnection::connectionStateChanged, this, &VpnLogic::onConnectionStateChanged); - connect(uiLogic()->m_vpnConnection, &VpnConnection::vpnProtocolError, this, &VpnLogic::onVpnProtocolError); - - connect(this, &VpnLogic::connectToVpn, uiLogic()->m_vpnConnection, &VpnConnection::connectToVpn, Qt::QueuedConnection); - connect(this, &VpnLogic::disconnectFromVpn, uiLogic()->m_vpnConnection, &VpnConnection::disconnectFromVpn, Qt::QueuedConnection); - - connect(m_settings.get(), &Settings::saveLogsChanged, this, &VpnLogic::onUpdatePage); - - if (m_settings->isAutoConnect() && m_settings->defaultServerIndex() >= 0) { - QTimer::singleShot(1000, this, [this](){ - set_pushButtonConnectEnabled(false); - onConnect(); - }); - } - else { - onConnectionStateChanged(Vpn::ConnectionState::Disconnected); - } -} - - -void VpnLogic::onUpdatePage() -{ - 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_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites || !isCustomRoutesSupported()); - set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites && isCustomRoutesSupported()); - set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites && isCustomRoutesSupported()); - - 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()); - set_labelCurrentServer(serverString); - - QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer); - set_labelCurrentService(selectedContainerName); - - auto dns = m_configurator->getDnsForConfig(m_settings->defaultServerIndex()); - set_amneziaDnsEnabled(dns.first == protocols::dns::amneziaDnsIp); - if (dns.first == protocols::dns::amneziaDnsIp) { - set_labelCurrentDns("On your server"); - } - else { - set_labelCurrentDns(dns.first + ", " + dns.second); - } - - set_isContainerSupportedByCurrentPlatform(ContainerProps::isSupportedByCurrentPlatform(selectedContainer)); - if (!isContainerSupportedByCurrentPlatform()) { - set_labelErrorText(tr("AmneziaVPN not supporting selected protocol on this device. Select another protocol.")); - } - else { - set_labelErrorText(""); - } - QString ver = QString("v. %2").arg(QString(APP_MAJOR_VERSION)); - set_labelVersionText(ver); - - set_labelLogEnabledVisible(m_settings->isSaveLogs()); -} - - -void VpnLogic::onRadioButtonVpnModeAllSitesClicked() -{ - m_settings->setRouteMode(Settings::VpnAllSites); - onUpdatePage(); -} - -void VpnLogic::onRadioButtonVpnModeForwardSitesClicked() -{ - m_settings->setRouteMode(Settings::VpnOnlyForwardSites); - onUpdatePage(); -} - -void VpnLogic::onRadioButtonVpnModeExceptSitesClicked() -{ - m_settings->setRouteMode(Settings::VpnAllExceptSites); - onUpdatePage(); -} - -void VpnLogic::onBytesChanged(quint64 receivedData, quint64 sentData) -{ - set_labelSpeedReceivedText(VpnConnection::bytesPerSecToText(receivedData)); - set_labelSpeedSentText(VpnConnection::bytesPerSecToText(sentData)); -} - -void VpnLogic::onConnectionStateChanged(Vpn::ConnectionState state) -{ - qDebug() << "VpnLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state); - if (uiLogic()->m_vpnConnection == NULL) { - qDebug() << "VpnLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state) << "невозможно, соединение отсутствует (уничтожено ранее)"; - return; - } - bool pbConnectEnabled = false; - bool pbConnectChecked = false; - - bool rbModeEnabled = false; - bool pbConnectVisible = false; - set_labelStateText(VpnProtocol::textConnectionState(state)); - - switch (state) { - case Vpn::ConnectionState::Disconnected: - onBytesChanged(0,0); - pbConnectChecked = false; - pbConnectEnabled = true; - pbConnectVisible = true; - rbModeEnabled = true; - break; - case Vpn::ConnectionState::Preparing: - pbConnectChecked = true; - pbConnectEnabled = false; - pbConnectVisible = false; - rbModeEnabled = false; - break; - case Vpn::ConnectionState::Connecting: - pbConnectChecked = true; - pbConnectEnabled = true; - pbConnectVisible = false; - rbModeEnabled = false; - break; - case Vpn::ConnectionState::Connected: - pbConnectChecked = true; - pbConnectEnabled = true; - pbConnectVisible = true; - rbModeEnabled = false; - break; - case Vpn::ConnectionState::Disconnecting: - pbConnectChecked = false; - pbConnectEnabled = false; - pbConnectVisible = false; - rbModeEnabled = false; - break; - case Vpn::ConnectionState::Reconnecting: - pbConnectChecked = true; - pbConnectEnabled = true; - pbConnectVisible = false; - rbModeEnabled = false; - break; - case Vpn::ConnectionState::Error: - pbConnectChecked = false; - pbConnectEnabled = true; - pbConnectVisible = true; - rbModeEnabled = true; - break; - case Vpn::ConnectionState::Unknown: - pbConnectChecked = false; - pbConnectEnabled = true; - pbConnectVisible = true; - rbModeEnabled = true; - } - - set_pushButtonConnectEnabled(pbConnectEnabled); - set_pushButtonConnectChecked(pbConnectChecked); - - set_pushButtonConnectVisible(pbConnectVisible); - set_widgetVpnModeEnabled(rbModeEnabled); -} - -void VpnLogic::onVpnProtocolError(ErrorCode errorCode) -{ - set_labelErrorText(errorString(errorCode)); -} - -void VpnLogic::onPushButtonConnectClicked() -{ - if (! pushButtonConnectChecked()) { - onConnect(); - } else { - onDisconnect(); - } -} - -void VpnLogic::onConnect() -{ - int serverIndex = m_settings->defaultServerIndex(); - ServerCredentials credentials = m_settings->serverCredentials(serverIndex); - DockerContainer container = m_settings->defaultContainer(serverIndex); - - 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; - } - - if (container == DockerContainer::None) { - set_labelErrorText(tr("VPN Protocol not chosen")); - set_pushButtonConnectChecked(false); - return; - } - - - const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container); - onConnectWorker(serverIndex, credentials, container, containerConfig); -} - -void VpnLogic::onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig) -{ - set_labelErrorText(""); - set_pushButtonConnectChecked(true); - set_pushButtonConnectEnabled(false); - - qApp->processEvents(); - - emit connectToVpn(serverIndex, credentials, container, containerConfig); -} - -void VpnLogic::onDisconnect() -{ - onConnectionStateChanged(Vpn::ConnectionState::Disconnected); - emit disconnectFromVpn(); -} diff --git a/client/ui/pages_logic/VpnLogic.h b/client/ui/pages_logic/VpnLogic.h deleted file mode 100644 index a0f7763b2..000000000 --- a/client/ui/pages_logic/VpnLogic.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef VPN_LOGIC_H -#define VPN_LOGIC_H - -#include "PageLogicBase.h" -#include "protocols/vpnprotocol.h" - -class UiLogic; - -class VpnLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, pushButtonConnectChecked) - AUTO_PROPERTY(QString, labelSpeedReceivedText) - AUTO_PROPERTY(QString, labelSpeedSentText) - AUTO_PROPERTY(QString, labelStateText) - AUTO_PROPERTY(QString, labelCurrentServer) - AUTO_PROPERTY(QString, labelCurrentService) - AUTO_PROPERTY(QString, labelCurrentDns) - AUTO_PROPERTY(bool, amneziaDnsEnabled) - - AUTO_PROPERTY(bool, pushButtonConnectEnabled) - AUTO_PROPERTY(bool, pushButtonConnectVisible) - AUTO_PROPERTY(bool, widgetVpnModeEnabled) - AUTO_PROPERTY(bool, isContainerSupportedByCurrentPlatform) - AUTO_PROPERTY(bool, isContainerHaveAuthData) - - AUTO_PROPERTY(QString, labelErrorText) - AUTO_PROPERTY(QString, labelVersionText) - - AUTO_PROPERTY(bool, isCustomRoutesSupported) - - AUTO_PROPERTY(bool, radioButtonVpnModeAllSitesChecked) - AUTO_PROPERTY(bool, radioButtonVpnModeForwardSitesChecked) - AUTO_PROPERTY(bool, radioButtonVpnModeExceptSitesChecked) - - AUTO_PROPERTY(bool, labelLogEnabledVisible) - -public: - Q_INVOKABLE void onUpdatePage() override; - - Q_INVOKABLE void onRadioButtonVpnModeAllSitesClicked(); - Q_INVOKABLE void onRadioButtonVpnModeForwardSitesClicked(); - Q_INVOKABLE void onRadioButtonVpnModeExceptSitesClicked(); - - Q_INVOKABLE void onPushButtonConnectClicked(); - -public: - explicit VpnLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~VpnLogic() = default; - - bool getPushButtonConnectChecked() const; - void setPushButtonConnectChecked(bool pushButtonConnectChecked); - -public slots: - void onConnect(); - void onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig); - void onDisconnect(); - - void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); - void onConnectionStateChanged(Vpn::ConnectionState state); - void onVpnProtocolError(amnezia::ErrorCode errorCode); - -signals: - void connectToVpn(int serverIndex, - const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig); - - void disconnectFromVpn(); -}; -#endif // VPN_LOGIC_H diff --git a/client/ui/pages_logic/WizardLogic.cpp b/client/ui/pages_logic/WizardLogic.cpp deleted file mode 100644 index 23a20aed0..000000000 --- a/client/ui/pages_logic/WizardLogic.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "WizardLogic.h" -#include "../uilogic.h" - -WizardLogic::WizardLogic(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent), - m_radioButtonHighChecked{false}, - m_radioButtonMediumChecked{true}, - m_radioButtonLowChecked{false}, - m_lineEditHighWebsiteMaskingText{}, - m_checkBoxVpnModeChecked{false} -{ - -} - -void WizardLogic::onUpdatePage() -{ - set_lineEditHighWebsiteMaskingText(protocols::cloak::defaultRedirSite); - set_radioButtonMediumChecked(true); -} - -QPair WizardLogic::getInstallConfigsFromWizardPage() const -{ - QJsonObject cloakConfig { - { config_key::container, ContainerProps::containerToString(DockerContainer::Cloak) }, - { ProtocolProps::protoToString(Proto::Cloak), QJsonObject { - { config_key::site, lineEditHighWebsiteMaskingText() }} - } - }; - QJsonObject ssConfig { - { config_key::container, ContainerProps::containerToString(DockerContainer::ShadowSocks) } - }; - QJsonObject openVpnConfig { - { config_key::container, ContainerProps::containerToString(DockerContainer::OpenVpn) } - }; - - QPair container; - - DockerContainer dockerContainer; - - if (radioButtonHighChecked()) { - container = {DockerContainer::Cloak, cloakConfig}; - } - - if (radioButtonMediumChecked()) { - container = {DockerContainer::ShadowSocks, ssConfig}; - } - - if (radioButtonLowChecked()) { - container = {DockerContainer::OpenVpn, openVpnConfig}; - } - - return container; -} - -void WizardLogic::onPushButtonVpnModeFinishClicked() -{ - auto container = getInstallConfigsFromWizardPage(); - uiLogic()->installServer(container); - if (checkBoxVpnModeChecked()) { - m_settings->setRouteMode(Settings::VpnOnlyForwardSites); - } else { - m_settings->setRouteMode(Settings::VpnAllSites); - } -} - -void WizardLogic::onPushButtonLowFinishClicked() -{ - auto container = getInstallConfigsFromWizardPage(); - uiLogic()->installServer(container); -} diff --git a/client/ui/pages_logic/WizardLogic.h b/client/ui/pages_logic/WizardLogic.h deleted file mode 100644 index a2e45af7d..000000000 --- a/client/ui/pages_logic/WizardLogic.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef WIZARD_LOGIC_H -#define WIZARD_LOGIC_H - -#include "PageLogicBase.h" -#include "containers/containers_defs.h" - -class UiLogic; - -class WizardLogic : public PageLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(bool, radioButtonHighChecked) - AUTO_PROPERTY(bool, radioButtonMediumChecked) - AUTO_PROPERTY(bool, radioButtonLowChecked) - AUTO_PROPERTY(bool, checkBoxVpnModeChecked) - AUTO_PROPERTY(QString, lineEditHighWebsiteMaskingText) - -public: - Q_INVOKABLE void onUpdatePage() override; - Q_INVOKABLE void onPushButtonVpnModeFinishClicked(); - Q_INVOKABLE void onPushButtonLowFinishClicked(); - -public: - explicit WizardLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~WizardLogic() = default; - - QPair getInstallConfigsFromWizardPage() const; - -}; -#endif // WIZARD_LOGIC_H diff --git a/client/ui/pages_logic/protocols/CloakLogic.cpp b/client/ui/pages_logic/protocols/CloakLogic.cpp deleted file mode 100644 index 0062d12d1..000000000 --- a/client/ui/pages_logic/protocols/CloakLogic.cpp +++ /dev/null @@ -1,137 +0,0 @@ -#include "CloakLogic.h" - -#include - -#include "core/servercontroller.h" -#include "ui/uilogic.h" -#include "ui/pages_logic/ServerConfiguringProgressLogic.h" - -using namespace amnezia; -using namespace PageEnumNS; - -CloakLogic::CloakLogic(UiLogic *logic, QObject *parent): - PageProtocolLogicBase(logic, parent), - m_comboBoxCipherText{"chacha20-poly1305"}, - m_lineEditSiteText{"tile.openstreetmap.org"}, - m_lineEditPortText{}, - m_pushButtonSaveVisible{false}, - m_progressBarResetVisible{false}, - m_lineEditPortEnabled{false}, - m_pageEnabled{true}, - m_labelInfoVisible{true}, - m_labelInfoText{}, - m_progressBarResetValue{0}, - m_progressBarResetMaximum{100} -{ - -} - -void CloakLogic::updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) -{ - set_pageEnabled(haveAuthData); - set_pushButtonSaveVisible(haveAuthData); - set_progressBarResetVisible(haveAuthData); - - set_comboBoxCipherText(ckConfig.value(config_key::cipher). - toString(protocols::cloak::defaultCipher)); - - set_lineEditSiteText(ckConfig.value(config_key::site). - toString(protocols::cloak::defaultRedirSite)); - - set_lineEditPortText(ckConfig.value(config_key::port). - toString(protocols::cloak::defaultPort)); - - set_lineEditPortEnabled(container == DockerContainer::Cloak); -} - -QJsonObject CloakLogic::getProtocolConfigFromPage(QJsonObject oldConfig) -{ - oldConfig.insert(config_key::cipher, comboBoxCipherText()); - oldConfig.insert(config_key::site, lineEditSiteText()); - oldConfig.insert(config_key::port, lineEditPortText()); - - return oldConfig; -} - -void CloakLogic::onPushButtonSaveClicked() -{ - QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, Proto::Cloak); - protocolConfig = getProtocolConfigFromPage(protocolConfig); - - QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer); - QJsonObject newContainerConfig = containerConfig; - newContainerConfig.insert(ProtocolProps::protoToString(Proto::Cloak), protocolConfig); - - ServerConfiguringProgressLogic::PageFunc pageFunc; - pageFunc.setEnabledFunc = [this] (bool enabled) -> void { - set_pageEnabled(enabled); - }; - ServerConfiguringProgressLogic::ButtonFunc saveButtonFunc; - saveButtonFunc.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonSaveVisible(visible); - }; - ServerConfiguringProgressLogic::LabelFunc waitInfoFunc; - waitInfoFunc.setVisibleFunc = [this] (bool visible) -> void { - set_labelInfoVisible(visible); - }; - waitInfoFunc.setTextFunc = [this] (const QString& text) -> void { - set_labelInfoText(text); - }; - ServerConfiguringProgressLogic::ProgressFunc progressBarFunc; - progressBarFunc.setVisibleFunc = [this] (bool visible) -> void { - set_progressBarResetVisible(visible); - }; - progressBarFunc.setValueFunc = [this] (int value) -> void { - set_progressBarResetValue(value); - }; - progressBarFunc.getValueFunc = [this] (void) -> int { - return progressBarResetValue(); - }; - progressBarFunc.getMaximumFunc = [this] (void) -> int { - return progressBarResetMaximum(); - }; - progressBarFunc.setTextVisibleFunc = [this] (bool visible) -> void { - set_progressBarTextVisible(visible); - }; - progressBarFunc.setTextFunc = [this] (const QString& text) -> void { - set_progressBarText(text); - }; - - ServerConfiguringProgressLogic::LabelFunc busyInfoFuncy; - busyInfoFuncy.setTextFunc = [this] (const QString& text) -> void { - set_labelServerBusyText(text); - }; - busyInfoFuncy.setVisibleFunc = [this] (bool visible) -> void { - set_labelServerBusyVisible(visible); - }; - - ServerConfiguringProgressLogic::ButtonFunc cancelButtonFunc; - cancelButtonFunc.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonCancelVisible(visible); - }; - - progressBarFunc.setTextVisibleFunc(true); - progressBarFunc.setTextFunc(QString("Configuring...")); - - auto installAction = [this, containerConfig, &newContainerConfig]() { - ServerController serverController(m_settings); - return serverController.updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), - uiLogic()->m_selectedDockerContainer, containerConfig, newContainerConfig); - }; - - ErrorCode e = uiLogic()->pageLogic()->doInstallAction(installAction, pageFunc, progressBarFunc, - saveButtonFunc, waitInfoFunc, - busyInfoFuncy, cancelButtonFunc); - - if (!e) { - m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, newContainerConfig); - m_settings->clearLastConnectionConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer); - } - - qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->m_selectedServerIndex << uiLogic()->m_selectedDockerContainer; -} - -void CloakLogic::onPushButtonCancelClicked() -{ - emit uiLogic()->pageLogic()->cancelDoInstallAction(true); -} diff --git a/client/ui/pages_logic/protocols/CloakLogic.h b/client/ui/pages_logic/protocols/CloakLogic.h deleted file mode 100644 index c135a6218..000000000 --- a/client/ui/pages_logic/protocols/CloakLogic.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef CLOAK_LOGIC_H -#define CLOAK_LOGIC_H - -#include "PageProtocolLogicBase.h" - -class UiLogic; - -class CloakLogic : public PageProtocolLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, comboBoxCipherText) - AUTO_PROPERTY(QString, lineEditSiteText) - AUTO_PROPERTY(QString, lineEditPortText) - AUTO_PROPERTY(bool, pushButtonSaveVisible) - AUTO_PROPERTY(bool, progressBarResetVisible) - AUTO_PROPERTY(bool, lineEditPortEnabled) - AUTO_PROPERTY(bool, pageEnabled) - AUTO_PROPERTY(bool, labelInfoVisible) - AUTO_PROPERTY(QString, labelInfoText) - AUTO_PROPERTY(int, progressBarResetValue) - AUTO_PROPERTY(int, progressBarResetMaximum) - AUTO_PROPERTY(bool, progressBarTextVisible) - AUTO_PROPERTY(QString, progressBarText) - - AUTO_PROPERTY(bool, labelServerBusyVisible) - AUTO_PROPERTY(QString, labelServerBusyText) - - AUTO_PROPERTY(bool, pushButtonCancelVisible) - -public: - Q_INVOKABLE void onPushButtonSaveClicked(); - Q_INVOKABLE void onPushButtonCancelClicked(); - -public: - explicit CloakLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~CloakLogic() = default; - - void updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) override; - QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override; - -private: - UiLogic *m_uiLogic; - -}; -#endif // CLOAK_LOGIC_H diff --git a/client/ui/pages_logic/protocols/OpenVpnLogic.cpp b/client/ui/pages_logic/protocols/OpenVpnLogic.cpp deleted file mode 100644 index 2eb68ed99..000000000 --- a/client/ui/pages_logic/protocols/OpenVpnLogic.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "OpenVpnLogic.h" - -#include - -#include "core/servercontroller.h" -#include "ui/uilogic.h" -#include "ui/pages_logic/ServerConfiguringProgressLogic.h" - -using namespace amnezia; -using namespace PageEnumNS; - -OpenVpnLogic::OpenVpnLogic(UiLogic *logic, QObject *parent): - PageProtocolLogicBase(logic, parent), - m_lineEditSubnetText{""}, - - m_radioButtonTcpEnabled{true}, - m_radioButtonTcpChecked{false}, - m_radioButtonUdpEnabled{true}, - m_radioButtonUdpChecked{false}, - - m_checkBoxAutoEncryptionChecked{}, - m_comboBoxVpnCipherText{"AES-256-GCM"}, - m_comboBoxVpnHashText{"SHA512"}, - m_checkBoxBlockDnsChecked{false}, - m_lineEditPortText{}, - m_checkBoxTlsAuthChecked{false}, - m_textAreaAdditionalClientConfig{""}, - m_textAreaAdditionalServerConfig{""}, - m_pushButtonSaveVisible{false}, - m_progressBarResetVisible{false}, - - m_lineEditPortEnabled{false}, - m_labelProtoOpenVpnInfoVisible{true}, - m_labelProtoOpenVpnInfoText{}, - m_progressBarResetValue{0}, - m_progressBarResetMaximum{100} -{ - -} - -void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) -{ - qDebug() << "OpenVpnLogic::updateProtocolPage"; - set_pageEnabled(haveAuthData); - set_pushButtonSaveVisible(haveAuthData); - set_progressBarResetVisible(haveAuthData); - - set_radioButtonUdpEnabled(true); - set_radioButtonTcpEnabled(true); - - set_lineEditSubnetText(openvpnConfig.value(config_key::subnet_address). - toString(protocols::openvpn::defaultSubnetAddress)); - - QString transport; - if (container == DockerContainer::ShadowSocks || container == DockerContainer::Cloak) { - transport = "tcp"; - set_radioButtonUdpEnabled(false); - set_radioButtonTcpEnabled(false); - } else { - transport = openvpnConfig.value(config_key::transport_proto). - toString(protocols::openvpn::defaultTransportProto); - } - set_radioButtonUdpChecked(transport == protocols::openvpn::defaultTransportProto); - set_radioButtonTcpChecked(transport != protocols::openvpn::defaultTransportProto); - - set_comboBoxVpnCipherText(openvpnConfig.value(config_key::cipher). - toString(protocols::openvpn::defaultCipher)); - - set_comboBoxVpnHashText(openvpnConfig.value(config_key::hash). - toString(protocols::openvpn::defaultHash)); - - bool blockOutsideDns = openvpnConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns); - set_checkBoxBlockDnsChecked(blockOutsideDns); - - bool isNcpDisabled = openvpnConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable); - set_checkBoxAutoEncryptionChecked(!isNcpDisabled); - - bool isTlsAuth = openvpnConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth); - set_checkBoxTlsAuthChecked(isTlsAuth); - - QString additionalClientConfig = openvpnConfig.value(config_key::additional_client_config). - toString(protocols::openvpn::defaultAdditionalClientConfig); - set_textAreaAdditionalClientConfig(additionalClientConfig); - - QString additionalServerConfig = openvpnConfig.value(config_key::additional_server_config). - toString(protocols::openvpn::defaultAdditionalServerConfig); - set_textAreaAdditionalServerConfig(additionalServerConfig); - - set_lineEditPortText(openvpnConfig.value(config_key::port). - toString(protocols::openvpn::defaultPort)); - - set_lineEditPortEnabled(container == DockerContainer::OpenVpn); - - auto lastConfig = openvpnConfig.value(config_key::last_config).toString(); - auto lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object(); - QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n"); - QString openVpnLastConfigText; - for (const QString &l: lines) { - openVpnLastConfigText.append(l + "\n"); - } - - set_openVpnLastConfigText(openVpnLastConfigText); - set_isThirdPartyConfig(openvpnConfig.value(config_key::isThirdPartyConfig).isBool()); -} - -void OpenVpnLogic::onPushButtonSaveClicked() -{ - QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, Proto::OpenVpn); - protocolConfig = getProtocolConfigFromPage(protocolConfig); - - QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer); - QJsonObject newContainerConfig = containerConfig; - newContainerConfig.insert(ProtocolProps::protoToString(Proto::OpenVpn), protocolConfig); - - ServerConfiguringProgressLogic::PageFunc pageFunc; - pageFunc.setEnabledFunc = [this] (bool enabled) -> void { - set_pageEnabled(enabled); - }; - ServerConfiguringProgressLogic::ButtonFunc saveButtonFunc; - saveButtonFunc.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonSaveVisible(visible); - }; - ServerConfiguringProgressLogic::LabelFunc waitInfoFunc; - waitInfoFunc.setVisibleFunc = [this] (bool visible) -> void { - set_labelProtoOpenVpnInfoVisible(visible); - }; - waitInfoFunc.setTextFunc = [this] (const QString& text) -> void { - set_labelProtoOpenVpnInfoText(text); - }; - ServerConfiguringProgressLogic::ProgressFunc progressBarFunc; - progressBarFunc.setVisibleFunc = [this] (bool visible) -> void { - set_progressBarResetVisible(visible); - }; - progressBarFunc.setValueFunc = [this] (int value) -> void { - set_progressBarResetValue(value); - }; - progressBarFunc.getValueFunc = [this] (void) -> int { - return progressBarResetValue(); - }; - progressBarFunc.getMaximumFunc = [this] (void) -> int { - return progressBarResetMaximum(); - }; - progressBarFunc.setTextVisibleFunc = [this] (bool visible) -> void { - set_progressBarTextVisible(visible); - }; - progressBarFunc.setTextFunc = [this] (const QString& text) -> void { - set_progressBarText(text); - }; - - ServerConfiguringProgressLogic::LabelFunc busyInfoFuncy; - busyInfoFuncy.setTextFunc = [this] (const QString& text) -> void { - set_labelServerBusyText(text); - }; - busyInfoFuncy.setVisibleFunc = [this] (bool visible) -> void { - set_labelServerBusyVisible(visible); - }; - - ServerConfiguringProgressLogic::ButtonFunc cancelButtonFunc; - cancelButtonFunc.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonCancelVisible(visible); - }; - - progressBarFunc.setTextVisibleFunc(true); - progressBarFunc.setTextFunc(QString("Configuring...")); - - auto installAction = [this, containerConfig, &newContainerConfig]() { - ServerController serverController(m_settings); - return serverController.updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), - uiLogic()->m_selectedDockerContainer, containerConfig, newContainerConfig); - }; - - ErrorCode e = uiLogic()->pageLogic()->doInstallAction(installAction, pageFunc, progressBarFunc, - saveButtonFunc, waitInfoFunc, - busyInfoFuncy, cancelButtonFunc); - - if (!e) { - m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, newContainerConfig); - m_settings->clearLastConnectionConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer); - } - qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->m_selectedServerIndex << uiLogic()->m_selectedDockerContainer; -} - -QJsonObject OpenVpnLogic::getProtocolConfigFromPage(QJsonObject oldConfig) -{ - oldConfig.insert(config_key::subnet_address, lineEditSubnetText()); - oldConfig.insert(config_key::transport_proto, - ProtocolProps::transportProtoToString(radioButtonUdpChecked() ? ProtocolEnumNS::Udp : ProtocolEnumNS::Tcp)); - - oldConfig.insert(config_key::ncp_disable, ! checkBoxAutoEncryptionChecked()); - oldConfig.insert(config_key::cipher, comboBoxVpnCipherText()); - oldConfig.insert(config_key::hash, comboBoxVpnHashText()); - oldConfig.insert(config_key::block_outside_dns, checkBoxBlockDnsChecked()); - oldConfig.insert(config_key::port, lineEditPortText()); - oldConfig.insert(config_key::tls_auth, checkBoxTlsAuthChecked()); - oldConfig.insert(config_key::additional_client_config, textAreaAdditionalClientConfig()); - oldConfig.insert(config_key::additional_server_config, textAreaAdditionalServerConfig()); - return oldConfig; -} - -void OpenVpnLogic::onPushButtonCancelClicked() -{ - emit uiLogic()->pageLogic()->cancelDoInstallAction(true); -} diff --git a/client/ui/pages_logic/protocols/OpenVpnLogic.h b/client/ui/pages_logic/protocols/OpenVpnLogic.h deleted file mode 100644 index db7d3baff..000000000 --- a/client/ui/pages_logic/protocols/OpenVpnLogic.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef OPENVPN_LOGIC_H -#define OPENVPN_LOGIC_H - -#include "PageProtocolLogicBase.h" - -class UiLogic; - -class OpenVpnLogic : public PageProtocolLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, lineEditSubnetText) - - AUTO_PROPERTY(bool, radioButtonTcpEnabled) - AUTO_PROPERTY(bool, radioButtonUdpEnabled) - AUTO_PROPERTY(bool, radioButtonTcpChecked) - AUTO_PROPERTY(bool, radioButtonUdpChecked) - - AUTO_PROPERTY(bool, checkBoxAutoEncryptionChecked) - AUTO_PROPERTY(QString, comboBoxVpnCipherText) - AUTO_PROPERTY(QString, comboBoxVpnHashText) - AUTO_PROPERTY(bool, checkBoxBlockDnsChecked) - AUTO_PROPERTY(QString, lineEditPortText) - AUTO_PROPERTY(bool, checkBoxTlsAuthChecked) - AUTO_PROPERTY(QString, textAreaAdditionalClientConfig) - AUTO_PROPERTY(QString, textAreaAdditionalServerConfig) - - AUTO_PROPERTY(bool, pushButtonSaveVisible) - AUTO_PROPERTY(bool, progressBarResetVisible) - - AUTO_PROPERTY(bool, lineEditPortEnabled) - - AUTO_PROPERTY(bool, labelProtoOpenVpnInfoVisible) - AUTO_PROPERTY(QString, labelProtoOpenVpnInfoText) - AUTO_PROPERTY(int, progressBarResetValue) - AUTO_PROPERTY(int, progressBarResetMaximum) - AUTO_PROPERTY(bool, progressBarTextVisible) - AUTO_PROPERTY(QString, progressBarText) - - AUTO_PROPERTY(bool, labelServerBusyVisible) - AUTO_PROPERTY(QString, labelServerBusyText) - - AUTO_PROPERTY(bool, pushButtonCancelVisible) - - AUTO_PROPERTY(QString, openVpnLastConfigText) - AUTO_PROPERTY(bool, isThirdPartyConfig) - -public: - Q_INVOKABLE void onPushButtonSaveClicked(); - Q_INVOKABLE void onPushButtonCancelClicked(); - -public: - explicit OpenVpnLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~OpenVpnLogic() = default; - - void updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) override; - QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override; - -private: - UiLogic *m_uiLogic; - -}; -#endif // OPENVPN_LOGIC_H diff --git a/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp b/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp deleted file mode 100644 index 965a3baf9..000000000 --- a/client/ui/pages_logic/protocols/OtherProtocolsLogic.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include -#include -#include -#include -#include - -#include "OtherProtocolsLogic.h" -#include -#include "../../uilogic.h" -#include "utilities.h" - -#ifdef Q_OS_WINDOWS -#include -#endif - -using namespace amnezia; -using namespace PageEnumNS; - -OtherProtocolsLogic::OtherProtocolsLogic(UiLogic *logic, QObject *parent): - PageProtocolLogicBase(logic, parent), - m_checkBoxSftpRestoreChecked{false} - -{ - -} - -OtherProtocolsLogic::~OtherProtocolsLogic() -{ -#ifdef Q_OS_WINDOWS - for (QProcess *p: m_sftpMountProcesses) { - if (p) Utils::signalCtrl(p->processId(), CTRL_C_EVENT); - if (p) p->kill(); - if (p) p->waitForFinished(); - if (p) delete p; - } -#endif -} - -void OtherProtocolsLogic::updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData) -{ - set_labelTftpUserNameText(config.value(config_key::userName).toString()); - set_labelTftpPasswordText(config.value(config_key::password).toString(protocols::sftp::defaultUserName)); - set_labelTftpPortText(config.value(config_key::port).toString()); - - set_labelTorWebSiteAddressText(config.value(config_key::site).toString()); - set_pushButtonSftpMountEnabled(true); -} - -#ifdef Q_OS_WINDOWS -QString OtherProtocolsLogic::getNextDriverLetter() const -{ - QProcess drivesProc; - drivesProc.start("wmic logicaldisk get caption"); - drivesProc.waitForFinished(); - QString drives = drivesProc.readAll(); - qDebug() << drives; - - - QString letters = "CFGHIJKLMNOPQRSTUVWXYZ"; - QString letter; - for (int i = letters.size() - 1; i > 0; i--) { - letter = letters.at(i); - if (!drives.contains(letter + ":")) break; - } - if (letter == "C:") { - // set err info - qDebug() << "Can't find free drive letter"; - return ""; - } - return letter; -} -#endif - -//QJsonObject OtherProtocolsLogic::getProtocolConfigFromPage(QJsonObject oldConfig) -//{ - -//} - - -void OtherProtocolsLogic::onPushButtonSftpMountDriveClicked() -{ - QString mountPath; - QString cmd; - QString host = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex).hostName; - - -#ifdef Q_OS_WINDOWS - mountPath = getNextDriverLetter() + ":"; - // QString cmd = QString("net use \\\\sshfs\\%1@x.x.x.x!%2 /USER:%1 %3") - // .arg(labelTftpUserNameText()) - // .arg(labelTftpPortText()) - // .arg(labelTftpPasswordText()); - - cmd = "C:\\Program Files\\SSHFS-Win\\bin\\sshfs.exe"; -#elif defined AMNEZIA_DESKTOP - mountPath = QString("%1/sftp:%2:%3") - .arg(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)) - .arg(host) - .arg(labelTftpPortText()); - QDir dir(mountPath); - if (!dir.exists()){ - dir.mkpath(mountPath); - } - - cmd = "/usr/local/bin/sshfs"; -#endif - -#ifdef AMNEZIA_DESKTOP - set_pushButtonSftpMountEnabled(false); - QProcess *p = new QProcess; - m_sftpMountProcesses.append(p); - p->setProcessChannelMode(QProcess::MergedChannels); - - connect(p, &QProcess::readyRead, this, [this, p, mountPath](){ - QString s = p->readAll(); - if (s.contains("The service sshfs has been started")) { - QDesktopServices::openUrl(QUrl("file:///" + mountPath)); - set_pushButtonSftpMountEnabled(true); - } - qDebug() << s; - }); - - - - p->setProgram(cmd); - - QString args = QString( - "%1@%2:/ %3 " - "-o port=%4 " - "-f " - "-o reconnect " - "-o rellinks " - "-o fstypename=SSHFS " - "-o ssh_command=/usr/bin/ssh.exe " - "-o UserKnownHostsFile=/dev/null " - "-o StrictHostKeyChecking=no " - "-o password_stdin") - .arg(labelTftpUserNameText()) - .arg(host) - .arg(mountPath) - .arg(labelTftpPortText()); - - -// args.replace("\n", " "); -// args.replace("\r", " "); -//#ifndef Q_OS_WIN -// args.replace("reconnect-orellinks", ""); -//#endif - p->setArguments(args.split(" ", Qt::SkipEmptyParts)); - p->start(); - p->waitForStarted(50); - if (p->state() != QProcess::Running) { - qDebug() << "onPushButtonSftpMountDriveClicked process not started"; - qDebug() << args; - } - else { - p->write((labelTftpPasswordText() + "\n").toUtf8()); - } - - //qDebug().noquote() << "onPushButtonSftpMountDriveClicked" << args; - - set_pushButtonSftpMountEnabled(true); -#endif -} - -void OtherProtocolsLogic::checkBoxSftpRestoreClicked() -{ - -} diff --git a/client/ui/pages_logic/protocols/OtherProtocolsLogic.h b/client/ui/pages_logic/protocols/OtherProtocolsLogic.h deleted file mode 100644 index 508c29141..000000000 --- a/client/ui/pages_logic/protocols/OtherProtocolsLogic.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef OTHER_PROTOCOLS_LOGIC_H -#define OTHER_PROTOCOLS_LOGIC_H - -#include "PageProtocolLogicBase.h" - -#include - -class UiLogic; - -class OtherProtocolsLogic : public PageProtocolLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, labelTftpUserNameText) - AUTO_PROPERTY(QString, labelTftpPasswordText) - AUTO_PROPERTY(QString, labelTftpPortText) - AUTO_PROPERTY(bool, pushButtonSftpMountEnabled) - AUTO_PROPERTY(bool, checkBoxSftpRestoreChecked) - - AUTO_PROPERTY(QString, labelTorWebSiteAddressText) - - -public: - Q_INVOKABLE void onPushButtonSftpMountDriveClicked(); - Q_INVOKABLE void checkBoxSftpRestoreClicked(); -public: - explicit OtherProtocolsLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~OtherProtocolsLogic(); - - void updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData) override; - //QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override; - -private: - UiLogic *m_uiLogic; - -#ifdef AMNEZIA_DESKTOP - QList m_sftpMountProcesses; -#endif - -#ifdef Q_OS_WINDOWS - QString getNextDriverLetter() const; -#endif - -}; -#endif // OTHER_PROTOCOLS_LOGIC_H diff --git a/client/ui/pages_logic/protocols/PageProtocolLogicBase.cpp b/client/ui/pages_logic/protocols/PageProtocolLogicBase.cpp deleted file mode 100644 index 62c5aa89b..000000000 --- a/client/ui/pages_logic/protocols/PageProtocolLogicBase.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "PageProtocolLogicBase.h" - - -PageProtocolLogicBase::PageProtocolLogicBase(UiLogic *logic, QObject *parent): - PageLogicBase(logic, parent) -{ - -} diff --git a/client/ui/pages_logic/protocols/PageProtocolLogicBase.h b/client/ui/pages_logic/protocols/PageProtocolLogicBase.h deleted file mode 100644 index ab66f8a95..000000000 --- a/client/ui/pages_logic/protocols/PageProtocolLogicBase.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef PAGE_PROTOCOL_LOGIC_BASE_H -#define PAGE_PROTOCOL_LOGIC_BASE_H - -#include "settings.h" -#include "../PageLogicBase.h" - -using namespace amnezia; -using namespace PageEnumNS; - -class UiLogic; - -class PageProtocolLogicBase : public PageLogicBase -{ - Q_OBJECT - -public: - explicit PageProtocolLogicBase(UiLogic *uiLogic, QObject *parent = nullptr); - ~PageProtocolLogicBase() = default; - - virtual void updateProtocolPage(const QJsonObject &config, DockerContainer container, bool haveAuthData) {} - virtual QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) { return QJsonObject(); } - -}; -#endif // PAGE_PROTOCOL_LOGIC_BASE_H diff --git a/client/ui/pages_logic/protocols/ShadowSocksLogic.cpp b/client/ui/pages_logic/protocols/ShadowSocksLogic.cpp deleted file mode 100644 index f9220a92b..000000000 --- a/client/ui/pages_logic/protocols/ShadowSocksLogic.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "ShadowSocksLogic.h" - -#include - -#include "core/servercontroller.h" -#include "ui/pages_logic/ServerConfiguringProgressLogic.h" -#include "ui/uilogic.h" - -using namespace amnezia; -using namespace PageEnumNS; - -ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent): - PageProtocolLogicBase(logic, parent), - m_comboBoxCipherText{"chacha20-poly1305"}, - m_lineEditPortText{}, - m_pushButtonSaveVisible{false}, - m_progressBarResetVisible{false}, - m_lineEditPortEnabled{false}, - m_labelInfoVisible{true}, - m_labelInfoText{}, - m_progressBarResetValue{0}, - m_progressBarResetMaximum{100} -{ - -} - -void ShadowSocksLogic::updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) -{ - set_pageEnabled(haveAuthData); - set_pushButtonSaveVisible(haveAuthData); - set_progressBarResetVisible(haveAuthData); - - set_comboBoxCipherText(ssConfig.value(config_key::cipher). - toString(protocols::shadowsocks::defaultCipher)); - - set_lineEditPortText(ssConfig.value(config_key::port). - toString(protocols::shadowsocks::defaultPort)); - - set_lineEditPortEnabled(container == DockerContainer::ShadowSocks); -} - -QJsonObject ShadowSocksLogic::getProtocolConfigFromPage(QJsonObject oldConfig) -{ - oldConfig.insert(config_key::cipher, comboBoxCipherText()); - oldConfig.insert(config_key::port, lineEditPortText()); - - return oldConfig; -} - -void ShadowSocksLogic::onPushButtonSaveClicked() -{ - QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, Proto::ShadowSocks); - - QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer); - QJsonObject newContainerConfig = containerConfig; - newContainerConfig.insert(ProtocolProps::protoToString(Proto::ShadowSocks), protocolConfig); - ServerConfiguringProgressLogic::PageFunc pageFunc; - pageFunc.setEnabledFunc = [this] (bool enabled) -> void { - set_pageEnabled(enabled); - }; - ServerConfiguringProgressLogic::ButtonFunc saveButtonFunc; - saveButtonFunc.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonSaveVisible(visible); - }; - ServerConfiguringProgressLogic::LabelFunc waitInfoFunc; - waitInfoFunc.setVisibleFunc = [this] (bool visible) -> void { - set_labelInfoVisible(visible); - }; - waitInfoFunc.setTextFunc = [this] (const QString& text) -> void { - set_labelInfoText(text); - }; - ServerConfiguringProgressLogic::ProgressFunc progressBarFunc; - progressBarFunc.setVisibleFunc = [this] (bool visible) -> void { - set_progressBarResetVisible(visible); - }; - progressBarFunc.setValueFunc = [this] (int value) -> void { - set_progressBarResetValue(value); - }; - progressBarFunc.getValueFunc = [this] (void) -> int { - return progressBarResetValue(); - }; - progressBarFunc.getMaximumFunc = [this] (void) -> int { - return progressBarResetMaximum(); - }; - progressBarFunc.setTextVisibleFunc = [this] (bool visible) -> void { - set_progressBarTextVisible(visible); - }; - progressBarFunc.setTextFunc = [this] (const QString& text) -> void { - set_progressBarText(text); - }; - - ServerConfiguringProgressLogic::LabelFunc busyInfoFuncy; - busyInfoFuncy.setTextFunc = [this] (const QString& text) -> void { - set_labelServerBusyText(text); - }; - busyInfoFuncy.setVisibleFunc = [this] (bool visible) -> void { - set_labelServerBusyVisible(visible); - }; - - ServerConfiguringProgressLogic::ButtonFunc cancelButtonFunc; - cancelButtonFunc.setVisibleFunc = [this] (bool visible) -> void { - set_pushButtonCancelVisible(visible); - }; - - progressBarFunc.setTextVisibleFunc(true); - progressBarFunc.setTextFunc(QString("Configuring...")); - - auto installAction = [this, containerConfig, &newContainerConfig]() { - ServerController serverController(m_settings); - return serverController.updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), - uiLogic()->m_selectedDockerContainer, containerConfig, newContainerConfig); - }; - ErrorCode e = uiLogic()->pageLogic()->doInstallAction(installAction, pageFunc, progressBarFunc, - saveButtonFunc, waitInfoFunc, - busyInfoFuncy, cancelButtonFunc); - - if (!e) { - m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, newContainerConfig); - m_settings->clearLastConnectionConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer); - } - qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->m_selectedServerIndex << uiLogic()->m_selectedDockerContainer; -} - -void ShadowSocksLogic::onPushButtonCancelClicked() -{ - emit uiLogic()->pageLogic()->cancelDoInstallAction(true); -} diff --git a/client/ui/pages_logic/protocols/ShadowSocksLogic.h b/client/ui/pages_logic/protocols/ShadowSocksLogic.h deleted file mode 100644 index bf9269286..000000000 --- a/client/ui/pages_logic/protocols/ShadowSocksLogic.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SHADOWSOCKS_LOGIC_H -#define SHADOWSOCKS_LOGIC_H - -#include "PageProtocolLogicBase.h" - -class UiLogic; - -class ShadowSocksLogic : public PageProtocolLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, comboBoxCipherText) - AUTO_PROPERTY(QString, lineEditPortText) - AUTO_PROPERTY(bool, pushButtonSaveVisible) - AUTO_PROPERTY(bool, progressBarResetVisible) - AUTO_PROPERTY(bool, lineEditPortEnabled) - AUTO_PROPERTY(bool, labelInfoVisible) - AUTO_PROPERTY(QString, labelInfoText) - AUTO_PROPERTY(int, progressBarResetValue) - AUTO_PROPERTY(int, progressBarResetMaximum) - AUTO_PROPERTY(bool, progressBarTextVisible) - AUTO_PROPERTY(QString, progressBarText) - - AUTO_PROPERTY(bool, labelServerBusyVisible) - AUTO_PROPERTY(QString, labelServerBusyText) - - AUTO_PROPERTY(bool, pushButtonCancelVisible) - -public: - Q_INVOKABLE void onPushButtonSaveClicked(); - Q_INVOKABLE void onPushButtonCancelClicked(); - -public: - explicit ShadowSocksLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~ShadowSocksLogic() = default; - - void updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) override; - QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override; - -private: - UiLogic *m_uiLogic; - -}; -#endif // SHADOWSOCKS_LOGIC_H diff --git a/client/ui/pages_logic/protocols/WireGuardLogic.cpp b/client/ui/pages_logic/protocols/WireGuardLogic.cpp deleted file mode 100644 index a6c661f51..000000000 --- a/client/ui/pages_logic/protocols/WireGuardLogic.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "WireGuardLogic.h" -#include "core/servercontroller.h" -#include -#include "../../uilogic.h" - -using namespace amnezia; -using namespace PageEnumNS; - -WireGuardLogic::WireGuardLogic(UiLogic *logic, QObject *parent): - PageProtocolLogicBase(logic, parent) -{ - -} - -void WireGuardLogic::updateProtocolPage(const QJsonObject &wireGuardConfig, DockerContainer container, bool haveAuthData) -{ - qDebug() << "WireGuardLogic::updateProtocolPage"; - - auto lastConfigJsonDoc = QJsonDocument::fromJson(wireGuardConfig.value(config_key::last_config).toString().toUtf8()); - auto lastConfigJson = lastConfigJsonDoc.object(); - - QString wireGuardLastConfigText; - QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n"); - for (const QString &l: lines) { - wireGuardLastConfigText.append(l + "\n"); - } - - set_wireGuardLastConfigText(wireGuardLastConfigText); - set_isThirdPartyConfig(wireGuardConfig.value(config_key::isThirdPartyConfig).toBool()); -} diff --git a/client/ui/pages_logic/protocols/WireGuardLogic.h b/client/ui/pages_logic/protocols/WireGuardLogic.h deleted file mode 100644 index 0b3bfc7b7..000000000 --- a/client/ui/pages_logic/protocols/WireGuardLogic.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WIREGUARDLOGIC_H -#define WIREGUARDLOGIC_H - -#include "PageProtocolLogicBase.h" - -class UiLogic; - -class WireGuardLogic : public PageProtocolLogicBase -{ - Q_OBJECT - - AUTO_PROPERTY(QString, wireGuardLastConfigText) - AUTO_PROPERTY(bool, isThirdPartyConfig) - -public: - explicit WireGuardLogic(UiLogic *uiLogic, QObject *parent = nullptr); - ~WireGuardLogic() = default; - - void updateProtocolPage(const QJsonObject &wireGuardConfig, DockerContainer container, bool haveAuthData) override; - -private: - UiLogic *m_uiLogic; - -}; - -#endif // WIREGUARDLOGIC_H diff --git a/client/ui/qml/Controls/BackButton.qml b/client/ui/qml/Controls/BackButton.qml deleted file mode 100644 index 47f0970ce..000000000 --- a/client/ui/qml/Controls/BackButton.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick -import QtQuick.Controls - -Button { - id: root - x: 10 - y: 5 - width: 41 - height: 35 - - hoverEnabled: true - property bool containsMouse: hovered - - background: Item {} - - MouseArea { - id: mouseArea - anchors.fill: parent - enabled: false - cursorShape: Qt.PointingHandCursor - } - - onClicked: { - UiLogic.closePage() - } - - contentItem: Image { - id: img - source: "qrc:/images/arrow_left.png" - anchors.fill: root - anchors.margins: root.containsMouse ? 9 : 10 - } -} diff --git a/client/ui/qml/Controls/BasicButtonType.qml b/client/ui/qml/Controls/BasicButtonType.qml deleted file mode 100644 index e115df29b..000000000 --- a/client/ui/qml/Controls/BasicButtonType.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick -import QtQuick.Controls - -Button { - id: root - property bool containsMouse: hovered - hoverEnabled: true - flat: true - highlighted: false - - MouseArea { - id: mouseArea - anchors.fill: parent - enabled: false - cursorShape: Qt.PointingHandCursor - } -} diff --git a/client/ui/qml/Controls/BlueButtonType.qml b/client/ui/qml/Controls/BlueButtonType.qml deleted file mode 100644 index a3602c4ab..000000000 --- a/client/ui/qml/Controls/BlueButtonType.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick -import QtQuick.Controls - -import "../Config" - -BasicButtonType { - id: root - width: parent.width - 2 * GC.defaultMargin - implicitHeight: 40 - - background: Rectangle { - anchors.fill: parent - radius: 4 - color: root.enabled ? (root.containsMouse ? "#211966" : "#100A44") : "#888888" - } - font.pixelSize: 16 - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: root.font.pixelSize - color: "#D4D4D4" - text: root.text - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - antialiasing: true -} diff --git a/client/ui/qml/Controls/Caption.qml b/client/ui/qml/Controls/Caption.qml deleted file mode 100644 index 50fc9aca0..000000000 --- a/client/ui/qml/Controls/Caption.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick -import QtQuick.Controls - -Text { - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 24 - color: "#100A44" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - x: 10 - y: 35 - width: parent.width - 40 - anchors.horizontalCenter: parent.horizontalCenter - wrapMode: Text.Wrap - //height: 31 -} diff --git a/client/ui/qml/Controls/CheckBoxType.qml b/client/ui/qml/Controls/CheckBoxType.qml deleted file mode 100644 index 0331706ce..000000000 --- a/client/ui/qml/Controls/CheckBoxType.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick -import QtQuick.Controls - -CheckBox { - id: root - property int imageWidth : 20 - property int imageHeight : 20 - indicator: Image { - id: indicator - anchors.verticalCenter: root.verticalCenter - height: imageHeight - width: imageWidth - source: root.checked ? "qrc:/images/controls/check_on.png" - : "qrc:/images/controls/check_off.png" - } - - contentItem: Text { - text: root.text - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - verticalAlignment: Text.AlignVCenter - leftPadding: root.indicator.width + root.spacing - wrapMode: Text.Wrap - } -} diff --git a/client/ui/qml/Controls/ComboBoxType.qml b/client/ui/qml/Controls/ComboBoxType.qml deleted file mode 100644 index 090ca9de8..000000000 --- a/client/ui/qml/Controls/ComboBoxType.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick -import QtQuick.Controls - -ComboBox { - id: root - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - - popup.font.pixelSize: 16 -} diff --git a/client/ui/qml/Controls/ContextMenu.qml b/client/ui/qml/Controls/ContextMenu.qml deleted file mode 100644 index 867fcb106..000000000 --- a/client/ui/qml/Controls/ContextMenu.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick -import QtQuick.Controls -import Qt.labs.platform - -Menu { - property var textObj - - MenuItem { - text: qsTr("C&ut") - shortcut: StandardKey.Cut - enabled: textObj.selectedText - onTriggered: textObj.cut() - } - MenuItem { - text: qsTr("&Copy") - shortcut: StandardKey.Copy - enabled: textObj.selectedText - onTriggered: textObj.copy() - } - MenuItem { - text: qsTr("&Paste") - shortcut: StandardKey.Paste - enabled: textObj.canPaste - onTriggered: textObj.paste() - } - - MenuItem { - text: qsTr("&SelectAll") - shortcut: StandardKey.SelectAll - enabled: textObj.length > 0 - onTriggered: textObj.selectAll() - } -} diff --git a/client/ui/qml/Controls/FadeBehavior.qml b/client/ui/qml/Controls/FadeBehavior.qml deleted file mode 100644 index e523061f8..000000000 --- a/client/ui/qml/Controls/FadeBehavior.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick -import QtQml - -Behavior { - id: root - - property QtObject fadeTarget: targetProperty.object - property string fadeProperty: "scale" - property int fadeDuration: 150 - property string easingType: "Quad" - - property alias outAnimation: outAnimation - property alias inAnimation: inAnimation - - SequentialAnimation { - NumberAnimation { - id: outAnimation - target: root.fadeTarget - property: root.fadeProperty - duration: root.fadeDuration - to: 0 - easing.type: Easing["In"+root.easingType] - } - PropertyAction { } - NumberAnimation { - id: inAnimation - target: root.fadeTarget - property: root.fadeProperty - duration: root.fadeDuration - to: target[property] - easing.type: Easing["Out"+root.easingType] - } - } - -} diff --git a/client/ui/qml/Controls/FlickableType.qml b/client/ui/qml/Controls/FlickableType.qml deleted file mode 100644 index 79bfabfdd..000000000 --- a/client/ui/qml/Controls/FlickableType.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import "../Config" - -Flickable { - id: fl - - clip: true - width: parent.width - - anchors.topMargin: GC.defaultMargin - anchors.bottom: parent.bottom - anchors.bottomMargin: GC.defaultMargin - anchors.left: root.left - anchors.leftMargin: GC.defaultMargin - anchors.right: root.right - anchors.rightMargin: 1 - - Keys.onUpPressed: scrollBar.decrease() - Keys.onDownPressed: scrollBar.increase() - - ScrollBar.vertical: ScrollBar { - id: scrollBar - policy: fl.height >= fl.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn - } -} diff --git a/client/ui/qml/Controls/ImageButtonType.qml b/client/ui/qml/Controls/ImageButtonType.qml deleted file mode 100644 index 74b90c6e5..000000000 --- a/client/ui/qml/Controls/ImageButtonType.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick -import QtQuick.Controls - -BasicButtonType { - id: root - property alias iconMargin: img.anchors.margins - property alias img: img - property int imgMargin: 4 - property int imgMarginHover: 3 - background: Item {} - contentItem: Image { - id: img - source: root.icon.source - anchors.fill: root - anchors.margins: root.containsMouse ? imgMarginHover : imgMargin - } -} diff --git a/client/ui/qml/Controls/LabelType.qml b/client/ui/qml/Controls/LabelType.qml deleted file mode 100644 index 9cce61b1b..000000000 --- a/client/ui/qml/Controls/LabelType.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick -import "../Config" - -Text { - id: root - width: parent.width - 2 * GC.defaultMargin - anchors.topMargin: 10 - - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap -} - diff --git a/client/ui/qml/Controls/Logo.qml b/client/ui/qml/Controls/Logo.qml deleted file mode 100644 index 74d828724..000000000 --- a/client/ui/qml/Controls/Logo.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick -import QtQuick.Controls - -Image { - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottomMargin: 30 - source: "qrc:/images/AmneziaVPN.png" -} diff --git a/client/ui/qml/Controls/PopupWarning.qml b/client/ui/qml/Controls/PopupWarning.qml deleted file mode 100644 index 57c332ebe..000000000 --- a/client/ui/qml/Controls/PopupWarning.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -Popup { - id: root - - property string popupWarningText - - anchors.centerIn: Overlay.overlay - modal: true - closePolicy: Popup.NoAutoClose - width: parent.width - 20 - - ColumnLayout { - width: parent.width - Text { - horizontalAlignment: Text.AlignHCenter - Layout.fillWidth: true - wrapMode: Text.WordWrap - font.pixelSize: 16 - text: root.popupWarningText - } - - BlueButtonType { - Layout.preferredWidth: parent.width / 2 - Layout.fillWidth: true - text: "Continue" - onClicked: { - root.close() - } - } - } -} diff --git a/client/ui/qml/Controls/PopupWithQuestion.qml b/client/ui/qml/Controls/PopupWithQuestion.qml deleted file mode 100644 index b55edf903..000000000 --- a/client/ui/qml/Controls/PopupWithQuestion.qml +++ /dev/null @@ -1,62 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -Popup { - id: root - - property string questionText - property string yesText: "yes" - property string noText: "no" - property var yesFunc - property var noFunc - - anchors.centerIn: Overlay.overlay - modal: true - closePolicy: Popup.CloseOnEscape - - width: parent.width - 20 - focus: true - - onAboutToHide: { - parent.forceActiveFocus(true) - } - - ColumnLayout { - width: parent.width - - Text { - horizontalAlignment: Text.AlignHCenter - Layout.fillWidth: true - wrapMode: Text.WordWrap - font.pixelSize: 16 - text: questionText - } - - RowLayout { - Layout.fillWidth: true - BlueButtonType { - id: yesButton - Layout.fillWidth: true - text: yesText - onClicked: { - root.enabled = false - if (yesFunc && typeof yesFunc === "function") { - yesFunc() - } - root.enabled = true - } - } - BlueButtonType { - id: noButton - Layout.fillWidth: true - text: noText - onClicked: { - if (noFunc && typeof noFunc === "function") { - noFunc() - } - } - } - } - } -} diff --git a/client/ui/qml/Controls/PopupWithTextField.qml b/client/ui/qml/Controls/PopupWithTextField.qml deleted file mode 100644 index acdf12478..000000000 --- a/client/ui/qml/Controls/PopupWithTextField.qml +++ /dev/null @@ -1,62 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -Popup { - id: root - - property alias text: textField.text - property alias placeholderText: textField.placeholderText - property string yesText: "yes" - property string noText: "no" - property var yesFunc - property var noFunc - - signal editingFinished() - - anchors.centerIn: Overlay.overlay - modal: true - closePolicy: Popup.NoAutoClose - - width: parent.width - 20 - - ColumnLayout { - width: parent.width - - TextField { - id: textField - horizontalAlignment: Text.AlignHCenter - Layout.fillWidth: true - font.pixelSize: 16 - echoMode: TextInput.Password - } - - RowLayout { - Layout.fillWidth: true - BlueButtonType { - id: yesButton - Layout.preferredWidth: parent.width / 2 - Layout.fillWidth: true - text: yesText - onClicked: { - root.enabled = false - if (yesFunc && typeof yesFunc === "function") { - yesFunc() - } - root.enabled = true - } - } - BlueButtonType { - id: noButton - Layout.preferredWidth: parent.width / 2 - Layout.fillWidth: true - text: noText - onClicked: { - if (noFunc && typeof noFunc === "function") { - noFunc() - } - } - } - } - } -} diff --git a/client/ui/qml/Controls/RadioButtonType.qml b/client/ui/qml/Controls/RadioButtonType.qml deleted file mode 100644 index cda28ea5c..000000000 --- a/client/ui/qml/Controls/RadioButtonType.qml +++ /dev/null @@ -1,36 +0,0 @@ -import QtQuick -import QtQuick.Controls - -RadioButton { - id: root - - indicator: Rectangle { - implicitWidth: 13 - implicitHeight: 13 - x: root.leftPadding - y: parent.height / 2 - height / 2 - radius: 13 - border.color: root.down ? "#777777" : "#777777" - - Rectangle { - width: 7 - height: 7 - x: 3 - y: 3 - radius: 4 - color: root.down ? "#15CDCB" : "#15CDCB" - visible: root.checked - } - } - - contentItem: Text { - text: root.text - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: enabled ? "#181922" : "#686972" - verticalAlignment: Text.AlignVCenter - leftPadding: root.indicator.width + root.spacing - } - height: 10 -} diff --git a/client/ui/qml/Controls/RichLabelType.qml b/client/ui/qml/Controls/RichLabelType.qml deleted file mode 100644 index f354f974c..000000000 --- a/client/ui/qml/Controls/RichLabelType.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick - -LabelType { - id: label_connection_code - width: parent.width - 60 - x: 30 - font.pixelSize: 14 - textFormat: Text.RichText - onLinkActivated: Qt.openUrlExternally(link) - - MouseArea { - anchors.fill: parent - cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor - acceptedButtons: Qt.NoButton - } -} - diff --git a/client/ui/qml/Controls/SettingButtonType.qml b/client/ui/qml/Controls/SettingButtonType.qml deleted file mode 100644 index 6166793d2..000000000 --- a/client/ui/qml/Controls/SettingButtonType.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick -import QtQuick.Controls - -BasicButtonType { - id: root - property alias textItem: textItem - height: 30 - - background: Item {} - contentItem: Item { - SvgImageType { - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - svg.source: root.icon.source - enabled: root.enabled - color: "#100A44" - width: 25 - height: 25 - } - Text { - id: textItem - anchors.fill: parent - leftPadding: 30 - text: root.text - color: root.enabled ? "#100A44": "#AAAAAA" - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 20 - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } - } -} diff --git a/client/ui/qml/Controls/ShareConnectionButtonCopyType.qml b/client/ui/qml/Controls/ShareConnectionButtonCopyType.qml deleted file mode 100644 index 31b3591e5..000000000 --- a/client/ui/qml/Controls/ShareConnectionButtonCopyType.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick -import QtQuick.Controls - -ShareConnectionButtonType { - property string start_text: qsTr("Copy") - property string end_text: qsTr("Copied") - - property string copyText - - enabled: copyText.length > 0 - visible: copyText.length > 0 - - Timer { - id: timer - interval: 1000; running: false; repeat: false - onTriggered: text = start_text - } - - text: start_text - - onClicked: { - text = end_text - timer.running = true - UiLogic.copyToClipboard(copyText) - } -} diff --git a/client/ui/qml/Controls/ShareConnectionButtonType.qml b/client/ui/qml/Controls/ShareConnectionButtonType.qml deleted file mode 100644 index 77ebbac07..000000000 --- a/client/ui/qml/Controls/ShareConnectionButtonType.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick -import QtQuick.Controls - - -BasicButtonType { - id: root - height: 40 - background: Rectangle { - anchors.fill: parent - radius: 4 - color: root.enabled - ? (root.containsMouse ? "#282932" : "#181922") - : "#484952" - } - font.pixelSize: 16 - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: root.font.pixelSize - color: "#D4D4D4" - text: root.text - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - antialiasing: true -} diff --git a/client/ui/qml/Controls/ShareConnectionContent.qml b/client/ui/qml/Controls/ShareConnectionContent.qml deleted file mode 100644 index 99427aef5..000000000 --- a/client/ui/qml/Controls/ShareConnectionContent.qml +++ /dev/null @@ -1,65 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Shapes 1.4 - -Item { - id: root - property bool active: false - property string text: "" - height: active ? contentLoader.item.height + 40 + 5 * 2 : 40 - signal clicked() - - Rectangle { - x: 0 - y: 0 - width: parent.width - height: 40 - color: "transparent" - clip: true - radius: 2 - gradient: LinearGradient { - x1: 0 ; y1: 0 - x2: 0 ; y2: height - stops: [ - GradientStop { position: 0.0; color: "#E1E1E1" }, - GradientStop { position: 0.4; color: "#DDDDDD" }, - GradientStop { position: 0.5; color: "#D8D8D8" }, - GradientStop { position: 1.0; color: "#D3D3D3" } - ] - } - Image { - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 10 - source: "qrc:/images/share.png" - } - Rectangle { - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 2 - color: "#148CD2" - visible: ms.containsMouse ? true : false - } - Text { - x: 40 - anchors.verticalCenter: parent.verticalCenter - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 18 - color: "#100A44" - font.bold: true - text: root.text - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - } - MouseArea { - id: ms - anchors.fill: parent - hoverEnabled: true - onClicked: root.clicked() - } - } -} - diff --git a/client/ui/qml/Controls/SvgButtonType.qml b/client/ui/qml/Controls/SvgButtonType.qml deleted file mode 100644 index e6f78c875..000000000 --- a/client/ui/qml/Controls/SvgButtonType.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick -import QtQuick.Controls -import "." - -BasicButtonType { - id: root - icon.color: "#181922" - - background: Item {} - contentItem: SvgImageType { - svg.source: icon.source - color: icon.color - anchors.fill: parent - anchors.margins: parent.containsMouse ? 0 : 1 - } -} diff --git a/client/ui/qml/Controls/SvgImageType.qml b/client/ui/qml/Controls/SvgImageType.qml deleted file mode 100644 index aee928ba0..000000000 --- a/client/ui/qml/Controls/SvgImageType.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick -import QtQuick.Controls -import Qt5Compat.GraphicalEffects - -Item { - id: root - property color color: "#181922" - property alias svg: image - Image { - anchors.fill: parent - id: image - sourceSize: Qt.size(root.width, root.height) - - antialiasing: true - visible: false - } - - ColorOverlay { - anchors.fill: image - source: image - color: root.enabled ? root.color : "grey" - } -} diff --git a/client/ui/qml/Controls/TextAreaType.qml b/client/ui/qml/Controls/TextAreaType.qml deleted file mode 100644 index 2f6e08433..000000000 --- a/client/ui/qml/Controls/TextAreaType.qml +++ /dev/null @@ -1,63 +0,0 @@ -import QtQuick -import QtQuick.Controls -import Qt.labs.platform - -import "../Config" - -Flickable -{ - property alias textArea: root - id: flickable - flickableDirection: Flickable.VerticalFlick - clip: true - TextArea.flickable: - - TextArea { - id: root - property bool error: false - - height: 40 - anchors.topMargin: 5 - selectByMouse: false - - selectionColor: "darkgray" - font.pixelSize: 16 - color: "#333333" - background: Rectangle { - implicitWidth: 200 - implicitHeight: 40 - border.width: 1 - color: { - if (root.error) { - return Qt.rgba(213, 40, 60, 255) - } - return root.enabled ? "#F4F4F4" : Qt.rgba(127, 127, 127, 255) - } - border.color: { - if (!root.enabled) { - return Qt.rgba(127, 127, 127, 255) - } - if (root.error) { - return Qt.rgba(213, 40, 60, 255) - } - if (root.focus) { - return "#A7A7A7" - } - return "#A7A7A7" - } - } - -// MouseArea { -// anchors.fill: root -// enabled: GC.isDesktop() -// acceptedButtons: Qt.RightButton -// onClicked: contextMenu.open() -// } - -// ContextMenu { -// id: contextMenu -// textObj: root -// } - } - -} diff --git a/client/ui/qml/Controls/TextFieldType.qml b/client/ui/qml/Controls/TextFieldType.qml deleted file mode 100644 index 5d7b2a651..000000000 --- a/client/ui/qml/Controls/TextFieldType.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick -import QtQuick.Controls -import Qt.labs.platform -import "../Config" - -TextField { - id: root - property bool error: false - - width: parent.width - 2 * GC.defaultMargin - height: 40 - anchors.topMargin: 5 - selectByMouse: true - selectionColor: "darkgray" - font.pixelSize: 16 - color: "#333333" - - background: Rectangle { - implicitWidth: 200 - implicitHeight: 40 - border.width: 1 - color: { - if (root.error) { - return Qt.rgba(213, 40, 60, 255) - } - return root.enabled ? "#F4F4F4" : Qt.rgba(127, 127, 127, 255) - } - border.color: { - if (!root.enabled) { - return Qt.rgba(127, 127, 127, 255) - } - if (root.error) { - return Qt.rgba(213, 40, 60, 255) - } - if (root.focus) { - return "#A7A7A7" - } - return "#A7A7A7" - } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.RightButton - onClicked: contextMenu.open() - } - - ContextMenu { - id: contextMenu - textObj: root - } -} diff --git a/client/ui/qml/Controls/UrlButtonType.qml b/client/ui/qml/Controls/UrlButtonType.qml deleted file mode 100644 index d77763dc0..000000000 --- a/client/ui/qml/Controls/UrlButtonType.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 - -BasicButtonType { - property alias label: lbl - id: root - antialiasing: true - height: 21 - background: Item {} - - contentItem: Text { - id: lbl - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 18 - font.underline: true - - text: root.text - color: "#3045ee" - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } -} diff --git a/client/ui/qml/Controls/VisibleBehavior.qml b/client/ui/qml/Controls/VisibleBehavior.qml deleted file mode 100644 index 9aeb4e858..000000000 --- a/client/ui/qml/Controls/VisibleBehavior.qml +++ /dev/null @@ -1,6 +0,0 @@ -FadeBehavior { - fadeProperty: "opacity" - fadeDuration: 200 - outAnimation.duration: targetValue ? 0 : fadeDuration - inAnimation.duration: targetValue ? fadeDuration : 0 -} diff --git a/client/ui/qml/Pages/ClientInfo/PageClientInfoBase.qml b/client/ui/qml/Pages/ClientInfo/PageClientInfoBase.qml deleted file mode 100644 index 7fde5bab7..000000000 --- a/client/ui/qml/Pages/ClientInfo/PageClientInfoBase.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageBase { - id: root - property var protocol: ProtocolEnum.Any - page: PageEnum.ClientInfo - logic: ClientInfoLogic -} diff --git a/client/ui/qml/Pages/ClientInfo/PageClientInfoOpenVPN.qml b/client/ui/qml/Pages/ClientInfo/PageClientInfoOpenVPN.qml deleted file mode 100644 index da5ba53c9..000000000 --- a/client/ui/qml/Pages/ClientInfo/PageClientInfoOpenVPN.qml +++ /dev/null @@ -1,115 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageClientInfoBase { - id: root - protocol: ProtocolEnum.OpenVpn - - BackButton { - id: back - enabled: !ClientInfoLogic.busyIndicatorIsRunning - } - - Caption { - id: caption - text: qsTr("Client Info") - } - - BusyIndicator { - z: 99 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - visible: ClientInfoLogic.busyIndicatorIsRunning - running: ClientInfoLogic.busyIndicatorIsRunning - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - visible: ClientInfoLogic.pageContentVisible - - ColumnLayout { - id: content - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: GC.defaultMargin - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - font.pixelSize: 20 - horizontalAlignment: Text.AlignHCenter - text: ClientInfoLogic.labelCurrentVpnProtocolText - } - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - height: 21 - text: qsTr("Client name") - } - - TextFieldType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - Layout.preferredHeight: 31 - text: ClientInfoLogic.lineEditNameAliasText - onEditingFinished: { - if (text !== ClientInfoLogic.lineEditNameAliasText) { - ClientInfoLogic.lineEditNameAliasText = text - ClientInfoLogic.onLineEditNameAliasEditingFinished() - } - } - } - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.topMargin: 20 - height: 21 - text: qsTr("Certificate id") - } - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - text: ClientInfoLogic.labelOpenVpnCertId - } - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.topMargin: 20 - height: 21 - text: qsTr("Certificate") - } - - TextAreaType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.preferredHeight: 200 - Layout.fillWidth: true - - textArea.readOnly: true - textArea.wrapMode: TextEdit.WrapAnywhere - textArea.verticalAlignment: Text.AlignTop - textArea.text: ClientInfoLogic.textAreaOpenVpnCertData - } - - BlueButtonType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - Layout.preferredHeight: 41 - text: qsTr("Revoke Certificate") - onClicked: { - ClientInfoLogic.onRevokeOpenVpnCertificateClicked() - UiLogic.closePage() - } - } - } - } -} diff --git a/client/ui/qml/Pages/ClientInfo/PageClientInfoWireGuard.qml b/client/ui/qml/Pages/ClientInfo/PageClientInfoWireGuard.qml deleted file mode 100644 index befaf7f8b..000000000 --- a/client/ui/qml/Pages/ClientInfo/PageClientInfoWireGuard.qml +++ /dev/null @@ -1,100 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageClientInfoBase { - id: root - protocol: ProtocolEnum.WireGuard - - BackButton { - id: back - enabled: !ClientInfoLogic.busyIndicatorIsRunning - } - - Caption { - id: caption - text: qsTr("Client Info") - } - - BusyIndicator { - z: 99 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - visible: ClientInfoLogic.busyIndicatorIsRunning - running: ClientInfoLogic.busyIndicatorIsRunning - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: GC.defaultMargin - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - font.pixelSize: 20 - horizontalAlignment: Text.AlignHCenter - text: ClientInfoLogic.labelCurrentVpnProtocolText - } - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - height: 21 - text: qsTr("Client name") - } - - TextFieldType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - Layout.preferredHeight: 31 - text: ClientInfoLogic.lineEditNameAliasText - onEditingFinished: { - if (text !== ClientInfoLogic.lineEditNameAliasText) { - ClientInfoLogic.lineEditNameAliasText = text - ClientInfoLogic.onLineEditNameAliasEditingFinished() - } - } - } - - LabelType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.topMargin: 20 - height: 21 - text: qsTr("Public Key") - } - - TextAreaType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.preferredHeight: 200 - Layout.fillWidth: true - - textArea.readOnly: true - textArea.wrapMode: TextEdit.WrapAnywhere - textArea.verticalAlignment: Text.AlignTop - textArea.text: ClientInfoLogic.textAreaWireGuardKeyData - } - - BlueButtonType { - enabled: !ClientInfoLogic.busyIndicatorIsRunning - Layout.fillWidth: true - Layout.preferredHeight: 41 - text: qsTr("Revoke Key") - onClicked: { - ClientInfoLogic.onRevokeWireGuardKeyClicked() - UiLogic.closePage() - } - } - } - } -} diff --git a/client/ui/qml/Pages/InstallSettings/InstallSettingsBase.qml b/client/ui/qml/Pages/InstallSettings/InstallSettingsBase.qml deleted file mode 100644 index 8e04c605d..000000000 --- a/client/ui/qml/Pages/InstallSettings/InstallSettingsBase.qml +++ /dev/null @@ -1,75 +0,0 @@ -import QtQuick -import QtQuick.Controls -import "./" -import "../../Controls" -import "../../Config" - -Rectangle { - signal containerChecked(bool checked) - property bool initiallyChecked: false - property string containerDescription - default property alias itemSettings: container.data - - x: 5 - y: 5 - width: parent.width - 20 - anchors.horizontalCenter: parent.horizontalCenter - - height: frame_settings.visible ? 140 : 72 - border.width: 1 - border.color: "lightgray" - radius: 2 - Rectangle { - id: frame_settings - height: 77 - width: parent.width - border.width: 1 - border.color: "lightgray" - anchors.bottom: parent.bottom - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - visible: false - radius: 2 - Grid { - id: container - anchors.fill: parent - columns: 2 - horizontalItemAlignment: Grid.AlignHCenter - verticalItemAlignment: Grid.AlignVCenter - topPadding: 5 - leftPadding: 10 - spacing: 5 - } - } - Row { - anchors.top: parent.top - anchors.topMargin: 5 - leftPadding: 15 - rightPadding: 5 - height: 55 - width: parent.width - CheckBoxType { - text: containerDescription - height: parent.height - width: parent.width - 50 - checked: initiallyChecked - onCheckedChanged: containerChecked(checked) - } - ImageButtonType { - width: 35 - height: 35 - anchors.verticalCenter: parent.verticalCenter - icon.source: "qrc:/images/settings.png" - checkable: true - checked: initiallyChecked - onCheckedChanged: { - //NewServerProtocolsLogic.pushButtonSettingsCloakChecked = checked - if (checked) { - frame_settings.visible = true - } else { - frame_settings.visible = false - } - } - } - } -} diff --git a/client/ui/qml/Pages/InstallSettings/SelectContainer.qml b/client/ui/qml/Pages/InstallSettings/SelectContainer.qml deleted file mode 100644 index 59e8f4646..000000000 --- a/client/ui/qml/Pages/InstallSettings/SelectContainer.qml +++ /dev/null @@ -1,200 +0,0 @@ -import QtQuick -import QtQuick.Controls -import SortFilterProxyModel 0.2 -import ProtocolEnum 1.0 -import "./" -import "../../Controls" -import "../../Config" - -Drawer { - id: root - signal containerSelected(int c_index) - property int selectedIndex: -1 - - y: 0 - x: 0 - edge: Qt.RightEdge - width: parent.width * 0.85 - height: parent.height - - modal: true - interactive: activeFocus - - SortFilterProxyModel { - id: proxyModel - sourceModel: UiLogic.containersModel - filters: [ - ValueFilter { - roleName: "is_installed_role" - value: false }, - ValueFilter { - roleName: "service_type_role" - value: ProtocolEnum.Vpn } - ] - - } - - SortFilterProxyModel { - id: proxyModel_other - sourceModel: UiLogic.containersModel - filters: [ - ValueFilter { - roleName: "is_installed_role" - value: false }, - ValueFilter { - roleName: "service_type_role" - value: ProtocolEnum.Other } - ] - - } - - FlickableType { - anchors.fill: parent - contentHeight: col.height - - Column { - id: col - anchors { - left: parent.left; - right: parent.right; - } - topPadding: 20 - spacing: 10 - - Caption { - id: cap1 - text: qsTr("VPN containers") - font.pixelSize: 20 - - } - - ListView { - id: tb - x: 10 - currentIndex: -1 - width: parent.width - 20 - height: contentItem.height - - spacing: 0 - clip: true - interactive: false - model: proxyModel - - delegate: Item { - implicitWidth: 170 * 2 - implicitHeight: 30 - Item { - width: parent.width - height: 30 - anchors.left: parent.left - id: c1 - Rectangle { - anchors.top: parent.top - width: parent.width - height: 1 - color: "lightgray" - visible: index !== tb.currentIndex - } - Rectangle { - anchors.fill: parent - color: "#63B4FB" - visible: index === tb.currentIndex - - } - Text { - id: text_name - text: name_role - font.pixelSize: 16 - anchors.fill: parent - leftPadding: 10 - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - } - } - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - tb.currentIndex = index - tb_other.currentIndex = -1 - containerSelected(proxyModel.mapToSource(index)) - selectedIndex = proxyModel.mapToSource(index) - root.close() - } - } - } - } - - - Caption { - id: cap2 - font.pixelSize: 20 - text: qsTr("Other containers") - } - - ListView { - id: tb_other - x: 10 - currentIndex: -1 - width: parent.width - 20 - height: contentItem.height - - spacing: 0 - clip: true - interactive: false - model: proxyModel_other - - delegate: Item { - implicitWidth: 170 * 2 - implicitHeight: 30 - Item { - width: parent.width - height: 30 - anchors.left: parent.left - id: c1_other - Rectangle { - anchors.top: parent.top - width: parent.width - height: 1 - color: "lightgray" - visible: index !== tb_other.currentIndex - } - Rectangle { - anchors.fill: parent - color: "#63B4FB" - visible: index === tb_other.currentIndex - - } - Text { - id: text_name_other - text: name_role - font.pixelSize: 16 - anchors.fill: parent - leftPadding: 10 - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - } - } - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - tb_other.currentIndex = index - tb.currentIndex = -1 - containerSelected(proxyModel_other.mapToSource(index)) - selectedIndex = proxyModel_other.mapToSource(index) - root.close() - } - } - } - } - - - } - - - } - -} diff --git a/client/ui/qml/Pages/PageAbout.qml b/client/ui/qml/Pages/PageAbout.qml deleted file mode 100644 index ab25c23e3..000000000 --- a/client/ui/qml/Pages/PageAbout.qml +++ /dev/null @@ -1,90 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.About - - BackButton { - id: back_from_start - } - - Caption { - id: caption - font.pixelSize: 22 - text: qsTr("About Amnezia") - } - - RichLabelType { - id: label_about - anchors.top: caption.bottom - - text: qsTr("AmneziaVPN is opensource software, it's free forever. Our goal is to make the best VPN client in the world. -

-") - } - - Caption { - id: caption2 - anchors.topMargin: 20 - font.pixelSize: 22 - text: qsTr("Support") - anchors.top: label_about.bottom - } - - RichLabelType { - id: label_support - anchors.top: caption2.bottom - - text: qsTr("Have questions? You can get support by: -") - } - - Caption { - id: caption3 - anchors.topMargin: 20 - font.pixelSize: 22 - text: qsTr("Donate") - width: undefined - anchors.top: label_support.bottom - } - - LabelType { - anchors.bottom: caption3.bottom - anchors.left: caption3.right - anchors.leftMargin: 5 - font.pixelSize: 24 - text: "♥" - color: "red" - } - - RichLabelType { - id: label_donate - anchors.top: caption3.bottom - - text: qsTr("Please support Amnezia project by donation, we really need it now more than ever. - -") - } - - Logo { - id: logo - anchors.bottom: parent.bottom - } -} diff --git a/client/ui/qml/Pages/PageAdvancedServerSettings.qml b/client/ui/qml/Pages/PageAdvancedServerSettings.qml deleted file mode 100644 index 9f71b2baf..000000000 --- a/client/ui/qml/Pages/PageAdvancedServerSettings.qml +++ /dev/null @@ -1,118 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.AdvancedServerSettings - logic: AdvancedServerSettingsLogic - - enabled: AdvancedServerSettingsLogic.pageEnabled - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Advanced server settings") - anchors.horizontalCenter: parent.horizontalCenter - } - - BusyIndicator { - z: 99 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - visible: !AdvancedServerSettingsLogic.pageEnabled - running: !AdvancedServerSettingsLogic.pageEnabled - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: logo.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - Layout.fillWidth: true - font.pixelSize: 20 - horizontalAlignment: Text.AlignHCenter - text: AdvancedServerSettingsLogic.labelCurrentVpnProtocolText - } - - TextFieldType { - Layout.fillWidth: true - font.pixelSize: 20 - horizontalAlignment: Text.AlignHCenter - text: AdvancedServerSettingsLogic.labelServerText - readOnly: true - background: Item {} - } - - LabelType { - Layout.fillWidth: true - horizontalAlignment: Text.AlignHCenter - text: AdvancedServerSettingsLogic.labelWaitInfoText - visible: AdvancedServerSettingsLogic.labelWaitInfoVisible - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - text: "Scan the server for installed containers" - visible: AdvancedServerSettingsLogic.pushButtonClearVisible - onClicked: { - AdvancedServerSettingsLogic.onPushButtonScanServerClicked() - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - text: AdvancedServerSettingsLogic.pushButtonClearText - visible: AdvancedServerSettingsLogic.pushButtonClearVisible - onClicked: { - popupClearServer.open() - } - } - - BlueButtonType { - Layout.topMargin: 10 - Layout.fillWidth: true - text: qsTr("Clients Management") - onClicked: { - UiLogic.goToPage(PageEnum.ClientManagement) - } - } - - PopupWithQuestion { - id: popupClearServer - questionText: "Attention! All containers will be deleted on the server. This means that configuration files, keys and certificates will be deleted. Continue?" - yesFunc: function() { - close() - AdvancedServerSettingsLogic.onPushButtonClearServerClicked() - } - noFunc: function() { - close() - } - } - } - } - - Logo { - id : logo - anchors.bottom: parent.bottom - } -} diff --git a/client/ui/qml/Pages/PageAppSetting.qml b/client/ui/qml/Pages/PageAppSetting.qml deleted file mode 100644 index 2bf0e306d..000000000 --- a/client/ui/qml/Pages/PageAppSetting.qml +++ /dev/null @@ -1,152 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.AppSettings - logic: AppSettingsLogic - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Application Settings") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - CheckBoxType { - visible: !GC.isMobile() - Layout.fillWidth: true - text: qsTr("Auto connect") - checked: AppSettingsLogic.checkBoxAutoConnectChecked - onCheckedChanged: { - AppSettingsLogic.checkBoxAutoConnectChecked = checked - AppSettingsLogic.onCheckBoxAutoconnectToggled(checked) - } - } - CheckBoxType { - visible: !GC.isMobile() - Layout.fillWidth: true - text: qsTr("Auto start") - checked: AppSettingsLogic.checkBoxAutostartChecked - onCheckedChanged: { - AppSettingsLogic.checkBoxAutostartChecked = checked - AppSettingsLogic.onCheckBoxAutostartToggled(checked) - } - } - CheckBoxType { - visible: !GC.isMobile() - Layout.fillWidth: true - text: qsTr("Start minimized") - checked: AppSettingsLogic.checkBoxStartMinimizedChecked - onCheckedChanged: { - AppSettingsLogic.checkBoxStartMinimizedChecked = checked - AppSettingsLogic.onCheckBoxStartMinimizedToggled(checked) - } - } - LabelType { - Layout.fillWidth: true - Layout.topMargin: 15 - text: AppSettingsLogic.labelVersionText - } - BlueButtonType { - visible: !GC.isMobile() - Layout.fillWidth: true - text: qsTr("Check for updates") - onClicked: { - Qt.openUrlExternally("https://github.com/amnezia-vpn/desktop-client/releases/latest") - } - } - - CheckBoxType { - Layout.fillWidth: true - Layout.topMargin: 15 - text: qsTr("Keep logs") - checked: AppSettingsLogic.checkBoxSaveLogsChecked - onCheckedChanged: { - AppSettingsLogic.checkBoxSaveLogsChecked = checked - AppSettingsLogic.onCheckBoxSaveLogsCheckedToggled(checked) - } - } - BlueButtonType { - Layout.fillWidth: true - text: qsTr("Open logs folder") - onClicked: { - AppSettingsLogic.onPushButtonOpenLogsClicked() - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - text: qsTr("Export logs") - onClicked: { - AppSettingsLogic.onPushButtonExportLogsClicked() - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - - property string start_text: qsTr("Clear logs") - property string end_text: qsTr("Cleared") - text: start_text - - Timer { - id: timer - interval: 1000; running: false; repeat: false - onTriggered: parent.text = parent.start_text - } - onClicked: { - text = end_text - timer.running = true - AppSettingsLogic.onPushButtonClearLogsClicked() - } - } - - LabelType { - Layout.fillWidth: true - Layout.topMargin: 30 - text: qsTr("Backup and restore configuration") - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - Layout.preferredHeight: 41 - text: qsTr("Backup app config") - onClicked: { - AppSettingsLogic.onPushButtonBackupAppConfigClicked() - } - } - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - Layout.preferredHeight: 41 - text: qsTr("Restore app config") - onClicked: { - AppSettingsLogic.onPushButtonRestoreAppConfigClicked() - } - } - } - } -} diff --git a/client/ui/qml/Pages/PageBase.qml b/client/ui/qml/Pages/PageBase.qml deleted file mode 100644 index c398515b4..000000000 --- a/client/ui/qml/Pages/PageBase.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -Item { - id: root - property var page: PageEnum.Start - property var logic: UiLogic - - property bool pageActive: false - - signal activated(bool reset) - signal deactivated() - - onActivated: pageActive = true - onDeactivated: pageActive = false -} diff --git a/client/ui/qml/Pages/PageClientManagement.qml b/client/ui/qml/Pages/PageClientManagement.qml deleted file mode 100644 index 39defe4c1..000000000 --- a/client/ui/qml/Pages/PageClientManagement.qml +++ /dev/null @@ -1,119 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import QtQuick.Shapes 1.4 -import SortFilterProxyModel 0.2 -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.ClientManagement - logic: ClientManagementLogic - enabled: !ClientManagementLogic.busyIndicatorIsRunning - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Clients Management") - } - - BusyIndicator { - z: 99 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - visible: ClientManagementLogic.busyIndicatorIsRunning - running: ClientManagementLogic.busyIndicatorIsRunning - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - Column { - id: content - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - - LabelType { - font.pixelSize: 20 - leftPadding: -20 - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - text: ClientManagementLogic.labelCurrentVpnProtocolText - } - - SortFilterProxyModel { - id: proxyClientManagementModel - sourceModel: UiLogic.clientManagementModel - sorters: RoleSorter { roleName: "clientName" } - } - - ListView { - id: lv_clients - width: parent.width - implicitHeight: contentHeight + 20 - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 20 - topMargin: 10 - spacing: 10 - clip: true - model: proxyClientManagementModel - highlightRangeMode: ListView.ApplyRange - highlightMoveVelocity: -1 - delegate: Item { - implicitWidth: lv_clients.width - implicitHeight: 60 - - MouseArea { - id: ms - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - ClientManagementLogic.onClientItemClicked(proxyClientManagementModel.mapToSource(index)) - } - } - - Rectangle { - anchors.fill: parent - gradient: ms.containsMouse ? gradient_containsMouse : gradient_notContainsMouse - LinearGradient { - id: gradient_notContainsMouse - x1: 0 ; y1:0 - x2: 0 ; y2: height - stops: [ - GradientStop { position: 0.0; color: "#FAFBFE" }, - GradientStop { position: 1.0; color: "#ECEEFF" } - ] - } - LinearGradient { - id: gradient_containsMouse - x1: 0 ; y1:0 - x2: 0 ; y2: height - stops: [ - GradientStop { position: 0.0; color: "#FAFBFE" }, - GradientStop { position: 1.0; color: "#DCDEDF" } - ] - } - } - - LabelType { - x: 20 - y: 20 - font.pixelSize: 20 - text: clientName - } - } - } - } - } -} diff --git a/client/ui/qml/Pages/PageGeneralSettings.qml b/client/ui/qml/Pages/PageGeneralSettings.qml deleted file mode 100644 index c85aa8a7a..000000000 --- a/client/ui/qml/Pages/PageGeneralSettings.qml +++ /dev/null @@ -1,166 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.GeneralSettings - logic: GeneralSettingsLogic - - BackButton { - id: back - z: -1 - } - - FlickableType { - id: fl - anchors.top: back.bottom - anchors.topMargin: 0 - anchors.bottomMargin: 10 - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.topMargin: 10 - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: GC.defaultMargin - - spacing: 15 - - - // ---------- App settings ------------ - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - icon.source: "qrc:/images/svg/settings_black_24dp.svg" - text: qsTr("App settings") - onClicked: { - UiLogic.goToPage(PageEnum.AppSettings) - } - } - - // ---------- Network settings ------------ - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - icon.source: "qrc:/images/svg/settings_suggest_black_24dp.svg" - text: qsTr("Network settings") - onClicked: { - UiLogic.goToPage(PageEnum.NetworkSettings) - } - } - - // ---------- Server settings ------------ - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - icon.source: "qrc:/images/svg/vpn_key_black_24dp.svg" - text: qsTr("Server Settings") - enabled: GeneralSettingsLogic.existsAnyServer - onClicked: { - GeneralSettingsLogic.onPushButtonGeneralSettingsServerSettingsClicked() - } - } - - // ---------- Share connection ------------ - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - icon.source: "qrc:/images/svg/share_black_24dp.svg" - text: qsTr("Share connection") - enabled: GeneralSettingsLogic.pushButtonGeneralSettingsShareConnectionEnable && - GeneralSettingsLogic.existsAnyServer - onClicked: { - GeneralSettingsLogic.onPushButtonGeneralSettingsShareConnectionClicked() - } - } - - // ---------- Servers ------------ - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - icon.source: "qrc:/images/svg/format_list_bulleted_black_24dp.svg" - text: qsTr("Servers") - enabled: GeneralSettingsLogic.existsAnyServer - onClicked: { - UiLogic.goToPage(PageEnum.ServersList) - } - } - - // ---------- Add server ------------ - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - icon.source: "qrc:/images/svg/control_point_black_24dp.svg" - text: qsTr("Add server") - onClicked: { - if(GeneralSettingsLogic.existsAnyServer) - // If there is any server set we will go to Start Page - UiLogic.goToPage(PageEnum.Start) - else - // Else just come back to start page - UiLogic.closePage() - } - } - - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 1 - color: "#DDDDDD" - } - - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: fl.height > (75+1) * 6 ? fl.height - (75+1) * 6 : 0 - } - - SettingButtonType { - Layout.fillWidth: true - Layout.preferredHeight: 30 - Layout.bottomMargin: 20 - icon.source: "qrc:/images/svg/logout_black_24dp.svg" - text: qsTr("Exit") - onClicked: { - Qt.quit() - } - } - } - } -} diff --git a/client/ui/qml/Pages/PageNetworkSetting.qml b/client/ui/qml/Pages/PageNetworkSetting.qml deleted file mode 100644 index e14c04a6f..000000000 --- a/client/ui/qml/Pages/PageNetworkSetting.qml +++ /dev/null @@ -1,113 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.NetworkSettings - logic: NetworkSettingsLogic - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("DNS Servers") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - CheckBoxType { - Layout.preferredWidth: parent.width - text: qsTr("Use AmneziaDNS service (recommended)") - checked: NetworkSettingsLogic.checkBoxUseAmneziaDnsChecked - onCheckedChanged: { - NetworkSettingsLogic.checkBoxUseAmneziaDnsChecked = checked - NetworkSettingsLogic.onCheckBoxUseAmneziaDnsToggled(checked) - UiLogic.onUpdateAllPages() - } - } - - LabelType { - Layout.preferredWidth: parent.width - text: qsTr("Use AmneziaDNS container on your server, when it installed.\n -Your AmneziaDNS server available only when it installed and VPN connected, it has internal IP address 172.29.172.254\n -If AmneziaDNS service is not installed on the same server, or this option is unchecked, the following DNS servers will be used:") - } - - LabelType { - Layout.topMargin: 15 - text: qsTr("Primary DNS server") - } - TextFieldType { - height: 40 - implicitWidth: parent.width - text: NetworkSettingsLogic.lineEditDns1Text - onEditingFinished: { - NetworkSettingsLogic.lineEditDns1Text = text - NetworkSettingsLogic.onLineEditDns1EditFinished(text) - UiLogic.onUpdateAllPages() - } - validator: RegularExpressionValidator { - regularExpression: NetworkSettingsLogic.ipAddressRegex - } - } - - UrlButtonType { - text: qsTr("Reset to default") - label.horizontalAlignment: Text.AlignLeft - label.verticalAlignment: Text.AlignTop - label.font.pixelSize: 14 - icon.source: "qrc:/images/svg/refresh_black_24dp.svg" - onClicked: { - NetworkSettingsLogic.onPushButtonResetDns1Clicked() - UiLogic.onUpdateAllPages() - } - } - - LabelType { - text: qsTr("Secondary DNS server") - } - TextFieldType { - height: 40 - implicitWidth: parent.width - text: NetworkSettingsLogic.lineEditDns2Text - onEditingFinished: { - NetworkSettingsLogic.lineEditDns2Text = text - NetworkSettingsLogic.onLineEditDns2EditFinished(text) - UiLogic.onUpdateAllPages() - } - validator: RegularExpressionValidator { - regularExpression: NetworkSettingsLogic.ipAddressRegex - } - } - - UrlButtonType { - text: qsTr("Reset to default") - label.horizontalAlignment: Text.AlignLeft - label.verticalAlignment: Text.AlignTop - label.font.pixelSize: 14 - icon.source: "qrc:/images/svg/refresh_black_24dp.svg" - onClicked: { - NetworkSettingsLogic.onPushButtonResetDns2Clicked() - UiLogic.onUpdateAllPages() - } - } - } - } -} diff --git a/client/ui/qml/Pages/PageNewServer.qml b/client/ui/qml/Pages/PageNewServer.qml deleted file mode 100644 index 00cb51bcc..000000000 --- a/client/ui/qml/Pages/PageNewServer.qml +++ /dev/null @@ -1,61 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.NewServer - - BackButton { - id: back_from_new_server - } - Caption { - id: caption - text: qsTr("Setup your server to use VPN") - } - LabelType { - id: labelWizard - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - text: qsTr("If you want easily configure your server just run Wizard") - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: caption.bottom - anchors.topMargin: 30 - } - BlueButtonType { - id: pushButtonWizard - text: qsTr("Run Setup Wizard") - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: labelWizard.bottom - anchors.topMargin: 10 - onClicked: { - UiLogic.goToPage(PageEnum.Wizard); - } - } - LabelType { - id: labelManual - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - text: qsTr("Press configure manually to choose VPN protocols you want to install") - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: pushButtonWizard.bottom - anchors.topMargin: 40 - } - - BlueButtonType { - text: qsTr("Configure") - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: labelManual.bottom - anchors.topMargin: 10 - onClicked: { - UiLogic.goToPage(PageEnum.NewServerProtocols); - } - } - - Logo { - anchors.bottom: parent.bottom - } -} diff --git a/client/ui/qml/Pages/PageNewServerProtocols.qml b/client/ui/qml/Pages/PageNewServerProtocols.qml deleted file mode 100644 index 0ce2090f1..000000000 --- a/client/ui/qml/Pages/PageNewServerProtocols.qml +++ /dev/null @@ -1,154 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ContainerProps 1.0 -import ProtocolProps 1.0 -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" -import "InstallSettings" - -PageBase { - id: root - page: PageEnum.NewServerProtocols - logic: NewServerProtocolsLogic - - onActivated: { - container_selector.selectedIndex = -1 - UiLogic.containersModel.setSelectedServerIndex(-1) - } - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Select VPN protocols") - } - - BlueButtonType { - id: pushButtonConfigure - enabled: container_selector.selectedIndex > 0 - anchors.horizontalCenter: parent.horizontalCenter - y: parent.height - 60 - width: parent.width - 40 - height: 40 - text: qsTr("Setup server") - onClicked: { - let cont = container_selector.selectedIndex - let tp = ProtocolProps.transportProtoFromString(cb_port_proto.currentText) - let port = tf_port_num.text - NewServerProtocolsLogic.onPushButtonConfigureClicked(cont, port, tp) - } - } - - BlueButtonType { - id: pb_add_container - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: caption.bottom - anchors.topMargin: 10 - - width: parent.width - 40 - height: 40 - text: qsTr("Select protocol container") - font.pixelSize: 16 - onClicked: container_selector.visible ? container_selector.close() : container_selector.open() - - } - - SelectContainer { - id: container_selector - onAboutToHide: { - pageLoader.focus = true - } - - onContainerSelected: function(c_index){ - var containerProto = ContainerProps.defaultProtocol(c_index) - - tf_port_num.text = ProtocolProps.defaultPort(containerProto) - cb_port_proto.currentIndex = ProtocolProps.defaultTransportProto(containerProto) - - tf_port_num.enabled = ProtocolProps.defaultPortChangeable(containerProto) - cb_port_proto.enabled = ProtocolProps.defaultTransportProtoChangeable(containerProto) - } - } - - Column { - id: c1 - visible: container_selector.selectedIndex > 0 - width: parent.width - anchors.top: pb_add_container.bottom - anchors.topMargin: 10 - - Caption { - font.pixelSize: 22 - text: UiLogic.containerName(container_selector.selectedIndex) - } - - Text { - width: parent.width - anchors.topMargin: 10 - padding: 10 - - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - - text: UiLogic.containerDesc(container_selector.selectedIndex) - } - } - - - - Rectangle { - id: frame_settings - visible: container_selector.selectedIndex > 0 - width: parent.width - anchors.top: c1.bottom - anchors.topMargin: 10 - - border.width: 1 - border.color: "lightgray" - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - radius: 2 - Grid { - id: grid - visible: container_selector.selectedIndex > 0 - anchors.fill: parent - columns: 2 - horizontalItemAlignment: Grid.AlignHCenter - verticalItemAlignment: Grid.AlignVCenter - topPadding: 5 - leftPadding: 10 - spacing: 5 - - - LabelType { - width: 130 - text: qsTr("Port") - } - TextFieldType { - id: tf_port_num - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - } - LabelType { - width: 130 - text: qsTr("Network Protocol") - } - ComboBoxType { - id: cb_port_proto - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - model: [ - qsTr("udp"), - qsTr("tcp"), - ] - } - } - } -} diff --git a/client/ui/qml/Pages/PageQrDecoderIos.qml b/client/ui/qml/Pages/PageQrDecoderIos.qml deleted file mode 100644 index 21bdbfe77..000000000 --- a/client/ui/qml/Pages/PageQrDecoderIos.qml +++ /dev/null @@ -1,94 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import QRCodeReader 1.0 - -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.QrDecoderIos - logic: QrDecoderLogic - - onDeactivated: { - console.debug("Stopping QR decoder") - loader.sourceComponent = undefined - } - - BackButton { - } - Caption { - id: caption - text: qsTr("Import configuration") - } - - Connections { - target: Qt.platform.os == "ios" ? QrDecoderLogic : null - function onStartDecode() { - console.debug("Starting QR decoder") - loader.sourceComponent = component - } - function onStopDecode() { - console.debug("Stopping QR decoder") - loader.sourceComponent = undefined - } - } - - Loader { - id: loader - - anchors.top: caption.bottom - anchors.bottom: progressColumn.top - anchors.left: parent.left - anchors.right: parent.right - } - - Column{ - height: 40 - id: progressColumn - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - ProgressBar { - id: progress - anchors.left: parent.left - anchors.right: parent.right - value: QrDecoderLogic.totalChunksCount === 0? 0 : (QrDecoderLogic.receivedChunksCount/QrDecoderLogic.totalChunksCount) - } - Text { - id: chunksCount - text: "Progress: " + QrDecoderLogic.receivedChunksCount +"/"+QrDecoderLogic.totalChunksCount - } - } - - Component { - id: component - - Item { - anchors.fill: parent - - QRCodeReader { - id: qrCodeReader - - onCodeReaded: { - QrDecoderLogic.onDetectedQrCode(code) - } - - Component.onCompleted: { - qrCodeReader.setCameraSize(Qt.rect(loader.x, - loader.y, - loader.width, - loader.height)) - qrCodeReader.startReading() - } - Component.onDestruction: qrCodeReader.stopReading() - } - - } - - } - - -} diff --git a/client/ui/qml/Pages/PageServerConfiguringProgress.qml b/client/ui/qml/Pages/PageServerConfiguringProgress.qml deleted file mode 100644 index 04f1b6f58..000000000 --- a/client/ui/qml/Pages/PageServerConfiguringProgress.qml +++ /dev/null @@ -1,121 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.ServerConfiguringProgress - logic: ServerConfiguringProgressLogic - - Caption { - id: caption - text: qsTr("Configuring...") - } - LabelType { - id: label - x: 0 - anchors.top: caption.bottom - anchors.topMargin: 10 - - width: parent.width - height: 31 - text: qsTr("Please wait.") - horizontalAlignment: Text.AlignHCenter - } - - LabelType { - id: labelServerBusy - x: 0 - anchors.top: label.bottom - anchors.topMargin: 30 - - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - - width: parent.width - 40 - height: 41 - - text: ServerConfiguringProgressLogic.labelServerBusyText - visible: ServerConfiguringProgressLogic.labelServerBusyVisible - } - - LabelType { - anchors.bottom: pr.top - anchors.bottomMargin: 20 - - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - - width: parent.width - 40 - height: 41 - text: ServerConfiguringProgressLogic.labelWaitInfoText - visible: ServerConfiguringProgressLogic.labelWaitInfoVisible - } - - - BlueButtonType { - id: pb_cancel - z: 1 - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: logo.bottom - anchors.bottomMargin: 40 - width: root.width - 60 - height: 40 - text: qsTr("Cancel") - visible: ServerConfiguringProgressLogic.pushButtonCancelVisible - enabled: ServerConfiguringProgressLogic.pushButtonCancelVisible - onClicked: { - ServerConfiguringProgressLogic.onPushButtonCancelClicked() - } - } - - ProgressBar { - id: pr - enabled: ServerConfiguringProgressLogic.pageEnabled - anchors.fill: pb_cancel - from: 0 - to: ServerConfiguringProgressLogic.progressBarMaximum - value: ServerConfiguringProgressLogic.progressBarValue - visible: ServerConfiguringProgressLogic.progressBarVisible - background: Rectangle { - implicitWidth: parent.width - implicitHeight: parent.height - color: "#100A44" - radius: 4 - } - - contentItem: Item { - implicitWidth: parent.width - implicitHeight: parent.height - Rectangle { - width: pr.visualPosition * parent.width - height: parent.height - radius: 4 - color: Qt.rgba(255, 255, 255, 0.15); - } - } - - LabelType { - anchors.left: parent.left - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - text: ServerConfiguringProgressLogic.progressBarText - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#D4D4D4" - visible: ServerConfiguringProgressLogic.progressBarTextVisible - } - } - - Logo { - id : logo - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - } -} diff --git a/client/ui/qml/Pages/PageServerContainers.qml b/client/ui/qml/Pages/PageServerContainers.qml deleted file mode 100644 index ddd607b05..000000000 --- a/client/ui/qml/Pages/PageServerContainers.qml +++ /dev/null @@ -1,434 +0,0 @@ -import QtQuick -import QtQuick.Controls -import Qt.labs.platform -import QtQuick.Layouts -import SortFilterProxyModel 0.2 -import ContainerProps 1.0 -import ProtocolProps 1.0 -import PageEnum 1.0 -import ProtocolEnum 1.0 -import "./" -import "../Controls" -import "../Config" -import "InstallSettings" - -PageBase { - id: root - page: PageEnum.ServerContainers - logic: ServerContainersLogic - - enabled: ServerContainersLogic.pageEnabled - - function resetPage() { - container_selector.selectedIndex = -1 - } - - Connections { - target: logic - function onUpdatePage() { - root.resetPage() - } - } - - BackButton { - id: back - onClicked: tb_c.currentIndex = -1 - } - Caption { - id: caption - text: container_selector.selectedIndex > 0 ? qsTr("Install new service") : qsTr("Installed services") - } - - SelectContainer { - id: container_selector - - onAboutToHide: { - pageLoader.focus = true - } - - onContainerSelected: function(c_index) { - var containerProto = ContainerProps.defaultProtocol(c_index) - - - if (ProtocolProps.defaultPort(containerProto) < 0) { - tf_port_num.enabled = false - tf_port_num.text = qsTr("Default") - } - else tf_port_num.text = ProtocolProps.defaultPort(containerProto) - cb_port_proto.currentIndex = ProtocolProps.defaultTransportProto(containerProto) - - tf_port_num.enabled = ProtocolProps.defaultPortChangeable(containerProto) - cb_port_proto.enabled = ProtocolProps.defaultTransportProtoChangeable(containerProto) - } - } - - Column { - id: c1 - visible: container_selector.selectedIndex > 0 - width: parent.width - anchors.top: caption.bottom - anchors.topMargin: 10 - - Caption { - font.pixelSize: 22 - text: UiLogic.containerName(container_selector.selectedIndex) - } - - Text { - width: parent.width - anchors.topMargin: 10 - padding: 10 - - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - - text: UiLogic.containerDesc(container_selector.selectedIndex) - } - } - - Rectangle { - id: frame_settings - visible: container_selector.selectedIndex > 0 - width: parent.width - anchors.top: c1.bottom - anchors.topMargin: 10 - - border.width: 1 - border.color: "lightgray" - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - radius: 2 - Grid { - id: grid - visible: container_selector.selectedIndex > 0 - anchors.fill: parent - columns: 2 - horizontalItemAlignment: Grid.AlignHCenter - verticalItemAlignment: Grid.AlignVCenter - topPadding: 5 - leftPadding: 10 - spacing: 5 - - - LabelType { - width: 130 - text: qsTr("Port") - } - TextFieldType { - id: tf_port_num - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - } - LabelType { - width: 130 - text: qsTr("Network Protocol") - } - ComboBoxType { - id: cb_port_proto - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - model: [ - qsTr("udp"), - qsTr("tcp"), - ] - } - } - } - - BlueButtonType { - id: pb_cancel_add - visible: container_selector.selectedIndex > 0 - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: pb_continue_add.top - anchors.bottomMargin: 20 - - width: parent.width - 40 - height: 40 - text: qsTr("Cancel") - font.pixelSize: 16 - onClicked: container_selector.selectedIndex = -1 - - } - - BlueButtonType { - id: pb_continue_add - visible: container_selector.selectedIndex > 0 - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - - width: parent.width - 40 - height: 40 - text: qsTr("Continue") - font.pixelSize: 16 - onClicked: { - let cont = container_selector.selectedIndex - let tp = ProtocolProps.transportProtoFromString(cb_port_proto.currentText) - let port = tf_port_num.text - ServerContainersLogic.onPushButtonContinueClicked(cont, port, tp) - } - } - - FlickableType { - visible: container_selector.selectedIndex <= 0 - clip: true - width: parent.width - anchors.top: caption.bottom - anchors.bottom: pb_add_container.top - contentHeight: col.height - - Column { - visible: container_selector.selectedIndex <= 0 - id: col - anchors { - left: parent.left; - right: parent.right; - } - spacing: 10 - - Caption { - id: cap1 - text: qsTr("Installed Protocols and Services") - leftPadding: -20 - font.pixelSize: 20 - - } - - SortFilterProxyModel { - id: proxyContainersModel - sourceModel: UiLogic.containersModel - filters: ValueFilter { - roleName: "is_installed_role" - value: true - } - } - - SortFilterProxyModel { - id: proxyProtocolsModel - sourceModel: UiLogic.protocolsModel - filters: ValueFilter { - roleName: "is_installed_role" - value: true - } - } - - - ListView { - id: tb_c - width: parent.width - 10 - height: tb_c.contentItem.height - currentIndex: -1 - spacing: 5 - clip: true - interactive: false - model: proxyContainersModel - - delegate: Item { - implicitWidth: tb_c.width - 10 - implicitHeight: c_item.height - Item { - id: c_item - width: parent.width - height: row_container.height + tb_p.height - anchors.left: parent.left - Rectangle { - anchors.top: parent.top - width: parent.width - height: 1 - color: "lightgray" - visible: index !== tb_c.currentIndex - } - Rectangle { - anchors.top: row_container.top - anchors.bottom: row_container.bottom - anchors.left: parent.left - anchors.right: parent.right - - color: "#63B4FB" - visible: index === tb_c.currentIndex - } - - RowLayout { - id: row_container - anchors.left: parent.left - anchors.right: parent.right - - Text { - id: lb_container_name - text: name_role - font.pixelSize: 17 - color: "#100A44" - topPadding: 16 - bottomPadding: 12 - leftPadding: 10 - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - Layout.fillWidth: true - - MouseArea { - enabled: col.visible - anchors.top: lb_container_name.top - anchors.bottom: lb_container_name.bottom - anchors.left: parent.left - anchors.right: parent.right - propagateComposedEvents: true - onClicked: { - if (tb_c.currentIndex === index) tb_c.currentIndex = -1 - else tb_c.currentIndex = index - - UiLogic.protocolsModel.setSelectedDockerContainer(proxyContainersModel.mapToSource(index)) - } - } - } - - ImageButtonType { - id: button_remove - visible: (index === tb_c.currentIndex) && ServerContainersLogic.isManagedServer - Layout.alignment: Qt.AlignRight - checkable: true - icon.source: "qrc:/images/delete.png" - implicitWidth: 30 - implicitHeight: 30 - - checked: default_role - onClicked: popupRemove.open() - - VisibleBehavior on visible { } - } - - PopupWithQuestion { - id: popupRemove - questionText: qsTr("Remove container") + " " + name_role + "?" + "\n" + qsTr("This action will erase all data of this container on the server.") - yesFunc: function() { - tb_c.currentIndex = -1 - ServerContainersLogic.onPushButtonRemoveClicked(proxyContainersModel.mapToSource(index)) - close() - } - noFunc: function() { - close() - } - } - - ImageButtonType { - id: button_share - visible: (index === tb_c.currentIndex) && ServerContainersLogic.isManagedServer - Layout.alignment: Qt.AlignRight - icon.source: "qrc:/images/share.png" - implicitWidth: 30 - implicitHeight: 30 - onClicked: { - ServerContainersLogic.onPushButtonShareClicked(proxyContainersModel.mapToSource(index)) - } - - VisibleBehavior on visible { } - } - - ImageButtonType { - id: button_default - visible: service_type_role == ProtocolEnum.Vpn - - Layout.alignment: Qt.AlignRight - checkable: true - img.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png" - implicitWidth: 30 - implicitHeight: 30 - - checked: default_role - onClicked: { - ServerContainersLogic.onPushButtonDefaultClicked(proxyContainersModel.mapToSource(index)) - } - } - } - - - ListView { - id: tb_p - currentIndex: -1 - x: 10 - anchors.top: row_container.bottom - - width: parent.width - 40 - height: index === tb_c.currentIndex ? tb_p.contentItem.height : 0 - implicitHeight: height - - spacing: 0 - clip: true - interactive: false - model: proxyProtocolsModel - - - Behavior on height { - NumberAnimation { - duration: 200 - } - } - - delegate: Item { - id: dp_item - - implicitWidth: tb_p.width - 10 - implicitHeight: p_item.height - Item { - id: p_item - width: parent.width - height: lb_protocol_name.height - anchors.left: parent.left - Rectangle { - anchors.top: parent.top - width: parent.width - height: 1 - color: "lightgray" - visible: index > 0 - } - - SettingButtonType { - id: lb_protocol_name - topPadding: 10 - bottomPadding: 10 - - anchors.left: parent.left - anchors.leftMargin: 10 - - width: parent.width - height: 45 - text: qsTr(name_role + " settings") - textItem.font.pixelSize: 16 - icon.source: "qrc:/images/settings.png" - onClicked: { - tb_p.currentIndex = index - ServerContainersLogic.onPushButtonProtoSettingsClicked( - proxyContainersModel.mapToSource(tb_c.currentIndex), - proxyProtocolsModel.mapToSource(tb_p.currentIndex)) - } - } - } - } - } - } - } - } - } - } - - - BlueButtonType { - id: pb_add_container - visible: container_selector.selectedIndex < 0 && ServerContainersLogic.isManagedServer - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.topMargin: 10 - anchors.bottomMargin: 20 - - width: parent.width - 40 - height: 40 - text: qsTr("Install new service") - font.pixelSize: 16 - onClicked: container_selector.visible ? container_selector.close() : container_selector.open() - } -} diff --git a/client/ui/qml/Pages/PageServerList.qml b/client/ui/qml/Pages/PageServerList.qml deleted file mode 100644 index 80ac9a1b8..000000000 --- a/client/ui/qml/Pages/PageServerList.qml +++ /dev/null @@ -1,185 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Shapes 1.4 -import PageEnum 1.0 -import "../Controls" -import "./" -import "../Config" - -PageBase { - id: root - page: PageEnum.ServersList - logic: ServerListLogic - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Servers") - width: undefined - } - - SvgButtonType { - anchors.verticalCenter: caption.verticalCenter - anchors.leftMargin: 10 - anchors.left: caption.right - width: 27 - height: 27 - - icon.source: "qrc:/images/svg/control_point_black_24dp.svg" - onClicked: { - UiLogic.goToPage(PageEnum.Start); - } - } - - ListView { - id: listWidget_servers - x: GC.defaultMargin - anchors.top: caption.bottom - anchors.topMargin: 15 - width: parent.width - GC.defaultMargin - 1 - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - model: ServerListLogic.serverListModel - highlightRangeMode: ListView.ApplyRange - highlightMoveVelocity: -1 - currentIndex: ServerListLogic.currServerIdx - spacing: 5 - clip: true - delegate: Item { - height: 60 - width: listWidget_servers.width - 15 - MouseArea { - id: ms - anchors.fill: parent - hoverEnabled: true - onClicked: { - if (GC.isMobile()) { - ServerListLogic.onServerListPushbuttonSettingsClicked(index) - } - mouse.accepted = false - } - onEntered: { - mouseExitAni.stop() - mouseEnterAni.start() - } - onExited: { - mouseEnterAni.stop() - mouseExitAni.start() - } - } - Rectangle { - anchors.fill: parent - gradient: ms.containsMouse ? gradient_containsMouse : gradient_notContainsMouse - LinearGradient { - id: gradient_notContainsMouse - x1: 0 ; y1:0 - x2: 0 ; y2: height - stops: [ - GradientStop { position: 0.0; color: "#FAFBFE" }, - GradientStop { position: 1.0; color: "#ECEEFF" } - ] - } - LinearGradient { - id: gradient_containsMouse - x1: 0 ; y1:0 - x2: 0 ; y2: height - stops: [ - GradientStop { position: 0.0; color: "#FAFBFE" }, - GradientStop { position: 1.0; color: "#DCDEDF" } - ] - } - } - - LabelType { - id: label_address - x: 20 - y: 40 - width: listWidget_servers.width - 100 - height: 16 - text: address - } - Text { - x: 10 - y: 10 - width: listWidget_servers.width - 100 - height: 21 - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - font.bold: true - color: "#181922" - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - text: desc - } - ImageButtonType { - x: parent.width - 30 - y: 15 - width: 30 - height: 30 - checkable: true - icon.source: checked ? "qrc:/images/check.png" - : "qrc:/images/uncheck.png" - onClicked: { - ServerListLogic.onServerListPushbuttonDefaultClicked(index) - } - checked: is_default - enabled: !is_default - } - SvgButtonType { - id: pushButtonSetting - x: parent.width - 70 - y: 15 - width: 30 - height: 30 - icon.source: "qrc:/images/svg/settings_black_24dp.svg" - opacity: 0 - - OpacityAnimator { - id: mouseEnterAni - target: pushButtonSetting; - from: 0; - to: 1; - duration: 150 - running: false - easing.type: Easing.InOutQuad - } - OpacityAnimator { - id: mouseExitAni - target: pushButtonSetting; - from: 1; - to: 0; - duration: 150 - running: false - easing.type: Easing.InOutQuad - } - MouseArea { - cursorShape: Qt.PointingHandCursor - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - - onEntered: { - mouseExitAni.stop() - mouseEnterAni.start() - } - onExited: { - mouseEnterAni.stop() - mouseExitAni.start() - } - - onClicked: { - ServerListLogic.onServerListPushbuttonSettingsClicked(index) - } - } - } - } - - ScrollBar.vertical: ScrollBar { - policy: ScrollBar.AsNeeded - } - } -} diff --git a/client/ui/qml/Pages/PageServerSettings.qml b/client/ui/qml/Pages/PageServerSettings.qml deleted file mode 100644 index 4ef22ce4e..000000000 --- a/client/ui/qml/Pages/PageServerSettings.qml +++ /dev/null @@ -1,140 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.ServerSettings - logic: ServerSettingsLogic - - enabled: ServerSettingsLogic.pageEnabled - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Server settings") - anchors.horizontalCenter: parent.horizontalCenter - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: logo.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - Layout.fillWidth: true - font.pixelSize: 20 - horizontalAlignment: Text.AlignHCenter - text: ServerSettingsLogic.labelCurrentVpnProtocolText - } - - TextFieldType { - Layout.fillWidth: true - font.pixelSize: 20 - horizontalAlignment: Text.AlignHCenter - text: ServerSettingsLogic.labelServerText - readOnly: true - background: Item {} - } - - LabelType { - Layout.fillWidth: true - text: ServerSettingsLogic.labelWaitInfoText - visible: ServerSettingsLogic.labelWaitInfoVisible - } - TextFieldType { - Layout.fillWidth: true - text: ServerSettingsLogic.lineEditDescriptionText - onEditingFinished: { - ServerSettingsLogic.lineEditDescriptionText = text - ServerSettingsLogic.onLineEditDescriptionEditingFinished() - } - } - - BlueButtonType { - text: qsTr("Protocols and Services") - Layout.topMargin: 20 - Layout.fillWidth: true - onClicked: { - UiLogic.goToPage(PageEnum.ServerContainers) - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - text: qsTr("Share Server (FULL ACCESS)") - visible: ServerSettingsLogic.pushButtonShareFullVisible - onClicked: { - ServerSettingsLogic.onPushButtonShareFullClicked() - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - text: qsTr("Advanced server settings") - onClicked: { - UiLogic.goToPage(PageEnum.AdvancedServerSettings) - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 60 - text: ServerSettingsLogic.pushButtonClearClientCacheText - visible: ServerSettingsLogic.pushButtonClearClientCacheVisible - onClicked: { - ServerSettingsLogic.onPushButtonClearClientCacheClicked() - } - } - - BlueButtonType { - Layout.fillWidth: true - Layout.topMargin: 10 - text: qsTr("Forget this server") - onClicked: { - if (ServerSettingsLogic.isCurrentServerHasCredentials()) { - popupForgetServer.questionText = "Attention! This action will not remove any data from the server, it will just remove server from the list. Continue?" - } - else { - popupForgetServer.questionText = "Remove server from the list?" - } - popupForgetServer.open() - } - } - - PopupWithQuestion { - id: popupForgetServer - yesFunc: function() { - ServerSettingsLogic.onPushButtonForgetServer() - close() - } - noFunc: function() { - close() - } - } - } - } - - Logo { - id : logo - anchors.bottom: parent.bottom - } -} diff --git a/client/ui/qml/Pages/PageSetupWizard.qml b/client/ui/qml/Pages/PageSetupWizard.qml deleted file mode 100644 index a7e93a3ac..000000000 --- a/client/ui/qml/Pages/PageSetupWizard.qml +++ /dev/null @@ -1,108 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.Wizard - logic: WizardLogic - - BackButton { - id: back_from_setup_wizard - } - Caption { - id: caption - text: qsTr("Setup your server to use VPN") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: next_button.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - RadioButtonType { - id: radioButton_setup_wizard_high - Layout.fillWidth: true - text: qsTr("High censorship level") - checked: WizardLogic.radioButtonHighChecked - onCheckedChanged: { - WizardLogic.radioButtonHighChecked = checked - } - } - LabelType { - Layout.fillWidth: true - Layout.leftMargin: 25 - verticalAlignment: Text.AlignTop - text: qsTr("I'm living in a country with a high censorship level. Many of the foreign websites and VPNs are blocked by my government. I want to setup a reliable VPN, which can not be detected by my internet provider and my government. -OpenVPN and ShadowSocks over Cloak (VPN obfuscation) profiles will be installed.\n") - } - - - RadioButtonType { - id: radioButton_setup_wizard_medium - Layout.fillWidth: true - text: qsTr("Medium censorship level") - checked: WizardLogic.radioButtonMediumChecked - onCheckedChanged: { - WizardLogic.radioButtonMediumChecked = checked - } - } - LabelType { - Layout.fillWidth: true - Layout.leftMargin: 25 - verticalAlignment: Text.AlignTop - text: qsTr("I'm living in a country with a medium censorship level. Some websites are blocked by my government, but VPNs are not blocked at all. I want to setup a flexible solution. -OpenVPN over ShadowSocks profile will be installed.\n") - } - - - RadioButtonType { - id: radioButton_setup_wizard_low - Layout.fillWidth: true - text: qsTr("Low censorship level") - checked: WizardLogic.radioButtonLowChecked - onCheckedChanged: { - WizardLogic.radioButtonLowChecked = checked - } - } - LabelType { - Layout.fillWidth: true - Layout.leftMargin: 25 - verticalAlignment: Text.AlignTop - text: qsTr("I want to improve my privacy on the internet. -OpenVPN profile will be installed.\n") - } - } - } - - BlueButtonType { - id: next_button - anchors.bottom: parent.bottom - anchors.bottomMargin: GC.defaultMargin - x: GC.defaultMargin - width: parent.width - 2 * GC.defaultMargin - text: qsTr("Next") - onClicked: { - if (radioButton_setup_wizard_high.checked) { - UiLogic.goToPage(PageEnum.WizardHigh, false); - } else if (radioButton_setup_wizard_medium.checked) { - UiLogic.goToPage(PageEnum.WizardMedium, false); - } else if (radioButton_setup_wizard_low.checked) { - UiLogic.goToPage(PageEnum.WizardLow, false); - } - } - } -} diff --git a/client/ui/qml/Pages/PageSetupWizardHighLevel.qml b/client/ui/qml/Pages/PageSetupWizardHighLevel.qml deleted file mode 100644 index e0f194fff..000000000 --- a/client/ui/qml/Pages/PageSetupWizardHighLevel.qml +++ /dev/null @@ -1,96 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.WizardHigh - logic: WizardLogic - - BackButton { - id: back_from_setup_wizard - } - Caption { - id: caption - text: qsTr("Setup Wizard") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: next_button.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - Layout.fillWidth: true - verticalAlignment: Text.AlignTop - text: qsTr("AmneziaVPN will install a VPN protocol which is not visible to your internet provider and government firewall. Your VPN connection will be seen by your internet provider as regular web traffic to a particular website. - -You SHOULD set this website address to some foreign website which is not blocked by your internet provider. In other words, you need to type some foreign website address which is accessible to you without a VPN.") - } - - LabelType { - Layout.fillWidth: true - Layout.topMargin: 15 - verticalAlignment: Text.AlignTop - text: qsTr("Type another web site address for masking or keep it by default. Your internet provider will think you working on this web site when you connected to VPN.") - } - - TextFieldType { - id: website_masking - Layout.fillWidth: true - text: WizardLogic.lineEditHighWebsiteMaskingText - onEditingFinished: { - let _text = website_masking.text - _text = _text.replace("http://", ""); - _text = _text.replace("https://", ""); - if (!_text) { - return - } - _text = _text.split("/")[0]; - WizardLogic.lineEditHighWebsiteMaskingText = _text - } - onAccepted: { - next_button.clicked() - } - } - - LabelType { - Layout.fillWidth: true - Layout.topMargin: 15 - verticalAlignment: Text.AlignTop - text: qsTr("OpenVPN and ShadowSocks over Cloak (VPN obfuscation) profiles will be installed. - -This protocol support exporting connection profiles to mobile devices by exporting ShadowSocks and Cloak configs (you should launch the 3rd party open source VPN client - ShadowSocks VPN and install Cloak plugin).") - } - } - } - - BlueButtonType { - id: next_button - anchors.bottom: parent.bottom - anchors.bottomMargin: GC.defaultMargin - x: GC.defaultMargin - width: parent.width - 2 * GC.defaultMargin - text: qsTr("Next") - onClicked: { - let domain = website_masking.text; - if (!domain || !domain.includes(".")) { - return - } - UiLogic.goToPage(PageEnum.WizardVpnMode, false) - } - } -} diff --git a/client/ui/qml/Pages/PageSetupWizardLowLevel.qml b/client/ui/qml/Pages/PageSetupWizardLowLevel.qml deleted file mode 100644 index d4e590c1c..000000000 --- a/client/ui/qml/Pages/PageSetupWizardLowLevel.qml +++ /dev/null @@ -1,65 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.WizardLow - logic: WizardLogic - - BackButton { - id: back_from_setup_wizard - } - Caption { - id: caption - text: qsTr("Setup Wizard") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: next_button.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - Layout.fillWidth: true - verticalAlignment: Text.AlignTop - text: qsTr('AmneziaVPN will install the OpenVPN protocol with public/private key pairs generated on both server and client sides. - -You can also configure the connection on your mobile device by copying the exported ".ovpn" file to your device, and setting up the official OpenVPN client. - -We recommend not to use messaging applications for sending the connection profile - it contains VPN private keys.') - } - LabelType { - Layout.fillWidth: true - Layout.topMargin: 15 - text: qsTr('OpenVPN profile will be installed') - verticalAlignment: Text.AlignBottom - } - } - } - - BlueButtonType { - id: next_button - anchors.bottom: parent.bottom - anchors.bottomMargin: GC.defaultMargin - x: GC.defaultMargin - width: parent.width - 2 * GC.defaultMargin - text: qsTr("Start configuring") - onClicked: { - WizardLogic.onPushButtonLowFinishClicked() - } - } -} diff --git a/client/ui/qml/Pages/PageSetupWizardMediumLevel.qml b/client/ui/qml/Pages/PageSetupWizardMediumLevel.qml deleted file mode 100644 index 6e1a45c1f..000000000 --- a/client/ui/qml/Pages/PageSetupWizardMediumLevel.qml +++ /dev/null @@ -1,60 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.WizardMedium - logic: WizardLogic - - BackButton { - id: back_from_setup_wizard - } - Caption { - id: caption - text: qsTr("Setup Wizard") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: next_button.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - Layout.fillWidth: true - verticalAlignment: Text.AlignTop - text: qsTr('AmneziaVPN will install a VPN protocol which is difficult to detect by your internet provider and government firewall (but possible). In most cases, this is the most suitable protocol. This protocol is faster compared to the VPN protocols with "VPN masking".\n\nThis protocol supports exporting connection profiles to mobile devices by using QR codes (you should launch the 3rd party open source VPN client - ShadowSocks VPN).') - } - LabelType { - Layout.fillWidth: true - Layout.topMargin: 15 - text: qsTr('OpenVPN over ShadowSocks profile will be installed') - } - } - } - - BlueButtonType { - id: next_button - anchors.bottom: parent.bottom - anchors.bottomMargin: GC.defaultMargin - x: GC.defaultMargin - width: parent.width - 2 * GC.defaultMargin - text: qsTr("Next") - onClicked: { - UiLogic.goToPage(PageEnum.WizardVpnMode, false) - } - } -} diff --git a/client/ui/qml/Pages/PageSetupWizardVPNMode.qml b/client/ui/qml/Pages/PageSetupWizardVPNMode.qml deleted file mode 100644 index 497ccad8a..000000000 --- a/client/ui/qml/Pages/PageSetupWizardVPNMode.qml +++ /dev/null @@ -1,65 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.WizardVpnMode - logic: WizardLogic - - BackButton { - id: back_from_setup_wizard - } - Caption { - id: caption - text: qsTr("Setup Wizard") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - anchors.bottom: vpn_mode_finish.top - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - Layout.fillWidth: true - verticalAlignment: Text.AlignTop - text: qsTr('Optional.\n -You can enable VPN mode "For selected sites" and add blocked sites you need to visit manually. If you will choose this option, you will need add every blocked site you want to visit to the access list. You may switch between modes later.\n\nPlease note, you should add addresses to the list after VPN connection established. You may add any domain, URL or IP address, it will be resolved to IP address.') - } - - CheckBoxType { - Layout.fillWidth: true - text: qsTr('Turn on mode "VPN for selected sites"') - checked: WizardLogic.checkBoxVpnModeChecked - onCheckedChanged: { - WizardLogic.checkBoxVpnModeChecked = checked - } - } - } - } - - BlueButtonType { - id: vpn_mode_finish - anchors.bottom: parent.bottom - anchors.bottomMargin: GC.defaultMargin - x: GC.defaultMargin - width: parent.width - 2 * GC.defaultMargin - text: qsTr("Start configuring") - onClicked: { - WizardLogic.onPushButtonVpnModeFinishClicked() - } - } -} diff --git a/client/ui/qml/Pages/PageShareConnection.qml b/client/ui/qml/Pages/PageShareConnection.qml deleted file mode 100644 index b5439b473..000000000 --- a/client/ui/qml/Pages/PageShareConnection.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Dialogs -import QtQuick.Layouts -import SortFilterProxyModel 0.2 -import ContainerProps 1.0 -import ProtocolProps 1.0 -import PageEnum 1.0 -import ProtocolEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.ShareConnection - logic: ShareConnectionLogic - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Share protocol config") - width: undefined - } - - - FlickableType { - clip: true - anchors.top: caption.bottom - contentHeight: col.height - boundsBehavior: Flickable.StopAtBounds - - Column { - id: col - anchors { - left: parent.left; - right: parent.right; - } - topPadding: 20 - spacing: 10 - - SortFilterProxyModel { - id: proxyProtocolsModel - sourceModel: UiLogic.protocolsModel - filters: ValueFilter { - roleName: "is_installed_role" - value: true - } - } - - - ShareConnectionContent { - text: qsTr("Share for Amnezia") - height: 40 - width: tb_c.width - 10 - onClicked: UiLogic.goToShareProtocolPage(ProtocolEnum.Any) - } - - ListView { - id: tb_c - width: parent.width - 10 - height: tb_c.contentItem.height - currentIndex: -1 - spacing: 10 - clip: true - interactive: false - model: proxyProtocolsModel - - delegate: Item { - implicitWidth: tb_c.width - 10 - implicitHeight: c_item.height - - ShareConnectionContent { - id: c_item - text: qsTr("Share for ") + name_role - height: 40 - width: tb_c.width - 10 - onClicked: UiLogic.goToShareProtocolPage(proxyProtocolsModel.mapToSource(index)) - } - } - } - } - } -} diff --git a/client/ui/qml/Pages/PageSites.qml b/client/ui/qml/Pages/PageSites.qml deleted file mode 100644 index 673e7e7a8..000000000 --- a/client/ui/qml/Pages/PageSites.qml +++ /dev/null @@ -1,315 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQml.Models -import Qt.labs.platform -import QtQuick.Dialogs -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.Sites - logic: SitesLogic - - property int lastIndex: 0 - - BackButton { - id: back - } - - Caption { - id: caption - text: SitesLogic.labelSitesAddCustomText - } - - LabelType { - id: lb_addr - color: "#333333" - text: qsTr("Web site/Hostname/IP address/Subnet") - x: 20 - anchors.top: caption.bottom - anchors.topMargin: 10 - width: parent.width - height: 21 - } - - TextFieldType { - anchors.top: lb_addr.bottom - anchors.topMargin: 10 - anchors.left: parent.left - anchors.leftMargin: 20 - anchors.right: sites_add.left - anchors.rightMargin: 10 - height: 31 - placeholderText: qsTr("yousite.com or IP address") - text: SitesLogic.lineEditSitesAddCustomText - onEditingFinished: { - SitesLogic.lineEditSitesAddCustomText = text - } - onAccepted: { - SitesLogic.onPushButtonAddCustomSitesClicked() - } - } - - BlueButtonType { - id: sites_add - anchors.right: sites_import.left - anchors.rightMargin: 10 - anchors.top: lb_addr.bottom - anchors.topMargin: 10 - width: 51 - height: 31 - font.pixelSize: 24 - text: "+" - onClicked: { - SitesLogic.onPushButtonAddCustomSitesClicked() - } - } - - BasicButtonType { - id: sites_import - anchors.right: parent.right - anchors.rightMargin: 20 - anchors.top: lb_addr.bottom - anchors.topMargin: 10 - width: 51 - height: 31 - background: Rectangle { - anchors.fill: parent - radius: 4 - color: parent.containsMouse ? "#211966" : "#100A44" - } - font.pixelSize: 16 - contentItem: Item { - anchors.fill: parent - Image { - anchors.centerIn: parent - width: 20 - height: 20 - source: "qrc:/images/folder.png" - fillMode: Image.Stretch - } - } - antialiasing: true - onClicked: { - fileDialog.open() - } - } - FileDialog { - id: fileDialog - title: qsTr("Import IP addresses") - visible: false - currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) - onAccepted: { - SitesLogic.onPushButtonSitesImportClicked(fileUrl) - } - } - - DelegateModel { - id: visualModel - model: SitesLogic.tableViewSitesModel - groups: [ - DelegateModelGroup { - id : delegateModelGroup - name: "multiSelect" - function removeAll(){ - var count = delegateModelGroup.count; - if (count !== 0){ - delegateModelGroup.remove(0,count); - } - } - function selectAll(){ - for(var i = 0; i < visualModel.count; i++){ - visualModel.items.get(i).inMultiSelect = true - } - } - } - ] - delegate: Rectangle { - id: item - focus: true - height: 25 - width: root.width - color: item.DelegateModel.inMultiSelect ? '#63b4fb' : 'transparent' - implicitWidth: 170 * 2 - implicitHeight: 30 - Item { - width: 170 - height: 30 - anchors.left: parent.left - id: c1 - Rectangle { - anchors.top: parent.top - width: parent.width - height: 1 - color: "lightgray" - visible: index !== tb.currentRow - } - Rectangle { - anchors.fill: parent - color: "#63B4FB" - visible: index === tb.currentRow - - } - Text { - text: url_path - anchors.fill: parent - leftPadding: 10 - verticalAlignment: Text.AlignVCenter - } - } - Item { - anchors.left: c1.right - width: 170 - height: 30 - Rectangle { - anchors.top: parent.top - width: parent.width - height: 1 - color: "lightgray" - visible: index !== tb.currentRow - } - Rectangle { - anchors.fill: parent - color: "#63B4FB" - visible: index === tb.currentRow - - } - Text { - text: ip - anchors.fill: parent - leftPadding: 10 - verticalAlignment: Text.AlignVCenter - } - } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked:{ - tb.focus = true - if(mouse.button === Qt.RightButton){ - //copyPasteMenu.popup() - console.log("RightButton") - } - if(mouse.button === Qt.LeftButton){ - switch(mouse.modifiers){ - case Qt.ControlModifier : - item.DelegateModel.inMultiSelect = !item.DelegateModel.inMultiSelect - break; - case Qt.ShiftModifier : - delegateModelGroup.removeAll(); - var start = lastIndex <= index? lastIndex: index; - var end = lastIndex >= index? lastIndex: index; - for(var i = start;i <= end;i++){ - visualModel.items.get(i).inMultiSelect = true - } - break; - default: - delegateModelGroup.removeAll(); - item.DelegateModel.inMultiSelect = true - lastIndex = index - break; - } - } - } - } - } - } - - ListView { - id: tb - x: 20 - anchors.top: sites_add.bottom - anchors.topMargin: 10 - width: parent.width - 40 - anchors.bottom: sites_delete.top - anchors.bottomMargin: 10 - spacing: 1 - clip: true - focus: true - activeFocusOnTab: true - keyNavigationEnabled: true - property int currentRow: -1 - model: visualModel - - Keys.onPressed: { - if (event.key === Qt.Key_PageUp) { - let idx = tb.indexAt(1, tb.contentY) - tb.positionViewAtIndex(idx-20, ListView.Beginning) - event.accepted = true - } - else if (event.key === Qt.Key_PageDown) { - let idx = tb.indexAt(1, tb.contentY) - tb.positionViewAtIndex(idx+20, ListView.Beginning) - event.accepted = true - } - else if (event.key === Qt.Key_Home) { - tb.positionViewAtBeginning() - event.accepted = true - } - else if (event.key === Qt.Key_End) { - tb.positionViewAtEnd() - event.accepted = true - } - else if (event.key === Qt.Key_Delete) { - let items = [] - for(let i = 0; i < visualModel.count; i++){ - if (visualModel.items.get(i).inMultiSelect) items.push(i) - } - SitesLogic.onPushButtonSitesDeleteClicked(items) - event.accepted = true - } - else if (event.key === Qt.Key_A) { - delegateModelGroup.selectAll() - event.accepted = true - } - } - - } - - BlueButtonType { - id: sites_delete - anchors.bottom: select_all.top - anchors.bottomMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - height: 31 - font.pixelSize: 16 - text: qsTr("Delete selected") - onClicked: { - let items = [] - for(let i = 0; i < visualModel.count; i++){ - if (visualModel.items.get(i).inMultiSelect) items.push(i) - } - - SitesLogic.onPushButtonSitesDeleteClicked(items) - } - } - - BlueButtonType { - id: select_all - anchors.bottom: sites_export.top - anchors.bottomMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - height: 31 - font.pixelSize: 16 - text: qsTr("Select all") - onClicked: { - delegateModelGroup.selectAll() - } - } - - BlueButtonType { - id: sites_export - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - anchors.horizontalCenter: parent.horizontalCenter - height: 31 - font.pixelSize: 16 - text: qsTr("Export all") - onClicked: { - SitesLogic.onPushButtonSitesExportClicked() - } - } -} diff --git a/client/ui/qml/Pages/PageStart.qml b/client/ui/qml/Pages/PageStart.qml deleted file mode 100644 index a752817f9..000000000 --- a/client/ui/qml/Pages/PageStart.qml +++ /dev/null @@ -1,356 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.Start - logic: StartPageLogic - - Connections { - target: StartPageLogic - - function onShowPassphraseRequestMessage() { - popupWithTextField.open() - } - } - - BackButton { - id: back_from_start - visible: pageLoader.depth > 1 - } - - ImageButtonType { - anchors { - right: parent.right - top: parent.top - } - - width: 41 - height: 41 - imgMarginHover: 8 - imgMargin: 9 - icon.source: "qrc:/images/settings_grey.png" - visible: !GeneralSettingsLogic.existsAnyServer - onClicked: { - UiLogic.goToPage(PageEnum.GeneralSettings) - } - } - - Caption { - id: caption - text: start_switch_page.checked ? - qsTr("Setup your server to use VPN") : - qsTr("Connect to the already created VPN server") - } - - Logo { - id: logo - anchors.bottom: parent.bottom - } - - BasicButtonType { - id: start_switch_page - width: parent.width - 2 * GC.defaultMargin - implicitHeight: 40 - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: logo.top - anchors.bottomMargin: 10 - anchors.topMargin: 20 - - text: qsTr("Set up your own server") - checked: false - checkable: true - onCheckedChanged: { - if (checked) { - page_start_new_server.visible = true - page_start_import.visible = false - text = qsTr("Import connection"); - } - else { - page_start_new_server.visible = false - page_start_import.visible = true - text = qsTr("Set up your own server"); - } - } - - background: Rectangle { - anchors.fill: parent - border.width: 1 - border.color: "#211C4A" - radius: 4 - } - - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#100A44" - text: start_switch_page.text - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - antialiasing: true - } - - Item { - id: page_start_import - width: parent.width - anchors.top: caption.bottom - anchors.bottom: start_switch_page.top - anchors.bottomMargin: 10 - - visible: true - - LabelType { - id: label_connection_code - anchors.top: parent.top - anchors.topMargin: 20 - anchors.horizontalCenter: parent.horizontalCenter - text: qsTr("Connection code") - } - TextFieldType { - id: lineEdit_start_existing_code - anchors.top: label_connection_code.bottom - anchors.horizontalCenter: parent.horizontalCenter - placeholderText: "vpn://..." - text: StartPageLogic.lineEditStartExistingCodeText - onEditingFinished: { - StartPageLogic.lineEditStartExistingCodeText = text - } - } - BlueButtonType { - id: new_sever_import - anchors.horizontalCenter: parent.horizontalCenter - y: 210 - anchors.top: lineEdit_start_existing_code.bottom - anchors.topMargin: 10 - text: qsTr("Connect") - onClicked: { - StartPageLogic.onPushButtonImport() - } - } - - - BlueButtonType { - id: qr_code_import_open - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: new_sever_import.bottom - anchors.topMargin: 40 - - text: qsTr("Open file") - onClicked: { - StartPageLogic.onPushButtonImportOpenFile() - } - enabled: StartPageLogic.pushButtonConnectEnabled - } - - BlueButtonType { - id: qr_code_import - visible: GC.isMobile() - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: qr_code_import_open.bottom - anchors.topMargin: 10 - - text: qsTr("Scan QR code") - onClicked: { - if (Qt.platform.os === "ios") { - UiLogic.goToPage(PageEnum.QrDecoderIos) - } else { - StartPageLogic.startQrDecoder() - } - } - enabled: StartPageLogic.pushButtonConnectEnabled - } - - BlueButtonType { - id: btn_restore_cfg - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: qr_code_import.bottom - anchors.topMargin: 30 - visible: UiLogic.pagesStackDepth === 1 - enabled: StartPageLogic.pushButtonConnectEnabled - - text: qsTr("Restore app config") - onClicked: { - AppSettingsLogic.onPushButtonRestoreAppConfigClicked() - } - } - } - - - Item { - id: page_start_new_server - width: parent.width - anchors.top: caption.bottom - anchors.bottom: start_switch_page.top - anchors.bottomMargin: 10 - - visible: false - - BasicButtonType { - id: new_sever_get_info - width: parent.width - 80 - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.topMargin: 5 - - text: qsTr("How to get own server? →") - background: Item { - anchors.fill: parent - } - - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#15CDCB"; - text: new_sever_get_info.text - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - antialiasing: true - checkable: true - checked: true - onClicked: { - Qt.openUrlExternally("https://amnezia.org/instruction.html") - } - } - LabelType { - id: label_server_ip - x: 40 - anchors.top: new_sever_get_info.bottom - text: qsTr("Server IP address [:port]") - } - TextFieldType { - id: new_server_ip - anchors.top: label_server_ip.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: StartPageLogic.lineEditIpText - onEditingFinished: { StartPageLogic.lineEditIpText = text } - onTextEdited: { StartPageLogic.lineEditIpText = text } - - validator: RegularExpressionValidator { - regularExpression: StartPageLogic.ipAddressPortRegex - } - } - - LabelType { - id:label_login - x: 40 - anchors.top: new_server_ip.bottom - text: qsTr("Login to connect via SSH") - } - TextFieldType { - id: new_server_login - anchors.top: label_login.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: StartPageLogic.lineEditLoginText - onEditingFinished: { StartPageLogic.lineEditLoginText = text } - onTextEdited: { StartPageLogic.lineEditLoginText = text } - } - - LabelType { - id: label_new_server_password - x: 40 - anchors.top: new_server_login.bottom - text: qsTr("Password") - } - TextFieldType { - id: new_server_password - anchors.top: label_new_server_password.bottom - anchors.horizontalCenter: parent.horizontalCenter - - inputMethodHints: Qt.ImhSensitiveData - echoMode: TextInput.Password - text: StartPageLogic.lineEditPasswordText - onEditingFinished: { StartPageLogic.lineEditPasswordText = text } - onTextEdited: { StartPageLogic.lineEditPasswordText = text } - onAccepted: { StartPageLogic.onPushButtonConnect() } - } - TextFieldType { - id: new_server_ssh_key - anchors.top: label_new_server_password.bottom - anchors.horizontalCenter: parent.horizontalCenter - - visible: false - height: 71 - font.pixelSize: 10 - verticalAlignment: Text.AlignTop - inputMethodHints: Qt.ImhSensitiveData - - text: StartPageLogic.textEditSshKeyText - onEditingFinished: { StartPageLogic.textEditSshKeyText = text } - onTextEdited: { StartPageLogic.textEditSshKeyText = text } - onAccepted: { StartPageLogic.onPushButtonConnect() } - } - - LabelType { - x: 40 - y: 390 - width: 301 - height: 41 - text: StartPageLogic.labelWaitInfoText - visible: StartPageLogic.labelWaitInfoVisible - wrapMode: Text.Wrap - } - - BlueButtonType { - id: new_sever_connect - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: new_server_ssh_key.bottom - anchors.topMargin: 10 - - text: StartPageLogic.pushButtonConnectText - onClicked: { - StartPageLogic.onPushButtonConnect() - } - enabled: StartPageLogic.pushButtonConnectEnabled - } - - UrlButtonType { - id: new_sever_connect_key - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: new_sever_connect.bottom - - width: 281 - height: 21 - text: qsTr("Connect using SSH key") - - label.font.pixelSize: 16 - checkable: true - checked: StartPageLogic.pushButtonConnectKeyChecked - onCheckedChanged: { - StartPageLogic.pushButtonConnectKeyChecked = checked - label_new_server_password.text = checked ? qsTr("Private key") : qsTr("Password") - new_sever_connect_key.text = checked ? qsTr("Connect using SSH password") : qsTr("Connect using SSH key") - new_server_password.visible = !checked - new_server_ssh_key.visible = checked - } - } - } - - PopupWithTextField { - id: popupWithTextField - placeholderText: "Enter private key passphrase" - yesFunc: function() { - editingFinished() - close() - StartPageLogic.passphraseDialogClosed() - text = "" - } - noFunc: function() { - close() - StartPageLogic.passphraseDialogClosed() - } - onEditingFinished: { - StartPageLogic.privateKeyPassphrase = text - } - } -} diff --git a/client/ui/qml/Pages/PageVPN.qml b/client/ui/qml/Pages/PageVPN.qml deleted file mode 100644 index 0e6f5078e..000000000 --- a/client/ui/qml/Pages/PageVPN.qml +++ /dev/null @@ -1,387 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.Vpn - logic: VpnLogic - - Image { - id: bg_top - anchors.horizontalCenter: parent.horizontalCenter - y: 0 - width: parent.width - height: parent.height * 0.28 - source: "qrc:/images/background_connected.png" - } - - LabelType { - x: 10 - y: 10 - width: 100 - height: 21 - text: VpnLogic.labelVersionText - color: "#dddddd" - font.pixelSize: 12 - } - - UrlButtonType { - id: button_donate - y: 10 - anchors.horizontalCenter: parent.horizontalCenter - height: 21 - label.color: "#D4D4D4" - label.text: qsTr("Donate") - - onClicked: { - UiLogic.goToPage(PageEnum.Test) - } - } - - ImageButtonType { - x: parent.width - 40 - y: 0 - width: 41 - height: 41 - imgMarginHover: 8 - imgMargin: 9 - icon.source: "qrc:/images/settings_grey.png" - onClicked: { - UiLogic.goToPage(PageEnum.GeneralSettings) - } - } - - LabelType { - id: lb_log_enabled - anchors.top: button_donate.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - height: 21 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - text: "Logging enabled!" - color: "#D4D4D4" - - visible: VpnLogic.labelLogEnabledVisible - } - - AnimatedImage { - id: connect_anim - source: "qrc:/images/animation.gif" - anchors.top: bg_top.bottom - anchors.topMargin: 10 - anchors.horizontalCenter: root.horizontalCenter - width: Math.min(parent.width, parent.height) / 4 - height: width - - visible: !VpnLogic.pushButtonConnectVisible - paused: VpnLogic.pushButtonConnectVisible && !root.pageActive - //VisibleBehavior on visible { } - } - - BasicButtonType { - id: button_connect - anchors.horizontalCenter: connect_anim.horizontalCenter - anchors.verticalCenter: connect_anim.verticalCenter - width: connect_anim.width - height: width - checkable: true - checked: VpnLogic.pushButtonConnectChecked - onClicked: VpnLogic.onPushButtonConnectClicked() - background: Image { - anchors.fill: parent - source: button_connect.checked ? "qrc:/images/connected.png" - : "qrc:/images/disconnected.png" - } - contentItem: Item {} - antialiasing: true - enabled: VpnLogic.pushButtonConnectEnabled && VpnLogic.isContainerSupportedByCurrentPlatform - opacity: VpnLogic.pushButtonConnectVisible ? 1 : 0 - -// transitions: Transition { -// NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad; duration: 500 } -// } - } - - - LabelType { - id: lb_state - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: button_connect.bottom - width: parent.width - height: 21 - horizontalAlignment: Text.AlignHCenter - text: VpnLogic.labelStateText - } - - RowLayout { - id: layout1 - anchors.top: lb_state.bottom - //anchors.topMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - height: 21 - - - LabelType { - Layout.alignment: Qt.AlignRight - height: 21 - text: ( VpnLogic.isContainerHaveAuthData ? qsTr("Server") : qsTr("Profile")) + ": " - } - - BasicButtonType { - Layout.alignment: Qt.AlignLeft - height: 21 - background: Item {} - text: VpnLogic.labelCurrentServer + (VpnLogic.isContainerHaveAuthData ? " →" : "") - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - onClicked: { - UiLogic.goToPage(PageEnum.ServersList) - } - } - } - - RowLayout { - id: layout2 - anchors.top: layout1.bottom - anchors.topMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - height: 21 - - - LabelType { - Layout.alignment: Qt.AlignRight - height: 21 - text: qsTr("Proto") + ": " - } - - BasicButtonType { - Layout.alignment: Qt.AlignLeft - height: 21 - background: Item {} - text: VpnLogic.labelCurrentService + (VpnLogic.isContainerHaveAuthData ? " →" : "") - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - onClicked: { - if (VpnLogic.isContainerHaveAuthData) UiLogic.onGotoCurrentProtocolsPage() - } - } - } - - RowLayout { - id: layout3 - anchors.top: layout2.bottom - anchors.topMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - height: 21 - - - LabelType { - Layout.alignment: Qt.AlignRight - height: 21 - text: qsTr("DNS") + ": " - } - - BasicButtonType { - Layout.alignment: Qt.AlignLeft - height: 21 - implicitWidth: implicitContentWidth > root.width * 0.6 ? root.width * 0.6 : implicitContentWidth + leftPadding + rightPadding - background: Item {} - text: VpnLogic.labelCurrentDns + (VpnLogic.isContainerHaveAuthData ? " →" : "") - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - onClicked: { - if (VpnLogic.isContainerHaveAuthData) UiLogic.goToPage(PageEnum.NetworkSettings) - } - } - - SvgImageType { - svg.source: VpnLogic.amneziaDnsEnabled ? "qrc:/images/svg/gpp_good_black_24dp.svg" : "qrc:/images/svg/gpp_maybe_black_24dp.svg" - color: VpnLogic.amneziaDnsEnabled ? "#22aa33" : "orange" - width: 25 - height: 25 - } - } - - - LabelType { - id: error_text - anchors.top: layout3.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 20 - width: parent.width - 20 - - height: 21 - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.Wrap - text: VpnLogic.labelErrorText - color: "red" - } - - Item { - x: 0 - anchors.bottom: line.top - anchors.bottomMargin: GC.isMobile() ? 0 :10 - width: parent.width - height: 51 - Image { - anchors.horizontalCenter: upload_label.horizontalCenter - y: 10 - width: 15 - height: 15 - source: "qrc:/images/upload.png" - } - Image { - anchors.horizontalCenter: download_label.horizontalCenter - y: 10 - width: 15 - height: 15 - source: "qrc:/images/download.png" - } - Text { - id: download_label - x: 0 - y: 20 - width: 130 - height: 30 - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#4171D6" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - text: VpnLogic.labelSpeedReceivedText - } - Text { - id: upload_label - x: parent.width - width - y: 20 - width: 130 - height: 30 - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#42D185" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - text: VpnLogic.labelSpeedSentText - } - } - - Rectangle { - id: line - x: 20 - width: parent.width - 40 - height: 1 - anchors.bottom: GC.isMobile() ? root.bottom : conn_type_label.top - anchors.bottomMargin: 10 - color: "#DDDDDD" - } - - Text { - id: conn_type_label - visible: !GC.isMobile() - x: 20 - anchors.bottom: conn_type_group.top - anchors.bottomMargin: GC.isMobile() ? 0 :10 - width: 281 - height: GC.isMobile() ? 0: 21 - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 15 - color: "#181922" - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - text: qsTr("How to use VPN") - } - - Item { - id: conn_type_group - x: 20 - visible: !GC.isMobile() - anchors.bottom: button_add_site.top - width: 351 - height: GC.isMobile() ? 0: 91 - enabled: VpnLogic.widgetVpnModeEnabled - RadioButtonType { - x: 0 - y: 0 - width: 341 - height: 19 - checked: VpnLogic.radioButtonVpnModeAllSitesChecked - text: qsTr("For all connections") - onClicked: VpnLogic.onRadioButtonVpnModeAllSitesClicked(true) - } - RadioButtonType { - enabled: VpnLogic.isCustomRoutesSupported - x: 0 - y: 60 - width: 341 - height: 19 - text: qsTr("Except selected sites") - checked: VpnLogic.radioButtonVpnModeExceptSitesChecked - onClicked: VpnLogic.onRadioButtonVpnModeExceptSitesClicked(true) - } - RadioButtonType { - enabled: VpnLogic.isCustomRoutesSupported - x: 0 - y: 30 - width: 341 - height: 19 - text: qsTr("For selected sites") - checked: VpnLogic.radioButtonVpnModeForwardSitesChecked - onClicked: VpnLogic.onRadioButtonVpnModeForwardSitesClicked(true) - } - } - - BasicButtonType { - id: button_add_site - visible: !GC.isMobile() - anchors.horizontalCenter: parent.horizontalCenter - y: parent.height - 60 - width: parent.width - 40 - height: GC.isMobile() ? 0: 40 - text: qsTr("+ Add site") - enabled: ! VpnLogic.radioButtonVpnModeAllSitesChecked - background: Rectangle { - anchors.fill: parent - radius: 4 - color: { - if (!button_add_site.enabled) { - return "#484952" - } - if (button_add_site.containsMouse) { - return "#282932" - } - return "#181922" - } - } - - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#D4D4D4" - text: button_add_site.text - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - antialiasing: true - onClicked: { - UiLogic.goToPage(PageEnum.Sites) - } - } -} diff --git a/client/ui/qml/Pages/PageViewConfig.qml b/client/ui/qml/Pages/PageViewConfig.qml deleted file mode 100644 index 24ccda451..000000000 --- a/client/ui/qml/Pages/PageViewConfig.qml +++ /dev/null @@ -1,138 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import PageEnum 1.0 -import "./" -import "../Controls" -import "../Config" - -PageBase { - id: root - page: PageEnum.ViewConfig - logic: ViewConfigLogic - - readonly property double rowHeight: ta_last_config.contentHeight / ta_last_config.textArea.lineCount - - BackButton {} - - Caption { - id: caption - text: qsTr("Check config") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - TextAreaType { - id: ta_config - - Layout.topMargin: 5 - Layout.bottomMargin: 20 - Layout.fillWidth: true - Layout.leftMargin: 1 - Layout.rightMargin: 1 - Layout.preferredHeight: ViewConfigLogic.warningActive ? 250 : fl.height - 70 - flickableDirection: Flickable.AutoFlickIfNeeded - - textArea.readOnly: true - textArea.text: logic.configText - } - - LabelType { - id: lb_att - visible: ViewConfigLogic.warningActive - text: qsTr("Attention! -The config above contains cached OpenVPN connection profile. -AmneziaVPN detected this profile may contain malicious scripts. Please, carefully review the config and import this config only if you completely trust it.") - Layout.fillWidth: true - } - - LabelType { - visible: ViewConfigLogic.warningActive - text: qsTr("Suspicious string:") - Layout.fillWidth: true - } - - TextAreaType { - id: ta_mal - visible: ViewConfigLogic.warningActive - - Layout.topMargin: 5 - Layout.bottomMargin: 20 - Layout.fillWidth: true - Layout.leftMargin: 1 - Layout.rightMargin: 1 - Layout.preferredHeight: 60 - flickableDirection: Flickable.AutoFlickIfNeeded - - textArea.readOnly: true - textArea.text: logic.openVpnMalStrings - textArea.textFormat: TextEdit.RichText - } - - LabelType { - visible: ViewConfigLogic.warningActive - text: qsTr("Cached connection profile:") - Layout.fillWidth: true - } - - TextAreaType { - id: ta_last_config - visible: ViewConfigLogic.warningActive - - Layout.topMargin: 5 - Layout.bottomMargin: 20 - Layout.fillWidth: true - Layout.leftMargin: 1 - Layout.rightMargin: 1 - Layout.preferredHeight: 350 - flickableDirection: Flickable.AutoFlickIfNeeded - - textArea.readOnly: true - textArea.text: logic.openVpnLastConfigs - textArea.textFormat: TextEdit.RichText - - Connections { - target: logic - function onWarningStringNumberChanged(n) { - ta_last_config.contentY = rowHeight * n - ta_last_config.height / 2 - } - } - } - - RowLayout { - id: btns_row - - BasicButtonType { - Layout.preferredWidth: (content.width - parent.spacing) /2 - Layout.preferredHeight: 40 - font.pixelSize: btn_import.font.pixelSize - text: qsTr("Cancel") - onClicked: { - UiLogic.closePage() - } - } - - BlueButtonType { - id: btn_import - Layout.preferredWidth: (content.width - parent.spacing) /2 - text: qsTr("Import config") - onClicked: { - logic.importConfig() - } - } - } - } - } - - } diff --git a/client/ui/qml/Pages/Protocols/PageProtoCloak.qml b/client/ui/qml/Pages/Protocols/PageProtoCloak.qml deleted file mode 100644 index 2b5b12ca0..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtoCloak.qml +++ /dev/null @@ -1,194 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageProtocolBase { - id: root - protocol: ProtocolEnum.Cloak - logic: UiLogic.protocolLogic(protocol) - - BackButton { - id: back - enabled: !logic.pushButtonCancelVisible - } - - Caption { - id: caption - text: qsTr("Cloak Settings") - } - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: caption.bottom - anchors.left: root.left - anchors.right: root.right - anchors.bottom: pb_save.top - anchors.margins: 20 - anchors.topMargin: 10 - - - RowLayout { - Layout.fillWidth: true - - LabelType { - height: 31 - text: qsTr("Cipher") - Layout.preferredWidth: 0.3 * root.width - 10 - } - - ComboBoxType { - Layout.fillWidth: true - height: 31 - model: [ - qsTr("chacha20-poly1305"), - qsTr("aes-256-gcm"), - qsTr("aes-192-gcm"), - qsTr("aes-128-gcm") - ] - currentIndex: { - for (let i = 0; i < model.length; ++i) { - if (logic.comboBoxCipherText === model[i]) { - return i - } - } - return -1 - } - onCurrentTextChanged: { - logic.comboBoxCipherText = currentText - } - } - } - - RowLayout { - Layout.fillWidth: true - - LabelType { - Layout.preferredWidth: 0.3 * root.width - 10 - height: 31 - text: qsTr("Fake Web Site") - } - - TextFieldType { - id: lineEdit_proto_cloak_site - Layout.fillWidth: true - height: 31 - text: logic.lineEditSiteText - onEditingFinished: { - logic.lineEditSiteText = text - } - } - } - - RowLayout { - Layout.fillWidth: true - - LabelType { - Layout.preferredWidth: 0.3 * root.width - 10 - height: 31 - text: qsTr("Port") - } - - TextFieldType { - id: lineEdit_proto_cloak_port - Layout.fillWidth: true - height: 31 - text: logic.lineEditPortText - onEditingFinished: { - logic.lineEditPortText = text - } - enabled: logic.lineEditPortEnabled - } - } - - Item { - Layout.fillHeight: true - } - } - - LabelType { - id: label_server_busy - horizontalAlignment: Text.AlignHCenter - Layout.maximumWidth: parent.width - Layout.fillWidth: true - visible: logic.labelServerBusyVisible - text: logic.labelServerBusyText - } - - LabelType { - id: label_proto_cloak_info - horizontalAlignment: Text.AlignHCenter - Layout.maximumWidth: parent.width - Layout.fillWidth: true - visible: logic.labelInfoVisible - text: logic.labelInfoText - } - - ProgressBar { - id: progressBar_proto_cloak_reset - anchors.horizontalCenter: parent.horizontalCenter - anchors.fill: pb_save - from: 0 - to: logic.progressBarResetMaximum - value: logic.progressBarResetValue - background: Rectangle { - implicitWidth: parent.width - implicitHeight: parent.height - color: "#100A44" - radius: 4 - } - - contentItem: Item { - implicitWidth: parent.width - implicitHeight: parent.height - Rectangle { - width: progressBar_proto_cloak_reset.visualPosition * parent.width - height: parent.height - radius: 4 - color: Qt.rgba(255, 255, 255, 0.15); - } - } - visible: logic.progressBarResetVisible - LabelType { - anchors.left: parent.left - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - text: logic.progressBarText - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#D4D4D4" - visible: logic.progressBarTextVisible - } - } - BlueButtonType { - id: pb_save - anchors.horizontalCenter: parent.horizontalCenter - enabled: logic.pageEnabled - anchors.bottom: root.bottom - anchors.bottomMargin: 20 - width: root.width - 60 - height: 40 - text: qsTr("Save and restart VPN") - visible: logic.pushButtonSaveVisible - onClicked: { - logic.onPushButtonSaveClicked() - } - } - - BlueButtonType { - anchors.fill: pb_save - text: qsTr("Cancel") - visible: logic.pushButtonCancelVisible - enabled: logic.pushButtonCancelVisible - onClicked: { - logic.onPushButtonCancelClicked() - } - } -} diff --git a/client/ui/qml/Pages/Protocols/PageProtoOpenVPN.qml b/client/ui/qml/Pages/Protocols/PageProtoOpenVPN.qml deleted file mode 100644 index 507f5f091..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtoOpenVPN.qml +++ /dev/null @@ -1,454 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageProtocolBase { - id: root - protocol: ProtocolEnum.OpenVpn - logic: UiLogic.protocolLogic(protocol) - - BackButton { - id: back - enabled: !logic.pushButtonCancelVisible - } - - Caption { - id: caption - text: qsTr("OpenVPN Settings") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: GC.defaultMargin - 1 - - ColumnLayout { - visible: !logic.isThirdPartyConfig - - LabelType { - id: lb_subnet - enabled: logic.pageEnabled - height: 21 - text: qsTr("VPN Addresses Subnet") - } - - TextFieldType { - id: tf_subnet - enabled: logic.pageEnabled - implicitWidth: parent.width - height: 31 - text: logic.lineEditSubnetText - onEditingFinished: { - logic.lineEditSubnetText = text - } - } - - LabelType { - id: lb_proto - enabled: logic.pageEnabled - Layout.topMargin: 20 - height: 21 - text: qsTr("Network protocol") - } - - Rectangle { - id: rect_proto - enabled: logic.pageEnabled - implicitWidth: parent.width - height: 71 - border.width: 1 - border.color: "lightgray" - radius: 2 - RadioButtonType { - x: 10 - y: 40 - width: 171 - height: 19 - text: qsTr("TCP") - enabled: logic.radioButtonTcpEnabled - checked: logic.radioButtonTcpChecked - onCheckedChanged: { - logic.radioButtonTcpChecked = checked - } - } - RadioButtonType { - x: 10 - y: 10 - width: 171 - height: 19 - text: qsTr("UDP") - checked: logic.radioButtonUdpChecked - onCheckedChanged: { - logic.radioButtonUdpChecked = checked - } - enabled: logic.radioButtonUdpEnabled - } - } - - RowLayout { - enabled: logic.pageEnabled - Layout.topMargin: 10 - Layout.fillWidth: true - LabelType { - id: lb_port - height: 31 - text: qsTr("Port") - Layout.preferredWidth: root.width / 2 - 10 - } - TextFieldType { - id: tf_port - Layout.fillWidth: true - - height: 31 - text: logic.lineEditPortText - onEditingFinished: { - logic.lineEditPortText = text - } - enabled: logic.lineEditPortEnabled - } - } - - CheckBoxType { - id: check_auto_enc - enabled: logic.pageEnabled - implicitWidth: parent.width - height: 21 - text: qsTr("Auto-negotiate encryption") - checked: logic.checkBoxAutoEncryptionChecked - onCheckedChanged: { - logic.checkBoxAutoEncryptionChecked = checked - } - onClicked: { - logic.checkBoxAutoEncryptionClicked() - } - } - - LabelType { - id: lb_cipher - enabled: logic.pageEnabled - height: 21 - text: qsTr("Cipher") - } - - ComboBoxType { - id: cb_cipher - enabled: logic.pageEnabled && !check_auto_enc.checked - implicitWidth: parent.width - - height: 31 - model: [ - qsTr("AES-256-GCM"), - qsTr("AES-192-GCM"), - qsTr("AES-128-GCM"), - qsTr("AES-256-CBC"), - qsTr("AES-192-CBC"), - qsTr("AES-128-CBC"), - qsTr("ChaCha20-Poly1305"), - qsTr("ARIA-256-CBC"), - qsTr("CAMELLIA-256-CBC"), - qsTr("none") - ] - currentIndex: { - for (let i = 0; i < model.length; ++i) { - if (logic.comboBoxVpnCipherText === model[i]) { - return i - } - } - return -1 - } - onCurrentTextChanged: { - logic.comboBoxVpnCipherText = currentText - } - } - - LabelType { - id: lb_hash - enabled: logic.pageEnabled - height: 21 - Layout.topMargin: 20 - text: qsTr("Hash") - } - - ComboBoxType { - id: cb_hash - enabled: logic.pageEnabled && !check_auto_enc.checked - height: 31 - implicitWidth: parent.width - model: [ - qsTr("SHA512"), - qsTr("SHA384"), - qsTr("SHA256"), - qsTr("SHA3-512"), - qsTr("SHA3-384"), - qsTr("SHA3-256"), - qsTr("whirlpool"), - qsTr("BLAKE2b512"), - qsTr("BLAKE2s256"), - qsTr("SHA1") - ] - currentIndex: { - for (let i = 0; i < model.length; ++i) { - if (logic.comboBoxVpnHashText === model[i]) { - return i - } - } - return -1 - } - onCurrentTextChanged: { - logic.comboBoxVpnHashText = currentText - } - } - - CheckBoxType { - id: check_tls - enabled: logic.pageEnabled - implicitWidth: parent.width - Layout.topMargin: 20 - height: 21 - text: qsTr("Enable TLS auth") - checked: logic.checkBoxTlsAuthChecked - onCheckedChanged: { - logic.checkBoxTlsAuthChecked = checked - } - - } - - CheckBoxType { - id: check_block_dns - enabled: logic.pageEnabled - implicitWidth: parent.width - height: 21 - text: qsTr("Block DNS requests outside of VPN") - checked: logic.checkBoxBlockDnsChecked - onCheckedChanged: { - logic.checkBoxBlockDnsChecked = checked - } - } - - BasicButtonType { - id: pb_client_config - enabled: logic.pageEnabled - implicitWidth: parent.width - height: 21 - text: qsTr("Additional client config commands →") - background: Item { - anchors.fill: parent - } - - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#15CDCB"; - text: pb_client_config.text - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } - antialiasing: true - checkable: true - checked: StartPageLogic.pushButtonConnectKeyChecked - } - - Rectangle { - id: rect_client_conf - enabled: logic.pageEnabled - implicitWidth: root.width - 60 - height: 101 - border.width: 1 - border.color: "lightgray" - radius: 2 - visible: pb_client_config.checked - - ScrollView { - anchors.fill: parent - TextArea { - id: te_client_config - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - text: logic.textAreaAdditionalClientConfig - onEditingFinished: { - logic.textAreaAdditionalClientConfig = text - } - } - } - } - - BasicButtonType { - id: pb_server_config - enabled: logic.pageEnabled - implicitWidth: parent.width - height: 21 - text: qsTr("Additional server config commands →") - background: Item { - anchors.fill: parent - } - - contentItem: Text { - anchors.fill: parent - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#15CDCB"; - text: pb_server_config.text - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } - antialiasing: true - checkable: true - checked: StartPageLogic.pushButtonConnectKeyChecked - } - - Rectangle { - id: rect_server_conf - enabled: logic.pageEnabled - implicitWidth: root.width - 60 - height: 101 - border.width: 1 - border.color: "lightgray" - radius: 2 - visible: pb_server_config.checked - - ScrollView { - anchors.fill: parent - TextArea { - id: te_server_config - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - text: logic.textAreaAdditionalServerConfig - onEditingFinished: { - logic.textAreaAdditionalServerConfig = text - } - } - } - } - - LabelType { - id: label_server_busy - enabled: logic.pageEnabled - horizontalAlignment: Text.AlignHCenter - Layout.maximumWidth: parent.width - Layout.fillWidth: true - visible: logic.labelServerBusyVisible - text: logic.labelServerBusyText - } - - LabelType { - id: label_proto_openvpn_info - enabled: logic.pageEnabled - horizontalAlignment: Text.AlignHCenter - Layout.maximumWidth: parent.width - Layout.fillWidth: true - height: 41 - visible: logic.labelProtoOpenVpnInfoVisible - text: logic.labelProtoOpenVpnInfoText - } - - Rectangle { - id: it_save - implicitWidth: parent.width - Layout.topMargin: 20 - height: 40 - - BlueButtonType { - id: pb_save - enabled: logic.pageEnabled - z: 1 - height: 40 - text: qsTr("Save and restart VPN") - width: parent.width - visible: logic.pushButtonSaveVisible - onClicked: { - logic.onPushButtonSaveClicked() - } - } - - BlueButtonType { - z: 1 - anchors.fill: pb_save - text: qsTr("Cancel") - visible: logic.pushButtonCancelVisible - enabled: logic.pushButtonCancelVisible - onClicked: { - logic.onPushButtonCancelClicked() - } - } - - ProgressBar { - id: progress_save - anchors.fill: pb_save - from: 0 - to: logic.progressBarResetMaximum - value: logic.progressBarResetValue - visible: logic.progressBarResetVisible - background: Rectangle { - implicitWidth: parent.width - implicitHeight: parent.height - color: "#100A44" - radius: 4 - } - - contentItem: Item { - implicitWidth: parent.width - implicitHeight: parent.height - Rectangle { - width: progress_save.visualPosition * parent.width - height: parent.height - radius: 4 - color: Qt.rgba(255, 255, 255, 0.15); - } - } - } - - LabelType { - anchors.left: parent.left - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - text: logic.progressBarText - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#D4D4D4" - visible: logic.progressBarTextVisible - } - } - - } - - ColumnLayout { - visible: logic.isThirdPartyConfig - TextAreaType { - id: ta_config - - Layout.topMargin: 5 - Layout.bottomMargin: 20 - Layout.fillWidth: true - Layout.leftMargin: 1 - Layout.rightMargin: 1 - Layout.preferredHeight: fl.height - 70 - flickableDirection: Flickable.AutoFlickIfNeeded - - textArea.readOnly: true - textArea.text: logic.openVpnLastConfigText - } - } - } - } -} diff --git a/client/ui/qml/Pages/Protocols/PageProtoSftp.qml b/client/ui/qml/Pages/Protocols/PageProtoSftp.qml deleted file mode 100644 index c6a0602f0..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtoSftp.qml +++ /dev/null @@ -1,140 +0,0 @@ -import QtQuick -import QtQuick.Controls -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageProtocolBase { - id: root - protocol: ProtocolEnum.Sftp - logic: UiLogic.protocolLogic(protocol) - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("SFTP settings") - } - - Rectangle { - id: frame_settings - width: parent.width - anchors.top: caption.bottom - anchors.topMargin: 10 - - border.width: 1 - border.color: "lightgray" - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - radius: 2 - Grid { - id: grid - anchors.fill: parent - columns: 2 - horizontalItemAlignment: Grid.AlignHCenter - verticalItemAlignment: Grid.AlignVCenter - topPadding: 5 - leftPadding: 30 - rightPadding: 30 - spacing: 5 - - - LabelType { - width: 130 - text: qsTr("Port") - } - TextFieldType { - id: tf_port_num - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - text: logic.labelTftpPortText - readOnly: true - } - - LabelType { - width: 130 - text: qsTr("User Name") - } - TextFieldType { - id: tf_user_name - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - text: logic.labelTftpUserNameText - readOnly: true - } - - LabelType { - width: 130 - text: qsTr("Password") - } - TextFieldType { - id: tf_password - width: parent.width - 130 - parent.spacing - parent.leftPadding * 2 - text: logic.labelTftpPasswordText - readOnly: true - } - } - } - - RichLabelType { - anchors.bottom: check_persist.top - anchors.bottomMargin: 10 - width: parent.width - 60 - x: 30 - font.pixelSize: 14 - - readonly property string windows_text: "In order to mount remote SFTP folder as local drive, perform following steps: -
    -
  • Install the latest version of WinFsp.
  • -
  • Install the latest version of SSHFS-Win. Choose the x64 or x86 installer according to your computer's architecture.
  • -
" - - readonly property string macos_text: "In order to mount remote SFTP folder as local folder, perform following steps: -
    -
  • Install the latest version of macFUSE.
  • -
  • Install the latest version of SSHFS.
  • -
" - - text: { - if (Qt.platform.os == "windows") return windows_text - else if (Qt.platform.os == "osx") return macos_text - else if (Qt.platform.os == "linux") return "" - else return "" - } - } - - CheckBoxType { - id: check_persist - visible: false - anchors.bottom: pb_mount.top - anchors.bottomMargin: 10 - x: 30 - width: parent.width - height: 21 - text: qsTr("Restore drive when client starts") - checked: logic.checkBoxSftpRestoreChecked - onCheckedChanged: { - logic.checkBoxSftpRestoreChecked = checked - } - onClicked: { - logic.checkBoxSftpRestoreClicked() - } - } - - BlueButtonType { - id: pb_mount - visible: GC.isDesktop() - enabled: logic.pushButtonSftpMountEnabled - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - x: 30 - width: parent.width - 60 - height: 40 - text: qsTr("Mount drive") - onClicked: { - logic.onPushButtonSftpMountDriveClicked() - } - } -} diff --git a/client/ui/qml/Pages/Protocols/PageProtoShadowSocks.qml b/client/ui/qml/Pages/Protocols/PageProtoShadowSocks.qml deleted file mode 100644 index f3b1f83de..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtoShadowSocks.qml +++ /dev/null @@ -1,175 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageProtocolBase { - id: root - protocol: ProtocolEnum.ShadowSocks - logic: UiLogic.protocolLogic(protocol) - - BackButton { - id: back - enabled: !logic.pushButtonCancelVisible - } - - Caption { - id: caption - text: qsTr("ShadowSocks Settings") - } - - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: caption.bottom - anchors.left: root.left - anchors.right: root.right - anchors.bottom: pb_save.top - anchors.margins: 20 - anchors.topMargin: 10 - - - - RowLayout { - Layout.fillWidth: true - - LabelType { - height: 31 - text: qsTr("Cipher") - Layout.preferredWidth: 0.3 * root.width - 10 - } - - ComboBoxType { - height: 31 - Layout.fillWidth: true - - model: [ - qsTr("chacha20-ietf-poly1305"), - qsTr("xchacha20-ietf-poly1305"), - qsTr("aes-256-gcm"), - qsTr("aes-192-gcm"), - qsTr("aes-128-gcm") - ] - currentIndex: { - for (let i = 0; i < model.length; ++i) { - if (logic.comboBoxCipherText === model[i]) { - return i - } - } - return -1 - } - } - } - - RowLayout { - Layout.fillWidth: true - - LabelType { - Layout.preferredWidth: 0.3 * root.width - 10 - height: 31 - text: qsTr("Port") - } - - TextFieldType { - id: lineEdit_proto_shadowsocks_port - Layout.fillWidth: true - height: 31 - text: logic.lineEditPortText - onEditingFinished: { - logic.lineEditPortText = text - } - enabled: logic.lineEditPortEnabled - } - } - - Item { - Layout.fillHeight: true - } - - LabelType { - id: label_server_busy - horizontalAlignment: Text.AlignHCenter - Layout.maximumWidth: parent.width - Layout.fillWidth: true - visible: logic.labelServerBusyVisible - text: logic.labelServerBusyText - } - - LabelType { - id: label_proto_shadowsocks_info - horizontalAlignment: Text.AlignHCenter - Layout.maximumWidth: parent.width - Layout.fillWidth: true - visible: logic.labelInfoVisible - text: logic.labelInfoText - } - } - - ProgressBar { - id: progressBar_reset - anchors.fill: pb_save - from: 0 - to: logic.progressBarResetMaximum - value: logic.progressBarResetValue - visible: logic.progressBarResetVisible - background: Rectangle { - implicitWidth: parent.width - implicitHeight: parent.height - color: "#100A44" - radius: 4 - } - - contentItem: Item { - implicitWidth: parent.width - implicitHeight: parent.height - Rectangle { - width: progressBar_reset.visualPosition * parent.width - height: parent.height - radius: 4 - color: Qt.rgba(255, 255, 255, 0.15); - } - } - LabelType { - anchors.left: parent.left - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - text: logic.progressBarText - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#D4D4D4" - visible: logic.progressBarTextVisible - } - } - - BlueButtonType { - id: pb_save - enabled: logic.pageEnabled - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: root.bottom - anchors.bottomMargin: 20 - width: root.width - 60 - height: 40 - text: qsTr("Save and restart VPN") - visible: logic.pushButtonSaveVisible - onClicked: { - logic.onPushButtonSaveClicked() - } - } - - BlueButtonType { - anchors.fill: pb_save - text: qsTr("Cancel") - visible: logic.pushButtonCancelVisible - enabled: logic.pushButtonCancelVisible - onClicked: { - logic.onPushButtonCancelClicked() - } - } -} diff --git a/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml b/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml deleted file mode 100644 index aa4d35d47..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtoTorWebSite.qml +++ /dev/null @@ -1,69 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageProtocolBase { - id: root - protocol: ProtocolEnum.TorWebSite - logic: UiLogic.protocolLogic(protocol) - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Tor Web Site settings") - } - - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: caption.bottom - anchors.left: root.left - anchors.right: root.right - anchors.margins: 20 - anchors.topMargin: 10 - - - - RowLayout { - Layout.fillWidth: true - - LabelType { - id: lbl_onion - Layout.preferredWidth: 0.3 * root.width - 10 - text: qsTr("Web site onion address") - } - TextFieldType { - id: tf_site_address - Layout.fillWidth: true - text: logic.labelTorWebSiteAddressText - readOnly: true - } - } - - ShareConnectionButtonCopyType { - Layout.fillWidth: true - Layout.topMargin: 5 - copyText: tf_site_address.text - } - - RichLabelType { - Layout.fillWidth: true - Layout.topMargin: 15 - text: qsTr("Notes:
    -
  • Use Tor Browser to open this url.
  • -
  • After installation it takes several minutes while your onion site will become available in the Tor Network.
  • -
  • When configuring WordPress set the domain as this onion address.
  • -
-") - } - } - -} diff --git a/client/ui/qml/Pages/Protocols/PageProtoWireGuard.qml b/client/ui/qml/Pages/Protocols/PageProtoWireGuard.qml deleted file mode 100644 index e4dde50ec..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtoWireGuard.qml +++ /dev/null @@ -1,60 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.15 -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageProtocolBase { - id: root - protocol: ProtocolEnum.WireGuard - logic: UiLogic.protocolLogic(protocol) - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("WireGuard Settings") - } - - Flickable { - id: fl - width: root.width - anchors.top: caption.bottom - anchors.topMargin: 20 - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - anchors.left: root.left - anchors.leftMargin: 30 - anchors.right: root.right - anchors.rightMargin: 30 - - contentHeight: content.height - clip: true - - ColumnLayout { - id: content - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - - TextAreaType { - id: ta_config - - Layout.topMargin: 5 - Layout.bottomMargin: 20 - Layout.fillWidth: true - Layout.leftMargin: 1 - Layout.rightMargin: 1 - Layout.preferredHeight: fl.height - 70 - flickableDirection: Flickable.AutoFlickIfNeeded - - textArea.readOnly: true - textArea.text: logic.wireGuardLastConfigText - } - } - } - -} diff --git a/client/ui/qml/Pages/Protocols/PageProtocolBase.qml b/client/ui/qml/Pages/Protocols/PageProtocolBase.qml deleted file mode 100644 index 97a0f1eb4..000000000 --- a/client/ui/qml/Pages/Protocols/PageProtocolBase.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import ProtocolEnum 1.0 -import "./.." -import "../../Controls" -import "../../Config" - -PageBase { - id: root - property var protocol: ProtocolEnum.Any - page: PageEnum.ProtocolSettings -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoAmnezia.qml b/client/ui/qml/Pages/Share/PageShareProtoAmnezia.qml deleted file mode 100644 index 4e52e5018..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoAmnezia.qml +++ /dev/null @@ -1,145 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.Any - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Share for Amnezia") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height + 20 - - Behavior on contentY{ - NumberAnimation { - duration: 300 - easing.type: Easing.InOutCubic - } - } - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - Text { - id: lb_desc - Layout.fillWidth: true - font.family: "Lato" - font.styleName: "normal" - font.pixelSize: 16 - color: "#181922" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - text: ShareConnectionLogic.shareFullAccess - ? qsTr("Anyone who logs in with this code will have the same permissions to use VPN and YOUR SERVER as you. \n -This code includes your server credentials!\n -Provide this code only to TRUSTED users.") - : qsTr("Anyone who logs in with this code will be able to connect to this VPN server. \n -This code does not include server credentials.\n -New encryption keys pair will be generated.") - } - - ShareConnectionButtonType { - Layout.topMargin: 20 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: ShareConnectionLogic.shareFullAccess - ? showConfigText - : (genConfigProcess ? generatingConfigText : generateConfigText) - onClicked: { - enabled = false - genConfigProcess = true - ShareConnectionLogic.onPushButtonShareAmneziaGenerateClicked() - enabled = true - genConfigProcess = false - fl.contentY = tfShareCode.mapToItem(fl.contentItem, 0, 0).y - } - } - - TextAreaType { - id: tfShareCode - - Layout.topMargin: 20 - Layout.bottomMargin: 20 - Layout.preferredHeight: 200 - - Layout.fillWidth: true - - textArea.readOnly: true - textArea.wrapMode: TextEdit.WrapAnywhere - textArea.verticalAlignment: Text.AlignTop - textArea.text: ShareConnectionLogic.textEditShareAmneziaCodeText - - visible: tfShareCode.textArea.length > 0 - } - - - ShareConnectionButtonCopyType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - copyText: tfShareCode.textArea.text - } - ShareConnectionButtonType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file") - enabled: tfShareCode.textArea.length > 0 - visible: tfShareCode.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "amnezia_config.vpn", "*.vpn", tfShareCode.textArea.text) - } - } - - Image { - id: image_share_code - Layout.topMargin: 20 - Layout.fillWidth: true - Layout.preferredHeight: width - smooth: false - - Timer { - property int idx: 0 - interval: 1000 - running: root.pageActive && ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0 - repeat: true - onTriggered: { - idx++ - if (idx >= ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength) { - idx = 0 - } - image_share_code.source = ShareConnectionLogic.shareAmneziaQrCodeTextSeries[idx] - } - } - - visible: ShareConnectionLogic.shareAmneziaQrCodeTextSeriesLength > 0 - } - - LabelType { - Layout.fillWidth: true - text: qsTr("Scan QR code using AmneziaVPN mobile") - } - } - } -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoCloak.qml b/client/ui/qml/Pages/Share/PageShareProtoCloak.qml deleted file mode 100644 index 92bcb8328..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoCloak.qml +++ /dev/null @@ -1,99 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.Cloak - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Share Cloak Settings") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - id: lb_desc - Layout.fillWidth: true - Layout.topMargin: 10 - - horizontalAlignment: Text.AlignHCenter - - wrapMode: Text.Wrap - text: qsTr("Note: Cloak protocol using same password for all connections") - } - - ShareConnectionButtonType { - Layout.topMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: genConfigProcess ? generatingConfigText : generateConfigText - onClicked: { - enabled = false - genConfigProcess = true - ShareConnectionLogic.onPushButtonShareCloakGenerateClicked() - enabled = true - genConfigProcess = false - } - } - - TextAreaType { - id: tfShareCode - - Layout.topMargin: 20 - Layout.bottomMargin: 20 - Layout.fillWidth: true - Layout.preferredHeight: 200 - - textArea.readOnly: true - textArea.text: ShareConnectionLogic.textEditShareCloakText - - visible: tfShareCode.textArea.length > 0 - } - - ShareConnectionButtonCopyType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - copyText: tfShareCode.textArea.text - } - - ShareConnectionButtonType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file") - enabled: tfShareCode.textArea.length > 0 - visible: tfShareCode.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "amnezia_config_cloak.json", "*.json", tfShareCode.textArea.text) - } - } - - } - } - -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoIkev2.qml b/client/ui/qml/Pages/Share/PageShareProtoIkev2.qml deleted file mode 100644 index 7e41650a7..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoIkev2.qml +++ /dev/null @@ -1,131 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.Ikev2 - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Share IKEv2 Settings") - } - - TextAreaType { - id: tfCert - textArea.readOnly: true - textArea.text: ShareConnectionLogic.textEditShareIkev2CertText - - visible: false - } - - TextAreaType { - id: tfMobileConfig - textArea.readOnly: true - textArea.text: ShareConnectionLogic.textEditShareIkev2MobileConfigText - - visible: false - } - - TextAreaType { - id: tfStrongSwanConfig - textArea.readOnly: true - textArea.text: ShareConnectionLogic.textEditShareIkev2StrongSwanConfigText - - visible: false - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - -// LabelType { -// id: lb_desc -// Layout.fillWidth: true -// Layout.topMargin: 10 - -// horizontalAlignment: Text.AlignHCenter - -// wrapMode: Text.Wrap -// text: qsTr("Note: ShadowSocks protocol using same password for all connections") -// } - - ShareConnectionButtonType { - Layout.topMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: genConfigProcess ? generatingConfigText : generateConfigText - onClicked: { - enabled = false - genConfigProcess = true - ShareConnectionLogic.onPushButtonShareIkev2GenerateClicked() - enabled = true - genConfigProcess = false - } - } - - ShareConnectionButtonType { - Layout.topMargin: 30 - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - width: parent.width - 60 - - text: qsTr("Export p12 certificate") - enabled: tfCert.textArea.length > 0 - visible: tfCert.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Export p12 certificate"), "amnezia_ikev2_cert_for_windows.p12", "*.p12", tfCert.textArea.text) - } - } - - ShareConnectionButtonType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - width: parent.width - 60 - - text: qsTr("Export config for Apple") - enabled: tfMobileConfig.textArea.length > 0 - visible: tfMobileConfig.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Export config for Apple"), "amnezia_for_apple.plist", "*.plist", tfMobileConfig.textArea.text) - } - } - - ShareConnectionButtonType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - width: parent.width - 60 - - text: qsTr("Export config for StrongSwan") - enabled: tfStrongSwanConfig.textArea.length > 0 - visible: tfStrongSwanConfig.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Export config for StrongSwan"), "amnezia_for_StrongSwan.profile", "*.profile", tfStrongSwanConfig.textArea.text) - } - } - } - } -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoOpenVPN.qml b/client/ui/qml/Pages/Share/PageShareProtoOpenVPN.qml deleted file mode 100644 index 4246be216..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoOpenVPN.qml +++ /dev/null @@ -1,96 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.OpenVpn - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Share OpenVPN Settings") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - id: lb_desc - Layout.fillWidth: true - Layout.topMargin: 10 - - horizontalAlignment: Text.AlignHCenter - - wrapMode: Text.Wrap - text: qsTr("New encryption keys pair will be generated.") - } - - ShareConnectionButtonType { - Layout.topMargin: 20 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: genConfigProcess ? generatingConfigText : generateConfigText - onClicked: { - enabled = false - genConfigProcess = true - ShareConnectionLogic.onPushButtonShareOpenVpnGenerateClicked() - genConfigProcess = false - enabled = true - } - } - - TextAreaType { - id: tfShareCode - Layout.topMargin: 20 - Layout.preferredHeight: 200 - Layout.fillWidth: true - - textArea.readOnly: true - - textArea.verticalAlignment: Text.AlignTop - textArea.text: ShareConnectionLogic.textEditShareOpenVpnCodeText - - visible: tfShareCode.textArea.length > 0 - } - - ShareConnectionButtonCopyType { - Layout.preferredHeight: 40 - Layout.fillWidth: true - - copyText: tfShareCode.textArea.text - } - ShareConnectionButtonType { - Layout.bottomMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - width: parent.width - 60 - - text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file") - enabled: tfShareCode.textArea.length > 0 - visible: tfShareCode.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "amnezia_for_openvpn.ovpn", "*.ovpn", tfShareCode.textArea.text) - } - } - } - } -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoSftp.qml b/client/ui/qml/Pages/Share/PageShareProtoSftp.qml deleted file mode 100644 index 8f990ac1d..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoSftp.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick -import QtQuick.Controls -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.Sftp - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Share SFTP settings") - } - - } diff --git a/client/ui/qml/Pages/Share/PageShareProtoShadowSocks.qml b/client/ui/qml/Pages/Share/PageShareProtoShadowSocks.qml deleted file mode 100644 index 91f5e8d29..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoShadowSocks.qml +++ /dev/null @@ -1,115 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.ShadowSocks - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Share ShadowSocks Settings") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - id: lb_desc - Layout.fillWidth: true - Layout.topMargin: 10 - - horizontalAlignment: Text.AlignHCenter - - wrapMode: Text.Wrap - text: qsTr("Note: ShadowSocks protocol using same password for all connections") - } - - ShareConnectionButtonType { - Layout.topMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: genConfigProcess ? generatingConfigText : generateConfigText - onClicked: { - enabled = false - genConfigProcess = true - ShareConnectionLogic.onPushButtonShareShadowSocksGenerateClicked() - enabled = true - genConfigProcess = false - } - } - - TextAreaType { - id: tfShareCode - - Layout.topMargin: 20 - Layout.preferredHeight: 200 - Layout.fillWidth: true - - textArea.readOnly: true - textArea.wrapMode: TextEdit.WrapAnywhere - textArea.verticalAlignment: Text.AlignTop - textArea.text: ShareConnectionLogic.textEditShareShadowSocksText - - visible: tfShareCode.textArea.length > 0 - } - ShareConnectionButtonCopyType { - Layout.preferredHeight: 40 - Layout.fillWidth: true - Layout.bottomMargin: 20 - - start_text: qsTr("Copy config") - copyText: tfShareCode.textArea.text - } - - LabelType { - height: 20 - visible: tfConnString.length > 0 - text: qsTr("Connection string") - } - TextFieldType { - id: tfConnString - height: 100 - horizontalAlignment: Text.AlignHCenter - Layout.fillWidth: true - text: ShareConnectionLogic.lineEditShareShadowSocksStringText - visible: tfConnString.length > 0 - - readOnly: true - } - ShareConnectionButtonCopyType { - Layout.preferredHeight: 40 - Layout.fillWidth: true - start_text: qsTr("Copy string") - copyText: tfConnString.text - } - - Image { - id: label_share_ss_qr_code - Layout.topMargin: 20 - Layout.fillWidth: true - Layout.preferredHeight: width - smooth: false - source: ShareConnectionLogic.shareShadowSocksQrCodeText - } - } - } -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml b/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml deleted file mode 100644 index 1c68f6cb8..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoTorWebSite.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick -import QtQuick.Controls -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.TorWebSite - - BackButton { - id: back - } - - Caption { - id: caption - text: qsTr("Share Tor Web site") - } -} diff --git a/client/ui/qml/Pages/Share/PageShareProtoWireGuard.qml b/client/ui/qml/Pages/Share/PageShareProtoWireGuard.qml deleted file mode 100644 index 7265de81c..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtoWireGuard.qml +++ /dev/null @@ -1,103 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import ProtocolEnum 1.0 -import "../" -import "../../Controls" -import "../../Config" - -PageShareProtocolBase { - id: root - protocol: ProtocolEnum.WireGuard - - BackButton { - id: back - } - Caption { - id: caption - text: qsTr("Share WireGuard Settings") - } - - FlickableType { - id: fl - anchors.top: caption.bottom - contentHeight: content.height - - ColumnLayout { - id: content - enabled: logic.pageEnabled - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: 15 - - LabelType { - id: lb_desc - Layout.fillWidth: true - Layout.topMargin: 10 - - horizontalAlignment: Text.AlignHCenter - - wrapMode: Text.Wrap - text: qsTr("New encryption keys pair will be generated.") - } - - ShareConnectionButtonType { - Layout.topMargin: 10 - Layout.fillWidth: true - Layout.preferredHeight: 40 - - text: genConfigProcess ? generatingConfigText : generateConfigText - onClicked: { - enabled = false - genConfigProcess = true - ShareConnectionLogic.onPushButtonShareWireGuardGenerateClicked() - enabled = true - genConfigProcess = false - } - } - - TextAreaType { - id: tfShareCode - - Layout.topMargin: 20 - Layout.preferredHeight: 200 - Layout.fillWidth: true - - textArea.readOnly: true - textArea.wrapMode: TextEdit.WrapAnywhere - textArea.verticalAlignment: Text.AlignTop - textArea.text: ShareConnectionLogic.textEditShareWireGuardCodeText - - visible: tfShareCode.textArea.length > 0 - } - ShareConnectionButtonCopyType { - Layout.preferredHeight: 40 - Layout.fillWidth: true - - copyText: tfShareCode.textArea.text - } - - ShareConnectionButtonType { - Layout.preferredHeight: 40 - Layout.fillWidth: true - - text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file") - enabled: tfShareCode.textArea.length > 0 - visible: tfShareCode.textArea.length > 0 - - onClicked: { - UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "amnezia_for_wireguard.conf", "*.conf", tfShareCode.textArea.text) - } - } - - Image { - Layout.topMargin: 20 - Layout.fillWidth: true - Layout.preferredHeight: width - smooth: false - source: ShareConnectionLogic.shareWireGuardQrCodeText - } - } - } -} diff --git a/client/ui/qml/Pages/Share/PageShareProtocolBase.qml b/client/ui/qml/Pages/Share/PageShareProtocolBase.qml deleted file mode 100644 index 603abdfad..000000000 --- a/client/ui/qml/Pages/Share/PageShareProtocolBase.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick -import QtQuick.Controls -import PageEnum 1.0 -import ProtocolEnum 1.0 -import "./.." -import "../../Controls" -import "../../Config" - -PageBase { - id: root - property var protocol: ProtocolEnum.Any - page: PageEnum.ProtocolShare - logic: ShareConnectionLogic - - readonly property string generateConfigText: qsTr("Generate config") - readonly property string generatingConfigText: qsTr("Generating config...") - readonly property string showConfigText: qsTr("Show config") - property bool genConfigProcess: false -} diff --git a/client/ui/qml/main.qml b/client/ui/qml/main.qml deleted file mode 100644 index 615197f01..000000000 --- a/client/ui/qml/main.qml +++ /dev/null @@ -1,387 +0,0 @@ -import QtCore -import QtQuick -import QtQuick.Controls -import QtQuick.Controls.Basic -import QtQuick.Dialogs -import QtQuick.Layouts -import QtQuick.Window - -import Qt.labs.platform as LabsPlatform -import Qt.labs.folderlistmodel as LabsFolderlistmodel - -import PageEnum 1.0 -import PageType 1.0 - -import "Controls" -import "Pages" -import "Pages/Protocols" -import "Pages/Share" -import "Pages/ClientInfo" -import "Config" - -Window { - property var pages: ({}) - property var protocolPages: ({}) - property var sharePages: ({}) - property var clientInfoPages: ({}) - - id: root - visible: true - width: GC.screenWidth - height: GC.screenHeight - minimumWidth: GC.isDesktop() ? 360 : 0 - minimumHeight: GC.isDesktop() ? 640 : 0 - onClosing: function() { - console.debug("QML onClosing signal") - UiLogic.onCloseWindow() - } - - title: "AmneziaVPN" - - function gotoPage(type, page, reset, slide) { - - let p_obj; - if (type === PageType.Basic) p_obj = pages[page] - else if (type === PageType.Proto) p_obj = protocolPages[page] - else if (type === PageType.ShareProto) p_obj = sharePages[page] - else if (type === PageType.ClientInfo) p_obj = clientInfoPages[page] - else return - - //console.debug("QML gotoPage " + type + " " + page + " " + p_obj) - - if (pageLoader.depth > 0) { - pageLoader.currentItem.deactivated() - } - - if (slide) { - pageLoader.push(p_obj, {}, StackView.PushTransition) - } else { - pageLoader.push(p_obj, {}, StackView.Immediate) - } - - if (reset) { - p_obj.logic.onUpdatePage(); - } - - p_obj.activated(reset) - } - - function close_page() { - if (pageLoader.depth <= 1) { - if (GC.isMobile()) { - root.close() - } - return - } - - pageLoader.currentItem.deactivated() - pageLoader.pop() - } - - function set_start_page(page, slide) { - if (pageLoader.depth > 0) { - pageLoader.currentItem.deactivated() - } - - pageLoader.clear() - if (slide) { - pageLoader.push(pages[page], {}, StackView.PushTransition) - } else { - pageLoader.push(pages[page], {}, StackView.Immediate) - } - if (page === PageEnum.Start) { - UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty - UiLogic.onUpdatePage(); - } - } - - Rectangle { - anchors.fill: parent - color: "white" - } - - StackView { - id: pageLoader - y: 0 - anchors.fill: parent - focus: true - - onCurrentItemChanged: function() { - UiLogic.currentPageValue = currentItem.page - } - - onDepthChanged: function() { - UiLogic.pagesStackDepth = depth - } - - Keys.onPressed: function(event) { - UiLogic.keyPressEvent(event.key) - event.accepted = true - } - } - - LabsFolderlistmodel.FolderListModel { - id: folderModelPages - folder: "qrc:/ui/qml/Pages/" - nameFilters: ["*.qml"] - showDirs: false - - onStatusChanged: if (status == LabsFolderlistmodel.FolderListModel.Ready) { - for (var i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "amnezia_application.h" - -#include "configurators/cloak_configurator.h" -#include "configurators/openvpn_configurator.h" -#include "configurators/shadowsocks_configurator.h" -#include "configurators/ssh_configurator.h" -#include "configurators/vpn_configurator.h" - -#include "core/errorstrings.h" -#include "core/server_defs.h" -#include "core/servercontroller.h" - -#include "containers/containers_defs.h" - -#include "ui/qautostart.h" - -#include "logger.h" -#include "uilogic.h" -#include "utilities.h" -#include "version.h" -#include "vpnconnection.h" -#include - -#if defined Q_OS_MAC || defined Q_OS_LINUX - #include "ui/macos_util.h" -#endif - -#ifdef Q_OS_ANDROID - #include "platforms/android/android_controller.h" -#endif - -#include "platforms/ios/MobileUtils.h" - -#include "pages_logic/AdvancedServerSettingsLogic.h" -#include "pages_logic/AppSettingsLogic.h" -#include "pages_logic/ClientInfoLogic.h" -#include "pages_logic/ClientManagementLogic.h" -#include "pages_logic/GeneralSettingsLogic.h" -#include "pages_logic/NetworkSettingsLogic.h" -#include "pages_logic/NewServerProtocolsLogic.h" -#include "pages_logic/QrDecoderLogic.h" -#include "pages_logic/ServerConfiguringProgressLogic.h" -#include "pages_logic/ServerContainersLogic.h" -#include "pages_logic/ServerListLogic.h" -#include "pages_logic/ServerSettingsLogic.h" -#include "pages_logic/ShareConnectionLogic.h" -#include "pages_logic/SitesLogic.h" -#include "pages_logic/StartPageLogic.h" -#include "pages_logic/ViewConfigLogic.h" -#include "pages_logic/VpnLogic.h" -#include "pages_logic/WizardLogic.h" - -#include "pages_logic/protocols/CloakLogic.h" -#include "pages_logic/protocols/OpenVpnLogic.h" -#include "pages_logic/protocols/OtherProtocolsLogic.h" -#include "pages_logic/protocols/ShadowSocksLogic.h" -#include "pages_logic/protocols/WireGuardLogic.h" - -using namespace amnezia; -using namespace PageEnumNS; - -UiLogic::UiLogic(std::shared_ptr settings, std::shared_ptr configurator, QObject *parent) - : QObject(parent), m_settings(settings), m_configurator(configurator) -{ - m_protocolsModel = new ProtocolsModel(settings, this); - m_clientManagementModel = new ClientManagementModel(this); - m_vpnConnection = new VpnConnection(settings, configurator); - m_vpnConnection->moveToThread(&m_vpnConnectionThread); - m_vpnConnectionThread.start(); - - m_protocolLogicMap.insert(Proto::OpenVpn, new OpenVpnLogic(this)); - m_protocolLogicMap.insert(Proto::ShadowSocks, new ShadowSocksLogic(this)); - m_protocolLogicMap.insert(Proto::Cloak, new CloakLogic(this)); - m_protocolLogicMap.insert(Proto::WireGuard, new WireGuardLogic(this)); - - m_protocolLogicMap.insert(Proto::Dns, new OtherProtocolsLogic(this)); - m_protocolLogicMap.insert(Proto::Sftp, new OtherProtocolsLogic(this)); - m_protocolLogicMap.insert(Proto::TorWebSite, new OtherProtocolsLogic(this)); -} - -UiLogic::~UiLogic() -{ - emit hide(); - -#ifdef AMNEZIA_DESKTOP - if (m_vpnConnection->connectionState() != Vpn::ConnectionState::Disconnected) { - m_vpnConnection->disconnectFromVpn(); - for (int i = 0; i < 50; i++) { - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - QThread::msleep(100); - if (m_vpnConnection->isDisconnected()) { - break; - } - } - } -#endif - - m_vpnConnection->deleteLater(); - m_vpnConnectionThread.quit(); - m_vpnConnectionThread.wait(3000); - - qDebug() << "Application closed"; -} - -void UiLogic::initializeUiLogic() -{ -#ifdef Q_OS_ANDROID - connect(AndroidController::instance(), &AndroidController::initialized, - [this](bool status, bool connected, const QDateTime &connectionDate) { - if (connected) { - pageLogic()->onConnectionStateChanged(Vpn::ConnectionState::Connected); - if (m_vpnConnection) - m_vpnConnection->restoreConnection(); - } - }); -// if (!AndroidController::instance()->initialize(pageLogic())) { -// qCritical() << QString("Init failed"); -// if (m_vpnConnection) m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Error); -// return; -// } -#endif - - m_notificationHandler = NotificationHandler::create(qmlRoot()); - - connect(m_vpnConnection, &VpnConnection::connectionStateChanged, m_notificationHandler, - &NotificationHandler::setConnectionState); - connect(m_notificationHandler, &NotificationHandler::raiseRequested, this, &UiLogic::raise); - connect(m_notificationHandler, &NotificationHandler::connectRequested, pageLogic(), &VpnLogic::onConnect); - connect(m_notificationHandler, &NotificationHandler::disconnectRequested, pageLogic(), - &VpnLogic::onDisconnect); - - // if (m_settings->serversCount() > 0) { - // if (m_settings->defaultServerIndex() < 0) m_settings->setDefaultServer(0); - // emit goToPage(Page::PageStart, true, false); - // } - // else { - // emit goToPage(Page::PageSetupWizardStart, true, false); - // } - - m_selectedServerIndex = m_settings->defaultServerIndex(); -} - -void UiLogic::showOnStartup() -{ - if (!m_settings->isStartMinimized()) { - emit show(); - } else { -#ifdef Q_OS_WIN - emit hide(); -#elif defined Q_OS_MACX - // TODO: fix: setDockIconVisible(false); -#endif - } -} - -void UiLogic::onUpdateAllPages() -{ - for (auto logic : m_logicMap) { - if (dynamic_cast(logic) || dynamic_cast(logic) - || dynamic_cast(logic)) { - continue; - } - logic->onUpdatePage(); - } -} - -void UiLogic::keyPressEvent(Qt::Key key) -{ - switch (key) { - case Qt::Key_AsciiTilde: - case Qt::Key_QuoteLeft: emit toggleLogPanel(); break; - case Qt::Key_L: Logger::openLogsFolder(); break; - case Qt::Key_K: Logger::openServiceLogsFolder(); break; -#ifdef QT_DEBUG - case Qt::Key_Q: qApp->quit(); break; - case Qt::Key_H: - m_selectedServerIndex = m_settings->defaultServerIndex(); - m_selectedDockerContainer = m_settings->defaultContainer(m_selectedServerIndex); - - // 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->defaultServer()).toJson(); - break; - case Qt::Key_A: emit goToPage(Page::Start); break; - case Qt::Key_S: - m_selectedServerIndex = m_settings->defaultServerIndex(); - emit goToPage(Page::ServerSettings); - break; - case Qt::Key_P: onGotoCurrentProtocolsPage(); break; - case Qt::Key_T: - m_configurator->sshConfigurator->openSshTerminal(m_settings->serverCredentials(m_settings->defaultServerIndex())); - break; - case Qt::Key_Escape: - if (currentPage() == Page::Vpn) - break; - if (currentPage() == Page::ServerConfiguringProgress) - break; - case Qt::Key_Back: - - // if (currentPage() == Page::Start && pagesStack.size() < 2) break; - // if (currentPage() == Page::Sites && - // ui->tableView_sites->selectionModel()->selection().indexes().size() > 0) { - // ui->tableView_sites->clearSelection(); - // break; - // } - - emit closePage(); - //} - default:; - } -} - -void UiLogic::onCloseWindow() -{ -#ifdef Q_OS_ANDROID - qApp->quit(); -#else - if (m_settings->serversCount() == 0) { - qApp->quit(); - } else { - emit hide(); - } -#endif -} - -QString UiLogic::containerName(int container) -{ - return ContainerProps::containerHumanNames().value(static_cast(container)); -} - -QString UiLogic::containerDesc(int container) -{ - return ContainerProps::containerDescriptions().value(static_cast(container)); -} - -void UiLogic::onGotoCurrentProtocolsPage() -{ - m_selectedServerIndex = m_settings->defaultServerIndex(); - m_selectedDockerContainer = m_settings->defaultContainer(m_selectedServerIndex); - emit goToPage(Page::ServerContainers); -} - -void UiLogic::installServer(QPair &container) -{ - emit goToPage(Page::ServerConfiguringProgress); - QEventLoop loop; - QTimer::singleShot(500, &loop, SLOT(quit())); - loop.exec(); - qApp->processEvents(); - - ServerConfiguringProgressLogic::PageFunc pageFunc; - pageFunc.setEnabledFunc = [this](bool enabled) -> void { - pageLogic()->set_pageEnabled(enabled); - }; - - ServerConfiguringProgressLogic::ButtonFunc noButton; - - ServerConfiguringProgressLogic::LabelFunc waitInfoFunc; - waitInfoFunc.setTextFunc = [this](const QString &text) -> void { - pageLogic()->set_labelWaitInfoText(text); - }; - waitInfoFunc.setVisibleFunc = [this](bool visible) -> void { - pageLogic()->set_labelWaitInfoVisible(visible); - }; - - ServerConfiguringProgressLogic::ProgressFunc progressBarFunc; - progressBarFunc.setVisibleFunc = [this](bool visible) -> void { - pageLogic()->set_progressBarVisible(visible); - }; - progressBarFunc.setValueFunc = [this](int value) -> void { - pageLogic()->set_progressBarValue(value); - }; - progressBarFunc.getValueFunc = [this](void) -> int { - return pageLogic()->progressBarValue(); - }; - progressBarFunc.getMaximumFunc = [this](void) -> int { - return pageLogic()->progressBarMaximum(); - }; - progressBarFunc.setTextVisibleFunc = [this](bool visible) -> void { - pageLogic()->set_progressBarTextVisible(visible); - }; - progressBarFunc.setTextFunc = [this](const QString &text) -> void { - pageLogic()->set_progressBarText(text); - }; - - ServerConfiguringProgressLogic::LabelFunc busyInfoFunc; - busyInfoFunc.setTextFunc = [this](const QString &text) -> void { - pageLogic()->set_labelServerBusyText(text); - }; - busyInfoFunc.setVisibleFunc = [this](bool visible) -> void { - pageLogic()->set_labelServerBusyVisible(visible); - }; - - ServerConfiguringProgressLogic::ButtonFunc cancelButtonFunc; - cancelButtonFunc.setVisibleFunc = [this](bool visible) -> void { - pageLogic()->set_pushButtonCancelVisible(visible); - }; - - bool isServerCreated = false; - ErrorCode errorCode = addAlreadyInstalledContainersGui(isServerCreated); - if (errorCode == ErrorCode::NoError) { - if (!isContainerAlreadyAddedToGui(container.first)) { - progressBarFunc.setTextFunc(QString("Installing %1").arg(ContainerProps::containerToString(container.first))); - auto installAction = [&]() { - ServerController serverController(m_settings); - return serverController.setupContainer(m_installCredentials, container.first, container.second); - }; - errorCode = pageLogic()->doInstallAction( - installAction, pageFunc, progressBarFunc, noButton, waitInfoFunc, busyInfoFunc, cancelButtonFunc); - if (errorCode == ErrorCode::NoError) { - if (!isServerCreated) { - QJsonObject server; - server.insert(config_key::hostName, m_installCredentials.hostName); - server.insert(config_key::userName, m_installCredentials.userName); - server.insert(config_key::password, m_installCredentials.secretData); - server.insert(config_key::port, m_installCredentials.port); - server.insert(config_key::description, m_settings->nextAvailableServerName()); - - server.insert(config_key::containers, QJsonArray { container.second }); - server.insert(config_key::defaultContainer, ContainerProps::containerToString(container.first)); - - m_settings->addServer(server); - m_settings->setDefaultServer(m_settings->serversCount() - 1); - } else { - m_settings->setContainerConfig(m_settings->serversCount() - 1, container.first, container.second); - m_settings->setDefaultContainer(m_settings->serversCount() - 1, container.first); - } - onUpdateAllPages(); - - emit setStartPage(Page::Vpn); - qApp->processEvents(); - return; - } - } else { - onUpdateAllPages(); - emit showWarningMessage( - "Attention! The container you are trying to install is already installed on the server. " - "All installed containers have been added to the application "); - emit setStartPage(Page::Vpn); - return; - } - } - emit showWarningMessage(tr("Error occurred while configuring server.") + "\n" + tr("Error message: ") - + errorString(errorCode) + "\n" + tr("See logs for details.")); - emit closePage(); -} - -PageProtocolLogicBase *UiLogic::protocolLogic(Proto p) -{ - PageProtocolLogicBase *logic = m_protocolLogicMap.value(p); - if (logic) - return logic; - else { - qCritical() << "UiLogic::protocolLogic Warning: logic missing for" << p; - return new PageProtocolLogicBase(this); - } -} - -QObject *UiLogic::qmlRoot() const -{ - return m_qmlRoot; -} - -void UiLogic::setQmlRoot(QObject *newQmlRoot) -{ - m_qmlRoot = newQmlRoot; -} - -NotificationHandler *UiLogic::notificationHandler() const -{ - return m_notificationHandler; -} - -void UiLogic::setQmlContextProperty(PageLogicBase *logic) -{ - amnApp->qmlEngine()->rootContext()->setContextProperty(logic->metaObject()->className(), logic); -} - -PageEnumNS::Page UiLogic::currentPage() -{ - return static_cast(currentPageValue()); -} - -void UiLogic::saveTextFile(const QString &desc, const QString &suggestedName, QString ext, const QString &data) -{ -#ifdef Q_OS_IOS - shareTempFile(suggestedName, ext, data); - return; -#endif - - ext.replace("*", ""); - QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QUrl fileName; -#ifdef AMNEZIA_DESKTOP - fileName = QFileDialog::getSaveFileUrl(nullptr, desc, QUrl::fromLocalFile(docDir + "/" + suggestedName), "*" + ext); - if (fileName.isEmpty()) - return; - if (!fileName.toString().endsWith(ext)) - fileName = QUrl(fileName.toString() + ext); -#elif defined Q_OS_ANDROID - qDebug() << "UiLogic::shareConfig" << data; - AndroidController::instance()->shareConfig(data, suggestedName); - return; -#endif - - if (fileName.isEmpty()) - return; - -#ifdef AMNEZIA_DESKTOP - QFile save(fileName.toLocalFile()); -#else - QFile save(QQmlFile::urlToLocalFileOrQrc(fileName)); -#endif - - save.open(QIODevice::WriteOnly); - save.write(data.toUtf8()); - save.close(); - - QFileInfo fi(fileName.toLocalFile()); - QDesktopServices::openUrl(fi.absoluteDir().absolutePath()); -} - -void UiLogic::saveBinaryFile(const QString &desc, QString ext, const QString &data) -{ - ext.replace("*", ""); - QString fileName = QFileDialog::getSaveFileName( - nullptr, desc, QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext); - - if (fileName.isEmpty()) - return; - if (!fileName.endsWith(ext)) - fileName.append(ext); - - QFile save(fileName); - save.open(QIODevice::WriteOnly); - save.write(QByteArray::fromBase64(data.toUtf8())); - save.close(); - - QFileInfo fi(fileName); - QDesktopServices::openUrl(fi.absoluteDir().absolutePath()); -} - -void UiLogic::copyToClipboard(const QString &text) -{ - qApp->clipboard()->setText(text); -} - -void UiLogic::shareTempFile(const QString &suggestedName, QString ext, const QString &data) -{ - ext.replace("*", ""); - QString fileName = QDir::tempPath() + "/" + suggestedName; - - if (fileName.isEmpty()) - return; - if (!fileName.endsWith(ext)) - fileName.append(ext); - - QFile::remove(fileName); - - QFile save(fileName); - save.open(QIODevice::WriteOnly); - save.write(data.toUtf8()); - save.close(); - - QStringList filesToSend; - filesToSend.append(fileName); - MobileUtils::shareText(filesToSend); -} - -QString UiLogic::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, - QString *selectedFilter, QFileDialog::Options options) -{ - QString fileName = QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options); - -#ifdef Q_OS_ANDROID - // patch for files containing spaces etc - const QString sep { "raw%3A%2F" }; - if (fileName.startsWith("content://") && fileName.contains(sep)) { - QString contentUrl = fileName.split(sep).at(0); - QString rawUrl = fileName.split(sep).at(1); - rawUrl.replace(" ", "%20"); - fileName = contentUrl + sep + rawUrl; - } -#endif - return fileName; -} - -void UiLogic::registerPagesLogic() -{ - amnApp->qmlEngine()->rootContext()->setContextProperty("UiLogic", this); - - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); - registerPageLogic(); -} - -ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool &isServerCreated) -{ - isServerCreated = false; - ServerCredentials installCredentials = m_installCredentials; - bool createNewServer = true; - int serverIndex; - - for (int i = 0; i < m_settings->serversCount(); i++) { - const ServerCredentials credentials = m_settings->serverCredentials(i); - if (m_installCredentials.hostName == credentials.hostName && m_installCredentials.port == credentials.port) { - createNewServer = false; - isServerCreated = true; - installCredentials = credentials; - serverIndex = i; - break; - } - } - - QMap installedContainers; - ServerController serverController(m_settings); - ErrorCode errorCode = serverController.getAlreadyInstalledContainers(installCredentials, installedContainers); - if (errorCode != ErrorCode::NoError) { - return errorCode; - } - - if (!installedContainers.empty()) { - QJsonObject server; - QJsonArray containerConfigs; - if (createNewServer) { - server.insert(config_key::hostName, installCredentials.hostName); - server.insert(config_key::userName, installCredentials.userName); - server.insert(config_key::password, installCredentials.secretData); - server.insert(config_key::port, installCredentials.port); - server.insert(config_key::description, m_settings->nextAvailableServerName()); - } - - for (auto container = installedContainers.begin(); container != installedContainers.end(); container++) { - if (isContainerAlreadyAddedToGui(container.key())) { - continue; - } - - if (createNewServer) { - containerConfigs.append(container.value()); - server.insert(config_key::containers, containerConfigs); - } else { - m_settings->setContainerConfig(serverIndex, container.key(), container.value()); - m_settings->setDefaultContainer(serverIndex, installedContainers.firstKey()); - } - } - - if (createNewServer) { - server.insert(config_key::defaultContainer, - ContainerProps::containerToString(installedContainers.firstKey())); - m_settings->addServer(server); - m_settings->setDefaultServer(m_settings->serversCount() - 1); - isServerCreated = true; - } - } - - return ErrorCode::NoError; -} - -bool UiLogic::isContainerAlreadyAddedToGui(DockerContainer container) -{ - for (int i = 0; i < m_settings->serversCount(); i++) { - const ServerCredentials credentials = m_settings->serverCredentials(i); - if (m_installCredentials.hostName == credentials.hostName && m_installCredentials.port == credentials.port) { - const QJsonObject containerConfig = m_settings->containerConfig(i, container); - if (!containerConfig.isEmpty()) { - return true; - } - } - } - return false; -} diff --git a/client/ui/uilogic.h b/client/ui/uilogic.h deleted file mode 100644 index 081b8e5a6..000000000 --- a/client/ui/uilogic.h +++ /dev/null @@ -1,201 +0,0 @@ -#ifndef UILOGIC_H -#define UILOGIC_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "property_helper.h" -#include "pages.h" -#include "protocols/vpnprotocol.h" -#include "containers/containers_defs.h" - -#include "models/containers_model.h" -#include "models/protocols_model.h" -#include "models/clientManagementModel.h" - -#include "notificationhandler.h" - -class Settings; -class VpnConfigurator; -class ServerController; - -class PageLogicBase; - -class AppSettingsLogic; -class GeneralSettingsLogic; -class NetworkSettingsLogic; -class NewServerProtocolsLogic; -class QrDecoderLogic; -class ServerConfiguringProgressLogic; -class ServerListLogic; -class ServerSettingsLogic; -class ServerContainersLogic; -class ShareConnectionLogic; -class SitesLogic; -class StartPageLogic; -class ViewConfigLogic; -class VpnLogic; -class WizardLogic; -class ClientManagementLogic; -class ClientInfoLogic; -class AdvancedServerSettingsLogic; - -class PageProtocolLogicBase; -class OpenVpnLogic; -class ShadowSocksLogic; -class CloakLogic; - -class OtherProtocolsLogic; - -class VpnConnection; - -class CreateServerTest; - -class UiLogic : public QObject -{ - Q_OBJECT - - AUTO_PROPERTY(bool, pageEnabled) - AUTO_PROPERTY(int, pagesStackDepth) - AUTO_PROPERTY(int, currentPageValue) - - READONLY_PROPERTY(QObject *, protocolsModel) - READONLY_PROPERTY(QObject *, clientManagementModel) - -public: - explicit UiLogic(std::shared_ptr settings, std::shared_ptr configurator, QObject *parent = nullptr); - ~UiLogic(); - void showOnStartup(); - - friend class PageLogicBase; - - friend class AppSettingsLogic; - friend class GeneralSettingsLogic; - friend class NetworkSettingsLogic; - friend class ServerConfiguringProgressLogic; - friend class NewServerProtocolsLogic; - friend class ServerListLogic; - friend class ServerSettingsLogic; - friend class ServerContainersLogic; - friend class ShareConnectionLogic; - friend class SitesLogic; - friend class StartPageLogic; - friend class ViewConfigLogic; - friend class VpnLogic; - friend class WizardLogic; - friend class ClientManagementLogic; - friend class ClientInfoLogic; - friend class AdvancedServerSettingsLogic; - - friend class PageProtocolLogicBase; - friend class OpenVpnLogic; - friend class ShadowSocksLogic; - friend class CloakLogic; - - friend class OtherProtocolsLogic; - - friend class CreateServerTest; - - Q_INVOKABLE virtual void onUpdatePage() {} // UiLogic is set as logic class for some qml pages - Q_INVOKABLE void onUpdateAllPages(); - - Q_INVOKABLE void initializeUiLogic(); - Q_INVOKABLE void onCloseWindow(); - - Q_INVOKABLE QString containerName(int container); - Q_INVOKABLE QString containerDesc(int container); - - Q_INVOKABLE void onGotoCurrentProtocolsPage(); - - Q_INVOKABLE void keyPressEvent(Qt::Key key); - - Q_INVOKABLE void saveTextFile(const QString& desc, const QString &suggestedName, QString ext, const QString& data); - Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data); - Q_INVOKABLE void copyToClipboard(const QString& text); - - Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated); - - void shareTempFile(const QString &suggestedName, QString ext, const QString& data); - static QString getOpenFileName(QWidget *parent = nullptr, - const QString &caption = QString(), - const QString &dir = QString(), - const QString &filter = QString(), - QString *selectedFilter = nullptr, - QFileDialog::Options options = QFileDialog::Options()); -signals: - void goToPage(PageEnumNS::Page page, bool reset = true, bool slide = true); - void goToProtocolPage(Proto protocol, bool reset = true, bool slide = true); - void goToShareProtocolPage(Proto protocol, bool reset = true, bool slide = true); - void goToClientInfoPage(Proto protocol, bool reset = true, bool slide = true); - - void closePage(); - void setStartPage(PageEnumNS::Page page, bool slide = true); - void showPublicKeyWarning(); - void showConnectErrorDialog(); - void show(); - void hide(); - void raise(); - void toggleLogPanel(); - void showWarningMessage(QString message); - -private slots: - // containers - INOUT arg - void installServer(QPair &container); - -private: - PageEnumNS::Page currentPage(); - bool isContainerAlreadyAddedToGui(DockerContainer container); - -public: - Q_INVOKABLE PageProtocolLogicBase *protocolLogic(Proto p); - - QObject *qmlRoot() const; - void setQmlRoot(QObject *newQmlRoot); - - NotificationHandler *notificationHandler() const; - - void setQmlContextProperty(PageLogicBase *logic); - void registerPagesLogic(); - - template - void registerPageLogic() - { - T* logic = new T(this); - m_logicMap[std::type_index(typeid(T))] = logic; - setQmlContextProperty(logic); - } - - template - T* pageLogic() - { - return static_cast(m_logicMap.value(std::type_index(typeid(T)))); - } - -private: - QObject *m_qmlRoot{nullptr}; - - QMap m_logicMap; - - QMap m_protocolLogicMap; - - VpnConnection* m_vpnConnection; - QThread m_vpnConnectionThread; - - std::shared_ptr m_settings; - std::shared_ptr m_configurator; - - NotificationHandler* m_notificationHandler; - - int m_selectedServerIndex = -1; // server index to use when proto settings page opened - DockerContainer m_selectedDockerContainer; // same - ServerCredentials m_installCredentials; // used to save cred between pages new_server and new_server_protocols and wizard -}; -#endif // UILOGIC_H