diff --git a/vpn/l2tp/CMakeLists.txt b/vpn/l2tp/CMakeLists.txt index 692d916c..7a0bc43e 100644 --- a/vpn/l2tp/CMakeLists.txt +++ b/vpn/l2tp/CMakeLists.txt @@ -1,28 +1,28 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasmanetworkmanagement_l2tpui\") set(l2tp_SRCS l2tp.cpp l2tpwidget.cpp l2tpauth.cpp - l2tpadvancedwidget.cpp + l2tpipsecwidget.cpp l2tppppwidget.cpp ) -ki18n_wrap_ui(l2tp_SRCS l2tp.ui l2tpadvanced.ui l2tpauth.ui l2tpppp.ui) +ki18n_wrap_ui(l2tp_SRCS l2tp.ui l2tpipsec.ui l2tpauth.ui l2tpppp.ui) add_library(plasmanetworkmanagement_l2tpui ${l2tp_SRCS}) kcoreaddons_desktop_to_json(plasmanetworkmanagement_l2tpui plasmanetworkmanagement_l2tpui.desktop) target_link_libraries(plasmanetworkmanagement_l2tpui plasmanm_internal plasmanm_editor KF5::CoreAddons KF5::I18n KF5::KIOWidgets KF5::WidgetsAddons ) install(TARGETS plasmanetworkmanagement_l2tpui DESTINATION ${KDE_INSTALL_PLUGINDIR}) install(FILES plasmanetworkmanagement_l2tpui.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) diff --git a/vpn/l2tp/l2tpadvanced.ui b/vpn/l2tp/l2tpipsec.ui similarity index 97% rename from vpn/l2tp/l2tpadvanced.ui rename to vpn/l2tp/l2tpipsec.ui index 4d405dcb..112d1d36 100644 --- a/vpn/l2tp/l2tpadvanced.ui +++ b/vpn/l2tp/l2tpipsec.ui @@ -1,303 +1,303 @@ - L2tpAdvancedWidget - + L2tpIpsecWidget + 0 0 382 254 6 Enable IPsec tunnel to L2TP host false Gateway ID: false false Pre-shared Key: false true false Phase1 algorithms: false false Phase2 algorithms: false false Enforce UDP encapsulation true QDialogButtonBox::Cancel|QDialogButtonBox::Ok PasswordField QLineEdit
passwordfield.h
cbEnableTunnelToHost toggled(bool) gatewayId setEnabled(bool) 159 14 209 65 cbEnableTunnelToHost toggled(bool) presharedKey setEnabled(bool) 159 14 209 91 cbEnableTunnelToHost toggled(bool) ike setEnabled(bool) 190 16 209 65 cbEnableTunnelToHost toggled(bool) esp setEnabled(bool) 190 16 209 65 cbEnableTunnelToHost toggled(bool) cbForceEncaps setEnabled(bool) 190 16 209 65 cbEnableTunnelToHost toggled(bool) label_2 setEnabled(bool) 190 16 75 87 cbEnableTunnelToHost toggled(bool) label setEnabled(bool) 190 16 86 49 cbEnableTunnelToHost toggled(bool) label_3 setEnabled(bool) 190 16 64 125 cbEnableTunnelToHost toggled(bool) label_4 setEnabled(bool) 190 16 64 163 buttonBox accepted() - L2tpAdvancedWidget + L2tpIpsecWidget accept() 190 119 190 68 buttonBox rejected() - L2tpAdvancedWidget + L2tpIpsecWidget reject() 190 119 190 68
diff --git a/vpn/l2tp/l2tpadvancedwidget.cpp b/vpn/l2tp/l2tpipsecwidget.cpp similarity index 87% rename from vpn/l2tp/l2tpadvancedwidget.cpp rename to vpn/l2tp/l2tpipsecwidget.cpp index fcc3a1c7..f42a5951 100644 --- a/vpn/l2tp/l2tpadvancedwidget.cpp +++ b/vpn/l2tp/l2tpipsecwidget.cpp @@ -1,93 +1,93 @@ /* Copyright 2013 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ -#include "l2tpadvancedwidget.h" -#include "ui_l2tpadvanced.h" +#include "l2tpipsecwidget.h" +#include "ui_l2tpipsec.h" #include "nm-l2tp-service.h" #include #include -L2tpAdvancedWidget::L2tpAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent) +L2tpIpsecWidget::L2tpIpsecWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent) : QDialog(parent) - , m_ui(new Ui::L2tpAdvancedWidget) + , m_ui(new Ui::L2tpIpsecWidget) { m_ui->setupUi(this); setWindowTitle(i18n("L2TP IPsec Options")); KAcceleratorManager::manage(this); loadConfig(setting); } -L2tpAdvancedWidget::~L2tpAdvancedWidget() +L2tpIpsecWidget::~L2tpIpsecWidget() { delete m_ui; } -void L2tpAdvancedWidget::loadConfig(const NetworkManager::VpnSetting::Ptr &setting) +void L2tpIpsecWidget::loadConfig(const NetworkManager::VpnSetting::Ptr &setting) { if (setting->data().value(NM_L2TP_KEY_IPSEC_ENABLE) == "yes") { m_ui->cbEnableTunnelToHost->setChecked(true); m_ui->gatewayId->setText(setting->data().value(NM_L2TP_KEY_IPSEC_GATEWAY_ID)); m_ui->presharedKey->setText(setting->data().value(NM_L2TP_KEY_IPSEC_PSK)); m_ui->ike->setText(setting->data().value(NM_L2TP_KEY_IPSEC_IKE)); m_ui->esp->setText(setting->data().value(NM_L2TP_KEY_IPSEC_ESP)); if (setting->data().value(NM_L2TP_KEY_IPSEC_FORCEENCAPS) == "yes" ) { m_ui->cbForceEncaps->setChecked(true); } else { m_ui->cbForceEncaps->setChecked(false); } } else { m_ui->cbEnableTunnelToHost->setChecked(false); } } -NMStringMap L2tpAdvancedWidget::setting() const +NMStringMap L2tpIpsecWidget::setting() const { NMStringMap result; if (m_ui->cbEnableTunnelToHost->isChecked()) { result.insert(NM_L2TP_KEY_IPSEC_ENABLE, "yes"); if (!m_ui->gatewayId->text().isEmpty()) { result.insert(NM_L2TP_KEY_IPSEC_GATEWAY_ID, m_ui->gatewayId->text()); } if (!m_ui->presharedKey->text().isEmpty()) { result.insert(NM_L2TP_KEY_IPSEC_PSK, m_ui->presharedKey->text()); } if (!m_ui->ike->text().isEmpty()) { result.insert(NM_L2TP_KEY_IPSEC_IKE, m_ui->ike->text()); } if (!m_ui->esp->text().isEmpty()) { result.insert(NM_L2TP_KEY_IPSEC_ESP, m_ui->esp->text()); } if (m_ui->cbForceEncaps->isChecked()) { result.insert(NM_L2TP_KEY_IPSEC_FORCEENCAPS, "yes"); } } return result; } diff --git a/vpn/l2tp/l2tpadvancedwidget.h b/vpn/l2tp/l2tpipsecwidget.h similarity index 75% rename from vpn/l2tp/l2tpadvancedwidget.h rename to vpn/l2tp/l2tpipsecwidget.h index 420363b8..d7db8efd 100644 --- a/vpn/l2tp/l2tpadvancedwidget.h +++ b/vpn/l2tp/l2tpipsecwidget.h @@ -1,47 +1,47 @@ /* Copyright 2013 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ -#ifndef PLASMA_NM_L2TP_ADVANCED_WIDGET_H -#define PLASMA_NM_L2TP_ADVANCED_WIDGET_H +#ifndef PLASMA_NM_L2TP_IPSEC_WIDGET_H +#define PLASMA_NM_L2TP_IPSEC_WIDGET_H #include #include namespace Ui { -class L2tpAdvancedWidget; +class L2tpIpsecWidget; } -class L2tpAdvancedWidget : public QDialog +class L2tpIpsecWidget : public QDialog { Q_OBJECT public: - explicit L2tpAdvancedWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = nullptr); - ~L2tpAdvancedWidget() override; + explicit L2tpIpsecWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget *parent = nullptr); + ~L2tpIpsecWidget() override; NMStringMap setting() const; private: void loadConfig(const NetworkManager::VpnSetting::Ptr &setting); - Ui::L2tpAdvancedWidget * m_ui; + Ui::L2tpIpsecWidget * m_ui; }; -#endif // PLASMA_NM_L2TP_ADVANCED_WIDGET_H +#endif // PLASMA_NM_L2TP_IPSEC_WIDGET_H diff --git a/vpn/l2tp/l2tpwidget.cpp b/vpn/l2tp/l2tpwidget.cpp index 49e1e5cc..23eb65a4 100644 --- a/vpn/l2tp/l2tpwidget.cpp +++ b/vpn/l2tp/l2tpwidget.cpp @@ -1,285 +1,285 @@ /* Copyright 2013 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "l2tpwidget.h" -#include "l2tpadvancedwidget.h" +#include "l2tpipsecwidget.h" #include "l2tppppwidget.h" #include "ui_l2tp.h" #include "nm-l2tp-service.h" #include #include #include L2tpWidget::L2tpWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent, Qt::WindowFlags f) : SettingWidget(setting, parent, f) , m_ui(new Ui::L2tpWidget) , m_setting(setting) { qDBusRegisterMetaType(); m_ui->setupUi(this); m_ui->password->setPasswordOptionsEnabled(true); - connect(m_ui->btnIPSecSettings, &QPushButton::clicked, this, &L2tpWidget::showAdvanced); + connect(m_ui->btnIPSecSettings, &QPushButton::clicked, this, &L2tpWidget::showIpsec); connect(m_ui->btnPPPSettings, &QPushButton::clicked, this, &L2tpWidget::showPpp); // Connect for setting check watchChangedSetting(); // Connect for validity check connect(m_ui->gateway, &QLineEdit::textChanged, this, &L2tpWidget::slotWidgetChanged); connect(m_ui->cbUseCertificate, &QCheckBox::stateChanged, this, &L2tpWidget::certStateChanged); KAcceleratorManager::manage(this); if (setting && !setting->isNull()) { loadConfig(setting); } } L2tpWidget::~L2tpWidget() { - m_tmpAdvancedSetting.clear(); + m_tmpIpsecSetting.clear(); m_tmpPppSetting.clear(); delete m_ui; } void L2tpWidget::loadConfig(const NetworkManager::Setting::Ptr &setting) { Q_UNUSED(setting); const NMStringMap data = m_setting->data(); if (data.contains(NM_L2TP_KEY_GATEWAY)) { m_ui->gateway->setText(data.value(NM_L2TP_KEY_GATEWAY)); } if (data.contains(NM_L2TP_KEY_USER)) { m_ui->username->setText(data.value(NM_L2TP_KEY_USER)); } const NetworkManager::Setting::SecretFlags userPassType = static_cast(data.value(NM_L2TP_KEY_PASSWORD"-flags").toInt()); if (userPassType.testFlag(NetworkManager::Setting::None)) { m_ui->password->setPasswordOption(PasswordField::StoreForAllUsers); } else if (userPassType.testFlag(NetworkManager::Setting::AgentOwned)) { m_ui->password->setPasswordOption(PasswordField::StoreForUser); } else { m_ui->password->setPasswordOption(PasswordField::AlwaysAsk); } if (data.contains(NM_L2TP_KEY_DOMAIN)) { m_ui->domain->setText(data.value(NM_L2TP_KEY_DOMAIN)); } if (data.contains(NM_L2TP_KEY_CERT_CA)) { m_ui->urCACertificate->setText(data.value(NM_L2TP_KEY_CERT_CA)); } if (data.contains(NM_L2TP_KEY_CERT_PUB)) { m_ui->urCertificate->setText(data.value(NM_L2TP_KEY_CERT_PUB)); } if (data.contains(NM_L2TP_KEY_CERT_KEY)) { m_ui->urPrivateKey->setText(data.value(NM_L2TP_KEY_CERT_KEY)); } if (data.value(NM_L2TP_KEY_USE_CERT) == QLatin1String("yes")) { m_ui->cbUseCertificate->setChecked(true); } loadSecrets(setting); } void L2tpWidget::loadSecrets(const NetworkManager::Setting::Ptr &setting) { NetworkManager::VpnSetting::Ptr vpnSetting = setting.staticCast(); if (vpnSetting) { const NMStringMap secrets = vpnSetting->secrets(); const QString userPassword = secrets.value(NM_L2TP_KEY_PASSWORD); if (!userPassword.isEmpty()) { m_ui->password->setText(userPassword); } } } QVariantMap L2tpWidget::setting() const { NetworkManager::VpnSetting setting; setting.setServiceType(QLatin1String(NM_DBUS_SERVICE_L2TP)); NMStringMap data; - if (!m_tmpAdvancedSetting.isNull()) { - data = m_tmpAdvancedSetting->data(); + if (!m_tmpIpsecSetting.isNull()) { + data = m_tmpIpsecSetting->data(); } else { // retrieve the settings if the dialog has not been opened - QScopedPointer adv(new L2tpAdvancedWidget(m_setting, nullptr)); - data = adv->setting(); + QScopedPointer ipsec(new L2tpIpsecWidget(m_setting, nullptr)); + data = ipsec->setting(); } if (!m_tmpPppSetting.isNull()) { data.unite(m_tmpPppSetting->data()); } else { // retrieve the settings if the dialog has not been opened QScopedPointer ppp(new L2tpPPPWidget(m_setting, nullptr)); data.unite(ppp->setting()); } NMStringMap secrets; if (!m_ui->gateway->text().isEmpty()) { data.insert(NM_L2TP_KEY_GATEWAY, m_ui->gateway->text()); } if (m_ui->cbUseCertificate->isChecked()) { data.insert(NM_L2TP_KEY_USE_CERT, "yes"); if (!m_ui->urCACertificate->text().isEmpty()) { data.insert(NM_L2TP_KEY_CERT_CA, m_ui->urCACertificate->text()); } if (!m_ui->urCertificate->text().isEmpty()) { data.insert(NM_L2TP_KEY_CERT_PUB, m_ui->urCertificate->text()); } if (!m_ui->urPrivateKey->text().isEmpty()) { data.insert(NM_L2TP_KEY_CERT_KEY, m_ui->urPrivateKey->text()); } data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotRequired)); } else { if (!m_ui->username->text().isEmpty()) { data.insert(NM_L2TP_KEY_USER, m_ui->username->text()); } if (m_ui->password->isEnabled() && !m_ui->password->text().isEmpty()) { secrets.insert(NM_L2TP_KEY_PASSWORD, m_ui->password->text()); } switch (m_ui->password->passwordOption()) { case PasswordField::StoreForAllUsers: data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::None)); break; case PasswordField::StoreForUser: data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::AgentOwned)); break; default: data.insert(NM_L2TP_KEY_PASSWORD"-flags", QString::number(NetworkManager::Setting::NotSaved)); }; if (!m_ui->domain->text().isEmpty()) { data.insert(NM_L2TP_KEY_DOMAIN, m_ui->domain->text()); } } setting.setData(data); setting.setSecrets(secrets); return setting.toMap(); } void L2tpWidget::userPasswordTypeChanged(int index) { m_ui->password->setEnabled(index == SettingWidget::EnumPasswordStorageType::Store); } -void L2tpWidget::showAdvanced() +void L2tpWidget::showIpsec() { - QPointer adv; - if (m_tmpAdvancedSetting.isNull()) { - adv = new L2tpAdvancedWidget(m_setting, this); + QPointer ipsec; + if (m_tmpIpsecSetting.isNull()) { + ipsec = new L2tpIpsecWidget(m_setting, this); } else { - adv = new L2tpAdvancedWidget(m_tmpAdvancedSetting, this); + ipsec = new L2tpIpsecWidget(m_tmpIpsecSetting, this); } - connect(adv.data(), &L2tpAdvancedWidget::accepted, - [adv, this] () { - NMStringMap advData = adv->setting(); - if (!advData.isEmpty()) { - if (m_tmpAdvancedSetting.isNull()) { - m_tmpAdvancedSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting); + connect(ipsec.data(), &L2tpIpsecWidget::accepted, + [ipsec, this] () { + NMStringMap ipsecData = ipsec->setting(); + if (!ipsecData.isEmpty()) { + if (m_tmpIpsecSetting.isNull()) { + m_tmpIpsecSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting); } - m_tmpAdvancedSetting->setData(advData); + m_tmpIpsecSetting->setData(ipsecData); } }); - connect(adv.data(), &L2tpAdvancedWidget::finished, - [adv] () { - if (adv) { - adv->deleteLater(); + connect(ipsec.data(), &L2tpIpsecWidget::finished, + [ipsec] () { + if (ipsec) { + ipsec->deleteLater(); } }); - adv->setModal(true); - adv->show(); + ipsec->setModal(true); + ipsec->show(); } void L2tpWidget::showPpp() { - QPointer adv; + QPointer ipsec; if (m_tmpPppSetting.isNull()) { - adv = new L2tpPPPWidget(m_setting, this); + ipsec = new L2tpPPPWidget(m_setting, this); } else { - adv = new L2tpPPPWidget(m_tmpPppSetting, this); + ipsec = new L2tpPPPWidget(m_tmpPppSetting, this); } - connect(adv.data(), &L2tpPPPWidget::accepted, - [adv, this] () { - NMStringMap advData = adv->setting(); - if (!advData.isEmpty()) { + connect(ipsec.data(), &L2tpPPPWidget::accepted, + [ipsec, this] () { + NMStringMap ipsecData = ipsec->setting(); + if (!ipsecData.isEmpty()) { if (m_tmpPppSetting.isNull()) { m_tmpPppSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting); } - m_tmpPppSetting->setData(advData); + m_tmpPppSetting->setData(ipsecData); } }); - connect(adv.data(), &L2tpPPPWidget::finished, - [adv] () { - if (adv) { - adv->deleteLater(); + connect(ipsec.data(), &L2tpPPPWidget::finished, + [ipsec] () { + if (ipsec) { + ipsec->deleteLater(); } }); - adv->setModal(true); - adv->show(); + ipsec->setModal(true); + ipsec->show(); } bool L2tpWidget::isValid() const { return !m_ui->gateway->text().isEmpty(); } void L2tpWidget::certStateChanged() { if (m_ui->cbUseCertificate->isChecked()) { m_ui->urCACertificate->setEnabled(true); m_ui->urCertificate->setEnabled(true); m_ui->urPrivateKey->setEnabled(true); m_ui->username->setEnabled(false); m_ui->password->setEnabled(false); m_ui->domain->setEnabled(false); } else { m_ui->urCACertificate->setEnabled(false); m_ui->urCertificate->setEnabled(false); m_ui->urPrivateKey->setEnabled(false); m_ui->username->setEnabled(true); m_ui->password->setEnabled(true); m_ui->domain->setEnabled(true); } } diff --git a/vpn/l2tp/l2tpwidget.h b/vpn/l2tp/l2tpwidget.h index 147e8792..e69d25a9 100644 --- a/vpn/l2tp/l2tpwidget.h +++ b/vpn/l2tp/l2tpwidget.h @@ -1,60 +1,60 @@ /* Copyright 2013 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #ifndef PLASMA_NM_L2TP_WIDGET_H #define PLASMA_NM_L2TP_WIDGET_H #include #include "settingwidget.h" namespace Ui { class L2tpWidget; } class L2tpWidget : public SettingWidget { Q_OBJECT public: explicit L2tpWidget(const NetworkManager::VpnSetting::Ptr &setting, QWidget* parent = nullptr, Qt::WindowFlags f = {}); ~L2tpWidget() override; void loadConfig(const NetworkManager::Setting::Ptr &setting) override; void loadSecrets(const NetworkManager::Setting::Ptr &setting) override; QVariantMap setting() const override; bool isValid() const override; private Q_SLOTS: void userPasswordTypeChanged(int index); - void showAdvanced(); + void showIpsec(); void showPpp(); void certStateChanged(); private: Ui::L2tpWidget * m_ui; NetworkManager::VpnSetting::Ptr m_setting; - NetworkManager::VpnSetting::Ptr m_tmpAdvancedSetting; + NetworkManager::VpnSetting::Ptr m_tmpIpsecSetting; NetworkManager::VpnSetting::Ptr m_tmpPppSetting; }; #endif // PLASMA_NM_L2TP_WIDGET_H