diff options
Diffstat (limited to 'tdecore')
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager.cpp | 53 | ||||
-rw-r--r-- | tdecore/networkbackends/network-manager/network-manager_p.h | 5 |
2 files changed, 52 insertions, 6 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp index c7394197b..2291ef225 100644 --- a/tdecore/networkbackends/network-manager/network-manager.cpp +++ b/tdecore/networkbackends/network-manager/network-manager.cpp @@ -1200,7 +1200,16 @@ void TDENetworkConnectionManager_BackendNMPrivate::internalProcessDeviceStateCha void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath& dbuspath) { TDENetworkWiFiAPInfo* apInfo = m_parent->getAccessPointDetails(dbuspath); if (apInfo) { - m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::Discovered); + if (!m_accessPointProxyList.contains(dbuspath)) { + // Set up monitoring object + DBus::AccessPointProxy* apProxy = new DBus::AccessPointProxy(NM_DBUS_SERVICE, dbuspath); + apProxy->setConnection(TQT_DBusConnection::systemBus()); + connect(apProxy, SIGNAL(PropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&)), this, SLOT(internalProcessAPPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&))); + m_accessPointProxyList[dbuspath] = (apProxy); + + // Notify client applications + m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::Discovered); + } delete apInfo; } } @@ -1208,8 +1217,16 @@ void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiAccessPoin void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath& dbuspath) { TDENetworkWiFiAPInfo* apInfo = m_parent->getAccessPointDetails(dbuspath); if (apInfo) { + // Notify client applications m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::Lost); delete apInfo; + + // Destroy related monitoring object + DBus::AccessPointProxy* apProxy = m_accessPointProxyList[dbuspath]; + m_accessPointProxyList.remove(dbuspath); + if (apProxy) { + delete apProxy; + } } } @@ -1228,10 +1245,17 @@ void TDENetworkConnectionManager_BackendNMPrivate::internalProcessWiFiProperties } } -// FIXME -// If access point strength changes, this must be called: -// m_parent->internalAccessPointStatusChanged(apInfo->BSSID, TDENetworkAPEventType::SignalStrengthChanged); -// How do I get NetworkManager to notify me when an access point changes strength? Do I have to poll it for this information? +void TDENetworkConnectionManager_BackendNMPrivate::internalProcessAPPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>& props) { + const DBus::AccessPointProxy* apProxy = dynamic_cast<const DBus::AccessPointProxy*>(sender()); + if (apProxy) { + TQT_DBusError error; + TDEMACAddress BSSID; + BSSID.fromString(apProxy->getHwAddress(error)); + if (props.contains("Strength")) { + m_parent->internalAccessPointStatusChanged(BSSID, TDENetworkAPEventType::SignalStrengthChanged); + } + } +} TDENetworkDeviceType::TDENetworkDeviceType TDENetworkConnectionManager_BackendNM::deviceType() { if (m_macAddress == "") { @@ -4257,6 +4281,10 @@ TDENetworkWiFiAPInfo* TDENetworkConnectionManager_BackendNM::getAccessPointDetai apInfo->valid = true; + // Ensure that this AP is monitored for changes + TQT_DBusObjectPath apDBUSPath(TQCString(dbusPath.ascii())); + d->internalProcessWiFiAccessPointAdded(apDBUSPath); + return apInfo; } @@ -4388,5 +4416,20 @@ bool TDENetworkConnectionManager_BackendNM::wiFiEnabled() { } } +TDENetworkConnectionManager_BackendNMPrivate::TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_parent(parent) { + // +} + +TDENetworkConnectionManager_BackendNMPrivate::~TDENetworkConnectionManager_BackendNMPrivate() { + TQMap<TQString, DBus::AccessPointProxy*>::iterator it; + for (it = m_accessPointProxyList.begin(); it != m_accessPointProxyList.end(); ++it) { + DBus::AccessPointProxy *apProxy = it.data(); + if (apProxy) { + delete apProxy; + } + } + m_accessPointProxyList.clear(); +} + #include "network-manager.moc" #include "network-manager_p.moc"
\ No newline at end of file diff --git a/tdecore/networkbackends/network-manager/network-manager_p.h b/tdecore/networkbackends/network-manager/network-manager_p.h index 98e4be066..728b1ac52 100644 --- a/tdecore/networkbackends/network-manager/network-manager_p.h +++ b/tdecore/networkbackends/network-manager/network-manager_p.h @@ -70,7 +70,8 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject Q_OBJECT public: - TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_parent(parent) {} + TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM*); + ~TDENetworkConnectionManager_BackendNMPrivate(); public: DBus::NetworkManagerProxy* m_networkManagerProxy; @@ -91,9 +92,11 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject void internalProcessWiFiAccessPointAdded(const TQT_DBusObjectPath&); void internalProcessWiFiAccessPointRemoved(const TQT_DBusObjectPath&); void internalProcessWiFiPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&); + void internalProcessAPPropertiesChanged(const TQMap<TQString, TQT_DBusVariant>&); private: TDENetworkConnectionManager_BackendNM* m_parent; + TQMap<TQString, DBus::AccessPointProxy*> m_accessPointProxyList; }; #endif // _TDENETWORKBACKEND_NETWORKMANAGER_P_H
\ No newline at end of file |