summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-02-22 14:08:40 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-02-22 14:42:55 +0900
commitf3cd32503240eee2c0f1749ba5410dddb59355a4 (patch)
tree3f9206b40c045b7f2b14f36c3c6291145613b6c0 /tdecore/tdehw
parentd94da50a46bea897c5122aae6d1f56e0a6780a82 (diff)
downloadtdelibs-f3cd32503240eee2c0f1749ba5410dddb59355a4.tar.gz
tdelibs-f3cd32503240eee2c0f1749ba5410dddb59355a4.zip
Prevent tdenetworkmanager from crashing when using unmanaged devices.
This relates to bug 2929. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 3192a72a465d6e5051ab77a43e75716bb641441c)
Diffstat (limited to 'tdecore/tdehw')
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager.cpp83
1 files changed, 46 insertions, 37 deletions
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
index 2f11dd59b..d15db3dc8 100644
--- a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
@@ -1158,16 +1158,16 @@ TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString d
return (*it);
}
}
- return "";
+ return TQString::null;
}
else {
// Error!
PRINT_ERROR((error.name() + ": " + error.message()))
- return "";
+ return TQString::null;
}
}
else {
- return "";
+ return TQString::null;
}
}
@@ -1251,7 +1251,7 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TDE
d->m_vpnProxy->setConnection(TQT_DBusConnection::systemBus());
d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
- if (d->m_dbusDeviceString != "") {
+ if (!d->m_dbusDeviceString.isEmpty()) {
d->m_networkDeviceProxy = new DBus::DeviceProxy(NM_DBUS_SERVICE, d->m_dbusDeviceString);
d->m_networkDeviceProxy->setConnection(TQT_DBusConnection::systemBus());
if (deviceType() == TDENetworkDeviceType::WiFi) {
@@ -1569,28 +1569,27 @@ TDENetworkDeviceType::TDENetworkDeviceType TDENetworkConnectionManager_BackendNM
if (!m_networkDevice) {
return TDENetworkDeviceType::BackendOnly;
}
- else {
- if (d->m_dbusDeviceString != "") {
- // Query NM for the device type
- TQT_DBusError error;
- d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
- DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
- genericDevice.setConnection(TQT_DBusConnection::systemBus());
- TDENetworkDeviceType::TDENetworkDeviceType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
- if (error.isValid()) {
- // Error!
- PRINT_ERROR((error.name() + ": " + error.message()))
- return TDENetworkDeviceType::Other;
- }
- else {
- return ret;
- }
- }
- else {
+
+ // Query NM for the device type
+ TQT_DBusError error;
+ d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
+ if (!d->m_dbusDeviceString.isEmpty()) {
+ DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
+ genericDevice.setConnection(TQT_DBusConnection::systemBus());
+ TDENetworkDeviceType::TDENetworkDeviceType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
+ if (error.isValid()) {
// Error!
- PRINT_ERROR(TQString("Invalid DBUS device string '%1'").arg(d->m_dbusDeviceString))
+ PRINT_ERROR((error.name() + ": " + error.message()))
return TDENetworkDeviceType::Other;
}
+ else {
+ return ret;
+ }
+ }
+ else {
+ // Error!
+ PRINT_ERROR(TQString("Invalid empty DBUS device string"))
+ return TDENetworkDeviceType::Other;
}
}
@@ -4843,6 +4842,10 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
else {
d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
}
+ if (d->m_dbusDeviceString.isEmpty()) {
+ PRINT_ERROR(TQString("Invalid empty DBUS device string"))
+ return TDENetworkConnectionStatus::Invalid;
+ }
#ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
TQT_DBusObjectPath active_connection;
ret = d->m_networkManagerProxy->ActivateConnection(existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), active_connection, error);
@@ -5036,6 +5039,10 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
else {
d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
}
+ if (d->m_dbusDeviceString.isEmpty()) {
+ PRINT_ERROR(TQString("Invalid empty DBUS device string"))
+ return TDENetworkConnectionStatus::Invalid;
+ }
#ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
ret = d->m_networkManagerProxy->DeactivateConnection(existingConnection, error);
if (ret && error.isValid()) {
@@ -5322,20 +5329,22 @@ TDENetworkHWNeighborList* TDENetworkConnectionManager_BackendNM::siteSurvey() {
clearTDENetworkHWNeighborList();
if (myDeviceType == TDENetworkDeviceType::WiFi) {
- DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
- wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
- // FIXME
- // Should call wiFiDevice.RequestScanAsync first to rescan all access points
- TQT_DBusObjectPathList accessPoints;
- ret = wiFiDevice.GetAccessPoints(accessPoints, error);
- if (ret) {
- TQT_DBusObjectPathList::iterator it;
- for (it = accessPoints.begin(); it != accessPoints.end(); ++it) {
- TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(TQString(*it));
- if (apInfo) {
- m_hwNeighborList->append(apInfo);
- // Ensure that this AP is monitored for changes
- d->internalProcessWiFiAccessPointAdded(*it);
+ if (!d->m_dbusDeviceString.isEmpty()) {
+ DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
+ wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
+ // FIXME
+ // Should call wiFiDevice.RequestScanAsync first to rescan all access points
+ TQT_DBusObjectPathList accessPoints;
+ ret = wiFiDevice.GetAccessPoints(accessPoints, error);
+ if (ret) {
+ TQT_DBusObjectPathList::iterator it;
+ for (it = accessPoints.begin(); it != accessPoints.end(); ++it) {
+ TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(TQString(*it));
+ if (apInfo) {
+ m_hwNeighborList->append(apInfo);
+ // Ensure that this AP is monitored for changes
+ d->internalProcessWiFiAccessPointAdded(*it);
+ }
}
}
}