Fix a number of display bugs

Warn on wireless connection failure
pull/1/head
Timothy Pearson 12 years ago
parent d476f3c6e6
commit 7f11dfba69

@ -20,9 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "devicetraycomponent.h"
#include <kiconloader.h>
#include <kdebug.h>
#include <klocale.h>
#include <kiconloader.h>
#include <ksystemtray.h>
#include <knotifyclient.h>
#include <knotifydialog.h>
TQString DeviceTrayComponent::pixmapForConnState(TDENetworkConnectionStatus::TDENetworkConnectionStatus state) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus flag = (TDENetworkConnectionStatus::TDENetworkConnectionStatus)0x80000000;
@ -114,6 +117,15 @@ void DeviceTrayComponent::tdeHardwareEventHandler(TDEHardwareEvent::TDEHardwareE
TDENetworkConnectionManager* deviceConnMan = dev->connectionManager();
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)));
}
}
void DeviceTrayComponent::deviceEventHandler(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message) {
kdDebug() << "DeviceTrayComponent::deviceEventHandler" << endl;
if (event == TDENetworkDeviceEventType::Failure) {
KNotifyClient::event( tray()->winId(), "tdenm-nm-connection-attempt-failed", i18n(message) );
}
}
@ -191,7 +203,7 @@ void DeviceTrayComponent::deviceStateChanged(TDENetworkConnectionStatus::TDENetw
return;
}
printf("Device tray state: %d\n\r", newState);
printf("Device tray state: 0x%08x\n\r", newState);
//check if our device now holds the default active connection
// if it is the default active connection

@ -59,6 +59,7 @@ class DeviceTrayComponent : public TrayComponent
private slots:
void tdeHardwareEventHandler(TDEHardwareEvent::TDEHardwareEvent, TQString);
void deviceEventHandler(TDENetworkDeviceEventType::TDENetworkDeviceEventType event, TQString message);
protected:
void setMovieForState(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString);

@ -13,6 +13,10 @@ default_presentation=17
Name=VPN Connection Attempt Failed
default_presentation=17
[tdenm-nm-connection-attempt-failed]
Name=Connection Attempt Failed
default_presentation=17
[tdenm-nm-sleeping]
Name=TDENetworkManager Offline
Name[bg]=TDENetworkManager - изключен от Интернет

@ -84,13 +84,13 @@ void NetworkMenuItem::slotActivate()
printf("Activate Connection %s on Device %s\n\r", conn->UUID.ascii(), dev->deviceNode().ascii());
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(conn->UUID);
if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) {
//
}
else {
kdDebug() << "ActivateDevice failed" << endl;
}
// if ((result == TDENetworkConnectionStatus::Disconnected)
// || (result == TDENetworkConnectionStatus::Invalid)) {
// //
// }
// else {
// kdDebug() << "ActivateDevice failed" << endl;
// }
}
}
else if (conn)

@ -297,8 +297,11 @@ void Tray::contextMenuAboutToShow (KPopupMenu* menu)
if (!conn) {
continue;
}
if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected)
|| (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus status = nm->checkConnectionStatus(conn->UUID);
if ((status == TDENetworkConnectionStatus::Disconnected)
|| (status == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (status & TDENetworkConnectionStatus::Invalid)
) {
continue;
}
@ -377,7 +380,7 @@ Tray::slotStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlag
setPixmap (loadIcon ("tdenetworkmanager"));
}
printf("NM state: %d\n\r", nm_state);
printf("NM state: 0x%08x\n\r", nm_state);
showActiveDeviceTray();
}
@ -613,7 +616,6 @@ void Tray::updateTrayDeviceManagerState() {
TDENetworkConnectionManager* deviceConnMan = foreground_tray_dev->connectionManager();
if (deviceConnMan) {
slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags, TDENetworkConnectionStatus::Invalid, TQString());
slotUpdateDeviceState(deviceConnMan->deviceInformation().statusFlags, TDENetworkConnectionStatus::Invalid, TQString());
}
}
}
@ -637,6 +639,7 @@ void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
}
else {
disconnectTrayDeviceManager();
d->foregroundTrayComponent = NULL;
// use active default
TQStringList defaultDevices = nm->defaultNetworkDevices();
@ -650,8 +653,10 @@ void Tray::trayComponentNeedsCenterStage(TrayComponent *component, bool needsIt)
}
}
kdDebug() << " Device " << dtc_comp_dev->deviceNode() << " background, new foreground device: " << device->deviceNode() << endl;
connectTrayDeviceManager();
updateTrayDeviceManagerState();
if (d->foregroundTrayComponent) {
connectTrayDeviceManager();
updateTrayDeviceManagerState();
}
}
}
}
@ -664,7 +669,7 @@ void Tray::slotUpdateDeviceState()
void Tray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus prevState, TQString hwAddress)
{
printf("Device state: %d\n\r", newState);
printf("Device state: 0x%08x\n\r", newState);
updateTrayIcon(newState);
updateActiveConnection(newState);
@ -687,8 +692,9 @@ void Tray::showActiveDeviceTray() {
TDENetworkDevice* dtc_comp_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->foregroundTrayComponent->device()));
TDENetworkConnectionManager* deviceConnMan = dtc_comp_dev->connectionManager();
TDENetworkConnectionStatus::TDENetworkConnectionStatus statusFlags = deviceConnMan->deviceInformation().statusFlags;
if ((statusFlags & TDENetworkConnectionStatus::Invalid) ||
(statusFlags & TDENetworkConnectionStatus::Disconnected)
if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
|| (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (statusFlags & TDENetworkConnectionStatus::Invalid)
) {
needsNewDeviceTrayComponent = true;
}
@ -700,14 +706,17 @@ void Tray::showActiveDeviceTray() {
if (needsNewDeviceTrayComponent) {
disconnectTrayDeviceManager();
d->foregroundTrayComponent = NULL;
for (TQValueList<TrayComponent*>::Iterator it = d->trayComponents.begin(); it != d->trayComponents.end(); ++it) {
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->deviceInformation().statusFlags;
if ((statusFlags & TDENetworkConnectionStatus::Invalid) ||
(statusFlags & TDENetworkConnectionStatus::Disconnected)
if ((statusFlags == TDENetworkConnectionStatus::Disconnected)
|| (statusFlags == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (statusFlags & TDENetworkConnectionStatus::Invalid)
) {
continue;
}
@ -718,8 +727,10 @@ void Tray::showActiveDeviceTray() {
}
}
connectTrayDeviceManager();
updateTrayDeviceManagerState();
if (d->foregroundTrayComponent != NULL) {
connectTrayDeviceManager();
updateTrayDeviceManagerState();
}
}
trayUiChanged();
@ -736,6 +747,17 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
// Make sure the current state will be displayed
if (d->foregroundTrayComponent) {
TDENetworkDevice* foreground_tray_dev = dynamic_cast<TDENetworkDevice*>(hwdevices->findByUniqueID(d->foregroundTrayComponent->device()));
if (foreground_tray_dev) {
TDENetworkConnectionManager* deviceConnMan = foreground_tray_dev->connectionManager();
if (deviceConnMan) {
state = deviceConnMan->deviceInformation().statusFlags;
}
}
}
// get all available VPN Connections
active_vpn = 0;
allconmap = nm->connections();
@ -768,8 +790,11 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
continue;
}
if ((nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Disconnected)
|| (nm->checkConnectionStatus(conn->UUID) & TDENetworkConnectionStatus::Invalid)) {
TDENetworkConnectionStatus::TDENetworkConnectionStatus status = nm->checkConnectionStatus(conn->UUID);
if ((status == TDENetworkConnectionStatus::Disconnected)
|| (status == (TDENetworkConnectionStatus::Disconnected | TDENetworkConnectionStatus::LinkUnavailable))
|| (status & TDENetworkConnectionStatus::Invalid)
) {
continue;
}
@ -827,7 +852,7 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
else {
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags current_vpn_state = (KGlobal::networkManager()->backendStatus() & TDENetworkGlobalManagerFlags::VPNMask);
printf("VPN state: %d\n\r", current_vpn_state);
printf("VPN state: 0x%08x\n\r", current_vpn_state);
//printf("Activated is: %d\n\r", TDENetworkConnectionStatus::Connected);
// stop the old movie to avoid unnecessary wakups
DeviceTrayComponent * dtc = d->foregroundTrayComponent;
@ -868,7 +893,7 @@ void Tray::updateTrayIcon(TDENetworkConnectionStatus::TDENetworkConnectionStatus
}
nm_device_state_global = state;
//printf("Device state: %d\n\r", nm_device_state_global);
//printf("Device state: 0x%08x\n\r", nm_device_state_global);
}
void Tray::updateActiveConnection(TDENetworkConnectionStatus::TDENetworkConnectionStatus state)
@ -1011,6 +1036,11 @@ Tray::Tray() : KSystemTray()
connect(KGlobal::networkManager(), TQT_SIGNAL(networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)), this, TQT_SLOT(slotStateChangedNotify(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags)));
connect(KGlobal::networkManager(), TQT_SIGNAL(vpnEvent(TDENetworkVPNEventType::TDENetworkVPNEventType, TQString)), this, TQT_SLOT(slotVPNEventHandler(TDENetworkVPNEventType::TDENetworkVPNEventType, TQString)));
// Get connection list
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
if (nm) {
if (tdenetworkmanager_editor_dialog_count == 0) nm->loadConnectionInformation();
}
// initial setup of the device-trays
updateDeviceTrays();

@ -308,7 +308,7 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
return;
}
printf("Wireless state: %d\n\r", newState);
printf("Wireless state: 0x%08x\n\r", newState);
slotCheckActiveAccessPoint();
@ -336,6 +336,9 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
}
}
}
// Update tray icon
emit uiUpdated();
}
void WirelessDeviceTray::slotCheckActiveAccessPoint()

@ -68,10 +68,10 @@ void WirelessNetworkItem::slotActivate()
{
kdDebug() << "Activate Connection " << _conn.ascii() << " on Device " << dev->deviceNode().ascii() << endl;
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(_conn);
if ((result == TDENetworkConnectionStatus::Disconnected)
|| (result == TDENetworkConnectionStatus::Invalid)) {
kdDebug() << "ActivateDevice failed" << endl;
}
// if ((result == TDENetworkConnectionStatus::Disconnected)
// || (result == TDENetworkConnectionStatus::Invalid)) {
// kdDebug() << "ActivateDevice failed" << endl;
// }
}
else

Loading…
Cancel
Save