-rw-r--r-- | noncore/applets/wirelessapplet/networkinfo.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/noncore/applets/wirelessapplet/networkinfo.cpp b/noncore/applets/wirelessapplet/networkinfo.cpp index 2274d99..e0c487b 100644 --- a/noncore/applets/wirelessapplet/networkinfo.cpp +++ b/noncore/applets/wirelessapplet/networkinfo.cpp @@ -137,138 +137,136 @@ bool MWirelessNetworkInterface::updateStatistics() } else essid = "*** Unknown ***"; // Address of associated access-point result = ioctl( fd, SIOCGIWAP, &iwr ); if ( result == 0 ) { APAddr.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", iwr.u.ap_addr.sa_data[0]&0xff, iwr.u.ap_addr.sa_data[1]&0xff, iwr.u.ap_addr.sa_data[2]&0xff, iwr.u.ap_addr.sa_data[3]&0xff, iwr.u.ap_addr.sa_data[4]&0xff, iwr.u.ap_addr.sa_data[5]&0xff ); } else APAddr = "*** Unknown ***"; iwr.u.data.pointer = (caddr_t) buffer; iwr.u.data.length = IW_ESSID_MAX_SIZE; iwr.u.data.flags = 0; result = ioctl( fd, SIOCGIWNICKN, &iwr ); if ( result == 0 ) { iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; nick = iwr.u.data.pointer; } else nick = "*** Unknown ***"; result = ioctl( fd, SIOCGIWMODE, &iwr ); if ( result == 0 ) mode = ( iwr.u.mode == IW_MODE_ADHOC ) ? "Ad-Hoc" : "Managed"; else mode = "*** Unknown ***"; result = ioctl( fd, SIOCGIWFREQ, &iwr ); if ( result == 0 ) freq = double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000; else freq = 0; // gather link quality from /proc/net/wireless char c; QString status; QString name; QFile wfile( PROCNETWIRELESS ); bool hasFile = wfile.open( IO_ReadOnly ); QTextStream wstream( &wfile ); if ( hasFile ) { wstream.readLine(); // skip the first two lines wstream.readLine(); // because they only contain headers } if ( ( !hasFile ) || ( wstream.atEnd() ) ) { #ifdef MDEBUG qDebug( "WIFIAPPLET: D'oh! Someone removed the card..." ); #endif quality = -1; signal = IW_LOWER; noise = IW_LOWER; return false; } wstream >> name >> status >> quality >> c >> signal >> c >> noise; - if ( quality > 92 ) #ifdef MDEBUG + if ( quality > 92 ) qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); -#endif + if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) -#ifdef MDEBUG qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); -#endif + if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) -#ifdef MDEBUG qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); #endif return true; } //--------------------------------------------------------------------------- // class Network // MNetwork::MNetwork() { procfile = PROCNETDEV; } MNetwork::~MNetwork() { } //--------------------------------------------------------------------------- // class WirelessNetwork // MWirelessNetwork::MWirelessNetwork() { procfile = PROCNETWIRELESS; } MWirelessNetwork::~MWirelessNetwork() { } MNetworkInterface* MWirelessNetwork::createInterface( const char* n ) const { return new MWirelessNetworkInterface( n ); } //--------------------------------------------------------------------------- // class NetworkInterface // MNetworkInterface* MNetwork::getFirstInterface() { enumerateInterfaces(); InterfaceMapIterator it( interfaces ); return ( it.count() > 0 ) ? it.toFirst() : 0; } void MNetwork::enumerateInterfaces() { interfaces.clear(); QString str; QFile f( procfile ); bool hasFile = f.open( IO_ReadOnly ); if ( !hasFile ) return; QTextStream s( &f ); s.readLine(); s.readLine(); while ( !s.atEnd() ) { s >> str; str.truncate( str.find( ':' ) ); |