Fix VPN editing and connection

pull/1/head
Timothy Pearson 12 years ago
parent cfa58d935e
commit f285871c3c

@ -175,6 +175,7 @@ VPNWidgetImpl::Deactivate()
// set the correct service type
_vpnsetting->vpnPluginID = service->getService();
if (_mapServiceWidget.find(service) != _mapServiceWidget.end()) {
VPNConfigWidget* config = *_mapServiceWidget.find(service);
if (config) {
// update the vpn properties
@ -183,6 +184,7 @@ VPNWidgetImpl::Deactivate()
_vpnsetting->pluginSecrets = config->getVPNSecrets();
}
}
}
}
void

@ -45,6 +45,8 @@
#include "tdenetman-connection_editor.h"
#include "tdenetman-connection_settings_dialog.h"
extern unsigned int tdenetworkmanager_editor_dialog_count;
using namespace ConnectionSettings;
/*
@ -54,21 +56,24 @@ class ConnectionListViewItem : public KListViewItem
{
public:
ConnectionListViewItem(TQListView* parent, TDENetworkConnection* connection)
ConnectionListViewItem(TQListView* parent, TQString connection)
: KListViewItem(parent)
, _conn(connection)
{
if (_conn) {
setText(0, _conn->friendlyName);
setText(1, TDENetworkConnectionManager::friendlyConnectionTypeName(_conn->type()));
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnection* conn = (nm)?nm->findConnectionByUUID(connection):NULL;
if (conn) {
setText(0, conn->friendlyName);
setText(1, TDENetworkConnectionManager::friendlyConnectionTypeName(conn->type()));
// TODO: Move to a Factory
if (_conn->type() == TDENetworkConnectionType::WiredEthernet) {
if (conn->type() == TDENetworkConnectionType::WiredEthernet) {
setPixmap(0, KGlobal::iconLoader()->loadIcon("wired", KIcon::Small));
}
else if (_conn->type() == TDENetworkConnectionType::WiFi) {
else if (conn->type() == TDENetworkConnectionType::WiFi) {
setPixmap(0, KGlobal::iconLoader()->loadIcon("wireless", KIcon::Small));
}
else if (_conn->type() == TDENetworkConnectionType::VPN) {
else if (conn->type() == TDENetworkConnectionType::VPN) {
setPixmap(0, KGlobal::iconLoader()->loadIcon("encrypted", KIcon::Small));
}
else {
@ -77,7 +82,7 @@ class ConnectionListViewItem : public KListViewItem
}
}
TDENetworkConnection* _conn;
TQString _conn;
};
/*
@ -86,6 +91,7 @@ class ConnectionListViewItem : public KListViewItem
ConnectionEditorImpl::ConnectionEditorImpl(TQWidget* parent, const char* name, bool modal, WFlags fl)
: ConnectionEditor(parent, name, modal, fl)
{
tdenetworkmanager_editor_dialog_count++;
// TODO: enable combobox if implemented
cboConnectionType->hide();
@ -126,6 +132,8 @@ ConnectionEditorImpl::~ConnectionEditorImpl()
if (pbNew->popup()) {
delete pbNew->popup();
}
tdenetworkmanager_editor_dialog_count--;
}
/*
@ -184,13 +192,15 @@ void ConnectionEditorImpl::slotEditCurrentConnection()
return;
}
TDENetworkConnection* conn = item->_conn;
TDENetworkConnection* conn = nm->findConnectionByUUID(item->_conn);
if (conn) {
// we need the secrets for editing
nm->loadConnectionSecrets(conn->UUID);
ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, false, TQByteArray(), this, "connect_something", false, TQt::WDestructiveClose);
dlg->show();
}
}
@ -209,7 +219,7 @@ void ConnectionEditorImpl::slotRemoveCurrentConnection()
return;
}
TDENetworkConnection* conn = item->_conn;
TDENetworkConnection* conn = nm->findConnectionByUUID(item->_conn);
lvConnections->takeItem(item);
delete item;
@ -232,7 +242,7 @@ void ConnectionEditorImpl::fillConnectionList()
TDENetworkConnectionList* allconmap = nm->connections();
for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDENetworkConnection* conn = *it;
new ConnectionListViewItem(lvConnections, conn);
new ConnectionListViewItem(lvConnections, conn->UUID);
}
}

@ -70,6 +70,8 @@
#include <stdio.h>
unsigned int tdenetworkmanager_editor_dialog_count = 0;
TDENetworkConnectionStatus::TDENetworkConnectionStatus nm_device_state_global = TDENetworkConnectionStatus::Invalid;
NewSecretsDialog::NewSecretsDialog(TDENetworkConnection *connection, TQWidget * parent, const char * name, bool modal, TQt::WFlags f)
@ -157,6 +159,10 @@ Tray* Tray::getInstance()
void Tray::slotEditConnections()
{
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (!nm) return;
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
ConnectionEditorImpl* dlg = new ConnectionEditorImpl(this);
dlg->show();
}
@ -211,7 +217,7 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
{
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
nm->loadConnectionInformation();
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
// clear menu
menu->clear();
@ -728,6 +734,8 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
TDENetworkConnectionList* allconmap;
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
// get all available VPN Connections
active_vpn = 0;
allconmap = nm->connections();
@ -750,8 +758,6 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
}
nm->loadConnectionInformation();
found_any_active_connection = 0;
// Get all active connections
allconmap = nm->connections();

@ -35,6 +35,8 @@
#include "tdenetman-connection_settings_dialog.h"
#include <stdio.h>
extern unsigned int tdenetworkmanager_editor_dialog_count;
using namespace ConnectionSettings;
void VPNTrayComponent::slotShowNewConnectionDialog()
@ -60,6 +62,8 @@ void VPNTrayComponent::addMenuItems(KPopupMenu* menu)
// Get all active connections
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
// get all available VPN Connections
TQPopupMenu* popup = NULL;
TDENetworkConnectionList* allconmap = nm->connections();
@ -88,8 +92,8 @@ void VPNTrayComponent::addMenuItems(KPopupMenu* menu)
|| (connStatus & TDENetworkConnectionStatus::DependencyWait)) {
// This VPN connection is active!
vpn_found = 1;
any_vpn_found = 1;
}
any_vpn_found = 1;
if (vpn_found == 1) {
printf("Active VPN connection found\n\r");
@ -103,8 +107,7 @@ void VPNTrayComponent::addMenuItems(KPopupMenu* menu)
}
if (popup) {
// At least one VPN connection is defined on this system
if (any_vpn_found == 1) {
if (!any_vpn_found) {
inactive_vpn_connections = 0;
}
@ -123,12 +126,34 @@ void VPNTrayComponent::addMenuItems(KPopupMenu* menu)
inactive_vpn_connections = 0;
}
#else
TQStringList defaultNetworkDevices = nm->defaultNetworkDevices();
if (defaultNetworkDevices.count() <= 0) {
// TQStringList defaultNetworkDevices = nm->defaultNetworkDevices();
// if (defaultNetworkDevices.count() <= 0) {
// inactive_vpn_connections = 0;
// }
// See if any connections are active
bool found_any_active_connection = false;
TDENetworkConnectionList* allconmap = nm->connections();
for (TDENetworkConnectionList::Iterator it = allconmap->begin(); it != allconmap->end(); ++it) {
TDENetworkConnection* conn = (*it);
if (!conn) {
continue;
}
if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected)
|| (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) {
continue;
}
// Found an active connection
found_any_active_connection = true;
}
if (!found_any_active_connection) {
inactive_vpn_connections = 0;
}
#endif
if (inactive_vpn_connections > 0) {
menu->insertItem(SmallIcon ("encrypted", TQIconSet::Automatic), i18n("Start VPN connection"), popup);
menu->insertSeparator();

Loading…
Cancel
Save