VpnLogic
This commit is contained in:
parent
deaeda59d0
commit
539bf2ee24
42 changed files with 678 additions and 940 deletions
|
@ -7,9 +7,8 @@
|
|||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
AppSettingsLogic::AppSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
AppSettingsLogic::AppSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_checkBoxAppSettingsAutostartChecked{false},
|
||||
m_checkBoxAppSettingsAutoconnectChecked{false},
|
||||
m_checkBoxAppSettingsStartMinimizedChecked{false}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef APP_SETTINGS_LOGIC_H
|
||||
#define APP_SETTINGS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class AppSettingsLogic : public QObject
|
||||
class AppSettingsLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -55,9 +54,6 @@ private slots:
|
|||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
bool m_checkBoxAppSettingsAutostartChecked;
|
||||
bool m_checkBoxAppSettingsAutoconnectChecked;
|
||||
bool m_checkBoxAppSettingsStartMinimizedChecked;
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic)
|
||||
GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -33,15 +29,15 @@ void GeneralSettingsLogic::setPushButtonGeneralSettingsShareConnectionEnable(boo
|
|||
|
||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
||||
{
|
||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
m_uiLogic->goToPage(Page::ServerSettings);
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->goToPage(Page::ServerSettings);
|
||||
}
|
||||
|
||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
||||
{
|
||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
m_uiLogic->selectedDockerContainer = m_settings.defaultContainer(m_uiLogic->selectedServerIndex);
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
|
||||
m_uiLogic->shareConnectionLogic()->updateSharingPage(m_uiLogic->selectedServerIndex, m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer);
|
||||
m_uiLogic->goToPage(Page::ShareConnection);
|
||||
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer);
|
||||
uiLogic()->goToPage(Page::ShareConnection);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef GENERAL_SETTINGS_LOGIC_H
|
||||
#define GENERAL_SETTINGS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class GeneralSettingsLogic : public QObject
|
||||
class GeneralSettingsLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -37,12 +36,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
bool m_pushButtonGeneralSettingsShareConnectionEnable;
|
||||
|
||||
};
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
#include "defines.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_ipAddressValidatorRegex{Utils::ipAddressRegExp().pattern()}
|
||||
{
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef NETWORK_SETTINGS_LOGIC_H
|
||||
#define NETWORK_SETTINGS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class NetworkSettingsLogic : public QObject
|
||||
class NetworkSettingsLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -48,12 +47,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
QString m_lineEditNetworkSettingsDns1Text;
|
||||
QString m_lineEditNetworkSettingsDns2Text;
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
#include "NewServerConfiguringLogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
NewServerConfiguringLogic::NewServerConfiguringLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
NewServerConfiguringLogic::NewServerConfiguringLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_progressBarNewServerConfiguringValue{0},
|
||||
m_pageNewServerConfiguringEnabled{true},
|
||||
m_labelNewServerConfiguringWaitInfoVisible{true},
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef NEW_SERVER_CONFIGURING_LOGIC_H
|
||||
#define NEW_SERVER_CONFIGURING_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class NewServerConfiguringLogic : public QObject
|
||||
class NewServerConfiguringLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -58,12 +57,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
double m_progressBarNewServerConfiguringValue;
|
||||
bool m_pageNewServerConfiguringEnabled;
|
||||
bool m_labelNewServerConfiguringWaitInfoVisible;
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
#include "NewServerProtocolsLogic.h"
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pushButtonNewServerSettingsCloakChecked{false},
|
||||
m_pushButtonNewServerSettingsSsChecked{false},
|
||||
m_pushButtonNewServerSettingsOpenvpnChecked{false},
|
||||
|
@ -26,7 +22,7 @@ NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *uiLogic, QObject *pare
|
|||
setFrameNewServerSettingsParentWireguardVisible(false);
|
||||
|
||||
connect(this, &NewServerProtocolsLogic::pushButtonNewServerConnectConfigureClicked, this, [this](){
|
||||
m_uiLogic->installServer(getInstallConfigsFromProtocolsPage());
|
||||
uiLogic()->installServer(getInstallConfigsFromProtocolsPage());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef NEW_SERVER_PROTOCOLS_LOGIC_H
|
||||
#define NEW_SERVER_PROTOCOLS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class NewServerProtocolsLogic : public QObject
|
||||
class NewServerProtocolsLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -96,12 +95,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
bool m_frameNewServerSettingsParentWireguardVisible;
|
||||
|
||||
bool m_pushButtonNewServerSettingsCloakChecked;
|
||||
|
|
9
client/ui/pages_logic/PageLogicBase.cpp
Normal file
9
client/ui/pages_logic/PageLogicBase.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "PageLogicBase.h"
|
||||
|
||||
|
||||
PageLogicBase::PageLogicBase(UiLogic *logic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(logic)
|
||||
{
|
||||
|
||||
}
|
37
client/ui/pages_logic/PageLogicBase.h
Normal file
37
client/ui/pages_logic/PageLogicBase.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#ifndef PAGE_LOGIC_BASE_H
|
||||
#define PAGE_LOGIC_BASE_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class PageLogicBase : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PageLogicBase(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~PageLogicBase() = default;
|
||||
|
||||
Q_INVOKABLE void updatePage() {}
|
||||
|
||||
protected:
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
#endif // PAGE_LOGIC_BASE_H
|
|
@ -1,54 +0,0 @@
|
|||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHostInfo>
|
||||
#include <QItemSelectionModel>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
#include <QSysInfo>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QRegularExpression>
|
||||
#include <QSaveFile>
|
||||
|
||||
//#include "configurators/cloak_configurator.h"
|
||||
//#include "configurators/vpn_configurator.h"
|
||||
//#include "configurators/openvpn_configurator.h"
|
||||
//#include "configurators/shadowsocks_configurator.h"
|
||||
//#include "configurators/ssh_configurator.h"
|
||||
|
||||
//#include "core/servercontroller.h"
|
||||
//#include "core/server_defs.h"
|
||||
//#include "core/errorstrings.h"
|
||||
|
||||
//#include "protocols/protocols_defs.h"
|
||||
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
#include "ProtocolSettingsLogic.h"
|
||||
#include "utils.h"
|
||||
#include "vpnconnection.h"
|
||||
#include <functional>
|
||||
|
||||
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||
#include "ui/macos_util.h"
|
||||
#endif
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
|
||||
ProtocolSettingsLogic::ProtocolSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic)
|
||||
{
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef PROTOCOL_SETTINGS_LOGIC_H
|
||||
#define PROTOCOL_SETTINGS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ProtocolSettingsLogic : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProtocolSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~ProtocolSettingsLogic() = default;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif // PROTOCOL_SETTINGS_LOGIC_H
|
|
@ -9,12 +9,8 @@
|
|||
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
ServerContainersLogic::ServerContainersLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
ServerContainersLogic::ServerContainersLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pageServerContainersEnabled{true},
|
||||
m_progressBarProtocolsContainerReinstallValue{0},
|
||||
m_progressBarProtocolsContainerReinstallMaximium{100},
|
||||
|
@ -647,3 +643,27 @@ void ServerContainersLogic::onPushButtonProtoCloakOpenvpnContCloakConfigClicked(
|
|||
uiLogic()->selectedDockerContainer, m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
uiLogic()->goToPage(Page::CloakSettings);
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonProtoOpenvpnContOpenvpnConfigClicked()
|
||||
{
|
||||
uiLogic()->selectedDockerContainer = DockerContainer::OpenVpn;
|
||||
uiLogic()->openVpnLogic()->updateOpenVpnPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Protocol::OpenVpn),
|
||||
uiLogic()->selectedDockerContainer, m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
uiLogic()->goToPage(Page::OpenVpnSettings);
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked()
|
||||
{
|
||||
uiLogic()->selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks;
|
||||
uiLogic()->openVpnLogic()->updateOpenVpnPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Protocol::OpenVpn),
|
||||
uiLogic()->selectedDockerContainer, m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
uiLogic()->goToPage(Page::OpenVpnSettings);
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonProtoSsOpenvpnContSsConfigClicked()
|
||||
{
|
||||
uiLogic()->selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks;
|
||||
uiLogic()->shadowSocksLogic()->updateShadowSocksPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Protocol::ShadowSocks),
|
||||
uiLogic()->selectedDockerContainer, m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
uiLogic()->goToPage(Page::ShadowSocksSettings);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef SERVER_CONTAINERS_LOGIC_H
|
||||
#define SERVER_CONTAINERS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ServerContainersLogic : public QObject
|
||||
class ServerContainersLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -49,6 +48,10 @@ public:
|
|||
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContSsConfigClicked();
|
||||
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContCloakConfigClicked();
|
||||
|
||||
Q_INVOKABLE void onPushButtonProtoOpenvpnContOpenvpnConfigClicked();
|
||||
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked();
|
||||
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContSsConfigClicked();
|
||||
|
||||
public:
|
||||
explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~ServerContainersLogic() = default;
|
||||
|
@ -168,12 +171,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
bool m_pageServerContainersEnabled;
|
||||
int m_progressBarProtocolsContainerReinstallValue;
|
||||
int m_progressBarProtocolsContainerReinstallMaximium;
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
#include "vpnconnection.h"
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
ServerListLogic::ServerListLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_serverListModel{new ServersModel(this)}
|
||||
{
|
||||
|
||||
|
@ -27,8 +23,8 @@ void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
|
|||
|
||||
void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
|
||||
{
|
||||
m_uiLogic->selectedServerIndex = index;
|
||||
m_uiLogic->goToPage(Page::ServerSettings);
|
||||
uiLogic()->selectedServerIndex = index;
|
||||
uiLogic()->goToPage(Page::ServerSettings);
|
||||
}
|
||||
|
||||
void ServerListLogic::updateServersListPage()
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#ifndef SERVER_LIST_LOGIC_H
|
||||
#define SERVER_LIST_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
#include "../serversmodel.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ServerListLogic : public QObject
|
||||
class ServerListLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -35,12 +34,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
ServersModel* m_serverListModel;
|
||||
|
||||
};
|
||||
|
|
|
@ -4,17 +4,13 @@
|
|||
#include "../uilogic.h"
|
||||
#include "ServerListLogic.h"
|
||||
#include "ShareConnectionLogic.h"
|
||||
#include "VpnLogic.h"
|
||||
|
||||
#include "core/errorstrings.h"
|
||||
#include <core/servercontroller.h>
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
|
||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pageServerSettingsEnabled{true},
|
||||
m_labelServerSettingsWaitInfoVisible{true},
|
||||
m_pushButtonServerSettingsClearVisible{true},
|
||||
|
@ -30,10 +26,10 @@ void ServerSettingsLogic::updateServerSettingsPage()
|
|||
{
|
||||
setLabelServerSettingsWaitInfoVisible(false);
|
||||
setLabelServerSettingsWaitInfoText("");
|
||||
setPushButtonServerSettingsClearVisible(m_settings.haveAuthData(m_uiLogic->selectedServerIndex));
|
||||
setPushButtonServerSettingsClearClientCacheVisible(m_settings.haveAuthData(m_uiLogic->selectedServerIndex));
|
||||
setPushButtonServerSettingsShareFullVisible(m_settings.haveAuthData(m_uiLogic->selectedServerIndex));
|
||||
QJsonObject server = m_settings.server(m_uiLogic->selectedServerIndex);
|
||||
setPushButtonServerSettingsClearVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
setPushButtonServerSettingsClearClientCacheVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
setPushButtonServerSettingsShareFullVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
QString port = server.value(config_key::port).toString();
|
||||
setLabelServerSettingsServerText(QString("%1@%2%3%4")
|
||||
.arg(server.value(config_key::userName).toString())
|
||||
|
@ -41,7 +37,7 @@ void ServerSettingsLogic::updateServerSettingsPage()
|
|||
.arg(port.isEmpty() ? "" : ":")
|
||||
.arg(port));
|
||||
setLineEditServerSettingsDescriptionText(server.value(config_key::description).toString());
|
||||
QString selectedContainerName = m_settings.defaultContainerName(m_uiLogic->selectedServerIndex);
|
||||
QString selectedContainerName = m_settings.defaultContainerName(uiLogic()->selectedServerIndex);
|
||||
setLabelServerSettingsCurrentVpnProtocolText(tr("Protocol: ") + selectedContainerName);
|
||||
}
|
||||
|
||||
|
@ -64,26 +60,26 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearServer()
|
|||
setPageServerSettingsEnabled(false);
|
||||
setPushButtonServerSettingsClearText(tr("Uninstalling Amnezia software..."));
|
||||
|
||||
if (m_settings.defaultServerIndex() == m_uiLogic->selectedServerIndex) {
|
||||
m_uiLogic->onDisconnect();
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
}
|
||||
|
||||
ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(m_uiLogic->selectedServerIndex));
|
||||
ServerController::disconnectFromHost(m_settings.serverCredentials(m_uiLogic->selectedServerIndex));
|
||||
ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||
ServerController::disconnectFromHost(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||
if (e) {
|
||||
m_uiLogic->setDialogConnectErrorText(
|
||||
uiLogic()->setDialogConnectErrorText(
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e) + "\n" +
|
||||
tr("See logs for details."));
|
||||
emit m_uiLogic->showConnectErrorDialog();
|
||||
emit uiLogic()->showConnectErrorDialog();
|
||||
}
|
||||
else {
|
||||
setLabelServerSettingsWaitInfoVisible(true);
|
||||
setLabelServerSettingsWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
||||
}
|
||||
|
||||
m_settings.setContainers(m_uiLogic->selectedServerIndex, {});
|
||||
m_settings.setDefaultContainer(m_uiLogic->selectedServerIndex, DockerContainer::None);
|
||||
m_settings.setContainers(uiLogic()->selectedServerIndex, {});
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
|
||||
setPageServerSettingsEnabled(true);
|
||||
setPushButtonServerSettingsClearText(tr("Clear server from Amnezia software"));
|
||||
|
@ -91,15 +87,15 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearServer()
|
|||
|
||||
void ServerSettingsLogic::onPushButtonServerSettingsForgetServer()
|
||||
{
|
||||
if (m_settings.defaultServerIndex() == m_uiLogic->selectedServerIndex && m_uiLogic->m_vpnConnection->isConnected()) {
|
||||
m_uiLogic->onDisconnect();
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
}
|
||||
m_settings.removeServer(m_uiLogic->selectedServerIndex);
|
||||
m_settings.removeServer(uiLogic()->selectedServerIndex);
|
||||
|
||||
if (m_settings.defaultServerIndex() == m_uiLogic->selectedServerIndex) {
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
m_settings.setDefaultServer(0);
|
||||
}
|
||||
else if (m_settings.defaultServerIndex() > m_uiLogic->selectedServerIndex) {
|
||||
else if (m_settings.defaultServerIndex() > uiLogic()->selectedServerIndex) {
|
||||
m_settings.setDefaultServer(m_settings.defaultServerIndex() - 1);
|
||||
}
|
||||
|
||||
|
@ -108,15 +104,15 @@ void ServerSettingsLogic::onPushButtonServerSettingsForgetServer()
|
|||
}
|
||||
|
||||
|
||||
m_uiLogic->selectedServerIndex = -1;
|
||||
uiLogic()->selectedServerIndex = -1;
|
||||
|
||||
m_uiLogic->serverListLogic()->updateServersListPage();
|
||||
uiLogic()->serverListLogic()->updateServersListPage();
|
||||
|
||||
if (m_settings.serversCount() == 0) {
|
||||
m_uiLogic->setStartPage(Page::Start);
|
||||
uiLogic()->setStartPage(Page::Start);
|
||||
}
|
||||
else {
|
||||
m_uiLogic->closePage();
|
||||
uiLogic()->closePage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,9 +239,9 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearClientCacheClicked()
|
|||
{
|
||||
setPushButtonServerSettingsClearClientCacheText(tr("Cache cleared"));
|
||||
|
||||
const auto &containers = m_settings.containers(m_uiLogic->selectedServerIndex);
|
||||
const auto &containers = m_settings.containers(uiLogic()->selectedServerIndex);
|
||||
for (DockerContainer container: containers.keys()) {
|
||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, container);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
|
||||
}
|
||||
|
||||
QTimer::singleShot(3000, this, [this]() {
|
||||
|
@ -256,10 +252,10 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearClientCacheClicked()
|
|||
void ServerSettingsLogic::onLineEditServerSettingsDescriptionEditingFinished()
|
||||
{
|
||||
const QString &newText = getLineEditServerSettingsDescriptionText();
|
||||
QJsonObject server = m_settings.server(m_uiLogic->selectedServerIndex);
|
||||
QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
server.insert(config_key::description, newText);
|
||||
m_settings.editServer(m_uiLogic->selectedServerIndex, server);
|
||||
m_uiLogic->serverListLogic()->updateServersListPage();
|
||||
m_settings.editServer(uiLogic()->selectedServerIndex, server);
|
||||
uiLogic()->serverListLogic()->updateServersListPage();
|
||||
}
|
||||
|
||||
QString ServerSettingsLogic::getPushButtonServerSettingsClearClientCacheText() const
|
||||
|
@ -277,6 +273,6 @@ void ServerSettingsLogic::setPushButtonServerSettingsClearClientCacheText(const
|
|||
|
||||
void ServerSettingsLogic::onPushButtonServerSettingsShareFullClicked()
|
||||
{
|
||||
m_uiLogic->shareConnectionLogic()->updateSharingPage(m_uiLogic->selectedServerIndex, m_settings.serverCredentials(m_uiLogic->selectedServerIndex), DockerContainer::None);
|
||||
m_uiLogic->goToPage(Page::ShareConnection);
|
||||
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), DockerContainer::None);
|
||||
uiLogic()->goToPage(Page::ShareConnection);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef SERVER_SETTINGS_LOGIC_H
|
||||
#define SERVER_SETTINGS_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ServerSettingsLogic : public QObject
|
||||
class ServerSettingsLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -81,12 +80,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
bool m_pageServerSettingsEnabled;
|
||||
bool m_labelServerSettingsWaitInfoVisible;
|
||||
bool m_pushButtonServerSettingsClearVisible;
|
||||
|
|
|
@ -19,12 +19,8 @@
|
|||
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
ShareConnectionLogic::ShareConnectionLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pageShareAmneziaVisible{true},
|
||||
m_pageShareOpenvpnVisible{true},
|
||||
m_pageShareShadowsocksVisible{true},
|
||||
|
@ -57,7 +53,7 @@ ShareConnectionLogic::ShareConnectionLogic(UiLogic *uiLogic, QObject *parent):
|
|||
m_pushButtonShareOpenvpnGenerateText{tr("Generate config")}
|
||||
{
|
||||
// TODO consider move to Component.onCompleted
|
||||
updateSharingPage(m_uiLogic->selectedServerIndex, m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer);
|
||||
updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -533,15 +529,15 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
setPushButtonShareAmneziaGenerateText(tr("Generating..."));
|
||||
qApp->processEvents();
|
||||
|
||||
ServerCredentials credentials = m_settings.serverCredentials(m_uiLogic->selectedServerIndex);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
containerConfig.insert(config_key::container, containerToString(m_uiLogic->selectedDockerContainer));
|
||||
ServerCredentials credentials = m_settings.serverCredentials(uiLogic()->selectedServerIndex);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
containerConfig.insert(config_key::container, containerToString(uiLogic()->selectedDockerContainer));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
for (Protocol p: amnezia::protocolsForContainer(m_uiLogic->selectedDockerContainer)) {
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, p);
|
||||
for (Protocol p: amnezia::protocolsForContainer(uiLogic()->selectedDockerContainer)) {
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p);
|
||||
|
||||
QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, m_uiLogic->selectedDockerContainer, containerConfig, p, &e);
|
||||
QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, uiLogic()->selectedDockerContainer, containerConfig, p, &e);
|
||||
if (e) {
|
||||
cfg = "Error generating config";
|
||||
break;
|
||||
|
@ -553,12 +549,12 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
|
||||
QByteArray ba;
|
||||
if (!e) {
|
||||
QJsonObject serverConfig = m_settings.server(m_uiLogic->selectedServerIndex);
|
||||
QJsonObject serverConfig = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
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, containerToString(m_uiLogic->selectedDockerContainer));
|
||||
serverConfig.insert(config_key::defaultContainer, containerToString(uiLogic()->selectedDockerContainer));
|
||||
|
||||
|
||||
ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
|
@ -580,11 +576,11 @@ void ShareConnectionLogic::onPushButtonShareOpenvpnGenerateClicked()
|
|||
setPushButtonShareOpenvpnSaveEnabled(false);
|
||||
setPushButtonShareOpenvpnGenerateText(tr("Generating..."));
|
||||
|
||||
ServerCredentials credentials = m_settings.serverCredentials(m_uiLogic->selectedServerIndex);
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
ServerCredentials credentials = m_settings.serverCredentials(uiLogic()->selectedServerIndex);
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, m_uiLogic->selectedDockerContainer, containerConfig, &e);
|
||||
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, uiLogic()->selectedDockerContainer, containerConfig, &e);
|
||||
cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg);
|
||||
|
||||
setTextEditShareOpenvpnCodeText(cfg);
|
||||
|
@ -610,8 +606,8 @@ void ShareConnectionLogic::onPushButtonShareOpenvpnSaveClicked()
|
|||
void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCredentials &credentials,
|
||||
DockerContainer container)
|
||||
{
|
||||
m_uiLogic->selectedDockerContainer = container;
|
||||
m_uiLogic->selectedServerIndex = serverIndex;
|
||||
uiLogic()->selectedDockerContainer = container;
|
||||
uiLogic()->selectedServerIndex = serverIndex;
|
||||
|
||||
//const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
|
||||
|
@ -708,7 +704,7 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
|||
if (container == DockerContainer::None) {
|
||||
setPageShareFullAccessVisible(true);
|
||||
|
||||
const QJsonObject &server = m_settings.server(m_uiLogic->selectedServerIndex);
|
||||
const QJsonObject &server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
|
||||
QByteArray ba = QJsonDocument(server).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#ifndef SHARE_CONNECTION_LOGIC_H
|
||||
#define SHARE_CONNECTION_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ShareConnectionLogic: public QObject
|
||||
class ShareConnectionLogic: public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -162,12 +161,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
CQR_Encode m_qrEncode;
|
||||
|
||||
bool m_pageShareAmneziaVisible;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QHostInfo>
|
||||
|
||||
#include "SitesLogic.h"
|
||||
#include "VpnLogic.h"
|
||||
#include "utils.h"
|
||||
#include "vpnconnection.h"
|
||||
#include <functional>
|
||||
|
@ -11,13 +12,8 @@
|
|||
#include "../uilogic.h"
|
||||
#include "../sites_model.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
|
||||
SitesLogic::SitesLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
SitesLogic::SitesLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_labelSitesAddCustomText{},
|
||||
m_tableViewSitesModel{nullptr},
|
||||
m_lineEditSitesAddCustomText{}
|
||||
|
@ -83,7 +79,7 @@ void SitesLogic::setLineEditSitesAddCustomText(const QString &lineEditSitesAddCu
|
|||
|
||||
void SitesLogic::onPushButtonAddCustomSitesClicked()
|
||||
{
|
||||
if (m_uiLogic->getRadioButtonVpnModeAllSitesChecked()) {
|
||||
if (uiLogic()->vpnLogic()->getRadioButtonVpnModeAllSitesChecked()) {
|
||||
return;
|
||||
}
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
|
@ -106,12 +102,12 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
|||
m_settings.addVpnSite(mode, newSite, ip);
|
||||
|
||||
if (!ip.isEmpty()) {
|
||||
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << ip);
|
||||
m_uiLogic->m_vpnConnection->flushDns();
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ip);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
}
|
||||
else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
||||
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << newSite);
|
||||
m_uiLogic->m_vpnConnection->flushDns();
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << newSite);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
}
|
||||
|
||||
updateSitesPage();
|
||||
|
@ -159,11 +155,11 @@ void SitesLogic::onPushButtonSitesDeleteClicked(int row)
|
|||
m_settings.removeVpnSites(mode, sites);
|
||||
}
|
||||
|
||||
if (m_uiLogic->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
||||
if (uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
||||
QStringList ips;
|
||||
ips.append(siteModel->data(row, 1).toString());
|
||||
m_uiLogic->m_vpnConnection->deleteRoutes(ips);
|
||||
m_uiLogic->m_vpnConnection->flushDns();
|
||||
uiLogic()->m_vpnConnection->deleteRoutes(ips);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
}
|
||||
|
||||
updateSitesPage();
|
||||
|
@ -193,8 +189,8 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
|
||||
m_settings.addVpnIps(mode, ips);
|
||||
|
||||
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||
m_uiLogic->m_vpnConnection->flushDns();
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
|
||||
updateSitesPage();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#ifndef SITES_LOGIC_H
|
||||
#define SITES_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
class SitesModel;
|
||||
|
||||
class SitesLogic : public QObject
|
||||
class SitesLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -48,10 +47,6 @@ private slots:
|
|||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
QString m_labelSitesAddCustomText;
|
||||
QObject* m_tableViewSitesModel;
|
||||
QString m_lineEditSitesAddCustomText;
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
#include "configurators/ssh_configurator.h"
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
StartPageLogic::StartPageLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pushButtonNewServerConnectEnabled{true},
|
||||
m_pushButtonNewServerConnectText{tr("Connect")},
|
||||
m_pushButtonNewServerConnectKeyChecked{false},
|
||||
|
@ -199,7 +195,7 @@ void StartPageLogic::onPushButtonNewServerConnect()
|
|||
if (getPushButtonNewServerConnectKeyChecked()){
|
||||
QString key = getTextEditNewServerSshKeyText();
|
||||
if (key.startsWith("ssh-rsa")) {
|
||||
emit m_uiLogic->showPublicKeyWarning();
|
||||
emit uiLogic()->showPublicKeyWarning();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -241,8 +237,8 @@ void StartPageLogic::onPushButtonNewServerConnect()
|
|||
setPushButtonNewServerConnectEnabled(true);
|
||||
setPushButtonNewServerConnectText(tr("Connect"));
|
||||
|
||||
m_uiLogic->installCredentials = serverCredentials;
|
||||
if (ok) m_uiLogic->goToPage(Page::NewServer);
|
||||
uiLogic()->installCredentials = serverCredentials;
|
||||
if (ok) uiLogic()->goToPage(Page::NewServer);
|
||||
}
|
||||
|
||||
void StartPageLogic::onPushButtonNewServerImport()
|
||||
|
@ -286,7 +282,7 @@ void StartPageLogic::onPushButtonNewServerImport()
|
|||
m_settings.addServer(o);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
|
||||
m_uiLogic->setStartPage(Page::Vpn);
|
||||
uiLogic()->setStartPage(Page::Vpn);
|
||||
}
|
||||
else {
|
||||
qDebug() << "Failed to import profile";
|
||||
|
@ -295,9 +291,9 @@ void StartPageLogic::onPushButtonNewServerImport()
|
|||
}
|
||||
|
||||
if (!o.contains(config_key::containers)) {
|
||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
m_uiLogic->selectedDockerContainer = m_settings.defaultContainer(m_uiLogic->selectedServerIndex);
|
||||
m_uiLogic->goToPage(Page::ServerContainers);
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->goToPage(Page::ServerContainers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef START_PAGE_LOGIC_H
|
||||
#define START_PAGE_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class StartPageLogic : public QObject
|
||||
class StartPageLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -80,12 +79,7 @@ private:
|
|||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
bool m_pushButtonNewServerConnectEnabled;
|
||||
QString m_pushButtonNewServerConnectText;
|
||||
bool m_pushButtonNewServerConnectKeyChecked;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHostInfo>
|
||||
#include <QItemSelectionModel>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
#include <QSysInfo>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QRegularExpression>
|
||||
#include <QSaveFile>
|
||||
//#include <QApplication>
|
||||
//#include <QClipboard>
|
||||
//#include <QDebug>
|
||||
//#include <QDesktopServices>
|
||||
//#include <QFileDialog>
|
||||
//#include <QHBoxLayout>
|
||||
//#include <QHostInfo>
|
||||
//#include <QItemSelectionModel>
|
||||
//#include <QJsonDocument>
|
||||
//#include <QJsonObject>
|
||||
//#include <QKeyEvent>
|
||||
//#include <QMenu>
|
||||
//#include <QMessageBox>
|
||||
//#include <QMetaEnum>
|
||||
//#include <QSysInfo>
|
||||
//#include <QThread>
|
||||
//#include <QTimer>
|
||||
//#include <QRegularExpression>
|
||||
//#include <QSaveFile>
|
||||
|
||||
//#include "configurators/cloak_configurator.h"
|
||||
//#include "configurators/vpn_configurator.h"
|
||||
|
@ -31,24 +31,333 @@
|
|||
//#include "protocols/protocols_defs.h"
|
||||
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include "VpnLogic.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "core/errorstrings.h"
|
||||
#include "vpnconnection.h"
|
||||
#include <functional>
|
||||
|
||||
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
||||
#include "ui/macos_util.h"
|
||||
#endif
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
#include "../uilogic.h"
|
||||
|
||||
|
||||
VpnLogic::VpnLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic)
|
||||
VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pushButtonConnectChecked{false},
|
||||
|
||||
m_radioButtonVpnModeAllSitesChecked{true},
|
||||
m_radioButtonVpnModeForwardSitesChecked{false},
|
||||
m_radioButtonVpnModeExceptSitesChecked{false},
|
||||
m_pushButtonVpnAddSiteEnabled{true},
|
||||
|
||||
m_labelSpeedReceivedText{tr("0 Mbps")},
|
||||
m_labelSpeedSentText{tr("0 Mbps")},
|
||||
m_labelStateText{},
|
||||
m_pushButtonConnectEnabled{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);
|
||||
|
||||
if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) {
|
||||
QTimer::singleShot(1000, this, [this](){
|
||||
setPushButtonConnectEnabled(false);
|
||||
onConnect();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VpnLogic::updateVpnPage()
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
setRadioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites);
|
||||
setRadioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites);
|
||||
setRadioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites);
|
||||
setPushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites);
|
||||
}
|
||||
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeAllSitesToggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
}
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeForwardSitesToggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
}
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeExceptSitesToggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnLogic::getRadioButtonVpnModeAllSitesChecked() const
|
||||
{
|
||||
return m_radioButtonVpnModeAllSitesChecked;
|
||||
}
|
||||
|
||||
bool VpnLogic::getRadioButtonVpnModeForwardSitesChecked() const
|
||||
{
|
||||
return m_radioButtonVpnModeForwardSitesChecked;
|
||||
}
|
||||
|
||||
bool VpnLogic::getRadioButtonVpnModeExceptSitesChecked() const
|
||||
{
|
||||
return m_radioButtonVpnModeExceptSitesChecked;
|
||||
}
|
||||
|
||||
void VpnLogic::setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked)
|
||||
{
|
||||
if (m_radioButtonVpnModeAllSitesChecked != radioButtonVpnModeAllSitesChecked) {
|
||||
m_radioButtonVpnModeAllSitesChecked = radioButtonVpnModeAllSitesChecked;
|
||||
emit radioButtonVpnModeAllSitesCheckedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void VpnLogic::setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked)
|
||||
{
|
||||
if (m_radioButtonVpnModeForwardSitesChecked != radioButtonVpnModeForwardSitesChecked) {
|
||||
m_radioButtonVpnModeForwardSitesChecked = radioButtonVpnModeForwardSitesChecked;
|
||||
emit radioButtonVpnModeForwardSitesCheckedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void VpnLogic::setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked)
|
||||
{
|
||||
if (m_radioButtonVpnModeExceptSitesChecked != radioButtonVpnModeExceptSitesChecked) {
|
||||
m_radioButtonVpnModeExceptSitesChecked = radioButtonVpnModeExceptSitesChecked;
|
||||
emit radioButtonVpnModeExceptSitesCheckedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnLogic::getPushButtonConnectChecked() const
|
||||
{
|
||||
return m_pushButtonConnectChecked;
|
||||
}
|
||||
|
||||
void VpnLogic::setPushButtonConnectChecked(bool pushButtonConnectChecked)
|
||||
{
|
||||
if (m_pushButtonConnectChecked != pushButtonConnectChecked) {
|
||||
m_pushButtonConnectChecked = pushButtonConnectChecked;
|
||||
emit pushButtonConnectCheckedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnLogic::getPushButtonVpnAddSiteEnabled() const
|
||||
{
|
||||
return m_pushButtonVpnAddSiteEnabled;
|
||||
}
|
||||
|
||||
void VpnLogic::setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled)
|
||||
{
|
||||
if (m_pushButtonVpnAddSiteEnabled != pushButtonVpnAddSiteEnabled) {
|
||||
m_pushButtonVpnAddSiteEnabled = pushButtonVpnAddSiteEnabled;
|
||||
emit pushButtonVpnAddSiteEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString VpnLogic::getLabelSpeedReceivedText() const
|
||||
{
|
||||
return m_labelSpeedReceivedText;
|
||||
}
|
||||
|
||||
void VpnLogic::setLabelSpeedReceivedText(const QString &labelSpeedReceivedText)
|
||||
{
|
||||
if (m_labelSpeedReceivedText != labelSpeedReceivedText) {
|
||||
m_labelSpeedReceivedText = labelSpeedReceivedText;
|
||||
emit labelSpeedReceivedTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString VpnLogic::getLabelSpeedSentText() const
|
||||
{
|
||||
return m_labelSpeedSentText;
|
||||
}
|
||||
|
||||
void VpnLogic::setLabelSpeedSentText(const QString &labelSpeedSentText)
|
||||
{
|
||||
if (m_labelSpeedSentText != labelSpeedSentText) {
|
||||
m_labelSpeedSentText = labelSpeedSentText;
|
||||
emit labelSpeedSentTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString VpnLogic::getLabelStateText() const
|
||||
{
|
||||
return m_labelStateText;
|
||||
}
|
||||
|
||||
void VpnLogic::setLabelStateText(const QString &labelStateText)
|
||||
{
|
||||
if (m_labelStateText != labelStateText) {
|
||||
m_labelStateText = labelStateText;
|
||||
emit labelStateTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnLogic::getPushButtonConnectEnabled() const
|
||||
{
|
||||
return m_pushButtonConnectEnabled;
|
||||
}
|
||||
|
||||
void VpnLogic::setPushButtonConnectEnabled(bool pushButtonConnectEnabled)
|
||||
{
|
||||
if (m_pushButtonConnectEnabled != pushButtonConnectEnabled) {
|
||||
m_pushButtonConnectEnabled = pushButtonConnectEnabled;
|
||||
emit pushButtonConnectEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnLogic::getWidgetVpnModeEnabled() const
|
||||
{
|
||||
return m_widgetVpnModeEnabled;
|
||||
}
|
||||
|
||||
void VpnLogic::setWidgetVpnModeEnabled(bool widgetVpnModeEnabled)
|
||||
{
|
||||
if (m_widgetVpnModeEnabled != widgetVpnModeEnabled) {
|
||||
m_widgetVpnModeEnabled = widgetVpnModeEnabled;
|
||||
emit widgetVpnModeEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString VpnLogic::getLabelErrorText() const
|
||||
{
|
||||
return m_labelErrorText;
|
||||
}
|
||||
|
||||
void VpnLogic::setLabelErrorText(const QString &labelErrorText)
|
||||
{
|
||||
if (m_labelErrorText != labelErrorText) {
|
||||
m_labelErrorText = labelErrorText;
|
||||
emit labelErrorTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void VpnLogic::onBytesChanged(quint64 receivedData, quint64 sentData)
|
||||
{
|
||||
setLabelSpeedReceivedText(VpnConnection::bytesPerSecToText(receivedData));
|
||||
setLabelSpeedSentText(VpnConnection::bytesPerSecToText(sentData));
|
||||
}
|
||||
|
||||
void VpnLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state)
|
||||
{
|
||||
qDebug() << "UiLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state);
|
||||
|
||||
bool pushButtonConnectEnabled = false;
|
||||
bool radioButtonsModeEnabled = false;
|
||||
setLabelStateText(VpnProtocol::textConnectionState(state));
|
||||
|
||||
uiLogic()->setTrayState(state);
|
||||
|
||||
switch (state) {
|
||||
case VpnProtocol::Disconnected:
|
||||
onBytesChanged(0,0);
|
||||
setPushButtonConnectChecked(false);
|
||||
pushButtonConnectEnabled = true;
|
||||
radioButtonsModeEnabled = true;
|
||||
break;
|
||||
case VpnProtocol::Preparing:
|
||||
pushButtonConnectEnabled = false;
|
||||
radioButtonsModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Connecting:
|
||||
pushButtonConnectEnabled = false;
|
||||
radioButtonsModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Connected:
|
||||
pushButtonConnectEnabled = true;
|
||||
radioButtonsModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Disconnecting:
|
||||
pushButtonConnectEnabled = false;
|
||||
radioButtonsModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Reconnecting:
|
||||
pushButtonConnectEnabled = true;
|
||||
radioButtonsModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Error:
|
||||
setPushButtonConnectEnabled(false);
|
||||
pushButtonConnectEnabled = true;
|
||||
radioButtonsModeEnabled = true;
|
||||
break;
|
||||
case VpnProtocol::Unknown:
|
||||
pushButtonConnectEnabled = true;
|
||||
radioButtonsModeEnabled = true;
|
||||
}
|
||||
|
||||
setPushButtonConnectEnabled(pushButtonConnectEnabled);
|
||||
setWidgetVpnModeEnabled(radioButtonsModeEnabled);
|
||||
}
|
||||
|
||||
void VpnLogic::onVpnProtocolError(ErrorCode errorCode)
|
||||
{
|
||||
setLabelErrorText(errorString(errorCode));
|
||||
}
|
||||
|
||||
void VpnLogic::onPushButtonConnectClicked(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
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()) {
|
||||
setLabelErrorText(tr("VPN Protocols is not installed.\n Please install VPN container at first"));
|
||||
setPushButtonConnectChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (container == DockerContainer::None) {
|
||||
setLabelErrorText(tr("VPN Protocol not choosen"));
|
||||
setPushButtonConnectChecked(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)
|
||||
{
|
||||
setLabelErrorText("");
|
||||
setPushButtonConnectChecked(true);
|
||||
qApp->processEvents();
|
||||
|
||||
ErrorCode errorCode = uiLogic()->m_vpnConnection->connectToVpn(
|
||||
serverIndex, credentials, container, containerConfig
|
||||
);
|
||||
|
||||
if (errorCode) {
|
||||
//ui->pushButton_connect->setChecked(false);
|
||||
uiLogic()->setDialogConnectErrorText(errorString(errorCode));
|
||||
emit uiLogic()->showConnectErrorDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
setPushButtonConnectEnabled(false);
|
||||
}
|
||||
|
||||
void VpnLogic::onDisconnect()
|
||||
{
|
||||
setPushButtonConnectChecked(false);
|
||||
uiLogic()->m_vpnConnection->disconnectFromVpn();
|
||||
}
|
||||
|
|
|
@ -1,35 +1,104 @@
|
|||
#ifndef VPN_LOGIC_H
|
||||
#define VPN_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
#include "protocols/vpnprotocol.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class VpnLogic : public QObject
|
||||
class VpnLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool pushButtonConnectChecked READ getPushButtonConnectChecked WRITE setPushButtonConnectChecked NOTIFY pushButtonConnectCheckedChanged)
|
||||
Q_PROPERTY(QString labelSpeedReceivedText READ getLabelSpeedReceivedText WRITE setLabelSpeedReceivedText NOTIFY labelSpeedReceivedTextChanged)
|
||||
Q_PROPERTY(QString labelSpeedSentText READ getLabelSpeedSentText WRITE setLabelSpeedSentText NOTIFY labelSpeedSentTextChanged)
|
||||
Q_PROPERTY(QString labelStateText READ getLabelStateText WRITE setLabelStateText NOTIFY labelStateTextChanged)
|
||||
Q_PROPERTY(bool pushButtonConnectEnabled READ getPushButtonConnectEnabled WRITE setPushButtonConnectEnabled NOTIFY pushButtonConnectEnabledChanged)
|
||||
Q_PROPERTY(bool widgetVpnModeEnabled READ getWidgetVpnModeEnabled WRITE setWidgetVpnModeEnabled NOTIFY widgetVpnModeEnabledChanged)
|
||||
Q_PROPERTY(QString labelErrorText READ getLabelErrorText WRITE setLabelErrorText NOTIFY labelErrorTextChanged)
|
||||
Q_PROPERTY(bool pushButtonVpnAddSiteEnabled READ getPushButtonVpnAddSiteEnabled WRITE setPushButtonVpnAddSiteEnabled NOTIFY pushButtonVpnAddSiteEnabledChanged)
|
||||
|
||||
Q_PROPERTY(bool radioButtonVpnModeAllSitesChecked READ getRadioButtonVpnModeAllSitesChecked WRITE setRadioButtonVpnModeAllSitesChecked NOTIFY radioButtonVpnModeAllSitesCheckedChanged)
|
||||
Q_PROPERTY(bool radioButtonVpnModeForwardSitesChecked READ getRadioButtonVpnModeForwardSitesChecked WRITE setRadioButtonVpnModeForwardSitesChecked NOTIFY radioButtonVpnModeForwardSitesCheckedChanged)
|
||||
Q_PROPERTY(bool radioButtonVpnModeExceptSitesChecked READ getRadioButtonVpnModeExceptSitesChecked WRITE setRadioButtonVpnModeExceptSitesChecked NOTIFY radioButtonVpnModeExceptSitesCheckedChanged)
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void updateVpnPage();
|
||||
|
||||
Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked);
|
||||
Q_INVOKABLE void onRadioButtonVpnModeForwardSitesToggled(bool checked);
|
||||
Q_INVOKABLE void onRadioButtonVpnModeExceptSitesToggled(bool checked);
|
||||
|
||||
Q_INVOKABLE void onPushButtonConnectClicked(bool checked);
|
||||
|
||||
public:
|
||||
explicit VpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~VpnLogic() = default;
|
||||
|
||||
bool getPushButtonConnectChecked() const;
|
||||
void setPushButtonConnectChecked(bool pushButtonConnectChecked);
|
||||
|
||||
|
||||
QString getLabelSpeedReceivedText() const;
|
||||
void setLabelSpeedReceivedText(const QString &labelSpeedReceivedText);
|
||||
QString getLabelSpeedSentText() const;
|
||||
void setLabelSpeedSentText(const QString &labelSpeedSentText);
|
||||
QString getLabelStateText() const;
|
||||
void setLabelStateText(const QString &labelStateText);
|
||||
bool getPushButtonConnectEnabled() const;
|
||||
void setPushButtonConnectEnabled(bool pushButtonConnectEnabled);
|
||||
bool getWidgetVpnModeEnabled() const;
|
||||
void setWidgetVpnModeEnabled(bool widgetVpnModeEnabled);
|
||||
QString getLabelErrorText() const;
|
||||
void setLabelErrorText(const QString &labelErrorText);
|
||||
|
||||
bool getRadioButtonVpnModeAllSitesChecked() const;
|
||||
void setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked);
|
||||
bool getRadioButtonVpnModeForwardSitesChecked() const;
|
||||
void setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked);
|
||||
bool getRadioButtonVpnModeExceptSitesChecked() const;
|
||||
void setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked);
|
||||
bool getPushButtonVpnAddSiteEnabled() const;
|
||||
void setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled);
|
||||
|
||||
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(VpnProtocol::ConnectionState state);
|
||||
void onVpnProtocolError(amnezia::ErrorCode errorCode);
|
||||
|
||||
signals:
|
||||
void radioButtonVpnModeAllSitesCheckedChanged();
|
||||
void radioButtonVpnModeForwardSitesCheckedChanged();
|
||||
void radioButtonVpnModeExceptSitesCheckedChanged();
|
||||
void pushButtonVpnAddSiteEnabledChanged();
|
||||
|
||||
void pushButtonConnectCheckedChanged();
|
||||
|
||||
void labelSpeedReceivedTextChanged();
|
||||
void labelSpeedSentTextChanged();
|
||||
void labelStateTextChanged();
|
||||
void pushButtonConnectEnabledChanged();
|
||||
void widgetVpnModeEnabledChanged();
|
||||
void labelErrorTextChanged();
|
||||
|
||||
private:
|
||||
bool m_pushButtonConnectChecked;
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
|
||||
bool m_radioButtonVpnModeAllSitesChecked;
|
||||
bool m_radioButtonVpnModeForwardSitesChecked;
|
||||
bool m_radioButtonVpnModeExceptSitesChecked;
|
||||
bool m_pushButtonVpnAddSiteEnabled;
|
||||
QString m_labelSpeedReceivedText;
|
||||
QString m_labelSpeedSentText;
|
||||
QString m_labelStateText;
|
||||
bool m_pushButtonConnectEnabled;
|
||||
bool m_widgetVpnModeEnabled;
|
||||
QString m_labelErrorText;
|
||||
|
||||
};
|
||||
#endif // VPN_LOGIC_H
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
#include "WizardLogic.h"
|
||||
#include "../uilogic.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
WizardLogic::WizardLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
WizardLogic::WizardLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_radioButtonSetupWizardHighChecked{false},
|
||||
m_radioButtonSetupWizardMediumChecked{true},
|
||||
m_radioButtonSetupWizardLowChecked{false},
|
||||
|
@ -120,7 +116,7 @@ QMap<DockerContainer, QJsonObject> WizardLogic::getInstallConfigsFromWizardPage(
|
|||
|
||||
void WizardLogic::onPushButtonSetupWizardVpnModeFinishClicked()
|
||||
{
|
||||
m_uiLogic->installServer(getInstallConfigsFromWizardPage());
|
||||
uiLogic()->installServer(getInstallConfigsFromWizardPage());
|
||||
if (getCheckBoxSetupWizardVpnModeChecked()) {
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
} else {
|
||||
|
@ -130,5 +126,5 @@ void WizardLogic::onPushButtonSetupWizardVpnModeFinishClicked()
|
|||
|
||||
void WizardLogic::onPushButtonSetupWizardLowFinishClicked()
|
||||
{
|
||||
m_uiLogic->installServer(getInstallConfigsFromWizardPage());
|
||||
uiLogic()->installServer(getInstallConfigsFromWizardPage());
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef WIZARD_LOGIC_H
|
||||
#define WIZARD_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class WizardLogic : public QObject
|
||||
class WizardLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -55,10 +54,6 @@ private slots:
|
|||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
bool m_radioButtonSetupWizardHighChecked;
|
||||
bool m_radioButtonSetupWizardMediumChecked;
|
||||
bool m_radioButtonSetupWizardLowChecked;
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
CloakLogic::CloakLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
CloakLogic::CloakLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_comboBoxProtoCloakCipherText{"chacha20-poly1305"},
|
||||
m_lineEditProtoCloakSiteText{"tile.openstreetmap.org"},
|
||||
m_lineEditProtoCloakPortText{},
|
||||
|
@ -213,10 +212,10 @@ void CloakLogic::setProgressBarProtoCloakResetMaximium(int progressBarProtoCloak
|
|||
|
||||
void CloakLogic::onPushButtonProtoCloakSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, Protocol::Cloak);
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Protocol::Cloak);
|
||||
protocolConfig = getCloakConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(config_key::cloak, protocolConfig);
|
||||
|
||||
|
@ -249,16 +248,16 @@ void CloakLogic::onPushButtonProtoCloakSaveClicked()
|
|||
return getProgressBarProtoCloakResetMaximium();
|
||||
};
|
||||
|
||||
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_cloak, progressBar_proto_cloak_reset,
|
||||
pushButton_proto_cloak_save, label_proto_cloak_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << m_uiLogic->selectedServerIndex << m_uiLogic->selectedDockerContainer;
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef CLOAK_LOGIC_H
|
||||
#define CLOAK_LOGIC_H
|
||||
|
||||
#include "../../pages.h"
|
||||
#include "settings.h"
|
||||
#include "../PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class CloakLogic : public QObject
|
||||
class CloakLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
OpenVpnLogic::OpenVpnLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
OpenVpnLogic::OpenVpnLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_lineEditProtoOpenvpnSubnetText{},
|
||||
m_radioButtonProtoOpenvpnUdpChecked{false},
|
||||
m_checkBoxProtoOpenvpnAutoEncryptionChecked{},
|
||||
|
@ -375,10 +374,10 @@ void OpenVpnLogic::onCheckBoxProtoOpenvpnAutoEncryptionClicked()
|
|||
|
||||
void OpenVpnLogic::onPushButtonProtoOpenvpnSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, Protocol::OpenVpn);
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Protocol::OpenVpn);
|
||||
protocolConfig = getOpenVpnConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(config_key::openvpn, protocolConfig);
|
||||
|
||||
|
@ -411,17 +410,17 @@ void OpenVpnLogic::onPushButtonProtoOpenvpnSaveClicked()
|
|||
return getProgressBarProtoOpenvpnResetMaximium();
|
||||
};
|
||||
|
||||
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_openvpn, progressBar_proto_openvpn_reset,
|
||||
pushButton_proto_openvpn_save, label_proto_openvpn_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << m_uiLogic->selectedServerIndex << m_uiLogic->selectedDockerContainer;
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
||||
QJsonObject OpenVpnLogic::getOpenVpnConfigFromPage(QJsonObject oldConfig)
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef OPENVPN_LOGIC_H
|
||||
#define OPENVPN_LOGIC_H
|
||||
|
||||
#include "../../pages.h"
|
||||
#include "settings.h"
|
||||
#include "../PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class OpenVpnLogic : public QObject
|
||||
class OpenVpnLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
ShadowSocksLogic::ShadowSocksLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_widgetProtoSsEnabled{false},
|
||||
m_comboBoxProtoShadowsocksCipherText{"chacha20-poly1305"},
|
||||
m_lineEditProtoShadowsocksPortText{},
|
||||
|
@ -192,10 +191,10 @@ void ShadowSocksLogic::setWidgetProtoSsEnabled(bool widgetProtoSsEnabled)
|
|||
|
||||
void ShadowSocksLogic::onPushButtonProtoShadowsocksSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, Protocol::ShadowSocks);
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Protocol::ShadowSocks);
|
||||
protocolConfig = getShadowSocksConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(config_key::shadowsocks, protocolConfig);
|
||||
UiLogic::PageFunc page_proto_shadowsocks;
|
||||
|
@ -227,15 +226,15 @@ void ShadowSocksLogic::onPushButtonProtoShadowsocksSaveClicked()
|
|||
return getProgressBarProtoShadowsocksResetMaximium();
|
||||
};
|
||||
|
||||
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_shadowsocks, progressBar_proto_shadowsocks_reset,
|
||||
pushButton_proto_shadowsocks_save, label_proto_shadowsocks_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << m_uiLogic->selectedServerIndex << m_uiLogic->selectedDockerContainer;
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef SHADOWSOCKS_LOGIC_H
|
||||
#define SHADOWSOCKS_LOGIC_H
|
||||
|
||||
#include "../../pages.h"
|
||||
#include "settings.h"
|
||||
#include "../PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ShadowSocksLogic : public QObject
|
||||
class ShadowSocksLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue