@ -293,14 +293,18 @@ void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetwo
}
}
void WirelessDeviceTray : : slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus state)
void WirelessDeviceTray : : slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus newState, TDENetworkConnectionStatu s: : TDENetworkConnectionStatus prevS tate, TQString hwAddress )
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
if ( dev - > macAddress ( ) ! = hwAddress ) {
printf ( " [WARNING] Got networkDeviceStateChanged signal for HW address '%s', but my HW address is '%s'! Ignoring... \n \r " , hwAddress . ascii ( ) , dev - > macAddress ( ) . ascii ( ) ) ;
}
slotCheckActiveAccessPoint ( ) ;
if ( state = = TDENetworkConnectionStatus : : Connected ) {
if ( newS tate = = TDENetworkConnectionStatus : : Connected ) {
// trigger an update of the connections seen bssids property
TDENetworkConnectionManager * deviceConnMan = dev - > connectionManager ( ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
@ -308,19 +312,19 @@ void WirelessDeviceTray::slotUpdateDeviceState(TDENetworkConnectionStatus::TDENe
int strength = ( ap - > signalQuality * 100.0 ) ;
if ( strength > 80 ) {
setPixmapForStates ( s tate, " nm_signal_100 " ) ;
setPixmapForStates ( newS tate, " nm_signal_100 " ) ;
}
else if ( strength > 55 ) {
setPixmapForStates ( s tate, " nm_signal_75 " ) ;
setPixmapForStates ( newS tate, " nm_signal_75 " ) ;
}
else if ( strength > 30 ) {
setPixmapForStates ( s tate, " nm_signal_50 " ) ;
setPixmapForStates ( newS tate, " nm_signal_50 " ) ;
}
else if ( strength > 5 ) {
setPixmapForStates ( s tate, " nm_signal_25 " ) ;
setPixmapForStates ( newS tate, " nm_signal_25 " ) ;
}
else {
setPixmapForStates ( s tate, " nm_signal_00 " ) ;
setPixmapForStates ( newS tate, " nm_signal_00 " ) ;
}
}
}
@ -346,13 +350,8 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
if ( active_conn & & deviceConnMan - > deviceInformation ( ) . statusFlags = = TDENetworkConnectionStatus : : Connected ) {
TDENetworkWiFiAPInfo * activeap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
if ( activeap ! = d - > activeAccessPoint ) {
if ( ! d - > activeAccessPoint . isNull ( ) ) {
disconnect ( deviceConnMan , TQT_SIGNAL ( accessPointStatusChanged ( TDEMACAddress , TDENetworkAPEventType : : TDENetworkAPEventType ) ) , this , TQT_SLOT ( apPropertyChanged ( TDEMACAddress , TDENetworkAPEventType : : TDENetworkAPEventType ) ) ) ;
}
d - > activeAccessPoint = activeap ;
if ( d - > activeAccessPoint ) {
connect ( deviceConnMan , TQT_SIGNAL ( accessPointStatusChanged ( TDEMACAddress , TDENetworkAPEventType : : TDENetworkAPEventType ) ) , this , TQT_SLOT ( apPropertyChanged ( TDEMACAddress , TDENetworkAPEventType : : TDENetworkAPEventType ) ) ) ;
TDEWiFiConnection * wireless = dynamic_cast < TDEWiFiConnection * > ( active_conn ) ;
if ( wireless ) {
if ( ! ( wireless - > heardBSSIDs . contains ( d - > activeAccessPoint - > BSSID ) ) ) {
@ -401,11 +400,48 @@ void WirelessDeviceTray::slotAccessPointAdded(TDENetworkWiFiAPInfo* ap)
KNotifyClient : : event ( tray ( ) - > winId ( ) , " knm-nm-network-found " , i18n ( " TDENetworkManager New Wireless Network Found " ) ) ;
}
void WirelessDeviceTray : : slotAccessPointRemoved ( const TQString & )
void WirelessDeviceTray : : slotAccessPointRemoved ( TDEMACAddress )
{
KNotifyClient : : event ( tray ( ) - > winId ( ) , " knm-nm-network-gone " , i18n ( " TDENetworkManager Wireless Network Disappeared " ) ) ;
}
void WirelessDeviceTray : : tdeHardwareEventHandler ( TDEHardwareEvent : : TDEHardwareEvent event , TQString )
{
if ( event = = TDEHardwareEvent : : HardwareListModified ) {
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
TDENetworkConnectionManager * deviceConnMan = dev - > connectionManager ( ) ;
// get notified when the device state changes
connect ( deviceConnMan , TQT_SIGNAL ( networkDeviceStateChanged ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus , TDENetworkConnectionStatus : : TDENetworkConnectionStatus , TQString ) ) , this , TQT_SLOT ( slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus , TDENetworkConnectionStatus : : TDENetworkConnectionStatus , TQString ) ) ) ;
// get notified of all AP changes
connect ( deviceConnMan , TQT_SIGNAL ( accessPointStatusChanged ( TDEMACAddress , TDENetworkAPEventType : : TDENetworkAPEventType ) ) , this , TQT_SLOT ( tdeAccessPointStatusChangedHandler ( TDEMACAddress , TDENetworkAPEventType : : TDENetworkAPEventType ) ) ) ;
}
}
void WirelessDeviceTray : : tdeAccessPointStatusChangedHandler ( TDEMACAddress BSSID , TDENetworkAPEventType : : TDENetworkAPEventType event ) {
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
TDENetworkConnectionManager * deviceConnMan = dev - > connectionManager ( ) ;
if ( event = = TDENetworkAPEventType : : Discovered ) {
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 ) {
apPropertyChanged ( BSSID , event ) ;
}
}
else if ( event = = TDENetworkAPEventType : : AccessPointChanged ) {
slotCheckActiveAccessPoint ( ) ;
}
}
WirelessDeviceTray : : WirelessDeviceTray ( TQString dev , KSystemTray * parent , const char * name )
: DeviceTrayComponent ( dev , parent , name )
{
@ -413,7 +449,6 @@ WirelessDeviceTray::WirelessDeviceTray (TQString dev, KSystemTray * parent, cons
d - > dev = dev ;
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * hwdev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
// we want other icons for wireless devices
setPixmapForState ( TDENetworkConnectionStatus : : Invalid , " wireless_off " ) ;
@ -422,19 +457,10 @@ WirelessDeviceTray::WirelessDeviceTray (TQString dev, KSystemTray * parent, cons
setPixmapForState ( TDENetworkConnectionStatus : : Disconnected , " wireless " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : Connected , " nm_signal_50 " ) ;
// TDENM FIXME
// These TQt connections will need to be re-established whenever the device list changes, e.g. after a call to TDEHardwareDevices::queryHardwareInformation()
// Therefore, this class should listen to hardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString) and reload devices if TDEHardwareEvent::HardwareListModified is passed
// get notified when the device state changes
connect ( hwdev , TQT_SIGNAL ( StateChanged ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus ) ) , this , TQT_SLOT ( slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus ) ) ) ;
// if the active access point changed but not the connection we roamed to a new AP
connect ( hwdev , TQT_SIGNAL ( propertiesChanged ( ) ) , this , TQT_SLOT ( slotCheckActiveAccessPoint ( ) ) ) ;
// get notified of all AP changes
connect ( hwdev , TQT_SIGNAL ( accessPointAdded ( TDENetworkWiFiAPInfo * ) ) , this , TQT_SLOT ( slotAccessPointAdded ( TDENetworkWiFiAPInfo * ) ) ) ;
connect ( hwdev , TQT_SIGNAL ( accessPointRemoved ( const TQString & ) ) , this , TQT_SLOT ( slotAccessPointRemoved ( const TQString & ) ) ) ;
// Listen for hardware change events
connect ( hwdevices , TQT_SIGNAL ( hardwareEvent ( TDEHardwareEvent : : TDEHardwareEvent , TQString ) ) , this , TQT_SLOT ( tdeHardwareEventHandler ( TDEHardwareEvent : : TDEHardwareEvent , TQString ) ) ) ;
// Trigger an initial hardware information update
tdeHardwareEventHandler ( TDEHardwareEvent : : HardwareListModified , TQString : : null ) ;
}
WirelessDeviceTray : : ~ WirelessDeviceTray ( )