summaryrefslogtreecommitdiffstats
path: root/tdenetworkmanager/vpn-plugins/openvpn/src
diff options
context:
space:
mode:
Diffstat (limited to 'tdenetworkmanager/vpn-plugins/openvpn/src')
-rw-r--r--tdenetworkmanager/vpn-plugins/openvpn/src/CMakeLists.txt43
-rw-r--r--tdenetworkmanager/vpn-plugins/openvpn/src/tdenetman-openvpn.cpp (renamed from tdenetworkmanager/vpn-plugins/openvpn/src/knetworkmanager-openvpn.cpp)133
-rw-r--r--tdenetworkmanager/vpn-plugins/openvpn/src/tdenetman-openvpn.h (renamed from tdenetworkmanager/vpn-plugins/openvpn/src/knetworkmanager-openvpn.h)20
3 files changed, 140 insertions, 56 deletions
diff --git a/tdenetworkmanager/vpn-plugins/openvpn/src/CMakeLists.txt b/tdenetworkmanager/vpn-plugins/openvpn/src/CMakeLists.txt
new file mode 100644
index 0000000..a565251
--- /dev/null
+++ b/tdenetworkmanager/vpn-plugins/openvpn/src/CMakeLists.txt
@@ -0,0 +1,43 @@
+#################################################
+#
+# (C) 2012 Timothy Pearson
+# kb9vqf (AT) pearsoncomputing.net
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_definitions( -UQT_NO_ASCII_CAST )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/tdenetworkmanager/src/settings
+ ${CMAKE_SOURCE_DIR}/tdenetworkmanager/src/configwidgets
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+ ${DBUS_TQT_INCLUDE_DIRS}
+ ${NM_UTIL_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+##### tdenetman_openvpn (module) ################
+
+set( target tdenetman_openvpn )
+
+set( ${target}_SRCS
+ tdenetman-openvpn.cpp
+ openvpnprop.ui
+ openvpnauth.ui
+)
+
+tde_add_kpart( ${target} AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK tdeinit_kded-shared tdeinit_tdenetworkmanager-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdenetworkmanager/vpn-plugins/openvpn/src/knetworkmanager-openvpn.cpp b/tdenetworkmanager/vpn-plugins/openvpn/src/tdenetman-openvpn.cpp
index ad27368..7cee87a 100644
--- a/tdenetworkmanager/vpn-plugins/openvpn/src/knetworkmanager-openvpn.cpp
+++ b/tdenetworkmanager/vpn-plugins/openvpn/src/tdenetman-openvpn.cpp
@@ -36,12 +36,11 @@
#include <tqwidgetstack.h>
#include <tqfileinfo.h>
#include <tqhostaddress.h>
-#include <tqdbusdata.h>
-#include "knetworkmanager-openvpn.h"
+#include "tdenetman-openvpn.h"
typedef KGenericFactory<OpenVPNPlugin> OpenVPNPluginFactory;
-K_EXPORT_COMPONENT_FACTORY( knetworkmanager_openvpn, OpenVPNPluginFactory("knetworkmanager_openvpn"));
+K_EXPORT_COMPONENT_FACTORY( tdenetman_openvpn, OpenVPNPluginFactory("tdenetman_openvpn"));
/************************************
* OpenVPNPlugin
@@ -177,21 +176,23 @@ void OpenVPNConfig::getCipherModes()
{
// get all possible cipher modes
TQString openvpn = findOpenVPNBinary();
- if (!openvpn.isNull())
- {
+ if (!openvpn.isNull()) {
KProcess* cipherHelper = new KProcess();
cipherHelper->setUseShell(true, "/bin/sh");
*cipherHelper << TQString::fromLatin1("%1 --show-ciphers | awk '/^[A-Z][A-Z0-9]+-/ { print $1 }'").arg(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))
+ if (!cipherHelper->start(KProcess::Block, KProcess::Stdout)) {
kdDebug() << "error starting openvpn" << endl;
+ }
}
-
}
-void OpenVPNConfig::setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties)
+void OpenVPNConfig::setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets)
{
+ m_vpnProperties = properties;
+ m_vpnSecrets = secrets;
+
// fill up our inputfields
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
{
@@ -283,63 +284,98 @@ void OpenVPNConfig::setVPNData(const TQStringList& routes, const TQMap<TQString,
if (!routes.empty())
{
_openvpnWidget->chkIPAdresses->setChecked(true);
- _openvpnWidget->routes->setText(routes.join(" "));
+ TQStringList routesText;
+ for (TDENetworkSingleRouteConfigurationList::Iterator it = routes.begin(); it != routes.end(); ++it) {
+ routesText.append(TQString("%1/%2").arg((*it).ipAddress.toString()).arg((*it).networkMask.toCIDRMask()));
+ }
+ _openvpnWidget->routes->setText(routesText.join(" "));
}
}
-TQMap<TQString, TQString>OpenVPNConfig::getVPNProperties()
+TDENetworkSettingsMap 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()));
+ // Build a list of properties
+ m_vpnProperties.insert("connection-type", TQString::number(OpenVPNConnectionType::mapConnectionType2String((OpenVPNConnectionType::CONNECTIONTYPE)_openvpnWidget->cboConnectionType->currentItem())));
+ m_vpnProperties.insert("remote", TQString(_openvpnWidget->gateway->text()));
// port is not necessary
- if (!_openvpnWidget->port->text().isEmpty() && !_openvpnWidget->chkDefaultPort->isChecked())
- strlist.insert("port", _openvpnWidget->port->text());
+ if (!_openvpnWidget->port->text().isEmpty() && !_openvpnWidget->chkDefaultPort->isChecked()) {
+ m_vpnProperties.insert("port", _openvpnWidget->port->text());
+ }
+ else {
+ m_vpnProperties.remove("port");
+ }
- strlist.insert("ca", TQString(_openvpnWidget->editCA->url()));
- strlist.insert("cert",TQString(_openvpnWidget->editCert->url() ));
- strlist.insert("key", TQString(_openvpnWidget->editKey->url()));
+ m_vpnProperties.insert("ca", TQString(_openvpnWidget->editCA->url()));
+ m_vpnProperties.insert("cert",TQString(_openvpnWidget->editCert->url() ));
+ m_vpnProperties.insert("key", TQString(_openvpnWidget->editKey->url()));
- if (_openvpnWidget->chkUseCipher->isChecked())
- strlist.insert("cipher", TQString(_openvpnWidget->cboCipher->currentText()));
+ if (_openvpnWidget->chkUseCipher->isChecked()) {
+ m_vpnProperties.insert("cipher", TQString(_openvpnWidget->cboCipher->currentText()));
+ }
+ else {
+ m_vpnProperties.remove("cipher");
+ }
- if (_openvpnWidget->chkUseLZO->isChecked())
- strlist.insert("comp-lzo", TQString("true"));
- else
- strlist.insert("comp-lzo", TQString("false"));
+ if (_openvpnWidget->chkUseLZO->isChecked()) {
+ m_vpnProperties.insert("comp-lzo", TQString("true"));
+ }
+ else {
+ m_vpnProperties.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()));
+ m_vpnProperties.insert("static-key", TQString(_openvpnWidget->editSharedKey->url()));
+ m_vpnProperties.insert("username", TQString(_openvpnWidget->editUsername->text()));
+ m_vpnProperties.insert("local-ip", TQString(_openvpnWidget->editLocalIP->text()));
+ m_vpnProperties.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");
+ m_vpnProperties.insert("tap-dev", "true");
+ m_vpnProperties.insert("proto-tcp", "true");
+ }
+ else {
+ m_vpnProperties.insert("tap-dev", "false");
+ m_vpnProperties.insert("proto-tcp", "false");
+ }
+
+ if (_openvpnWidget->chkUseTLS->isChecked()) {
+ m_vpnProperties.insert("ta", TQString(_openvpnWidget->editTLSAuth->url()));
+ }
+ else {
+ m_vpnProperties.remove("ta");
}
- if (_openvpnWidget->chkUseTLS->isChecked())
- strlist.insert("ta", TQString(_openvpnWidget->editTLSAuth->url()));
+ m_vpnProperties.insert("ta-dir", TQString(_openvpnWidget->cboDirection->currentText()));
+
+ return m_vpnProperties;
+}
- strlist.insert("ta-dir", TQString(_openvpnWidget->cboDirection->currentText()));
+TDENetworkSettingsMap OpenVPNConfig::getVPNSecrets() {
+ // Build a list of secrets
+ // FIXME
- return strlist;
+ return m_vpnSecrets;
}
-TQStringList OpenVPNConfig::getVPNRoutes()
+TDENetworkSingleRouteConfigurationList OpenVPNConfig::getVPNRoutes()
{
+ TDENetworkSingleRouteConfigurationList ret;
TQStringList strlist;
- if(_openvpnWidget->chkIPAdresses->isChecked())
- {
+ if(_openvpnWidget->chkIPAdresses->isChecked()) {
strlist = TQStringList::split(" ", _openvpnWidget->routes->text());
}
- return strlist;
+
+ for (TQStringList::Iterator it = strlist.begin(); it != strlist.end(); ++it) {
+ TQStringList pieces = TQStringList::split("/", (*it));
+ TDENetworkSingleRouteConfiguration routeconfig;
+ routeconfig.ipAddress.setAddress(pieces[0]);
+ if (pieces.count() > 1) {
+ routeconfig.networkMask.fromCIDRMask(pieces[1].toUInt());
+ }
+ ret.append(routeconfig);
+ }
+
+ return ret;
}
bool OpenVPNConfig::hasChanged()
@@ -526,7 +562,7 @@ OpenVPNAuthentication::~OpenVPNAuthentication()
}
-void OpenVPNAuthentication::setVPNData(const TQStringList& /*routes*/, const TQMap<TQString, TQString>& properties)
+void OpenVPNAuthentication::setVPNData(TDENetworkSingleRouteConfigurationList& /*routes*/, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets)
{
// find the connection type property
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
@@ -539,7 +575,7 @@ void OpenVPNAuthentication::setVPNData(const TQStringList& /*routes*/, const TQM
}
}
-TQMap<TQString, TQString> OpenVPNAuthentication::getPasswords()
+TDENetworkSettingsMap OpenVPNAuthentication::getPasswords()
{
TQMap<TQString, TQString> pwds;
if ((_connectionType == OpenVPNConnectionType::PASSWORD) || (_connectionType == OpenVPNConnectionType::X509USERPASS))
@@ -550,10 +586,10 @@ TQMap<TQString, TQString> OpenVPNAuthentication::getPasswords()
return pwds;
}
-void OpenVPNAuthentication::setPasswords(TQString name, TQString value) {
- if (name == TQString("password")) {
+void OpenVPNAuthentication::setPasswords(TDENetworkSettingsMap secrets) {
+ if (secrets.contains("password")) {
_openvpnAuth->editUserPassword->erase();
- _openvpnAuth->editUserPassword->insert(value);
+ _openvpnAuth->editUserPassword->insert(secrets["password"]);
}
}
@@ -564,3 +600,4 @@ bool OpenVPNAuthentication::needsUserInteraction()
return false;
}
+#include "tdenetman-openvpn.moc" \ No newline at end of file
diff --git a/tdenetworkmanager/vpn-plugins/openvpn/src/knetworkmanager-openvpn.h b/tdenetworkmanager/vpn-plugins/openvpn/src/tdenetman-openvpn.h
index 02c328f..2f8889d 100644
--- a/tdenetworkmanager/vpn-plugins/openvpn/src/knetworkmanager-openvpn.h
+++ b/tdenetworkmanager/vpn-plugins/openvpn/src/tdenetman-openvpn.h
@@ -31,7 +31,7 @@
#include <tqlayout.h>
#include <kprocess.h>
-#include "knetworkmanager-vpnplugin.h"
+#include "tdenetman-vpnplugin.h"
#include "openvpnprop.h"
#include "openvpnauth.h"
@@ -68,11 +68,12 @@ class OpenVPNConfig : public VPNConfigWidget
Q_OBJECT
public:
- void setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties);
- TQMap<TQString, TQString> getVPNProperties();
- TQStringList getVPNRoutes();
+ void setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets);
+ TDENetworkSettingsMap getVPNProperties();
+ TDENetworkSettingsMap getVPNSecrets();
+ TDENetworkSingleRouteConfigurationList getVPNRoutes();
bool hasChanged();
- bool isValid(TQStringList& );
+ bool isValid(TQStringList&);
OpenVPNConfig(TQWidget* parent);
~OpenVPNConfig();
@@ -86,6 +87,9 @@ class OpenVPNConfig : public VPNConfigWidget
void getCipherModes();
TQString findOpenVPNBinary();
+ TDENetworkSettingsMap m_vpnProperties;
+ TDENetworkSettingsMap m_vpnSecrets;
+
protected slots:
void languageChange();
};
@@ -97,9 +101,9 @@ class OpenVPNAuthentication : public VPNAuthenticationWidget
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);
+ void setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets);
+ TDENetworkSettingsMap getPasswords();
+ void setPasswords(TDENetworkSettingsMap secrets);
bool needsUserInteraction();
private: