1
/***************************************************************************
3
* knetworkmanager-pptp.cpp - A NetworkManager frontend for KDE
5
* Copyright (C) 2006 Novell, Inc.
7
* Author: Helmut Schaa <hschaa@suse.de>, <Helmut.Schaa@gmx.de>
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.
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.
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
23
**************************************************************************/
26
#include <qmessagebox.h>
28
#include <kcombobox.h>
29
#include <klineedit.h>
30
#include <kurlrequester.h>
31
#include <qobjectlist.h>
33
#include <qcheckbox.h>
35
#include <kgenericfactory.h>
37
#include "knetworkmanager-pptp.h"
39
typedef KGenericFactory<PPTPPlugin> PPTPPluginFactory;
40
K_EXPORT_COMPONENT_FACTORY( knetworkmanager_pptp, PPTPPluginFactory("knetworkmanager_pptp"));
43
PPTPPlugin::PPTPPlugin(QObject* parent, const char* name, const QStringList& args)
44
: VPNPlugin(parent, name, args)
46
KLocale* loc = KGlobal::locale();
47
loc->insertCatalogue("NetworkManager-pptp");
50
PPTPPlugin::~PPTPPlugin()
55
VPNConfigWidget* PPTPPlugin::CreateConfigWidget(QWidget* parent)
57
return new PPTPConfig(parent);
60
VPNAuthenticationWidget* PPTPPlugin::CreateAuthenticationWidget(QWidget* parent)
62
return new PPTPAuthentication(parent);
66
PPTPConfig::PPTPConfig(QWidget* parent)
67
: VPNConfigWidget(parent)
69
QVBoxLayout* layout = new QVBoxLayout(this, 1, 1);
70
_pptpWidget = new PPTPConfigWidget(this);
71
layout->addWidget(_pptpWidget);
73
connect(_pptpWidget->chkIPAdresses, SIGNAL(toggled(bool)), _pptpWidget->routes, SLOT(setEnabled(bool)));
75
this->languageChange();
78
PPTPConfig::~PPTPConfig()
83
void PPTPConfig::languageChange()
88
void PPTPConfig::setVPNData(const QStringList& routes, const QStringList& properties)
90
// fill up our inputfields (only textfields atm)
91
for(QStringList::ConstIterator it = properties.begin(); it != properties.end(); ++it)
93
QString entry = (*it);
95
if (entry == "remote")
97
_pptpWidget->gateway->setText(*(++it));
99
else if (entry == "username")
101
_pptpWidget->username->setText(*(++it));
103
else if (entry == "comp-mppc")
105
_pptpWidget->chkUseMPPC->setChecked( (*(++it) == "yes") );
107
else if (entry == "encrypt-mppe")
109
_pptpWidget->chkUseMPPE->setChecked( (*(++it) == "yes") );
116
_pptpWidget->chkIPAdresses->setChecked(true);
117
_pptpWidget->routes->setText(routes.join(" "));
121
QStringList PPTPConfig::getVPNProperties()
123
// build a StingList of properties
125
strlist.append("remote");
126
strlist.append(_pptpWidget->gateway->text());
128
strlist.append("username");
129
strlist.append(_pptpWidget->username->text());
131
strlist.append("comp-mppc");
132
strlist.append(_pptpWidget->chkUseMPPC->isChecked() ? "yes" : "no");
134
strlist.append("encrypt-mppe");
135
strlist.append(_pptpWidget->chkUseMPPE->isChecked() ? "yes" : "no");
140
QStringList PPTPConfig::getVPNRoutes()
143
if(_pptpWidget->chkIPAdresses->isChecked())
145
strlist = QStringList::split(" ", _pptpWidget->routes->text());
151
bool PPTPConfig::hasChanged()
156
bool PPTPConfig::isValid(QStringList& err_msg)
159
if(_pptpWidget->gateway->text() == "" || _pptpWidget->username->text() == "")
161
err_msg.append(i18n("At least the gateway and username has to be supplied."));
167
PPTPAuthentication::PPTPAuthentication(QWidget* parent, char* name)
168
: VPNAuthenticationWidget(parent, name)
170
QVBoxLayout* layout = new QVBoxLayout(this, 1, 1);
171
_pptpAuth = new PPTPAuthenticationWidget(this);
172
layout->addWidget(_pptpAuth);
175
PPTPAuthentication::~PPTPAuthentication()
180
QStringList PPTPAuthentication::getPasswords()
183
pwds.push_back(_pptpAuth->username->text());
184
pwds.push_back(_pptpAuth->password->password());