Diffstat (limited to 'noncore/applets/wirelessapplet') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index 0491a86..364f3ad 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp @@ -13,16 +13,20 @@ #include "wireless.h" #include "mgraph.h" #include "advancedconfig.h" /* OPIE */ +#include <opie2/odebug.h> #include <opie2/onetwork.h> #include <opie2/otaskbarapplet.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; +using namespace Opie::Ui; +using namespace Opie::Net; /* QT */ #include <qradiobutton.h> #include <qpushbutton.h> #include <qpainter.h> #include <qlabel.h> @@ -40,14 +44,12 @@ #define round qRound #endif //#define MDEBUG #undef MDEBUG -using namespace Opie::Ui; -using namespace Opie::Net; WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) { readConfig(); writeConfigEntry( "UpdateFrequency", updateFrequency ); @@ -204,72 +206,72 @@ void WirelessApplet::checkInterface() if ( it.current() && it.current()->isWireless() ) interface = static_cast<OWirelessNetworkInterface*>( it.current() ); if ( interface ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); + odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl; #endif } else { #ifdef MDEBUG - qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); + odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl; #endif hide(); } } void WirelessApplet::renewDHCP() { #ifdef MDEBUG - qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); + odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl; #endif QString pidfile; if ( !interface ) return ; QString ifacename( interface->name() ); // At first we are trying dhcpcd pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); #ifdef MDEBUG - qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile ); + odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl; #endif int pid; QFile pfile( pidfile ); bool hasFile = pfile.open( IO_ReadOnly ); QTextStream s( &pfile ); if ( hasFile ) { s >> pid; #ifdef MDEBUG - qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); + odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl; #endif kill( pid, SIGALRM ); return ; } // No dhcpcd, so we are trying udhcpc #ifdef MDEBUG - qDebug( "WIFIAPPLET: dhcpcd not available." ); + odebug << "WIFIAPPLET: dhcpcd not available." << oendl; #endif pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); #ifdef MDEBUG - qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", ( const char* ) pidfile ); + odebug << "WIFIAPPLET: udhcpc pidfile is '" << ( const char* ) pidfile << "'" << oendl; #endif QFile pfile2( pidfile ); hasFile = pfile2.open( IO_ReadOnly ); QTextStream s2( &pfile2 ); if ( hasFile ) { s2 >> pid; #ifdef MDEBUG - qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); + odebug << "WIFIAPPLET: sent SIGUSR1 to pid " << pid << "" << oendl; #endif kill( pid, SIGUSR1 ); return ; } } @@ -300,30 +302,30 @@ void WirelessApplet::displayStyleChange( int style ) WirelessApplet::~WirelessApplet() {} void WirelessApplet::timerEvent( QTimerEvent* ) { #ifdef MDEBUG - qDebug( "WirelessApplet::timerEvent" ); + odebug << "WirelessApplet::timerEvent" << oendl; #endif if ( interface ) { if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: Interface no longer present." ); + odebug << "WIFIAPPLET: Interface no longer present." << oendl; #endif interface = 0L; mustRepaint(); return; } if ( mustRepaint() ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: A value has changed -> repainting." ); + odebug << "WIFIAPPLET: A value has changed -> repainting." << oendl; #endif repaint(); } if ( status->isVisible() ) { @@ -353,20 +355,20 @@ bool WirelessApplet::mustRepaint() if ( interface != oldiface ) { oldiface = interface; if ( interface ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); + odebug << "WIFIAPPLET: We had no interface but now we have one! :-)" << oendl; #endif show(); } else { #ifdef MDEBUG - qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); + odebug << "WIFIAPPLET: We had a interface but now we don't have one! ;-(" << oendl; #endif hide(); return true; } } @@ -392,34 +394,34 @@ bool WirelessApplet::mustRepaint() return true; } if ( rocESSID && ( oldESSID != interface->SSID() ) ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: ESSID has changed." ); + odebug << "WIFIAPPLET: ESSID has changed." << oendl; #endif renewDHCP(); } else if ( rocFREQ && ( oldFREQ != interface->frequency() ) ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: FREQ has changed." ); + odebug << "WIFIAPPLET: FREQ has changed." << oendl; #endif renewDHCP(); } else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: AP has changed." ); + odebug << "WIFIAPPLET: AP has changed." << oendl; #endif renewDHCP(); } else if ( rocMODE && ( oldMODE != interface->mode() ) ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: MODE has changed." ); + odebug << "WIFIAPPLET: MODE has changed." << oendl; #endif renewDHCP(); } oldESSID = interface->SSID(); oldMODE = interface->mode(); @@ -447,13 +449,13 @@ void WirelessApplet::updatePopupWindow() } int WirelessApplet::numberOfRings() { if ( !interface ) return -1; int qualityH = interface->signalStrength(); - qDebug( "quality = %d", qualityH ); + odebug << "quality = " << qualityH << "" << oendl; if ( qualityH < 1 ) return -1; if ( qualityH < 20 ) return 0; if ( qualityH < 40 ) return 1; if ( qualityH < 60 ) return 2; if ( qualityH < 65 ) return 3; return 4; @@ -478,13 +480,13 @@ void WirelessApplet::paintEvent( QPaintEvent* ) p.setPen( QPen( QColor( 200, 20, 20 ), 2 ) ); p.drawLine( w/2-m-m, h/2-m-m, w/2+m+m, h/2+m+m ); p.drawLine( w/2+m+m, h/2-m-m, w/2-m-m, h/2+m+m ); return; } - qDebug( "WirelessApplet: painting %d rings", rings ); + odebug << "WirelessApplet: painting " << rings << " rings" << oendl; int radius = 2; int rstep = 4; int maxrings = w/rstep; p.setPen( QColor( 200, 20, 20 ) ); for ( int i = 0; i < rings; ++i ) |