diff options
author | Timothy Pearson <[email protected]> | 2012-09-10 15:33:33 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-09-10 15:33:33 -0500 |
commit | c27ceace4c04419b8d52f6233ca5e1cbe1e019e2 (patch) | |
tree | 033dabf50f4badd8ada7e9048420f2becb029851 | |
parent | e7af20397702231bf389a22c6e53c415b82442a9 (diff) | |
download | tdelibs-c27ceace4c04419b8d52f6233ca5e1cbe1e019e2.tar.gz tdelibs-c27ceace4c04419b8d52f6233ca5e1cbe1e019e2.zip |
Detect available VPN plugins
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.cpp | 39 | ||||
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.h | 2 |
2 files changed, 35 insertions, 6 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp index 1b00d8b84..a79ff2c87 100644 --- a/tdecore/networkbackends/network-manager/network-manager.cpp +++ b/tdecore/networkbackends/network-manager/network-manager.cpp @@ -16,6 +16,9 @@ Boston, MA 02110-1301, USA. */ +#include <tqdir.h> + +#include "kconfig.h" #include "tdehardwaredevices.h" #include "network-manager.h" @@ -4542,12 +4545,36 @@ TQStringList TDENetworkConnectionManager_BackendNM::connectionPhysicalDeviceUUID TDENetworkVPNTypeList TDENetworkConnectionManager_BackendNM::availableVPNTypes() { TDENetworkVPNTypeList ret; - // FIXME - // This backend should query NetworkManager to verify plugin availability before claiming support for a VPN type! - ret.append(TDENetworkVPNType::OpenVPN); - ret.append(TDENetworkVPNType::PPTP); - ret.append(TDENetworkVPNType::StrongSwan); - ret.append(TDENetworkVPNType::VPNC); + // Query NetworkManager to verify plugin availability before claiming support for a VPN type + TQDir serviceDir(NM_PLUGIN_SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files); + TQStringList services = serviceDir.entryList ().grep (".name", true); + + if (services.count () > 0) { + // read in all available Services + for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { + TQString service = NM_PLUGIN_SERVICE_DIR + TQString ("/") + *i; + KConfig* kconfig = new KConfig (service, true, true, "config"); + kconfig->setGroup ("VPN Connection"); + + TQString serviceName = kconfig->readEntry("name", TQString()); + serviceName = serviceName.lower(); + + if (serviceName == "openvpn") { + ret.append(TDENetworkVPNType::OpenVPN); + } + if (serviceName == "pptp") { + ret.append(TDENetworkVPNType::PPTP); + } + if (serviceName == "strongswan") { + ret.append(TDENetworkVPNType::StrongSwan); + } + if (serviceName == "vpnc") { + ret.append(TDENetworkVPNType::VPNC); + } + + delete kconfig; + } + } return ret; } diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h index 6a9e8ebc9..11f08c65a 100644 --- a/tdecore/networkbackends/network-manager/network-manager.h +++ b/tdecore/networkbackends/network-manager/network-manager.h @@ -126,6 +126,8 @@ #define NM_802_11_DEVICE_CAP_WPA 0x10 #define NM_802_11_DEVICE_CAP_RSN 0x20 //==================================================================================================== +#define NM_PLUGIN_SERVICE_DIR "/etc/NetworkManager/VPN" +//==================================================================================================== class TDENetworkConnectionManager_BackendNMPrivate; |