~ubuntu-branches/ubuntu/oneiric/knetworkmanager/oneiric

« back to all changes in this revision

Viewing changes to knetworkmanager/vpn-plugins/pptp/src/knetworkmanager-pptp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-07-14 14:05:44 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080714140544-yjhxgrdwartk3kx7
Tags: 1:0.7svn830754-0ubuntu1
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *
3
 
 * knetworkmanager-pptp.cpp - A NetworkManager frontend for KDE 
4
 
 *
5
 
 * Copyright (C) 2006 Novell, Inc.
6
 
 *
7
 
 * Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or modify
10
 
 * it under the terms of the GNU General Public License as published by
11
 
 * the Free Software Foundation; either version 2 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 * 
19
 
 * You should have received a copy of the GNU General Public License
20
 
 * along with this program; if not, write to the Free Software
21
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 
 *
23
 
 **************************************************************************/
24
 
 
25
 
#include <klocale.h>
26
 
#include <qmessagebox.h>
27
 
#include <qbutton.h>
28
 
#include <kcombobox.h>
29
 
#include <klineedit.h>
30
 
#include <kurlrequester.h>
31
 
#include <qobjectlist.h>
32
 
#include <qobject.h>
33
 
#include <qcheckbox.h>
34
 
#include <kpassdlg.h>
35
 
#include <kgenericfactory.h>
36
 
 
37
 
#include "knetworkmanager-pptp.h"
38
 
 
39
 
typedef KGenericFactory<PPTPPlugin> PPTPPluginFactory;
40
 
K_EXPORT_COMPONENT_FACTORY( knetworkmanager_pptp, PPTPPluginFactory("knetworkmanager_pptp"));
41
 
 
42
 
 
43
 
PPTPPlugin::PPTPPlugin(QObject* parent, const char* name, const QStringList& args) 
44
 
        : VPNPlugin(parent, name, args)
45
 
{
46
 
        KLocale* loc = KGlobal::locale();
47
 
        loc->insertCatalogue("NetworkManager-pptp");
48
 
}
49
 
 
50
 
PPTPPlugin::~PPTPPlugin()
51
 
{
52
 
 
53
 
}
54
 
 
55
 
VPNConfigWidget* PPTPPlugin::CreateConfigWidget(QWidget* parent)
56
 
{
57
 
        return new PPTPConfig(parent);
58
 
}
59
 
 
60
 
VPNAuthenticationWidget* PPTPPlugin::CreateAuthenticationWidget(QWidget* parent)
61
 
{
62
 
        return new PPTPAuthentication(parent);
63
 
}
64
 
 
65
 
 
66
 
PPTPConfig::PPTPConfig(QWidget* parent)
67
 
        : VPNConfigWidget(parent)
68
 
{
69
 
        QVBoxLayout* layout = new QVBoxLayout(this, 1, 1);
70
 
        _pptpWidget = new PPTPConfigWidget(this);
71
 
        layout->addWidget(_pptpWidget);
72
 
        
73
 
        connect(_pptpWidget->chkIPAdresses, SIGNAL(toggled(bool)), _pptpWidget->routes, SLOT(setEnabled(bool)));
74
 
 
75
 
        this->languageChange();
76
 
}
77
 
 
78
 
PPTPConfig::~PPTPConfig()
79
 
{
80
 
 
81
 
}
82
 
 
83
 
void PPTPConfig::languageChange()
84
 
{
85
 
 
86
 
}
87
 
 
88
 
void PPTPConfig::setVPNData(const QStringList& routes, const QStringList& properties)
89
 
{
90
 
        // fill up our inputfields (only textfields atm)
91
 
        for(QStringList::ConstIterator it = properties.begin(); it != properties.end(); ++it)
92
 
        {
93
 
                QString entry = (*it);
94
 
                
95
 
                if (entry == "remote")
96
 
                {
97
 
                        _pptpWidget->gateway->setText(*(++it));
98
 
                }
99
 
                else if (entry == "username")
100
 
                {
101
 
                        _pptpWidget->username->setText(*(++it));
102
 
                }
103
 
                else if (entry == "comp-mppc")
104
 
                {
105
 
                        _pptpWidget->chkUseMPPC->setChecked( (*(++it) == "yes") );
106
 
                }
107
 
                else if (entry == "encrypt-mppe")
108
 
                {
109
 
                        _pptpWidget->chkUseMPPE->setChecked( (*(++it) == "yes") );
110
 
                }
111
 
        }
112
 
 
113
 
        // set routes
114
 
        if (!routes.empty())
115
 
        {
116
 
                _pptpWidget->chkIPAdresses->setChecked(true);
117
 
                _pptpWidget->routes->setText(routes.join(" "));
118
 
        }
119
 
}
120
 
 
121
 
QStringList PPTPConfig::getVPNProperties()
122
 
{
123
 
        // build a StingList of properties
124
 
        QStringList strlist;
125
 
        strlist.append("remote");       
126
 
        strlist.append(_pptpWidget->gateway->text());
127
 
 
128
 
        strlist.append("username");     
129
 
        strlist.append(_pptpWidget->username->text());
130
 
 
131
 
        strlist.append("comp-mppc");
132
 
        strlist.append(_pptpWidget->chkUseMPPC->isChecked() ? "yes" : "no");
133
 
 
134
 
        strlist.append("encrypt-mppe");
135
 
        strlist.append(_pptpWidget->chkUseMPPE->isChecked() ? "yes" : "no");
136
 
 
137
 
        return strlist;
138
 
}
139
 
 
140
 
QStringList PPTPConfig::getVPNRoutes()
141
 
{
142
 
        QStringList strlist;
143
 
        if(_pptpWidget->chkIPAdresses->isChecked())
144
 
        {
145
 
                strlist = QStringList::split(" ", _pptpWidget->routes->text());
146
 
        }       
147
 
        return strlist;
148
 
 
149
 
}
150
 
 
151
 
bool PPTPConfig::hasChanged()
152
 
{
153
 
        return true;
154
 
}
155
 
 
156
 
bool PPTPConfig::isValid(QStringList& err_msg)
157
 
{
158
 
        bool retval = true;
159
 
        if(_pptpWidget->gateway->text() == "" || _pptpWidget->username->text() == "")
160
 
        {
161
 
                err_msg.append(i18n("At least the gateway and username has to be supplied."));
162
 
                retval = false;
163
 
        }
164
 
        return retval;
165
 
}
166
 
 
167
 
PPTPAuthentication::PPTPAuthentication(QWidget* parent, char* name)
168
 
        : VPNAuthenticationWidget(parent, name)
169
 
{
170
 
        QVBoxLayout* layout = new QVBoxLayout(this, 1, 1);
171
 
        _pptpAuth = new PPTPAuthenticationWidget(this);
172
 
        layout->addWidget(_pptpAuth);
173
 
}
174
 
 
175
 
PPTPAuthentication::~PPTPAuthentication()
176
 
{
177
 
 
178
 
}
179
 
 
180
 
QStringList PPTPAuthentication::getPasswords()
181
 
{
182
 
        QStringList pwds;
183
 
        pwds.push_back(_pptpAuth->username->text());
184
 
        pwds.push_back(_pptpAuth->password->password());
185
 
        return pwds;
186
 
}