summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-02-23 14:42:18 (UTC)
committer mickeyl <mickeyl>2004-02-23 14:42:18 (UTC)
commit68c8d3eb878f9ba913c42368fbb253d7320c62be (patch) (unidiff)
tree5c2ceda7500c2a18e0134f763d278e6d0c00c911
parent1f362cd77a2b39eae2abca6da28efa5118d2c347 (diff)
downloadopie-68c8d3eb878f9ba913c42368fbb253d7320c62be.zip
opie-68c8d3eb878f9ba913c42368fbb253d7320c62be.tar.gz
opie-68c8d3eb878f9ba913c42368fbb253d7320c62be.tar.bz2
working on the overhaul. CAUTION: WirelessApplet is broken now.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/config.in2
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp50
-rw-r--r--noncore/applets/wirelessapplet/wireless.h10
-rw-r--r--noncore/applets/wirelessapplet/wirelessapplet.pro2
4 files changed, 36 insertions, 28 deletions
diff --git a/noncore/applets/wirelessapplet/config.in b/noncore/applets/wirelessapplet/config.in
index 8e948a2..f4828d3 100644
--- a/noncore/applets/wirelessapplet/config.in
+++ b/noncore/applets/wirelessapplet/config.in
@@ -1,4 +1,4 @@
1 config WIRELESSAPPLET 1 config WIRELESSAPPLET
2 boolean "opie-wirelessapplet (view wireless signal strength, and renew IP on AP change)" 2 boolean "opie-wirelessapplet (view wireless signal strength, and renew IP on AP change)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index cbaf5d6..dc9742a 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -19,16 +19,17 @@
19#include "connect1.xpm" 19#include "connect1.xpm"
20#include "connect2.xpm" 20#include "connect2.xpm"
21#include "connect3.xpm" 21#include "connect3.xpm"
22#include "connect4.xpm" 22#include "connect4.xpm"
23#include "connect5.xpm" 23#include "connect5.xpm"
24#include "nowireless.xpm" 24#include "nowireless.xpm"
25 25
26/* OPIE */ 26/* OPIE */
27#include <opie2/onetwork.h>
27#include <opie2/otaskbarapplet.h> 28#include <opie2/otaskbarapplet.h>
28#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
29#include <qpe/config.h> 30#include <qpe/config.h>
30 31
31/* QT */ 32/* QT */
32#include <qpoint.h> 33#include <qpoint.h>
33#include <qradiobutton.h> 34#include <qradiobutton.h>
34#include <qpushbutton.h> 35#include <qpushbutton.h>
@@ -202,32 +203,39 @@ void WirelessControl::writeConfigEntry( const char *entry, int val )
202 cfg.setGroup( "Wireless" ); 203 cfg.setGroup( "Wireless" );
203 cfg.writeEntry( entry, val ); 204 cfg.writeEntry( entry, val );
204} 205}
205 206
206//=========================================================================== 207//===========================================================================
207 208
208WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) 209WirelessApplet::WirelessApplet( QWidget *parent, const char *name )
209 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), 210 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ),
210 timer( 0 ), interface( 0 ), 211 timer( 0 ), interface( 0 ), oldiface( 0 ),
211 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) 212 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false )
212{ 213{
213 setFixedHeight( 18 ); 214 setFixedHeight( 18 );
214 setFixedWidth( 14 ); 215 setFixedWidth( 14 );
215 network = new MWirelessNetwork();
216 status = new WirelessControl( this, this, "wireless status" ); 216 status = new WirelessControl( this, this, "wireless status" );
217} 217}
218 218
219void WirelessApplet::checkInterface() 219void WirelessApplet::checkInterface()
220{ 220{
221 interface = network->getFirstInterface(); 221 interface = 0L;
222 ONetwork* net = ONetwork::instance();
223 ONetwork::InterfaceIterator it = net->iterator();
224
225 while ( it.current() && !it.current()->isWireless() ) ++it;
226
227 if ( it.current() && it.current()->isWireless() )
228 interface = static_cast<OWirelessNetworkInterface*>( it.current() );
229
222 if ( interface ) 230 if ( interface )
223 { 231 {
224#ifdef MDEBUG 232#ifdef MDEBUG
225 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->getName() ); 233 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() );
226#endif 234#endif
227 235
228 } 236 }
229 else 237 else
230 { 238 {
231#ifdef MDEBUG 239#ifdef MDEBUG
232 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); 240 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" );
233#endif 241#endif
@@ -239,17 +247,17 @@ void WirelessApplet::renewDHCP()
239{ 247{
240#ifdef MDEBUG 248#ifdef MDEBUG
241 qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); 249 qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." );
242#endif 250#endif
243 251
244 QString pidfile; 252 QString pidfile;
245 if ( !interface ) 253 if ( !interface )
246 return ; 254 return ;
247 QString ifacename( interface->getName() ); 255 QString ifacename( interface->name() );
248 256
249 // At first we are trying dhcpcd 257 // At first we are trying dhcpcd
250 258
251 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); 259 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename );
252#ifdef MDEBUG 260#ifdef MDEBUG
253 qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile ); 261 qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile );
254#endif 262#endif
255 int pid; 263 int pid;
@@ -312,17 +320,19 @@ void WirelessApplet::displayStyleChange( int style )
312 repaint(); 320 repaint();
313} 321}
314 322
315WirelessApplet::~WirelessApplet() 323WirelessApplet::~WirelessApplet()
316{} 324{}
317 325
318void WirelessApplet::timerEvent( QTimerEvent* ) 326void WirelessApplet::timerEvent( QTimerEvent* )
319{ 327{
320 MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; 328 /*
329
330 OWirelessNetworkInterface* iface = interface;
321 331
322 if ( iface ) 332 if ( iface )
323 { 333 {
324 bool statResult = iface->updateStatistics(); 334 bool statResult = iface->updateStatistics();
325 if ( !statResult ) 335 if ( !statResult )
326 { 336 {
327 interface = 0; 337 interface = 0;
328 mustRepaint(); 338 mustRepaint();
@@ -334,29 +344,31 @@ void WirelessApplet::timerEvent( QTimerEvent* )
334 //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); 344 //qDebug( "WIFIAPPLET: A value has changed -> repainting." );
335 repaint(); 345 repaint();
336 } 346 }
337 347
338 if ( status->isVisible() ) 348 if ( status->isVisible() )
339 updatePopupWindow(); 349 updatePopupWindow();
340 } 350 }
341 else checkInterface(); 351 else checkInterface();
352
353 */
342} 354}
343 355
344void WirelessApplet::mousePressEvent( QMouseEvent * ) 356void WirelessApplet::mousePressEvent( QMouseEvent * )
345{ 357{
346 if ( status->isVisible() ) 358 if ( status->isVisible() )
347 status->hide(); 359 status->hide();
348 else 360 else
349 status->show( true ); 361 status->show( true );
350} 362}
351 363
352bool WirelessApplet::mustRepaint() 364bool WirelessApplet::mustRepaint()
353{ 365{
354 MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; 366 OWirelessNetworkInterface* iface = interface;
355 367
356 // check if there are enough changes to justify a (flickering) repaint 368 // check if there are enough changes to justify a (flickering) repaint
357 369
358 // has the interface changed? 370 // has the interface changed?
359 371
360 if ( iface != oldiface ) 372 if ( iface != oldiface )
361 { 373 {
362 oldiface = iface; 374 oldiface = iface;
@@ -380,63 +392,63 @@ bool WirelessApplet::mustRepaint()
380 const char** pixmap = getQualityPixmap(); 392 const char** pixmap = getQualityPixmap();
381 393
382 if ( pixmap && ( pixmap != oldpixmap ) ) 394 if ( pixmap && ( pixmap != oldpixmap ) )
383 { 395 {
384 oldpixmap = pixmap; 396 oldpixmap = pixmap;
385 return true; 397 return true;
386 } 398 }
387 399
388 int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; 400 int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100;
389 int signalH = iface->signalPercent() * ( height() - 3 ) / 100; 401 int signalH = iface->signalStrength() * ( height() - 3 ) / 100;
390 int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; 402 int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100;
391 403
392 if ( ( noiseH != oldnoiseH ) 404 if ( ( noiseH != oldnoiseH )
393 || ( signalH != oldsignalH ) 405 || ( signalH != oldsignalH )
394 || ( qualityH != oldqualityH ) ) 406 || ( qualityH != oldqualityH ) )
395 { 407 {
396 oldnoiseH = noiseH; 408 oldnoiseH = noiseH;
397 oldsignalH = signalH; 409 oldsignalH = signalH;
398 oldqualityH = qualityH; 410 oldqualityH = qualityH;
399 return true; 411 return true;
400 } 412 }
401 413
402 if ( rocESSID && ( oldESSID != iface->essid ) ) 414 if ( rocESSID && ( oldESSID != iface->SSID() ) )
403 { 415 {
404#ifdef MDEBUG 416#ifdef MDEBUG
405 qDebug( "WIFIAPPLET: ESSID has changed." ); 417 qDebug( "WIFIAPPLET: ESSID has changed." );
406#endif 418#endif
407 renewDHCP(); 419 renewDHCP();
408 } 420 }
409 else if ( rocFREQ && ( oldFREQ != iface->freq ) ) 421 else if ( rocFREQ && ( oldFREQ != iface->frequency() ) )
410 { 422 {
411#ifdef MDEBUG 423#ifdef MDEBUG
412 qDebug( "WIFIAPPLET: FREQ has changed." ); 424 qDebug( "WIFIAPPLET: FREQ has changed." );
413#endif 425#endif
414 renewDHCP(); 426 renewDHCP();
415 } 427 }
416 else if ( rocAP && ( oldAP != iface->APAddr ) ) 428 else if ( rocAP && ( oldAP != iface->associatedAP().toString() ) )
417 { 429 {
418#ifdef MDEBUG 430#ifdef MDEBUG
419 qDebug( "WIFIAPPLET: AP has changed." ); 431 qDebug( "WIFIAPPLET: AP has changed." );
420#endif 432#endif
421 renewDHCP(); 433 renewDHCP();
422 } 434 }
423 else if ( rocMODE && ( oldMODE != iface->mode ) ) 435 else if ( rocMODE && ( oldMODE != iface->mode() ) )
424 { 436 {
425#ifdef MDEBUG 437#ifdef MDEBUG
426 qDebug( "WIFIAPPLET: MODE has changed." ); 438 qDebug( "WIFIAPPLET: MODE has changed." );
427#endif 439#endif
428 renewDHCP(); 440 renewDHCP();
429 } 441 }
430 442
431 oldESSID = iface->essid; 443 oldESSID = iface->SSID();
432 oldMODE = iface->mode; 444 oldMODE = iface->mode();
433 oldFREQ = iface->freq; 445 oldFREQ = iface->frequency();
434 oldAP = iface->APAddr; 446 oldAP = iface->associatedAP().toString();
435 447
436 return false; 448 return false;
437} 449}
438 450
439void WirelessApplet::updatePopupWindow() 451void WirelessApplet::updatePopupWindow()
440{ 452{
441 MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; 453 MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface;
442 int qualityH = iface->qualityPercent(); 454 int qualityH = iface->qualityPercent();
diff --git a/noncore/applets/wirelessapplet/wireless.h b/noncore/applets/wirelessapplet/wireless.h
index 644be26..27f8c90 100644
--- a/noncore/applets/wirelessapplet/wireless.h
+++ b/noncore/applets/wirelessapplet/wireless.h
@@ -14,20 +14,17 @@
14 14
15#ifndef __WIRELESS_APPLET_H__ 15#ifndef __WIRELESS_APPLET_H__
16#define __WIRELESS_APPLET_H__ 16#define __WIRELESS_APPLET_H__
17 17
18#include <qwidget.h> 18#include <qwidget.h>
19#include <qframe.h> 19#include <qframe.h>
20#include <qpixmap.h> 20#include <qpixmap.h>
21 21
22class MNetwork; 22class OWirelessNetworkInterface;
23class MWirelessNetwork;
24class MNetworkInterface;
25class MWirelessNetworkInterface;
26class Y; 23class Y;
27class QLabel; 24class QLabel;
28class WirelessApplet; 25class WirelessApplet;
29class MGraph; 26class MGraph;
30 27
31class WirelessControl : public QFrame 28class WirelessControl : public QFrame
32{ 29{
33 Q_OBJECT 30 Q_OBJECT
@@ -84,22 +81,21 @@ class WirelessApplet : public QWidget
84 void updatePopupWindow(); 81 void updatePopupWindow();
85 const char** getQualityPixmap(); 82 const char** getQualityPixmap();
86 83
87 private: 84 private:
88 QPixmap snapshotPixmap; 85 QPixmap snapshotPixmap;
89 int visualStyle; 86 int visualStyle;
90 int timer; 87 int timer;
91 88
92 MWirelessNetwork* network; 89 OWirelessNetworkInterface* interface;
93 MNetworkInterface* interface;
94 90
95 private: 91 private:
96 const char** oldpixmap; 92 const char** oldpixmap;
97 MWirelessNetworkInterface* oldiface; 93 OWirelessNetworkInterface* oldiface;
98 int oldqualityH; 94 int oldqualityH;
99 int oldsignalH; 95 int oldsignalH;
100 int oldnoiseH; 96 int oldnoiseH;
101 97
102 QString oldESSID; 98 QString oldESSID;
103 QString oldAP; 99 QString oldAP;
104 QString oldMODE; 100 QString oldMODE;
105 double oldFREQ; 101 double oldFREQ;
diff --git a/noncore/applets/wirelessapplet/wirelessapplet.pro b/noncore/applets/wirelessapplet/wirelessapplet.pro
index 38cb475..7bd7380 100644
--- a/noncore/applets/wirelessapplet/wirelessapplet.pro
+++ b/noncore/applets/wirelessapplet/wirelessapplet.pro
@@ -2,12 +2,12 @@ TEMPLATE = lib
2CONFIG += qt plugin warn_on release 2CONFIG += qt plugin warn_on release
3HEADERS = wireless.h networkinfo.h mgraph.h advancedconfig.h 3HEADERS = wireless.h networkinfo.h mgraph.h advancedconfig.h
4SOURCES = wireless.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp 4SOURCES = wireless.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp
5INTERFACES = advancedconfigbase.ui 5INTERFACES = advancedconfigbase.ui
6TARGET = wirelessapplet 6TARGET = wirelessapplet
7DESTDIR = $(OPIEDIR)/plugins/applets 7DESTDIR = $(OPIEDIR)/plugins/applets
8INCLUDEPATH += $(OPIEDIR)/include 8INCLUDEPATH += $(OPIEDIR)/include
9DEPENDPATH += $(OPIEDIR)/include 9DEPENDPATH += $(OPIEDIR)/include
10LIBS += -lqpe 10LIBS += -lqpe -lopiecore2 -lopienet2
11VERSION = 0.1.1 11VERSION = 0.1.1
12 12
13include ( $(OPIEDIR)/include.pro ) 13include ( $(OPIEDIR)/include.pro )