~ubuntu-branches/ubuntu/jaunty/plasma-widget-network-manager/jaunty-updates

« back to all changes in this revision

Viewing changes to libs/ui/gsmwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-02-10 16:33:42 UTC
  • Revision ID: james.westby@ubuntu.com-20090210163342-y22tcldf0fuyqqm9
Tags: upstream-0.0+svn924363
ImportĀ upstreamĀ versionĀ 0.0+svn924363

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2008 Will Stephenson <wstephenson@kde.org>
 
3
 
 
4
This program is free software; you can redistribute it and/or
 
5
modify it under the terms of the GNU General Public License as
 
6
published by the Free Software Foundation; either version 2 of
 
7
the License or (at your option) version 3 or any later version
 
8
accepted by the membership of KDE e.V. (or its successor approved
 
9
by the membership of KDE e.V.), which shall act as a proxy 
 
10
defined in Section 14 of version 3 of the license.
 
11
 
 
12
This program 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
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#include "gsmwidget.h"
 
22
 
 
23
#include "ui_gsm.h"
 
24
#include "connection.h"
 
25
#include "settings/gsm.h"
 
26
 
 
27
class GsmWidget::Private
 
28
{
 
29
public:
 
30
    Ui_Gsm ui;
 
31
    Knm::GsmSetting * setting;
 
32
};
 
33
 
 
34
GsmWidget::GsmWidget(Knm::Connection * connection, QWidget * parent)
 
35
: SettingWidget(connection, parent), d(new GsmWidget::Private)
 
36
{
 
37
    d->ui.setupUi(this);
 
38
    d->setting = static_cast<Knm::GsmSetting *>(connection->setting(Knm::Setting::Gsm));
 
39
    connect(d->ui.chkShowPass, SIGNAL(stateChanged(int)), this, SLOT(chkShowPassToggled()));
 
40
    d->ui.pin->setEchoMode(QLineEdit::Password);
 
41
    d->ui.puk->setEchoMode(QLineEdit::Password);
 
42
}
 
43
 
 
44
GsmWidget::~GsmWidget()
 
45
{
 
46
    delete d;
 
47
}
 
48
 
 
49
void GsmWidget::readConfig()
 
50
{
 
51
    d->ui.number->setText(d->setting->number());
 
52
    d->ui.username->setText(d->setting->username());
 
53
    d->ui.apn->setText(d->setting->apn());
 
54
    d->ui.network->setText(d->setting->networkid());
 
55
    d->ui.band->setValue(d->setting->band());
 
56
    d->ui.password->setEchoMode(QLineEdit::Password);
 
57
}
 
58
 
 
59
void GsmWidget::chkShowPassToggled()
 
60
{
 
61
    bool on = d->ui.chkShowPass->isChecked();
 
62
    d->ui.password->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
 
63
    d->ui.pin->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
 
64
    d->ui.puk->setEchoMode(on ? QLineEdit::Normal : QLineEdit::Password);
 
65
}
 
66
 
 
67
 
 
68
void GsmWidget::writeConfig()
 
69
{
 
70
    d->setting->setNumber(d->ui.number->text());
 
71
    d->setting->setUsername(d->ui.username->text());
 
72
    d->setting->setPassword(d->ui.password->text());
 
73
    d->setting->setApn(d->ui.apn->text());
 
74
    d->setting->setNetworkid(d->ui.network->text());
 
75
    d->setting->setBand(d->ui.band->value());
 
76
    d->setting->setPin(d->ui.pin->text());
 
77
    d->setting->setPuk(d->ui.puk->text());
 
78
}
 
79
 
 
80
void GsmWidget::readSecrets()
 
81
{
 
82
    d->ui.password->setText(d->setting->password());
 
83
    d->ui.pin->setText(d->setting->pin());
 
84
    d->ui.puk->setText(d->setting->puk());
 
85
 
 
86
}
 
87
 
 
88
// vim: sw=4 sts=4 et tw=100