@ -61,15 +61,18 @@ class WirelessDeviceTrayPrivate
WirelessDeviceTrayPrivate ( ) : dev ( 0 ) , activeAccessPoint ( 0 ) { }
~ WirelessDeviceTrayPrivate ( ) { }
T DENetworkDevice* dev ;
T QString dev ;
TQGuardedPtr < TDENetworkWiFiAPInfo > activeAccessPoint ;
} ;
TQStringList WirelessDeviceTray : : getToolTipText ( )
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
TQStringList tooltip = DeviceTrayComponent : : getToolTipText ( ) ;
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( deviceConnMan - > deviceInformation ( ) . wiFiInfo . activeAccessPointBSSID ) ;
if ( ap ) {
tooltip . append ( i18n ( " Network: %1 " ) . arg ( ap - > friendlySSID ( ) ) ) ;
@ -80,8 +83,11 @@ TQStringList WirelessDeviceTray::getToolTipText()
void WirelessDeviceTray : : newConnection ( )
{
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
// create a new wireless connection
TDENetworkConnection * conn = new TDEWiFiConnection ( ) ;
nm - > loadConnectionAllowedValues ( conn ) ;
// open a dialog for editing the connection
use_new_wireless_essid = 0 ; // deactivate autofill for now
@ -127,17 +133,20 @@ TDEWiFiConnection* WirelessDeviceTray::findMatchingConnection(const WirelessNetw
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 " ) ;
// get all wireless networks
TQValueList < WirelessNetwork > nets = WirelessManager : : getWirelessNetworks ( d - > dev ) ;
TQValueList < WirelessNetwork > nets = WirelessManager : : getWirelessNetworks ( d ev) ;
// get all wireless connections
TQValueList < TDEWiFiConnection * > conns = WirelessManager : : getWirelessConnections ( ) ;
// get the currently active connection
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = dev - > connectionManager ( ) ;
TDENetworkConnection * active_conn = NULL ;
if ( ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Disconnected ) )
& & ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Invalid ) ) ) {
@ -152,13 +161,14 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
WirelessNetwork net ;
// only show connections which are in range
if ( ! findMatchingNetwork ( * it , nets , net ) )
if ( ! findMatchingNetwork ( * it , nets , net ) ) {
continue ;
}
wirelessNetworkItem = new WirelessNetworkItem ( menu ,
d - > dev ,
net ,
* it ,
( * it ) - > UUID ,
false ) ;
int id = menu - > insertItem ( wirelessNetworkItem , - 1 , - 1 ) ;
menu - > setItemChecked ( id , ( ( TDENetworkConnection * ) ( * it ) = = active_conn ) ) ;
@ -187,7 +197,7 @@ void WirelessDeviceTray::addWirelessNetworks(KPopupMenu* menu)
wirelessNetworkItem = new WirelessNetworkItem ( menu ,
d - > dev ,
net ,
* it ,
( * it ) - > UUID ,
false ) ;
int id = popup - > insertItem ( wirelessNetworkItem , - 1 , - 1 ) ;
@ -234,11 +244,14 @@ void WirelessDeviceTray::addWirelessNetworks(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
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
// 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 ) ;
// bolding subhead instead
@ -282,11 +295,14 @@ void WirelessDeviceTray::setPixmapForStates(TDENetworkConnectionStatus::TDENetwo
void WirelessDeviceTray : : slotUpdateDeviceState ( TDENetworkConnectionStatus : : TDENetworkConnectionStatus state )
{
TDEHardwareDevices * hwdevices = KGlobal : : hardwareDevices ( ) ;
TDENetworkDevice * dev = dynamic_cast < TDENetworkDevice * > ( hwdevices - > findByUniqueID ( d - > dev ) ) ;
slotCheckActiveAccessPoint ( ) ;
if ( state = = TDENetworkConnectionStatus : : Connected ) {
// 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 ) ;
if ( ap ) {
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
// 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
TDEGlobalNetworkManager * nm = KGlobal : : networkManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkConnection * active_conn = NULL ;
if ( ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Disconnected ) )
& & ( ! ( deviceConnMan - > deviceInformation ( ) . statusFlags & TDENetworkConnectionStatus : : Invalid ) ) ) {
@ -347,8 +366,11 @@ void WirelessDeviceTray::slotCheckActiveAccessPoint()
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 ) {
TDENetworkConnectionManager * deviceConnMan = d - > dev - > connectionManager ( ) ;
TDENetworkConnectionManager * deviceConnMan = d ev- > connectionManager ( ) ;
TDENetworkWiFiAPInfo * ap = deviceConnMan - > findAccessPointByBSSID ( BSSID ) ;
if ( ap ) {
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 " ) ) ;
}
WirelessDeviceTray : : WirelessDeviceTray ( T DENetworkDevice* dev , KSystemTray * parent , const char * name )
WirelessDeviceTray : : WirelessDeviceTray ( T QString dev , KSystemTray * parent , const char * name )
: DeviceTrayComponent ( dev , parent , name )
{
d = new WirelessDeviceTrayPrivate ( ) ;
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 " ) ;
setPixmapForState ( TDENetworkConnectionStatus : : LinkUnavailable , " wireless_off " ) ;
@ -397,15 +422,19 @@ WirelessDeviceTray::WirelessDeviceTray (TDENetworkDevice* dev, KSystemTray * par
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 ( 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
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
connect ( 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 ( accessPointAdded ( TDENetworkWiFiAPInfo * ) ) , this , TQT_SLOT ( slotAccessPointAdded ( TDENetworkWiFiAPInfo * ) ) ) ;
connect ( hw dev, TQT_SIGNAL ( accessPointRemoved ( const TQString & ) ) , this , TQT_SLOT ( slotAccessPointRemoved ( const TQString & ) ) ) ;
}
WirelessDeviceTray : : ~ WirelessDeviceTray ( )