40
39
Q_D(VpncAuthWidget);
41
40
d->ui.setupUi(this);
42
41
d->setting = static_cast<Knm::VpnSetting *>(connection->setting(Knm::Setting::Vpn));
43
connect(d->ui.cbShowPasswords, SIGNAL(clicked(bool)), this, SLOT(showPasswords(bool)));
46
44
VpncAuthWidget::~VpncAuthWidget()
58
56
void VpncAuthWidget::readSecrets()
60
58
Q_D(VpncAuthWidget);
59
QStringMap data = d->setting->data();
61
60
QStringMap secrets = d->setting->vpnSecrets();
62
QStringMap secretsType = d->setting->secretsStorageType();
67
* First time "old" settings are loaded secretsType map is empty, so
68
* try to read from data as fallback
70
userType = secretsType.value(NM_VPNC_KEY_XAUTH_PASSWORD);
71
if (userType.isNull()) {
72
userType = d->setting->data().value(NM_VPNC_KEY_XAUTH_PASSWORD_TYPE);
74
if (userType == QLatin1String(NM_VPN_PW_TYPE_SAVE)) {
62
if (!((Knm::Setting::secretsTypes)data[NM_VPNC_KEY_XAUTH_PASSWORD"-flags"].toInt()).testFlag(Knm::Setting::NotRequired)) {
75
63
d->ui.leUserPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_XAUTH_PASSWORD)));
65
d->ui.userLabel->setVisible(false);
66
d->ui.leUserPassword->setVisible(false);
78
groupType = secretsType.value(NM_VPNC_KEY_SECRET);
79
if (groupType.isNull()) {
80
groupType = d->setting->data().value(NM_VPNC_KEY_SECRET_TYPE);
82
if (groupType == QLatin1String(NM_VPN_PW_TYPE_SAVE)) {
69
if (!((Knm::Setting::secretsTypes)d->setting->data().value(NM_VPNC_KEY_SECRET"-flags").toInt()).testFlag(Knm::Setting::NotRequired)) {
83
70
d->ui.leGroupPassword->setText(secrets.value(QLatin1String(NM_VPNC_KEY_SECRET)));
72
d->ui.groupLabel->setVisible(false);
73
d->ui.leGroupPassword->setVisible(false);
86
76
if (d->ui.leUserPassword->text().isEmpty())
107
97
d->setting->setVpnSecrets(secretData);
110
void VpncAuthWidget::showPasswords(bool on)
114
d->ui.leUserPassword->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
115
d->ui.leGroupPassword->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
118
100
// vim: sw=4 sts=4 et tw=100