summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-26 16:55:07 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-26 16:55:07 -0600
commitf285871c3c37ee2cc5c8f1408e2cd56320c90dc5 (patch)
tree9fe37a7cad74d7f13c5fd216c80295a0928833bf
parentcfa58d935e639af93b35447cf4dc194c26156f34 (diff)
downloadtdenetworkmanager-f285871c.tar.gz
tdenetworkmanager-f285871c.zip
Fix VPN editing and connection
-rw-r--r--tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp14
-rw-r--r--tdenetworkmanager/src/tdenetman-connection_editor.cpp42
-rw-r--r--tdenetworkmanager/src/tdenetman-tray.cpp12
-rw-r--r--tdenetworkmanager/src/vpn_tray_component.cpp37
4 files changed, 74 insertions, 31 deletions
diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp
index ba4aa18..36140d8 100644
--- a/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp
+++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_setting_vpn_widget.cpp
@@ -175,12 +175,14 @@ VPNWidgetImpl::Deactivate()
// set the correct service type
_vpnsetting->vpnPluginID = service->getService();
- VPNConfigWidget* config = *_mapServiceWidget.find(service);
- if (config) {
- // update the vpn properties
- _vpnsetting->pluginData = config->getVPNProperties();
- // update the vpn secrets
- _vpnsetting->pluginSecrets = config->getVPNSecrets();
+ if (_mapServiceWidget.find(service) != _mapServiceWidget.end()) {
+ VPNConfigWidget* config = *_mapServiceWidget.find(service);
+ if (config) {
+ // update the vpn properties
+ _vpnsetting->pluginData = config->getVPNProperties();
+ // update the vpn secrets
+ _vpnsetting->pluginSecrets = config->getVPNSecrets();
+ }
}
}
}
diff --git a/tdenetworkmanager/src/tdenetman-connection_editor.cpp b/tdenetworkmanager/src/tdenetman-connection_editor.cpp
index 5a00c30..994105a 100644
--- a/tdenetworkmanager/src/tdenetman-connection_editor.cpp
+++ b/tdenetworkmanager/src/tdenetman-connection_editor.cpp
@@ -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);
- // we need the secrets for editing
- nm->loadConnectionSecrets(conn->UUID);
+ 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();
+ ConnectionSettingsDialogImpl* dlg = new ConnectionSettingsDialogImpl(conn, false, TQByteArray(), this, "connect_something", false, TQt::WDestructiveClose);
+ dlg->show();
+ }
}
@@ -209,11 +219,11 @@ void ConnectionEditorImpl::slotRemoveCurrentConnection()
return;
}
- TDENetworkConnection* conn = item->_conn;
+ TDENetworkConnection* conn = nm->findConnectionByUUID(item->_conn);
lvConnections->takeItem(item);
delete item;
-
+
nm->deleteConnection(conn->UUID);
}
@@ -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);
}
}
diff --git a/tdenetworkmanager/src/tdenetman-tray.cpp b/tdenetworkmanager/src/tdenetman-tray.cpp
index 68aea07..a6b9e34 100644
--- a/tdenetworkmanager/src/tdenetman-tray.cpp
+++ b/tdenetworkmanager/src/tdenetman-tray.cpp
@@ -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();
diff --git a/tdenetworkmanager/src/vpn_tray_component.cpp b/tdenetworkmanager/src/vpn_tray_component.cpp
index 35b32d3..cc696b7 100644
--- a/tdenetworkmanager/src/vpn_tray_component.cpp
+++ b/tdenetworkmanager/src/vpn_tray_component.cpp
@@ -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();