diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-17 17:38:53 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-17 17:38:53 +0000 |
commit | 1e0dd58661c9097fb41218ee7e3515f2d8ba8dac (patch) | |
tree | a263b4ad0c1f7fba6013f5d9854db4cb4962df82 /knetworkmanager-0.8/vpn-plugins/openvpn | |
download | knetworkmanager8-1e0dd58661c9097fb41218ee7e3515f2d8ba8dac.tar.gz knetworkmanager8-1e0dd58661c9097fb41218ee7e3515f2d8ba8dac.zip |
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/knetworkmanager8@1259314 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knetworkmanager-0.8/vpn-plugins/openvpn')
9 files changed, 1433 insertions, 0 deletions
diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/AUTHORS b/knetworkmanager-0.8/vpn-plugins/openvpn/AUTHORS new file mode 100644 index 0000000..f4340ea --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/AUTHORS @@ -0,0 +1,2 @@ +Helmut Schaa <[email protected]>, <[email protected]> +Thomas Kallenberg <[email protected]> <[email protected]> diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/Makefile.am b/knetworkmanager-0.8/vpn-plugins/openvpn/Makefile.am new file mode 100644 index 0000000..81ae93b --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = src + +service_DATA = knetworkmanager_openvpn.desktop +servicedir = $(kde_servicesdir) + diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/configure.in.in b/knetworkmanager-0.8/vpn-plugins/openvpn/configure.in.in new file mode 100644 index 0000000..00b2409 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/configure.in.in @@ -0,0 +1,14 @@ +KNETWORKMANAGER_OPENVPN_VERSION=0.1 +AC_DEFINE_UNQUOTED(KNETWORKMANAGER_OPENVPN_VERSION, $KNETWORKMANAGER_OPENVPN_VERSION, [KNetworkManager OpenVPN Plugin Version]) +AC_DEFINE_UNQUOTED(KNETWORKMANAGER_OPENVPN_VERSION_STRING, "$KNETWORKMANAGER_OPENVPN_VERSION", [KNetworkManager OpenVPN Plugin Version String]) + +PKG_CHECK_MODULES(DBUS_TQT, [dbus-1-tqt >= 0.8.1], [], [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([TQT dbus bindings missing]) +]) + +OPENVPN_CFLAGS="$DBUS_TQT_CFLAGS" +OPENVPN_LIBS="$DBUS_TQT_LIBS" + +AC_SUBST(OPENVPN_CFLAGS) +AC_SUBST(OPENVPN_LIBS) diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/knetworkmanager_openvpn.desktop b/knetworkmanager-0.8/vpn-plugins/openvpn/knetworkmanager_openvpn.desktop new file mode 100644 index 0000000..a6abde3 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/knetworkmanager_openvpn.desktop @@ -0,0 +1,25 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Service +Icon= +ServiceTypes=KNetworkManager/VPNPlugin +X-KDE-Library=knetworkmanager_openvpn +X-NetworkManager-Services=openvpn +X-KDE-PluginInfo-Author=Helmut Schaa +X-KDE-PluginInfo-Name=knetworkmanager_openvpn +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website= +X-KDE-PluginInfo-Category=VPNService +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +Name=OpenVPN +Name[bn]=ওপেন-ভিপিএন +Name[ca]=VPN oberta +Name[xx]=xxOpenVPNxx +Comment=OpenVPN +Comment[bn]=ওপেন-ভিপিএন +Comment[ca]=VPN oberta +Comment[xx]=xxOpenVPNxx + diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/src/Makefile.am b/knetworkmanager-0.8/vpn-plugins/openvpn/src/Makefile.am new file mode 100644 index 0000000..af37dc3 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/src/Makefile.am @@ -0,0 +1,12 @@ +INCLUDES = $(KNETWORKMANAGER_CFLAGS) $(OPENVPN_CFLAGS) $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = knetworkmanager_openvpn.la +knetworkmanager_openvpn_la_SOURCES = knetworkmanager-openvpn.cpp \ + openvpnprop.ui \ + openvpnauth.ui +noinst_HEADERS = knetworkmanager-openvpn.h +knetworkmanager_openvpn_la_LDFLAGS = -module $(all_libraries) +knetworkmanager_openvpn_la_LIBADD = $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) + diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/src/knetworkmanager-openvpn.cpp b/knetworkmanager-0.8/vpn-plugins/openvpn/src/knetworkmanager-openvpn.cpp new file mode 100644 index 0000000..0593a08 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/src/knetworkmanager-openvpn.cpp @@ -0,0 +1,566 @@ +/*************************************************************************** + * + * knetworkmanager-openvpn.cpp - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa <[email protected]>, <[email protected]> + * + * 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 <klocale.h> +#include <tqmessagebox.h> +#include <tqbutton.h> +#include <kcombobox.h> +#include <klineedit.h> +#include <kurlrequester.h> +#include <tqobjectlist.h> +#include <tqobject.h> +#include <tqcheckbox.h> +#include <kpassdlg.h> +#include <kgenericfactory.h> +#include <tqwidgetstack.h> +#include <tqfileinfo.h> +#include <tqhostaddress.h> +#include <tqdbusdata.h> + +#include "knetworkmanager-openvpn.h" + +typedef KGenericFactory<OpenVPNPlugin> OpenVPNPluginFactory; +K_EXPORT_COMPONENT_FACTORY( knetworkmanager_openvpn, OpenVPNPluginFactory("knetworkmanager_openvpn")); + +/************************************ +* OpenVPNPlugin +************************************/ +OpenVPNPlugin::OpenVPNPlugin(TQObject* parent, const char* name, const TQStringList& args) + : VPNPlugin(parent, name, args) +{ + +} + +OpenVPNPlugin::~OpenVPNPlugin() +{ + +} + +VPNConfigWidget* OpenVPNPlugin::CreateConfigWidget(TQWidget* parent) +{ + return new OpenVPNConfig(parent); +} + +VPNAuthenticationWidget* OpenVPNPlugin::CreateAuthenticationWidget(TQWidget* parent) +{ + return new OpenVPNAuthentication(parent); +} + +/************************************ +* OpenVPNConnectionType +************************************/ +OpenVPNConnectionType::CONNECTIONTYPE OpenVPNConnectionType::mapString2ConnectionType(int prop) +{ + if (prop == 0) + return X509; + else if (prop == 1) + return SHARED_KEY; + else if (prop == 2) + return PASSWORD; + else if (prop == 3) + return X509USERPASS; + return UNKNOWN; +} + +int OpenVPNConnectionType::mapConnectionType2String(CONNECTIONTYPE connType) +{ + switch(connType) + { + case X509: + return 0; + case SHARED_KEY: + return 1; + case PASSWORD: + return 2; + case X509USERPASS: + return 3; + default: + return -1; + } + return -1; +} + +/************************************ +* OpenVPNConfig +************************************/ + +OpenVPNConfig::OpenVPNConfig(TQWidget* parent) + : VPNConfigWidget(parent) +{ + TQVBoxLayout* tqlayout = new TQVBoxLayout(this, 1, 1); + _openvpnWidget = new OpenVPNConfigWidget(this); + tqlayout->addWidget(_openvpnWidget); + + connect(_openvpnWidget->chkUseCipher, TQT_SIGNAL(toggled(bool)), _openvpnWidget->cboCipher, TQT_SLOT(setEnabled(bool))); + connect(_openvpnWidget->chkUseTLS, TQT_SIGNAL(toggled(bool)), _openvpnWidget->cboDirection, TQT_SLOT(setEnabled(bool))); + connect(_openvpnWidget->chkUseTLS, TQT_SIGNAL(toggled(bool)), _openvpnWidget->editTLSAuth, TQT_SLOT(setEnabled(bool))); + connect(_openvpnWidget->chkIPAdresses, TQT_SIGNAL(toggled(bool)), _openvpnWidget->routes, TQT_SLOT(setEnabled(bool))); + + // add all Cipher modes to the Combobox + getCipherModes(); + + // switch to the right configuration interface when selecting the connection type + connect(_openvpnWidget->cboConnectionType, TQT_SIGNAL( activated(int)), _openvpnWidget->widgetStack, TQT_SLOT(raiseWidget(int))); + this->languageChange(); +} + +OpenVPNConfig::~OpenVPNConfig() +{ + +} + +void OpenVPNConfig::languageChange() +{ + _openvpnWidget->cboConnectionType->insertItem(i18n("X.509 Certificates"), OpenVPNConnectionType::X509 ); + _openvpnWidget->cboConnectionType->insertItem(i18n("Pre-shared key") , OpenVPNConnectionType::SHARED_KEY ); + _openvpnWidget->cboConnectionType->insertItem(i18n("Password Authentication") , OpenVPNConnectionType::PASSWORD ); + _openvpnWidget->cboConnectionType->insertItem(i18n("X.509 with Password Authentication") , OpenVPNConnectionType::X509USERPASS ); + + _openvpnWidget->cboDirection->insertItem(i18n("none")); + _openvpnWidget->cboDirection->insertItem(i18n("0")); + _openvpnWidget->cboDirection->insertItem(i18n("1")); +} + +TQString OpenVPNConfig::findOpenVPNBinary() +{ + static const char *openvpn_binary_paths[] = + { + "/usr/sbin/openvpn", + "/sbin/openvpn", + NULL + }; + + const char **openvpn_binary = openvpn_binary_paths; + + while (*openvpn_binary != NULL) { + if ( TQFileInfo(*openvpn_binary).exists()) + break; + openvpn_binary++; + } + + return *openvpn_binary; +} + + +void OpenVPNConfig::receiveCipherData(KProcess*, char* buffer, int len) +{ + // add possible cipher modes to the combobox + TQStringList cipherModes = TQStringList::split("\n", TQString::tqfromLatin1(buffer, len), false ); + for (TQStringList::ConstIterator it = cipherModes.begin(); it != cipherModes.end(); ++it) + { + _openvpnWidget->cboCipher->insertItem((*it)); + } +} + +void OpenVPNConfig::getCipherModes() +{ + // get all possible cipher modes + TQString openvpn = findOpenVPNBinary(); + if (!openvpn.isNull()) + { + KProcess* cipherHelper = new KProcess(); + cipherHelper->setUseShell(true, "/bin/sh"); + *cipherHelper << TQString::tqfromLatin1("%1 --show-ciphers | awk '/^[A-Z][A-Z0-9]+-/ { print $1 }'").tqarg(openvpn); + connect (cipherHelper, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), this, TQT_SLOT(receiveCipherData(KProcess*, char*, int))); + kdDebug() << "starting openvpn to get cipher modes" << endl; + if (!cipherHelper->start(KProcess::Block, KProcess::Stdout)) + kdDebug() << "error starting openvpn" << endl; + } + +} + +void OpenVPNConfig::setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties) +{ + // fill up our inputfields + for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it) + { + TQString entry = it.key(); + TQString value = it.data(); + + if (entry == "connection-type") + { + OpenVPNConnectionType::CONNECTIONTYPE type = OpenVPNConnectionType::mapString2ConnectionType(value.toInt()); + _openvpnWidget->cboConnectionType->setCurrentItem(type); + _openvpnWidget->widgetStack->raiseWidget(type); + } + else if (entry == "remote") + { + _openvpnWidget->gateway->setText(value); + } + else if (entry == "port") + { + if (value.toInt() > 0) + { + _openvpnWidget->port->setText(value); + _openvpnWidget->chkDefaultPort->setChecked(false); + } + else + { + _openvpnWidget->chkDefaultPort->setChecked(true); + } + } + else if (entry == "proto" || entry == "proto-tcp") + { + _openvpnWidget->chkUseTCP->setChecked( value == "yes"); + } + else if (entry == "ca") + { + _openvpnWidget->editCA->setURL(value); + } + else if (entry == "cert") + { + _openvpnWidget->editCert->setURL(value); + } + else if (entry == "key") + { + _openvpnWidget->editKey->setURL(value); + } + else if (entry == "cipher") + { + _openvpnWidget->chkUseCipher->setChecked(true); + _openvpnWidget->cboCipher->setCurrentItem(value); + } + else if (entry == "comp-lzo") + { + _openvpnWidget->chkUseLZO->setChecked(value == "true"); + } + else if (entry == "shared-key" || entry == "static-key") + { + _openvpnWidget->editSharedKey->setURL(value); + } + else if (entry == "username") + { + _openvpnWidget->editUsername->setText(value); + } + else if (entry == "local-ip") + { + _openvpnWidget->editLocalIP->setText(value); + } + else if (entry == "remote-ip") + { + _openvpnWidget->editRemoteIP->setText(value); + } + else if (entry == "dev" || entry == "tap-dev") { + _openvpnWidget->chkUseTAP->setChecked(value == "true"); + } + else if (entry == "ta") + { + _openvpnWidget->chkUseTLS->setChecked(true); + _openvpnWidget->editTLSAuth->setURL(value); + } + else if (entry == "ta-dir") + { + _openvpnWidget->cboDirection->setCurrentItem(value); + } + else + { + kdDebug() << TQString("OpenVPN: Property '%1' not handled").tqarg(entry) << endl; + } + } + + // set routes + if (!routes.empty()) + { + _openvpnWidget->chkIPAdresses->setChecked(true); + _openvpnWidget->routes->setText(routes.join(" ")); + } +} + +TQMap<TQString, TQString>OpenVPNConfig::getVPNProperties() +{ + // build a StingList of properties + TQMap<TQString, TQString> strlist; + + strlist.insert("connection-type", TQString::number(OpenVPNConnectionType::mapConnectionType2String((OpenVPNConnectionType::CONNECTIONTYPE)_openvpnWidget->cboConnectionType->currentItem()))); + strlist.insert("remote", TQString(_openvpnWidget->gateway->text())); + + // port is not necessary + if (!_openvpnWidget->port->text().isEmpty() && !_openvpnWidget->chkDefaultPort->isChecked()) + strlist.insert("port", _openvpnWidget->port->text()); + + strlist.insert("ca", TQString(_openvpnWidget->editCA->url())); + strlist.insert("cert",TQString(_openvpnWidget->editCert->url() )); + strlist.insert("key", TQString(_openvpnWidget->editKey->url())); + + if (_openvpnWidget->chkUseCipher->isChecked()) + strlist.insert("cipher", TQString(_openvpnWidget->cboCipher->currentText())); + + if (_openvpnWidget->chkUseLZO->isChecked()) + strlist.insert("comp-lzo", TQString("true")); + else + strlist.insert("comp-lzo", TQString("false")); + + strlist.insert("static-key", TQString(_openvpnWidget->editSharedKey->url())); + strlist.insert("username", TQString(_openvpnWidget->editUsername->text())); + strlist.insert("local-ip", TQString(_openvpnWidget->editLocalIP->text())); + strlist.insert("remote-ip", TQString(_openvpnWidget->editRemoteIP->text())); + + if (_openvpnWidget->chkUseTAP->isChecked()) { + strlist.insert("tap-dev", "true"); + strlist.insert("proto-tcp", "true"); + } else { + strlist.insert("tap-dev", "false"); + strlist.insert("proto-tcp", "false"); + } + + if (_openvpnWidget->chkUseTLS->isChecked()) + strlist.insert("ta", TQString(_openvpnWidget->editTLSAuth->url())); + + strlist.insert("ta-dir", TQString(_openvpnWidget->cboDirection->currentText())); + + return strlist; +} + +TQStringList OpenVPNConfig::getVPNRoutes() +{ + TQStringList strlist; + if(_openvpnWidget->chkIPAdresses->isChecked()) + { + strlist = TQStringList::split(" ", _openvpnWidget->routes->text()); + } + return strlist; +} + +bool OpenVPNConfig::hasChanged() +{ + return true; +} + +bool OpenVPNConfig::isValid(TQStringList& err_msg) +{ + bool retval = true; + + // check gateway + if (_openvpnWidget->gateway->text().isEmpty()) + { + err_msg.append(i18n("You have to specify a gateway")); + retval = false; + } + + bool ok = false; + _openvpnWidget->port->text().toULong(&ok); + if (!ok && !_openvpnWidget->port->text().isEmpty() ) + { + err_msg.append(i18n("The port number has to be numeric")); + retval = false; + } + + switch(_openvpnWidget->cboConnectionType->currentItem()) + { + case OpenVPNConnectionType::X509: + // check if ca file is correct + if (_openvpnWidget->editCA->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no CA file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editCA->url()).isFile()) + { + retval = false; + err_msg.append(i18n("CA file not valid")); + } + + // check if cert file is correct + if (_openvpnWidget->editCert->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no CERT file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editCert->url()).isFile()) + { + retval = false; + err_msg.append(i18n("CERT file not valid")); + } + + // check if key file is correct + if (_openvpnWidget->editKey->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no Key file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editKey->url()).isFile()) + { + retval = false; + err_msg.append(i18n("Key file not valid")); + } + + break; + + + case OpenVPNConnectionType::SHARED_KEY: + // check if a shared key is selected + if (_openvpnWidget->editSharedKey->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("Please provide a valid shared key")); + } + // check if the shared key file exists + else if (!TQFileInfo(_openvpnWidget->editSharedKey->url()).exists()) + { + retval = false; + err_msg.append(i18n("Please provide a valid shared key")); + } + + // check if local ip is valid + if (!TQHostAddress().setAddress(_openvpnWidget->editLocalIP->text())) + { + retval = false; + err_msg.append(i18n("local IP is invalid")); + } + // check if remote ip is valid + if (!TQHostAddress().setAddress(_openvpnWidget->editRemoteIP->text())) + { + retval = false; + err_msg.append(i18n("remote IP is invalid")); + } + + break; + case OpenVPNConnectionType::PASSWORD: + // check if username is suplied + if (_openvpnWidget->editUsername->text().isEmpty()) + { + retval = false; + err_msg.append(i18n("no username provided")); + } + + // check if ca file is correct + if (_openvpnWidget->editCA->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no CA file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editCA->url()).isFile()) + { + retval = false; + err_msg.append(i18n("CA file not valid")); + } + + break; + + + case OpenVPNConnectionType::X509USERPASS: + // check if username is suplied + if (_openvpnWidget->editUsername->text().isEmpty()) + { + retval = false; + err_msg.append(i18n("no username provided")); + } + + // check if ca file is correct + if (_openvpnWidget->editCA->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no CA file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editCA->url()).isFile()) + { + retval = false; + err_msg.append(i18n("CA file not valid")); + } + + // check if cert file is correct + if (_openvpnWidget->editCert->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no CERT file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editCert->url()).isFile()) + { + retval = false; + err_msg.append(i18n("CERT file not valid")); + } + + // check if key file is correct + if (_openvpnWidget->editKey->url().isEmpty()) + { + retval = false; + err_msg.append(i18n("no Key file provided")); + } + else if (!TQFileInfo(_openvpnWidget->editKey->url()).isFile()) + { + retval = false; + err_msg.append(i18n("Key file not valid")); + } + break; + } + + + return retval; +} + +/************************************ +* OpenVPNAuthentication +************************************/ + +OpenVPNAuthentication::OpenVPNAuthentication(TQWidget* parent, char* name) + : VPNAuthenticationWidget(parent, name) +{ + TQVBoxLayout* tqlayout = new TQVBoxLayout(this, 1, 1); + _openvpnAuth = new OpenVPNAuthenticationWidget(this); + tqlayout->addWidget(_openvpnAuth); +} + +OpenVPNAuthentication::~OpenVPNAuthentication() +{ + +} + +void OpenVPNAuthentication::setVPNData(const TQStringList& /*routes*/, const TQMap<TQString, TQString>& properties) +{ + // find the connection type property + for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it) + { + if (it.key() == "connection-type") + { + _connectionType = OpenVPNConnectionType::mapString2ConnectionType(it.data().toInt()); + break; + } + } +} + +TQMap<TQString, TQString> OpenVPNAuthentication::getPasswords() +{ + TQMap<TQString, TQString> pwds; + if ((_connectionType == OpenVPNConnectionType::PASSWORD) || (_connectionType == OpenVPNConnectionType::X509USERPASS)) + pwds.insert("password", TQString(_openvpnAuth->editUserPassword->password())); + else + pwds.insert("no-secret", TQString("true")); + + return pwds; +} + +void OpenVPNAuthentication::setPasswords(TQString name, TQString value) { + if (name == TQString("password")) { + _openvpnAuth->editUserPassword->erase(); + _openvpnAuth->editUserPassword->insert(value); + } +} + +bool OpenVPNAuthentication::needsUserInteraction() +{ + if ((_connectionType == OpenVPNConnectionType::PASSWORD) || (_connectionType == OpenVPNConnectionType::X509USERPASS)) + return true; + return false; +} + diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/src/knetworkmanager-openvpn.h b/knetworkmanager-0.8/vpn-plugins/openvpn/src/knetworkmanager-openvpn.h new file mode 100644 index 0000000..c78f524 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/src/knetworkmanager-openvpn.h @@ -0,0 +1,110 @@ +/*************************************************************************** + * + * knetworkmanager-openvpn.h - A NetworkManager frontend for KDE + * + * Copyright (C) 2006 Novell, Inc. + * + * Author: Helmut Schaa <[email protected]>, <[email protected]> + * + * 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_OPENVPN_H +#define KNETWORKMANAGER_OPENVPN_H + +#include <tqmap.h> +#include <tqstring.h> +#include <tqwidget.h> +#include <tqlayout.h> +#include <kprocess.h> + +#include "knetworkmanager-vpnplugin.h" +#include "openvpnprop.h" +#include "openvpnauth.h" + +class OpenVPNPlugin : public VPNPlugin +{ + Q_OBJECT + TQ_OBJECT + public: + OpenVPNPlugin(TQObject*, const char*, const TQStringList&); + ~OpenVPNPlugin(); + + VPNConfigWidget* CreateConfigWidget(TQWidget* parent=0); + VPNAuthenticationWidget* CreateAuthenticationWidget(TQWidget* parent=0); +}; + +class OpenVPNConnectionType +{ + public: + enum CONNECTIONTYPE + { + UNKNOWN = -1 + , X509 = 0 + , SHARED_KEY + , PASSWORD + , X509USERPASS + }; + + static CONNECTIONTYPE mapString2ConnectionType(int string); + static int mapConnectionType2String(CONNECTIONTYPE connectionType); +}; + +class OpenVPNConfig : public VPNConfigWidget +{ + Q_OBJECT + TQ_OBJECT + public: + void setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties); + TQMap<TQString, TQString> getVPNProperties(); + TQStringList getVPNRoutes(); + bool hasChanged(); + bool isValid(TQStringList& ); + + OpenVPNConfig(TQWidget* parent); + ~OpenVPNConfig(); + + public slots: + void receiveCipherData(KProcess*, char*, int); + + private: + OpenVPNConfigWidget* _openvpnWidget; + + void getCipherModes(); + TQString findOpenVPNBinary(); + + protected slots: + void languageChange(); +}; + +class OpenVPNAuthentication : public VPNAuthenticationWidget +{ + Q_OBJECT + TQ_OBJECT + public: + OpenVPNAuthentication(TQWidget* parent = NULL, char* name = NULL); + ~OpenVPNAuthentication(); + void setVPNData(const TQStringList&, const TQMap<TQString, TQString>&); + TQMap<TQString, TQString> getPasswords(); + void setPasswords(TQString name, TQString value); + bool needsUserInteraction(); + + private: + OpenVPNAuthenticationWidget* _openvpnAuth; + OpenVPNConnectionType::CONNECTIONTYPE _connectionType; +}; + +#endif /* KNETWORKMANAGER_OPENVPN_H */ diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/src/openvpnauth.ui b/knetworkmanager-0.8/vpn-plugins/openvpn/src/openvpnauth.ui new file mode 100644 index 0000000..4cb6578 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/src/openvpnauth.ui @@ -0,0 +1,80 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>OpenVPNAuthenticationWidget</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>OpenVPNAuthenticationWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>372</width> + <height>171</height> + </rect> + </property> + <property name="caption"> + <string>OpenVPNAuthentication</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Password</string> + </property> + </widget> + <spacer row="0" column="2"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="1"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + <widget class="KPasswordEdit" row="0" column="1"> + <property name="name"> + <cstring>editUserPassword</cstring> + </property> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + +</includehints> +</UI> diff --git a/knetworkmanager-0.8/vpn-plugins/openvpn/src/openvpnprop.ui b/knetworkmanager-0.8/vpn-plugins/openvpn/src/openvpnprop.ui new file mode 100644 index 0000000..c136050 --- /dev/null +++ b/knetworkmanager-0.8/vpn-plugins/openvpn/src/openvpnprop.ui @@ -0,0 +1,619 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>OpenVPNConfigWidget</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>OpenVPNConfigWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>667</width> + <height>322</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>kTabWidget1</cstring> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Required Information</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="4" column="1"> + <property name="name"> + <cstring>spacer9</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>16</height> + </size> + </property> + </spacer> + <widget class="TQWidgetStack" row="3" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>widgetStack</cstring> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>WStackPage</cstring> + </property> + <attribute name="id"> + <number>0</number> + </attribute> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>groupBox5</cstring> + </property> + <property name="title"> + <string>X.509</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KURLRequester" row="0" column="1"> + <property name="name"> + <cstring>editCA2</cstring> + </property> + </widget> + <widget class="KURLRequester" row="1" column="1"> + <property name="name"> + <cstring>editCert2</cstring> + </property> + </widget> + <widget class="KURLRequester" row="2" column="1"> + <property name="name"> + <cstring>editKey2</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>CA file</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="text"> + <string>Certificate</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Key</string> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WStackPage</cstring> + </property> + <attribute name="id"> + <number>1</number> + </attribute> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>groupBox5_2</cstring> + </property> + <property name="title"> + <string>Shared key</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KURLRequester" row="0" column="1"> + <property name="name"> + <cstring>editSharedKey</cstring> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>editLocalIP</cstring> + </property> + </widget> + <widget class="KLineEdit" row="2" column="1"> + <property name="name"> + <cstring>editRemoteIP</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel5</cstring> + </property> + <property name="text"> + <string>Shared Key</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel6</cstring> + </property> + <property name="text"> + <string>Local IP</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel7</cstring> + </property> + <property name="text"> + <string>Remote IP</string> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WStackPage</cstring> + </property> + <attribute name="id"> + <number>2</number> + </attribute> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>groupBox5_2_2</cstring> + </property> + <property name="title"> + <string>Password</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KURLRequester" row="0" column="1"> + <property name="name"> + <cstring>editCA3</cstring> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>editUsername2</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel8</cstring> + </property> + <property name="text"> + <string>CA file</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel9</cstring> + </property> + <property name="text"> + <string>Username</string> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WStackPage</cstring> + </property> + <attribute name="id"> + <number>3</number> + </attribute> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>groupBox5_3</cstring> + </property> + <property name="title"> + <string>X.509 with password authentication</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KURLRequester" row="0" column="1"> + <property name="name"> + <cstring>editCA</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>CA file</string> + </property> + </widget> + <widget class="KURLRequester" row="1" column="1"> + <property name="name"> + <cstring>editCert</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel3_2_2</cstring> + </property> + <property name="text"> + <string>Certificate</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel4_2</cstring> + </property> + <property name="text"> + <string>Key</string> + </property> + </widget> + <widget class="KURLRequester" row="2" column="1"> + <property name="name"> + <cstring>editKey</cstring> + </property> + </widget> + <widget class="KLineEdit" row="3" column="1"> + <property name="name"> + <cstring>editUsername</cstring> + </property> + </widget> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel9_2</cstring> + </property> + <property name="text"> + <string>Username</string> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>labelConnectionType</cstring> + </property> + <property name="text"> + <string>Connection Type</string> + </property> + </widget> + <widget class="KComboBox" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cboConnectionType</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Gateway</string> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel3_3</cstring> + </property> + <property name="text"> + <string>Port</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>gateway</cstring> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>port</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="2"> + <property name="name"> + <cstring>chkDefaultPort</cstring> + </property> + <property name="text"> + <string>Use Default</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>TabPage</cstring> + </property> + <attribute name="title"> + <string>Optional Information</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KLineEdit" row="7" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>routes</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + <widget class="TQCheckBox" row="6" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkIPAdresses</cstring> + </property> + <property name="text"> + <string>Only use VPN Connection for these Addresses (eg: 172.16.0.0/16 10.11.12.0/24)</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkUseTAP</cstring> + </property> + <property name="text"> + <string>Use TAP device</string> + </property> + </widget> + <widget class="TQCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkUseLZO</cstring> + </property> + <property name="text"> + <string>Use LZO compression</string> + </property> + </widget> + <widget class="TQCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>chkUseTCP</cstring> + </property> + <property name="text"> + <string>Use TCP connection</string> + </property> + </widget> + <spacer row="8" column="1"> + <property name="name"> + <cstring>spacer10</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>30</height> + </size> + </property> + </spacer> + <widget class="TQCheckBox" row="3" column="0"> + <property name="name"> + <cstring>chkUseCipher</cstring> + </property> + <property name="text"> + <string>Use cipher</string> + </property> + </widget> + <widget class="TQCheckBox" row="4" column="0"> + <property name="name"> + <cstring>chkUseTLS</cstring> + </property> + <property name="text"> + <string>Use TLS auth</string> + </property> + </widget> + <widget class="TQLabel" row="5" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Direction:</string> + </property> + </widget> + <widget class="KComboBox" row="5" column="1"> + <property name="name"> + <cstring>cboDirection</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + <widget class="KURLRequester" row="4" column="1"> + <property name="name"> + <cstring>editTLSAuth</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + <widget class="KComboBox" row="3" column="1"> + <property name="name"> + <cstring>cboCipher</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </grid> + </widget> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>editCA</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCA2</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCA</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCA3</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCA2</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCA</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCA2</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCA3</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCA3</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCA2</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCA3</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCA</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCert</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCert2</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editCert2</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editCert</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editKey</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editKey2</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editKey2</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editKey</receiver> + <slot>setURL(const QString&)</slot> + </connection> + <connection> + <sender>editUsername</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editUsername2</receiver> + <slot>setText(const QString&)</slot> + </connection> + <connection> + <sender>editUsername2</sender> + <signal>textChanged(const QString&)</signal> + <receiver>editUsername</receiver> + <slot>setText(const QString&)</slot> + </connection> + <connection> + <sender>chkDefaultPort</sender> + <signal>toggled(bool)</signal> + <receiver>port</receiver> + <slot>setDisabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>kTabWidget1</tabstop> + <tabstop>chkUseLZO</tabstop> + <tabstop>chkUseTAP</tabstop> + <tabstop>chkUseTCP</tabstop> + <tabstop>chkUseCipher</tabstop> + <tabstop>cboCipher</tabstop> + <tabstop>chkUseTLS</tabstop> + <tabstop>editTLSAuth</tabstop> + <tabstop>cboDirection</tabstop> + <tabstop>chkIPAdresses</tabstop> + <tabstop>routes</tabstop> + <tabstop>gateway</tabstop> + <tabstop>cboConnectionType</tabstop> + <tabstop>editCA2</tabstop> + <tabstop>editCert2</tabstop> + <tabstop>editKey2</tabstop> + <tabstop>editSharedKey</tabstop> + <tabstop>editLocalIP</tabstop> + <tabstop>editRemoteIP</tabstop> + <tabstop>editCA3</tabstop> + <tabstop>editUsername2</tabstop> + <tabstop>editCA</tabstop> + <tabstop>editCert</tabstop> + <tabstop>editKey</tabstop> + <tabstop>editUsername</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> +</includehints> +</UI> |