author | mickeyl <mickeyl> | 2004-02-23 14:42:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 14:42:18 (UTC) |
commit | 68c8d3eb878f9ba913c42368fbb253d7320c62be (patch) (side-by-side diff) | |
tree | 5c2ceda7500c2a18e0134f763d278e6d0c00c911 | |
parent | 1f362cd77a2b39eae2abca6da28efa5118d2c347 (diff) | |
download | opie-68c8d3eb878f9ba913c42368fbb253d7320c62be.zip opie-68c8d3eb878f9ba913c42368fbb253d7320c62be.tar.gz opie-68c8d3eb878f9ba913c42368fbb253d7320c62be.tar.bz2 |
working on the overhaul. CAUTION: WirelessApplet is broken now.
-rw-r--r-- | noncore/applets/wirelessapplet/config.in | 2 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 50 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.h | 10 | ||||
-rw-r--r-- | noncore/applets/wirelessapplet/wirelessapplet.pro | 2 |
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 @@ config WIRELESSAPPLET boolean "opie-wirelessapplet (view wireless signal strength, and renew IP on AP change)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + 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 @@ -3,48 +3,49 @@ ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "wireless.h" #include "networkinfo.h" #include "mgraph.h" #include "advancedconfig.h" #include "connect0.xpm" #include "connect1.xpm" #include "connect2.xpm" #include "connect3.xpm" #include "connect4.xpm" #include "connect5.xpm" #include "nowireless.xpm" /* OPIE */ +#include <opie2/onetwork.h> #include <opie2/otaskbarapplet.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> /* QT */ #include <qpoint.h> #include <qradiobutton.h> #include <qpushbutton.h> #include <qpainter.h> #include <qlabel.h> #include <qslider.h> #include <qbuttongroup.h> #include <qlayout.h> #include <qframe.h> #include <qpixmap.h> #include <qstring.h> #include <qfile.h> #include <qtextstream.h> /* STD */ #include <sys/types.h> #include <signal.h> #define STYLE_BARS 0 @@ -186,86 +187,93 @@ void WirelessControl::show ( bool ) void WirelessControl::readConfig() { Config cfg( "qpe" ); cfg.setGroup( "Wireless" ); updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); } void WirelessControl::writeConfigEntry( const char *entry, int val ) { Config cfg( "qpe" ); cfg.setGroup( "Wireless" ); cfg.writeEntry( entry, val ); } //=========================================================================== WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), - timer( 0 ), interface( 0 ), - rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) + timer( 0 ), interface( 0 ), oldiface( 0 ), + rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) { setFixedHeight( 18 ); setFixedWidth( 14 ); - network = new MWirelessNetwork(); status = new WirelessControl( this, this, "wireless status" ); } void WirelessApplet::checkInterface() { - interface = network->getFirstInterface(); + interface = 0L; + ONetwork* net = ONetwork::instance(); + ONetwork::InterfaceIterator it = net->iterator(); + + while ( it.current() && !it.current()->isWireless() ) ++it; + + if ( it.current() && it.current()->isWireless() ) + interface = static_cast<OWirelessNetworkInterface*>( it.current() ); + if ( interface ) { #ifdef MDEBUG - qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->getName() ); + qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); #endif } else { #ifdef MDEBUG qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); #endif hide(); } } void WirelessApplet::renewDHCP() { #ifdef MDEBUG qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); #endif QString pidfile; if ( !interface ) return ; - QString ifacename( interface->getName() ); + QString ifacename( interface->name() ); // At first we are trying dhcpcd pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); #ifdef MDEBUG qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", ( const char* ) pidfile ); #endif int pid; QFile pfile( pidfile ); bool hasFile = pfile.open( IO_ReadOnly ); QTextStream s( &pfile ); if ( hasFile ) { s >> pid; #ifdef MDEBUG qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); #endif kill( pid, SIGALRM ); return ; } // No dhcpcd, so we are trying udhcpc #ifdef MDEBUG qDebug( "WIFIAPPLET: dhcpcd not available." ); @@ -296,163 +304,167 @@ void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE rocMODE = MODE; } void WirelessApplet::updateDelayChange( int delay ) { if ( timer ) killTimer( timer ); delay *= 1000; if ( delay == 0 ) delay = 50; timer = startTimer( delay ); } void WirelessApplet::displayStyleChange( int style ) { visualStyle = style; repaint(); } WirelessApplet::~WirelessApplet() {} void WirelessApplet::timerEvent( QTimerEvent* ) { - MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; + /* + + OWirelessNetworkInterface* iface = interface; if ( iface ) { bool statResult = iface->updateStatistics(); if ( !statResult ) { interface = 0; mustRepaint(); return ; } else if ( mustRepaint() ) { //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); repaint(); } if ( status->isVisible() ) updatePopupWindow(); } else checkInterface(); + + */ } void WirelessApplet::mousePressEvent( QMouseEvent * ) { if ( status->isVisible() ) status->hide(); else status->show( true ); } bool WirelessApplet::mustRepaint() { - MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; + OWirelessNetworkInterface* iface = interface; // check if there are enough changes to justify a (flickering) repaint // has the interface changed? if ( iface != oldiface ) { oldiface = iface; if ( iface ) { #ifdef MDEBUG qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); #endif show(); } else { #ifdef MDEBUG qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); #endif hide(); return true; } } const char** pixmap = getQualityPixmap(); if ( pixmap && ( pixmap != oldpixmap ) ) { oldpixmap = pixmap; return true; } - int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; - int signalH = iface->signalPercent() * ( height() - 3 ) / 100; - int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; + int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; + int signalH = iface->signalStrength() * ( height() - 3 ) / 100; + int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; if ( ( noiseH != oldnoiseH ) || ( signalH != oldsignalH ) || ( qualityH != oldqualityH ) ) { oldnoiseH = noiseH; oldsignalH = signalH; oldqualityH = qualityH; return true; } - if ( rocESSID && ( oldESSID != iface->essid ) ) + if ( rocESSID && ( oldESSID != iface->SSID() ) ) { #ifdef MDEBUG qDebug( "WIFIAPPLET: ESSID has changed." ); #endif renewDHCP(); } - else if ( rocFREQ && ( oldFREQ != iface->freq ) ) + else if ( rocFREQ && ( oldFREQ != iface->frequency() ) ) { #ifdef MDEBUG qDebug( "WIFIAPPLET: FREQ has changed." ); #endif renewDHCP(); } - else if ( rocAP && ( oldAP != iface->APAddr ) ) + else if ( rocAP && ( oldAP != iface->associatedAP().toString() ) ) { #ifdef MDEBUG qDebug( "WIFIAPPLET: AP has changed." ); #endif renewDHCP(); } - else if ( rocMODE && ( oldMODE != iface->mode ) ) + else if ( rocMODE && ( oldMODE != iface->mode() ) ) { #ifdef MDEBUG qDebug( "WIFIAPPLET: MODE has changed." ); #endif renewDHCP(); } - oldESSID = iface->essid; - oldMODE = iface->mode; - oldFREQ = iface->freq; - oldAP = iface->APAddr; + oldESSID = iface->SSID(); + oldMODE = iface->mode(); + oldFREQ = iface->frequency(); + oldAP = iface->associatedAP().toString(); return false; } void WirelessApplet::updatePopupWindow() { MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface; int qualityH = iface->qualityPercent(); if ( status->mgraph ) status->mgraph->addValue( qualityH, false ); QString freqString; QString cell = ( iface->mode == "Managed" ) ? "AP: " : "Cell: "; freqString.sprintf( "%.3f GHz", iface->freq ); status->statusLabel->setText( "Station: " + iface->nick + "<br>" + "ESSID: " + iface->essid + "<br>" + "MODE: " + iface->mode + "<br>" + "FREQ: " + freqString + "<br>" + cell + " " + iface->APAddr ); } const char** WirelessApplet::getQualityPixmap() { 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 @@ -1,49 +1,46 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> ** All rights reserved. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef __WIRELESS_APPLET_H__ #define __WIRELESS_APPLET_H__ #include <qwidget.h> #include <qframe.h> #include <qpixmap.h> -class MNetwork; -class MWirelessNetwork; -class MNetworkInterface; -class MWirelessNetworkInterface; +class OWirelessNetworkInterface; class Y; class QLabel; class WirelessApplet; class MGraph; class WirelessControl : public QFrame { Q_OBJECT public: WirelessControl( WirelessApplet* icon, QWidget *parent=0, const char *name=0 ); void show( bool ); void readConfig(); void writeConfigEntry( const char* entry, int val ); MGraph* mgraph; QLabel* statusLabel; QLabel* updateLabel; public slots: void updateDelayChange( int ); void displayStyleChange( int ); void advancedConfigClicked(); @@ -68,47 +65,46 @@ class WirelessApplet : public QWidget static int position(); WirelessControl* status; virtual void timerEvent( QTimerEvent* ); void updateDelayChange( int delay ); void displayStyleChange( int style ); void updateDHCPConfig( bool, bool, bool, bool ); private: void mousePressEvent( QMouseEvent * ); void paintEvent( QPaintEvent* ); void checkInterface(); void renewDHCP(); bool mustRepaint(); void updatePopupWindow(); const char** getQualityPixmap(); private: QPixmap snapshotPixmap; int visualStyle; int timer; - MWirelessNetwork* network; - MNetworkInterface* interface; + OWirelessNetworkInterface* interface; private: const char** oldpixmap; - MWirelessNetworkInterface* oldiface; + OWirelessNetworkInterface* oldiface; int oldqualityH; int oldsignalH; int oldnoiseH; QString oldESSID; QString oldAP; QString oldMODE; double oldFREQ; bool rocESSID; bool rocFREQ; bool rocAP; bool rocMODE; }; #endif // __WIRELESS_APPLET_H__ 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 @@ -1,13 +1,13 @@ TEMPLATE = lib CONFIG += qt plugin warn_on release HEADERS = wireless.h networkinfo.h mgraph.h advancedconfig.h SOURCES = wireless.cpp networkinfo.cpp mgraph.cpp advancedconfig.cpp INTERFACES = advancedconfigbase.ui TARGET = wirelessapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopiecore2 -lopienet2 VERSION = 0.1.1 include ( $(OPIEDIR)/include.pro ) |