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.cpp59
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
@@ -9,13 +9,12 @@
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"
@@ -48,14 +47,14 @@
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
57WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 56WirelessControl::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();
@@ -322,38 +321,32 @@ void WirelessApplet::displayStyleChange( int style )
322 321
323WirelessApplet::~WirelessApplet() 322WirelessApplet::~WirelessApplet()
324{} 323{}
325 324
326void WirelessApplet::timerEvent( QTimerEvent* ) 325void 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
356void WirelessApplet::mousePressEvent( QMouseEvent * ) 349void WirelessApplet::mousePressEvent( QMouseEvent * )
357{ 350{
358 if ( status->isVisible() ) 351 if ( status->isVisible() )
359 status->hide(); 352 status->hide();
@@ -447,34 +440,34 @@ bool WirelessApplet::mustRepaint()
447 440
448 return false; 441 return false;
449} 442}
450 443
451void WirelessApplet::updatePopupWindow() 444void 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
469const char** WirelessApplet::getQualityPixmap() 462const 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;
@@ -486,27 +479,27 @@ const char** WirelessApplet::getQualityPixmap()
486 479
487 return 0; // please draw your bars 480 return 0; // please draw your bars
488} 481}
489 482
490void WirelessApplet::paintEvent( QPaintEvent* ) 483void 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;