Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index dc9742a..72ac380 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -3,25 +3,24 @@ | |||
3 | ** | 3 | ** |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
5 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
7 | ** packaging of this file. | 7 | ** packaging of this file. |
8 | ** | 8 | ** |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | 13 | ||
14 | #include "wireless.h" | 14 | #include "wireless.h" |
15 | #include "networkinfo.h" | ||
16 | #include "mgraph.h" | 15 | #include "mgraph.h" |
17 | #include "advancedconfig.h" | 16 | #include "advancedconfig.h" |
18 | #include "connect0.xpm" | 17 | #include "connect0.xpm" |
19 | #include "connect1.xpm" | 18 | #include "connect1.xpm" |
20 | #include "connect2.xpm" | 19 | #include "connect2.xpm" |
21 | #include "connect3.xpm" | 20 | #include "connect3.xpm" |
22 | #include "connect4.xpm" | 21 | #include "connect4.xpm" |
23 | #include "connect5.xpm" | 22 | #include "connect5.xpm" |
24 | #include "nowireless.xpm" | 23 | #include "nowireless.xpm" |
25 | 24 | ||
26 | /* OPIE */ | 25 | /* OPIE */ |
27 | #include <opie2/onetwork.h> | 26 | #include <opie2/onetwork.h> |
@@ -42,26 +41,26 @@ | |||
42 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
43 | #include <qstring.h> | 42 | #include <qstring.h> |
44 | #include <qfile.h> | 43 | #include <qfile.h> |
45 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
46 | 45 | ||
47 | /* STD */ | 46 | /* STD */ |
48 | #include <sys/types.h> | 47 | #include <sys/types.h> |
49 | #include <signal.h> | 48 | #include <signal.h> |
50 | 49 | ||
51 | #define STYLE_BARS 0 | 50 | #define STYLE_BARS 0 |
52 | #define STYLE_ANTENNA 1 | 51 | #define STYLE_ANTENNA 1 |
53 | 52 | ||
54 | //#define MDEBUG | 53 | #define MDEBUG |
55 | #undef MDEBUG | 54 | //#undef MDEBUG |
56 | 55 | ||
57 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) | 56 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) |
58 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 57 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
59 | { | 58 | { |
60 | 59 | ||
61 | readConfig(); | 60 | readConfig(); |
62 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | 61 | writeConfigEntry( "UpdateFrequency", updateFrequency ); |
63 | writeConfigEntry( "DisplayStyle", displayStyle ); | 62 | writeConfigEntry( "DisplayStyle", displayStyle ); |
64 | 63 | ||
65 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 64 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
66 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 65 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
67 | 66 | ||
@@ -316,50 +315,44 @@ void WirelessApplet::updateDelayChange( int delay ) | |||
316 | 315 | ||
317 | void WirelessApplet::displayStyleChange( int style ) | 316 | void WirelessApplet::displayStyleChange( int style ) |
318 | { | 317 | { |
319 | visualStyle = style; | 318 | visualStyle = style; |
320 | repaint(); | 319 | repaint(); |
321 | } | 320 | } |
322 | 321 | ||
323 | WirelessApplet::~WirelessApplet() | 322 | WirelessApplet::~WirelessApplet() |
324 | {} | 323 | {} |
325 | 324 | ||
326 | void WirelessApplet::timerEvent( QTimerEvent* ) | 325 | void WirelessApplet::timerEvent( QTimerEvent* ) |
327 | { | 326 | { |
328 | /* | 327 | qDebug( "WirelessApplet::timerEvent" ); |
329 | |||
330 | OWirelessNetworkInterface* iface = interface; | 328 | OWirelessNetworkInterface* iface = interface; |
331 | 329 | ||
332 | if ( iface ) | 330 | if ( iface ) |
333 | { | 331 | { |
334 | bool statResult = iface->updateStatistics(); | 332 | if ( mustRepaint() ) |
335 | if ( !statResult ) | ||
336 | { | 333 | { |
337 | interface = 0; | 334 | qDebug( "WIFIAPPLET: A value has changed -> repainting." ); |
338 | mustRepaint(); | 335 | repaint(); |
339 | return ; | ||
340 | } | 336 | } |
341 | else | ||
342 | if ( mustRepaint() ) | ||
343 | { | ||
344 | //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); | ||
345 | repaint(); | ||
346 | } | ||
347 | 337 | ||
348 | if ( status->isVisible() ) | 338 | if ( status->isVisible() ) |
339 | { | ||
349 | updatePopupWindow(); | 340 | updatePopupWindow(); |
341 | } | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | checkInterface(); | ||
350 | } | 346 | } |
351 | else checkInterface(); | ||
352 | |||
353 | */ | ||
354 | } | 347 | } |
355 | 348 | ||
356 | void WirelessApplet::mousePressEvent( QMouseEvent * ) | 349 | void WirelessApplet::mousePressEvent( QMouseEvent * ) |
357 | { | 350 | { |
358 | if ( status->isVisible() ) | 351 | if ( status->isVisible() ) |
359 | status->hide(); | 352 | status->hide(); |
360 | else | 353 | else |
361 | status->show( true ); | 354 | status->show( true ); |
362 | } | 355 | } |
363 | 356 | ||
364 | bool WirelessApplet::mustRepaint() | 357 | bool WirelessApplet::mustRepaint() |
365 | { | 358 | { |
@@ -441,78 +434,78 @@ bool WirelessApplet::mustRepaint() | |||
441 | } | 434 | } |
442 | 435 | ||
443 | oldESSID = iface->SSID(); | 436 | oldESSID = iface->SSID(); |
444 | oldMODE = iface->mode(); | 437 | oldMODE = iface->mode(); |
445 | oldFREQ = iface->frequency(); | 438 | oldFREQ = iface->frequency(); |
446 | oldAP = iface->associatedAP().toString(); | 439 | oldAP = iface->associatedAP().toString(); |
447 | 440 | ||
448 | return false; | 441 | return false; |
449 | } | 442 | } |
450 | 443 | ||
451 | void WirelessApplet::updatePopupWindow() | 444 | void WirelessApplet::updatePopupWindow() |
452 | { | 445 | { |
453 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; | 446 | OWirelessNetworkInterface* iface = interface; |
454 | int qualityH = iface->qualityPercent(); | 447 | int qualityH = iface->signalStrength(); |
455 | 448 | ||
456 | if ( status->mgraph ) | 449 | if ( status->mgraph ) |
457 | status->mgraph->addValue( qualityH, false ); | 450 | status->mgraph->addValue( qualityH, false ); |
458 | 451 | ||
459 | QString freqString; | 452 | QString freqString; |
460 | QString cell = ( iface->mode == "Managed" ) ? "AP: " : "Cell: "; | 453 | QString cell = ( iface->mode() == "Managed" ) ? "AP: " : "Cell: "; |
461 | freqString.sprintf( "%.3f GHz", iface->freq ); | 454 | freqString.sprintf( "%.3f GHz", iface->frequency() ); |
462 | status->statusLabel->setText( "Station: " + iface->nick + "<br>" + | 455 | status->statusLabel->setText( "Station: " + iface->nickName() + "<br>" + |
463 | "ESSID: " + iface->essid + "<br>" + | 456 | "ESSID: " + iface->SSID() + "<br>" + |
464 | "MODE: " + iface->mode + "<br>" + | 457 | "MODE: " + iface->mode() + "<br>" + |
465 | "FREQ: " + freqString + "<br>" + | 458 | "FREQ: " + freqString + "<br>" + |
466 | cell + " " + iface->APAddr ); | 459 | cell + " " + iface->associatedAP().toString() ); |
467 | } | 460 | } |
468 | 461 | ||
469 | const char** WirelessApplet::getQualityPixmap() | 462 | const char** WirelessApplet::getQualityPixmap() |
470 | { | 463 | { |
471 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; | 464 | OWirelessNetworkInterface* iface = interface; |
472 | 465 | ||
473 | if ( !iface ) return ( const char** ) nowireless_xpm; | 466 | if ( !iface ) return ( const char** ) nowireless_xpm; |
474 | int qualityH = iface->qualityPercent(); | 467 | int qualityH = iface->signalStrength(); |
475 | if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; | 468 | if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; |
476 | 469 | ||
477 | if ( visualStyle == STYLE_ANTENNA ) | 470 | if ( visualStyle == STYLE_ANTENNA ) |
478 | { | 471 | { |
479 | if ( qualityH < 1 ) return ( const char** ) connect0_xpm; | 472 | if ( qualityH < 1 ) return ( const char** ) connect0_xpm; |
480 | if ( qualityH < 17 ) return ( const char** ) connect1_xpm; | 473 | if ( qualityH < 17 ) return ( const char** ) connect1_xpm; |
481 | if ( qualityH < 34 ) return ( const char** ) connect2_xpm; | 474 | if ( qualityH < 34 ) return ( const char** ) connect2_xpm; |
482 | if ( qualityH < 50 ) return ( const char** ) connect3_xpm; | 475 | if ( qualityH < 50 ) return ( const char** ) connect3_xpm; |
483 | if ( qualityH < 65 ) return ( const char** ) connect4_xpm; | 476 | if ( qualityH < 65 ) return ( const char** ) connect4_xpm; |
484 | return ( const char** ) connect5_xpm; | 477 | return ( const char** ) connect5_xpm; |
485 | } | 478 | } |
486 | 479 | ||
487 | return 0; // please draw your bars | 480 | return 0; // please draw your bars |
488 | } | 481 | } |
489 | 482 | ||
490 | void WirelessApplet::paintEvent( QPaintEvent* ) | 483 | void WirelessApplet::paintEvent( QPaintEvent* ) |
491 | { | 484 | { |
492 | MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; | 485 | OWirelessNetworkInterface* iface = interface; |
493 | 486 | ||
494 | QPainter p( this ); | 487 | QPainter p( this ); |
495 | QColor color; | 488 | QColor color; |
496 | 489 | ||
497 | const char** pixmap = getQualityPixmap(); | 490 | const char** pixmap = getQualityPixmap(); |
498 | 491 | ||
499 | if ( pixmap ) | 492 | if ( pixmap ) |
500 | p.drawPixmap( 0, 1, pixmap ); | 493 | p.drawPixmap( 0, 1, pixmap ); |
501 | else | 494 | else |
502 | { | 495 | { |
503 | 496 | ||
504 | int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; | 497 | int noiseH = 30; // iface->noisePercent() * ( height() - 3 ) / 100; |
505 | int signalH = iface->signalPercent() * ( height() - 3 ) / 100; | 498 | int signalH = 50; // iface->signalPercent() * ( height() - 3 ) / 100; |
506 | int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; | 499 | int qualityH = iface->signalStrength(); // iface->qualityPercent() * ( height() - 3 ) / 100; |
507 | 500 | ||
508 | double intensity; | 501 | double intensity; |
509 | int pixelHeight; | 502 | int pixelHeight; |
510 | int pixelWidth = 2; | 503 | int pixelWidth = 2; |
511 | int Hue; | 504 | int Hue; |
512 | int barSpace = 3; | 505 | int barSpace = 3; |
513 | int leftoffset = 0; | 506 | int leftoffset = 0; |
514 | int bottomoffset = 2; | 507 | int bottomoffset = 2; |
515 | 508 | ||
516 | // draw noise indicator | 509 | // draw noise indicator |
517 | pixelHeight = noiseH; | 510 | pixelHeight = noiseH; |
518 | Hue = 50; | 511 | Hue = 50; |