author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (unidiff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/applets/wirelessapplet/wireless.cpp | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (ignore 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 | |||
@@ -1,71 +1,73 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> |
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 "mgraph.h" | 15 | #include "mgraph.h" |
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> |
24 | using namespace Opie::Core; | ||
25 | using namespace Opie::Ui; | ||
26 | using namespace Opie::Net; | ||
23 | 27 | ||
24 | /* QT */ | 28 | /* QT */ |
25 | #include <qradiobutton.h> | 29 | #include <qradiobutton.h> |
26 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
27 | #include <qpainter.h> | 31 | #include <qpainter.h> |
28 | #include <qlabel.h> | 32 | #include <qlabel.h> |
29 | #include <qslider.h> | 33 | #include <qslider.h> |
30 | #include <qbuttongroup.h> | 34 | #include <qbuttongroup.h> |
31 | #include <qlayout.h> | 35 | #include <qlayout.h> |
32 | #include <qfile.h> | 36 | #include <qfile.h> |
33 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
34 | 38 | ||
35 | /* STD */ | 39 | /* STD */ |
36 | #include <math.h> | 40 | #include <math.h> |
37 | #include <sys/types.h> | 41 | #include <sys/types.h> |
38 | #include <signal.h> | 42 | #include <signal.h> |
39 | #if defined (__GNUC__) && (__GNUC__ < 3) | 43 | #if defined (__GNUC__) && (__GNUC__ < 3) |
40 | #define round qRound | 44 | #define round qRound |
41 | #endif | 45 | #endif |
42 | 46 | ||
43 | //#define MDEBUG | 47 | //#define MDEBUG |
44 | #undef MDEBUG | 48 | #undef MDEBUG |
45 | 49 | ||
46 | using namespace Opie::Ui; | ||
47 | using namespace Opie::Net; | ||
48 | WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) | 50 | WirelessControl::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 | { |
51 | 53 | ||
52 | readConfig(); | 54 | readConfig(); |
53 | writeConfigEntry( "UpdateFrequency", updateFrequency ); | 55 | writeConfigEntry( "UpdateFrequency", updateFrequency ); |
54 | 56 | ||
55 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 57 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
56 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); | 58 | QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); |
57 | 59 | ||
58 | /* status label */ | 60 | /* status label */ |
59 | 61 | ||
60 | statusLabel = new QLabel( this, "statuslabel" ); | 62 | statusLabel = new QLabel( this, "statuslabel" ); |
61 | QString text( "Wireless Status:<br>" | 63 | QString text( "Wireless Status:<br>" |
62 | "*** Unknown ***<br>" | 64 | "*** Unknown ***<br>" |
63 | "Card not inserted ?<br>" | 65 | "Card not inserted ?<br>" |
64 | "Or Sharp ROM ?<br>" | 66 | "Or Sharp ROM ?<br>" |
65 | "CELL: 00:00:00:00:00:00" ); | 67 | "CELL: 00:00:00:00:00:00" ); |
66 | /* QString text( "Station: Unknown<br>" | 68 | /* QString text( "Station: Unknown<br>" |
67 | "ESSID: Unknown<br>" | 69 | "ESSID: Unknown<br>" |
68 | "MODE: Unknown<br>" | 70 | "MODE: Unknown<br>" |
69 | "FREQ: Unknown<br>" | 71 | "FREQ: Unknown<br>" |
70 | "CELL: AA:BB:CC:DD:EE:FF" ); */ | 72 | "CELL: AA:BB:CC:DD:EE:FF" ); */ |
71 | statusLabel->setText( text ); | 73 | statusLabel->setText( text ); |
@@ -186,322 +188,322 @@ WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | |||
186 | : QWidget( parent, name ), | 188 | : QWidget( parent, name ), |
187 | timer( 0 ), interface( 0 ), oldiface( 0 ), | 189 | timer( 0 ), interface( 0 ), oldiface( 0 ), |
188 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) | 190 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) |
189 | { | 191 | { |
190 | setFixedHeight( 18 ); | 192 | setFixedHeight( 18 ); |
191 | setFixedWidth( 14 ); | 193 | setFixedWidth( 14 ); |
192 | status = new WirelessControl( this, this, "wireless status" ); | 194 | status = new WirelessControl( this, this, "wireless status" ); |
193 | } | 195 | } |
194 | 196 | ||
195 | void WirelessApplet::checkInterface() | 197 | void WirelessApplet::checkInterface() |
196 | { | 198 | { |
197 | interface = 0L; | 199 | interface = 0L; |
198 | ONetwork* net = ONetwork::instance(); | 200 | ONetwork* net = ONetwork::instance(); |
199 | net->synchronize(); | 201 | net->synchronize(); |
200 | ONetwork::InterfaceIterator it = net->iterator(); | 202 | ONetwork::InterfaceIterator it = net->iterator(); |
201 | 203 | ||
202 | while ( it.current() && !it.current()->isWireless() ) ++it; | 204 | while ( it.current() && !it.current()->isWireless() ) ++it; |
203 | 205 | ||
204 | if ( it.current() && it.current()->isWireless() ) | 206 | if ( it.current() && it.current()->isWireless() ) |
205 | interface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 207 | interface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
206 | 208 | ||
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 | } |
221 | } | 223 | } |
222 | 224 | ||
223 | void WirelessApplet::renewDHCP() | 225 | void 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; |
230 | if ( !interface ) | 232 | if ( !interface ) |
231 | return ; | 233 | return ; |
232 | QString ifacename( interface->name() ); | 234 | QString ifacename( interface->name() ); |
233 | 235 | ||
234 | // At first we are trying dhcpcd | 236 | // At first we are trying dhcpcd |
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 ); |
242 | bool hasFile = pfile.open( IO_ReadOnly ); | 244 | bool hasFile = pfile.open( IO_ReadOnly ); |
243 | QTextStream s( &pfile ); | 245 | QTextStream s( &pfile ); |
244 | if ( hasFile ) | 246 | if ( hasFile ) |
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 ; |
252 | } | 254 | } |
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 ); |
264 | QTextStream s2( &pfile2 ); | 266 | QTextStream s2( &pfile2 ); |
265 | if ( hasFile ) | 267 | if ( hasFile ) |
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 ; |
273 | } | 275 | } |
274 | } | 276 | } |
275 | 277 | ||
276 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) | 278 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) |
277 | { | 279 | { |
278 | rocESSID = ESSID; | 280 | rocESSID = ESSID; |
279 | rocFREQ = FREQ; | 281 | rocFREQ = FREQ; |
280 | rocAP = AP; | 282 | rocAP = AP; |
281 | rocMODE = MODE; | 283 | rocMODE = MODE; |
282 | } | 284 | } |
283 | 285 | ||
284 | void WirelessApplet::updateDelayChange( int delay ) | 286 | void WirelessApplet::updateDelayChange( int delay ) |
285 | { | 287 | { |
286 | if ( timer ) | 288 | if ( timer ) |
287 | killTimer( timer ); | 289 | killTimer( timer ); |
288 | delay *= 1000; | 290 | delay *= 1000; |
289 | if ( delay == 0 ) | 291 | if ( delay == 0 ) |
290 | delay = 50; | 292 | delay = 50; |
291 | timer = startTimer( delay ); | 293 | timer = startTimer( delay ); |
292 | } | 294 | } |
293 | 295 | ||
294 | void WirelessApplet::displayStyleChange( int style ) | 296 | void WirelessApplet::displayStyleChange( int style ) |
295 | { | 297 | { |
296 | visualStyle = style; | 298 | visualStyle = style; |
297 | repaint(); | 299 | repaint(); |
298 | } | 300 | } |
299 | 301 | ||
300 | WirelessApplet::~WirelessApplet() | 302 | WirelessApplet::~WirelessApplet() |
301 | {} | 303 | {} |
302 | 304 | ||
303 | void WirelessApplet::timerEvent( QTimerEvent* ) | 305 | void 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(); |
317 | return; | 319 | return; |
318 | } | 320 | } |
319 | 321 | ||
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 | } |
327 | 329 | ||
328 | if ( status->isVisible() ) | 330 | if ( status->isVisible() ) |
329 | { | 331 | { |
330 | updatePopupWindow(); | 332 | updatePopupWindow(); |
331 | } | 333 | } |
332 | } | 334 | } |
333 | else | 335 | else |
334 | { | 336 | { |
335 | checkInterface(); | 337 | checkInterface(); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | 340 | ||
339 | void WirelessApplet::mousePressEvent( QMouseEvent * ) | 341 | void WirelessApplet::mousePressEvent( QMouseEvent * ) |
340 | { | 342 | { |
341 | if ( status->isVisible() ) | 343 | if ( status->isVisible() ) |
342 | status->hide(); | 344 | status->hide(); |
343 | else | 345 | else |
344 | status->show( true ); | 346 | status->show( true ); |
345 | } | 347 | } |
346 | 348 | ||
347 | bool WirelessApplet::mustRepaint() | 349 | bool WirelessApplet::mustRepaint() |
348 | { | 350 | { |
349 | // check if there are enough changes to justify a (flickering) repaint | 351 | // check if there are enough changes to justify a (flickering) repaint |
350 | 352 | ||
351 | // has the interface changed? | 353 | // has the interface changed? |
352 | 354 | ||
353 | if ( interface != oldiface ) | 355 | if ( interface != oldiface ) |
354 | { | 356 | { |
355 | oldiface = interface; | 357 | oldiface = interface; |
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; |
370 | } | 372 | } |
371 | } | 373 | } |
372 | 374 | ||
373 | int rings = numberOfRings(); | 375 | int rings = numberOfRings(); |
374 | 376 | ||
375 | if ( rings != oldrings ) | 377 | if ( rings != oldrings ) |
376 | { | 378 | { |
377 | oldrings = rings; | 379 | oldrings = rings; |
378 | return true; | 380 | return true; |
379 | } | 381 | } |
380 | 382 | ||
381 | int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; | 383 | int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; |
382 | int signalH = interface->signalStrength() * ( height() - 3 ) / 100; | 384 | int signalH = interface->signalStrength() * ( height() - 3 ) / 100; |
383 | int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; | 385 | int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; |
384 | 386 | ||
385 | if ( ( noiseH != oldnoiseH ) | 387 | if ( ( noiseH != oldnoiseH ) |
386 | || ( signalH != oldsignalH ) | 388 | || ( signalH != oldsignalH ) |
387 | || ( qualityH != oldqualityH ) ) | 389 | || ( qualityH != oldqualityH ) ) |
388 | { | 390 | { |
389 | oldnoiseH = noiseH; | 391 | oldnoiseH = noiseH; |
390 | oldsignalH = signalH; | 392 | oldsignalH = signalH; |
391 | oldqualityH = qualityH; | 393 | oldqualityH = qualityH; |
392 | return true; | 394 | return true; |
393 | } | 395 | } |
394 | 396 | ||
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 | } |
423 | 425 | ||
424 | oldESSID = interface->SSID(); | 426 | oldESSID = interface->SSID(); |
425 | oldMODE = interface->mode(); | 427 | oldMODE = interface->mode(); |
426 | oldFREQ = interface->frequency(); | 428 | oldFREQ = interface->frequency(); |
427 | oldAP = interface->associatedAP().toString(); | 429 | oldAP = interface->associatedAP().toString(); |
428 | 430 | ||
429 | return false; | 431 | return false; |
430 | } | 432 | } |
431 | 433 | ||
432 | void WirelessApplet::updatePopupWindow() | 434 | void WirelessApplet::updatePopupWindow() |
433 | { | 435 | { |
434 | int qualityH = interface->signalStrength(); | 436 | int qualityH = interface->signalStrength(); |
435 | 437 | ||
436 | if ( status->mgraph ) | 438 | if ( status->mgraph ) |
437 | status->mgraph->addValue( qualityH, false ); | 439 | status->mgraph->addValue( qualityH, false ); |
438 | 440 | ||
439 | QString freqString; | 441 | QString freqString; |
440 | QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: "; | 442 | QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: "; |
441 | freqString.sprintf( "%.3f GHz", interface->frequency() ); | 443 | freqString.sprintf( "%.3f GHz", interface->frequency() ); |
442 | status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" + | 444 | status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" + |
443 | "ESSID: " + interface->SSID() + "<br>" + | 445 | "ESSID: " + interface->SSID() + "<br>" + |
444 | "MODE: " + interface->mode() + "<br>" + | 446 | "MODE: " + interface->mode() + "<br>" + |
445 | "FREQ: " + freqString + "<br>" + | 447 | "FREQ: " + freqString + "<br>" + |
446 | cell + " " + interface->associatedAP().toString() ); | 448 | cell + " " + interface->associatedAP().toString() ); |
447 | } | 449 | } |
448 | 450 | ||
449 | int WirelessApplet::numberOfRings() | 451 | 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; |
457 | if ( qualityH < 60 ) return 2; | 459 | if ( qualityH < 60 ) return 2; |
458 | if ( qualityH < 65 ) return 3; | 460 | if ( qualityH < 65 ) return 3; |
459 | return 4; | 461 | return 4; |
460 | } | 462 | } |
461 | 463 | ||
462 | void WirelessApplet::paintEvent( QPaintEvent* ) | 464 | void WirelessApplet::paintEvent( QPaintEvent* ) |
463 | { | 465 | { |
464 | QPainter p( this ); | 466 | QPainter p( this ); |
465 | int h = height(); | 467 | int h = height(); |
466 | int w = width(); | 468 | int w = width(); |
467 | int m = 2; | 469 | int m = 2; |
468 | 470 | ||
469 | p.drawLine( m, h-m-1, round( w/2.0 ), round( 0+h/3.0 ) ); | 471 | p.drawLine( m, h-m-1, round( w/2.0 ), round( 0+h/3.0 ) ); |
470 | p.drawLine( round( w/2.0 ), round( 0+h/3.0 ), w-m, h-m-1 ); | 472 | p.drawLine( round( w/2.0 ), round( 0+h/3.0 ), w-m, h-m-1 ); |
471 | p.setPen( QColor( 150, 150, 150 ) ); | 473 | p.setPen( QColor( 150, 150, 150 ) ); |
472 | p.drawLine( w-m, h-m-1, m, h-m-1 ); | 474 | p.drawLine( w-m, h-m-1, m, h-m-1 ); |
473 | 475 | ||
474 | int rings = numberOfRings(); | 476 | int rings = numberOfRings(); |
475 | 477 | ||
476 | if ( rings == -1 ) | 478 | if ( rings == -1 ) |
477 | { | 479 | { |
478 | p.setPen( QPen( QColor( 200, 20, 20 ), 2 ) ); | 480 | p.setPen( QPen( QColor( 200, 20, 20 ), 2 ) ); |
479 | p.drawLine( w/2-m-m, h/2-m-m, w/2+m+m, h/2+m+m ); | 481 | p.drawLine( w/2-m-m, h/2-m-m, w/2+m+m, h/2+m+m ); |
480 | p.drawLine( w/2+m+m, h/2-m-m, w/2-m-m, h/2+m+m ); | 482 | p.drawLine( w/2+m+m, h/2-m-m, w/2-m-m, h/2+m+m ); |
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; |
488 | 490 | ||
489 | p.setPen( QColor( 200, 20, 20 ) ); | 491 | p.setPen( QColor( 200, 20, 20 ) ); |
490 | for ( int i = 0; i < rings; ++i ) | 492 | for ( int i = 0; i < rings; ++i ) |
491 | { | 493 | { |
492 | p.drawEllipse( w/2 - radius/2, h/3 - radius/2, radius, radius ); | 494 | p.drawEllipse( w/2 - radius/2, h/3 - radius/2, radius, radius ); |
493 | radius += rstep; | 495 | radius += rstep; |
494 | }; | 496 | }; |
495 | 497 | ||
496 | 498 | ||
497 | 499 | ||
498 | } | 500 | } |
499 | 501 | ||
500 | 502 | ||
501 | int WirelessApplet::position() | 503 | int WirelessApplet::position() |
502 | { | 504 | { |
503 | return 6; | 505 | return 6; |
504 | } | 506 | } |
505 | 507 | ||
506 | EXPORT_OPIE_APPLET_v1( WirelessApplet ) | 508 | EXPORT_OPIE_APPLET_v1( WirelessApplet ) |
507 | 509 | ||