summaryrefslogtreecommitdiff
path: root/noncore/applets/wirelessapplet/wireless.cpp
Side-by-side diff
Diffstat (limited to 'noncore/applets/wirelessapplet/wireless.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp59
1 files changed, 26 insertions, 33 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index dc9742a..72ac380 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -1,79 +1,78 @@
/**********************************************************************
** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de>
**
** 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
#define STYLE_ANTENNA 1
-//#define MDEBUG
-#undef MDEBUG
+#define MDEBUG
+//#undef MDEBUG
WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name )
: QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet )
{
readConfig();
writeConfigEntry( "UpdateFrequency", updateFrequency );
writeConfigEntry( "DisplayStyle", displayStyle );
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" );
/* status label */
statusLabel = new QLabel( this, "statuslabel" );
QString text( "Wireless Status:<br>"
"*** Unknown ***<br>"
"Card not inserted ?<br>"
"Or Sharp ROM ?<br>"
"CELL: 00:00:00:00:00:00" );
/* QString text( "Station: Unknown<br>"
"ESSID: Unknown<br>"
"MODE: Unknown<br>"
"FREQ: Unknown<br>"
@@ -304,74 +303,68 @@ 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* )
{
- /*
-
+ qDebug( "WirelessApplet::timerEvent" );
OWirelessNetworkInterface* iface = interface;
if ( iface )
{
- bool statResult = iface->updateStatistics();
- if ( !statResult )
+ if ( mustRepaint() )
{
- interface = 0;
- mustRepaint();
- return ;
+ qDebug( "WIFIAPPLET: A value has changed -> repainting." );
+ repaint();
}
- else
- if ( mustRepaint() )
- {
- //qDebug( "WIFIAPPLET: A value has changed -> repainting." );
- repaint();
- }
if ( status->isVisible() )
+ {
updatePopupWindow();
+ }
+ }
+ else
+ {
+ checkInterface();
}
- else checkInterface();
-
- */
}
void WirelessApplet::mousePressEvent( QMouseEvent * )
{
if ( status->isVisible() )
status->hide();
else
status->show( true );
}
bool WirelessApplet::mustRepaint()
{
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
@@ -429,102 +422,102 @@ bool WirelessApplet::mustRepaint()
{
#ifdef MDEBUG
qDebug( "WIFIAPPLET: AP has changed." );
#endif
renewDHCP();
}
else if ( rocMODE && ( oldMODE != iface->mode() ) )
{
#ifdef MDEBUG
qDebug( "WIFIAPPLET: MODE has changed." );
#endif
renewDHCP();
}
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();
+ OWirelessNetworkInterface* iface = interface;
+ int qualityH = iface->signalStrength();
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>" +
+ QString cell = ( iface->mode() == "Managed" ) ? "AP: " : "Cell: ";
+ freqString.sprintf( "%.3f GHz", iface->frequency() );
+ status->statusLabel->setText( "Station: " + iface->nickName() + "<br>" +
+ "ESSID: " + iface->SSID() + "<br>" +
+ "MODE: " + iface->mode() + "<br>" +
"FREQ: " + freqString + "<br>" +
- cell + " " + iface->APAddr );
+ cell + " " + iface->associatedAP().toString() );
}
const char** WirelessApplet::getQualityPixmap()
{
- MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface;
+ OWirelessNetworkInterface* iface = interface;
if ( !iface ) return ( const char** ) nowireless_xpm;
- int qualityH = iface->qualityPercent();
+ int qualityH = iface->signalStrength();
if ( qualityH < 0 ) return ( const char** ) nowireless_xpm;
if ( visualStyle == STYLE_ANTENNA )
{
if ( qualityH < 1 ) return ( const char** ) connect0_xpm;
if ( qualityH < 17 ) return ( const char** ) connect1_xpm;
if ( qualityH < 34 ) return ( const char** ) connect2_xpm;
if ( qualityH < 50 ) return ( const char** ) connect3_xpm;
if ( qualityH < 65 ) return ( const char** ) connect4_xpm;
return ( const char** ) connect5_xpm;
}
return 0; // please draw your bars
}
void WirelessApplet::paintEvent( QPaintEvent* )
{
- MWirelessNetworkInterface * iface = ( MWirelessNetworkInterface* ) interface;
+ OWirelessNetworkInterface* iface = interface;
QPainter p( this );
QColor color;
const char** pixmap = getQualityPixmap();
if ( pixmap )
p.drawPixmap( 0, 1, pixmap );
else
{
- int noiseH = iface->noisePercent() * ( height() - 3 ) / 100;
- int signalH = iface->signalPercent() * ( height() - 3 ) / 100;
- int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100;
+ int noiseH = 30; // iface->noisePercent() * ( height() - 3 ) / 100;
+ int signalH = 50; // iface->signalPercent() * ( height() - 3 ) / 100;
+ int qualityH = iface->signalStrength(); // iface->qualityPercent() * ( height() - 3 ) / 100;
double intensity;
int pixelHeight;
int pixelWidth = 2;
int Hue;
int barSpace = 3;
int leftoffset = 0;
int bottomoffset = 2;
// draw noise indicator
pixelHeight = noiseH;
Hue = 50;
for ( int i = 0; i < pixelHeight; ++i )
{
intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
color.setHsv( Hue, 255, intensity );
p.setPen ( color );
p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
}
// draw signal indicator
pixelHeight = signalH;
Hue = 100;
leftoffset += pixelWidth + barSpace;