2021-09-03 20:17:13 +03:00
|
|
|
#include "WizardLogic.h"
|
2021-09-06 11:44:03 +03:00
|
|
|
#include "../uilogic.h"
|
2021-09-03 20:17:13 +03:00
|
|
|
|
2021-09-07 21:01:56 +03:00
|
|
|
WizardLogic::WizardLogic(UiLogic *logic, QObject *parent):
|
|
|
|
|
PageLogicBase(logic, parent),
|
2021-09-08 14:23:02 +03:00
|
|
|
m_radioButtonHighChecked{false},
|
|
|
|
|
m_radioButtonMediumChecked{true},
|
|
|
|
|
m_radioButtonLowChecked{false},
|
|
|
|
|
m_lineEditHighWebsiteMaskingText{},
|
|
|
|
|
m_checkBoxVpnModeChecked{false}
|
2021-09-03 20:17:13 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2021-09-06 11:44:03 +03:00
|
|
|
|
2021-09-22 14:49:08 +03:00
|
|
|
void WizardLogic::onUpdatePage()
|
2021-09-06 11:44:03 +03:00
|
|
|
{
|
2021-09-08 14:23:02 +03:00
|
|
|
set_lineEditHighWebsiteMaskingText(protocols::cloak::defaultRedirSite);
|
2021-11-06 13:47:52 +03:00
|
|
|
set_radioButtonMediumChecked(true);
|
2021-09-06 11:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMap<DockerContainer, QJsonObject> WizardLogic::getInstallConfigsFromWizardPage() const
|
|
|
|
|
{
|
|
|
|
|
QJsonObject cloakConfig {
|
2021-09-20 21:51:28 +03:00
|
|
|
{ config_key::container, ContainerProps::containerToString(DockerContainer::Cloak) },
|
2021-11-30 16:56:24 +04:00
|
|
|
{ ProtocolProps::protoToString(Proto::Cloak), QJsonObject {
|
2021-09-08 14:23:02 +03:00
|
|
|
{ config_key::site, lineEditHighWebsiteMaskingText() }}
|
2021-09-06 11:44:03 +03:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
QJsonObject ssConfig {
|
2021-09-20 21:51:28 +03:00
|
|
|
{ config_key::container, ContainerProps::containerToString(DockerContainer::ShadowSocks) }
|
2021-09-06 11:44:03 +03:00
|
|
|
};
|
|
|
|
|
QJsonObject openVpnConfig {
|
2021-09-20 21:51:28 +03:00
|
|
|
{ config_key::container, ContainerProps::containerToString(DockerContainer::OpenVpn) }
|
2021-09-06 11:44:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QMap<DockerContainer, QJsonObject> containers;
|
|
|
|
|
|
2021-09-08 14:23:02 +03:00
|
|
|
if (radioButtonHighChecked()) {
|
2021-09-20 21:51:28 +03:00
|
|
|
containers.insert(DockerContainer::Cloak, cloakConfig);
|
2021-09-06 11:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
2021-09-08 14:23:02 +03:00
|
|
|
if (radioButtonMediumChecked()) {
|
2021-09-20 21:51:28 +03:00
|
|
|
containers.insert(DockerContainer::ShadowSocks, ssConfig);
|
2021-09-06 11:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
2021-09-08 14:23:02 +03:00
|
|
|
if (radioButtonLowChecked()) {
|
2021-09-06 11:44:03 +03:00
|
|
|
containers.insert(DockerContainer::OpenVpn, openVpnConfig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return containers;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 14:23:02 +03:00
|
|
|
void WizardLogic::onPushButtonVpnModeFinishClicked()
|
2021-09-06 11:44:03 +03:00
|
|
|
{
|
2021-09-24 13:14:35 +03:00
|
|
|
auto containers = getInstallConfigsFromWizardPage();
|
|
|
|
|
uiLogic()->installServer(containers);
|
2021-09-08 14:23:02 +03:00
|
|
|
if (checkBoxVpnModeChecked()) {
|
2021-09-06 11:44:03 +03:00
|
|
|
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
|
|
|
|
} else {
|
|
|
|
|
m_settings.setRouteMode(Settings::VpnAllSites);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 14:23:02 +03:00
|
|
|
void WizardLogic::onPushButtonLowFinishClicked()
|
2021-09-06 11:44:03 +03:00
|
|
|
{
|
2021-09-24 13:14:35 +03:00
|
|
|
auto containers = getInstallConfigsFromWizardPage();
|
|
|
|
|
uiLogic()->installServer(containers);
|
2021-09-06 11:44:03 +03:00
|
|
|
}
|