diff options
Diffstat (limited to 'tdenetworkmanager/src/vpn_tray_component.cpp')
-rw-r--r-- | tdenetworkmanager/src/vpn_tray_component.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
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(); |