Prevent tdenetworkmanager from crashing when using unmanaged devices.

This relates to bug 2929.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/76/head
Michele Calgaro 5 years ago
parent 30606e55f1
commit 3192a72a46
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1156,16 +1156,16 @@ TQString TDENetworkConnectionManager_BackendNM::deviceInterfaceString(TQString d
return (*it); return (*it);
} }
} }
return ""; return TQString::null;
} }
else { else {
// Error! // Error!
PRINT_ERROR((error.name() + ": " + error.message())) PRINT_ERROR((error.name() + ": " + error.message()))
return ""; return TQString::null;
} }
} }
else { else {
return ""; return TQString::null;
} }
} }
@ -1249,7 +1249,7 @@ TDENetworkConnectionManager_BackendNM::TDENetworkConnectionManager_BackendNM(TDE
d->m_vpnProxy->setConnection(TQT_DBusConnection::systemBus()); d->m_vpnProxy->setConnection(TQT_DBusConnection::systemBus());
d->m_dbusDeviceString = deviceInterfaceString(deviceNode()); 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 = new DBus::DeviceProxy(NM_DBUS_SERVICE, d->m_dbusDeviceString);
d->m_networkDeviceProxy->setConnection(TQT_DBusConnection::systemBus()); d->m_networkDeviceProxy->setConnection(TQT_DBusConnection::systemBus());
if (deviceType() == TDENetworkDeviceType::WiFi) { if (deviceType() == TDENetworkDeviceType::WiFi) {
@ -1567,28 +1567,27 @@ TDENetworkDeviceType::TDENetworkDeviceType TDENetworkConnectionManager_BackendNM
if (!m_networkDevice) { if (!m_networkDevice) {
return TDENetworkDeviceType::BackendOnly; return TDENetworkDeviceType::BackendOnly;
} }
else {
if (d->m_dbusDeviceString != "") { // Query NM for the device type
// Query NM for the device type TQT_DBusError error;
TQT_DBusError error; d->m_dbusDeviceString = deviceInterfaceString(deviceNode());
d->m_dbusDeviceString = deviceInterfaceString(deviceNode()); if (!d->m_dbusDeviceString.isEmpty()) {
DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString); DBus::DeviceProxy genericDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
genericDevice.setConnection(TQT_DBusConnection::systemBus()); genericDevice.setConnection(TQT_DBusConnection::systemBus());
TDENetworkDeviceType::TDENetworkDeviceType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error)); TDENetworkDeviceType::TDENetworkDeviceType ret = nmDeviceTypeToTDEDeviceType(genericDevice.getDeviceType(error));
if (error.isValid()) { if (error.isValid()) {
// Error!
PRINT_ERROR((error.name() + ": " + error.message()))
return TDENetworkDeviceType::Other;
}
else {
return ret;
}
}
else {
// Error! // Error!
PRINT_ERROR(TQString("Invalid DBUS device string '%1'").arg(d->m_dbusDeviceString)) PRINT_ERROR((error.name() + ": " + error.message()))
return TDENetworkDeviceType::Other; return TDENetworkDeviceType::Other;
} }
else {
return ret;
}
}
else {
// Error!
PRINT_ERROR(TQString("Invalid empty DBUS device string"))
return TDENetworkDeviceType::Other;
} }
} }
@ -4791,6 +4790,10 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
else { else {
d->m_dbusDeviceString = deviceInterfaceString(deviceNode()); 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 #ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
TQT_DBusObjectPath active_connection; TQT_DBusObjectPath active_connection;
ret = d->m_networkManagerProxy->ActivateConnection(existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), active_connection, error); ret = d->m_networkManagerProxy->ActivateConnection(existingConnection, TQT_DBusObjectPath(d->m_dbusDeviceString.ascii()), TQT_DBusObjectPath("/"), active_connection, error);
@ -4984,6 +4987,10 @@ TDENetworkConnectionStatus::TDENetworkConnectionStatus TDENetworkConnectionManag
else { else {
d->m_dbusDeviceString = deviceInterfaceString(deviceNode()); 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 #ifndef USE_ASYNC_DBUS_CONNECTION_COMMAND_CALLS
ret = d->m_networkManagerProxy->DeactivateConnection(existingConnection, error); ret = d->m_networkManagerProxy->DeactivateConnection(existingConnection, error);
if (ret && error.isValid()) { if (ret && error.isValid()) {
@ -5270,20 +5277,22 @@ TDENetworkHWNeighborList* TDENetworkConnectionManager_BackendNM::siteSurvey() {
clearTDENetworkHWNeighborList(); clearTDENetworkHWNeighborList();
if (myDeviceType == TDENetworkDeviceType::WiFi) { if (myDeviceType == TDENetworkDeviceType::WiFi) {
DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString); if (!d->m_dbusDeviceString.isEmpty()) {
wiFiDevice.setConnection(TQT_DBusConnection::systemBus()); DBus::WiFiDeviceProxy wiFiDevice(NM_DBUS_SERVICE, d->m_dbusDeviceString);
// FIXME wiFiDevice.setConnection(TQT_DBusConnection::systemBus());
// Should call wiFiDevice.RequestScanAsync first to rescan all access points // FIXME
TQT_DBusObjectPathList accessPoints; // Should call wiFiDevice.RequestScanAsync first to rescan all access points
ret = wiFiDevice.GetAccessPoints(accessPoints, error); TQT_DBusObjectPathList accessPoints;
if (ret) { ret = wiFiDevice.GetAccessPoints(accessPoints, error);
TQT_DBusObjectPathList::iterator it; if (ret) {
for (it = accessPoints.begin(); it != accessPoints.end(); ++it) { TQT_DBusObjectPathList::iterator it;
TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(TQString(*it)); for (it = accessPoints.begin(); it != accessPoints.end(); ++it) {
if (apInfo) { TDENetworkWiFiAPInfo* apInfo = getAccessPointDetails(TQString(*it));
m_hwNeighborList->append(apInfo); if (apInfo) {
// Ensure that this AP is monitored for changes m_hwNeighborList->append(apInfo);
d->internalProcessWiFiAccessPointAdded(*it); // Ensure that this AP is monitored for changes
d->internalProcessWiFiAccessPointAdded(*it);
}
} }
} }
} }

Loading…
Cancel
Save