~ubuntu-branches/ubuntu/precise/networkmanagement/precise

« back to all changes in this revision

Viewing changes to vpnplugins/vpnc/vpncauth.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-10-23 14:00:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20111023140013-e38hdzybcg6zndrk
Tags: 0.9~svngit.nm09.20111023.ff842e-0ubuntu1
* New upstream snapshot.
* Drop all patches, merged upstream.
* Add kubuntu_add_subdirectory_po.diff to build the translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
*/
20
20
 
21
21
#include "vpncauth.h"
22
 
 
23
 
#include <nm-setting-vpn.h>
 
22
#include "ui_vpncauth.h"
24
23
 
25
24
#include <QString>
26
25
#include "nm-vpnc-service.h"
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)));
44
42
}
45
43
 
46
44
VpncAuthWidget::~VpncAuthWidget()
58
56
void VpncAuthWidget::readSecrets()
59
57
{
60
58
    Q_D(VpncAuthWidget);
 
59
    QStringMap data = d->setting->data();
61
60
    QStringMap secrets = d->setting->vpnSecrets();
62
 
    QStringMap secretsType = d->setting->secretsStorageType();
63
 
    QString userType;
64
 
    QString groupType;
65
61
 
66
 
    /*
67
 
     * First time "old" settings are loaded secretsType map is empty, so
68
 
     * try to read from data as fallback
69
 
     */
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);
73
 
    }
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)));
 
64
    } else {
 
65
        d->ui.userLabel->setVisible(false);
 
66
        d->ui.leUserPassword->setVisible(false);
76
67
    }
77
68
 
78
 
    groupType = secretsType.value(NM_VPNC_KEY_SECRET);
79
 
    if (groupType.isNull()) {
80
 
        groupType = d->setting->data().value(NM_VPNC_KEY_SECRET_TYPE);
81
 
    }
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)));
 
71
    } else {
 
72
        d->ui.groupLabel->setVisible(false);
 
73
        d->ui.leGroupPassword->setVisible(false);
84
74
    }
85
75
 
86
76
    if (d->ui.leUserPassword->text().isEmpty())
107
97
    d->setting->setVpnSecrets(secretData);
108
98
}
109
99
 
110
 
void VpncAuthWidget::showPasswords(bool on)
111
 
{
112
 
    Q_D(VpncAuthWidget);
113
 
 
114
 
    d->ui.leUserPassword->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
115
 
    d->ui.leGroupPassword->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
116
 
}
117
 
 
118
100
// vim: sw=4 sts=4 et tw=100