summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-29 20:07:31 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-29 20:07:31 -0600
commit9e5d27963b3bf1b0a2d76ef165616fdfaf58b825 (patch)
tree9cc996e374d092b40851fc5c7857a1479bf141f8
parent2277bfa0d62d052c5a1fa42425ed6ed23d1cc96d (diff)
downloadtdelibs-9e5d27963b3bf1b0a2d76ef165616fdfaf58b825.tar.gz
tdelibs-9e5d27963b3bf1b0a2d76ef165616fdfaf58b825.zip
Fix various performance and stability issues in the network-manager backend
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.cpp31
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.h1
-rw-r--r--tdecore/tdenetworkconnections.cpp91
-rw-r--r--tdecore/tdenetworkconnections.h40
4 files changed, 153 insertions, 10 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp
index 05aa97618..e0b11481c 100644
--- a/tdecore/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/networkbackends/network-manager/network-manager.cpp
@@ -1332,7 +1332,7 @@ void TDENetworkConnectionManager_BackendNM_DBusSignalReceiver::dbusSignal(const
TQString member = message.member();
TQString path = message.path();
-// printf("[DEBUG] In dbusSignal: sender: %s, member: %s, interface: %s, path: %s\n\r", sender.ascii(), member.ascii(), interface.ascii(), path.ascii()); fflush(stdout);
+// printf("[DEBUG] In dbusSignal: sender: %s, member: %s, interface: %s, path: %s, parent path: %s\n\r", sender.ascii(), member.ascii(), interface.ascii(), path.ascii(), m_parent->m_dbusDeviceString.ascii()); fflush(stdout);
if (interface == NM_VPN_DBUS_CONNECTION_SERVICE) {
if (member == "VpnStateChanged") {
@@ -1711,6 +1711,31 @@ TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceInforma
return ret;
}
+TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceStatus() {
+ TQT_DBusError error;
+ TDENetworkDeviceInformation ret;
+
+ if (d->m_networkDeviceProxy) {
+ ret.statusFlags = nmDeviceStateToTDEDeviceState(d->m_networkDeviceProxy->getState(error));
+ ret.UUID = d->m_networkDeviceProxy->getUdi(error);
+
+ // Get active connection UUID
+ TQT_DBusObjectPath connectionPath = d->m_networkDeviceProxy->getActiveConnection(error);
+ if (!error.isValid()) {
+ DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, connectionPath);
+ activeConnection.setConnection(TQT_DBusConnection::systemBus());
+ ret.activeConnectionUUID = activeConnection.getUuid(error);
+ if (!error.isValid()) {
+ ret.activeConnectionUUID = TQString::null;
+ }
+ }
+
+ ret.valid = true;
+ }
+
+ return ret;
+}
+
void TDENetworkConnectionManager_BackendNMPrivate::processConnectionSettingsAsyncReply(int asyncCallId, const TQT_DBusDataMap<TQString>& settings) {
nmConnectionSettingsAsyncCallWaiting[asyncCallId] = false;
nmConnectionSettingsAsyncSettingsResponse[asyncCallId] = settings;
@@ -4660,7 +4685,9 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
}
return checkConnectionStatus(uuid);
#else // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
connect(d->m_networkManagerProxy, SIGNAL(ActivateConnectionAsyncReply(int, const TQT_DBusObjectPath&)), d, SLOT(processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&)));
+#endif // WAIT_FOR_OPERATION_BEFORE_RETURNING
int asyncCallID;
ret = d->m_networkManagerProxy->ActivateConnectionAsync(asyncCallID, existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), error);
if (ret && error.isValid()) {
@@ -4841,7 +4868,9 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
}
return checkConnectionStatus(uuid);
#else // USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
+#ifdef WAIT_FOR_OPERATION_BEFORE_RETURNING
connect(d->m_networkManagerProxy, SIGNAL(DeactivateConnectionAsyncReply(int)), d, SLOT(processConnectionSettingsUpdateAsyncReply(int)));
+#endif // WAIT_FOR_OPERATION_BEFORE_RETURNING
int asyncCallID;
ret = d->m_networkManagerProxy->DeactivateConnectionAsync(asyncCallID, existingConnection, error);
if (ret && error.isValid()) {
diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h
index f06643b6e..2063a036b 100644
--- a/tdecore/networkbackends/network-manager/network-manager.h
+++ b/tdecore/networkbackends/network-manager/network-manager.h
@@ -159,6 +159,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
virtual TDENetworkDeviceType::TDENetworkDeviceType deviceType();
virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus();
virtual TDENetworkDeviceInformation deviceInformation();
+ virtual TDENetworkDeviceInformation deviceStatus();
virtual void loadConnectionInformation();
virtual void loadConnectionAllowedValues(TDENetworkConnection* connection);
diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp
index 82df5c8cc..80f34b765 100644
--- a/tdecore/tdenetworkconnections.cpp
+++ b/tdecore/tdenetworkconnections.cpp
@@ -21,8 +21,12 @@
#include "config.h"
+#include <tqtimer.h>
+
#include <klocale.h>
+// #define DEBUG_SIGNAL_QUEUE 1
+
#ifdef WITH_NETWORK_MANAGER_BACKEND
#include "networkbackends/network-manager/network-manager.h"
#endif // WITH_NETWORK_MANAGER_BACKEND
@@ -684,11 +688,14 @@ TDEWiFiConnection::~TDEWiFiConnection() {
/*================================================================================================*/
TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_hwNeighborList(NULL), m_macAddress(macAddress), m_prevConnectionStatus(TDENetworkGlobalManagerFlags::Unknown) {
- //
+ m_emissionTimer = new TQTimer();
+ connect(m_emissionTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(emitQueuedSignals()));
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
TDENetworkConnectionManager::~TDENetworkConnectionManager() {
- //
+ m_emissionTimer->stop();
+ delete m_emissionTimer;
}
TQString TDENetworkConnectionManager::deviceMACAddress() {
@@ -828,7 +835,13 @@ void TDENetworkConnectionManager::clearTDENetworkHWNeighborList() {
}
void TDENetworkConnectionManager::internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState) {
- emit(networkConnectionStateChanged(m_prevConnectionStatus, newState));
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 0;
+ queuedEvent.newState = newState;
+ queuedEvent.previousState = m_prevConnectionStatus;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+
m_prevConnectionStatus = newState;
}
@@ -836,24 +849,86 @@ void TDENetworkConnectionManager::internalNetworkDeviceStateChanged(TDENetworkCo
if (!m_prevDeviceStatus.contains(hwAddress)) {
m_prevDeviceStatus[hwAddress] = TDENetworkConnectionStatus::Invalid;
}
- emit(networkDeviceStateChanged(newState, m_prevDeviceStatus[hwAddress], hwAddress));
+
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 1;
+ queuedEvent.newConnStatus = newState;
+ queuedEvent.previousConnStatus = m_prevDeviceStatus[hwAddress];
+ queuedEvent.hwAddress = hwAddress;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+
m_prevDeviceStatus[hwAddress] = newState;
}
void TDENetworkConnectionManager::internalAccessPointStatusChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) {
- emit(accessPointStatusChanged(BSSID, event));
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 2;
+ queuedEvent.BSSID = BSSID;
+ queuedEvent.apevent = event;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::internalNetworkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message) {
- emit(networkDeviceEvent(event, message));
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 3;
+ queuedEvent.ndevent = event;
+ queuedEvent.message = message;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::internalVpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType event, TQString message) {
- emit(vpnEvent(event, message));
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 4;
+ queuedEvent.vpnevent = event;
+ queuedEvent.message = message;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
}
void TDENetworkConnectionManager::internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event) {
- emit(networkManagementEvent(event));
+ TDENetworkEventQueueEvent_Private queuedEvent;
+ queuedEvent.eventType = 5;
+ queuedEvent.globalevent = event;
+ m_globalEventQueueEventList.append(queuedEvent);
+ if (!m_emissionTimer->isActive()) m_emissionTimer->start(0, TRUE);
+}
+
+void TDENetworkConnectionManager::emitQueuedSignals() {
+ if (!m_globalEventQueueEventList.isEmpty()) {
+#ifdef DEBUG_SIGNAL_QUEUE
+ kdDebug() << "TDENetworkConnectionManager::emitQueuedSignals: Going to dequeue " << m_globalEventQueueEventList.count() << " events..." << endl;
+#endif // DEBUG_SIGNAL_QUEUE
+ TDENetworkEventQueueEvent_PrivateList::Iterator it;
+ it = m_globalEventQueueEventList.begin();
+ while (it != m_globalEventQueueEventList.end()) {
+ TDENetworkEventQueueEvent_Private event = (*it);
+ it = m_globalEventQueueEventList.remove(it);
+ if (event.eventType == 0) {
+ emit(networkConnectionStateChanged(event.newState, event.previousState));
+ }
+ else if (event.eventType == 1) {
+ emit(networkDeviceStateChanged(event.newConnStatus, event.previousConnStatus, event.hwAddress));
+ }
+ else if (event.eventType == 2) {
+ emit(accessPointStatusChanged(event.BSSID, event.apevent));
+ }
+ else if (event.eventType == 3) {
+ emit(networkDeviceEvent(event.ndevent, event.message));
+ }
+ else if (event.eventType == 4) {
+ emit(vpnEvent(event.vpnevent, event.message));
+ }
+ else if (event.eventType == 5) {
+ emit(networkManagementEvent(event.globalevent));
+ }
+ }
+#ifdef DEBUG_SIGNAL_QUEUE
+ kdDebug() << "TDENetworkConnectionManager::emitQueuedSignals: " << m_globalEventQueueEventList.count() << " events remain in queue" << endl;
+#endif // DEBUG_SIGNAL_QUEUE
+ }
}
/*================================================================================================*/
diff --git a/tdecore/tdenetworkconnections.h b/tdecore/tdenetworkconnections.h
index b1e02ce9d..b8425196a 100644
--- a/tdecore/tdenetworkconnections.h
+++ b/tdecore/tdenetworkconnections.h
@@ -990,6 +990,29 @@ class TDECORE_EXPORT TDEModemConnection : public TDENetworkConnection
typedef TQPtrList< TDENetworkConnection > TDENetworkConnectionList;
+/**
+* INTERNAL CLASS
+*/
+class TDENetworkEventQueueEvent_Private
+{
+ public:
+ int eventType;
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState;
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags previousState;
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus newConnStatus;
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus previousConnStatus;
+ TDEMACAddress BSSID;
+ TQString message;
+ TQString hwAddress;
+ TDENetworkAPEventType::TDENetworkAPEventType apevent;
+ TDENetworkDeviceEventType::TDENetworkDeviceEventType ndevent;
+ TDENetworkVPNEventType::TDENetworkVPNEventType vpnevent;
+ TDENetworkGlobalEventType::TDENetworkGlobalEventType globalevent;
+};
+typedef TQValueList<TDENetworkEventQueueEvent_Private> TDENetworkEventQueueEvent_PrivateList;
+
+class TQTimer;
+
class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
{
Q_OBJECT
@@ -1024,11 +1047,21 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
virtual TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags backendStatus() = 0;
/**
- * @return A TDENetworkDeviceInformation object containing the current status of the network device.
+ * @return A TDENetworkDeviceInformation object containing the current configuration and status of the network device.
*/
virtual TDENetworkDeviceInformation deviceInformation() = 0;
/**
+ * @return A TDENetworkDeviceInformation object containing a (limited) current status of the network device.
+ * Only the following object fields are populated:
+ * statusFlags
+ * UUID
+ * activeConnectionUUID
+ * valid
+ */
+ virtual TDENetworkDeviceInformation deviceStatus() = 0;
+
+ /**
* Loads all connection information from the configuration backend
* Secret information must be loaded separately via a call to
* loadConnectionSecrets(TQString uuid) after this method has been
@@ -1311,12 +1344,17 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
void internalNetworkManagementEvent(TDENetworkGlobalEventType::TDENetworkGlobalEventType event);
+ protected slots:
+ void emitQueuedSignals();
+
protected:
TDENetworkConnectionList* m_connectionList;
TDENetworkHWNeighborList* m_hwNeighborList;
TQString m_macAddress;
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags m_prevConnectionStatus;
TQMap<TQString, TDENetworkConnectionStatus::TDENetworkConnectionStatus> m_prevDeviceStatus;
+ TQTimer* m_emissionTimer;
+ TDENetworkEventQueueEvent_PrivateList m_globalEventQueueEventList;
};
class TDECORE_EXPORT TDEGlobalNetworkManager : public TQObject