summaryrefslogtreecommitdiff
path: root/noncore/applets/wirelessapplet/wireless.cpp
Side-by-side diff
Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp48
1 files changed, 30 insertions, 18 deletions
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
@@ -15,24 +15,25 @@
#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>
@@ -198,62 +199,69 @@ void WirelessControl::readConfig()
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 ),
+ 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 )
@@ -308,59 +316,63 @@ void WirelessApplet::updateDelayChange( int 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! :-)" );
@@ -376,71 +388,71 @@ bool WirelessApplet::mustRepaint()
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 );