summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-02-24 16:24:03 (UTC)
committer mickeyl <mickeyl>2004-02-24 16:24:03 (UTC)
commitf02547005d26a1f3816f5475116bbdf094a31ccb (patch) (unidiff)
tree86c1c9b21ae48aba81a24f6c412d881386708f35
parente3e4d0cca07dfa5487acb54596ac978f2343fc40 (diff)
downloadopie-f02547005d26a1f3816f5475116bbdf094a31ccb.zip
opie-f02547005d26a1f3816f5475116bbdf094a31ccb.tar.gz
opie-f02547005d26a1f3816f5475116bbdf094a31ccb.tar.bz2
fix a regression bug when an interface appears or disappears
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp74
1 files changed, 40 insertions, 34 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index 72ac380..cee789c 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -5,98 +5,98 @@
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 "mgraph.h" 15#include "mgraph.h"
16#include "advancedconfig.h" 16#include "advancedconfig.h"
17#include "connect0.xpm" 17#include "connect0.xpm"
18#include "connect1.xpm" 18#include "connect1.xpm"
19#include "connect2.xpm" 19#include "connect2.xpm"
20#include "connect3.xpm" 20#include "connect3.xpm"
21#include "connect4.xpm" 21#include "connect4.xpm"
22#include "connect5.xpm" 22#include "connect5.xpm"
23#include "nowireless.xpm" 23#include "nowireless.xpm"
24 24
25/* OPIE */ 25/* OPIE */
26#include <opie2/onetwork.h> 26#include <opie2/onetwork.h>
27#include <opie2/otaskbarapplet.h> 27#include <opie2/otaskbarapplet.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30 30
31/* QT */ 31/* QT */
32#include <qpoint.h> 32#include <qpoint.h>
33#include <qradiobutton.h> 33#include <qradiobutton.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qslider.h> 37#include <qslider.h>
38#include <qbuttongroup.h> 38#include <qbuttongroup.h>
39#include <qlayout.h> 39#include <qlayout.h>
40#include <qframe.h> 40#include <qframe.h>
41#include <qpixmap.h> 41#include <qpixmap.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46/* STD */ 46/* STD */
47#include <sys/types.h> 47#include <sys/types.h>
48#include <signal.h> 48#include <signal.h>
49 49
50#define STYLE_BARS 0 50#define STYLE_BARS 0
51#define STYLE_ANTENNA 1 51#define STYLE_ANTENNA 1
52 52
53#define MDEBUG 53//#define MDEBUG
54//#undef MDEBUG 54#undef MDEBUG
55 55
56WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 56WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name )
57 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) 57 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet )
58{ 58{
59 59
60 readConfig(); 60 readConfig();
61 writeConfigEntry( "UpdateFrequency", updateFrequency ); 61 writeConfigEntry( "UpdateFrequency", updateFrequency );
62 writeConfigEntry( "DisplayStyle", displayStyle ); 62 writeConfigEntry( "DisplayStyle", displayStyle );
63 63
64 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 64 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
65 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); 65 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" );
66 66
67 /* status label */ 67 /* status label */
68 68
69 statusLabel = new QLabel( this, "statuslabel" ); 69 statusLabel = new QLabel( this, "statuslabel" );
70 QString text( "Wireless Status:<br>" 70 QString text( "Wireless Status:<br>"
71 "*** Unknown ***<br>" 71 "*** Unknown ***<br>"
72 "Card not inserted ?<br>" 72 "Card not inserted ?<br>"
73 "Or Sharp ROM ?<br>" 73 "Or Sharp ROM ?<br>"
74 "CELL: 00:00:00:00:00:00" ); 74 "CELL: 00:00:00:00:00:00" );
75 /* QString text( "Station: Unknown<br>" 75 /* QString text( "Station: Unknown<br>"
76 "ESSID: Unknown<br>" 76 "ESSID: Unknown<br>"
77 "MODE: Unknown<br>" 77 "MODE: Unknown<br>"
78 "FREQ: Unknown<br>" 78 "FREQ: Unknown<br>"
79 "CELL: AA:BB:CC:DD:EE:FF" ); */ 79 "CELL: AA:BB:CC:DD:EE:FF" ); */
80 statusLabel->setText( text ); 80 statusLabel->setText( text );
81 statusLabel->setFixedSize( statusLabel->sizeHint() ); 81 statusLabel->setFixedSize( statusLabel->sizeHint() );
82 grid->addWidget( statusLabel, 0, 0 ); 82 grid->addWidget( statusLabel, 0, 0 );
83 83
84 /* visualization group box */ 84 /* visualization group box */
85 85
86 QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); 86 QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this );
87 QRadioButton* r1 = new QRadioButton( "Color Bars", group ); 87 QRadioButton* r1 = new QRadioButton( "Color Bars", group );
88 QRadioButton* r2 = new QRadioButton( "Antenna", group ); 88 QRadioButton* r2 = new QRadioButton( "Antenna", group );
89 r1->setFocusPolicy( QWidget::NoFocus ); 89 r1->setFocusPolicy( QWidget::NoFocus );
90 r2->setFocusPolicy( QWidget::NoFocus ); 90 r2->setFocusPolicy( QWidget::NoFocus );
91 group->setFocusPolicy( QWidget::NoFocus ); 91 group->setFocusPolicy( QWidget::NoFocus );
92 group->setButton( displayStyle ); 92 group->setButton( displayStyle );
93 grid->addWidget( group, 0, 1 ); 93 grid->addWidget( group, 0, 1 );
94 94
95 /* quality graph */ 95 /* quality graph */
96 96
97 mgraph = new MGraph( this ); 97 mgraph = new MGraph( this );
98 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 98 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
99 mgraph->setMin( 0 ); 99 mgraph->setMin( 0 );
100 mgraph->setMax( 92 ); 100 mgraph->setMax( 92 );
101 grid->addWidget( mgraph, 1, 0 ); 101 grid->addWidget( mgraph, 1, 0 );
102 mgraph->setFocusPolicy( QWidget::NoFocus ); 102 mgraph->setFocusPolicy( QWidget::NoFocus );
@@ -174,96 +174,97 @@ void WirelessControl::show ( bool )
174 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); 174 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) );
175 175
176 int w = sizeHint().width(); 176 int w = sizeHint().width();
177 int x = curPos.x() - ( w / 2 ); 177 int x = curPos.x() - ( w / 2 );
178 178
179 if ( ( x + w ) > QPEApplication::desktop() ->width() ) 179 if ( ( x + w ) > QPEApplication::desktop() ->width() )
180 x = QPEApplication::desktop ( ) -> width ( ) - w; 180 x = QPEApplication::desktop ( ) -> width ( ) - w;
181 181
182 move( x, curPos.y () - sizeHint().height () ); 182 move( x, curPos.y () - sizeHint().height () );
183 QFrame::show(); 183 QFrame::show();
184} 184}
185 185
186void WirelessControl::readConfig() 186void WirelessControl::readConfig()
187{ 187{
188 Config cfg( "qpe" ); 188 Config cfg( "qpe" );
189 cfg.setGroup( "Wireless" ); 189 cfg.setGroup( "Wireless" );
190 190
191 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); 191 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 );
192 displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); 192 displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA );
193 rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); 193 rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false );
194 rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); 194 rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false );
195 rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); 195 rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false );
196 rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); 196 rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false );
197} 197}
198 198
199void WirelessControl::writeConfigEntry( const char *entry, int val ) 199void WirelessControl::writeConfigEntry( const char *entry, int val )
200{ 200{
201 Config cfg( "qpe" ); 201 Config cfg( "qpe" );
202 cfg.setGroup( "Wireless" ); 202 cfg.setGroup( "Wireless" );
203 cfg.writeEntry( entry, val ); 203 cfg.writeEntry( entry, val );
204} 204}
205 205
206//=========================================================================== 206//===========================================================================
207 207
208WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) 208WirelessApplet::WirelessApplet( QWidget *parent, const char *name )
209 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), 209 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ),
210 timer( 0 ), interface( 0 ), oldiface( 0 ), 210 timer( 0 ), interface( 0 ), oldiface( 0 ),
211 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) 211 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false )
212{ 212{
213 setFixedHeight( 18 ); 213 setFixedHeight( 18 );
214 setFixedWidth( 14 ); 214 setFixedWidth( 14 );
215 status = new WirelessControl( this, this, "wireless status" ); 215 status = new WirelessControl( this, this, "wireless status" );
216} 216}
217 217
218void WirelessApplet::checkInterface() 218void WirelessApplet::checkInterface()
219{ 219{
220 interface = 0L; 220 interface = 0L;
221 ONetwork* net = ONetwork::instance(); 221 ONetwork* net = ONetwork::instance();
222 net->synchronize();
222 ONetwork::InterfaceIterator it = net->iterator(); 223 ONetwork::InterfaceIterator it = net->iterator();
223 224
224 while ( it.current() && !it.current()->isWireless() ) ++it; 225 while ( it.current() && !it.current()->isWireless() ) ++it;
225 226
226 if ( it.current() && it.current()->isWireless() ) 227 if ( it.current() && it.current()->isWireless() )
227 interface = static_cast<OWirelessNetworkInterface*>( it.current() ); 228 interface = static_cast<OWirelessNetworkInterface*>( it.current() );
228 229
229 if ( interface ) 230 if ( interface )
230 { 231 {
231#ifdef MDEBUG 232#ifdef MDEBUG
232 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); 233 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() );
233#endif 234#endif
234 235
235 } 236 }
236 else 237 else
237 { 238 {
238#ifdef MDEBUG 239#ifdef MDEBUG
239 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); 240 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" );
240#endif 241#endif
241 hide(); 242 hide();
242 } 243 }
243} 244}
244 245
245void WirelessApplet::renewDHCP() 246void WirelessApplet::renewDHCP()
246{ 247{
247#ifdef MDEBUG 248#ifdef MDEBUG
248 qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); 249 qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." );
249#endif 250#endif
250 251
251 QString pidfile; 252 QString pidfile;
252 if ( !interface ) 253 if ( !interface )
253 return ; 254 return ;
254 QString ifacename( interface->name() ); 255 QString ifacename( interface->name() );
255 256
256 // At first we are trying dhcpcd 257 // At first we are trying dhcpcd
257 258
258 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); 259 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename );
259#ifdef MDEBUG 260#ifdef MDEBUG
260 qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile ); 261 qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile );
261#endif 262#endif
262 int pid; 263 int pid;
263 QFile pfile( pidfile ); 264 QFile pfile( pidfile );
264 bool hasFile = pfile.open( IO_ReadOnly ); 265 bool hasFile = pfile.open( IO_ReadOnly );
265 QTextStream s( &pfile ); 266 QTextStream s( &pfile );
266 if ( hasFile ) 267 if ( hasFile )
267 { 268 {
268 s >> pid; 269 s >> pid;
269#ifdef MDEBUG 270#ifdef MDEBUG
@@ -279,269 +280,274 @@ void WirelessApplet::renewDHCP()
279#endif 280#endif
280 pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); 281 pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename );
281#ifdef MDEBUG 282#ifdef MDEBUG
282 qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", ( const char* ) pidfile ); 283 qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", ( const char* ) pidfile );
283#endif 284#endif
284 QFile pfile2( pidfile ); 285 QFile pfile2( pidfile );
285 hasFile = pfile2.open( IO_ReadOnly ); 286 hasFile = pfile2.open( IO_ReadOnly );
286 QTextStream s2( &pfile2 ); 287 QTextStream s2( &pfile2 );
287 if ( hasFile ) 288 if ( hasFile )
288 { 289 {
289 s2 >> pid; 290 s2 >> pid;
290#ifdef MDEBUG 291#ifdef MDEBUG
291 qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); 292 qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid );
292#endif 293#endif
293 kill( pid, SIGUSR1 ); 294 kill( pid, SIGUSR1 );
294 return ; 295 return ;
295 } 296 }
296} 297}
297 298
298void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) 299void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE )
299{ 300{
300 rocESSID = ESSID; 301 rocESSID = ESSID;
301 rocFREQ = FREQ; 302 rocFREQ = FREQ;
302 rocAP = AP; 303 rocAP = AP;
303 rocMODE = MODE; 304 rocMODE = MODE;
304} 305}
305 306
306void WirelessApplet::updateDelayChange( int delay ) 307void WirelessApplet::updateDelayChange( int delay )
307{ 308{
308 if ( timer ) 309 if ( timer )
309 killTimer( timer ); 310 killTimer( timer );
310 delay *= 1000; 311 delay *= 1000;
311 if ( delay == 0 ) 312 if ( delay == 0 )
312 delay = 50; 313 delay = 50;
313 timer = startTimer( delay ); 314 timer = startTimer( delay );
314} 315}
315 316
316void WirelessApplet::displayStyleChange( int style ) 317void WirelessApplet::displayStyleChange( int style )
317{ 318{
318 visualStyle = style; 319 visualStyle = style;
319 repaint(); 320 repaint();
320} 321}
321 322
322WirelessApplet::~WirelessApplet() 323WirelessApplet::~WirelessApplet()
323{} 324{}
324 325
325void WirelessApplet::timerEvent( QTimerEvent* ) 326void WirelessApplet::timerEvent( QTimerEvent* )
326{ 327{
328#ifdef MDEBUG
327 qDebug( "WirelessApplet::timerEvent" ); 329 qDebug( "WirelessApplet::timerEvent" );
328 OWirelessNetworkInterface* iface = interface; 330#endif
329 331 if ( interface )
330 if ( iface ) 332 {
333 if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) )
331 { 334 {
335#ifdef MDEBUG
336 qDebug( "WIFIAPPLET: Interface no longer present." );
337#endif
338 interface = 0L;
339 mustRepaint();
340 return;
341 }
342
332 if ( mustRepaint() ) 343 if ( mustRepaint() )
333 { 344 {
345#ifdef MDEBUG
334 qDebug( "WIFIAPPLET: A value has changed -> repainting." ); 346 qDebug( "WIFIAPPLET: A value has changed -> repainting." );
347#endif
335 repaint(); 348 repaint();
336 } 349 }
337 350
338 if ( status->isVisible() ) 351 if ( status->isVisible() )
339 { 352 {
340 updatePopupWindow(); 353 updatePopupWindow();
341 } 354 }
342 } 355 }
343 else 356 else
344 { 357 {
345 checkInterface(); 358 checkInterface();
346 } 359 }
347} 360}
348 361
349void WirelessApplet::mousePressEvent( QMouseEvent * ) 362void WirelessApplet::mousePressEvent( QMouseEvent * )
350{ 363{
351 if ( status->isVisible() ) 364 if ( status->isVisible() )
352 status->hide(); 365 status->hide();
353 else 366 else
354 status->show( true ); 367 status->show( true );
355} 368}
356 369
357bool WirelessApplet::mustRepaint() 370bool WirelessApplet::mustRepaint()
358{ 371{
359 OWirelessNetworkInterface* iface = interface;
360
361 // check if there are enough changes to justify a (flickering) repaint 372 // check if there are enough changes to justify a (flickering) repaint
362 373
363 // has the interface changed? 374 // has the interface changed?
364 375
365 if ( iface != oldiface ) 376 if ( interface != oldiface )
366 { 377 {
367 oldiface = iface; 378 oldiface = interface;
368 if ( iface ) 379 if ( interface )
369 { 380 {
370#ifdef MDEBUG 381#ifdef MDEBUG
371 qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); 382 qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" );
372#endif 383#endif
373 show(); 384 show();
374 } 385 }
375 else 386 else
376 { 387 {
377#ifdef MDEBUG 388#ifdef MDEBUG
378 qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); 389 qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" );
379#endif 390#endif
380 hide(); 391 hide();
381 return true; 392 return true;
382 } 393 }
383 } 394 }
384 395
385 const char** pixmap = getQualityPixmap(); 396 const char** pixmap = getQualityPixmap();
386 397
387 if ( pixmap && ( pixmap != oldpixmap ) ) 398 if ( pixmap && ( pixmap != oldpixmap ) )
388 { 399 {
389 oldpixmap = pixmap; 400 oldpixmap = pixmap;
390 return true; 401 return true;
391 } 402 }
392 403
393 int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; 404 int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100;
394 int signalH = iface->signalStrength() * ( height() - 3 ) / 100; 405 int signalH = interface->signalStrength() * ( height() - 3 ) / 100;
395 int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; 406 int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100;
396 407
397 if ( ( noiseH != oldnoiseH ) 408 if ( ( noiseH != oldnoiseH )
398 || ( signalH != oldsignalH ) 409 || ( signalH != oldsignalH )
399 || ( qualityH != oldqualityH ) ) 410 || ( qualityH != oldqualityH ) )
400 { 411 {
401 oldnoiseH = noiseH; 412 oldnoiseH = noiseH;
402 oldsignalH = signalH; 413 oldsignalH = signalH;
403 oldqualityH = qualityH; 414 oldqualityH = qualityH;
404 return true; 415 return true;
405 } 416 }
406 417
407 if ( rocESSID && ( oldESSID != iface->SSID() ) ) 418 if ( rocESSID && ( oldESSID != interface->SSID() ) )
408 { 419 {
409#ifdef MDEBUG 420#ifdef MDEBUG
410 qDebug( "WIFIAPPLET: ESSID has changed." ); 421 qDebug( "WIFIAPPLET: ESSID has changed." );
411#endif 422#endif
412 renewDHCP(); 423 renewDHCP();
413 } 424 }
414 else if ( rocFREQ && ( oldFREQ != iface->frequency() ) ) 425 else if ( rocFREQ && ( oldFREQ != interface->frequency() ) )
415 { 426 {
416#ifdef MDEBUG 427#ifdef MDEBUG
417 qDebug( "WIFIAPPLET: FREQ has changed." ); 428 qDebug( "WIFIAPPLET: FREQ has changed." );
418#endif 429#endif
419 renewDHCP(); 430 renewDHCP();
420 } 431 }
421 else if ( rocAP && ( oldAP != iface->associatedAP().toString() ) ) 432 else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) )
422 { 433 {
423#ifdef MDEBUG 434#ifdef MDEBUG
424 qDebug( "WIFIAPPLET: AP has changed." ); 435 qDebug( "WIFIAPPLET: AP has changed." );
425#endif 436#endif
426 renewDHCP(); 437 renewDHCP();
427 } 438 }
428 else if ( rocMODE && ( oldMODE != iface->mode() ) ) 439 else if ( rocMODE && ( oldMODE != interface->mode() ) )
429 { 440 {
430#ifdef MDEBUG 441#ifdef MDEBUG
431 qDebug( "WIFIAPPLET: MODE has changed." ); 442 qDebug( "WIFIAPPLET: MODE has changed." );
432#endif 443#endif
433 renewDHCP(); 444 renewDHCP();
434 } 445 }
435 446
436 oldESSID = iface->SSID(); 447 oldESSID = interface->SSID();
437 oldMODE = iface->mode(); 448 oldMODE = interface->mode();
438 oldFREQ = iface->frequency(); 449 oldFREQ = interface->frequency();
439 oldAP = iface->associatedAP().toString(); 450 oldAP = interface->associatedAP().toString();
440 451
441 return false; 452 return false;
442} 453}
443 454
444void WirelessApplet::updatePopupWindow() 455void WirelessApplet::updatePopupWindow()
445{ 456{
446 OWirelessNetworkInterface* iface = interface; 457 int qualityH = interface->signalStrength();
447 int qualityH = iface->signalStrength();
448 458
449 if ( status->mgraph ) 459 if ( status->mgraph )
450 status->mgraph->addValue( qualityH, false ); 460 status->mgraph->addValue( qualityH, false );
451 461
452 QString freqString; 462 QString freqString;
453 QString cell = ( iface->mode() == "Managed" ) ? "AP: " : "Cell: "; 463 QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: ";
454 freqString.sprintf( "%.3f GHz", iface->frequency() ); 464 freqString.sprintf( "%.3f GHz", interface->frequency() );
455 status->statusLabel->setText( "Station: " + iface->nickName() + "<br>" + 465 status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" +
456 "ESSID: " + iface->SSID() + "<br>" + 466 "ESSID: " + interface->SSID() + "<br>" +
457 "MODE: " + iface->mode() + "<br>" + 467 "MODE: " + interface->mode() + "<br>" +
458 "FREQ: " + freqString + "<br>" + 468 "FREQ: " + freqString + "<br>" +
459 cell + " " + iface->associatedAP().toString() ); 469 cell + " " + interface->associatedAP().toString() );
460} 470}
461 471
462const char** WirelessApplet::getQualityPixmap() 472const char** WirelessApplet::getQualityPixmap()
463{ 473{
464 OWirelessNetworkInterface* iface = interface; 474 if ( !interface ) return ( const char** ) nowireless_xpm;
465 475 int qualityH = interface->signalStrength();
466 if ( !iface ) return ( const char** ) nowireless_xpm;
467 int qualityH = iface->signalStrength();
468 if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; 476 if ( qualityH < 0 ) return ( const char** ) nowireless_xpm;
469 477
470 if ( visualStyle == STYLE_ANTENNA ) 478 if ( visualStyle == STYLE_ANTENNA )
471 { 479 {
472 if ( qualityH < 1 ) return ( const char** ) connect0_xpm; 480 if ( qualityH < 1 ) return ( const char** ) connect0_xpm;
473 if ( qualityH < 17 ) return ( const char** ) connect1_xpm; 481 if ( qualityH < 17 ) return ( const char** ) connect1_xpm;
474 if ( qualityH < 34 ) return ( const char** ) connect2_xpm; 482 if ( qualityH < 34 ) return ( const char** ) connect2_xpm;
475 if ( qualityH < 50 ) return ( const char** ) connect3_xpm; 483 if ( qualityH < 50 ) return ( const char** ) connect3_xpm;
476 if ( qualityH < 65 ) return ( const char** ) connect4_xpm; 484 if ( qualityH < 65 ) return ( const char** ) connect4_xpm;
477 return ( const char** ) connect5_xpm; 485 return ( const char** ) connect5_xpm;
478 } 486 }
479 487
480 return 0; // please draw your bars 488 return 0; // please draw your bars
481} 489}
482 490
483void WirelessApplet::paintEvent( QPaintEvent* ) 491void WirelessApplet::paintEvent( QPaintEvent* )
484{ 492{
485 OWirelessNetworkInterface* iface = interface;
486
487 QPainter p( this ); 493 QPainter p( this );
488 QColor color; 494 QColor color;
489 495
490 const char** pixmap = getQualityPixmap(); 496 const char** pixmap = getQualityPixmap();
491 497
492 if ( pixmap ) 498 if ( pixmap )
493 p.drawPixmap( 0, 1, pixmap ); 499 p.drawPixmap( 0, 1, pixmap );
494 else 500 else
495 { 501 {
496 502
497 int noiseH = 30; // iface->noisePercent() * ( height() - 3 ) / 100; 503 int noiseH = 30; // iface->noisePercent() * ( height() - 3 ) / 100;
498 int signalH = 50; // iface->signalPercent() * ( height() - 3 ) / 100; 504 int signalH = 50; // iface->signalPercent() * ( height() - 3 ) / 100;
499 int qualityH = iface->signalStrength(); // iface->qualityPercent() * ( height() - 3 ) / 100; 505 int qualityH = interface->signalStrength(); // iface->qualityPercent() * ( height() - 3 ) / 100;
500 506
501 double intensity; 507 double intensity;
502 int pixelHeight; 508 int pixelHeight;
503 int pixelWidth = 2; 509 int pixelWidth = 2;
504 int Hue; 510 int Hue;
505 int barSpace = 3; 511 int barSpace = 3;
506 int leftoffset = 0; 512 int leftoffset = 0;
507 int bottomoffset = 2; 513 int bottomoffset = 2;
508 514
509 // draw noise indicator 515 // draw noise indicator
510 pixelHeight = noiseH; 516 pixelHeight = noiseH;
511 Hue = 50; 517 Hue = 50;
512 for ( int i = 0; i < pixelHeight; ++i ) 518 for ( int i = 0; i < pixelHeight; ++i )
513 { 519 {
514 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; 520 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
515 color.setHsv( Hue, 255, intensity ); 521 color.setHsv( Hue, 255, intensity );
516 p.setPen ( color ); 522 p.setPen ( color );
517 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); 523 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
518 } 524 }
519 525
520 // draw signal indicator 526 // draw signal indicator
521 pixelHeight = signalH; 527 pixelHeight = signalH;
522 Hue = 100; 528 Hue = 100;
523 leftoffset += pixelWidth + barSpace; 529 leftoffset += pixelWidth + barSpace;
524 for ( int i = 0; i < pixelHeight; ++i ) 530 for ( int i = 0; i < pixelHeight; ++i )
525 { 531 {
526 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; 532 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
527 color.setHsv( Hue, 255, intensity ); 533 color.setHsv( Hue, 255, intensity );
528 p.setPen ( color ); 534 p.setPen ( color );
529 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); 535 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
530 } 536 }
531 537
532 // draw quality indicator 538 // draw quality indicator
533 pixelHeight = qualityH; 539 pixelHeight = qualityH;
534 Hue = 250; 540 Hue = 250;
535 leftoffset += pixelWidth + barSpace; 541 leftoffset += pixelWidth + barSpace;
536 for ( int i = 0; i < pixelHeight; ++i ) 542 for ( int i = 0; i < pixelHeight; ++i )
537 { 543 {
538 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205; 544 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
539 color.setHsv( Hue, 255, intensity ); 545 color.setHsv( Hue, 255, intensity );
540 p.setPen ( color ); 546 p.setPen ( color );
541 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i ); 547 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
542 } 548 }
543 } 549 }
544} 550}
545 551
546 552
547int WirelessApplet::position() 553int WirelessApplet::position()