From 3c57e87e071472d32b70090f8a11a9df08c1c461 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 10 Sep 2012 16:03:14 -0500 Subject: [PATCH] Reactivate PPTP plugin --- tdenetworkmanager/vpn-plugins/CMakeLists.txt | 2 +- tdenetworkmanager/vpn-plugins/pptp/AUTHORS | 1 + .../vpn-plugins/pptp/CMakeLists.txt | 14 +++ .../vpn-plugins/pptp/src/CMakeLists.txt | 43 +++++++++ ...orkmanager-pptp.cpp => tdenetman-pptp.cpp} | 87 ++++++++++++------- ...networkmanager-pptp.h => tdenetman-pptp.h} | 16 ++-- ...er_pptp.desktop => tdenetman_pptp.desktop} | 8 +- .../vpn-plugins/vpnc/src/tdenetman-vpnc.cpp | 3 +- .../vpn-plugins/vpnc/src/tdenetman-vpnc.h | 2 +- 9 files changed, 130 insertions(+), 46 deletions(-) create mode 100644 tdenetworkmanager/vpn-plugins/pptp/CMakeLists.txt create mode 100644 tdenetworkmanager/vpn-plugins/pptp/src/CMakeLists.txt rename tdenetworkmanager/vpn-plugins/pptp/src/{knetworkmanager-pptp.cpp => tdenetman-pptp.cpp} (63%) rename tdenetworkmanager/vpn-plugins/pptp/src/{knetworkmanager-pptp.h => tdenetman-pptp.h} (80%) rename tdenetworkmanager/vpn-plugins/pptp/{knetworkmanager_pptp.desktop => tdenetman_pptp.desktop} (73%) diff --git a/tdenetworkmanager/vpn-plugins/CMakeLists.txt b/tdenetworkmanager/vpn-plugins/CMakeLists.txt index aa31dbf..6e10d60 100644 --- a/tdenetworkmanager/vpn-plugins/CMakeLists.txt +++ b/tdenetworkmanager/vpn-plugins/CMakeLists.txt @@ -10,6 +10,6 @@ ################################################# # add_subdirectory( openvpn ) -# add_subdirectory( pptp ) +add_subdirectory( pptp ) # add_subdirectory( strongswan ) add_subdirectory( vpnc ) diff --git a/tdenetworkmanager/vpn-plugins/pptp/AUTHORS b/tdenetworkmanager/vpn-plugins/pptp/AUTHORS index 17bdf96..93dbeb8 100644 --- a/tdenetworkmanager/vpn-plugins/pptp/AUTHORS +++ b/tdenetworkmanager/vpn-plugins/pptp/AUTHORS @@ -1 +1,2 @@ +Timothy Pearson Helmut Schaa , diff --git a/tdenetworkmanager/vpn-plugins/pptp/CMakeLists.txt b/tdenetworkmanager/vpn-plugins/pptp/CMakeLists.txt new file mode 100644 index 0000000..323bc89 --- /dev/null +++ b/tdenetworkmanager/vpn-plugins/pptp/CMakeLists.txt @@ -0,0 +1,14 @@ +################################################# +# +# (C) 2012 Timothy Pearson +# kb9vqf (AT) pearsoncomputing.net +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( src ) + +install( FILES tdenetman_pptp.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/tdenetworkmanager/vpn-plugins/pptp/src/CMakeLists.txt b/tdenetworkmanager/vpn-plugins/pptp/src/CMakeLists.txt new file mode 100644 index 0000000..fa1c6e0 --- /dev/null +++ b/tdenetworkmanager/vpn-plugins/pptp/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_pptp (module) ################### + +set( target tdenetman_pptp ) + +set( ${target}_SRCS + tdenetman-pptp.cpp + pptpprop.ui + pptpauth.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/pptp/src/knetworkmanager-pptp.cpp b/tdenetworkmanager/vpn-plugins/pptp/src/tdenetman-pptp.cpp similarity index 63% rename from tdenetworkmanager/vpn-plugins/pptp/src/knetworkmanager-pptp.cpp rename to tdenetworkmanager/vpn-plugins/pptp/src/tdenetman-pptp.cpp index e8180d1..3475dd5 100644 --- a/tdenetworkmanager/vpn-plugins/pptp/src/knetworkmanager-pptp.cpp +++ b/tdenetworkmanager/vpn-plugins/pptp/src/tdenetman-pptp.cpp @@ -35,10 +35,10 @@ #include #include -#include "knetworkmanager-pptp.h" +#include "tdenetman-pptp.h" typedef KGenericFactory PPTPPluginFactory; -K_EXPORT_COMPONENT_FACTORY( knetworkmanager_pptp, PPTPPluginFactory("knetworkmanager_pptp")); +K_EXPORT_COMPONENT_FACTORY(tdenetman_pptp, PPTPPluginFactory("tdenetman_pptp")); PPTPPlugin::PPTPPlugin(TQObject* parent, const char* name, const TQStringList& args) @@ -86,8 +86,10 @@ void PPTPConfig::languageChange() } -void PPTPConfig::setVPNData(const TQStringList& routes, const TQMap& properties) -{ +void PPTPConfig::setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets) { + m_vpnProperties = properties; + m_vpnSecrets = secrets; + // fill up our inputfields (only textfields atm) for(TQMap::ConstIterator it = properties.begin(); it != properties.end(); ++it) { @@ -144,42 +146,61 @@ void PPTPConfig::setVPNData(const TQStringList& routes, const TQMapchkIPAdresses->setChecked(true); - _pptpWidget->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())); + } + _pptpWidget->routes->setText(routesText.join(" ")); } } -TQMap PPTPConfig::getVPNProperties() -{ - // build a StingList of properties - TQMap strlist; - strlist.insert("gateway", TQString(_pptpWidget->gateway->text())); - strlist.insert("refuse-eap", TQString(_pptpWidget->chk_refuseeap->isChecked() ? "yes" : "no")); - strlist.insert("refuse-pap", TQString(_pptpWidget->chk_refusepap->isChecked() ? "yes" : "no")); - strlist.insert("refuse-chap", TQString(_pptpWidget->chk_refusechap->isChecked() ? "yes" : "no")); - strlist.insert("refuse-mschap", TQString(_pptpWidget->chk_refusemschap->isChecked() ? "yes" : "no")); - strlist.insert("refuse-mschapv2", TQString(_pptpWidget->chk_refusemschapv2->isChecked() ? "yes" : "no")); - strlist.insert("require-mppe", TQString(_pptpWidget->chk_requiremppe->isChecked() ? "yes" : "no")); - strlist.insert("require-mppe-40", TQString(_pptpWidget->chk_requiremppe40->isChecked() ? "yes" : "no")); - strlist.insert("require-mppe-128", TQString(_pptpWidget->chk_requiremppe128->isChecked() ? "yes" : "no")); - strlist.insert("mppe-stateful", TQString(_pptpWidget->chk_mppestateful->isChecked() ? "yes" : "no")); - strlist.insert("nodeflate", TQString(_pptpWidget->chk_nodeflate->isChecked() ? "yes" : "no")); +TDENetworkSettingsMap PPTPConfig::getVPNProperties() { + // Build a list of properties + m_vpnProperties.insert("gateway", TQString(_pptpWidget->gateway->text())); + m_vpnProperties.insert("refuse-eap", TQString(_pptpWidget->chk_refuseeap->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("refuse-pap", TQString(_pptpWidget->chk_refusepap->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("refuse-chap", TQString(_pptpWidget->chk_refusechap->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("refuse-mschap", TQString(_pptpWidget->chk_refusemschap->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("refuse-mschapv2", TQString(_pptpWidget->chk_refusemschapv2->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("require-mppe", TQString(_pptpWidget->chk_requiremppe->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("require-mppe-40", TQString(_pptpWidget->chk_requiremppe40->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("require-mppe-128", TQString(_pptpWidget->chk_requiremppe128->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("mppe-stateful", TQString(_pptpWidget->chk_mppestateful->isChecked() ? "yes" : "no")); + m_vpnProperties.insert("nodeflate", TQString(_pptpWidget->chk_nodeflate->isChecked() ? "yes" : "no")); // Current network-manager-pptp plugin supports bluetooth-gprs,dialup and pptp. // We want a pptp connection. - //strlist.insert("ppp-connection-type", "pptp"); + //m_vpnProperties.insert("ppp-connection-type", "pptp"); + + return m_vpnProperties; +} + +TDENetworkSettingsMap PPTPConfig::getVPNSecrets() { + // Build a list of secrets + // FIXME - return strlist; + return m_vpnSecrets; } -TQStringList PPTPConfig::getVPNRoutes() +TDENetworkSingleRouteConfigurationList PPTPConfig::getVPNRoutes() { + TDENetworkSingleRouteConfigurationList ret; TQStringList strlist; - if(_pptpWidget->chkIPAdresses->isChecked()) - { + if(_pptpWidget->chkIPAdresses->isChecked()) { strlist = TQStringList::split(" ", _pptpWidget->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 PPTPConfig::hasChanged() @@ -211,11 +232,11 @@ PPTPAuthentication::~PPTPAuthentication() } -TQMap PPTPAuthentication::getPasswords() +TDENetworkSettingsMap PPTPAuthentication::getPasswords() { // network-manager-pptp will fail hard if "CHAP" is not the // first element in the username&password list. - TQMap pwds; + TDENetworkSettingsMap pwds; //pwds.insert("CHAP", "CHAP"); pwds.insert("user", TQString(_pptpAuth->username->text())); pwds.insert("password", TQString(_pptpAuth->password->password())); @@ -223,9 +244,11 @@ TQMap PPTPAuthentication::getPasswords() return pwds; } -void PPTPAuthentication::setPasswords(TQString name, TQString value) { - if (name == TQString("password")) { +void PPTPAuthentication::setPasswords(TDENetworkSettingsMap secrets) { + if (secrets.contains("password")) { _pptpAuth->password->erase(); - _pptpAuth->password->insert(value); + _pptpAuth->password->insert(secrets["password"]); } -} \ No newline at end of file +} + +#include "tdenetman-pptp.moc" \ No newline at end of file diff --git a/tdenetworkmanager/vpn-plugins/pptp/src/knetworkmanager-pptp.h b/tdenetworkmanager/vpn-plugins/pptp/src/tdenetman-pptp.h similarity index 80% rename from tdenetworkmanager/vpn-plugins/pptp/src/knetworkmanager-pptp.h rename to tdenetworkmanager/vpn-plugins/pptp/src/tdenetman-pptp.h index c286e16..6f80300 100644 --- a/tdenetworkmanager/vpn-plugins/pptp/src/knetworkmanager-pptp.h +++ b/tdenetworkmanager/vpn-plugins/pptp/src/tdenetman-pptp.h @@ -30,7 +30,7 @@ #include #include -#include "knetworkmanager-vpnplugin.h" +#include "tdenetman-vpnplugin.h" #include "pptpprop.h" #include "pptpauth.h" @@ -51,9 +51,10 @@ class PPTPConfig : public VPNConfigWidget Q_OBJECT public: - void setVPNData(const TQStringList& routes, const TQMap& properties); - TQMap getVPNProperties(); - TQStringList getVPNRoutes(); + void setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets); + TDENetworkSettingsMap getVPNProperties(); + TDENetworkSettingsMap getVPNSecrets(); + TDENetworkSingleRouteConfigurationList getVPNRoutes(); bool hasChanged(); bool isValid(TQStringList& ); @@ -63,6 +64,9 @@ class PPTPConfig : public VPNConfigWidget private: PPTPConfigWidget* _pptpWidget; + TDENetworkSettingsMap m_vpnProperties; + TDENetworkSettingsMap m_vpnSecrets; + protected slots: void languageChange(); }; @@ -74,8 +78,8 @@ class PPTPAuthentication : public VPNAuthenticationWidget public: PPTPAuthentication(TQWidget* parent = NULL, char* name = NULL); ~PPTPAuthentication(); - TQMap getPasswords(); - void setPasswords(TQString name, TQString value); + TDENetworkSettingsMap getPasswords(); + void setPasswords(TDENetworkSettingsMap secrets); private: PPTPAuthenticationWidget* _pptpAuth; diff --git a/tdenetworkmanager/vpn-plugins/pptp/knetworkmanager_pptp.desktop b/tdenetworkmanager/vpn-plugins/pptp/tdenetman_pptp.desktop similarity index 73% rename from tdenetworkmanager/vpn-plugins/pptp/knetworkmanager_pptp.desktop rename to tdenetworkmanager/vpn-plugins/pptp/tdenetman_pptp.desktop index bbc0b4b..d5d626c 100644 --- a/tdenetworkmanager/vpn-plugins/pptp/knetworkmanager_pptp.desktop +++ b/tdenetworkmanager/vpn-plugins/pptp/tdenetman_pptp.desktop @@ -3,11 +3,11 @@ Encoding=UTF-8 Type=Service Icon= ServiceTypes=TDENetworkManager/VPNPlugin -X-TDE-Library=knetworkmanager_pptp +X-TDE-Library=tdenetman_pptp X-NetworkManager-Services=pptp -X-TDE-PluginInfo-Author=Helmut Schaa -X-TDE-PluginInfo-Email=hschaa@suse.de -X-TDE-PluginInfo-Name=knetworkmanager_pptp +X-TDE-PluginInfo-Author=Timothy Pearson +X-TDE-PluginInfo-Email=kb9vqf@pearsoncomputing.net +X-TDE-PluginInfo-Name=tdenetman_pptp X-TDE-PluginInfo-Version=0.1 X-TDE-PluginInfo-Website= X-TDE-PluginInfo-Category=VPNService diff --git a/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.cpp b/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.cpp index d060a55..272e05f 100644 --- a/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.cpp +++ b/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.cpp @@ -44,7 +44,7 @@ using namespace std; typedef KGenericFactory VPNCPluginFactory; -K_EXPORT_COMPONENT_FACTORY( tdenetman_vpnc, VPNCPluginFactory("tdenetman_vpnc")); +K_EXPORT_COMPONENT_FACTORY(tdenetman_vpnc, VPNCPluginFactory("tdenetman_vpnc")); #define NAT_MODE_CISCO 0 #define NAT_MODE_NATT 1 @@ -356,7 +356,6 @@ TDENetworkSingleRouteConfigurationList VPNCConfig::getVPNRoutes() } return ret; - } bool VPNCConfig::hasChanged() diff --git a/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.h b/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.h index 9d5e6e1..9999140 100644 --- a/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.h +++ b/tdenetworkmanager/vpn-plugins/vpnc/src/tdenetman-vpnc.h @@ -52,7 +52,7 @@ class VPNCConfig : public VPNConfigWidget Q_OBJECT public: - void setVPNData(TDENetworkSingleRouteConfigurationList&, TDENetworkSettingsMap&, TDENetworkSettingsMap&); + void setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets); TDENetworkSettingsMap getVPNProperties(); TDENetworkSettingsMap getVPNSecrets(); TDENetworkSingleRouteConfigurationList getVPNRoutes();