Fix VPN settings dialog

pull/1/head
Timothy Pearson 12 years ago
parent 2027fb3d61
commit 0fa003ad69

@ -44,7 +44,7 @@ set( ${target}_SRCS
connection_setting_wireless_security_wepencryption.ui connection_setting_wireless_security_wepencryption.ui
connection_settings.ui connection_settings.ui
connection_setting_wireless_security_auth.ui connection_setting_wireless_security_auth.ui
# connection_setting_vpn.ui connection_setting_vpn.ui
tdenetman-connection_setting_cdma_widget.cpp tdenetman-connection_setting_cdma_widget.cpp
tdenetman-connection_setting_gsm_widget.cpp tdenetman-connection_setting_gsm_widget.cpp
tdenetman-connection_setting_info_widget.cpp tdenetman-connection_setting_info_widget.cpp
@ -53,7 +53,7 @@ set( ${target}_SRCS
tdenetman-connection_setting_serial_widget.cpp tdenetman-connection_setting_serial_widget.cpp
tdenetman-connection_setting_wireless_security_widget.cpp tdenetman-connection_setting_wireless_security_widget.cpp
tdenetman-connection_setting_wireless_widget.cpp tdenetman-connection_setting_wireless_widget.cpp
# tdenetman-connection_setting_vpn_widget.cpp tdenetman-connection_setting_vpn_widget.cpp
tdenetman-connection_setting_widget_interface.cpp tdenetman-connection_setting_widget_interface.cpp
tdenetman-connection_settings_dialog.cpp tdenetman-connection_settings_dialog.cpp
) )

@ -35,20 +35,17 @@
#include <kuser.h> #include <kuser.h>
// tdenm headers // tdenm headers
#include "tdenetman-connection.h"
#include "tdenetman-connection_setting_vpn.h"
#include "tdenetman-connection_setting_vpn_widget.h" #include "tdenetman-connection_setting_vpn_widget.h"
#include "tdenetman-device.h"
#include "tdenetman-vpnmanager.h" #include "tdenetman-vpnmanager.h"
#include "tdenetman-vpnservice.h" #include "tdenetman-vpnservice.h"
using namespace ConnectionSettings; using namespace ConnectionSettings;
VPNWidgetImpl::VPNWidgetImpl(Connection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl) VPNWidgetImpl::VPNWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent, const char* name, WFlags fl)
: WidgetInterface(parent, name, fl) : WidgetInterface(parent, name, fl)
, _new_conn(new_conn) , _new_conn(new_conn)
{ {
_vpnsetting = dynamic_cast<ConnectionSettings::VPN*> (conn->getSetting(NM_SETTING_VPN_SETTING_NAME)); _vpnsetting = dynamic_cast<TDEVPNConnection*>(conn);
TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1); TQVBoxLayout* layout = new TQVBoxLayout(this, 1, 1);
_mainWid = new ConnectionSettingVPNWidget(this); _mainWid = new ConnectionSettingVPNWidget(this);
@ -96,9 +93,10 @@ VPNWidgetImpl::Init()
disp_name = "StrongSwan VPN"; disp_name = "StrongSwan VPN";
} }
// the service should not get changed when editing a connection // the service should not be changed when editing a connection
if (service->getService() != _vpnsetting->getServiceType() && !_new_conn) if (service->getService() != _vpnsetting->vpnPluginID && !_new_conn) {
continue; continue;
}
// no special icon for this service, use default // no special icon for this service, use default
if (icon.isEmpty()) if (icon.isEmpty())
@ -107,7 +105,7 @@ VPNWidgetImpl::Init()
_mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index); _mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index);
_mapServiceCombo.insert(index++, *it); _mapServiceCombo.insert(index++, *it);
if (service->getService() == _vpnsetting->getServiceType()) if (service->getService() == _vpnsetting->vpnPluginID)
{ {
// preselect the correct service // preselect the correct service
_mainWid->cboServices->setCurrentItem(index - 1); _mainWid->cboServices->setCurrentItem(index - 1);
@ -128,7 +126,7 @@ VPNWidgetImpl::Init()
// update the username to the current one // update the username to the current one
KUser user; KUser user;
_vpnsetting->setUserName(user.loginName()); _vpnsetting->lockedUserName = user.loginName();
// notification if VPN service is selected // notification if VPN service is selected
connect(_mainWid->cboServices, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotServiceComboActivated(int))); connect(_mainWid->cboServices, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotServiceComboActivated(int)));
@ -169,7 +167,7 @@ VPNWidgetImpl::slotServiceComboActivated(int index)
VPNConfigWidget* config = getVPNConfigWidget(service); VPNConfigWidget* config = getVPNConfigWidget(service);
_mainWid->widgetStack->raiseWidget(config); _mainWid->widgetStack->raiseWidget(config);
config->setVPNData(_vpnsetting->getRoutes(), _vpnsetting->getData()); config->setVPNData(_vpnsetting->ipConfig.routeConfigurations, _vpnsetting->pluginData, _vpnsetting->pluginSecrets);
} }
} }
else else
@ -186,13 +184,15 @@ VPNWidgetImpl::Deactivate()
if (service) if (service)
{ {
// set the correct service type // set the correct service type
_vpnsetting->setServiceType(service->getService()); _vpnsetting->vpnPluginID = service->getService();
VPNConfigWidget* config = *_mapServiceWidget.find(service); VPNConfigWidget* config = *_mapServiceWidget.find(service);
if (config) if (config)
{ {
// update the vpn properties // update the vpn properties
_vpnsetting->setData(config->getVPNProperties()); _vpnsetting->pluginData = config->getVPNProperties();
// update the vpn secrets
_vpnsetting->pluginSecrets = config->getVPNSecrets();
} }
} }
} }

@ -41,14 +41,12 @@ class VPNConfigWidget;
namespace ConnectionSettings namespace ConnectionSettings
{ {
class Connection;
class VPNWidgetImpl : public WidgetInterface class VPNWidgetImpl : public WidgetInterface
{ {
Q_OBJECT Q_OBJECT
public: public:
VPNWidgetImpl(Connection* conn, bool new_conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0); VPNWidgetImpl(TDENetworkConnection* conn, bool new_conn, TQWidget* parent = NULL, const char* name = NULL, WFlags fl = 0);
void Activate(); void Activate();
void Deactivate(); void Deactivate();
public slots: public slots:
@ -59,7 +57,7 @@ class VPNWidgetImpl : public WidgetInterface
VPNConfigWidget* getVPNConfigWidget(VPNService* service); VPNConfigWidget* getVPNConfigWidget(VPNService* service);
bool _new_conn; bool _new_conn;
VPN* _vpnsetting; TDEVPNConnection* _vpnsetting;
ConnectionSettingVPNWidget* _mainWid; ConnectionSettingVPNWidget* _mainWid;
TQMap<int, VPNService*> _mapServiceCombo; TQMap<int, VPNService*> _mapServiceCombo;
TQMap<VPNService*, VPNConfigWidget*> _mapServiceWidget; TQMap<VPNService*, VPNConfigWidget*> _mapServiceWidget;

@ -50,6 +50,7 @@
#include "tdenetman-connection_setting_wireless_security_widget.h" #include "tdenetman-connection_setting_wireless_security_widget.h"
#include "tdenetman-connection_setting_ipv4_widget.h" #include "tdenetman-connection_setting_ipv4_widget.h"
#include "tdenetman-connection_setting_info_widget.h" #include "tdenetman-connection_setting_info_widget.h"
#include "tdenetman-connection_setting_vpn_widget.h"
#include "tdenetman-wireless_network.h" #include "tdenetman-wireless_network.h"
#include "tdenetman-wireless_manager.h" #include "tdenetman-wireless_manager.h"
@ -143,8 +144,8 @@ ConnectionSettingsDialogImpl::createWidgetsForVPN(TDENetworkConnection* conn, bo
{ {
TQValueList<WidgetInterface*> ret; TQValueList<WidgetInterface*> ret;
// widgetlist for wired connection // widgetlist for virtual private connection
// ret.append(new ConnectionSettings::VPNWidgetImpl(conn, new_conn, this)); ret.append(new ConnectionSettings::VPNWidgetImpl(conn, new_conn, this));
ret.append(new ConnectionSettings::InfoWidgetImpl(conn, this)); ret.append(new ConnectionSettings::InfoWidgetImpl(conn, this));
return ret; return ret;
@ -221,9 +222,9 @@ ConnectionSettingsDialogImpl::createWidgetsForConnection(TDENetworkConnection* c
} }
} }
} }
// else if (conn->getType() == NM_SETTING_VPN_SETTING_NAME) { else if (conn->type() == TDENetworkConnectionType::VPN) {
// widgets = createWidgetsForVPN(conn, new_conn); widgets = createWidgetsForVPN(conn, new_conn);
// } }
else { else {
kdWarning() << k_funcinfo << "Not handled yet" << endl; kdWarning() << k_funcinfo << "Not handled yet" << endl;
} }

@ -23,8 +23,6 @@
* *
**************************************************************************/ **************************************************************************/
#define SERVICE_DIR "/etc/NetworkManager/VPN"
#include <klocale.h> #include <klocale.h>
#include <tqdir.h> #include <tqdir.h>
#include <kdebug.h> #include <kdebug.h>
@ -42,27 +40,40 @@ VPNServiceList
VPNManager::getVPNServices () VPNManager::getVPNServices ()
{ {
VPNServiceList list; VPNServiceList list;
TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
TQStringList services = serviceDir.entryList ().grep (".name", true);
if (services.count () > 0) TDEGlobalNetworkManager* nm = KGlobal::networkManager();
{ TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
// 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");
kdDebug() << "VPN Service " << kconfig->readEntry ("name", TQString()).ascii() << endl; 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 " << serviceString.ascii() << endl;
// create new VPNService Object // create new VPNService Object
VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(TDENetworkManager::getInstance())); VPNService* vpnservice = new VPNService(serviceString, serviceString, TQT_TQOBJECT(TDENetworkManager::getInstance()));
if (!vpnservice->getVPNPlugin()) if (!vpnservice->getVPNPlugin()) {
delete vpnservice; delete vpnservice;
else }
else {
list.push_back(vpnservice); list.push_back(vpnservice);
delete kconfig; }
} }
} }
@ -73,31 +84,43 @@ VPNService*
VPNManager::getVPNService(TQString service_type) VPNManager::getVPNService(TQString service_type)
{ {
VPNServiceList list; VPNServiceList list;
TQDir serviceDir(SERVICE_DIR, TQString(), TQDir::Name|TQDir::IgnoreCase, TQDir::Files);
TQStringList services = serviceDir.entryList ().grep (".name", true);
if (services.count () > 0) TDEGlobalNetworkManager* nm = KGlobal::networkManager();
{ TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
// 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 (kconfig->readEntry ("service", TQString()) == service_type) 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 (serviceString == service_type) {
// create new VPNService Object // create new VPNService Object
VPNService* vpnservice = new VPNService(kconfig->readEntry ("name", TQString()), kconfig->readEntry ("service", TQString()), TQT_TQOBJECT(TDENetworkManager::getInstance())); VPNService* vpnservice = new VPNService(service_type, service_type, TQT_TQOBJECT(TDENetworkManager::getInstance()));
if (!vpnservice->getVPNPlugin()) if (!vpnservice->getVPNPlugin()) {
delete vpnservice; delete vpnservice;
else }
else {
return vpnservice; return vpnservice;
}
} }
} }
} }
return NULL;
return NULL;
} }
#include "tdenetman-vpnmanager.moc" #include "tdenetman-vpnmanager.moc"

Loading…
Cancel
Save