@ -61,15 +61,18 @@ class WirelessDeviceTrayPrivate
WirelessDeviceTrayPrivate ( ) : dev ( 0 ) , activeAccessPoint ( 0 ) { }
WirelessDeviceTrayPrivate ( ) : dev ( 0 ) , activeAccessPoint ( 0 ) { }
~ WirelessDeviceTrayPrivate ( ) { }
~ WirelessDeviceTrayPrivate ( ) { }
T DENetworkDevice* dev ;
T QString dev ;
TQGuardedPtr < TDENetworkWiFiAPInfo > activeAccessPoint ;
TQGuardedPtr < TDENetworkWiFiAPInfo > activeAccessPoint ;
} ;
} ;
TQStringList WirelessDeviceTray : : getToolTipText ( )
TQStringList WirelessDeviceTray : : getToolTipText ( )
{
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
TQStringList tooltip = DeviceTrayComponent : : getToolTipText ( ) ;
TQStringList tooltip = DeviceTrayComponent : : getToolTipText ( ) ;
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
if ( ap ) {
if ( ap ) {
tooltip . append ( i18n ( " Network: %1 " ) . arg ( ap - > friendlySSID ( ) ) ) ;
tooltip . append ( i18n ( " Network: %1 " ) . arg ( ap - > friendlySSID ( ) ) ) ;
@ -80,8 +83,11 @@ TQStringList WirelessDeviceTray::getToolTipText()
void WirelessDeviceTray : : newConnection ( )
void WirelessDeviceTray : : newConnection ( )
{
{
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
// create a new wireless connection
// create a new wireless connection
TDENetworkConnection * conn = new TDEWiFiConnection ( ) ;
TDENetworkConnection * conn = new TDEWiFiConnection ( ) ;
nm - > loadConnectionAllowedValues ( conn ) ;
// open a dialog for editing the connection
// open a dialog for editing the connection
use_new_wireless_essid = 0 ; // deactivate autofill for now
use_new_wireless_essid = 0 ; // deactivate autofill for now
@ -127,17 +133,20 @@ TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetw
void WirelessDeviceTray : : addWirelessNetworks ( KPopupMenu * menu )
void WirelessDeviceTray : : addWirelessNetworks ( KPopupMenu * menu )
{
{
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
printf ( " Updating wireless network list \n \r " ) ;
printf ( " Updating wireless network list \n \r " ) ;
// get all wireless networks
// get all wireless networks
TQValueList < WirelessNetwork > nets = WirelessManager : : getWirelessNetworks ( d - > dev ) ;
TQValueList < WirelessNetwork > nets = WirelessManager : : getWirelessNetworks ( d ev) ;
// get all wireless connections
// get all wireless connections
TQValueList < TDEWiFiConnection * > conns = WirelessManager : : getWirelessConnections ( ) ;
TQValueList < TDEWiFiConnection * > conns = WirelessManager : : getWirelessConnections ( ) ;
// get the currently active connection
// get the currently active connection
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnection * active_conn = NULL ;
TDENetworkConnection * active_conn = NULL ;
if ( ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Disconnected ) )
if ( ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Disconnected ) )
& & ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Invalid ) ) ) {
& & ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Invalid ) ) ) {
@ -152,13 +161,14 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
WirelessNetwork net ;
WirelessNetwork net ;
// only show connections which are in range
// only show connections which are in range
if ( ! findMatchingNetwork ( * it , nets , net ) )
if ( ! findMatchingNetwork ( * it , nets , net ) ) {
continue ;
continue ;
}
wirelessNetworkItem = new WirelessNetworkItem ( menu ,
wirelessNetworkItem = new WirelessNetworkItem ( menu ,
d - > dev ,
d - > dev ,
net ,
net ,
* it ,
( * it ) - > UUID ,
false ) ;
false ) ;
int id = menu - > insertItem ( wirelessNetworkItem , - 1 , - 1 ) ;
int id = menu - > insertItem ( wirelessNetworkItem , - 1 , - 1 ) ;
menu - > setItemChecked ( id , ( ( TDENetworkConnection * ) ( * it ) = = active_conn ) ) ;
menu - > setItemChecked ( id , ( ( TDENetworkConnection * ) ( * it ) = = active_conn ) ) ;
@ -187,7 +197,7 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
wirelessNetworkItem = new WirelessNetworkItem ( menu ,
wirelessNetworkItem = new WirelessNetworkItem ( menu ,
d - > dev ,
d - > dev ,
net ,
net ,
* it ,
( * it ) - > UUID ,
false ) ;
false ) ;
int id = popup - > insertItem ( wirelessNetworkItem , - 1 , - 1 ) ;
int id = popup - > insertItem ( wirelessNetworkItem , - 1 , - 1 ) ;
@ -234,11 +244,14 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
void WirelessDeviceTray : : addMenuItems ( KPopupMenu * menu )
void WirelessDeviceTray : : addMenuItems ( KPopupMenu * menu )
{
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
// get the currently active connection
// get the currently active connection
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
// device title
// device title
Subhead * subhead = new Subhead ( menu , " subhead " , TQString ( " Wireless Connection (%1) " ) . arg ( d - > d ev- > deviceNode ( ) ) , SmallIcon ( " wireless " , TQIconSet : : Automatic ) ) ;
Subhead * subhead = new Subhead ( menu , " subhead " , TQString ( " Wireless Connection (%1) " ) . arg ( d ev- > deviceNode ( ) ) , SmallIcon ( " wireless " , TQIconSet : : Automatic ) ) ;
menu - > insertItem ( subhead , - 1 , - 1 ) ;
menu - > insertItem ( subhead , - 1 , - 1 ) ;
// bolding subhead instead
// bolding subhead instead
@ -282,11 +295,14 @@ void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetwo
void WirelessDeviceTray : : slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus state )
void WirelessDeviceTray : : slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus state )
{
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
slotCheckActiveAccessPoint ( ) ;
slotCheckActiveAccessPoint ( ) ;
if ( state = = TDENetworkConnectionStatus : : Connected ) {
if ( state = = TDENetworkConnectionStatus : : Connected ) {
// trigger an update of the connections seen bssids property
// trigger an update of the connections seen bssids property
TDENetworkConnectionManager * deviceConnMan = d - > d ev- > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
if ( ap ) {
if ( ap ) {
int strength = ( ap - > signalQuality * 100.0 ) ;
int strength = ( ap - > signalQuality * 100.0 ) ;
@ -315,9 +331,12 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
// the active AP changed, if a connection is already active we have roamed
// the active AP changed, if a connection is already active we have roamed
// thus add the bssid to the list of seen bssids
// thus add the bssid to the list of seen bssids
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
// get the currently active connection
// get the currently active connection
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkConnection * active_conn = NULL ;
TDENetworkConnection * active_conn = NULL ;
if ( ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Disconnected ) )
if ( ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Disconnected ) )
& & ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Invalid ) ) ) {
& & ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Invalid ) ) ) {
@ -347,8 +366,11 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
void WirelessDeviceTray : : apPropertyChanged ( TDEMACAddress BSSID , TDENetworkAPEventType : : TDENetworkAPEventType event )
void WirelessDeviceTray : : apPropertyChanged ( TDEMACAddress BSSID , TDENetworkAPEventType : : TDENetworkAPEventType event )
{
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
if ( event = = TDENetworkAPEventType : : SignalStrengthChanged ) {
if ( event = = TDENetworkAPEventType : : SignalStrengthChanged ) {
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( BSSID ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( BSSID ) ;
if ( ap ) {
if ( ap ) {
TQ_UINT32 strength = ( ap - > signalQuality * 100.0 ) ;
TQ_UINT32 strength = ( ap - > signalQuality * 100.0 ) ;
@ -384,12 +406,15 @@ void WirelessDeviceTray::slotAccessPointRemoved(const TQString&)
KNotifyClient : : event ( tray ( ) - > winId ( ) , " knm-nm-network-gone " , i18n ( " TDENetworkManager Wireless Network Disappeared " ) ) ;
KNotifyClient : : event ( tray ( ) - > winId ( ) , " knm-nm-network-gone " , i18n ( " TDENetworkManager Wireless Network Disappeared " ) ) ;
}
}
WirelessDeviceTray : : WirelessDeviceTray ( T DENetworkDevice* dev , KSystemTray * parent , const char * name )
WirelessDeviceTray : : WirelessDeviceTray ( T QString dev , KSystemTray * parent , const char * name )
: DeviceTrayComponent ( dev , parent , name )
: DeviceTrayComponent ( dev , parent , name )
{
{
d = new WirelessDeviceTrayPrivate ( ) ;
d = new WirelessDeviceTrayPrivate ( ) ;
d - > dev = dev ;
d - > dev = dev ;
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * hwdev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
// we want other icons for wireless devices
// we want other icons for wireless devices
setPixmapForState ( TDENetworkConnectionStatus : : Invalid , " wireless_off " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : Invalid , " wireless_off " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : LinkUnavailable , " wireless_off " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : LinkUnavailable , " wireless_off " ) ;
@ -397,15 +422,19 @@ WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * par
setPixmapForState ( TDENetworkConnectionStatus : : Disconnected , " wireless " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : Disconnected , " wireless " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : Connected , " nm_signal_50 " ) ;
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
// get notified when the device state changes
connect ( dev , TQT_SIGNAL ( StateChanged ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus ) ) , this , TQT_SLOT ( slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus ) ) ) ;
connect ( hw dev, 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
// if the active access point changed but not the connection we roamed to a new AP
connect ( dev, TQT_SIGNAL ( propertiesChanged ( ) ) , this , TQT_SLOT ( slotCheckActiveAccessPoint ( ) ) ) ;
connect ( hw dev, TQT_SIGNAL ( propertiesChanged ( ) ) , this , TQT_SLOT ( slotCheckActiveAccessPoint ( ) ) ) ;
// get notified of all AP changes
// get notified of all AP changes
connect ( dev, TQT_SIGNAL ( accessPointAdded ( TDENetworkWiFiAPInfo * ) ) , this , TQT_SLOT ( slotAccessPointAdded ( TDENetworkWiFiAPInfo * ) ) ) ;
connect ( hw dev, TQT_SIGNAL ( accessPointAdded ( TDENetworkWiFiAPInfo * ) ) , this , TQT_SLOT ( slotAccessPointAdded ( TDENetworkWiFiAPInfo * ) ) ) ;
connect ( dev, TQT_SIGNAL ( accessPointRemoved ( const TQString & ) ) , this , TQT_SLOT ( slotAccessPointRemoved ( const TQString & ) ) ) ;
connect ( hw dev, TQT_SIGNAL ( accessPointRemoved ( const TQString & ) ) , this , TQT_SLOT ( slotAccessPointRemoved ( const TQString & ) ) ) ;
}
}
WirelessDeviceTray : : ~ WirelessDeviceTray ( )
WirelessDeviceTray : : ~ WirelessDeviceTray ( )