From 9279804b3f550d8920c1f879aaaca919365d881a Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 17 Oct 2011 17:38:53 +0000 Subject: Add dead-ended knetworkmanager 0.8 source Add copy of same for knetworkmanager 0.9 starting point git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knetworkmanager9@1259314 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../vpn-plugins/strongswan/src/Makefile.am | 12 ++ .../strongswan/src/knetworkmanager-strongswan.cpp | 234 ++++++++++++++++++++ .../strongswan/src/knetworkmanager-strongswan.h | 99 +++++++++ .../vpn-plugins/strongswan/src/strongswanauth.ui | 88 ++++++++ .../vpn-plugins/strongswan/src/strongswanprop.ui | 236 +++++++++++++++++++++ 5 files changed, 669 insertions(+) create mode 100644 knetworkmanager-0.9/vpn-plugins/strongswan/src/Makefile.am create mode 100644 knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.cpp create mode 100644 knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.h create mode 100644 knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanauth.ui create mode 100644 knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanprop.ui (limited to 'knetworkmanager-0.9/vpn-plugins/strongswan/src') diff --git a/knetworkmanager-0.9/vpn-plugins/strongswan/src/Makefile.am b/knetworkmanager-0.9/vpn-plugins/strongswan/src/Makefile.am new file mode 100644 index 0000000..df5bfbc --- /dev/null +++ b/knetworkmanager-0.9/vpn-plugins/strongswan/src/Makefile.am @@ -0,0 +1,12 @@ +INCLUDES = $(PACKAGE_CFLAGS) $(KNETWORKMANAGER_CFLAGS) $(SSWAN_FLAGS) $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = knetworkmanager_strongswan.la +knetworkmanager_strongswan_la_SOURCES = knetworkmanager-strongswan.cpp \ + strongswanprop.ui \ + strongswanauth.ui +noinst_HEADERS = knetworkmanager-strongswan.h +knetworkmanager_strongswan_la_LDFLAGS = -module $(all_libraries) +knetworkmanager_strongswan_la_LIBADD = $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) + diff --git a/knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.cpp b/knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.cpp new file mode 100644 index 0000000..37cee81 --- /dev/null +++ b/knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.cpp @@ -0,0 +1,234 @@ +/*************************************************************************** + * + * knetworkmanager-strongswan.cpp - A NetworkManager frontend for KDE + * + * Author: Thomas Kallenberg , + * + * Strongly based on the Code of Helmut Schaa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "knetworkmanager-strongswan.h" + +typedef KGenericFactory StrongswanPluginFactory; +K_EXPORT_COMPONENT_FACTORY( knetworkmanager_strongswan, StrongswanPluginFactory("knetworkmanager_strongswan")); + + +StrongswanPlugin::StrongswanPlugin(TQObject* parent, const char* name, const TQStringList& args) + : VPNPlugin(parent, name, args) +{ + KLocale* loc = KGlobal::locale(); + loc->insertCatalogue("NetworkManager-strongswan"); +} + +StrongswanPlugin::~StrongswanPlugin() +{ + +} + +VPNConfigWidget* StrongswanPlugin::CreateConfigWidget(TQWidget* parent) +{ + return new StrongswanConfig(parent); +} + +VPNAuthenticationWidget* StrongswanPlugin::CreateAuthenticationWidget(TQWidget* parent) +{ + return new StrongswanAuthentication(parent); +} + + +StrongswanConfig::StrongswanConfig(TQWidget* parent) + : VPNConfigWidget(parent) +{ + TQVBoxLayout* tqlayout = new TQVBoxLayout(this, 1, 1); + _strongswanWidget = new StrongswanConfigWidget(this); + tqlayout->addWidget(_strongswanWidget); + + /* TODO not sure if we need this here */ + this->languageChange(); +} + +StrongswanConfig::~StrongswanConfig() +{ + +} + +void StrongswanConfig::languageChange() +{ + +} + + // usercert agent password userkey +StrongswanConnectionType::CONNECTIONTYPE StrongswanConnectionType::mapString2ConnectionType(int prop) +{ + if (prop == 0) + return psk; + else if (prop == 1) + return key; + else if (prop == 2) + return agent; + return UNKNOWN; +} + +int StrongswanConnectionType::mapConnectionType2String(CONNECTIONTYPE connType) +{ + switch(connType) + { + case psk: + return 0; + case key: + return 1; + case agent: + return 2; + default: + return -1; + } + return -1; +} + +void StrongswanConfig::setVPNData(const TQStringList& routes, const TQMap& properties) +{ + // fill up our inputfields (only textfields atm) + for(TQMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) + { + TQString entry = it.key(); + TQString value = it.data(); + + if (entry == "gateway") + { + _strongswanWidget->gateway->setText(value); + } + else if (entry == "certificate") + { + _strongswanWidget->certificate->setURL(value); + } + else if (entry == "username") + { + _strongswanWidget->username->setText(value); + } + else if (entry == "method") + { + StrongswanConnectionType::CONNECTIONTYPE type = StrongswanConnectionType::mapString2ConnectionType(value.toInt()); + _strongswanWidget->authtype->setCurrentItem(type); + } + // Options + else if (entry == "chkUDPenc") + { + _strongswanWidget->chkUDPenc->setChecked(value == "true"); + } + else if (entry == "chkIPcomp") + { + _strongswanWidget->chkIPcomp->setChecked(value == "true"); + } + else if (entry == "chkIPinner") + { + _strongswanWidget->chkIPinner->setChecked(value == "true"); + } + } +} + +TQMap StrongswanConfig::getVPNProperties() +{ + // build a StingList of properties + TQMap strlist; + + strlist.insert("gateway", TQString(_strongswanWidget->gateway->text())); + strlist.insert("certificate", TQString(_strongswanWidget->certificate->url())); + strlist.insert("username", TQString(_strongswanWidget->username->text())); + strlist.insert("method", + TQString::number(StrongswanConnectionType::mapConnectionType2String((StrongswanConnectionType::CONNECTIONTYPE)_strongswanWidget->authtype->currentItem()))); + + if (_strongswanWidget->chkUDPenc->isChecked()) + strlist.insert("encap", TQString("yes")); + + if (_strongswanWidget->chkIPcomp->isChecked()) + strlist.insert("ipcomp", TQString("yes")); + + if (_strongswanWidget->chkIPinner->isChecked()) + strlist.insert("virtual", TQString("yes")); + + return strlist; +} + +TQStringList StrongswanConfig::getVPNRoutes() +{ + TQStringList strlist; + /*if(_strongswanWidget->chkIPAdresses->isChecked()) + { + strlist = TQStringList::split(" ", _strongswanWidget->routes->text()); + } + */ + return strlist; + +} + +bool StrongswanConfig::hasChanged() +{ + return true; +} + +bool StrongswanConfig::isValid(TQStringList& err_msg) +{ + bool retval = true; + if(_strongswanWidget->gateway->text() == "" || _strongswanWidget->username->text() == "") + { + err_msg.append(i18n("At least the gateway and group has to be supplied.")); + retval = false; + } + return retval; +} + +StrongswanAuthentication::StrongswanAuthentication(TQWidget* parent, char* name) + : VPNAuthenticationWidget(parent, name) +{ + TQVBoxLayout* tqlayout = new TQVBoxLayout(this, 1, 1); + _strongswanAuth = new StrongswanAuthenticationWidget(this); + tqlayout->addWidget(_strongswanAuth); +} + +StrongswanAuthentication::~StrongswanAuthentication() +{ + +} + +TQMap StrongswanAuthentication::getPasswords() +{ + TQMap pwds; + pwds.insert("user", TQString(_strongswanAuth->username->text())); + pwds.insert("password", TQString(_strongswanAuth->password->password())); + return pwds; +} + +void StrongswanAuthentication::setPasswords(TQString name, TQString value) { + if (name == TQString("password")) { + _strongswanAuth->password->erase(); + _strongswanAuth->password->insert(value); + } +} \ No newline at end of file diff --git a/knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.h b/knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.h new file mode 100644 index 0000000..74f82a5 --- /dev/null +++ b/knetworkmanager-0.9/vpn-plugins/strongswan/src/knetworkmanager-strongswan.h @@ -0,0 +1,99 @@ +/*************************************************************************** + * + * knetworkmanager-strongswan.h - A NetworkManager frontend for KDE + * + * Author: Thomas Kallenberg , + * + * Strongly based on the Code of Helmut Schaa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + **************************************************************************/ + +#ifndef KNETWORKMANAGER_STRONGSWAN_H +#define KNETWORKMANAGER_STRONGSWAN_H + +#include +#include +#include +#include + +#include "knetworkmanager-vpnplugin.h" +#include "strongswanprop.h" +#include "strongswanauth.h" + +class StrongswanPlugin : public VPNPlugin +{ + Q_OBJECT + TQ_OBJECT + public: + StrongswanPlugin(TQObject*, const char*, const TQStringList&); + ~StrongswanPlugin(); + + VPNConfigWidget* CreateConfigWidget(TQWidget* parent=0); + VPNAuthenticationWidget* CreateAuthenticationWidget(TQWidget* parent=0); +}; + +class StrongswanConnectionType +{ + public: + enum CONNECTIONTYPE + { + UNKNOWN = -1 + , psk = 0 + , key + , agent + }; + + static CONNECTIONTYPE mapString2ConnectionType(int string); + static int mapConnectionType2String(CONNECTIONTYPE connectionType); +}; + +class StrongswanConfig : public VPNConfigWidget +{ + Q_OBJECT + TQ_OBJECT + public: + void setVPNData(const TQStringList& routes, const TQMap& properties); + TQMap getVPNProperties(); + TQStringList getVPNRoutes(); + bool hasChanged(); + bool isValid(TQStringList& ); + + StrongswanConfig(TQWidget* parent); + ~StrongswanConfig(); + + private: + StrongswanConfigWidget* _strongswanWidget; + + protected slots: + void languageChange(); +}; + +class StrongswanAuthentication : public VPNAuthenticationWidget +{ + Q_OBJECT + TQ_OBJECT + public: + StrongswanAuthentication(TQWidget* parent = NULL, char* name = NULL); + ~StrongswanAuthentication(); + TQMap getPasswords(); + void setPasswords(TQString name, TQString value); + + private: + StrongswanAuthenticationWidget* _strongswanAuth; +}; + +#endif /* KNETWORKMANAGER_STRONGSWAN_H */ diff --git a/knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanauth.ui b/knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanauth.ui new file mode 100644 index 0000000..332d3c8 --- /dev/null +++ b/knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanauth.ui @@ -0,0 +1,88 @@ + +StrongswanAuthenticationWidget + + + StrongswanAuthenticationWidget + + + + 0 + 0 + 372 + 171 + + + + StrongswanAuthentication + + + + unnamed + + + 0 + + + + spacer1 + + + Vertical + + + Expanding + + + + 20 + 100 + + + + + + textLabel1 + + + Password + + + + + textLabel1_2 + + + Username + + + + + password + + + + + username + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 130 + 20 + + + + + + + diff --git a/knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanprop.ui b/knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanprop.ui new file mode 100644 index 0000000..d55c066 --- /dev/null +++ b/knetworkmanager-0.9/vpn-plugins/strongswan/src/strongswanprop.ui @@ -0,0 +1,236 @@ + +StrongswanConfigWidget + + + StrongswanConfigWidget + + + + 0 + 0 + 442 + 260 + + + + StrongswanConfigWidget + + + + unnamed + + + + tabWidget2 + + + + tab + + + Required Information + + + + unnamed + + + + textLabel1 + + + <font size="+1"><b>Gateway</b></font> + + + + + textLabel4 + + + <font size="+1"><b>Authentication</b></font> + + + + + textLabel6 + + + Method + + + + + textLabel2 + + + Address + + + + + textLabel3 + + + Certificate + + + + + textLabel5 + + + Username + + + + + + Key + + + + + PSK + + + + + Agent + + + + authtype + + + + + username + + + + + gateway + + + + 7 + 0 + 0 + 0 + + + + + + certificate + + + + 7 + 0 + 0 + 0 + + + + + + spacer1 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + + + tab + + + Optional Information + + + + unnamed + + + + chkUDPenc + + + Enforce UDP encapsulation + + + + + chkIPcomp + + + Use IP compression + + + + + chkIPinner + + + Request inner IP + + + + + spacer3 + + + Vertical + + + Expanding + + + + 20 + 51 + + + + + + spacer4 + + + Horizontal + + + Expanding + + + + 231 + 31 + + + + + + + + + + + + + klineedit.h + kpushbutton.h + + -- cgit v1.2.1