summaryrefslogtreecommitdiff
path: root/noncore/applets/wirelessapplet/wireless.cpp
Unidiff
Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp44
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
@@ -16,10 +16,14 @@
16#include "advancedconfig.h" 16#include "advancedconfig.h"
17 17
18/* OPIE */ 18/* OPIE */
19#include <opie2/odebug.h>
19#include <opie2/onetwork.h> 20#include <opie2/onetwork.h>
20#include <opie2/otaskbarapplet.h> 21#include <opie2/otaskbarapplet.h>
21#include <qpe/config.h> 22#include <qpe/config.h>
22#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24using namespace Opie::Core;
25using namespace Opie::Ui;
26using namespace Opie::Net;
23 27
24/* QT */ 28/* QT */
25#include <qradiobutton.h> 29#include <qradiobutton.h>
@@ -43,8 +47,6 @@
43//#define MDEBUG 47//#define MDEBUG
44#undef MDEBUG 48#undef MDEBUG
45 49
46using namespace Opie::Ui;
47using namespace Opie::Net;
48WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 50WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name )
49 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) 51 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet )
50{ 52{
@@ -207,14 +209,14 @@ void WirelessApplet::checkInterface()
207 if ( interface ) 209 if ( interface )
208 { 210 {
209#ifdef MDEBUG 211#ifdef MDEBUG
210 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); 212 odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl;
211#endif 213#endif
212 214
213 } 215 }
214 else 216 else
215 { 217 {
216#ifdef MDEBUG 218#ifdef MDEBUG
217 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); 219 odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl;
218#endif 220#endif
219 hide(); 221 hide();
220 } 222 }
@@ -223,7 +225,7 @@ void WirelessApplet::checkInterface()
223void WirelessApplet::renewDHCP() 225void WirelessApplet::renewDHCP()
224{ 226{
225#ifdef MDEBUG 227#ifdef MDEBUG
226 qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); 228 odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl;
227#endif 229#endif
228 230
229 QString pidfile; 231 QString pidfile;
@@ -235,7 +237,7 @@ void WirelessApplet::renewDHCP()
235 237
236 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); 238 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename );
237#ifdef MDEBUG 239#ifdef MDEBUG
238 qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile ); 240 odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl;
239#endif 241#endif
240 int pid; 242 int pid;
241 QFile pfile( pidfile ); 243 QFile pfile( pidfile );
@@ -245,7 +247,7 @@ void WirelessApplet::renewDHCP()
245 { 247 {
246 s >> pid; 248 s >> pid;
247#ifdef MDEBUG 249#ifdef MDEBUG
248 qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); 250 odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl;
249#endif 251#endif
250 kill( pid, SIGALRM ); 252 kill( pid, SIGALRM );
251 return ; 253 return ;
@@ -253,11 +255,11 @@ void WirelessApplet::renewDHCP()
253 255
254 // No dhcpcd, so we are trying udhcpc 256 // No dhcpcd, so we are trying udhcpc
255#ifdef MDEBUG 257#ifdef MDEBUG
256 qDebug( "WIFIAPPLET: dhcpcd not available." ); 258 odebug << "WIFIAPPLET: dhcpcd not available." << oendl;
257#endif 259#endif
258 pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); 260 pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename );
259#ifdef MDEBUG 261#ifdef MDEBUG
260 qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", ( const char* ) pidfile ); 262 odebug << "WIFIAPPLET: udhcpc pidfile is '" << ( const char* ) pidfile << "'" << oendl;
261#endif 263#endif
262 QFile pfile2( pidfile ); 264 QFile pfile2( pidfile );
263 hasFile = pfile2.open( IO_ReadOnly ); 265 hasFile = pfile2.open( IO_ReadOnly );
@@ -266,7 +268,7 @@ void WirelessApplet::renewDHCP()
266 { 268 {
267 s2 >> pid; 269 s2 >> pid;
268#ifdef MDEBUG 270#ifdef MDEBUG
269 qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); 271 odebug << "WIFIAPPLET: sent SIGUSR1 to pid " << pid << "" << oendl;
270#endif 272#endif
271 kill( pid, SIGUSR1 ); 273 kill( pid, SIGUSR1 );
272 return ; 274 return ;
@@ -303,14 +305,14 @@ WirelessApplet::~WirelessApplet()
303void WirelessApplet::timerEvent( QTimerEvent* ) 305void WirelessApplet::timerEvent( QTimerEvent* )
304{ 306{
305#ifdef MDEBUG 307#ifdef MDEBUG
306 qDebug( "WirelessApplet::timerEvent" ); 308 odebug << "WirelessApplet::timerEvent" << oendl;
307#endif 309#endif
308 if ( interface ) 310 if ( interface )
309 { 311 {
310 if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) ) 312 if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) )
311 { 313 {
312#ifdef MDEBUG 314#ifdef MDEBUG
313 qDebug( "WIFIAPPLET: Interface no longer present." ); 315 odebug << "WIFIAPPLET: Interface no longer present." << oendl;
314#endif 316#endif
315 interface = 0L; 317 interface = 0L;
316 mustRepaint(); 318 mustRepaint();
@@ -320,7 +322,7 @@ void WirelessApplet::timerEvent( QTimerEvent* )
320 if ( mustRepaint() ) 322 if ( mustRepaint() )
321 { 323 {
322#ifdef MDEBUG 324#ifdef MDEBUG
323 qDebug( "WIFIAPPLET: A value has changed -> repainting." ); 325 odebug << "WIFIAPPLET: A value has changed -> repainting." << oendl;
324#endif 326#endif
325 repaint(); 327 repaint();
326 } 328 }
@@ -356,14 +358,14 @@ bool WirelessApplet::mustRepaint()
356 if ( interface ) 358 if ( interface )
357 { 359 {
358#ifdef MDEBUG 360#ifdef MDEBUG
359 qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); 361 odebug << "WIFIAPPLET: We had no interface but now we have one! :-)" << oendl;
360#endif 362#endif
361 show(); 363 show();
362 } 364 }
363 else 365 else
364 { 366 {
365#ifdef MDEBUG 367#ifdef MDEBUG
366 qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); 368 odebug << "WIFIAPPLET: We had a interface but now we don't have one! ;-(" << oendl;
367#endif 369#endif
368 hide(); 370 hide();
369 return true; 371 return true;
@@ -395,28 +397,28 @@ bool WirelessApplet::mustRepaint()
395 if ( rocESSID && ( oldESSID != interface->SSID() ) ) 397 if ( rocESSID && ( oldESSID != interface->SSID() ) )
396 { 398 {
397#ifdef MDEBUG 399#ifdef MDEBUG
398 qDebug( "WIFIAPPLET: ESSID has changed." ); 400 odebug << "WIFIAPPLET: ESSID has changed." << oendl;
399#endif 401#endif
400 renewDHCP(); 402 renewDHCP();
401 } 403 }
402 else if ( rocFREQ && ( oldFREQ != interface->frequency() ) ) 404 else if ( rocFREQ && ( oldFREQ != interface->frequency() ) )
403 { 405 {
404#ifdef MDEBUG 406#ifdef MDEBUG
405 qDebug( "WIFIAPPLET: FREQ has changed." ); 407 odebug << "WIFIAPPLET: FREQ has changed." << oendl;
406#endif 408#endif
407 renewDHCP(); 409 renewDHCP();
408 } 410 }
409 else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) ) 411 else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) )
410 { 412 {
411#ifdef MDEBUG 413#ifdef MDEBUG
412 qDebug( "WIFIAPPLET: AP has changed." ); 414 odebug << "WIFIAPPLET: AP has changed." << oendl;
413#endif 415#endif
414 renewDHCP(); 416 renewDHCP();
415 } 417 }
416 else if ( rocMODE && ( oldMODE != interface->mode() ) ) 418 else if ( rocMODE && ( oldMODE != interface->mode() ) )
417 { 419 {
418#ifdef MDEBUG 420#ifdef MDEBUG
419 qDebug( "WIFIAPPLET: MODE has changed." ); 421 odebug << "WIFIAPPLET: MODE has changed." << oendl;
420#endif 422#endif
421 renewDHCP(); 423 renewDHCP();
422 } 424 }
@@ -450,7 +452,7 @@ int WirelessApplet::numberOfRings()
450{ 452{
451 if ( !interface ) return -1; 453 if ( !interface ) return -1;
452 int qualityH = interface->signalStrength(); 454 int qualityH = interface->signalStrength();
453 qDebug( "quality = %d", qualityH ); 455 odebug << "quality = " << qualityH << "" << oendl;
454 if ( qualityH < 1 ) return -1; 456 if ( qualityH < 1 ) return -1;
455 if ( qualityH < 20 ) return 0; 457 if ( qualityH < 20 ) return 0;
456 if ( qualityH < 40 ) return 1; 458 if ( qualityH < 40 ) return 1;
@@ -481,7 +483,7 @@ void WirelessApplet::paintEvent( QPaintEvent* )
481 return; 483 return;
482 } 484 }
483 485
484 qDebug( "WirelessApplet: painting %d rings", rings ); 486 odebug << "WirelessApplet: painting " << rings << " rings" << oendl;
485 int radius = 2; 487 int radius = 2;
486 int rstep = 4; 488 int rstep = 4;
487 int maxrings = w/rstep; 489 int maxrings = w/rstep;