VpnLogic
This commit is contained in:
parent
deaeda59d0
commit
539bf2ee24
42 changed files with 678 additions and 940 deletions
|
@ -39,7 +39,7 @@ HEADERS += \
|
||||||
ui/pages_logic/NetworkSettingsLogic.h \
|
ui/pages_logic/NetworkSettingsLogic.h \
|
||||||
ui/pages_logic/NewServerConfiguringLogic.h \
|
ui/pages_logic/NewServerConfiguringLogic.h \
|
||||||
ui/pages_logic/NewServerProtocolsLogic.h \
|
ui/pages_logic/NewServerProtocolsLogic.h \
|
||||||
ui/pages_logic/ProtocolSettingsLogic.h \
|
ui/pages_logic/PageLogicBase.h \
|
||||||
ui/pages_logic/ServerContainersLogic.h \
|
ui/pages_logic/ServerContainersLogic.h \
|
||||||
ui/pages_logic/ServerListLogic.h \
|
ui/pages_logic/ServerListLogic.h \
|
||||||
ui/pages_logic/ServerSettingsLogic.h \
|
ui/pages_logic/ServerSettingsLogic.h \
|
||||||
|
@ -85,7 +85,7 @@ SOURCES += \
|
||||||
ui/pages_logic/NetworkSettingsLogic.cpp \
|
ui/pages_logic/NetworkSettingsLogic.cpp \
|
||||||
ui/pages_logic/NewServerConfiguringLogic.cpp \
|
ui/pages_logic/NewServerConfiguringLogic.cpp \
|
||||||
ui/pages_logic/NewServerProtocolsLogic.cpp \
|
ui/pages_logic/NewServerProtocolsLogic.cpp \
|
||||||
ui/pages_logic/ProtocolSettingsLogic.cpp \
|
ui/pages_logic/PageLogicBase.cpp \
|
||||||
ui/pages_logic/ServerContainersLogic.cpp \
|
ui/pages_logic/ServerContainersLogic.cpp \
|
||||||
ui/pages_logic/ServerListLogic.cpp \
|
ui/pages_logic/ServerListLogic.cpp \
|
||||||
ui/pages_logic/ServerSettingsLogic.cpp \
|
ui/pages_logic/ServerSettingsLogic.cpp \
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
||||||
#include "ui/pages_logic/NewServerConfiguringLogic.h"
|
#include "ui/pages_logic/NewServerConfiguringLogic.h"
|
||||||
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
||||||
#include "ui/pages_logic/ProtocolSettingsLogic.h"
|
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||||
#include "ui/pages_logic/ServerListLogic.h"
|
#include "ui/pages_logic/ServerListLogic.h"
|
||||||
#include "ui/pages_logic/ServerSettingsLogic.h"
|
#include "ui/pages_logic/ServerSettingsLogic.h"
|
||||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||||
|
@ -134,7 +134,6 @@ int main(int argc, char *argv[])
|
||||||
engine.rootContext()->setContextProperty("NetworkSettingsLogic", uiLogic->networkSettingsLogic());
|
engine.rootContext()->setContextProperty("NetworkSettingsLogic", uiLogic->networkSettingsLogic());
|
||||||
engine.rootContext()->setContextProperty("NewServerConfiguringLogic", uiLogic->newServerConfiguringLogic());
|
engine.rootContext()->setContextProperty("NewServerConfiguringLogic", uiLogic->newServerConfiguringLogic());
|
||||||
engine.rootContext()->setContextProperty("NewServerProtocolsLogic", uiLogic->newServerProtocolsLogic());
|
engine.rootContext()->setContextProperty("NewServerProtocolsLogic", uiLogic->newServerProtocolsLogic());
|
||||||
engine.rootContext()->setContextProperty("ProtocolSettingsLogic", uiLogic->protocolSettingsLogic());
|
|
||||||
engine.rootContext()->setContextProperty("ServerListLogic", uiLogic->serverListLogic());
|
engine.rootContext()->setContextProperty("ServerListLogic", uiLogic->serverListLogic());
|
||||||
engine.rootContext()->setContextProperty("ServerSettingsLogic", uiLogic->serverSettingsLogic());
|
engine.rootContext()->setContextProperty("ServerSettingsLogic", uiLogic->serverSettingsLogic());
|
||||||
engine.rootContext()->setContextProperty("ServerContainersLogic", uiLogic->serverVpnProtocolsLogic());
|
engine.rootContext()->setContextProperty("ServerContainersLogic", uiLogic->serverVpnProtocolsLogic());
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
using namespace amnezia;
|
using namespace amnezia;
|
||||||
using namespace PageEnumNS;
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
AppSettingsLogic::AppSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
AppSettingsLogic::AppSettingsLogic(UiLogic *logic, QObject *parent):
|
||||||
QObject(parent),
|
PageLogicBase(logic, parent),
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_checkBoxAppSettingsAutostartChecked{false},
|
m_checkBoxAppSettingsAutostartChecked{false},
|
||||||
m_checkBoxAppSettingsAutoconnectChecked{false},
|
m_checkBoxAppSettingsAutoconnectChecked{false},
|
||||||
m_checkBoxAppSettingsStartMinimizedChecked{false}
|
m_checkBoxAppSettingsStartMinimizedChecked{false}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef APP_SETTINGS_LOGIC_H
|
#ifndef APP_SETTINGS_LOGIC_H
|
||||||
#define APP_SETTINGS_LOGIC_H
|
#define APP_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class AppSettingsLogic : public QObject
|
class AppSettingsLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -55,9 +54,6 @@ private slots:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
|
|
||||||
bool m_checkBoxAppSettingsAutostartChecked;
|
bool m_checkBoxAppSettingsAutostartChecked;
|
||||||
bool m_checkBoxAppSettingsAutoconnectChecked;
|
bool m_checkBoxAppSettingsAutoconnectChecked;
|
||||||
bool m_checkBoxAppSettingsStartMinimizedChecked;
|
bool m_checkBoxAppSettingsStartMinimizedChecked;
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
|
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent)
|
||||||
|
|
||||||
GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,15 +29,15 @@ void GeneralSettingsLogic::setPushButtonGeneralSettingsShareConnectionEnable(boo
|
||||||
|
|
||||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
||||||
{
|
{
|
||||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
m_uiLogic->goToPage(Page::ServerSettings);
|
uiLogic()->goToPage(Page::ServerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
||||||
{
|
{
|
||||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
m_uiLogic->selectedDockerContainer = m_settings.defaultContainer(m_uiLogic->selectedServerIndex);
|
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||||
|
|
||||||
m_uiLogic->shareConnectionLogic()->updateSharingPage(m_uiLogic->selectedServerIndex, m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer);
|
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer);
|
||||||
m_uiLogic->goToPage(Page::ShareConnection);
|
uiLogic()->goToPage(Page::ShareConnection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef GENERAL_SETTINGS_LOGIC_H
|
#ifndef GENERAL_SETTINGS_LOGIC_H
|
||||||
#define GENERAL_SETTINGS_LOGIC_H
|
#define GENERAL_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class GeneralSettingsLogic : public QObject
|
class GeneralSettingsLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -37,12 +36,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
bool m_pushButtonGeneralSettingsShareConnectionEnable;
|
bool m_pushButtonGeneralSettingsShareConnectionEnable;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_ipAddressValidatorRegex{Utils::ipAddressRegExp().pattern()}
|
m_ipAddressValidatorRegex{Utils::ipAddressRegExp().pattern()}
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef NETWORK_SETTINGS_LOGIC_H
|
#ifndef NETWORK_SETTINGS_LOGIC_H
|
||||||
#define NETWORK_SETTINGS_LOGIC_H
|
#define NETWORK_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class NetworkSettingsLogic : public QObject
|
class NetworkSettingsLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -48,12 +47,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
QString m_lineEditNetworkSettingsDns1Text;
|
QString m_lineEditNetworkSettingsDns1Text;
|
||||||
QString m_lineEditNetworkSettingsDns2Text;
|
QString m_lineEditNetworkSettingsDns2Text;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#include "NewServerConfiguringLogic.h"
|
#include "NewServerConfiguringLogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
NewServerConfiguringLogic::NewServerConfiguringLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
NewServerConfiguringLogic::NewServerConfiguringLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_progressBarNewServerConfiguringValue{0},
|
m_progressBarNewServerConfiguringValue{0},
|
||||||
m_pageNewServerConfiguringEnabled{true},
|
m_pageNewServerConfiguringEnabled{true},
|
||||||
m_labelNewServerConfiguringWaitInfoVisible{true},
|
m_labelNewServerConfiguringWaitInfoVisible{true},
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef NEW_SERVER_CONFIGURING_LOGIC_H
|
#ifndef NEW_SERVER_CONFIGURING_LOGIC_H
|
||||||
#define NEW_SERVER_CONFIGURING_LOGIC_H
|
#define NEW_SERVER_CONFIGURING_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class NewServerConfiguringLogic : public QObject
|
class NewServerConfiguringLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -58,12 +57,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
double m_progressBarNewServerConfiguringValue;
|
double m_progressBarNewServerConfiguringValue;
|
||||||
bool m_pageNewServerConfiguringEnabled;
|
bool m_pageNewServerConfiguringEnabled;
|
||||||
bool m_labelNewServerConfiguringWaitInfoVisible;
|
bool m_labelNewServerConfiguringWaitInfoVisible;
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
#include "NewServerProtocolsLogic.h"
|
#include "NewServerProtocolsLogic.h"
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_pushButtonNewServerSettingsCloakChecked{false},
|
m_pushButtonNewServerSettingsCloakChecked{false},
|
||||||
m_pushButtonNewServerSettingsSsChecked{false},
|
m_pushButtonNewServerSettingsSsChecked{false},
|
||||||
m_pushButtonNewServerSettingsOpenvpnChecked{false},
|
m_pushButtonNewServerSettingsOpenvpnChecked{false},
|
||||||
|
@ -26,7 +22,7 @@ NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *uiLogic, QObject *pare
|
||||||
setFrameNewServerSettingsParentWireguardVisible(false);
|
setFrameNewServerSettingsParentWireguardVisible(false);
|
||||||
|
|
||||||
connect(this, &NewServerProtocolsLogic::pushButtonNewServerConnectConfigureClicked, this, [this](){
|
connect(this, &NewServerProtocolsLogic::pushButtonNewServerConnectConfigureClicked, this, [this](){
|
||||||
m_uiLogic->installServer(getInstallConfigsFromProtocolsPage());
|
uiLogic()->installServer(getInstallConfigsFromProtocolsPage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef NEW_SERVER_PROTOCOLS_LOGIC_H
|
#ifndef NEW_SERVER_PROTOCOLS_LOGIC_H
|
||||||
#define NEW_SERVER_PROTOCOLS_LOGIC_H
|
#define NEW_SERVER_PROTOCOLS_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class NewServerProtocolsLogic : public QObject
|
class NewServerProtocolsLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -96,12 +95,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
bool m_frameNewServerSettingsParentWireguardVisible;
|
bool m_frameNewServerSettingsParentWireguardVisible;
|
||||||
|
|
||||||
bool m_pushButtonNewServerSettingsCloakChecked;
|
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"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
ServerContainersLogic::ServerContainersLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
ServerContainersLogic::ServerContainersLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_pageServerContainersEnabled{true},
|
m_pageServerContainersEnabled{true},
|
||||||
m_progressBarProtocolsContainerReinstallValue{0},
|
m_progressBarProtocolsContainerReinstallValue{0},
|
||||||
m_progressBarProtocolsContainerReinstallMaximium{100},
|
m_progressBarProtocolsContainerReinstallMaximium{100},
|
||||||
|
@ -647,3 +643,27 @@ void ServerContainersLogic::onPushButtonProtoCloakOpenvpnContCloakConfigClicked(
|
||||||
uiLogic()->selectedDockerContainer, m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
uiLogic()->selectedDockerContainer, m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||||
uiLogic()->goToPage(Page::CloakSettings);
|
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
|
#ifndef SERVER_CONTAINERS_LOGIC_H
|
||||||
#define SERVER_CONTAINERS_LOGIC_H
|
#define SERVER_CONTAINERS_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class ServerContainersLogic : public QObject
|
class ServerContainersLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -49,6 +48,10 @@ public:
|
||||||
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContSsConfigClicked();
|
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContSsConfigClicked();
|
||||||
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContCloakConfigClicked();
|
Q_INVOKABLE void onPushButtonProtoCloakOpenvpnContCloakConfigClicked();
|
||||||
|
|
||||||
|
Q_INVOKABLE void onPushButtonProtoOpenvpnContOpenvpnConfigClicked();
|
||||||
|
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked();
|
||||||
|
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContSsConfigClicked();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
~ServerContainersLogic() = default;
|
~ServerContainersLogic() = default;
|
||||||
|
@ -168,12 +171,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
bool m_pageServerContainersEnabled;
|
bool m_pageServerContainersEnabled;
|
||||||
int m_progressBarProtocolsContainerReinstallValue;
|
int m_progressBarProtocolsContainerReinstallValue;
|
||||||
int m_progressBarProtocolsContainerReinstallMaximium;
|
int m_progressBarProtocolsContainerReinstallMaximium;
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
ServerListLogic::ServerListLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_serverListModel{new ServersModel(this)}
|
m_serverListModel{new ServersModel(this)}
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -27,8 +23,8 @@ void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
|
||||||
|
|
||||||
void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
|
void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
|
||||||
{
|
{
|
||||||
m_uiLogic->selectedServerIndex = index;
|
uiLogic()->selectedServerIndex = index;
|
||||||
m_uiLogic->goToPage(Page::ServerSettings);
|
uiLogic()->goToPage(Page::ServerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerListLogic::updateServersListPage()
|
void ServerListLogic::updateServersListPage()
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
#ifndef SERVER_LIST_LOGIC_H
|
#ifndef SERVER_LIST_LOGIC_H
|
||||||
#define SERVER_LIST_LOGIC_H
|
#define SERVER_LIST_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "../serversmodel.h"
|
#include "../serversmodel.h"
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class ServerListLogic : public QObject
|
class ServerListLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -35,12 +34,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
ServersModel* m_serverListModel;
|
ServersModel* m_serverListModel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,17 +4,13 @@
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
#include "ServerListLogic.h"
|
#include "ServerListLogic.h"
|
||||||
#include "ShareConnectionLogic.h"
|
#include "ShareConnectionLogic.h"
|
||||||
|
#include "VpnLogic.h"
|
||||||
|
|
||||||
#include "core/errorstrings.h"
|
#include "core/errorstrings.h"
|
||||||
#include <core/servercontroller.h>
|
#include <core/servercontroller.h>
|
||||||
|
|
||||||
using namespace amnezia;
|
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
|
|
||||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_pageServerSettingsEnabled{true},
|
m_pageServerSettingsEnabled{true},
|
||||||
m_labelServerSettingsWaitInfoVisible{true},
|
m_labelServerSettingsWaitInfoVisible{true},
|
||||||
m_pushButtonServerSettingsClearVisible{true},
|
m_pushButtonServerSettingsClearVisible{true},
|
||||||
|
@ -30,10 +26,10 @@ void ServerSettingsLogic::updateServerSettingsPage()
|
||||||
{
|
{
|
||||||
setLabelServerSettingsWaitInfoVisible(false);
|
setLabelServerSettingsWaitInfoVisible(false);
|
||||||
setLabelServerSettingsWaitInfoText("");
|
setLabelServerSettingsWaitInfoText("");
|
||||||
setPushButtonServerSettingsClearVisible(m_settings.haveAuthData(m_uiLogic->selectedServerIndex));
|
setPushButtonServerSettingsClearVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||||
setPushButtonServerSettingsClearClientCacheVisible(m_settings.haveAuthData(m_uiLogic->selectedServerIndex));
|
setPushButtonServerSettingsClearClientCacheVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||||
setPushButtonServerSettingsShareFullVisible(m_settings.haveAuthData(m_uiLogic->selectedServerIndex));
|
setPushButtonServerSettingsShareFullVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||||
QJsonObject server = m_settings.server(m_uiLogic->selectedServerIndex);
|
QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||||
QString port = server.value(config_key::port).toString();
|
QString port = server.value(config_key::port).toString();
|
||||||
setLabelServerSettingsServerText(QString("%1@%2%3%4")
|
setLabelServerSettingsServerText(QString("%1@%2%3%4")
|
||||||
.arg(server.value(config_key::userName).toString())
|
.arg(server.value(config_key::userName).toString())
|
||||||
|
@ -41,7 +37,7 @@ void ServerSettingsLogic::updateServerSettingsPage()
|
||||||
.arg(port.isEmpty() ? "" : ":")
|
.arg(port.isEmpty() ? "" : ":")
|
||||||
.arg(port));
|
.arg(port));
|
||||||
setLineEditServerSettingsDescriptionText(server.value(config_key::description).toString());
|
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);
|
setLabelServerSettingsCurrentVpnProtocolText(tr("Protocol: ") + selectedContainerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,26 +60,26 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearServer()
|
||||||
setPageServerSettingsEnabled(false);
|
setPageServerSettingsEnabled(false);
|
||||||
setPushButtonServerSettingsClearText(tr("Uninstalling Amnezia software..."));
|
setPushButtonServerSettingsClearText(tr("Uninstalling Amnezia software..."));
|
||||||
|
|
||||||
if (m_settings.defaultServerIndex() == m_uiLogic->selectedServerIndex) {
|
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||||
m_uiLogic->onDisconnect();
|
uiLogic()->vpnLogic()->onDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(m_uiLogic->selectedServerIndex));
|
ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||||
ServerController::disconnectFromHost(m_settings.serverCredentials(m_uiLogic->selectedServerIndex));
|
ServerController::disconnectFromHost(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||||
if (e) {
|
if (e) {
|
||||||
m_uiLogic->setDialogConnectErrorText(
|
uiLogic()->setDialogConnectErrorText(
|
||||||
tr("Error occurred while configuring server.") + "\n" +
|
tr("Error occurred while configuring server.") + "\n" +
|
||||||
errorString(e) + "\n" +
|
errorString(e) + "\n" +
|
||||||
tr("See logs for details."));
|
tr("See logs for details."));
|
||||||
emit m_uiLogic->showConnectErrorDialog();
|
emit uiLogic()->showConnectErrorDialog();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setLabelServerSettingsWaitInfoVisible(true);
|
setLabelServerSettingsWaitInfoVisible(true);
|
||||||
setLabelServerSettingsWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
setLabelServerSettingsWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings.setContainers(m_uiLogic->selectedServerIndex, {});
|
m_settings.setContainers(uiLogic()->selectedServerIndex, {});
|
||||||
m_settings.setDefaultContainer(m_uiLogic->selectedServerIndex, DockerContainer::None);
|
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||||
|
|
||||||
setPageServerSettingsEnabled(true);
|
setPageServerSettingsEnabled(true);
|
||||||
setPushButtonServerSettingsClearText(tr("Clear server from Amnezia software"));
|
setPushButtonServerSettingsClearText(tr("Clear server from Amnezia software"));
|
||||||
|
@ -91,15 +87,15 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearServer()
|
||||||
|
|
||||||
void ServerSettingsLogic::onPushButtonServerSettingsForgetServer()
|
void ServerSettingsLogic::onPushButtonServerSettingsForgetServer()
|
||||||
{
|
{
|
||||||
if (m_settings.defaultServerIndex() == m_uiLogic->selectedServerIndex && m_uiLogic->m_vpnConnection->isConnected()) {
|
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||||
m_uiLogic->onDisconnect();
|
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);
|
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);
|
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) {
|
if (m_settings.serversCount() == 0) {
|
||||||
m_uiLogic->setStartPage(Page::Start);
|
uiLogic()->setStartPage(Page::Start);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_uiLogic->closePage();
|
uiLogic()->closePage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,9 +239,9 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearClientCacheClicked()
|
||||||
{
|
{
|
||||||
setPushButtonServerSettingsClearClientCacheText(tr("Cache cleared"));
|
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()) {
|
for (DockerContainer container: containers.keys()) {
|
||||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, container);
|
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot(3000, this, [this]() {
|
QTimer::singleShot(3000, this, [this]() {
|
||||||
|
@ -256,10 +252,10 @@ void ServerSettingsLogic::onPushButtonServerSettingsClearClientCacheClicked()
|
||||||
void ServerSettingsLogic::onLineEditServerSettingsDescriptionEditingFinished()
|
void ServerSettingsLogic::onLineEditServerSettingsDescriptionEditingFinished()
|
||||||
{
|
{
|
||||||
const QString &newText = getLineEditServerSettingsDescriptionText();
|
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);
|
server.insert(config_key::description, newText);
|
||||||
m_settings.editServer(m_uiLogic->selectedServerIndex, server);
|
m_settings.editServer(uiLogic()->selectedServerIndex, server);
|
||||||
m_uiLogic->serverListLogic()->updateServersListPage();
|
uiLogic()->serverListLogic()->updateServersListPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ServerSettingsLogic::getPushButtonServerSettingsClearClientCacheText() const
|
QString ServerSettingsLogic::getPushButtonServerSettingsClearClientCacheText() const
|
||||||
|
@ -277,6 +273,6 @@ void ServerSettingsLogic::setPushButtonServerSettingsClearClientCacheText(const
|
||||||
|
|
||||||
void ServerSettingsLogic::onPushButtonServerSettingsShareFullClicked()
|
void ServerSettingsLogic::onPushButtonServerSettingsShareFullClicked()
|
||||||
{
|
{
|
||||||
m_uiLogic->shareConnectionLogic()->updateSharingPage(m_uiLogic->selectedServerIndex, m_settings.serverCredentials(m_uiLogic->selectedServerIndex), DockerContainer::None);
|
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), DockerContainer::None);
|
||||||
m_uiLogic->goToPage(Page::ShareConnection);
|
uiLogic()->goToPage(Page::ShareConnection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef SERVER_SETTINGS_LOGIC_H
|
#ifndef SERVER_SETTINGS_LOGIC_H
|
||||||
#define SERVER_SETTINGS_LOGIC_H
|
#define SERVER_SETTINGS_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class ServerSettingsLogic : public QObject
|
class ServerSettingsLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -81,12 +80,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
bool m_pageServerSettingsEnabled;
|
bool m_pageServerSettingsEnabled;
|
||||||
bool m_labelServerSettingsWaitInfoVisible;
|
bool m_labelServerSettingsWaitInfoVisible;
|
||||||
bool m_pushButtonServerSettingsClearVisible;
|
bool m_pushButtonServerSettingsClearVisible;
|
||||||
|
|
|
@ -19,12 +19,8 @@
|
||||||
|
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
ShareConnectionLogic::ShareConnectionLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_pageShareAmneziaVisible{true},
|
m_pageShareAmneziaVisible{true},
|
||||||
m_pageShareOpenvpnVisible{true},
|
m_pageShareOpenvpnVisible{true},
|
||||||
m_pageShareShadowsocksVisible{true},
|
m_pageShareShadowsocksVisible{true},
|
||||||
|
@ -57,7 +53,7 @@ ShareConnectionLogic::ShareConnectionLogic(UiLogic *uiLogic, QObject *parent):
|
||||||
m_pushButtonShareOpenvpnGenerateText{tr("Generate config")}
|
m_pushButtonShareOpenvpnGenerateText{tr("Generate config")}
|
||||||
{
|
{
|
||||||
// TODO consider move to Component.onCompleted
|
// 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..."));
|
setPushButtonShareAmneziaGenerateText(tr("Generating..."));
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
|
|
||||||
ServerCredentials credentials = m_settings.serverCredentials(m_uiLogic->selectedServerIndex);
|
ServerCredentials credentials = m_settings.serverCredentials(uiLogic()->selectedServerIndex);
|
||||||
QJsonObject containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||||
containerConfig.insert(config_key::container, containerToString(m_uiLogic->selectedDockerContainer));
|
containerConfig.insert(config_key::container, containerToString(uiLogic()->selectedDockerContainer));
|
||||||
|
|
||||||
ErrorCode e = ErrorCode::NoError;
|
ErrorCode e = ErrorCode::NoError;
|
||||||
for (Protocol p: amnezia::protocolsForContainer(m_uiLogic->selectedDockerContainer)) {
|
for (Protocol p: amnezia::protocolsForContainer(uiLogic()->selectedDockerContainer)) {
|
||||||
QJsonObject protoConfig = m_settings.protocolConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, p);
|
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) {
|
if (e) {
|
||||||
cfg = "Error generating config";
|
cfg = "Error generating config";
|
||||||
break;
|
break;
|
||||||
|
@ -553,12 +549,12 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
||||||
|
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
if (!e) {
|
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::userName);
|
||||||
serverConfig.remove(config_key::password);
|
serverConfig.remove(config_key::password);
|
||||||
serverConfig.remove(config_key::port);
|
serverConfig.remove(config_key::port);
|
||||||
serverConfig.insert(config_key::containers, QJsonArray {containerConfig});
|
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);
|
ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||||
|
@ -580,11 +576,11 @@ void ShareConnectionLogic::onPushButtonShareOpenvpnGenerateClicked()
|
||||||
setPushButtonShareOpenvpnSaveEnabled(false);
|
setPushButtonShareOpenvpnSaveEnabled(false);
|
||||||
setPushButtonShareOpenvpnGenerateText(tr("Generating..."));
|
setPushButtonShareOpenvpnGenerateText(tr("Generating..."));
|
||||||
|
|
||||||
ServerCredentials credentials = m_settings.serverCredentials(m_uiLogic->selectedServerIndex);
|
ServerCredentials credentials = m_settings.serverCredentials(uiLogic()->selectedServerIndex);
|
||||||
const QJsonObject &containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
const QJsonObject &containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||||
|
|
||||||
ErrorCode e = ErrorCode::NoError;
|
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);
|
cfg = OpenVpnConfigurator::processConfigWithExportSettings(cfg);
|
||||||
|
|
||||||
setTextEditShareOpenvpnCodeText(cfg);
|
setTextEditShareOpenvpnCodeText(cfg);
|
||||||
|
@ -610,8 +606,8 @@ void ShareConnectionLogic::onPushButtonShareOpenvpnSaveClicked()
|
||||||
void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCredentials &credentials,
|
void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCredentials &credentials,
|
||||||
DockerContainer container)
|
DockerContainer container)
|
||||||
{
|
{
|
||||||
m_uiLogic->selectedDockerContainer = container;
|
uiLogic()->selectedDockerContainer = container;
|
||||||
m_uiLogic->selectedServerIndex = serverIndex;
|
uiLogic()->selectedServerIndex = serverIndex;
|
||||||
|
|
||||||
//const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
//const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||||
|
|
||||||
|
@ -708,7 +704,7 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
||||||
if (container == DockerContainer::None) {
|
if (container == DockerContainer::None) {
|
||||||
setPageShareFullAccessVisible(true);
|
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);
|
QByteArray ba = QJsonDocument(server).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
#ifndef SHARE_CONNECTION_LOGIC_H
|
#ifndef SHARE_CONNECTION_LOGIC_H
|
||||||
#define SHARE_CONNECTION_LOGIC_H
|
#define SHARE_CONNECTION_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
|
#include "3rd/QRCodeGenerator/QRCodeGenerator.h"
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class ShareConnectionLogic: public QObject
|
class ShareConnectionLogic: public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -162,12 +161,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
CQR_Encode m_qrEncode;
|
CQR_Encode m_qrEncode;
|
||||||
|
|
||||||
bool m_pageShareAmneziaVisible;
|
bool m_pageShareAmneziaVisible;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
|
|
||||||
#include "SitesLogic.h"
|
#include "SitesLogic.h"
|
||||||
|
#include "VpnLogic.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -11,13 +12,8 @@
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
#include "../sites_model.h"
|
#include "../sites_model.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
SitesLogic::SitesLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
|
|
||||||
SitesLogic::SitesLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_labelSitesAddCustomText{},
|
m_labelSitesAddCustomText{},
|
||||||
m_tableViewSitesModel{nullptr},
|
m_tableViewSitesModel{nullptr},
|
||||||
m_lineEditSitesAddCustomText{}
|
m_lineEditSitesAddCustomText{}
|
||||||
|
@ -83,7 +79,7 @@ void SitesLogic::setLineEditSitesAddCustomText(const QString &lineEditSitesAddCu
|
||||||
|
|
||||||
void SitesLogic::onPushButtonAddCustomSitesClicked()
|
void SitesLogic::onPushButtonAddCustomSitesClicked()
|
||||||
{
|
{
|
||||||
if (m_uiLogic->getRadioButtonVpnModeAllSitesChecked()) {
|
if (uiLogic()->vpnLogic()->getRadioButtonVpnModeAllSitesChecked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Settings::RouteMode mode = m_settings.routeMode();
|
Settings::RouteMode mode = m_settings.routeMode();
|
||||||
|
@ -106,12 +102,12 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
||||||
m_settings.addVpnSite(mode, newSite, ip);
|
m_settings.addVpnSite(mode, newSite, ip);
|
||||||
|
|
||||||
if (!ip.isEmpty()) {
|
if (!ip.isEmpty()) {
|
||||||
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << ip);
|
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ip);
|
||||||
m_uiLogic->m_vpnConnection->flushDns();
|
uiLogic()->m_vpnConnection->flushDns();
|
||||||
}
|
}
|
||||||
else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
else if (Utils::ipAddressWithSubnetRegExp().exactMatch(newSite)) {
|
||||||
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << newSite);
|
uiLogic()->m_vpnConnection->addRoutes(QStringList() << newSite);
|
||||||
m_uiLogic->m_vpnConnection->flushDns();
|
uiLogic()->m_vpnConnection->flushDns();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSitesPage();
|
updateSitesPage();
|
||||||
|
@ -159,11 +155,11 @@ void SitesLogic::onPushButtonSitesDeleteClicked(int row)
|
||||||
m_settings.removeVpnSites(mode, sites);
|
m_settings.removeVpnSites(mode, sites);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_uiLogic->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
if (uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
||||||
QStringList ips;
|
QStringList ips;
|
||||||
ips.append(siteModel->data(row, 1).toString());
|
ips.append(siteModel->data(row, 1).toString());
|
||||||
m_uiLogic->m_vpnConnection->deleteRoutes(ips);
|
uiLogic()->m_vpnConnection->deleteRoutes(ips);
|
||||||
m_uiLogic->m_vpnConnection->flushDns();
|
uiLogic()->m_vpnConnection->flushDns();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSitesPage();
|
updateSitesPage();
|
||||||
|
@ -193,8 +189,8 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
||||||
|
|
||||||
m_settings.addVpnIps(mode, ips);
|
m_settings.addVpnIps(mode, ips);
|
||||||
|
|
||||||
m_uiLogic->m_vpnConnection->addRoutes(QStringList() << ips);
|
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||||
m_uiLogic->m_vpnConnection->flushDns();
|
uiLogic()->m_vpnConnection->flushDns();
|
||||||
|
|
||||||
updateSitesPage();
|
updateSitesPage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
#ifndef SITES_LOGIC_H
|
#ifndef SITES_LOGIC_H
|
||||||
#define SITES_LOGIC_H
|
#define SITES_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
class SitesModel;
|
class SitesModel;
|
||||||
|
|
||||||
class SitesLogic : public QObject
|
class SitesLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -48,10 +47,6 @@ private slots:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
QString m_labelSitesAddCustomText;
|
QString m_labelSitesAddCustomText;
|
||||||
QObject* m_tableViewSitesModel;
|
QObject* m_tableViewSitesModel;
|
||||||
QString m_lineEditSitesAddCustomText;
|
QString m_lineEditSitesAddCustomText;
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
#include "configurators/ssh_configurator.h"
|
#include "configurators/ssh_configurator.h"
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
StartPageLogic::StartPageLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_pushButtonNewServerConnectEnabled{true},
|
m_pushButtonNewServerConnectEnabled{true},
|
||||||
m_pushButtonNewServerConnectText{tr("Connect")},
|
m_pushButtonNewServerConnectText{tr("Connect")},
|
||||||
m_pushButtonNewServerConnectKeyChecked{false},
|
m_pushButtonNewServerConnectKeyChecked{false},
|
||||||
|
@ -199,7 +195,7 @@ void StartPageLogic::onPushButtonNewServerConnect()
|
||||||
if (getPushButtonNewServerConnectKeyChecked()){
|
if (getPushButtonNewServerConnectKeyChecked()){
|
||||||
QString key = getTextEditNewServerSshKeyText();
|
QString key = getTextEditNewServerSshKeyText();
|
||||||
if (key.startsWith("ssh-rsa")) {
|
if (key.startsWith("ssh-rsa")) {
|
||||||
emit m_uiLogic->showPublicKeyWarning();
|
emit uiLogic()->showPublicKeyWarning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +237,8 @@ void StartPageLogic::onPushButtonNewServerConnect()
|
||||||
setPushButtonNewServerConnectEnabled(true);
|
setPushButtonNewServerConnectEnabled(true);
|
||||||
setPushButtonNewServerConnectText(tr("Connect"));
|
setPushButtonNewServerConnectText(tr("Connect"));
|
||||||
|
|
||||||
m_uiLogic->installCredentials = serverCredentials;
|
uiLogic()->installCredentials = serverCredentials;
|
||||||
if (ok) m_uiLogic->goToPage(Page::NewServer);
|
if (ok) uiLogic()->goToPage(Page::NewServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartPageLogic::onPushButtonNewServerImport()
|
void StartPageLogic::onPushButtonNewServerImport()
|
||||||
|
@ -286,7 +282,7 @@ void StartPageLogic::onPushButtonNewServerImport()
|
||||||
m_settings.addServer(o);
|
m_settings.addServer(o);
|
||||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||||
|
|
||||||
m_uiLogic->setStartPage(Page::Vpn);
|
uiLogic()->setStartPage(Page::Vpn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Failed to import profile";
|
qDebug() << "Failed to import profile";
|
||||||
|
@ -295,9 +291,9 @@ void StartPageLogic::onPushButtonNewServerImport()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!o.contains(config_key::containers)) {
|
if (!o.contains(config_key::containers)) {
|
||||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||||
m_uiLogic->selectedDockerContainer = m_settings.defaultContainer(m_uiLogic->selectedServerIndex);
|
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||||
m_uiLogic->goToPage(Page::ServerContainers);
|
uiLogic()->goToPage(Page::ServerContainers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef START_PAGE_LOGIC_H
|
#ifndef START_PAGE_LOGIC_H
|
||||||
#define START_PAGE_LOGIC_H
|
#define START_PAGE_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class StartPageLogic : public QObject
|
class StartPageLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -80,12 +79,7 @@ private:
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
bool m_pushButtonNewServerConnectEnabled;
|
bool m_pushButtonNewServerConnectEnabled;
|
||||||
QString m_pushButtonNewServerConnectText;
|
QString m_pushButtonNewServerConnectText;
|
||||||
bool m_pushButtonNewServerConnectKeyChecked;
|
bool m_pushButtonNewServerConnectKeyChecked;
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#include <QApplication>
|
//#include <QApplication>
|
||||||
#include <QClipboard>
|
//#include <QClipboard>
|
||||||
#include <QDebug>
|
//#include <QDebug>
|
||||||
#include <QDesktopServices>
|
//#include <QDesktopServices>
|
||||||
#include <QFileDialog>
|
//#include <QFileDialog>
|
||||||
#include <QHBoxLayout>
|
//#include <QHBoxLayout>
|
||||||
#include <QHostInfo>
|
//#include <QHostInfo>
|
||||||
#include <QItemSelectionModel>
|
//#include <QItemSelectionModel>
|
||||||
#include <QJsonDocument>
|
//#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
//#include <QJsonObject>
|
||||||
#include <QKeyEvent>
|
//#include <QKeyEvent>
|
||||||
#include <QMenu>
|
//#include <QMenu>
|
||||||
#include <QMessageBox>
|
//#include <QMessageBox>
|
||||||
#include <QMetaEnum>
|
//#include <QMetaEnum>
|
||||||
#include <QSysInfo>
|
//#include <QSysInfo>
|
||||||
#include <QThread>
|
//#include <QThread>
|
||||||
#include <QTimer>
|
//#include <QTimer>
|
||||||
#include <QRegularExpression>
|
//#include <QRegularExpression>
|
||||||
#include <QSaveFile>
|
//#include <QSaveFile>
|
||||||
|
|
||||||
//#include "configurators/cloak_configurator.h"
|
//#include "configurators/cloak_configurator.h"
|
||||||
//#include "configurators/vpn_configurator.h"
|
//#include "configurators/vpn_configurator.h"
|
||||||
|
@ -31,24 +31,333 @@
|
||||||
//#include "protocols/protocols_defs.h"
|
//#include "protocols/protocols_defs.h"
|
||||||
//#include "protocols/shadowsocksvpnprotocol.h"
|
//#include "protocols/shadowsocksvpnprotocol.h"
|
||||||
|
|
||||||
#include "debug.h"
|
|
||||||
#include "defines.h"
|
|
||||||
#include "VpnLogic.h"
|
#include "VpnLogic.h"
|
||||||
#include "utils.h"
|
|
||||||
|
#include "core/errorstrings.h"
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include "../uilogic.h"
|
||||||
#if defined Q_OS_MAC || defined Q_OS_LINUX
|
|
||||||
#include "ui/macos_util.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace amnezia;
|
|
||||||
using namespace PageEnumNS;
|
|
||||||
|
|
||||||
|
|
||||||
VpnLogic::VpnLogic(UiLogic *uiLogic, QObject *parent):
|
VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
||||||
QObject(parent),
|
PageLogicBase(logic, parent),
|
||||||
m_uiLogic(uiLogic)
|
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
|
#ifndef VPN_LOGIC_H
|
||||||
#define VPN_LOGIC_H
|
#define VPN_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
#include "protocols/vpnprotocol.h"
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class VpnLogic : public QObject
|
class VpnLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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:
|
public:
|
||||||
explicit VpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
explicit VpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||||
~VpnLogic() = default;
|
~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:
|
signals:
|
||||||
|
void radioButtonVpnModeAllSitesCheckedChanged();
|
||||||
|
void radioButtonVpnModeForwardSitesCheckedChanged();
|
||||||
|
void radioButtonVpnModeExceptSitesCheckedChanged();
|
||||||
|
void pushButtonVpnAddSiteEnabledChanged();
|
||||||
|
|
||||||
|
void pushButtonConnectCheckedChanged();
|
||||||
|
|
||||||
|
void labelSpeedReceivedTextChanged();
|
||||||
|
void labelSpeedSentTextChanged();
|
||||||
|
void labelStateTextChanged();
|
||||||
|
void pushButtonConnectEnabledChanged();
|
||||||
|
void widgetVpnModeEnabledChanged();
|
||||||
|
void labelErrorTextChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_pushButtonConnectChecked;
|
||||||
|
|
||||||
|
bool m_radioButtonVpnModeAllSitesChecked;
|
||||||
private slots:
|
bool m_radioButtonVpnModeForwardSitesChecked;
|
||||||
|
bool m_radioButtonVpnModeExceptSitesChecked;
|
||||||
|
bool m_pushButtonVpnAddSiteEnabled;
|
||||||
|
QString m_labelSpeedReceivedText;
|
||||||
private:
|
QString m_labelSpeedSentText;
|
||||||
Settings m_settings;
|
QString m_labelStateText;
|
||||||
UiLogic *m_uiLogic;
|
bool m_pushButtonConnectEnabled;
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
bool m_widgetVpnModeEnabled;
|
||||||
|
QString m_labelErrorText;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // VPN_LOGIC_H
|
#endif // VPN_LOGIC_H
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
#include "WizardLogic.h"
|
#include "WizardLogic.h"
|
||||||
#include "../uilogic.h"
|
#include "../uilogic.h"
|
||||||
|
|
||||||
using namespace amnezia;
|
WizardLogic::WizardLogic(UiLogic *logic, QObject *parent):
|
||||||
using namespace PageEnumNS;
|
PageLogicBase(logic, parent),
|
||||||
|
|
||||||
WizardLogic::WizardLogic(UiLogic *uiLogic, QObject *parent):
|
|
||||||
QObject(parent),
|
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_radioButtonSetupWizardHighChecked{false},
|
m_radioButtonSetupWizardHighChecked{false},
|
||||||
m_radioButtonSetupWizardMediumChecked{true},
|
m_radioButtonSetupWizardMediumChecked{true},
|
||||||
m_radioButtonSetupWizardLowChecked{false},
|
m_radioButtonSetupWizardLowChecked{false},
|
||||||
|
@ -120,7 +116,7 @@ QMap<DockerContainer, QJsonObject> WizardLogic::getInstallConfigsFromWizardPage(
|
||||||
|
|
||||||
void WizardLogic::onPushButtonSetupWizardVpnModeFinishClicked()
|
void WizardLogic::onPushButtonSetupWizardVpnModeFinishClicked()
|
||||||
{
|
{
|
||||||
m_uiLogic->installServer(getInstallConfigsFromWizardPage());
|
uiLogic()->installServer(getInstallConfigsFromWizardPage());
|
||||||
if (getCheckBoxSetupWizardVpnModeChecked()) {
|
if (getCheckBoxSetupWizardVpnModeChecked()) {
|
||||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,5 +126,5 @@ void WizardLogic::onPushButtonSetupWizardVpnModeFinishClicked()
|
||||||
|
|
||||||
void WizardLogic::onPushButtonSetupWizardLowFinishClicked()
|
void WizardLogic::onPushButtonSetupWizardLowFinishClicked()
|
||||||
{
|
{
|
||||||
m_uiLogic->installServer(getInstallConfigsFromWizardPage());
|
uiLogic()->installServer(getInstallConfigsFromWizardPage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef WIZARD_LOGIC_H
|
#ifndef WIZARD_LOGIC_H
|
||||||
#define WIZARD_LOGIC_H
|
#define WIZARD_LOGIC_H
|
||||||
|
|
||||||
#include "../pages.h"
|
#include "PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class WizardLogic : public QObject
|
class WizardLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -55,10 +54,6 @@ private slots:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
|
||||||
UiLogic *m_uiLogic;
|
|
||||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
|
||||||
|
|
||||||
bool m_radioButtonSetupWizardHighChecked;
|
bool m_radioButtonSetupWizardHighChecked;
|
||||||
bool m_radioButtonSetupWizardMediumChecked;
|
bool m_radioButtonSetupWizardMediumChecked;
|
||||||
bool m_radioButtonSetupWizardLowChecked;
|
bool m_radioButtonSetupWizardLowChecked;
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
using namespace amnezia;
|
using namespace amnezia;
|
||||||
using namespace PageEnumNS;
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
CloakLogic::CloakLogic(UiLogic *uiLogic, QObject *parent):
|
CloakLogic::CloakLogic(UiLogic *logic, QObject *parent):
|
||||||
QObject(parent),
|
PageLogicBase(logic, parent),
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_comboBoxProtoCloakCipherText{"chacha20-poly1305"},
|
m_comboBoxProtoCloakCipherText{"chacha20-poly1305"},
|
||||||
m_lineEditProtoCloakSiteText{"tile.openstreetmap.org"},
|
m_lineEditProtoCloakSiteText{"tile.openstreetmap.org"},
|
||||||
m_lineEditProtoCloakPortText{},
|
m_lineEditProtoCloakPortText{},
|
||||||
|
@ -213,10 +212,10 @@ void CloakLogic::setProgressBarProtoCloakResetMaximium(int progressBarProtoCloak
|
||||||
|
|
||||||
void CloakLogic::onPushButtonProtoCloakSaveClicked()
|
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);
|
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;
|
QJsonObject newContainerConfig = containerConfig;
|
||||||
newContainerConfig.insert(config_key::cloak, protocolConfig);
|
newContainerConfig.insert(config_key::cloak, protocolConfig);
|
||||||
|
|
||||||
|
@ -249,16 +248,16 @@ void CloakLogic::onPushButtonProtoCloakSaveClicked()
|
||||||
return getProgressBarProtoCloakResetMaximium();
|
return getProgressBarProtoCloakResetMaximium();
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
|
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||||
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
|
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||||
},
|
},
|
||||||
page_proto_cloak, progressBar_proto_cloak_reset,
|
page_proto_cloak, progressBar_proto_cloak_reset,
|
||||||
pushButton_proto_cloak_save, label_proto_cloak_info);
|
pushButton_proto_cloak_save, label_proto_cloak_info);
|
||||||
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
|
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
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
|
#ifndef CLOAK_LOGIC_H
|
||||||
#define CLOAK_LOGIC_H
|
#define CLOAK_LOGIC_H
|
||||||
|
|
||||||
#include "../../pages.h"
|
#include "../PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class CloakLogic : public QObject
|
class CloakLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
using namespace amnezia;
|
using namespace amnezia;
|
||||||
using namespace PageEnumNS;
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
OpenVpnLogic::OpenVpnLogic(UiLogic *uiLogic, QObject *parent):
|
OpenVpnLogic::OpenVpnLogic(UiLogic *logic, QObject *parent):
|
||||||
QObject(parent),
|
PageLogicBase(logic, parent),
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_lineEditProtoOpenvpnSubnetText{},
|
m_lineEditProtoOpenvpnSubnetText{},
|
||||||
m_radioButtonProtoOpenvpnUdpChecked{false},
|
m_radioButtonProtoOpenvpnUdpChecked{false},
|
||||||
m_checkBoxProtoOpenvpnAutoEncryptionChecked{},
|
m_checkBoxProtoOpenvpnAutoEncryptionChecked{},
|
||||||
|
@ -375,10 +374,10 @@ void OpenVpnLogic::onCheckBoxProtoOpenvpnAutoEncryptionClicked()
|
||||||
|
|
||||||
void OpenVpnLogic::onPushButtonProtoOpenvpnSaveClicked()
|
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);
|
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;
|
QJsonObject newContainerConfig = containerConfig;
|
||||||
newContainerConfig.insert(config_key::openvpn, protocolConfig);
|
newContainerConfig.insert(config_key::openvpn, protocolConfig);
|
||||||
|
|
||||||
|
@ -411,17 +410,17 @@ void OpenVpnLogic::onPushButtonProtoOpenvpnSaveClicked()
|
||||||
return getProgressBarProtoOpenvpnResetMaximium();
|
return getProgressBarProtoOpenvpnResetMaximium();
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
|
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||||
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
|
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||||
},
|
},
|
||||||
page_proto_openvpn, progressBar_proto_openvpn_reset,
|
page_proto_openvpn, progressBar_proto_openvpn_reset,
|
||||||
pushButton_proto_openvpn_save, label_proto_openvpn_info);
|
pushButton_proto_openvpn_save, label_proto_openvpn_info);
|
||||||
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
|
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
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)
|
QJsonObject OpenVpnLogic::getOpenVpnConfigFromPage(QJsonObject oldConfig)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#ifndef OPENVPN_LOGIC_H
|
#ifndef OPENVPN_LOGIC_H
|
||||||
#define OPENVPN_LOGIC_H
|
#define OPENVPN_LOGIC_H
|
||||||
|
|
||||||
#include "../../pages.h"
|
#include "../PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class OpenVpnLogic : public QObject
|
class OpenVpnLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
using namespace amnezia;
|
using namespace amnezia;
|
||||||
using namespace PageEnumNS;
|
using namespace PageEnumNS;
|
||||||
|
|
||||||
ShadowSocksLogic::ShadowSocksLogic(UiLogic *uiLogic, QObject *parent):
|
ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent):
|
||||||
QObject(parent),
|
PageLogicBase(logic, parent),
|
||||||
m_uiLogic(uiLogic),
|
|
||||||
m_widgetProtoSsEnabled{false},
|
m_widgetProtoSsEnabled{false},
|
||||||
m_comboBoxProtoShadowsocksCipherText{"chacha20-poly1305"},
|
m_comboBoxProtoShadowsocksCipherText{"chacha20-poly1305"},
|
||||||
m_lineEditProtoShadowsocksPortText{},
|
m_lineEditProtoShadowsocksPortText{},
|
||||||
|
@ -192,10 +191,10 @@ void ShadowSocksLogic::setWidgetProtoSsEnabled(bool widgetProtoSsEnabled)
|
||||||
|
|
||||||
void ShadowSocksLogic::onPushButtonProtoShadowsocksSaveClicked()
|
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);
|
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;
|
QJsonObject newContainerConfig = containerConfig;
|
||||||
newContainerConfig.insert(config_key::shadowsocks, protocolConfig);
|
newContainerConfig.insert(config_key::shadowsocks, protocolConfig);
|
||||||
UiLogic::PageFunc page_proto_shadowsocks;
|
UiLogic::PageFunc page_proto_shadowsocks;
|
||||||
|
@ -227,15 +226,15 @@ void ShadowSocksLogic::onPushButtonProtoShadowsocksSaveClicked()
|
||||||
return getProgressBarProtoShadowsocksResetMaximium();
|
return getProgressBarProtoShadowsocksResetMaximium();
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
|
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, newContainerConfig](){
|
||||||
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
|
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||||
},
|
},
|
||||||
page_proto_shadowsocks, progressBar_proto_shadowsocks_reset,
|
page_proto_shadowsocks, progressBar_proto_shadowsocks_reset,
|
||||||
pushButton_proto_shadowsocks_save, label_proto_shadowsocks_info);
|
pushButton_proto_shadowsocks_save, label_proto_shadowsocks_info);
|
||||||
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
|
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||||
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
|
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
|
#ifndef SHADOWSOCKS_LOGIC_H
|
||||||
#define SHADOWSOCKS_LOGIC_H
|
#define SHADOWSOCKS_LOGIC_H
|
||||||
|
|
||||||
#include "../../pages.h"
|
#include "../PageLogicBase.h"
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
class UiLogic;
|
class UiLogic;
|
||||||
|
|
||||||
class ShadowSocksLogic : public QObject
|
class ShadowSocksLogic : public PageLogicBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: UiLogic.labelErrorText
|
text: VpnLogic.labelErrorText
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
@ -52,7 +52,7 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: UiLogic.labelStateText
|
text: VpnLogic.labelStateText
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
|
@ -62,10 +62,10 @@ Item {
|
||||||
width: 80
|
width: 80
|
||||||
height: 40
|
height: 40
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: UiLogic.pushButtonConnectChecked
|
checked: VpnLogic.pushButtonConnectChecked
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.pushButtonConnectChecked = checked
|
VpnLogic.pushButtonConnectChecked = checked
|
||||||
UiLogic.onPushButtonConnectClicked(checked)
|
VpnLogic.onPushButtonConnectClicked(checked)
|
||||||
}
|
}
|
||||||
background: Image {
|
background: Image {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -74,7 +74,7 @@ Item {
|
||||||
}
|
}
|
||||||
contentItem: Item {}
|
contentItem: Item {}
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
enabled: UiLogic.pushButtonConnectEnabled
|
enabled: VpnLogic.pushButtonConnectEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -110,7 +110,7 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: UiLogic.labelSpeedReceivedText
|
text: VpnLogic.labelSpeedReceivedText
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: upload_label
|
id: upload_label
|
||||||
|
@ -125,7 +125,7 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
text: UiLogic.labelSpeedSentText
|
text: VpnLogic.labelSpeedSentText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,18 +162,18 @@ Item {
|
||||||
anchors.bottom: button_add_site.top
|
anchors.bottom: button_add_site.top
|
||||||
width: 351
|
width: 351
|
||||||
height: 91
|
height: 91
|
||||||
enabled: UiLogic.widgetVpnModeEnabled
|
enabled: VpnLogic.widgetVpnModeEnabled
|
||||||
RadioButtonType {
|
RadioButtonType {
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
width: 341
|
width: 341
|
||||||
height: 19
|
height: 19
|
||||||
checked: UiLogic.radioButtonVpnModeAllSitesChecked
|
checked: VpnLogic.radioButtonVpnModeAllSitesChecked
|
||||||
text: qsTr("For all connections")
|
text: qsTr("For all connections")
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.radioButtonVpnModeAllSitesChecked = checked
|
VpnLogic.radioButtonVpnModeAllSitesChecked = checked
|
||||||
button_add_site.enabled = !checked
|
button_add_site.enabled = !checked
|
||||||
UiLogic.onRadioButtonVpnModeAllSitesToggled(checked)
|
VpnLogic.onRadioButtonVpnModeAllSitesToggled(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RadioButtonType {
|
RadioButtonType {
|
||||||
|
@ -182,10 +182,10 @@ Item {
|
||||||
width: 341
|
width: 341
|
||||||
height: 19
|
height: 19
|
||||||
text: qsTr("Except selected sites")
|
text: qsTr("Except selected sites")
|
||||||
checked: UiLogic.radioButtonVpnModeExceptSitesChecked
|
checked: VpnLogic.radioButtonVpnModeExceptSitesChecked
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.radioButtonVpnModeExceptSitesChecked = checked
|
VpnLogic.radioButtonVpnModeExceptSitesChecked = checked
|
||||||
UiLogic.onRadioButtonVpnModeExceptSitesToggled(checked)
|
VpnLogic.onRadioButtonVpnModeExceptSitesToggled(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RadioButtonType {
|
RadioButtonType {
|
||||||
|
@ -194,10 +194,10 @@ Item {
|
||||||
width: 341
|
width: 341
|
||||||
height: 19
|
height: 19
|
||||||
text: qsTr("For selected sites")
|
text: qsTr("For selected sites")
|
||||||
checked: UiLogic.radioButtonVpnModeForwardSitesChecked
|
checked: VpnLogic.radioButtonVpnModeForwardSitesChecked
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
UiLogic.radioButtonVpnModeForwardSitesChecked = checked
|
VpnLogic.radioButtonVpnModeForwardSitesChecked = checked
|
||||||
UiLogic.onRadioButtonVpnModeForwardSitesToggled(checked)
|
VpnLogic.onRadioButtonVpnModeForwardSitesToggled(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ Item {
|
||||||
width: parent.width - 40
|
width: parent.width - 40
|
||||||
height: 40
|
height: 40
|
||||||
text: qsTr("+ Add site")
|
text: qsTr("+ Add site")
|
||||||
enabled: UiLogic.pushButtonVpnAddSiteEnabled
|
enabled: VpnLogic.pushButtonVpnAddSiteEnabled
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: 4
|
radius: 4
|
||||||
|
|
|
@ -182,7 +182,7 @@ Window {
|
||||||
SitesLogic.updateSitesPage()
|
SitesLogic.updateSitesPage()
|
||||||
}
|
}
|
||||||
if (page === PageEnum.Vpn) {
|
if (page === PageEnum.Vpn) {
|
||||||
UiLogic.updateVpnPage()
|
VpnLogic.updateVpnPage()
|
||||||
}
|
}
|
||||||
UiLogic.pushButtonNewServerConnectKeyChecked = false
|
UiLogic.pushButtonNewServerConnectKeyChecked = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
#include "pages_logic/NetworkSettingsLogic.h"
|
#include "pages_logic/NetworkSettingsLogic.h"
|
||||||
#include "pages_logic/NewServerConfiguringLogic.h"
|
#include "pages_logic/NewServerConfiguringLogic.h"
|
||||||
#include "pages_logic/NewServerProtocolsLogic.h"
|
#include "pages_logic/NewServerProtocolsLogic.h"
|
||||||
#include "pages_logic/ProtocolSettingsLogic.h"
|
|
||||||
#include "pages_logic/ServerListLogic.h"
|
#include "pages_logic/ServerListLogic.h"
|
||||||
#include "pages_logic/ServerSettingsLogic.h"
|
#include "pages_logic/ServerSettingsLogic.h"
|
||||||
#include "pages_logic/ServerContainersLogic.h"
|
#include "pages_logic/ServerContainersLogic.h"
|
||||||
|
@ -69,33 +68,10 @@ using namespace PageEnumNS;
|
||||||
|
|
||||||
UiLogic::UiLogic(QObject *parent) :
|
UiLogic::UiLogic(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_radioButtonVpnModeAllSitesChecked{true},
|
|
||||||
m_radioButtonVpnModeForwardSitesChecked{false},
|
|
||||||
m_radioButtonVpnModeExceptSitesChecked{false},
|
|
||||||
m_pushButtonVpnAddSiteEnabled{true},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_currentPageValue{0},
|
m_currentPageValue{0},
|
||||||
m_trayIconUrl{},
|
m_trayIconUrl{},
|
||||||
m_trayActionDisconnectEnabled{true},
|
m_trayActionDisconnectEnabled{true},
|
||||||
m_trayActionConnectEnabled{true},
|
m_trayActionConnectEnabled{true},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_pushButtonConnectChecked{false},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_labelSpeedReceivedText{tr("0 Mbps")},
|
|
||||||
m_labelSpeedSentText{tr("0 Mbps")},
|
|
||||||
m_labelStateText{},
|
|
||||||
m_pushButtonConnectEnabled{false},
|
|
||||||
m_widgetVpnModeEnabled{false},
|
|
||||||
m_labelErrorText{tr("Error text")},
|
|
||||||
m_dialogConnectErrorText{},
|
m_dialogConnectErrorText{},
|
||||||
m_vpnConnection(nullptr)
|
m_vpnConnection(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +82,6 @@ UiLogic::UiLogic(QObject *parent) :
|
||||||
m_networkSettingsLogic = new NetworkSettingsLogic(this);
|
m_networkSettingsLogic = new NetworkSettingsLogic(this);
|
||||||
m_newServerConfiguringLogic = new NewServerConfiguringLogic(this);
|
m_newServerConfiguringLogic = new NewServerConfiguringLogic(this);
|
||||||
m_newServerProtocolsLogic = new NewServerProtocolsLogic(this);
|
m_newServerProtocolsLogic = new NewServerProtocolsLogic(this);
|
||||||
m_protocolSettingsLogic = new ProtocolSettingsLogic(this);
|
|
||||||
m_serverListLogic = new ServerListLogic(this);
|
m_serverListLogic = new ServerListLogic(this);
|
||||||
m_serverSettingsLogic = new ServerSettingsLogic(this);
|
m_serverSettingsLogic = new ServerSettingsLogic(this);
|
||||||
m_serverVpnProtocolsLogic = new ServerContainersLogic(this);
|
m_serverVpnProtocolsLogic = new ServerContainersLogic(this);
|
||||||
|
@ -119,16 +94,11 @@ UiLogic::UiLogic(QObject *parent) :
|
||||||
m_openVpnLogic = new OpenVpnLogic(this);
|
m_openVpnLogic = new OpenVpnLogic(this);
|
||||||
m_shadowSocksLogic = new ShadowSocksLogic(this);
|
m_shadowSocksLogic = new ShadowSocksLogic(this);
|
||||||
m_cloakLogic = new CloakLogic(this);
|
m_cloakLogic = new CloakLogic(this);
|
||||||
|
|
||||||
connect(m_vpnConnection, SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(onBytesChanged(quint64, quint64)));
|
|
||||||
connect(m_vpnConnection, SIGNAL(connectionStateChanged(VpnProtocol::ConnectionState)), this, SLOT(onConnectionStateChanged(VpnProtocol::ConnectionState)));
|
|
||||||
connect(m_vpnConnection, SIGNAL(vpnProtocolError(amnezia::ErrorCode)), this, SLOT(onVpnProtocolError(amnezia::ErrorCode)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::initalizeUiLogic()
|
void UiLogic::initalizeUiLogic()
|
||||||
{
|
{
|
||||||
setupTray();
|
setupTray();
|
||||||
setLabelErrorText("");
|
|
||||||
|
|
||||||
|
|
||||||
// if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) {
|
// if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) {
|
||||||
|
@ -161,14 +131,8 @@ void UiLogic::initalizeUiLogic()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onConnectionStateChanged(VpnProtocol::Disconnected);
|
vpnLogic()->onConnectionStateChanged(VpnProtocol::Disconnected);
|
||||||
|
|
||||||
if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) {
|
|
||||||
QTimer::singleShot(1000, this, [this](){
|
|
||||||
setPushButtonConnectEnabled(false);
|
|
||||||
onConnect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// m_ipAddressValidator.setRegExp(Utils::ipAddressRegExp());
|
// m_ipAddressValidator.setRegExp(Utils::ipAddressRegExp());
|
||||||
// m_ipAddressPortValidator.setRegExp(Utils::ipAddressPortRegExp());
|
// m_ipAddressPortValidator.setRegExp(Utils::ipAddressPortRegExp());
|
||||||
|
@ -190,44 +154,7 @@ void UiLogic::initalizeUiLogic()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UiLogic::getRadioButtonVpnModeAllSitesChecked() const
|
|
||||||
{
|
|
||||||
return m_radioButtonVpnModeAllSitesChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getRadioButtonVpnModeForwardSitesChecked() const
|
|
||||||
{
|
|
||||||
return m_radioButtonVpnModeForwardSitesChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getRadioButtonVpnModeExceptSitesChecked() const
|
|
||||||
{
|
|
||||||
return m_radioButtonVpnModeExceptSitesChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setRadioButtonVpnModeAllSitesChecked(bool radioButtonVpnModeAllSitesChecked)
|
|
||||||
{
|
|
||||||
if (m_radioButtonVpnModeAllSitesChecked != radioButtonVpnModeAllSitesChecked) {
|
|
||||||
m_radioButtonVpnModeAllSitesChecked = radioButtonVpnModeAllSitesChecked;
|
|
||||||
emit radioButtonVpnModeAllSitesCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setRadioButtonVpnModeForwardSitesChecked(bool radioButtonVpnModeForwardSitesChecked)
|
|
||||||
{
|
|
||||||
if (m_radioButtonVpnModeForwardSitesChecked != radioButtonVpnModeForwardSitesChecked) {
|
|
||||||
m_radioButtonVpnModeForwardSitesChecked = radioButtonVpnModeForwardSitesChecked;
|
|
||||||
emit radioButtonVpnModeForwardSitesCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setRadioButtonVpnModeExceptSitesChecked(bool radioButtonVpnModeExceptSitesChecked)
|
|
||||||
{
|
|
||||||
if (m_radioButtonVpnModeExceptSitesChecked != radioButtonVpnModeExceptSitesChecked) {
|
|
||||||
m_radioButtonVpnModeExceptSitesChecked = radioButtonVpnModeExceptSitesChecked;
|
|
||||||
emit radioButtonVpnModeExceptSitesCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,118 +226,7 @@ void UiLogic::setTrayActionConnectEnabled(bool trayActionConnectEnabled)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool UiLogic::getPushButtonConnectChecked() const
|
|
||||||
{
|
|
||||||
return m_pushButtonConnectChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setPushButtonConnectChecked(bool pushButtonConnectChecked)
|
|
||||||
{
|
|
||||||
if (m_pushButtonConnectChecked != pushButtonConnectChecked) {
|
|
||||||
m_pushButtonConnectChecked = pushButtonConnectChecked;
|
|
||||||
emit pushButtonConnectCheckedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getPushButtonVpnAddSiteEnabled() const
|
|
||||||
{
|
|
||||||
return m_pushButtonVpnAddSiteEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setPushButtonVpnAddSiteEnabled(bool pushButtonVpnAddSiteEnabled)
|
|
||||||
{
|
|
||||||
if (m_pushButtonVpnAddSiteEnabled != pushButtonVpnAddSiteEnabled) {
|
|
||||||
m_pushButtonVpnAddSiteEnabled = pushButtonVpnAddSiteEnabled;
|
|
||||||
emit pushButtonVpnAddSiteEnabledChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString UiLogic::getLabelSpeedReceivedText() const
|
|
||||||
{
|
|
||||||
return m_labelSpeedReceivedText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLabelSpeedReceivedText(const QString &labelSpeedReceivedText)
|
|
||||||
{
|
|
||||||
if (m_labelSpeedReceivedText != labelSpeedReceivedText) {
|
|
||||||
m_labelSpeedReceivedText = labelSpeedReceivedText;
|
|
||||||
emit labelSpeedReceivedTextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLabelSpeedSentText() const
|
|
||||||
{
|
|
||||||
return m_labelSpeedSentText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLabelSpeedSentText(const QString &labelSpeedSentText)
|
|
||||||
{
|
|
||||||
if (m_labelSpeedSentText != labelSpeedSentText) {
|
|
||||||
m_labelSpeedSentText = labelSpeedSentText;
|
|
||||||
emit labelSpeedSentTextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLabelStateText() const
|
|
||||||
{
|
|
||||||
return m_labelStateText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLabelStateText(const QString &labelStateText)
|
|
||||||
{
|
|
||||||
if (m_labelStateText != labelStateText) {
|
|
||||||
m_labelStateText = labelStateText;
|
|
||||||
emit labelStateTextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getPushButtonConnectEnabled() const
|
|
||||||
{
|
|
||||||
return m_pushButtonConnectEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setPushButtonConnectEnabled(bool pushButtonConnectEnabled)
|
|
||||||
{
|
|
||||||
if (m_pushButtonConnectEnabled != pushButtonConnectEnabled) {
|
|
||||||
m_pushButtonConnectEnabled = pushButtonConnectEnabled;
|
|
||||||
emit pushButtonConnectEnabledChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UiLogic::getWidgetVpnModeEnabled() const
|
|
||||||
{
|
|
||||||
return m_widgetVpnModeEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setWidgetVpnModeEnabled(bool widgetVpnModeEnabled)
|
|
||||||
{
|
|
||||||
if (m_widgetVpnModeEnabled != widgetVpnModeEnabled) {
|
|
||||||
m_widgetVpnModeEnabled = widgetVpnModeEnabled;
|
|
||||||
emit widgetVpnModeEnabledChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UiLogic::getLabelErrorText() const
|
|
||||||
{
|
|
||||||
return m_labelErrorText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setLabelErrorText(const QString &labelErrorText)
|
|
||||||
{
|
|
||||||
if (m_labelErrorText != labelErrorText) {
|
|
||||||
m_labelErrorText = labelErrorText;
|
|
||||||
emit labelErrorTextChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString UiLogic::getDialogConnectErrorText() const
|
QString UiLogic::getDialogConnectErrorText() const
|
||||||
|
@ -802,78 +618,6 @@ ErrorCode UiLogic::doInstallAction(const std::function<ErrorCode()> &action,
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UiLogic::onBytesChanged(quint64 receivedData, quint64 sentData)
|
|
||||||
{
|
|
||||||
setLabelSpeedReceivedText(VpnConnection::bytesPerSecToText(receivedData));
|
|
||||||
setLabelSpeedSentText(VpnConnection::bytesPerSecToText(sentData));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state)
|
|
||||||
{
|
|
||||||
qDebug() << "UiLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state);
|
|
||||||
|
|
||||||
bool pushButtonConnectEnabled = false;
|
|
||||||
bool radioButtonsModeEnabled = false;
|
|
||||||
setLabelStateText(VpnProtocol::textConnectionState(state));
|
|
||||||
|
|
||||||
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 UiLogic::onVpnProtocolError(ErrorCode errorCode)
|
|
||||||
{
|
|
||||||
setLabelErrorText(errorString(errorCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonConnectClicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked) {
|
|
||||||
onConnect();
|
|
||||||
} else {
|
|
||||||
onDisconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::setupTray()
|
void UiLogic::setupTray()
|
||||||
{
|
{
|
||||||
setTrayState(VpnProtocol::Disconnected);
|
setTrayState(VpnProtocol::Disconnected);
|
||||||
|
@ -933,120 +677,5 @@ void UiLogic::setTrayState(VpnProtocol::ConnectionState state)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiLogic::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 UiLogic::onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig)
|
|
||||||
{
|
|
||||||
setLabelErrorText("");
|
|
||||||
setPushButtonConnectChecked(true);
|
|
||||||
qApp->processEvents();
|
|
||||||
|
|
||||||
ErrorCode errorCode = m_vpnConnection->connectToVpn(
|
|
||||||
serverIndex, credentials, container, containerConfig
|
|
||||||
);
|
|
||||||
|
|
||||||
if (errorCode) {
|
|
||||||
//ui->pushButton_connect->setChecked(false);
|
|
||||||
setDialogConnectErrorText(errorString(errorCode));
|
|
||||||
emit showConnectErrorDialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPushButtonConnectEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onDisconnect()
|
|
||||||
{
|
|
||||||
setPushButtonConnectChecked(false);
|
|
||||||
m_vpnConnection->disconnectFromVpn();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonProtoOpenvpnContOpenvpnConfigClicked()
|
|
||||||
{
|
|
||||||
selectedDockerContainer = DockerContainer::OpenVpn;
|
|
||||||
m_openVpnLogic->updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn),
|
|
||||||
selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex));
|
|
||||||
goToPage(Page::OpenVpnSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked()
|
|
||||||
{
|
|
||||||
selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks;
|
|
||||||
m_openVpnLogic->updateOpenVpnPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::OpenVpn),
|
|
||||||
selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex));
|
|
||||||
goToPage(Page::OpenVpnSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onPushButtonProtoSsOpenvpnContSsConfigClicked()
|
|
||||||
{
|
|
||||||
selectedDockerContainer = DockerContainer::OpenVpnOverShadowSocks;
|
|
||||||
shadowSocksLogic()->updateShadowSocksPage(m_settings.protocolConfig(selectedServerIndex, selectedDockerContainer, Protocol::ShadowSocks),
|
|
||||||
selectedDockerContainer, m_settings.haveAuthData(selectedServerIndex));
|
|
||||||
goToPage(Page::ShadowSocksSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UiLogic::updateVpnPage()
|
|
||||||
{
|
|
||||||
Settings::RouteMode mode = m_settings.routeMode();
|
|
||||||
setRadioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites);
|
|
||||||
setRadioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites);
|
|
||||||
setRadioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites);
|
|
||||||
setPushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UiLogic::onRadioButtonVpnModeAllSitesToggled(bool checked)
|
|
||||||
{
|
|
||||||
if (checked) {
|
|
||||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onRadioButtonVpnModeForwardSitesToggled(bool checked)
|
|
||||||
{
|
|
||||||
if (checked) {
|
|
||||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UiLogic::onRadioButtonVpnModeExceptSitesToggled(bool checked)
|
|
||||||
{
|
|
||||||
if (checked) {
|
|
||||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ class GeneralSettingsLogic;
|
||||||
class NetworkSettingsLogic;
|
class NetworkSettingsLogic;
|
||||||
class NewServerProtocolsLogic;
|
class NewServerProtocolsLogic;
|
||||||
class NewServerConfiguringLogic;
|
class NewServerConfiguringLogic;
|
||||||
class ProtocolSettingsLogic;
|
|
||||||
class ServerListLogic;
|
class ServerListLogic;
|
||||||
class ServerSettingsLogic;
|
class ServerSettingsLogic;
|
||||||
class ServerContainersLogic;
|
class ServerContainersLogic;
|
||||||
|
@ -41,24 +40,8 @@ class UiLogic : public QObject
|
||||||
Q_PROPERTY(bool trayActionDisconnectEnabled READ getTrayActionDisconnectEnabled WRITE setTrayActionDisconnectEnabled NOTIFY trayActionDisconnectEnabledChanged)
|
Q_PROPERTY(bool trayActionDisconnectEnabled READ getTrayActionDisconnectEnabled WRITE setTrayActionDisconnectEnabled NOTIFY trayActionDisconnectEnabledChanged)
|
||||||
Q_PROPERTY(bool trayActionConnectEnabled READ getTrayActionConnectEnabled WRITE setTrayActionConnectEnabled NOTIFY trayActionConnectEnabledChanged)
|
Q_PROPERTY(bool trayActionConnectEnabled READ getTrayActionConnectEnabled WRITE setTrayActionConnectEnabled NOTIFY trayActionConnectEnabledChanged)
|
||||||
|
|
||||||
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(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged)
|
Q_PROPERTY(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged)
|
||||||
|
|
||||||
|
|
||||||
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:
|
public:
|
||||||
explicit UiLogic(QObject *parent = nullptr);
|
explicit UiLogic(QObject *parent = nullptr);
|
||||||
~UiLogic();
|
~UiLogic();
|
||||||
|
@ -69,7 +52,6 @@ public:
|
||||||
friend class NetworkSettingsLogic;
|
friend class NetworkSettingsLogic;
|
||||||
friend class NewServerConfiguringLogic;
|
friend class NewServerConfiguringLogic;
|
||||||
friend class NewServerProtocolsLogic;
|
friend class NewServerProtocolsLogic;
|
||||||
friend class ProtocolSettingsLogic;
|
|
||||||
friend class ServerListLogic;
|
friend class ServerListLogic;
|
||||||
friend class ServerSettingsLogic;
|
friend class ServerSettingsLogic;
|
||||||
friend class ServerContainersLogic;
|
friend class ServerContainersLogic;
|
||||||
|
@ -84,6 +66,7 @@ public:
|
||||||
friend class CloakLogic;
|
friend class CloakLogic;
|
||||||
|
|
||||||
Q_INVOKABLE void initalizeUiLogic();
|
Q_INVOKABLE void initalizeUiLogic();
|
||||||
|
Q_INVOKABLE void onCloseWindow();
|
||||||
|
|
||||||
|
|
||||||
int getCurrentPageValue() const;
|
int getCurrentPageValue() const;
|
||||||
|
@ -95,95 +78,14 @@ public:
|
||||||
bool getTrayActionConnectEnabled() const;
|
bool getTrayActionConnectEnabled() const;
|
||||||
void setTrayActionConnectEnabled(bool trayActionConnectEnabled);
|
void setTrayActionConnectEnabled(bool trayActionConnectEnabled);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
QString getDialogConnectErrorText() const;
|
QString getDialogConnectErrorText() const;
|
||||||
void setDialogConnectErrorText(const QString &dialogConnectErrorText);
|
void setDialogConnectErrorText(const QString &dialogConnectErrorText);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Q_INVOKABLE void onPushButtonProtoOpenvpnContOpenvpnConfigClicked();
|
|
||||||
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContOpenvpnConfigClicked();
|
|
||||||
Q_INVOKABLE void onPushButtonProtoSsOpenvpnContSsConfigClicked();
|
|
||||||
|
|
||||||
Q_INVOKABLE void onCloseWindow();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void radioButtonVpnModeAllSitesCheckedChanged();
|
|
||||||
void radioButtonVpnModeForwardSitesCheckedChanged();
|
|
||||||
void radioButtonVpnModeExceptSitesCheckedChanged();
|
|
||||||
void pushButtonVpnAddSiteEnabledChanged();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void currentPageValueChanged();
|
void currentPageValueChanged();
|
||||||
void trayIconUrlChanged();
|
void trayIconUrlChanged();
|
||||||
void trayActionDisconnectEnabledChanged();
|
void trayActionDisconnectEnabledChanged();
|
||||||
void trayActionConnectEnabledChanged();
|
void trayActionConnectEnabledChanged();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void pushButtonConnectCheckedChanged();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void labelSpeedReceivedTextChanged();
|
|
||||||
void labelSpeedSentTextChanged();
|
|
||||||
void labelStateTextChanged();
|
|
||||||
void pushButtonConnectEnabledChanged();
|
|
||||||
void widgetVpnModeEnabledChanged();
|
|
||||||
void labelErrorTextChanged();
|
|
||||||
|
|
||||||
void dialogConnectErrorTextChanged();
|
void dialogConnectErrorTextChanged();
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,50 +98,16 @@ signals:
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_radioButtonVpnModeAllSitesChecked;
|
|
||||||
bool m_radioButtonVpnModeForwardSitesChecked;
|
|
||||||
bool m_radioButtonVpnModeExceptSitesChecked;
|
|
||||||
bool m_pushButtonVpnAddSiteEnabled;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int m_currentPageValue;
|
int m_currentPageValue;
|
||||||
QString m_trayIconUrl;
|
QString m_trayIconUrl;
|
||||||
bool m_trayActionDisconnectEnabled;
|
bool m_trayActionDisconnectEnabled;
|
||||||
bool m_trayActionConnectEnabled;
|
bool m_trayActionConnectEnabled;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool m_pushButtonConnectChecked;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString m_labelSpeedReceivedText;
|
|
||||||
QString m_labelSpeedSentText;
|
|
||||||
QString m_labelStateText;
|
|
||||||
bool m_pushButtonConnectEnabled;
|
|
||||||
bool m_widgetVpnModeEnabled;
|
|
||||||
QString m_labelErrorText;
|
|
||||||
QString m_dialogConnectErrorText;
|
QString m_dialogConnectErrorText;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
|
||||||
void onConnectionStateChanged(VpnProtocol::ConnectionState state);
|
|
||||||
void onVpnProtocolError(amnezia::ErrorCode errorCode);
|
|
||||||
|
|
||||||
void installServer(const QMap<DockerContainer, QJsonObject> &containers);
|
void installServer(const QMap<DockerContainer, QJsonObject> &containers);
|
||||||
void setTrayState(VpnProtocol::ConnectionState state);
|
void setTrayState(VpnProtocol::ConnectionState state);
|
||||||
void onConnect();
|
|
||||||
void onConnectWorker(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
|
|
||||||
void onDisconnect();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PageEnumNS::Page currentPage();
|
PageEnumNS::Page currentPage();
|
||||||
|
@ -285,7 +153,6 @@ public:
|
||||||
NetworkSettingsLogic *networkSettingsLogic() { return m_networkSettingsLogic; }
|
NetworkSettingsLogic *networkSettingsLogic() { return m_networkSettingsLogic; }
|
||||||
NewServerConfiguringLogic *newServerConfiguringLogic() { return m_newServerConfiguringLogic; }
|
NewServerConfiguringLogic *newServerConfiguringLogic() { return m_newServerConfiguringLogic; }
|
||||||
NewServerProtocolsLogic *newServerProtocolsLogic() { return m_newServerProtocolsLogic; }
|
NewServerProtocolsLogic *newServerProtocolsLogic() { return m_newServerProtocolsLogic; }
|
||||||
ProtocolSettingsLogic *protocolSettingsLogic() { return m_protocolSettingsLogic; }
|
|
||||||
ServerListLogic *serverListLogic() { return m_serverListLogic; }
|
ServerListLogic *serverListLogic() { return m_serverListLogic; }
|
||||||
ServerSettingsLogic *serverSettingsLogic() { return m_serverSettingsLogic; }
|
ServerSettingsLogic *serverSettingsLogic() { return m_serverSettingsLogic; }
|
||||||
ServerContainersLogic *serverVpnProtocolsLogic() { return m_serverVpnProtocolsLogic; }
|
ServerContainersLogic *serverVpnProtocolsLogic() { return m_serverVpnProtocolsLogic; }
|
||||||
|
@ -305,7 +172,6 @@ private:
|
||||||
NetworkSettingsLogic *m_networkSettingsLogic;
|
NetworkSettingsLogic *m_networkSettingsLogic;
|
||||||
NewServerConfiguringLogic *m_newServerConfiguringLogic;
|
NewServerConfiguringLogic *m_newServerConfiguringLogic;
|
||||||
NewServerProtocolsLogic *m_newServerProtocolsLogic;
|
NewServerProtocolsLogic *m_newServerProtocolsLogic;
|
||||||
ProtocolSettingsLogic *m_protocolSettingsLogic;
|
|
||||||
ServerListLogic *m_serverListLogic;
|
ServerListLogic *m_serverListLogic;
|
||||||
ServerSettingsLogic *m_serverSettingsLogic;
|
ServerSettingsLogic *m_serverSettingsLogic;
|
||||||
ServerContainersLogic *m_serverVpnProtocolsLogic;
|
ServerContainersLogic *m_serverVpnProtocolsLogic;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue