summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-26 13:09:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-26 13:09:21 -0600
commit1351acec11a5f985ef664119c54aba254195f8b2 (patch)
treec2fc19cd9fc5f97ff68bddd8c4531b729f41c6ae
parent08df31ba2c9f242e74a4e61743db1a808a80a356 (diff)
downloadtdelibs-1351acec11a5f985ef664119c54aba254195f8b2.tar.gz
tdelibs-1351acec11a5f985ef664119c54aba254195f8b2.zip
Fix network-manager backend
Add Bluetooth device detection
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.cpp48
-rw-r--r--tdecore/networkbackends/network-manager/network-manager.h5
-rw-r--r--tdecore/networkbackends/network-manager/network-manager_p.h1
-rw-r--r--tdecore/tdehardwaredevices.cpp12
-rw-r--r--tdecore/tdehardwaredevices.h1
-rw-r--r--tdecore/tdenetworkconnections.cpp11
6 files changed, 72 insertions, 6 deletions
diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp
index a3ebba325..a4ff24a90 100644
--- a/tdecore/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/networkbackends/network-manager/network-manager.cpp
@@ -26,10 +26,10 @@
// #define DEBUG_NETWORK_MANAGER_COMMUNICATIONS
-#define PRINT_ERROR(x) printf("[TDE NM Backend ERROR] %s\n\r", x.ascii());
+#define PRINT_ERROR(x) printf("[TDE NM Backend ERROR] [%s:%d] %s\n\r", __FILE__, __LINE__, x.ascii());
#ifdef DEBUG_NETWORK_MANAGER_COMMUNICATIONS
-#define PRINT_WARNING(x) printf("[TDE NM Backend WARNING] %s\n\r", x.ascii());
+#define PRINT_WARNING(x) printf("[TDE NM Backend WARNING] [%s:%d] %s\n\r", __FILE__, __LINE__, x.ascii());
#else
#define PRINT_WARNING(x)
#endif
@@ -1592,6 +1592,9 @@ TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceInforma
ret.autoConnect = d->m_networkDeviceProxy->getAutoconnect(error);
ret.firmwareMissing = d->m_networkDeviceProxy->getFirmwareMissing(error);
ret.deviceType = nmDeviceTypeToTDEDeviceType(d->m_networkDeviceProxy->getDeviceType(error));
+ if (error.isValid()) {
+ PRINT_ERROR(error.name())
+ }
// Populate wiFiInfo
if ((deviceType() == TDENetworkDeviceType::WiFi) && (d->m_wiFiDeviceProxy)) {
@@ -1601,8 +1604,15 @@ TDENetworkDeviceInformation TDENetworkConnectionManager_BackendNM::deviceInforma
ret.wiFiInfo.operatingMode = nmWiFiModeToTDEWiFiMode(d->m_wiFiDeviceProxy->getMode(error));
ret.wiFiInfo.bitrate = d->m_wiFiDeviceProxy->getBitrate(error);
TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(d->m_wiFiDeviceProxy->getActiveAccessPoint(error));
+ if (error.isValid()) {
+ PRINT_ERROR(error.name())
+ }
if (apInfo) {
ret.wiFiInfo.activeAccessPointBSSID = apInfo->BSSID;
+ TDENetworkWiFiAPInfo* neighborListAPInfo = findAccessPointByBSSID(ret.wiFiInfo.activeAccessPointBSSID);
+ if (neighborListAPInfo) {
+ *neighborListAPInfo = *apInfo;
+ }
delete apInfo;
}
else {
@@ -1646,6 +1656,10 @@ void TDENetworkConnectionManager_BackendNMPrivate::processAddConnectionAsyncRepl
}
void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
+ if (d->nonReentrantCallActive) return;
+
+ d->nonReentrantCallActive = true;
+
TDEMACAddress deviceMACAddress;
deviceMACAddress.fromString(m_macAddress);
@@ -2755,6 +2769,8 @@ void TDENetworkConnectionManager_BackendNM::loadConnectionInformation() {
}
internalNetworkManagementEvent(TDENetworkGlobalEventType::ConnectionListChanged);
}
+
+ d->nonReentrantCallActive = false;
}
void TDENetworkConnectionManager_BackendNM::loadConnectionAllowedValues(TDENetworkConnection* connection) {
@@ -4590,6 +4606,28 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
}
}
+TQCString TDENetworkConnectionManager_BackendNM::getActiveConnectionPath(TQString uuid) {
+ TQT_DBusObjectPath existingConnection;
+ TQT_DBusError error;
+ if (d->m_networkManagerProxy) {
+ TQT_DBusObjectPathList activeConnections = d->m_networkManagerProxy->getActiveConnections(error);
+ TQT_DBusObjectPathList::iterator it;
+ for (it = activeConnections.begin(); it != activeConnections.end(); ++it) {
+ DBus::ActiveConnectionProxy activeConnection(NM_DBUS_SERVICE, (*it));
+ activeConnection.setConnection(TQT_DBusConnection::systemBus());
+ if (activeConnection.getUuid(error) == uuid) {
+ return (*it);
+ }
+ }
+ PRINT_WARNING(TQString("active connection for provided uuid '%1' was not found").arg(uuid));
+ return TQT_DBusObjectPath();
+ }
+ else {
+ PRINT_ERROR(TQString("invalid internal network-manager settings proxy object"));
+ return TQT_DBusObjectPath();
+ }
+}
+
TQStringList TDENetworkConnectionManager_BackendNM::connectionPhysicalDeviceUUIDs(TQString uuid) {
if (deviceType() == TDENetworkDeviceType::BackendOnly) {
return TQStringList();
@@ -4666,8 +4704,8 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
TQT_DBusError error;
bool ret;
if ((d->m_networkManagerSettings) && (d->m_networkManagerProxy)) {
- ret = d->m_networkManagerSettings->GetConnectionByUuid(uuid, existingConnection, error);
- if (ret) {
+ existingConnection = getActiveConnectionPath(uuid);
+ if (existingConnection.isValid()) {
TQString dbusDeviceString;
if (m_macAddress == "") {
dbusDeviceString = "/";
@@ -5104,7 +5142,7 @@ TQStringList TDENetworkConnectionManager_BackendNM::defaultNetworkDevices() {
}
}
-TDENetworkConnectionManager_BackendNMPrivate::TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_vpnProxy(NULL), m_parent(parent) {
+TDENetworkConnectionManager_BackendNMPrivate::TDENetworkConnectionManager_BackendNMPrivate(TDENetworkConnectionManager_BackendNM* parent) : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL), m_wiFiDeviceProxy(NULL), m_vpnProxy(NULL), nonReentrantCallActive(false), m_parent(parent) {
//
}
diff --git a/tdecore/networkbackends/network-manager/network-manager.h b/tdecore/networkbackends/network-manager/network-manager.h
index 5b475eea7..15c3a8fad 100644
--- a/tdecore/networkbackends/network-manager/network-manager.h
+++ b/tdecore/networkbackends/network-manager/network-manager.h
@@ -29,6 +29,10 @@
#define NM_VPN_DBUS_PLUGIN_PATH "/org/freedesktop/NetworkManager/VPN/Plugin"
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
+#define NM_DBUS_ACTIVE_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Connection.Active"
+#define NM_DBUS_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device"
+#define NM_DBUS_WIRED_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device.Wired"
+#define NM_DBUS_WIRELESS_DEVICE_SERVICE "org.freedesktop.NetworkManager.Device.Wireless"
#define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings"
#define NM_DBUS_SETTINGS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Settings.Connection"
#define NM_VPN_DBUS_PLUGIN_SERVICE "org.freedesktop.NetworkManager.VPN.Plugin"
@@ -186,6 +190,7 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
bool loadConnectionSecretsForGroup(TQString uuid, TQString group);
TDENetworkWiFiAPInfo* getAccessPointDetails(TQString dbusPath);
TDENetworkConnectionType::TDENetworkConnectionType connectionType(TQString dbusPath);
+ TQCString getActiveConnectionPath(TQString uuid);
private:
TDENetworkConnectionManager_BackendNMPrivate* d;
diff --git a/tdecore/networkbackends/network-manager/network-manager_p.h b/tdecore/networkbackends/network-manager/network-manager_p.h
index 4ef3affe8..299f539f2 100644
--- a/tdecore/networkbackends/network-manager/network-manager_p.h
+++ b/tdecore/networkbackends/network-manager/network-manager_p.h
@@ -84,6 +84,7 @@ class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting;
NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse;
NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse;
+ bool nonReentrantCallActive;
public slots:
void processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&);
diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp
index bb979f79a..d4a10c340 100644
--- a/tdecore/tdehardwaredevices.cpp
+++ b/tdecore/tdehardwaredevices.cpp
@@ -2724,6 +2724,9 @@ TDEGenericDeviceType::TDEGenericDeviceType readGenericDeviceTypeFromString(TQStr
else if (query == "ThermalControl") {
ret = TDEGenericDeviceType::ThermalControl;
}
+ else if (query == "BlueTooth") {
+ ret = TDEGenericDeviceType::BlueTooth;
+ }
else if (query == "Bridge") {
ret = TDEGenericDeviceType::Bridge;
}
@@ -3262,6 +3265,9 @@ TDEGenericDevice* TDEHardwareDevices::classifyUnknownDevice(udev_device* dev, TD
if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::TextIO);
}
}
+ else if (devicesubsystem == "bluetooth") {
+ if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::BlueTooth);
+ }
else if (devicesubsystem == "usb-serial") {
if (!device) device = new TDEGenericDevice(TDEGenericDeviceType::Serial);
}
@@ -5281,6 +5287,9 @@ TQString TDEHardwareDevices::getFriendlyDeviceTypeStringFromType(TDEGenericDevic
else if (query == TDEGenericDeviceType::ThermalControl) {
ret = i18n("Thermal Control");
}
+ else if (query == TDEGenericDeviceType::BlueTooth) {
+ ret = i18n("BlueTooth");
+ }
else if (query == TDEGenericDeviceType::Bridge) {
ret = i18n("Bridge");
}
@@ -5433,6 +5442,9 @@ TQPixmap TDEHardwareDevices::getDeviceTypeIconFromType(TDEGenericDeviceType::TDE
else if (query == TDEGenericDeviceType::ThermalControl) {
ret = DesktopIcon("kcmdevices", size); // FIXME
}
+ else if (query == TDEGenericDeviceType::BlueTooth) {
+ ret = DesktopIcon("kcmpci", size); // FIXME
+ }
else if (query == TDEGenericDeviceType::Bridge) {
ret = DesktopIcon("kcmpci", size);
}
diff --git a/tdecore/tdehardwaredevices.h b/tdecore/tdehardwaredevices.h
index 1f87301c5..b6d0dd5ef 100644
--- a/tdecore/tdehardwaredevices.h
+++ b/tdecore/tdehardwaredevices.h
@@ -91,6 +91,7 @@ enum TDEGenericDeviceType {
Dock,
ThermalSensor,
ThermalControl,
+ BlueTooth,
Bridge,
Platform,
Cryptography,
diff --git a/tdecore/tdenetworkconnections.cpp b/tdecore/tdenetworkconnections.cpp
index 14117d990..5f1f85414 100644
--- a/tdecore/tdenetworkconnections.cpp
+++ b/tdecore/tdenetworkconnections.cpp
@@ -208,7 +208,16 @@ void TDEMACAddress::setAddress(TDENetworkByteList address) {
}
bool TDEMACAddress::isValid() {
- return m_isValid;
+ if (!m_isValid) {
+ return false;
+ }
+
+ if (m_macAddress.count() > 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
}
void TDEMACAddress::fromString(TQString address) {