start page refact
This commit is contained in:
parent
ca3617aa7d
commit
6dc13b2c00
8 changed files with 538 additions and 432 deletions
|
@ -44,6 +44,7 @@ HEADERS += \
|
|||
ui/pages_logic/ServerVpnProtocolsLogic.h \
|
||||
ui/pages_logic/ShareConnectionLogic.h \
|
||||
ui/pages_logic/SitesLogic.h \
|
||||
ui/pages_logic/StartPageLogic.h \
|
||||
ui/pages_logic/VpnLogic.h \
|
||||
ui/pages_logic/WizardLogic.h \
|
||||
ui/serversmodel.h \
|
||||
|
@ -85,6 +86,7 @@ SOURCES += \
|
|||
ui/pages_logic/ServerVpnProtocolsLogic.cpp \
|
||||
ui/pages_logic/ShareConnectionLogic.cpp \
|
||||
ui/pages_logic/SitesLogic.cpp \
|
||||
ui/pages_logic/StartPageLogic.cpp \
|
||||
ui/pages_logic/VpnLogic.cpp \
|
||||
ui/pages_logic/WizardLogic.cpp \
|
||||
ui/serversmodel.cpp \
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "ui/pages_logic/ServerVpnProtocolsLogic.h"
|
||||
#include "ui/pages_logic/ShareConnectionLogic.h"
|
||||
#include "ui/pages_logic/SitesLogic.h"
|
||||
#include "ui/pages_logic/StartPageLogic.h"
|
||||
#include "ui/pages_logic/VpnLogic.h"
|
||||
#include "ui/pages_logic/WizardLogic.h"
|
||||
|
||||
|
@ -121,6 +122,7 @@ int main(int argc, char *argv[])
|
|||
ServerVpnProtocolsLogic *serverVpnProtocolsLogic = new ServerVpnProtocolsLogic(uiLogic);
|
||||
ShareConnectionLogic *shareConnectionLogic = new ShareConnectionLogic(uiLogic);
|
||||
SitesLogic *sitesLogic = new SitesLogic(uiLogic);
|
||||
StartPageLogic *startPageLogic = new StartPageLogic(uiLogic);
|
||||
VpnLogic *vpnLogic = new VpnLogic(uiLogic);
|
||||
WizardLogic *wizardLogic = new WizardLogic(uiLogic);
|
||||
|
||||
|
@ -145,10 +147,10 @@ int main(int argc, char *argv[])
|
|||
engine.rootContext()->setContextProperty("ServerVpnProtocolsLogic", serverVpnProtocolsLogic);
|
||||
engine.rootContext()->setContextProperty("ShareConnectionLogic", shareConnectionLogic);
|
||||
engine.rootContext()->setContextProperty("SitesLogic", sitesLogic);
|
||||
engine.rootContext()->setContextProperty("StartPageLogic", startPageLogic);
|
||||
engine.rootContext()->setContextProperty("VpnLogic", vpnLogic);
|
||||
engine.rootContext()->setContextProperty("WizardLogic", wizardLogic);
|
||||
|
||||
|
||||
engine.load(url);
|
||||
|
||||
// TODO - fix
|
||||
|
|
388
client/ui/pages_logic/StartPageLogic.cpp
Normal file
388
client/ui/pages_logic/StartPageLogic.cpp
Normal file
|
@ -0,0 +1,388 @@
|
|||
//#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 "debug.h"
|
||||
//#include "defines.h"
|
||||
#include "StartPageLogic.h"
|
||||
#include "core/errorstrings.h"
|
||||
//#include "utils.h"
|
||||
//#include "vpnconnection.h"
|
||||
//#include <functional>
|
||||
|
||||
#include "configurators/ssh_configurator.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
#include "../uilogic.h"
|
||||
|
||||
|
||||
StartPageLogic::StartPageLogic(UiLogic *uiLogic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_uiLogic(uiLogic),
|
||||
m_pushButtonNewServerConnectEnabled{},
|
||||
m_pushButtonNewServerConnectText{tr("Connect")},
|
||||
m_pushButtonNewServerConnectKeyChecked{false},
|
||||
m_lineEditStartExistingCodeText{},
|
||||
m_textEditNewServerSshKeyText{},
|
||||
m_lineEditNewServerIpText{},
|
||||
m_lineEditNewServerPasswordText{},
|
||||
m_lineEditNewServerLoginText{},
|
||||
m_labelNewServerWaitInfoVisible{true},
|
||||
m_labelNewServerWaitInfoText{},
|
||||
m_progressBarNewServerConnectionMinimum{0},
|
||||
m_progressBarNewServerConnectionMaximum{100},
|
||||
m_pushButtonBackFromStartVisible{true},
|
||||
m_pushButtonNewServerConnectVisible{true}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StartPageLogic::updateStartPage()
|
||||
{
|
||||
setLineEditStartExistingCodeText("");
|
||||
setTextEditNewServerSshKeyText("");
|
||||
setLineEditNewServerIpText("");
|
||||
setLineEditNewServerPasswordText("");
|
||||
setTextEditNewServerSshKeyText("");
|
||||
setLineEditNewServerLoginText("");
|
||||
|
||||
setLabelNewServerWaitInfoVisible(false);
|
||||
setLabelNewServerWaitInfoText("");
|
||||
setProgressBarNewServerConnectionMinimum(0);
|
||||
setProgressBarNewServerConnectionMaximum(300);
|
||||
setPushButtonNewServerConnectVisible(true);
|
||||
}
|
||||
|
||||
bool StartPageLogic::getPushButtonNewServerConnectKeyChecked() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectKeyChecked;
|
||||
}
|
||||
|
||||
void StartPageLogic::setPushButtonNewServerConnectKeyChecked(bool pushButtonNewServerConnectKeyChecked)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectKeyChecked != pushButtonNewServerConnectKeyChecked) {
|
||||
m_pushButtonNewServerConnectKeyChecked = pushButtonNewServerConnectKeyChecked;
|
||||
emit pushButtonNewServerConnectKeyCheckedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getLineEditStartExistingCodeText() const
|
||||
{
|
||||
return m_lineEditStartExistingCodeText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setLineEditStartExistingCodeText(const QString &lineEditStartExistingCodeText)
|
||||
{
|
||||
if (m_lineEditStartExistingCodeText != lineEditStartExistingCodeText) {
|
||||
m_lineEditStartExistingCodeText = lineEditStartExistingCodeText;
|
||||
emit lineEditStartExistingCodeTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getTextEditNewServerSshKeyText() const
|
||||
{
|
||||
return m_textEditNewServerSshKeyText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setTextEditNewServerSshKeyText(const QString &textEditNewServerSshKeyText)
|
||||
{
|
||||
if (m_textEditNewServerSshKeyText != textEditNewServerSshKeyText) {
|
||||
m_textEditNewServerSshKeyText = textEditNewServerSshKeyText;
|
||||
emit textEditNewServerSshKeyTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getLineEditNewServerIpText() const
|
||||
{
|
||||
return m_lineEditNewServerIpText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setLineEditNewServerIpText(const QString &lineEditNewServerIpText)
|
||||
{
|
||||
if (m_lineEditNewServerIpText != lineEditNewServerIpText) {
|
||||
m_lineEditNewServerIpText = lineEditNewServerIpText;
|
||||
emit lineEditNewServerIpTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getLineEditNewServerPasswordText() const
|
||||
{
|
||||
return m_lineEditNewServerPasswordText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setLineEditNewServerPasswordText(const QString &lineEditNewServerPasswordText)
|
||||
{
|
||||
if (m_lineEditNewServerPasswordText != lineEditNewServerPasswordText) {
|
||||
m_lineEditNewServerPasswordText = lineEditNewServerPasswordText;
|
||||
emit lineEditNewServerPasswordTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getLineEditNewServerLoginText() const
|
||||
{
|
||||
return m_lineEditNewServerLoginText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setLineEditNewServerLoginText(const QString &lineEditNewServerLoginText)
|
||||
{
|
||||
if (m_lineEditNewServerLoginText != lineEditNewServerLoginText) {
|
||||
m_lineEditNewServerLoginText = lineEditNewServerLoginText;
|
||||
emit lineEditNewServerLoginTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool StartPageLogic::getLabelNewServerWaitInfoVisible() const
|
||||
{
|
||||
return m_labelNewServerWaitInfoVisible;
|
||||
}
|
||||
|
||||
void StartPageLogic::setLabelNewServerWaitInfoVisible(bool labelNewServerWaitInfoVisible)
|
||||
{
|
||||
if (m_labelNewServerWaitInfoVisible != labelNewServerWaitInfoVisible) {
|
||||
m_labelNewServerWaitInfoVisible = labelNewServerWaitInfoVisible;
|
||||
emit labelNewServerWaitInfoVisibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getLabelNewServerWaitInfoText() const
|
||||
{
|
||||
return m_labelNewServerWaitInfoText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setLabelNewServerWaitInfoText(const QString &labelNewServerWaitInfoText)
|
||||
{
|
||||
if (m_labelNewServerWaitInfoText != labelNewServerWaitInfoText) {
|
||||
m_labelNewServerWaitInfoText = labelNewServerWaitInfoText;
|
||||
emit labelNewServerWaitInfoTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
double StartPageLogic::getProgressBarNewServerConnectionMinimum() const
|
||||
{
|
||||
return m_progressBarNewServerConnectionMinimum;
|
||||
}
|
||||
|
||||
void StartPageLogic::setProgressBarNewServerConnectionMinimum(double progressBarNewServerConnectionMinimum)
|
||||
{
|
||||
if (m_progressBarNewServerConnectionMinimum != progressBarNewServerConnectionMinimum) {
|
||||
m_progressBarNewServerConnectionMinimum = progressBarNewServerConnectionMinimum;
|
||||
emit progressBarNewServerConnectionMinimumChanged();
|
||||
}
|
||||
}
|
||||
|
||||
double StartPageLogic::getProgressBarNewServerConnectionMaximum() const
|
||||
{
|
||||
return m_progressBarNewServerConnectionMaximum;
|
||||
}
|
||||
|
||||
void StartPageLogic::setProgressBarNewServerConnectionMaximum(double progressBarNewServerConnectionMaximum)
|
||||
{
|
||||
if (m_progressBarNewServerConnectionMaximum != progressBarNewServerConnectionMaximum) {
|
||||
m_progressBarNewServerConnectionMaximum = progressBarNewServerConnectionMaximum;
|
||||
emit progressBarNewServerConnectionMaximumChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool StartPageLogic::getPushButtonNewServerConnectVisible() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectVisible;
|
||||
}
|
||||
|
||||
void StartPageLogic::setPushButtonNewServerConnectVisible(bool pushButtonNewServerConnectVisible)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectVisible != pushButtonNewServerConnectVisible) {
|
||||
m_pushButtonNewServerConnectVisible = pushButtonNewServerConnectVisible;
|
||||
emit pushButtonNewServerConnectVisibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool StartPageLogic::getPushButtonBackFromStartVisible() const
|
||||
{
|
||||
return m_pushButtonBackFromStartVisible;
|
||||
}
|
||||
|
||||
void StartPageLogic::setPushButtonBackFromStartVisible(bool pushButtonBackFromStartVisible)
|
||||
{
|
||||
if (m_pushButtonBackFromStartVisible != pushButtonBackFromStartVisible) {
|
||||
m_pushButtonBackFromStartVisible = pushButtonBackFromStartVisible;
|
||||
emit pushButtonBackFromStartVisibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void StartPageLogic::onPushButtonNewServerConnect()
|
||||
{
|
||||
if (getPushButtonNewServerConnectKeyChecked()){
|
||||
if (getLineEditNewServerIpText().isEmpty() ||
|
||||
getLineEditNewServerLoginText().isEmpty() ||
|
||||
getTextEditNewServerSshKeyText().isEmpty() ) {
|
||||
setLabelNewServerWaitInfoText(tr("Please fill in all fields"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (getLineEditNewServerIpText().isEmpty() ||
|
||||
getLineEditNewServerLoginText().isEmpty() ||
|
||||
getLineEditNewServerPasswordText().isEmpty() ) {
|
||||
setLabelNewServerWaitInfoText(tr("Please fill in all fields"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
qDebug() << "UiLogic::onPushButtonNewServerConnect checking new server";
|
||||
|
||||
ServerCredentials serverCredentials;
|
||||
serverCredentials.hostName = getLineEditNewServerIpText();
|
||||
if (serverCredentials.hostName.contains(":")) {
|
||||
serverCredentials.port = serverCredentials.hostName.split(":").at(1).toInt();
|
||||
serverCredentials.hostName = serverCredentials.hostName.split(":").at(0);
|
||||
}
|
||||
serverCredentials.userName = getLineEditNewServerLoginText();
|
||||
if (getPushButtonNewServerConnectKeyChecked()){
|
||||
QString key = getTextEditNewServerSshKeyText();
|
||||
if (key.startsWith("ssh-rsa")) {
|
||||
emit m_uiLogic->showPublicKeyWarning();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) {
|
||||
key = SshConfigurator::convertOpenSShKey(key);
|
||||
}
|
||||
|
||||
serverCredentials.password = key;
|
||||
}
|
||||
else {
|
||||
serverCredentials.password = getLineEditNewServerPasswordText();
|
||||
}
|
||||
|
||||
setPushButtonNewServerConnectEnabled(false);
|
||||
setPushButtonNewServerConnectText(tr("Connecting..."));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
#ifdef Q_DEBUG
|
||||
//QString output = ServerController::checkSshConnection(serverCredentials, &e);
|
||||
#else
|
||||
QString output;
|
||||
#endif
|
||||
|
||||
bool ok = true;
|
||||
if (e) {
|
||||
setLabelNewServerWaitInfoVisible(true);
|
||||
setLabelNewServerWaitInfoText(errorString(e));
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
if (output.contains("Please login as the user")) {
|
||||
output.replace("\n", "");
|
||||
setLabelNewServerWaitInfoVisible(true);
|
||||
setLabelNewServerWaitInfoText(output);
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
setPushButtonNewServerConnectEnabled(true);
|
||||
setPushButtonNewServerConnectText(tr("Connect"));
|
||||
|
||||
m_uiLogic->installCredentials = serverCredentials;
|
||||
if (ok) m_uiLogic->goToPage(Page::NewServer);
|
||||
}
|
||||
|
||||
void StartPageLogic::onPushButtonNewServerImport()
|
||||
{
|
||||
QString s = getLineEditStartExistingCodeText();
|
||||
s.replace("vpn://", "");
|
||||
QJsonObject o = QJsonDocument::fromJson(QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)).object();
|
||||
|
||||
ServerCredentials credentials;
|
||||
credentials.hostName = o.value("h").toString();
|
||||
if (credentials.hostName.isEmpty()) credentials.hostName = o.value(config_key::hostName).toString();
|
||||
|
||||
credentials.port = o.value("p").toInt();
|
||||
if (credentials.port == 0) credentials.port = o.value(config_key::port).toInt();
|
||||
|
||||
credentials.userName = o.value("u").toString();
|
||||
if (credentials.userName.isEmpty()) credentials.userName = o.value(config_key::userName).toString();
|
||||
|
||||
credentials.password = o.value("w").toString();
|
||||
if (credentials.password.isEmpty()) credentials.password = o.value(config_key::password).toString();
|
||||
|
||||
if (credentials.isValid()) {
|
||||
o.insert(config_key::hostName, credentials.hostName);
|
||||
o.insert(config_key::port, credentials.port);
|
||||
o.insert(config_key::userName, credentials.userName);
|
||||
o.insert(config_key::password, credentials.password);
|
||||
|
||||
o.remove("h");
|
||||
o.remove("p");
|
||||
o.remove("u");
|
||||
o.remove("w");
|
||||
}
|
||||
qDebug() << QString("Added server %3@%1:%2").
|
||||
arg(credentials.hostName).
|
||||
arg(credentials.port).
|
||||
arg(credentials.userName);
|
||||
|
||||
//qDebug() << QString("Password") << credentials.password;
|
||||
|
||||
if (credentials.isValid() || o.contains(config_key::containers)) {
|
||||
m_settings.addServer(o);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
|
||||
m_uiLogic->setStartPage(Page::Vpn);
|
||||
}
|
||||
else {
|
||||
qDebug() << "Failed to import profile";
|
||||
qDebug().noquote() << QJsonDocument(o).toJson();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!o.contains(config_key::containers)) {
|
||||
m_uiLogic->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
m_uiLogic->selectedDockerContainer = m_settings.defaultContainer(m_uiLogic->selectedServerIndex);
|
||||
m_uiLogic->goToPage(Page::ServerVpnProtocols);
|
||||
}
|
||||
}
|
||||
|
||||
bool StartPageLogic::getPushButtonNewServerConnectEnabled() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectEnabled;
|
||||
}
|
||||
|
||||
void StartPageLogic::setPushButtonNewServerConnectEnabled(bool pushButtonNewServerConnectEnabled)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectEnabled != pushButtonNewServerConnectEnabled) {
|
||||
m_pushButtonNewServerConnectEnabled = pushButtonNewServerConnectEnabled;
|
||||
emit pushButtonNewServerConnectEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString StartPageLogic::getPushButtonNewServerConnectText() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectText;
|
||||
}
|
||||
|
||||
void StartPageLogic::setPushButtonNewServerConnectText(const QString &pushButtonNewServerConnectText)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectText != pushButtonNewServerConnectText) {
|
||||
m_pushButtonNewServerConnectText = pushButtonNewServerConnectText;
|
||||
emit pushButtonNewServerConnectTextChanged();
|
||||
}
|
||||
}
|
111
client/ui/pages_logic/StartPageLogic.h
Normal file
111
client/ui/pages_logic/StartPageLogic.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
#ifndef START_PAGE_LOGIC_H
|
||||
#define START_PAGE_LOGIC_H
|
||||
|
||||
#include "../pages.h"
|
||||
#include "settings.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class StartPageLogic : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void updateStartPage();
|
||||
|
||||
Q_PROPERTY(bool pushButtonNewServerConnectEnabled READ getPushButtonNewServerConnectEnabled WRITE setPushButtonNewServerConnectEnabled NOTIFY pushButtonNewServerConnectEnabledChanged)
|
||||
Q_PROPERTY(bool pushButtonNewServerConnectKeyChecked READ getPushButtonNewServerConnectKeyChecked WRITE setPushButtonNewServerConnectKeyChecked NOTIFY pushButtonNewServerConnectKeyCheckedChanged)
|
||||
Q_PROPERTY(QString pushButtonNewServerConnectText READ getPushButtonNewServerConnectText WRITE setPushButtonNewServerConnectText NOTIFY pushButtonNewServerConnectTextChanged)
|
||||
Q_PROPERTY(QString lineEditStartExistingCodeText READ getLineEditStartExistingCodeText WRITE setLineEditStartExistingCodeText NOTIFY lineEditStartExistingCodeTextChanged)
|
||||
Q_PROPERTY(QString textEditNewServerSshKeyText READ getTextEditNewServerSshKeyText WRITE setTextEditNewServerSshKeyText NOTIFY textEditNewServerSshKeyTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerIpText READ getLineEditNewServerIpText WRITE setLineEditNewServerIpText NOTIFY lineEditNewServerIpTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerPasswordText READ getLineEditNewServerPasswordText WRITE setLineEditNewServerPasswordText NOTIFY lineEditNewServerPasswordTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerLoginText READ getLineEditNewServerLoginText WRITE setLineEditNewServerLoginText NOTIFY lineEditNewServerLoginTextChanged)
|
||||
Q_PROPERTY(bool labelNewServerWaitInfoVisible READ getLabelNewServerWaitInfoVisible WRITE setLabelNewServerWaitInfoVisible NOTIFY labelNewServerWaitInfoVisibleChanged)
|
||||
Q_PROPERTY(QString labelNewServerWaitInfoText READ getLabelNewServerWaitInfoText WRITE setLabelNewServerWaitInfoText NOTIFY labelNewServerWaitInfoTextChanged)
|
||||
Q_PROPERTY(double progressBarNewServerConnectionMinimum READ getProgressBarNewServerConnectionMinimum WRITE setProgressBarNewServerConnectionMinimum NOTIFY progressBarNewServerConnectionMinimumChanged)
|
||||
Q_PROPERTY(double progressBarNewServerConnectionMaximum READ getProgressBarNewServerConnectionMaximum WRITE setProgressBarNewServerConnectionMaximum NOTIFY progressBarNewServerConnectionMaximumChanged)
|
||||
Q_PROPERTY(bool pushButtonBackFromStartVisible READ getPushButtonBackFromStartVisible WRITE setPushButtonBackFromStartVisible NOTIFY pushButtonBackFromStartVisibleChanged)
|
||||
Q_PROPERTY(bool pushButtonNewServerConnectVisible READ getPushButtonNewServerConnectVisible WRITE setPushButtonNewServerConnectVisible NOTIFY pushButtonNewServerConnectVisibleChanged)
|
||||
|
||||
Q_INVOKABLE void onPushButtonNewServerConnect();
|
||||
Q_INVOKABLE void onPushButtonNewServerImport();
|
||||
|
||||
public:
|
||||
explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~StartPageLogic() = default;
|
||||
|
||||
bool getPushButtonBackFromStartVisible() const;
|
||||
void setPushButtonBackFromStartVisible(bool pushButtonBackFromStartVisible);
|
||||
bool getPushButtonNewServerConnectEnabled() const;
|
||||
void setPushButtonNewServerConnectEnabled(bool pushButtonNewServerConnectEnabled);
|
||||
|
||||
bool getPushButtonNewServerConnectVisible() const;
|
||||
void setPushButtonNewServerConnectVisible(bool pushButtonNewServerConnectVisible);
|
||||
bool getPushButtonNewServerConnectKeyChecked() const;
|
||||
void setPushButtonNewServerConnectKeyChecked(bool pushButtonNewServerConnectKeyChecked);
|
||||
QString getLineEditStartExistingCodeText() const;
|
||||
void setLineEditStartExistingCodeText(const QString &lineEditStartExistingCodeText);
|
||||
QString getTextEditNewServerSshKeyText() const;
|
||||
void setTextEditNewServerSshKeyText(const QString &textEditNewServerSshKeyText);
|
||||
QString getLineEditNewServerIpText() const;
|
||||
void setLineEditNewServerIpText(const QString &lineEditNewServerIpText);
|
||||
QString getLineEditNewServerPasswordText() const;
|
||||
void setLineEditNewServerPasswordText(const QString &lineEditNewServerPasswordText);
|
||||
QString getLineEditNewServerLoginText() const;
|
||||
void setLineEditNewServerLoginText(const QString &lineEditNewServerLoginText);
|
||||
bool getLabelNewServerWaitInfoVisible() const;
|
||||
void setLabelNewServerWaitInfoVisible(bool labelNewServerWaitInfoVisible);
|
||||
QString getLabelNewServerWaitInfoText() const;
|
||||
void setLabelNewServerWaitInfoText(const QString &labelNewServerWaitInfoText);
|
||||
double getProgressBarNewServerConnectionMinimum() const;
|
||||
void setProgressBarNewServerConnectionMinimum(double progressBarNewServerConnectionMinimum);
|
||||
double getProgressBarNewServerConnectionMaximum() const;
|
||||
void setProgressBarNewServerConnectionMaximum(double progressBarNewServerConnectionMaximum);
|
||||
|
||||
QString getPushButtonNewServerConnectText() const;
|
||||
void setPushButtonNewServerConnectText(const QString &pushButtonNewServerConnectText);
|
||||
|
||||
signals:
|
||||
void pushButtonNewServerConnectKeyCheckedChanged();
|
||||
void lineEditStartExistingCodeTextChanged();
|
||||
void textEditNewServerSshKeyTextChanged();
|
||||
void lineEditNewServerIpTextChanged();
|
||||
void lineEditNewServerPasswordTextChanged();
|
||||
void lineEditNewServerLoginTextChanged();
|
||||
void labelNewServerWaitInfoVisibleChanged();
|
||||
void labelNewServerWaitInfoTextChanged();
|
||||
void progressBarNewServerConnectionMinimumChanged();
|
||||
void progressBarNewServerConnectionMaximumChanged();
|
||||
void pushButtonBackFromStartVisibleChanged();
|
||||
void pushButtonNewServerConnectVisibleChanged();
|
||||
void pushButtonNewServerConnectEnabledChanged();
|
||||
void pushButtonNewServerConnectTextChanged();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
bool m_pushButtonNewServerConnectEnabled;
|
||||
QString m_pushButtonNewServerConnectText;
|
||||
bool m_pushButtonNewServerConnectKeyChecked;
|
||||
QString m_lineEditStartExistingCodeText;
|
||||
QString m_textEditNewServerSshKeyText;
|
||||
QString m_lineEditNewServerIpText;
|
||||
QString m_lineEditNewServerPasswordText;
|
||||
QString m_lineEditNewServerLoginText;
|
||||
bool m_labelNewServerWaitInfoVisible;
|
||||
QString m_labelNewServerWaitInfoText;
|
||||
double m_progressBarNewServerConnectionMinimum;
|
||||
double m_progressBarNewServerConnectionMaximum;
|
||||
bool m_pushButtonBackFromStartVisible;
|
||||
bool m_pushButtonNewServerConnectVisible;
|
||||
};
|
||||
#endif // START_PAGE_LOGIC_H
|
|
@ -97,9 +97,9 @@ Item {
|
|||
width: 300
|
||||
height: 40
|
||||
placeholderText: "vpn://..."
|
||||
text: UiLogic.lineEditStartExistingCodeText
|
||||
text: StartPageLogic.lineEditStartExistingCodeText
|
||||
onEditingFinished: {
|
||||
UiLogic.lineEditStartExistingCodeText = text
|
||||
StartPageLogic.lineEditStartExistingCodeText = text
|
||||
}
|
||||
}
|
||||
BlueButtonType {
|
||||
|
@ -110,7 +110,7 @@ Item {
|
|||
height: 40
|
||||
text: qsTr("Connect")
|
||||
onClicked: {
|
||||
UiLogic.onPushButtonNewServerImport()
|
||||
StartPageLogic.onPushButtonNewServerImport()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ Item {
|
|||
y: 390
|
||||
width: 301
|
||||
height: 41
|
||||
text: UiLogic.labelNewServerWaitInfoText
|
||||
visible: UiLogic.labelNewServerWaitInfoVisible
|
||||
text: StartPageLogic.labelNewServerWaitInfoText
|
||||
visible: StartPageLogic.labelNewServerWaitInfoVisible
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
TextFieldType {
|
||||
|
@ -175,9 +175,9 @@ Item {
|
|||
y: 100
|
||||
width: 300
|
||||
height: 40
|
||||
text: UiLogic.lineEditNewServerIpText
|
||||
text: StartPageLogic.lineEditNewServerIpText
|
||||
onEditingFinished: {
|
||||
UiLogic.lineEditNewServerIpText = text
|
||||
StartPageLogic.lineEditNewServerIpText = text
|
||||
}
|
||||
}
|
||||
TextFieldType {
|
||||
|
@ -186,9 +186,9 @@ Item {
|
|||
y: 180
|
||||
width: 300
|
||||
height: 40
|
||||
text: UiLogic.lineEditNewServerLoginText
|
||||
text: StartPageLogic.lineEditNewServerLoginText
|
||||
onEditingFinished: {
|
||||
UiLogic.lineEditNewServerLoginText = text
|
||||
StartPageLogic.lineEditNewServerLoginText = text
|
||||
}
|
||||
}
|
||||
TextFieldType {
|
||||
|
@ -198,9 +198,9 @@ Item {
|
|||
width: 300
|
||||
height: 40
|
||||
echoMode: TextInput.Password
|
||||
text: UiLogic.lineEditNewServerPasswordText
|
||||
text: StartPageLogic.lineEditNewServerPasswordText
|
||||
onEditingFinished: {
|
||||
UiLogic.lineEditNewServerPasswordText = text
|
||||
StartPageLogic.lineEditNewServerPasswordText = text
|
||||
}
|
||||
}
|
||||
BlueButtonType {
|
||||
|
@ -209,12 +209,12 @@ Item {
|
|||
y: 350
|
||||
width: 301
|
||||
height: 40
|
||||
text: UiLogic.pushButtonNewServerConnectText
|
||||
visible: UiLogic.pushButtonNewServerConnectVisible
|
||||
text: StartPageLogic.pushButtonNewServerConnectText
|
||||
visible: StartPageLogic.pushButtonNewServerConnectVisible
|
||||
onClicked: {
|
||||
UiLogic.onPushButtonNewServerConnect()
|
||||
StartPageLogic.onPushButtonNewServerConnect()
|
||||
}
|
||||
enabled: UiLogic.pushButtonNewServerConnectEnabled
|
||||
enabled: StartPageLogic.pushButtonNewServerConnectEnabled
|
||||
}
|
||||
BasicButtonType {
|
||||
id: new_sever_connect_key
|
||||
|
@ -239,9 +239,9 @@ Item {
|
|||
}
|
||||
antialiasing: true
|
||||
checkable: true
|
||||
checked: UiLogic.pushButtonNewServerConnectKeyChecked
|
||||
checked: StartPageLogic.pushButtonNewServerConnectKeyChecked
|
||||
onCheckedChanged: {
|
||||
UiLogic.pushButtonNewServerConnectKeyChecked = checked
|
||||
StartPageLogic.pushButtonNewServerConnectKeyChecked = checked
|
||||
label_new_server_password.text = checked ? qsTr("Private key") : qsTr("Password")
|
||||
new_sever_connect_key.text = checked ? qsTr("Connect using SSH password") : qsTr("Connect using SSH key")
|
||||
new_server_password.visible = !checked
|
||||
|
@ -285,9 +285,9 @@ Item {
|
|||
echoMode: TextInput.Password
|
||||
font.pixelSize: 9
|
||||
verticalAlignment: Text.AlignTop
|
||||
text: UiLogic.textEditNewServerSshKeyText
|
||||
text: StartPageLogic.textEditNewServerSshKeyText
|
||||
onEditingFinished: {
|
||||
UiLogic.textEditNewServerSshKeyText = text
|
||||
StartPageLogic.textEditNewServerSshKeyText = text
|
||||
}
|
||||
visible: false
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ Item {
|
|||
width: 26
|
||||
height: 20
|
||||
icon.source: "qrc:/images/arrow_left.png"
|
||||
visible: UiLogic.pushButtonBackFromStartVisible
|
||||
visible: StartPageLogic.pushButtonBackFromStartVisible
|
||||
onClicked: {
|
||||
UiLogic.closePage()
|
||||
}
|
||||
|
|
|
@ -162,8 +162,8 @@ Window {
|
|||
ServerListLogic.updateServersListPage();
|
||||
}
|
||||
if (page === PageEnum.Start) {
|
||||
UiLogic.pushButtonBackFromStartVisible = !pageLoader.empty
|
||||
UiLogic.updateStartPage();
|
||||
StartPageLogic.pushButtonBackFromStartVisible = !pageLoader.empty
|
||||
StartPageLogic.updateStartPage();
|
||||
}
|
||||
if (page === PageEnum.NewServerProtocols) {
|
||||
UiLogic.updateNewServerProtocolsPage()
|
||||
|
|
|
@ -64,18 +64,6 @@ UiLogic::UiLogic(QObject *parent) :
|
|||
m_comboBoxNewServerSsCipherText{"chacha20-ietf-poly1305"},
|
||||
m_lineEditNewServerOpenvpnPortText{},
|
||||
m_comboBoxNewServerOpenvpnProtoText{"udp"},
|
||||
m_pushButtonNewServerConnectKeyChecked{false},
|
||||
m_lineEditStartExistingCodeText{},
|
||||
m_textEditNewServerSshKeyText{},
|
||||
m_lineEditNewServerIpText{},
|
||||
m_lineEditNewServerPasswordText{},
|
||||
m_lineEditNewServerLoginText{},
|
||||
m_labelNewServerWaitInfoVisible{true},
|
||||
m_labelNewServerWaitInfoText{},
|
||||
m_progressBarNewServerConnectionMinimum{0},
|
||||
m_progressBarNewServerConnectionMaximum{100},
|
||||
m_pushButtonBackFromStartVisible{true},
|
||||
m_pushButtonNewServerConnectVisible{true},
|
||||
m_radioButtonVpnModeAllSitesChecked{true},
|
||||
m_radioButtonVpnModeForwardSitesChecked{false},
|
||||
m_radioButtonVpnModeExceptSitesChecked{false},
|
||||
|
@ -153,8 +141,6 @@ UiLogic::UiLogic(QObject *parent) :
|
|||
m_pushButtonConnectEnabled{false},
|
||||
m_widgetVpnModeEnabled{false},
|
||||
m_labelErrorText{tr("Error text")},
|
||||
m_pushButtonNewServerConnectEnabled{},
|
||||
m_pushButtonNewServerConnectText{tr("Connect")},
|
||||
m_dialogConnectErrorText{},
|
||||
m_pageNewServerConfiguringEnabled{true},
|
||||
m_labelNewServerConfiguringWaitInfoVisible{true},
|
||||
|
@ -334,18 +320,7 @@ void UiLogic::updateNewServerProtocolsPage()
|
|||
setComboBoxNewServerOpenvpnProtoText(amnezia::protocols::openvpn::defaultTransportProto);
|
||||
}
|
||||
|
||||
bool UiLogic::getPushButtonNewServerConnectKeyChecked() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectKeyChecked;
|
||||
}
|
||||
|
||||
void UiLogic::setPushButtonNewServerConnectKeyChecked(bool pushButtonNewServerConnectKeyChecked)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectKeyChecked != pushButtonNewServerConnectKeyChecked) {
|
||||
m_pushButtonNewServerConnectKeyChecked = pushButtonNewServerConnectKeyChecked;
|
||||
emit pushButtonNewServerConnectKeyCheckedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getComboBoxNewServerOpenvpnProtoText() const
|
||||
{
|
||||
|
@ -489,148 +464,10 @@ void UiLogic::setLineEditSetupWizardHighWebsiteMaskingText(const QString &lineEd
|
|||
emit lineEditSetupWizardHighWebsiteMaskingTextChanged();
|
||||
}
|
||||
}
|
||||
QString UiLogic::getLineEditStartExistingCodeText() const
|
||||
{
|
||||
return m_lineEditStartExistingCodeText;
|
||||
}
|
||||
|
||||
void UiLogic::setLineEditStartExistingCodeText(const QString &lineEditStartExistingCodeText)
|
||||
{
|
||||
if (m_lineEditStartExistingCodeText != lineEditStartExistingCodeText) {
|
||||
m_lineEditStartExistingCodeText = lineEditStartExistingCodeText;
|
||||
emit lineEditStartExistingCodeTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getTextEditNewServerSshKeyText() const
|
||||
{
|
||||
return m_textEditNewServerSshKeyText;
|
||||
}
|
||||
|
||||
void UiLogic::setTextEditNewServerSshKeyText(const QString &textEditNewServerSshKeyText)
|
||||
{
|
||||
if (m_textEditNewServerSshKeyText != textEditNewServerSshKeyText) {
|
||||
m_textEditNewServerSshKeyText = textEditNewServerSshKeyText;
|
||||
emit textEditNewServerSshKeyTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getLineEditNewServerIpText() const
|
||||
{
|
||||
return m_lineEditNewServerIpText;
|
||||
}
|
||||
|
||||
void UiLogic::setLineEditNewServerIpText(const QString &lineEditNewServerIpText)
|
||||
{
|
||||
if (m_lineEditNewServerIpText != lineEditNewServerIpText) {
|
||||
m_lineEditNewServerIpText = lineEditNewServerIpText;
|
||||
emit lineEditNewServerIpTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getLineEditNewServerPasswordText() const
|
||||
{
|
||||
return m_lineEditNewServerPasswordText;
|
||||
}
|
||||
|
||||
void UiLogic::setLineEditNewServerPasswordText(const QString &lineEditNewServerPasswordText)
|
||||
{
|
||||
if (m_lineEditNewServerPasswordText != lineEditNewServerPasswordText) {
|
||||
m_lineEditNewServerPasswordText = lineEditNewServerPasswordText;
|
||||
emit lineEditNewServerPasswordTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getLineEditNewServerLoginText() const
|
||||
{
|
||||
return m_lineEditNewServerLoginText;
|
||||
}
|
||||
|
||||
void UiLogic::setLineEditNewServerLoginText(const QString &lineEditNewServerLoginText)
|
||||
{
|
||||
if (m_lineEditNewServerLoginText != lineEditNewServerLoginText) {
|
||||
m_lineEditNewServerLoginText = lineEditNewServerLoginText;
|
||||
emit lineEditNewServerLoginTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool UiLogic::getLabelNewServerWaitInfoVisible() const
|
||||
{
|
||||
return m_labelNewServerWaitInfoVisible;
|
||||
}
|
||||
|
||||
void UiLogic::setLabelNewServerWaitInfoVisible(bool labelNewServerWaitInfoVisible)
|
||||
{
|
||||
if (m_labelNewServerWaitInfoVisible != labelNewServerWaitInfoVisible) {
|
||||
m_labelNewServerWaitInfoVisible = labelNewServerWaitInfoVisible;
|
||||
emit labelNewServerWaitInfoVisibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getLabelNewServerWaitInfoText() const
|
||||
{
|
||||
return m_labelNewServerWaitInfoText;
|
||||
}
|
||||
|
||||
void UiLogic::setLabelNewServerWaitInfoText(const QString &labelNewServerWaitInfoText)
|
||||
{
|
||||
if (m_labelNewServerWaitInfoText != labelNewServerWaitInfoText) {
|
||||
m_labelNewServerWaitInfoText = labelNewServerWaitInfoText;
|
||||
emit labelNewServerWaitInfoTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
double UiLogic::getProgressBarNewServerConnectionMinimum() const
|
||||
{
|
||||
return m_progressBarNewServerConnectionMinimum;
|
||||
}
|
||||
|
||||
void UiLogic::setProgressBarNewServerConnectionMinimum(double progressBarNewServerConnectionMinimum)
|
||||
{
|
||||
if (m_progressBarNewServerConnectionMinimum != progressBarNewServerConnectionMinimum) {
|
||||
m_progressBarNewServerConnectionMinimum = progressBarNewServerConnectionMinimum;
|
||||
emit progressBarNewServerConnectionMinimumChanged();
|
||||
}
|
||||
}
|
||||
|
||||
double UiLogic::getProgressBarNewServerConnectionMaximum() const
|
||||
{
|
||||
return m_progressBarNewServerConnectionMaximum;
|
||||
}
|
||||
|
||||
void UiLogic::setProgressBarNewServerConnectionMaximum(double progressBarNewServerConnectionMaximum)
|
||||
{
|
||||
if (m_progressBarNewServerConnectionMaximum != progressBarNewServerConnectionMaximum) {
|
||||
m_progressBarNewServerConnectionMaximum = progressBarNewServerConnectionMaximum;
|
||||
emit progressBarNewServerConnectionMaximumChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool UiLogic::getPushButtonBackFromStartVisible() const
|
||||
{
|
||||
return m_pushButtonBackFromStartVisible;
|
||||
}
|
||||
|
||||
void UiLogic::setPushButtonBackFromStartVisible(bool pushButtonBackFromStartVisible)
|
||||
{
|
||||
if (m_pushButtonBackFromStartVisible != pushButtonBackFromStartVisible) {
|
||||
m_pushButtonBackFromStartVisible = pushButtonBackFromStartVisible;
|
||||
emit pushButtonBackFromStartVisibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool UiLogic::getPushButtonNewServerConnectVisible() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectVisible;
|
||||
}
|
||||
|
||||
void UiLogic::setPushButtonNewServerConnectVisible(bool pushButtonNewServerConnectVisible)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectVisible != pushButtonNewServerConnectVisible) {
|
||||
m_pushButtonNewServerConnectVisible = pushButtonNewServerConnectVisible;
|
||||
emit pushButtonNewServerConnectVisibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool UiLogic::getRadioButtonVpnModeAllSitesChecked() const
|
||||
{
|
||||
|
@ -1588,31 +1425,7 @@ void UiLogic::setLabelErrorText(const QString &labelErrorText)
|
|||
}
|
||||
}
|
||||
|
||||
bool UiLogic::getPushButtonNewServerConnectEnabled() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectEnabled;
|
||||
}
|
||||
|
||||
void UiLogic::setPushButtonNewServerConnectEnabled(bool pushButtonNewServerConnectEnabled)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectEnabled != pushButtonNewServerConnectEnabled) {
|
||||
m_pushButtonNewServerConnectEnabled = pushButtonNewServerConnectEnabled;
|
||||
emit pushButtonNewServerConnectEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString UiLogic::getPushButtonNewServerConnectText() const
|
||||
{
|
||||
return m_pushButtonNewServerConnectText;
|
||||
}
|
||||
|
||||
void UiLogic::setPushButtonNewServerConnectText(const QString &pushButtonNewServerConnectText)
|
||||
{
|
||||
if (m_pushButtonNewServerConnectText != pushButtonNewServerConnectText) {
|
||||
m_pushButtonNewServerConnectText = pushButtonNewServerConnectText;
|
||||
emit pushButtonNewServerConnectTextChanged();
|
||||
}
|
||||
}
|
||||
QString UiLogic::getDialogConnectErrorText() const
|
||||
{
|
||||
return m_dialogConnectErrorText;
|
||||
|
@ -2104,81 +1917,6 @@ void UiLogic::onCloseWindow()
|
|||
//#endif
|
||||
//}
|
||||
|
||||
void UiLogic::onPushButtonNewServerConnect()
|
||||
{
|
||||
if (getPushButtonNewServerConnectKeyChecked()){
|
||||
if (getLineEditNewServerIpText().isEmpty() ||
|
||||
getLineEditNewServerLoginText().isEmpty() ||
|
||||
getTextEditNewServerSshKeyText().isEmpty() ) {
|
||||
setLabelNewServerWaitInfoText(tr("Please fill in all fields"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (getLineEditNewServerIpText().isEmpty() ||
|
||||
getLineEditNewServerLoginText().isEmpty() ||
|
||||
getLineEditNewServerPasswordText().isEmpty() ) {
|
||||
setLabelNewServerWaitInfoText(tr("Please fill in all fields"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
qDebug() << "UiLogic::onPushButtonNewServerConnect checking new server";
|
||||
|
||||
ServerCredentials serverCredentials;
|
||||
serverCredentials.hostName = getLineEditNewServerIpText();
|
||||
if (serverCredentials.hostName.contains(":")) {
|
||||
serverCredentials.port = serverCredentials.hostName.split(":").at(1).toInt();
|
||||
serverCredentials.hostName = serverCredentials.hostName.split(":").at(0);
|
||||
}
|
||||
serverCredentials.userName = getLineEditNewServerLoginText();
|
||||
if (getPushButtonNewServerConnectKeyChecked()){
|
||||
QString key = getTextEditNewServerSshKeyText();
|
||||
if (key.startsWith("ssh-rsa")) {
|
||||
emit showPublicKeyWarning();
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) {
|
||||
key = SshConfigurator::convertOpenSShKey(key);
|
||||
}
|
||||
|
||||
serverCredentials.password = key;
|
||||
}
|
||||
else {
|
||||
serverCredentials.password = getLineEditNewServerPasswordText();
|
||||
}
|
||||
|
||||
setPushButtonNewServerConnectEnabled(false);
|
||||
setPushButtonNewServerConnectText(tr("Connecting..."));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
#ifdef Q_DEBUG
|
||||
//QString output = ServerController::checkSshConnection(serverCredentials, &e);
|
||||
#else
|
||||
QString output;
|
||||
#endif
|
||||
|
||||
bool ok = true;
|
||||
if (e) {
|
||||
setLabelNewServerWaitInfoVisible(true);
|
||||
setLabelNewServerWaitInfoText(errorString(e));
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
if (output.contains("Please login as the user")) {
|
||||
output.replace("\n", "");
|
||||
setLabelNewServerWaitInfoVisible(true);
|
||||
setLabelNewServerWaitInfoText(output);
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
setPushButtonNewServerConnectEnabled(true);
|
||||
setPushButtonNewServerConnectText(tr("Connect"));
|
||||
|
||||
installCredentials = serverCredentials;
|
||||
if (ok) goToPage(Page::NewServer);
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QJsonObject> UiLogic::getInstallConfigsFromProtocolsPage() const
|
||||
{
|
||||
|
@ -2326,62 +2064,6 @@ void UiLogic::installServer(const QMap<DockerContainer, QJsonObject> &containers
|
|||
}
|
||||
}
|
||||
|
||||
void UiLogic::onPushButtonNewServerImport()
|
||||
{
|
||||
QString s = getLineEditStartExistingCodeText();
|
||||
s.replace("vpn://", "");
|
||||
QJsonObject o = QJsonDocument::fromJson(QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)).object();
|
||||
|
||||
ServerCredentials credentials;
|
||||
credentials.hostName = o.value("h").toString();
|
||||
if (credentials.hostName.isEmpty()) credentials.hostName = o.value(config_key::hostName).toString();
|
||||
|
||||
credentials.port = o.value("p").toInt();
|
||||
if (credentials.port == 0) credentials.port = o.value(config_key::port).toInt();
|
||||
|
||||
credentials.userName = o.value("u").toString();
|
||||
if (credentials.userName.isEmpty()) credentials.userName = o.value(config_key::userName).toString();
|
||||
|
||||
credentials.password = o.value("w").toString();
|
||||
if (credentials.password.isEmpty()) credentials.password = o.value(config_key::password).toString();
|
||||
|
||||
if (credentials.isValid()) {
|
||||
o.insert(config_key::hostName, credentials.hostName);
|
||||
o.insert(config_key::port, credentials.port);
|
||||
o.insert(config_key::userName, credentials.userName);
|
||||
o.insert(config_key::password, credentials.password);
|
||||
|
||||
o.remove("h");
|
||||
o.remove("p");
|
||||
o.remove("u");
|
||||
o.remove("w");
|
||||
}
|
||||
qDebug() << QString("Added server %3@%1:%2").
|
||||
arg(credentials.hostName).
|
||||
arg(credentials.port).
|
||||
arg(credentials.userName);
|
||||
|
||||
//qDebug() << QString("Password") << credentials.password;
|
||||
|
||||
if (credentials.isValid() || o.contains(config_key::containers)) {
|
||||
m_settings.addServer(o);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
|
||||
setStartPage(Page::Vpn);
|
||||
}
|
||||
else {
|
||||
qDebug() << "Failed to import profile";
|
||||
qDebug().noquote() << QJsonDocument(o).toJson();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!o.contains(config_key::containers)) {
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
|
||||
goToPage(Page::ServerVpnProtocols);
|
||||
}
|
||||
}
|
||||
|
||||
bool UiLogic::installContainers(ServerCredentials credentials,
|
||||
const QMap<DockerContainer, QJsonObject> &containers,
|
||||
const PageFunc &page,
|
||||
|
@ -3086,23 +2768,6 @@ void UiLogic::onPushButtonProtoCloakSaveClicked()
|
|||
qDebug() << "Protocol saved with code:" << e << "for" << selectedServerIndex << selectedDockerContainer;
|
||||
}
|
||||
|
||||
void UiLogic::updateStartPage()
|
||||
{
|
||||
setLineEditStartExistingCodeText("");
|
||||
setTextEditNewServerSshKeyText("");
|
||||
setLineEditNewServerIpText("");
|
||||
setLineEditNewServerPasswordText("");
|
||||
setTextEditNewServerSshKeyText("");
|
||||
setLineEditNewServerLoginText("");
|
||||
|
||||
setLabelNewServerWaitInfoVisible(false);
|
||||
setLabelNewServerWaitInfoText("");
|
||||
setProgressBarNewServerConnectionMinimum(0);
|
||||
setProgressBarNewServerConnectionMaximum(300);
|
||||
setPushButtonNewServerConnectVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UiLogic::updateVpnPage()
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ class ServerSettingsLogic;
|
|||
class ServerVpnProtocolsLogic;
|
||||
class ShareConnectionLogic;
|
||||
class SitesLogic;
|
||||
class StartPageLogic;
|
||||
class VpnLogic;
|
||||
class WizardLogic;
|
||||
|
||||
|
@ -45,18 +46,7 @@ class UiLogic : public QObject
|
|||
Q_PROPERTY(QString comboBoxNewServerSsCipherText READ getComboBoxNewServerSsCipherText WRITE setComboBoxNewServerSsCipherText NOTIFY comboBoxNewServerSsCipherTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerOpenvpnPortText READ getlineEditNewServerOpenvpnPortText WRITE setLineEditNewServerOpenvpnPortText NOTIFY lineEditNewServerOpenvpnPortTextChanged)
|
||||
Q_PROPERTY(QString comboBoxNewServerOpenvpnProtoText READ getComboBoxNewServerOpenvpnProtoText WRITE setComboBoxNewServerOpenvpnProtoText NOTIFY comboBoxNewServerOpenvpnProtoTextChanged)
|
||||
Q_PROPERTY(bool pushButtonNewServerConnectKeyChecked READ getPushButtonNewServerConnectKeyChecked WRITE setPushButtonNewServerConnectKeyChecked NOTIFY pushButtonNewServerConnectKeyCheckedChanged)
|
||||
Q_PROPERTY(QString lineEditStartExistingCodeText READ getLineEditStartExistingCodeText WRITE setLineEditStartExistingCodeText NOTIFY lineEditStartExistingCodeTextChanged)
|
||||
Q_PROPERTY(QString textEditNewServerSshKeyText READ getTextEditNewServerSshKeyText WRITE setTextEditNewServerSshKeyText NOTIFY textEditNewServerSshKeyTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerIpText READ getLineEditNewServerIpText WRITE setLineEditNewServerIpText NOTIFY lineEditNewServerIpTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerPasswordText READ getLineEditNewServerPasswordText WRITE setLineEditNewServerPasswordText NOTIFY lineEditNewServerPasswordTextChanged)
|
||||
Q_PROPERTY(QString lineEditNewServerLoginText READ getLineEditNewServerLoginText WRITE setLineEditNewServerLoginText NOTIFY lineEditNewServerLoginTextChanged)
|
||||
Q_PROPERTY(bool labelNewServerWaitInfoVisible READ getLabelNewServerWaitInfoVisible WRITE setLabelNewServerWaitInfoVisible NOTIFY labelNewServerWaitInfoVisibleChanged)
|
||||
Q_PROPERTY(QString labelNewServerWaitInfoText READ getLabelNewServerWaitInfoText WRITE setLabelNewServerWaitInfoText NOTIFY labelNewServerWaitInfoTextChanged)
|
||||
Q_PROPERTY(double progressBarNewServerConnectionMinimum READ getProgressBarNewServerConnectionMinimum WRITE setProgressBarNewServerConnectionMinimum NOTIFY progressBarNewServerConnectionMinimumChanged)
|
||||
Q_PROPERTY(double progressBarNewServerConnectionMaximum READ getProgressBarNewServerConnectionMaximum WRITE setProgressBarNewServerConnectionMaximum NOTIFY progressBarNewServerConnectionMaximumChanged)
|
||||
Q_PROPERTY(bool pushButtonBackFromStartVisible READ getPushButtonBackFromStartVisible WRITE setPushButtonBackFromStartVisible NOTIFY pushButtonBackFromStartVisibleChanged)
|
||||
Q_PROPERTY(bool pushButtonNewServerConnectVisible READ getPushButtonNewServerConnectVisible WRITE setPushButtonNewServerConnectVisible NOTIFY pushButtonNewServerConnectVisibleChanged)
|
||||
|
||||
|
||||
Q_PROPERTY(int currentPageValue READ getCurrentPageValue WRITE setCurrentPageValue NOTIFY currentPageValueChanged)
|
||||
Q_PROPERTY(QString trayIconUrl READ getTrayIconUrl WRITE setTrayIconUrl NOTIFY trayIconUrlChanged)
|
||||
|
@ -128,8 +118,6 @@ class UiLogic : public QObject
|
|||
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 pushButtonNewServerConnectEnabled READ getPushButtonNewServerConnectEnabled WRITE setPushButtonNewServerConnectEnabled NOTIFY pushButtonNewServerConnectEnabledChanged)
|
||||
Q_PROPERTY(QString pushButtonNewServerConnectText READ getPushButtonNewServerConnectText WRITE setPushButtonNewServerConnectText NOTIFY pushButtonNewServerConnectTextChanged)
|
||||
Q_PROPERTY(QString dialogConnectErrorText READ getDialogConnectErrorText WRITE setDialogConnectErrorText NOTIFY dialogConnectErrorTextChanged)
|
||||
Q_PROPERTY(bool pageNewServerConfiguringEnabled READ getPageNewServerConfiguringEnabled WRITE setPageNewServerConfiguringEnabled NOTIFY pageNewServerConfiguringEnabledChanged)
|
||||
Q_PROPERTY(bool labelNewServerConfiguringWaitInfoVisible READ getLabelNewServerConfiguringWaitInfoVisible WRITE setLabelNewServerConfiguringWaitInfoVisible NOTIFY labelNewServerConfiguringWaitInfoVisibleChanged)
|
||||
|
@ -181,6 +169,7 @@ public:
|
|||
friend class ServerVpnProtocolsLogic;
|
||||
friend class ShareConnectionLogic;
|
||||
friend class SitesLogic;
|
||||
friend class StartPageLogic;
|
||||
friend class VpnLogic;
|
||||
friend class WizardLogic;
|
||||
|
||||
|
@ -217,31 +206,6 @@ public:
|
|||
void setLineEditNewServerOpenvpnPortText(const QString &lineEditNewServerOpenvpnPortText);
|
||||
QString getComboBoxNewServerOpenvpnProtoText() const;
|
||||
void setComboBoxNewServerOpenvpnProtoText(const QString &comboBoxNewServerOpenvpnProtoText);
|
||||
QString getLineEditStartExistingCodeText() const;
|
||||
void setLineEditStartExistingCodeText(const QString &lineEditStartExistingCodeText);
|
||||
QString getTextEditNewServerSshKeyText() const;
|
||||
void setTextEditNewServerSshKeyText(const QString &textEditNewServerSshKeyText);
|
||||
QString getLineEditNewServerIpText() const;
|
||||
void setLineEditNewServerIpText(const QString &lineEditNewServerIpText);
|
||||
QString getLineEditNewServerPasswordText() const;
|
||||
void setLineEditNewServerPasswordText(const QString &lineEditNewServerPasswordText);
|
||||
QString getLineEditNewServerLoginText() const;
|
||||
void setLineEditNewServerLoginText(const QString &lineEditNewServerLoginText);
|
||||
bool getLabelNewServerWaitInfoVisible() const;
|
||||
void setLabelNewServerWaitInfoVisible(bool labelNewServerWaitInfoVisible);
|
||||
QString getLabelNewServerWaitInfoText() const;
|
||||
void setLabelNewServerWaitInfoText(const QString &labelNewServerWaitInfoText);
|
||||
double getProgressBarNewServerConnectionMinimum() const;
|
||||
void setProgressBarNewServerConnectionMinimum(double progressBarNewServerConnectionMinimum);
|
||||
double getProgressBarNewServerConnectionMaximum() const;
|
||||
void setProgressBarNewServerConnectionMaximum(double progressBarNewServerConnectionMaximum);
|
||||
bool getPushButtonBackFromStartVisible() const;
|
||||
void setPushButtonBackFromStartVisible(bool pushButtonBackFromStartVisible);
|
||||
bool getPushButtonNewServerConnectVisible() const;
|
||||
void setPushButtonNewServerConnectVisible(bool pushButtonNewServerConnectVisible);
|
||||
bool getPushButtonNewServerConnectKeyChecked() const;
|
||||
void setPushButtonNewServerConnectKeyChecked(bool pushButtonNewServerConnectKeyChecked);
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -386,10 +350,8 @@ public:
|
|||
void setWidgetVpnModeEnabled(bool widgetVpnModeEnabled);
|
||||
QString getLabelErrorText() const;
|
||||
void setLabelErrorText(const QString &labelErrorText);
|
||||
bool getPushButtonNewServerConnectEnabled() const;
|
||||
void setPushButtonNewServerConnectEnabled(bool pushButtonNewServerConnectEnabled);
|
||||
QString getPushButtonNewServerConnectText() const;
|
||||
void setPushButtonNewServerConnectText(const QString &pushButtonNewServerConnectText);
|
||||
|
||||
|
||||
QString getDialogConnectErrorText() const;
|
||||
void setDialogConnectErrorText(const QString &dialogConnectErrorText);
|
||||
|
||||
|
@ -461,11 +423,9 @@ public:
|
|||
|
||||
Q_INVOKABLE void updateWizardHighPage();
|
||||
Q_INVOKABLE void updateNewServerProtocolsPage();
|
||||
Q_INVOKABLE void updateStartPage();
|
||||
Q_INVOKABLE void updateVpnPage();
|
||||
|
||||
Q_INVOKABLE void onPushButtonNewServerConnect();
|
||||
Q_INVOKABLE void onPushButtonNewServerImport();
|
||||
|
||||
Q_INVOKABLE void onPushButtonSetupWizardVpnModeFinishClicked();
|
||||
Q_INVOKABLE void onPushButtonSetupWizardLowFinishClicked();
|
||||
Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked);
|
||||
|
@ -512,18 +472,8 @@ signals:
|
|||
void comboBoxNewServerSsCipherTextChanged();
|
||||
void lineEditNewServerOpenvpnPortTextChanged();
|
||||
void comboBoxNewServerOpenvpnProtoTextChanged();
|
||||
void pushButtonNewServerConnectKeyCheckedChanged();
|
||||
void lineEditStartExistingCodeTextChanged();
|
||||
void textEditNewServerSshKeyTextChanged();
|
||||
void lineEditNewServerIpTextChanged();
|
||||
void lineEditNewServerPasswordTextChanged();
|
||||
void lineEditNewServerLoginTextChanged();
|
||||
void labelNewServerWaitInfoVisibleChanged();
|
||||
void labelNewServerWaitInfoTextChanged();
|
||||
void progressBarNewServerConnectionMinimumChanged();
|
||||
void progressBarNewServerConnectionMaximumChanged();
|
||||
void pushButtonBackFromStartVisibleChanged();
|
||||
void pushButtonNewServerConnectVisibleChanged();
|
||||
|
||||
|
||||
void radioButtonVpnModeAllSitesCheckedChanged();
|
||||
void radioButtonVpnModeForwardSitesCheckedChanged();
|
||||
void radioButtonVpnModeExceptSitesCheckedChanged();
|
||||
|
@ -601,8 +551,7 @@ signals:
|
|||
void pushButtonConnectEnabledChanged();
|
||||
void widgetVpnModeEnabledChanged();
|
||||
void labelErrorTextChanged();
|
||||
void pushButtonNewServerConnectEnabledChanged();
|
||||
void pushButtonNewServerConnectTextChanged();
|
||||
|
||||
void dialogConnectErrorTextChanged();
|
||||
|
||||
void pageNewServerConfiguringEnabledChanged();
|
||||
|
@ -670,18 +619,9 @@ private:
|
|||
QString m_comboBoxNewServerSsCipherText;
|
||||
QString m_lineEditNewServerOpenvpnPortText;
|
||||
QString m_comboBoxNewServerOpenvpnProtoText;
|
||||
bool m_pushButtonNewServerConnectKeyChecked;
|
||||
QString m_lineEditStartExistingCodeText;
|
||||
QString m_textEditNewServerSshKeyText;
|
||||
QString m_lineEditNewServerIpText;
|
||||
QString m_lineEditNewServerPasswordText;
|
||||
QString m_lineEditNewServerLoginText;
|
||||
bool m_labelNewServerWaitInfoVisible;
|
||||
QString m_labelNewServerWaitInfoText;
|
||||
double m_progressBarNewServerConnectionMinimum;
|
||||
double m_progressBarNewServerConnectionMaximum;
|
||||
bool m_pushButtonBackFromStartVisible;
|
||||
bool m_pushButtonNewServerConnectVisible;
|
||||
|
||||
|
||||
|
||||
bool m_radioButtonVpnModeAllSitesChecked;
|
||||
bool m_radioButtonVpnModeForwardSitesChecked;
|
||||
bool m_radioButtonVpnModeExceptSitesChecked;
|
||||
|
@ -760,8 +700,6 @@ private:
|
|||
bool m_pushButtonConnectEnabled;
|
||||
bool m_widgetVpnModeEnabled;
|
||||
QString m_labelErrorText;
|
||||
bool m_pushButtonNewServerConnectEnabled;
|
||||
QString m_pushButtonNewServerConnectText;
|
||||
QString m_dialogConnectErrorText;
|
||||
|
||||
bool m_pageNewServerConfiguringEnabled;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue