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_settings.ui
connection_setting_wireless_security_auth.ui
# connection_setting_vpn.ui
connection_setting_vpn.ui
tdenetman-connection_setting_cdma_widget.cpp
tdenetman-connection_setting_gsm_widget.cpp
tdenetman-connection_setting_info_widget.cpp
@ -53,7 +53,7 @@ set( ${target}_SRCS
tdenetman-connection_setting_serial_widget.cpp
tdenetman-connection_setting_wireless_security_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_settings_dialog.cpp
)

@ -35,20 +35,17 @@
#include <kuser.h>
// tdenm headers
#include "tdenetman-connection.h"
#include "tdenetman-connection_setting_vpn.h"
#include "tdenetman-connection_setting_vpn_widget.h"
#include "tdenetman-device.h"
#include "tdenetman-vpnmanager.h"
#include "tdenetman-vpnservice.h"
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)
, _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);
_mainWid = new ConnectionSettingVPNWidget(this);
@ -96,9 +93,10 @@ VPNWidgetImpl::Init()
disp_name = "StrongSwan VPN";
}
// the service should not get changed when editing a connection
if (service->getService() != _vpnsetting->getServiceType() && !_new_conn)
// the service should not be changed when editing a connection
if (service->getService() != _vpnsetting->vpnPluginID && !_new_conn) {
continue;
}
// no special icon for this service, use default
if (icon.isEmpty())
@ -107,7 +105,7 @@ VPNWidgetImpl::Init()
_mainWid->cboServices->insertItem(SmallIcon(icon, TQIconSet::Automatic), disp_name, index);
_mapServiceCombo.insert(index++, *it);
if (service->getService() == _vpnsetting->getServiceType())
if (service->getService() == _vpnsetting->vpnPluginID)
{
// preselect the correct service
_mainWid->cboServices->setCurrentItem(index - 1);
@ -128,7 +126,7 @@ VPNWidgetImpl::Init()
// update the username to the current one
KUser user;
_vpnsetting->setUserName(user.loginName());
_vpnsetting->lockedUserName = user.loginName();
// notification if VPN service is selected
connect(_mainWid->cboServices, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotServiceComboActivated(int)));
@ -169,7 +167,7 @@ VPNWidgetImpl::slotServiceComboActivated(int index)
VPNConfigWidget* config = getVPNConfigWidget(service);
_mainWid->widgetStack->raiseWidget(config);
config->setVPNData(_vpnsetting->getRoutes(), _vpnsetting->getData());
config->setVPNData(_vpnsetting->ipConfig.routeConfigurations, _vpnsetting->pluginData, _vpnsetting->pluginSecrets);
}
}
else
@ -186,13 +184,15 @@ VPNWidgetImpl::Deactivate()
if (service)
{
// set the correct service type
_vpnsetting->setServiceType(service->getService());
_vpnsetting->vpnPluginID = service->getService();
VPNConfigWidget* config = *_mapServiceWidget.find(service);
if (config)
{
// 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
{
class Connection;
class VPNWidgetImpl : public WidgetInterface
{
Q_OBJECT
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 Deactivate();
public slots:
@ -59,7 +57,7 @@ class VPNWidgetImpl : public WidgetInterface
VPNConfigWidget* getVPNConfigWidget(VPNService* service);
bool _new_conn;
VPN* _vpnsetting;
TDEVPNConnection* _vpnsetting;
ConnectionSettingVPNWidget* _mainWid;
TQMap<int, VPNService*> _mapServiceCombo;
TQMap<VPNService*, VPNConfigWidget*> _mapServiceWidget;

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

@ -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"

Loading…
Cancel
Save