2
Copyright 2013 Jan Grulich <jgrulich@redhat.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) version 3, or any
8
later version accepted by the membership of KDE e.V. (or its
9
successor approved by the membership of KDE e.V.), which shall
10
act as a proxy defined in Section 6 of version 3 of the license.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
#include "openswanauth.h"
22
#include "ui_openswanauth.h"
23
#include "nm-openswan-service.h"
27
class OpenswanAuthDialogPrivate
31
NetworkManager::VpnSetting::Ptr setting;
34
OpenswanAuthDialog::OpenswanAuthDialog(const NetworkManager::VpnSetting::Ptr &setting, QWidget * parent)
35
: SettingWidget(setting, parent), d_ptr(new OpenswanAuthDialogPrivate)
37
Q_D(OpenswanAuthDialog);
40
connect(d->ui.cbShowPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsChanged(bool)));
44
KAcceleratorManager::manage(this);
47
OpenswanAuthDialog::~OpenswanAuthDialog()
52
void OpenswanAuthDialog::readSecrets()
54
Q_D(OpenswanAuthDialog);
55
const NMStringMap data = d->setting->data();
56
const NMStringMap secrets = d->setting->secrets();
58
const QString groupName = data.value(NM_OPENSWAN_LEFTID);
59
if (!groupName.isEmpty()) {
60
d->ui.leGroupName->setText(groupName);
63
bool haveUserPassword = true;
64
if (data.value(NM_OPENSWAN_XAUTH_PASSWORD_INPUT_MODES) != NM_OPENSWAN_PW_TYPE_UNUSED) {
65
d->ui.leUserPassword->setText(secrets.value(NM_OPENSWAN_XAUTH_PASSWORD));
67
d->ui.leUserPassword->setVisible(false);
68
d->ui.userPasswordLabel->setVisible(false);
69
haveUserPassword = false;
72
bool haveGroupPassword = true;
73
if (data.value(NM_OPENSWAN_PSK_INPUT_MODES) != NM_OPENSWAN_PW_TYPE_UNUSED) {
74
d->ui.leGroupPassword->setText(secrets.value(NM_OPENSWAN_PSK_VALUE));
76
d->ui.leGroupPassword->setVisible(false);
77
d->ui.groupPasswordLabel->setVisible(false);
78
haveGroupPassword = false;
81
if (haveUserPassword && d->ui.leUserPassword->text().isEmpty()) {
82
d->ui.leUserPassword->setFocus(Qt::OtherFocusReason);
83
} else if (haveGroupPassword && d->ui.leGroupPassword->text().isEmpty()) {
84
d->ui.leGroupPassword->setFocus(Qt::OtherFocusReason);
88
QVariantMap OpenswanAuthDialog::setting(bool agentOwned) const
90
Q_D(const OpenswanAuthDialog);
96
if (!d->ui.leUserPassword->text().isEmpty()) {
97
secrets.insert(NM_OPENSWAN_XAUTH_PASSWORD, d->ui.leUserPassword->text());
100
if (!d->ui.leGroupPassword->text().isEmpty()) {
101
secrets.insert(NM_OPENSWAN_PSK_VALUE, d->ui.leGroupPassword->text());
104
result.insert("secrets", QVariant::fromValue<NMStringMap>(secrets));
109
void OpenswanAuthDialog::showPasswordsChanged(bool show)
111
Q_D(OpenswanAuthDialog);
112
d->ui.leUserPassword->setPasswordMode(!show);
113
d->ui.leGroupPassword->setPasswordMode(!show);