~ubuntu-branches/ubuntu/saucy/plasma-nm/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/editor/pppwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-08-16 19:07:09 UTC
  • Revision ID: package-import@ubuntu.com-20130816190709-ef9ydm9skigmg15l
Tags: upstream-0.0~git20130816
ImportĀ upstreamĀ versionĀ 0.0~git20130816

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
 
3
 
 
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.
 
11
 
 
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.
 
16
 
 
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/>.
 
19
*/
 
20
 
 
21
#include "pppwidget.h"
 
22
#include "ui_ppp.h"
 
23
 
 
24
#include <NetworkManagerQt/PppSetting>
 
25
 
 
26
PPPWidget::PPPWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
 
27
    SettingWidget(setting, parent, f),
 
28
    m_ui(new Ui::PPPWidget)
 
29
{
 
30
    m_ui->setupUi(this);
 
31
 
 
32
    KAcceleratorManager::manage(this);
 
33
 
 
34
    if (setting)
 
35
        loadConfig(setting);
 
36
}
 
37
 
 
38
PPPWidget::~PPPWidget()
 
39
{
 
40
    delete m_ui;
 
41
}
 
42
 
 
43
void PPPWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
 
44
{
 
45
    NetworkManager::PppSetting::Ptr pppSetting = setting.staticCast<NetworkManager::PppSetting>();
 
46
 
 
47
    m_ui->eap->setChecked(!pppSetting->refuseEap());
 
48
    m_ui->pap->setChecked(!pppSetting->refusePap());
 
49
    m_ui->chap->setChecked(!pppSetting->refuseChap());
 
50
    m_ui->mschap->setChecked(!pppSetting->refuseMschap());
 
51
    m_ui->mschapv2->setChecked(!pppSetting->refuseMschapv2());
 
52
 
 
53
    m_ui->mppe->setChecked(pppSetting->requireMppe());
 
54
    m_ui->mppe128->setChecked(pppSetting->requireMppe128());
 
55
    m_ui->mppeStateful->setChecked(pppSetting->mppeStateful());
 
56
 
 
57
    m_ui->bsdComp->setChecked(!pppSetting->noBsdComp());
 
58
    m_ui->deflateComp->setChecked(!pppSetting->noDeflate());
 
59
    m_ui->tcpComp->setChecked(!pppSetting->noVjComp());
 
60
 
 
61
    if (pppSetting->lcpEchoInterval() > 0) {
 
62
        m_ui->senddEcho->setChecked(true);
 
63
    } else {
 
64
        m_ui->senddEcho->setChecked(false);
 
65
    }
 
66
}
 
67
 
 
68
QVariantMap PPPWidget::setting(bool agentOwned) const
 
69
{
 
70
    Q_UNUSED(agentOwned);
 
71
 
 
72
    NetworkManager::PppSetting pppSetting;
 
73
 
 
74
    pppSetting.setRefuseEap(!m_ui->eap->isChecked());
 
75
    pppSetting.setRefusePap(!m_ui->pap->isChecked());
 
76
    pppSetting.setRefuseChap(!m_ui->chap->isChecked());
 
77
    pppSetting.setRefuseMschap(!m_ui->mschap->isChecked());
 
78
    pppSetting.setRefuseMschapv2(!m_ui->mschapv2->isChecked());
 
79
 
 
80
    pppSetting.setRequireMppe(m_ui->mppe->isChecked());
 
81
    pppSetting.setRequireMppe128(m_ui->mppe128->isChecked());
 
82
    pppSetting.setMppeStateful(m_ui->mppeStateful->isChecked());
 
83
 
 
84
    pppSetting.setNoBsdComp(!m_ui->bsdComp->isChecked());
 
85
    pppSetting.setNoDeflate(!m_ui->deflateComp->isChecked());
 
86
    pppSetting.setNoVjComp(!m_ui->tcpComp->isChecked());
 
87
 
 
88
    if (m_ui->senddEcho->isChecked()) {
 
89
        pppSetting.setLcpEchoFailure(5);
 
90
        pppSetting.setLcpEchoInterval(30);
 
91
    }
 
92
 
 
93
    return pppSetting.toMap();
 
94
}