|
|
|
@ -23,8 +23,6 @@
|
|
|
|
|
*
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define SERVICE_DIR "/etc/NetworkManager/VPN"
|
|
|
|
|
|
|
|
|
|
#include <klocale.h>
|
|
|
|
|
#include <tqdir.h>
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
@ -43,26 +41,39 @@ VPNManager::getVPNServices ()
|
|
|
|
|
{
|
|
|
|
|
VPNServiceList list;
|
|
|
|
|
|
|
|
|
|
TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
|
|
|
|
|
TQStringList services = serviceDir.entryList ().grep (".name", true);
|
|
|
|
|
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
|
|
|
|
|
TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
|
|
|
|
|
|
|
|
|
|
if (services.count () > 0)
|
|
|
|
|
{
|
|
|
|
|
// read in all available Services
|
|
|
|
|
for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) {
|
|
|
|
|
TQString service = SERVICE_DIR + TQString ("/") + *i;
|
|
|
|
|
KConfig* kconfig = new KConfig (service, true, true, "config");
|
|
|
|
|
kconfig->setGroup ("VPN Connection");
|
|
|
|
|
if (availablePlugins.count() > 0) {
|
|
|
|
|
// find all available services
|
|
|
|
|
for (TDENetworkVPNTypeList::Iterator it = availablePlugins.begin (); it != availablePlugins.end (); ++it) {
|
|
|
|
|
TQString serviceString;
|
|
|
|
|
if ((*it) == TDENetworkVPNType::OpenVPN) {
|
|
|
|
|
serviceString = "openvpn";
|
|
|
|
|
}
|
|
|
|
|
else if ((*it) == TDENetworkVPNType::PPTP) {
|
|
|
|
|
serviceString = "pptp";
|
|
|
|
|
}
|
|
|
|
|
else if ((*it) == TDENetworkVPNType::StrongSwan) {
|
|
|
|
|
serviceString = "strongswan";
|
|
|
|
|
}
|
|
|
|
|
else if ((*it) == TDENetworkVPNType::VPNC) {
|
|
|
|
|
serviceString = "vpnc";
|
|
|
|
|
}
|
|
|
|
|
if (serviceString == "") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() << endl;
|
|
|
|
|
kdDebug() << "VPN Service " << serviceString.ascii() << endl;
|
|
|
|
|
|
|
|
|
|
// create new VPNService Object
|
|
|
|
|
VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(TDENetworkManager::getInstance()));
|
|
|
|
|
if (!vpnservice->getVPNPlugin())
|
|
|
|
|
VPNService* vpnservice = new VPNService(serviceString, serviceString, TQT_TQOBJECT(TDENetworkManager::getInstance()));
|
|
|
|
|
if (!vpnservice->getVPNPlugin()) {
|
|
|
|
|
delete vpnservice;
|
|
|
|
|
else
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
list.push_back(vpnservice);
|
|
|
|
|
delete kconfig;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -74,30 +85,42 @@ VPNManager::getVPNService(TQString service_type)
|
|
|
|
|
{
|
|
|
|
|
VPNServiceList list;
|
|
|
|
|
|
|
|
|
|
TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
|
|
|
|
|
TQStringList services = serviceDir.entryList ().grep (".name", true);
|
|
|
|
|
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
|
|
|
|
|
TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
|
|
|
|
|
|
|
|
|
|
if (services.count () > 0)
|
|
|
|
|
{
|
|
|
|
|
// read in all available Services
|
|
|
|
|
for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) {
|
|
|
|
|
TQString service = SERVICE_DIR + TQString ("/") + *i;
|
|
|
|
|
KConfig* kconfig = new KConfig (service, true, true, "config");
|
|
|
|
|
kconfig->setGroup ("VPN Connection");
|
|
|
|
|
if (availablePlugins.count() > 0) {
|
|
|
|
|
for (TDENetworkVPNTypeList::Iterator it = availablePlugins.begin (); it != availablePlugins.end (); ++it) {
|
|
|
|
|
TQString serviceString;
|
|
|
|
|
if ((*it) == TDENetworkVPNType::OpenVPN) {
|
|
|
|
|
serviceString = "openvpn";
|
|
|
|
|
}
|
|
|
|
|
else if ((*it) == TDENetworkVPNType::PPTP) {
|
|
|
|
|
serviceString = "pptp";
|
|
|
|
|
}
|
|
|
|
|
else if ((*it) == TDENetworkVPNType::StrongSwan) {
|
|
|
|
|
serviceString = "strongswan";
|
|
|
|
|
}
|
|
|
|
|
else if ((*it) == TDENetworkVPNType::VPNC) {
|
|
|
|
|
serviceString = "vpnc";
|
|
|
|
|
}
|
|
|
|
|
if (serviceString == "") {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (kconfig->readEntry ("service", TQString()) == service_type)
|
|
|
|
|
{
|
|
|
|
|
if (serviceString == service_type) {
|
|
|
|
|
// create new VPNService Object
|
|
|
|
|
VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(TDENetworkManager::getInstance()));
|
|
|
|
|
if (!vpnservice->getVPNPlugin())
|
|
|
|
|
VPNService* vpnservice = new VPNService(service_type, service_type, TQT_TQOBJECT(TDENetworkManager::getInstance()));
|
|
|
|
|
if (!vpnservice->getVPNPlugin()) {
|
|
|
|
|
delete vpnservice;
|
|
|
|
|
else
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return vpnservice;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "tdenetman-vpnmanager.moc"
|
|
|
|
|