summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-09-29 23:49:55 +0200
committerSlávek Banko <slavek.banko@axis.cz>2021-10-01 22:28:05 +0200
commit88cc44bac49ac83acb46c439b405b126b04c7ae7 (patch)
tree83064446fda0a284dcbf7320b050eb9cf51519a0
parent0735c7e3f83fa8415890294fbfc45a71860d52c1 (diff)
downloadtdenetworkmanager-88cc44bac49ac83acb46c439b405b126b04c7ae7.tar.gz
tdenetworkmanager-88cc44bac49ac83acb46c439b405b126b04c7ae7.zip
Fix crash in case tdelibs is built without support for NetworkManager.
Fix crash in case of unsuccessful search for device. This resolves issue #8. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp13
-rw-r--r--tdenetworkmanager/src/devicetraycomponent.cpp30
-rw-r--r--tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp22
-rw-r--r--tdenetworkmanager/src/tdenetman-menuitem.cpp2
-rw-r--r--tdenetworkmanager/src/tdenetman-tray.cpp184
-rw-r--r--tdenetworkmanager/src/tdenetman-vpnmanager.cpp136
-rw-r--r--tdenetworkmanager/src/tdenetman-wired_device_tray.cpp13
-rw-r--r--tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp209
-rw-r--r--tdenetworkmanager/src/tdenetman-wireless_manager.cpp43
-rw-r--r--tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp10
-rw-r--r--tdenetworkmanager/src/tdenetman-wireless_network.cpp73
-rw-r--r--tdenetworkmanager/src/vpn_tray_component.cpp8
12 files changed, 487 insertions, 256 deletions
diff --git a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp
index 9cb8b46..c3ac242 100644
--- a/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp
+++ b/tdenetworkmanager/src/configwidgets/tdenetman-connection_settings_dialog.cpp
@@ -287,9 +287,11 @@ ConnectionSettingsDialogImpl::slotConnect()
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
// add/save the connection
- if (nm->saveConnection(_conn)) {
+ if (nm && nm->saveConnection(_conn))
+ {
// activate device
- if (_conn && nm) {
+ if (_conn)
+ {
// // VPN connection needs a special specific object
// if (_conn->getType() == NM_SETTING_VPN_SETTING_NAME) {
// TQT_DBusObjectPath act_conn = nm->getDefaultActiveConnection();
@@ -329,7 +331,8 @@ ConnectionSettingsDialogImpl::slotSave()
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
// save the connection
- if (!nm->saveConnection(_conn)) {
+ if (!nm || !nm->saveConnection(_conn))
+ {
KMessageBox::error(this, i18n("<qt><b>Unable to save network connection!</b><p>Potential causes:<br> * Insufficient permissions<br> * NetworkManager not running<br> * DBUS failure</qt>"), i18n("Unable to perform requested operation"));
}
@@ -453,14 +456,14 @@ ConnectionSettingsDialogImpl::slotEnableButtons()
TDENetworkErrorStringMap errorStringMap;
TDENetworkConnectionErrorFlags::TDENetworkConnectionErrorFlags errorFlags;
bool ret;
- ret = nm->verifyConnectionSettings(_conn, &errorFlags, &errorStringMap);
+ ret = (nm ? nm->verifyConnectionSettings(_conn, &errorFlags, &errorStringMap) : 0);
btnConnect->setEnabled(ret);
if (!ret) {
// FIXME
// Check the error flags and the current dialog type to determine if an error message is warranted
// KMessageBox::error(this, errorString, i18n("Invalid Settings Detected"));
}
- pbSave->setEnabled(nm->verifyConnectionSettings(_conn));
+ pbSave->setEnabled(nm ? nm->verifyConnectionSettings(_conn) : 0);
}
}
diff --git a/tdenetworkmanager/src/devicetraycomponent.cpp b/tdenetworkmanager/src/devicetraycomponent.cpp
index 2ea4e35..8bc0eef 100644
--- a/tdenetworkmanager/src/devicetraycomponent.cpp
+++ b/tdenetworkmanager/src/devicetraycomponent.cpp
@@ -76,10 +76,13 @@ DeviceTrayComponent::DeviceTrayComponent(TQString device, KSystemTray * parent,
// Trigger an initial hardware information update
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
- TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ TDENetworkConnectionManager* deviceConnMan = (dev ? dev->connectionManager() : NULL);
- connect(deviceConnMan, TQT_SIGNAL(networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)), TQT_SLOT(deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)));
- connect(deviceConnMan, TQT_SIGNAL(networkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType, TQString)), this, TQT_SLOT(deviceEventHandler(TDENetworkDeviceEventType::TDENetworkDeviceEventType, TQString)));
+ if (deviceConnMan)
+ {
+ connect(deviceConnMan, TQT_SIGNAL(networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)), TQT_SLOT(deviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)));
+ connect(deviceConnMan, TQT_SIGNAL(networkDeviceEvent(TDENetworkDeviceEventType::TDENetworkDeviceEventType, TQString)), this, TQT_SLOT(deviceEventHandler(TDENetworkDeviceEventType::TDENetworkDeviceEventType, TQString)));
+ }
m_pixmaps[TDENetworkConnectionStatus::Invalid] = "nm_no_connection";
m_pixmaps[TDENetworkConnectionStatus::UnManaged] = "nm_no_connection";
@@ -128,11 +131,15 @@ TQStringList DeviceTrayComponent::getToolTipText()
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
TQStringList list;
- TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceStatus().statusFlags;
- if (tooltipForConnState(state) != "") {
- list.append(i18n("Device: %1").arg(dev->deviceNode()));
- list.append(i18n("State: %1").arg(tooltipForConnState(state)));
+ TDENetworkConnectionManager* deviceConnMan = (dev ? dev->connectionManager() : NULL);
+ if (deviceConnMan)
+ {
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceStatus().statusFlags;
+ if (tooltipForConnState(state) != "")
+ {
+ list.append(i18n("Device: %1").arg(dev->deviceNode()));
+ list.append(i18n("State: %1").arg(tooltipForConnState(state)));
+ }
}
return list;
}
@@ -203,6 +210,10 @@ void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetw
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(m_device));
+ if (!dev)
+ {
+ return;
+ }
if (dev->deviceNode() != deviceNode) {
kdDebug() << k_funcinfo << "WARNING: Got networkDeviceStateChanged signal for interface '" << deviceNode << "', but my interface is '" << dev->deviceNode() << "'! Ignoring...";
return;
@@ -219,7 +230,8 @@ void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetw
TQTimer::singleShot(0, this, TQT_SLOT(sendGetCenterStage()));
}
else if (newState & TDENetworkConnectionStatus::Connected) {
- if (nm->defaultNetworkDevices().contains(m_device)) {
+ if (nm && nm->defaultNetworkDevices().contains(m_device))
+ {
TQTimer::singleShot(0, this, TQT_SLOT(sendGetCenterStage()));
}
}
diff --git a/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp b/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp
index d62b79f..52cc3c4 100644
--- a/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp
+++ b/tdenetworkmanager/src/tdenetman-cellular_device_tray.cpp
@@ -51,11 +51,24 @@ class CellularDeviceTrayPrivate
void CellularDeviceTray::newConnection()
{
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
+ if (!nm)
+ {
+ return;
+ }
+
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (!dev)
+ {
+ return;
+ }
// create an appropriate connection
TDENetworkConnection* conn = 0;
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ if (!deviceConnMan)
+ {
+ return;
+ }
switch (deviceConnMan->deviceType()) {
case TDENetworkDeviceType::Modem:
conn = new TDEModemConnection();
@@ -75,19 +88,24 @@ void CellularDeviceTray::newConnection()
void CellularDeviceTray::addMenuItems(TDEPopupMenu* menu)
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (!dev)
+ {
+ return;
+ }
// device title
Subhead* subhead = new Subhead (menu, "subhead", dev->deviceNode(), SmallIcon("nm_device_wwan", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1);
+ TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- if (!deviceConnMan->deviceInformation().managed) {
+ if (!nm || !deviceConnMan || !deviceConnMan->deviceInformation().managed)
+ {
// device is not managed by NM -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Not managed"), SmallIcon("no", TQIconSet::Automatic));
menu->insertItem(subhead, -1, -1);
}
else {
- TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
diff --git a/tdenetworkmanager/src/tdenetman-menuitem.cpp b/tdenetworkmanager/src/tdenetman-menuitem.cpp
index 1697f63..fa71a54 100644
--- a/tdenetworkmanager/src/tdenetman-menuitem.cpp
+++ b/tdenetworkmanager/src/tdenetman-menuitem.cpp
@@ -73,7 +73,7 @@ void NetworkMenuItem::slotActivate()
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
- TDENetworkConnection* conn = nm->findConnectionByUUID(d->conn);
+ TDENetworkConnection* conn = (nm ? nm->findConnectionByUUID(d->conn) : 0);
if (dev && conn)
{
diff --git a/tdenetworkmanager/src/tdenetman-tray.cpp b/tdenetworkmanager/src/tdenetman-tray.cpp
index 173464f..e97e1ba 100644
--- a/tdenetworkmanager/src/tdenetman-tray.cpp
+++ b/tdenetworkmanager/src/tdenetman-tray.cpp
@@ -220,12 +220,16 @@ void Tray::contextMenuAboutToShow (TDEPopupMenu* menu)
{
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
- if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
-
// clear menu
menu->clear();
- if (!(nm->backendStatus() & TDENetworkGlobalManagerFlags::BackendUnavailable)) {
+ if (nm && !(nm->backendStatus() & TDENetworkGlobalManagerFlags::BackendUnavailable))
+ {
+ if (tdenetworkmanager_editor_dialog_count == 0)
+ {
+ nm->loadConnectionInformation();
+ }
+
// actions for each Device
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) {
(*it)->addMenuItems(menu);
@@ -248,26 +252,34 @@ void Tray::contextMenuAboutToShow (TDEPopupMenu* menu)
TDEAction * deviceNewConnAction = 0;
if (dev_comp) {
TDENetworkDevice* dev_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dev_comp->device()));
- TQString actionName = TQString("new_connection_%1").arg(dev_comp_dev->deviceNode());
- TQString menuCaption = TQString("%1").arg(dev_comp_dev->deviceNode());
- if (menuCaption.contains("eth", FALSE) > 0) {
- menuCaption = menuCaption.insert(0, "Wired Connection (");
+ if (dev_comp_dev)
+ {
+ TQString actionName = TQString("new_connection_%1").arg(dev_comp_dev->deviceNode());
+ TQString menuCaption = TQString("%1").arg(dev_comp_dev->deviceNode());
+ if (menuCaption.contains("eth", FALSE) > 0)
+ {
+ menuCaption = menuCaption.insert(0, "Wired Connection (");
+ }
+ else if (menuCaption.contains("wlan", FALSE) > 0)
+ {
+ menuCaption = menuCaption.insert(0, "Wireless Connection (");
+ }
+ else if (menuCaption.contains("pan", FALSE) > 0)
+ {
+ menuCaption = menuCaption.insert(0, "Private Area Connection (");
+ }
+ else
+ {
+ menuCaption = menuCaption.insert(0, "Unknown Connection (");
+ }
+ menuCaption = menuCaption.append(")");
+ deviceNewConnAction = actionCollection ()->action (actionName.utf8());
+ if (!deviceNewConnAction)
+ {
+ deviceNewConnAction = new TDEAction (menuCaption, 0, (*it), TQT_SLOT(newConnection()), actionCollection(), actionName.utf8());
+ }
+ newConnActionMenu->insert(deviceNewConnAction);
}
- else if (menuCaption.contains("wlan", FALSE) > 0) {
- menuCaption = menuCaption.insert(0, "Wireless Connection (");
- }
- else if (menuCaption.contains("pan", FALSE) > 0) {
- menuCaption = menuCaption.insert(0, "Private Area Connection (");
- }
- else {
- menuCaption = menuCaption.insert(0, "Unknown Connection (");
- }
- menuCaption = menuCaption.append(")");
- deviceNewConnAction = actionCollection ()->action (actionName.utf8());
- if (!deviceNewConnAction) {
- deviceNewConnAction = new TDEAction (menuCaption, 0, (*it), TQT_SLOT(newConnection()), actionCollection(), actionName.utf8());
- }
- newConnActionMenu->insert(deviceNewConnAction);
}
}
// New VPN connection option
@@ -277,8 +289,9 @@ void Tray::contextMenuAboutToShow (TDEPopupMenu* menu)
TQString actionName = TQString("new_connection_%1").arg("vpn");
deviceNewConnAction = new TDEAction (menuCaption, 0, TQT_TQOBJECT(this), TQT_SLOT(slotNewVPNConnection()), actionCollection(), actionName.utf8());
newConnActionMenu->insert(deviceNewConnAction);
- }
- else if ( devices == 1 ) {
+ }
+ else if ( devices == 1 )
+ {
newConnAction = actionCollection ()->action ("new_connection");
TQT_BASE_OBJECT_NAME::disconnect( newConnAction, TQT_SIGNAL(activated()) );
TQT_BASE_OBJECT_NAME::connect( newConnAction, TQT_SIGNAL(activated()), d->trayComponents[0], TQT_SLOT(newConnection()));
@@ -490,21 +503,24 @@ void Tray::createDeviceTrayComponent(TQString dev)
{
DeviceTrayComponent* devTray = 0;
TDENetworkDevice* new_tray_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dev));
- TDENetworkConnectionManager* deviceConnMan = new_tray_dev->connectionManager();
+ TDENetworkConnectionManager* deviceConnMan = (new_tray_dev ? new_tray_dev->connectionManager() : NULL);
// different tray icons for different device types!
- switch (deviceConnMan->deviceType())
+ if (deviceConnMan)
{
- case TDENetworkDeviceType::WiredEthernet:
- devTray = new WiredDeviceTray(dev, this, "wired_device_tray");
- break;
- case TDENetworkDeviceType::WiFi:
- devTray = new WirelessDeviceTray(dev, this, "wireless_device_tray");
- break;
- case TDENetworkDeviceType::Modem:
- devTray = new CellularDeviceTray(dev, this, "cellular_device_tray");
- break;
- default:
- kdWarning() << k_funcinfo << "UDI: " << dev << " has unknown devicetype: " << deviceConnMan->deviceType() << endl;
+ switch (deviceConnMan->deviceType())
+ {
+ case TDENetworkDeviceType::WiredEthernet:
+ devTray = new WiredDeviceTray(dev, this, "wired_device_tray");
+ break;
+ case TDENetworkDeviceType::WiFi:
+ devTray = new WirelessDeviceTray(dev, this, "wireless_device_tray");
+ break;
+ case TDENetworkDeviceType::Modem:
+ devTray = new CellularDeviceTray(dev, this, "cellular_device_tray");
+ break;
+ default:
+ kdWarning() << k_funcinfo << "UDI: " << dev << " has unknown devicetype: " << deviceConnMan->deviceType() << endl;
+ }
}
if(devTray)
{
@@ -637,10 +653,14 @@ void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
DeviceTrayComponent * dtc = dynamic_cast<DeviceTrayComponent*>(component);
- if (dtc) {
+ if (nm && dtc)
+ {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dtc->device()));
- kdDebug() << k_funcinfo << dtc_comp_dev->deviceNode() << " : " << needsIt << endl;
- TDENetworkDevice * device = dtc_comp_dev;
+ kdDebug()
+ << k_funcinfo
+ << (dtc_comp_dev ? dtc_comp_dev->deviceNode() : TQString("<unknown device>"))
+ << " : " << needsIt
+ << endl;
if (needsIt) {
if (d->foregroundTrayComponent) {
disconnectTrayDeviceManager();
@@ -663,8 +683,14 @@ void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
break;
}
}
- kdDebug() << " Device " << dtc_comp_dev->deviceNode() << " background, new foreground device: " << device->deviceNode() << endl;
if (d->foregroundTrayComponent) {
+ TDENetworkDevice* newDtc_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->foregroundTrayComponent->device()));
+ kdDebug()
+ << " Device "
+ << (dtc_comp_dev ? dtc_comp_dev->deviceNode() : TQString("<unknown device>"))
+ << " background, new foreground device: "
+ << (newDtc_dev ? newDtc_dev->deviceNode() : TQString("<unknown device>"))
+ << endl;
connectTrayDeviceManager();
updateTrayDeviceManagerState();
}
@@ -702,26 +728,34 @@ void Tray::trayUiChanged()
DeviceTrayComponent * dtc = d->foregroundTrayComponent;
if (dtc) {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(dtc->device()));
- TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
- updateTrayIcon(deviceConnMan->deviceStatus().statusFlags);
+ if (dtc_comp_dev)
+ {
+ TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
+ if (deviceConnMan)
+ {
+ updateTrayIcon(deviceConnMan->deviceStatus().statusFlags);
+ }
+ }
}
}
void Tray::showActiveDeviceTray() {
// If the current foreground tray device is deactivated, find the first active device and use it instead
bool needsNewDeviceTrayComponent = true;
- if (d->foregroundTrayComponent) {
+ if (d->foregroundTrayComponent)
+ {
+ needsNewDeviceTrayComponent = false;
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->foregroundTrayComponent->device()));
- TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
- TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceStatus().statusFlags;
- if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
- || (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
- || (statusFlags & TDENetworkConnectionStatus::Invalid)
- ) {
- needsNewDeviceTrayComponent = true;
- }
- else {
- needsNewDeviceTrayComponent = false;
+ TDENetworkConnectionManager* deviceConnMan = (dtc_comp_dev ? dtc_comp_dev->connectionManager() : NULL);
+ if (deviceConnMan)
+ {
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceStatus().statusFlags;
+ if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
+ || (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
+ || (statusFlags & TDENetworkConnectionStatus::Invalid))
+ {
+ needsNewDeviceTrayComponent = true;
+ }
}
}
@@ -734,17 +768,22 @@ void Tray::showActiveDeviceTray() {
DeviceTrayComponent* newDtc = dynamic_cast<DeviceTrayComponent*> (*it);
if (newDtc) {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(newDtc->device()));
- TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
- TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceStatus().statusFlags;
- if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
- || (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
- || (statusFlags & TDENetworkConnectionStatus::Invalid)
- ) {
- continue;
- }
- else {
- d->foregroundTrayComponent = newDtc;
- break;
+ TDENetworkConnectionManager* deviceConnMan = (dtc_comp_dev ? dtc_comp_dev->connectionManager() : NULL);
+ if (deviceConnMan)
+ {
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceStatus().statusFlags;
+ if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
+ || (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
+ || (statusFlags & TDENetworkConnectionStatus::Invalid)
+ )
+ {
+ continue;
+ }
+ else
+ {
+ d->foregroundTrayComponent = newDtc;
+ break;
+ }
}
}
}
@@ -777,7 +816,7 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
}
- TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags globalState = nm->backendStatus();
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags globalState = (nm ? nm->backendStatus() : TDENetworkGlobalManagerFlags::Unknown);
// get all available VPN Connections
active_vpn = 0;
@@ -796,7 +835,7 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
// }
#endif // DEBUG_STATE
- TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (TDEGlobal::networkManager()->backendStatus() & TDENetworkGlobalManagerFlags::VPNMask);
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (globalState & TDENetworkGlobalManagerFlags::VPNMask);
if ((current_vpn_state & TDENetworkGlobalManagerFlags::VPNFailed) || (current_vpn_state & TDENetworkGlobalManagerFlags::VPNDisconnected)) {
active_vpn = 0;
}
@@ -840,11 +879,11 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
}
else {
- setBaseStateIcon(nm->backendStatus());
+ setBaseStateIcon(globalState);
}
}
else {
- TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (TDEGlobal::networkManager()->backendStatus() & TDENetworkGlobalManagerFlags::VPNMask);
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (globalState & TDENetworkGlobalManagerFlags::VPNMask);
#ifdef DEBUG_STATE
printf("VPN state: 0x%08x\n", current_vpn_state);
//printf("Activated is: %d\n", TDENetworkConnectionStatus::Connected);
@@ -905,7 +944,7 @@ void Tray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnecti
void Tray::slotDeviceAddedNotify(TDENetworkDevice* dev)
{
kdDebug() << "Tray::slotDeviceAddedNotify" << endl;
- if( !dev->deviceNode().isEmpty() ) {
+ if( dev && !dev->deviceNode().isEmpty() ) {
KNotifyClient::event( winId(), "tdenm-nm-device-added", i18n("New network device %1 found").arg(dev->deviceNode()) );
}
}
@@ -913,7 +952,7 @@ void Tray::slotDeviceAddedNotify(TDENetworkDevice* dev)
void Tray::slotDeviceRemovedNotify(TDENetworkDevice* dev)
{
kdDebug() << "Tray::slotDeviceRemovedNotify" << endl;
- if( !dev->deviceNode().isEmpty() ) {
+ if( dev && !dev->deviceNode().isEmpty() ) {
KNotifyClient::event( winId(), "tdenm-nm-device-removed", i18n("Network device %1 removed").arg(dev->deviceNode()) );
}
}
@@ -1100,7 +1139,7 @@ Tray::Tray() : KSystemTray()
// initial setup of the device-trays
updateDeviceTrays();
- slotStateChanged(TDEGlobal::networkManager()->backendStatus(), TDENetworkGlobalManagerFlags::Unknown);
+ slotStateChanged(nm ? nm->backendStatus() : TDENetworkGlobalManagerFlags::Unknown, TDENetworkGlobalManagerFlags::Unknown);
}
Tray::~Tray ()
@@ -1109,4 +1148,3 @@ Tray::~Tray ()
}
#include "tdenetman-tray.moc"
-
diff --git a/tdenetworkmanager/src/tdenetman-vpnmanager.cpp b/tdenetworkmanager/src/tdenetman-vpnmanager.cpp
index f106455..756451e 100644
--- a/tdenetworkmanager/src/tdenetman-vpnmanager.cpp
+++ b/tdenetworkmanager/src/tdenetman-vpnmanager.cpp
@@ -42,37 +42,50 @@ VPNManager::getVPNServices ()
VPNServiceList list;
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
- TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
- if (availablePlugins.count() > 0) {
- // find all available services
- for (TDENetworkVPNTypeList::Iterator it = availablePlugins.begin (); it != availablePlugins.end (); ++it) {
- TQString serviceString;
- if ((*it) == TDENetworkVPNType::OpenVPN) {
- serviceString = "openvpn";
- }
- else if ((*it) == TDENetworkVPNType::PPTP) {
- serviceString = "pptp";
- }
- else if ((*it) == TDENetworkVPNType::StrongSwan) {
- serviceString = "strongswan";
- }
- else if ((*it) == TDENetworkVPNType::VPNC) {
- serviceString = "vpnc";
- }
- if (serviceString == "") {
- continue;
- }
+ if (nm)
+ {
+ TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
- kdDebug() << "VPN Service " << serviceString.ascii() << endl;
+ if (availablePlugins.count() > 0)
+ {
+ // find all available services
+ for (TDENetworkVPNTypeList::Iterator it = availablePlugins.begin (); it != availablePlugins.end (); ++it)
+ {
+ TQString serviceString;
+ if ((*it) == TDENetworkVPNType::OpenVPN)
+ {
+ serviceString = "openvpn";
+ }
+ else if ((*it) == TDENetworkVPNType::PPTP)
+ {
+ serviceString = "pptp";
+ }
+ else if ((*it) == TDENetworkVPNType::StrongSwan)
+ {
+ serviceString = "strongswan";
+ }
+ else if ((*it) == TDENetworkVPNType::VPNC)
+ {
+ serviceString = "vpnc";
+ }
+ if (serviceString == "")
+ {
+ continue;
+ }
- // create new VPNService Object
- VPNService* vpnservice = new VPNService(serviceString, serviceString, TQT_TQOBJECT(TDENetworkManager::getInstance()));
- if (!vpnservice->getVPNPlugin()) {
- delete vpnservice;
- }
- else {
- list.push_back(vpnservice);
+ kdDebug() << "VPN Service " << serviceString.ascii() << endl;
+
+ // create new VPNService Object
+ VPNService* vpnservice = new VPNService(serviceString, serviceString, TQT_TQOBJECT(TDENetworkManager::getInstance()));
+ if (!vpnservice->getVPNPlugin())
+ {
+ delete vpnservice;
+ }
+ else
+ {
+ list.push_back(vpnservice);
+ }
}
}
}
@@ -86,35 +99,48 @@ VPNManager::getVPNService(TQString service_type)
VPNServiceList list;
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
- TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
-
- if (availablePlugins.count() > 0) {
- for (TDENetworkVPNTypeList::Iterator it = availablePlugins.begin (); it != availablePlugins.end (); ++it) {
- TQString serviceString;
- if ((*it) == TDENetworkVPNType::OpenVPN) {
- serviceString = "openvpn";
- }
- else if ((*it) == TDENetworkVPNType::PPTP) {
- serviceString = "pptp";
- }
- else if ((*it) == TDENetworkVPNType::StrongSwan) {
- serviceString = "strongswan";
- }
- else if ((*it) == TDENetworkVPNType::VPNC) {
- serviceString = "vpnc";
- }
- if (serviceString == "") {
- continue;
- }
+ if (nm)
+ {
+ TDENetworkVPNTypeList availablePlugins = nm->availableVPNTypes();
- if (serviceString == service_type) {
- // create new VPNService Object
- VPNService* vpnservice = new VPNService(service_type, service_type, TQT_TQOBJECT(TDENetworkManager::getInstance()));
- if (!vpnservice->getVPNPlugin()) {
- delete vpnservice;
+ if (availablePlugins.count() > 0)
+ {
+ for (TDENetworkVPNTypeList::Iterator it = availablePlugins.begin (); it != availablePlugins.end (); ++it)
+ {
+ TQString serviceString;
+ if ((*it) == TDENetworkVPNType::OpenVPN)
+ {
+ serviceString = "openvpn";
+ }
+ else if ((*it) == TDENetworkVPNType::PPTP)
+ {
+ serviceString = "pptp";
+ }
+ else if ((*it) == TDENetworkVPNType::StrongSwan)
+ {
+ serviceString = "strongswan";
}
- else {
- return vpnservice;
+ else if ((*it) == TDENetworkVPNType::VPNC)
+ {
+ serviceString = "vpnc";
+ }
+ if (serviceString == "")
+ {
+ continue;
+ }
+
+ if (serviceString == service_type)
+ {
+ // create new VPNService Object
+ VPNService* vpnservice = new VPNService(service_type, service_type, TQT_TQOBJECT(TDENetworkManager::getInstance()));
+ if (!vpnservice->getVPNPlugin())
+ {
+ delete vpnservice;
+ }
+ else
+ {
+ return vpnservice;
+ }
}
}
}
diff --git a/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp b/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp
index 3527f92..3744b9a 100644
--- a/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp
+++ b/tdenetworkmanager/src/tdenetman-wired_device_tray.cpp
@@ -61,6 +61,10 @@ class WiredDeviceTrayPrivate
void WiredDeviceTray::newConnection()
{
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
+ if (!nm)
+ {
+ return;
+ }
// create a new wired connection
TDENetworkConnection* conn = new TDEWiredEthernetConnection();
@@ -75,13 +79,19 @@ void WiredDeviceTray::newConnection()
void WiredDeviceTray::addMenuItems(TDEPopupMenu* menu)
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (!dev)
+ {
+ return;
+ }
// device title
Subhead* subhead = new Subhead (menu, "subhead", TQString("Wired Connection (%1)").arg(dev->deviceNode()), SmallIcon("wired", TQIconSet::Automatic));
menu->insertItem (subhead, -1, -1);
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- if (!deviceConnMan->deviceInformation().managed) {
+ TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
+ if (!nm || !deviceConnMan|| !deviceConnMan->deviceInformation().managed)
+ {
// device is not managed by NM -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Not managed"), SmallIcon("no", TQIconSet::Automatic));
menu->insertItem(subhead, -1, -1);
@@ -92,7 +102,6 @@ void WiredDeviceTray::addMenuItems(TDEPopupMenu* menu)
menu->insertItem(subhead, -1, -1);
}
else {
- TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
TDENetworkConnection* active_conn = NULL;
if ((!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Disconnected))
&& (!(deviceConnMan->deviceInformation().statusFlags & TDENetworkConnectionStatus::Invalid))) {
diff --git a/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp b/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp
index 8811650..c34c33c 100644
--- a/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp
+++ b/tdenetworkmanager/src/tdenetman-wireless_device_tray.cpp
@@ -65,16 +65,22 @@ class WirelessDeviceTrayPrivate
TQStringList WirelessDeviceTray::getToolTipText()
{
- TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
-
TQStringList tooltip = DeviceTrayComponent::getToolTipText();
- TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
- if (ap) {
- tooltip.append(i18n("Network: %1").arg(ap->friendlySSID()));
- int strength = (ap->signalQuality*100.0);
- tooltip.append(i18n("Signal Strength: %1%").arg(strength));
+ TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (dev)
+ {
+ TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ if (deviceConnMan)
+ {
+ TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
+ if (ap)
+ {
+ tooltip.append(i18n("Network: %1").arg(ap->friendlySSID()));
+ int strength = (ap->signalQuality*100.0);
+ tooltip.append(i18n("Signal Strength: %1%").arg(strength));
+ }
+ }
}
return tooltip;
@@ -88,6 +94,10 @@ void WirelessDeviceTray::newConnection()
void WirelessDeviceTray::newConnection(int id)
{
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
+ if (!nm)
+ {
+ return;
+ }
// create a new wireless connection
TDENetworkConnection* conn = new TDEWiFiConnection();
@@ -154,12 +164,16 @@ void WirelessDeviceTray::addWirelessNetworks(TDEPopupMenu* menu)
TQValueList<TDEWiFiConnection*> conns = WirelessManager::getWirelessConnections();
// get the currently active connection
- TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ TDENetworkConnectionManager* deviceConnMan = (dev ? dev->connectionManager() : NULL);
TDENetworkConnection* active_conn = NULL;
- TDENetworkDeviceInformation devInfo = deviceConnMan->deviceStatus();
- if ((!(devInfo.statusFlags & TDENetworkConnectionStatus::Disconnected))
- && (!(devInfo.statusFlags & TDENetworkConnectionStatus::Invalid))) {
- active_conn = nm->findConnectionByUUID(devInfo.activeConnectionUUID);
+ if (nm && deviceConnMan)
+ {
+ TDENetworkDeviceInformation devInfo = deviceConnMan->deviceStatus();
+ if ((!(devInfo.statusFlags & TDENetworkConnectionStatus::Disconnected))
+ && (!(devInfo.statusFlags & TDENetworkConnectionStatus::Invalid)))
+ {
+ active_conn = nm->findConnectionByUUID(devInfo.activeConnectionUUID);
+ }
}
// add all wireless connections in range
@@ -258,6 +272,10 @@ void WirelessDeviceTray::addWirelessNetworks(TDEPopupMenu* menu)
void WirelessDeviceTray::addMenuItems(TDEPopupMenu* menu)
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (!dev)
+ {
+ return;
+ }
// get the currently active connection
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
@@ -267,7 +285,8 @@ void WirelessDeviceTray::addMenuItems(TDEPopupMenu* menu)
menu->insertItem (subhead, -1, -1);
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- if (!deviceConnMan->deviceInformation().managed) {
+ if (!nm || !deviceConnMan || !deviceConnMan->deviceInformation().managed)
+ {
// device is not managed by NM -> do not show any connections
subhead = new Subhead(menu, "subhead2", i18n("Not managed"), SmallIcon("no", TQIconSet::Automatic));
menu->insertItem(subhead, -1, -1);
@@ -312,7 +331,12 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
- if (dev->deviceNode() != deviceNode) {
+ if (!dev)
+ {
+ return;
+ }
+ if (dev->deviceNode() != deviceNode)
+ {
kdDebug() << k_funcinfo << "WARNING: Got networkDeviceStateChanged signal for interface '" << deviceNode << "', but my interface is '" << dev->deviceNode() << "'! Ignoring...";
return;
}
@@ -326,24 +350,33 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
if (newState == TDENetworkConnectionStatus::Connected) {
// trigger an update of the connections seen bssids property
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
- if (ap) {
- int strength = (ap->signalQuality*100.0);
-
- if (strength > 80) {
- setPixmapForStates(newState, "nm_signal_100");
- }
- else if (strength > 55) {
- setPixmapForStates(newState, "nm_signal_75");
- }
- else if (strength > 30) {
- setPixmapForStates(newState, "nm_signal_50");
- }
- else if (strength > 5) {
- setPixmapForStates(newState, "nm_signal_25");
- }
- else {
- setPixmapForStates(newState, "nm_signal_00");
+ if (deviceConnMan)
+ {
+ TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID);
+ if (ap)
+ {
+ int strength = (ap->signalQuality*100.0);
+
+ if (strength > 80)
+ {
+ setPixmapForStates(newState, "nm_signal_100");
+ }
+ else if (strength > 55)
+ {
+ setPixmapForStates(newState, "nm_signal_75");
+ }
+ else if (strength > 30)
+ {
+ setPixmapForStates(newState, "nm_signal_50");
+ }
+ else if (strength > 5)
+ {
+ setPixmapForStates(newState, "nm_signal_25");
+ }
+ else
+ {
+ setPixmapForStates(newState, "nm_signal_00");
+ }
}
}
}
@@ -361,25 +394,34 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
// get the currently active connection
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
- TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ TDENetworkConnectionManager* deviceConnMan = (dev ? dev->connectionManager() : NULL);
TDENetworkConnection* active_conn = NULL;
- TDENetworkDeviceInformation devInfo = deviceConnMan->deviceStatus();
- if ((!(devInfo.statusFlags & TDENetworkConnectionStatus::Disconnected))
- && (!(devInfo.statusFlags & TDENetworkConnectionStatus::Invalid))) {
- active_conn = nm->findConnectionByUUID(devInfo.activeConnectionUUID);
- }
+ if (nm && deviceConnMan)
+ {
+ TDENetworkDeviceInformation devInfo = deviceConnMan->deviceStatus();
+ if ((!(devInfo.statusFlags & TDENetworkConnectionStatus::Disconnected))
+ && (!(devInfo.statusFlags & TDENetworkConnectionStatus::Invalid)))
+ {
+ active_conn = nm->findConnectionByUUID(devInfo.activeConnectionUUID);
+ }
- if (active_conn && devInfo.statusFlags == TDENetworkConnectionStatus::Connected) {
- TDENetworkDeviceInformation devInfo = deviceConnMan->deviceInformation();
- TDENetworkWiFiAPInfo * activeap = deviceConnMan->findAccessPointByBSSID(devInfo.wiFiInfo.activeAccessPointBSSID);
- if ( activeap != d->activeAccessPoint) {
- d->activeAccessPoint = activeap;
- if ( d->activeAccessPoint ) {
- TDEWiFiConnection* wireless = dynamic_cast<TDEWiFiConnection*>(active_conn);
- if (wireless) {
- if (!(wireless->heardBSSIDs.contains(d->activeAccessPoint->BSSID))) {
- wireless->heardBSSIDs.append(d->activeAccessPoint->BSSID);
+ if (active_conn && devInfo.statusFlags == TDENetworkConnectionStatus::Connected)
+ {
+ TDENetworkDeviceInformation devInfo = deviceConnMan->deviceInformation();
+ TDENetworkWiFiAPInfo * activeap = deviceConnMan->findAccessPointByBSSID(devInfo.wiFiInfo.activeAccessPointBSSID);
+ if ( activeap != d->activeAccessPoint)
+ {
+ d->activeAccessPoint = activeap;
+ if ( d->activeAccessPoint )
+ {
+ TDEWiFiConnection* wireless = dynamic_cast<TDEWiFiConnection*>(active_conn);
+ if (wireless)
+ {
+ if (!(wireless->heardBSSIDs.contains(d->activeAccessPoint->BSSID)))
+ {
+ wireless->heardBSSIDs.append(d->activeAccessPoint->BSSID);
+ }
}
}
}
@@ -390,30 +432,43 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
void WirelessDeviceTray::apPropertyChanged(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event)
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (!dev)
+ {
+ return;
+ }
if (event == TDENetworkAPEventType::SignalStrengthChanged) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID);
- if (ap) {
- TQ_UINT32 strength = (ap->signalQuality*100.0);
- kdDebug() << k_funcinfo << strength << endl;
- TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
- if (strength > 80) {
- setPixmapForStates(state, "nm_signal_100");
- }
- else if (strength > 55) {
- setPixmapForStates(state, "nm_signal_75");
- }
- else if (strength > 30) {
- setPixmapForStates(state, "nm_signal_50");
- }
- else if (strength > 5) {
- setPixmapForStates(state, "nm_signal_25");
- }
- else {
- setPixmapForStates(state, "nm_signal_00");
+ if (deviceConnMan)
+ {
+ TDENetworkWiFiAPInfo * ap = deviceConnMan->findAccessPointByBSSID(BSSID);
+ if (ap)
+ {
+ TQ_UINT32 strength = (ap->signalQuality*100.0);
+ kdDebug() << k_funcinfo << strength << endl;
+ TDENetworkConnectionStatus::TDENetworkConnectionStatus state = deviceConnMan->deviceInformation().statusFlags;
+ if (strength > 80)
+ {
+ setPixmapForStates(state, "nm_signal_100");
+ }
+ else if (strength > 55)
+ {
+ setPixmapForStates(state, "nm_signal_75");
+ }
+ else if (strength > 30)
+ {
+ setPixmapForStates(state, "nm_signal_50");
+ }
+ else if (strength > 5)
+ {
+ setPixmapForStates(state, "nm_signal_25");
+ }
+ else
+ {
+ setPixmapForStates(state, "nm_signal_00");
+ }
+ TQTimer::singleShot(0, this, TQT_SLOT(sendUpdateUI()));
}
- TQTimer::singleShot(0, this, TQT_SLOT(sendUpdateUI()));
}
}
}
@@ -430,17 +485,27 @@ void WirelessDeviceTray::slotAccessPointRemoved(TDEMACAddress)
void WirelessDeviceTray::tdeAccessPointStatusChangedHandler(TDEMACAddress BSSID, TDENetworkAPEventType::TDENetworkAPEventType event) {
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->dev));
+ if (!dev)
+ {
+ return;
+ }
+
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
if (event == TDENetworkAPEventType::Discovered) {
- TDENetworkWiFiAPInfo* apinfo = deviceConnMan->findAccessPointByBSSID(BSSID);
- slotAccessPointAdded(apinfo);
+ if (deviceConnMan)
+ {
+ TDENetworkWiFiAPInfo* apinfo = deviceConnMan->findAccessPointByBSSID(BSSID);
+ slotAccessPointAdded(apinfo);
+ }
}
else if (event == TDENetworkAPEventType::Lost) {
slotAccessPointRemoved(BSSID);
}
else if (event == TDENetworkAPEventType::SignalStrengthChanged) {
- if (deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID == BSSID) {
+ if (deviceConnMan &&
+ deviceConnMan->deviceInformation().wiFiInfo.activeAccessPointBSSID == BSSID)
+ {
apPropertyChanged(BSSID, event);
}
}
diff --git a/tdenetworkmanager/src/tdenetman-wireless_manager.cpp b/tdenetworkmanager/src/tdenetman-wireless_manager.cpp
index f240778..de6a387 100644
--- a/tdenetworkmanager/src/tdenetman-wireless_manager.cpp
+++ b/tdenetworkmanager/src/tdenetman-wireless_manager.cpp
@@ -82,14 +82,19 @@ TQValueList<TDENetworkWiFiAPInfo*> internalGetAccessPoints(TDENetworkDevice* dev
TQValueList<TDENetworkWiFiAPInfo*> list;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- TDENetworkHWNeighbor* neighbor;
- TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey();
- for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next()) {
- TDENetworkWiFiAPInfo* apInfo = dynamic_cast<TDENetworkWiFiAPInfo*>(neighbor);
- if (!apInfo) {
- continue;
+ if (deviceConnMan)
+ {
+ TDENetworkHWNeighbor* neighbor;
+ TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey();
+ for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next())
+ {
+ TDENetworkWiFiAPInfo* apInfo = dynamic_cast<TDENetworkWiFiAPInfo*>(neighbor);
+ if (!apInfo)
+ {
+ continue;
+ }
+ list.append(apInfo);
}
- list.append(apInfo);
}
}
return list;
@@ -141,15 +146,21 @@ TQValueList<TDENetworkWiFiAPInfo*> internalGetAccessPointsWithESSID(TQByteArray
TQValueList<TDENetworkWiFiAPInfo*> list;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- TDENetworkHWNeighbor* neighbor;
- TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey();
- for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next()) {
- TDENetworkWiFiAPInfo* apInfo = dynamic_cast<TDENetworkWiFiAPInfo*>(neighbor);
- if (!apInfo) {
- continue;
- }
- if (apInfo->SSID == essid) {
- list.append(apInfo);
+ if (deviceConnMan)
+ {
+ TDENetworkHWNeighbor* neighbor;
+ TDENetworkHWNeighborList* neighbors = deviceConnMan->siteSurvey();
+ for (neighbor = neighbors->first(); neighbor; neighbor = neighbors->next())
+ {
+ TDENetworkWiFiAPInfo* apInfo = dynamic_cast<TDENetworkWiFiAPInfo*>(neighbor);
+ if (!apInfo)
+ {
+ continue;
+ }
+ if (apInfo->SSID == essid)
+ {
+ list.append(apInfo);
+ }
}
}
}
diff --git a/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp b/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp
index 42497b9..5d473a9 100644
--- a/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp
+++ b/tdenetworkmanager/src/tdenetman-wireless_menuitem.cpp
@@ -56,15 +56,13 @@ using namespace ConnectionSettings;
void WirelessNetworkItem::slotActivate()
{
TDENetworkDevice* dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(_dev));
-
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
- TDENetworkConnection* conn = nm->findConnectionByUUID(_conn);
-
- TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
+ TDENetworkConnectionManager* deviceConnMan = (dev ? dev->connectionManager() : NULL);
printf("slotActivate\n");
- if (!_dev.isEmpty() && deviceConnMan)
+ if (!_dev.isEmpty() && nm && deviceConnMan)
{
+ TDENetworkConnection* conn = nm->findConnectionByUUID(_conn);
if ( conn )
{
kdDebug() << "Activate Connection " << _conn.ascii() << " on Device " << dev->deviceNode().ascii() << endl;
@@ -87,7 +85,7 @@ void WirelessNetworkItem::slotActivate()
TQString WirelessNetworkItem::getDisplayText()
{
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
- TDENetworkConnection* conn = nm->findConnectionByUUID(_conn);
+ TDENetworkConnection* conn = (nm ? nm->findConnectionByUUID(_conn) : 0);
TQString security = "";
if (((_net.getWpaFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None) && ((_net.getRsnFlags() & TDENetworkWiFiAPFlags::EncryptionFlagsMask) != TDENetworkWiFiAPFlags::None)) {
diff --git a/tdenetworkmanager/src/tdenetman-wireless_network.cpp b/tdenetworkmanager/src/tdenetman-wireless_network.cpp
index f071f4d..5b13c52 100644
--- a/tdenetworkmanager/src/tdenetman-wireless_network.cpp
+++ b/tdenetworkmanager/src/tdenetman-wireless_network.cpp
@@ -90,13 +90,20 @@ bool WirelessNetwork::contains(const TDEMACAddress ap)
dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->aps[ap]));
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(ap);
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(ap);
+ }
}
else if (d->aps[ap] == "") {
- apInfo = nm->findAccessPointByBSSID(ap);
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(ap);
+ }
}
}
- else {
+ else if (nm)
+ {
apInfo = nm->findAccessPointByBSSID(ap);
}
@@ -137,10 +144,16 @@ const TQByteArray WirelessNetwork::getSsid() const
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(d->aps.begin().key());
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(d->aps.begin().key());
+ }
}
else if (d->aps.begin().data() == "") {
- apInfo = nm->findAccessPointByBSSID(d->aps.begin().key());
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(d->aps.begin().key());
+ }
}
if (apInfo) {
@@ -164,10 +177,16 @@ TQString WirelessNetwork::getDisplaySsid() const
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(d->aps.begin().key());
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(d->aps.begin().key());
+ }
}
else if (d->aps.begin().data() == "") {
- apInfo = nm->findAccessPointByBSSID(d->aps.begin().key());
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(d->aps.begin().key());
+ }
}
if (apInfo) {
@@ -192,10 +211,16 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getFlags() const
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ }
}
else if (it.data() == "") {
- apInfo = nm->findAccessPointByBSSID(it.key());
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(it.key());
+ }
}
if (apInfo) {
@@ -217,10 +242,16 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getWpaFlags() cons
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ }
}
else if (it.data() == "") {
- apInfo = nm->findAccessPointByBSSID(it.key());
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(it.key());
+ }
}
if (apInfo) {
@@ -241,10 +272,16 @@ TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags WirelessNetwork::getRsnFlags() cons
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ }
}
else if (it.data() == "") {
- apInfo = nm->findAccessPointByBSSID(it.key());
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(it.key());
+ }
}
if (apInfo) {
@@ -269,10 +306,16 @@ TQ_UINT8 WirelessNetwork::getStrength() const
TDENetworkWiFiAPInfo* apInfo = NULL;
if (dev) {
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
- apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ if (deviceConnMan)
+ {
+ apInfo = deviceConnMan->findAccessPointByBSSID(it.key());
+ }
}
else if (it.data() == "") {
- apInfo = nm->findAccessPointByBSSID(it.key());
+ if (nm)
+ {
+ apInfo = nm->findAccessPointByBSSID(it.key());
+ }
}
if (apInfo) {
diff --git a/tdenetworkmanager/src/vpn_tray_component.cpp b/tdenetworkmanager/src/vpn_tray_component.cpp
index f032647..bfaf26d 100644
--- a/tdenetworkmanager/src/vpn_tray_component.cpp
+++ b/tdenetworkmanager/src/vpn_tray_component.cpp
@@ -44,6 +44,10 @@ using namespace ConnectionSettings;
void VPNTrayComponent::slotShowNewConnectionDialog()
{
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
+ if (!nm)
+ {
+ return;
+ }
// create a new VPN connection
TDEVPNConnection* conn = new TDEVPNConnection();
@@ -63,6 +67,10 @@ void VPNTrayComponent::addMenuItems(TDEPopupMenu* menu)
// Get all active connections
TDEGlobalNetworkManager* nm = TDEGlobal::networkManager();
+ if (!nm)
+ {
+ return;
+ }
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();