-rw-r--r-- | noncore/net/wellenreiter/gui/graphwindow.cpp | 159 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/graphwindow.h | 118 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 7 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 7 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/opie-wellenreiter.control | 2 |
7 files changed, 298 insertions, 3 deletions
diff --git a/noncore/net/wellenreiter/gui/graphwindow.cpp b/noncore/net/wellenreiter/gui/graphwindow.cpp new file mode 100644 index 0000000..c620fe2 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/graphwindow.cpp @@ -0,0 +1,159 @@ +/********************************************************************** +** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. +** +** This file is part of Opie Environment. +** +** 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 "graphwindow.h" + +#include <qpainter.h> +#include <qpixmap.h> +#include <qtimer.h> + +MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const char* name, WFlags f) + :QWidget( parent, name,f ), _channels( channels ) +{ + _values = new int[_channels]; + _dirty = new bool[_channels]; + for ( int i = 0; i < channels; ++i ) + { _values[i] = 0; + _dirty[i] = true; + } + + // we draw everything alone + setBackgroundMode( QWidget::NoBackground ); +} + + +void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c ) +{ + p->setPen( c.light() ); + p->drawPoint( x++, y ); + p->setPen( c ); + p->drawLine( x, y, x+width-2, y ); + p->setPen( c.dark() ); + p->drawPoint( x+width-1, y ); +} + + +void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight ) +{ +/* int h1 = 133; int h2 = 0; + int s1 = 200; int s2 = 255; + int v1 = 140; int v2 = 255; */ + + int h1 = 196; int h2 = 194; + int s1 = 85; int s2 = 15; + int v1 = 95; int v2 = 237; + + QColor c( 120, 60, 200 ); + for ( int i = 0; i < height; ++i ) + { + int h = (h2-h1)*i/maxheight + h1; + int s = (s2-s1)*i/maxheight + s1; + int v = (v2-v1)*i/maxheight + v1; + drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); + } + + /*for ( int i = height; i < maxheight; ++i ) + drawLine( p, x, y-i, width, QColor( 47, 68, 76 ) );*/ + +} + + +void MFrequencySpectrum::paintEvent( QPaintEvent* e ) +{ + QPixmap pm( size() ); + QPainter p; + p.begin( &pm ); + p.drawTiledPixmap( 0, 0, size().width(), size().height(), QPixmap( (const char**) &background ) ); + + int xmargin = 5; + int ymargin = 2; + int y = size().height() - 2 * ymargin; + int x = 0; + int width = ( size().width() - 2 * xmargin ) / _channels; + + for ( int i = 0; i < _channels; ++i ) + { + if ( _dirty[i] ) + { + drawBar( &p, xmargin + x, y - ymargin, width-3, _values[i]*y/100, y ); + _dirty[i] = false; + } + x+= width; + } + + p.end(); + bitBlt( this, 0, 0, &pm ); +} + + +Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f ) + :QFrame( parent, name, f ), _channels( channels ) +{ + setLineWidth( 2 ); + setFrameStyle( Panel + Sunken ); + setFixedHeight( 16 ); + +} + + +void Legende::drawContents( QPainter* p ) +{ + int xmargin = 5; + int ymargin = 2; + int x = 0; + int width = ( contentsRect().width() - 2 * xmargin ) / _channels; + + for ( int i = 0; i < _channels; ++i ) + p->drawText( xmargin + (width*i), 12, QString().sprintf( "%02d", i+1 ) ); +} + + +MGraphWindow::MGraphWindow( QWidget* parent, const char* name, WFlags f ) + :QVBox( parent, name, f ) +{ + spectrum = new MFrequencySpectrum( 14, this ); + legende = new Legende( 14, this ); + startTimer( 50 ); + + //testGraph(); + +}; + + +void MGraphWindow::testGraph() +{ + static int i = 0; + spectrum->setValue( i++, 100 ); + if ( i == 14 ) i = 0; + QTimer::singleShot( 2000, this, SLOT( testGraph() ) ); + +} + + +void MGraphWindow::timerEvent( QTimerEvent* e ) +{ + for ( int i = 0; i < 14; i++ ) + { + spectrum->decrease( i, 4 ); + } + spectrum->repaint(); +} + + +void MGraphWindow::traffic( int channel, int signal ) +{ + spectrum->setValue( channel-1, signal ); +} + diff --git a/noncore/net/wellenreiter/gui/graphwindow.h b/noncore/net/wellenreiter/gui/graphwindow.h new file mode 100644 index 0000000..4050065 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/graphwindow.h @@ -0,0 +1,118 @@ +/********************************************************************** +** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. +** +** This file is part of Opie Environment. +** +** 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 GRAPHWINDOW_H +#define GRAPHWINDOW_H + +#include <qwidget.h> +#include <qvbox.h> + +class MFrequencySpectrum : public QWidget +{ + public: + MFrequencySpectrum( int channels, QWidget* parent = 0, const char* name = "MFrequencySpectrum", WFlags f = 0 ); + int value( int channel ) const { return _values[channel]; }; + void setValue( int channel, int value ) + { + if ( value > _values[channel] ) + { + _values[channel] = value; + _dirty[channel] = true; + } + }; + void decrease( int channel, int amount ) + { + if ( _values[channel] >= amount ) + { + _values[channel] -= amount; + _dirty[channel] = true; + } + }; + + protected: + virtual void paintEvent( QPaintEvent* ); + + void drawLine( QPainter* p, int x, int y, int width, const QColor& c ); + void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight ); + + private: + int _channels; + int* _values; + bool* _dirty; +}; + + +class Legende : public QFrame +{ + public: + Legende( int channels, QWidget* parent = 0, const char* name = "Legende", WFlags f = 0 ); + + protected: + virtual void drawContents( QPainter* ); + + private: + int _channels; +}; + + +class MGraphWindow : public QVBox +{ + Q_OBJECT + + public: + MGraphWindow( QWidget* parent = 0, const char* name = "MGraphWindow", WFlags f = 0 ); + void traffic( int channel, int signal ); + + protected: + virtual void timerEvent( QTimerEvent* e ); + + protected slots: + virtual void testGraph(); + + protected: + MFrequencySpectrum* spectrum; + Legende* legende; + +}; + +/* XPM */ +static char * background[] = { +"16 16 6 1", +" c None", +". c #52676E", +"+ c #3F545B", +"@ c #394E56", +"# c #2F454C", +"$ c #364B52", +".+++++++++++++++", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############", +"+$$$$$$$$$$$$$$$", +"@###############"}; + + +#endif + diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 476518a..927f4b7 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -3,36 +3,38 @@ OBJECTS_DIR = ./tmp DESTDIR = $(OPIEDIR)/bin TEMPLATE = app CONFIG = qt warn_on debug HEADERS = wellenreiterbase.h \ mainwindow.h \ wellenreiter.h \ scanlist.h \ logwindow.h \ hexwindow.h \ statwindow.h \ configwindow.h \ - manufacturers.h + manufacturers.h \ + graphwindow.h SOURCES = main.cpp \ mainwindow.cpp \ wellenreiterbase.cpp \ wellenreiter.cpp \ scanlist.cpp \ logwindow.cpp \ hexwindow.cpp \ statwindow.cpp \ configwindow.cpp \ - manufacturers.cpp + manufacturers.cpp \ + graphwindow.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include INTERFACES = configbase.ui TARGET = wellenreiter !contains( platform, x11 ) { message( qws ) include ( $(OPIEDIR)/include.pro ) LIBS += -lqpe -lopie -lopiecore2 -lopieui2 -lopienet2 -lstdc++ } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 4b82c9a..c061319 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -49,24 +49,25 @@ using namespace Opie; #include <string.h> #include <sys/types.h> #include <stdlib.h> // Local #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" #include "hexwindow.h" #include "configwindow.h" #include "statwindow.h" +#include "graphwindow.h" #include "manufacturers.h" Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // // construct manufacturer database // QString manufile; @@ -157,24 +158,30 @@ void Wellenreiter::receivePacket(OPacket* p) { qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); return; } OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); QString essid = ssid ? ssid->ID() : QString("<unknown>"); OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); int channel = ds ? ds->channel() : -1; OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); + + // do we have a prism header? + OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); + if ( ds && prism ) + graphwindow->traffic( ds->channel(), prism->signalStrength() ); + return; } // check for a data frame OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); if ( data ) { OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); if ( wlan->fromDS() && !wlan->toDS() ) { qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", (const char*) wlan->macAddress3().toString(true), diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 9745069..36fbb9a 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp @@ -22,24 +22,25 @@ #include <qpushbutton.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include "logwindow.h" #include "hexwindow.h" #include "scanlist.h" #include "statwindow.h" +#include "graphwindow.h" #ifdef QWS #include <qpe/resource.h> #include <opie/otabwidget.h> #else #include "resource.h" #include <qtabwidget.h> #endif /* * Constructs a WellenreiterBase which is a child of 'parent', with the @@ -70,24 +71,28 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f TabWidget = new QTabWidget( this, "TabWidget" ); #endif ap = new QWidget( TabWidget, "ap" ); apLayout = new QVBoxLayout( ap ); apLayout->setSpacing( 2 ); apLayout->setMargin( 2 ); //--------- NETVIEW TAB -------------- netview = new MScanListView( ap ); apLayout->addWidget( netview ); + //--------- GRAPH TAB -------------- + + graphwindow = new MGraphWindow( TabWidget, "Graph" ); + //--------- LOG TAB -------------- logwindow = new MLogWindow( TabWidget, "Log" ); //--------- HEX TAB -------------- hexwindow = new MHexWindow( TabWidget, "Hex" ); //--------- STAT TAB -------------- statwindow = new MStatWindow( TabWidget, "Stat" ); @@ -120,30 +125,32 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f "<hr>\n" "Max Moser<br>\n" "Martin J. Muench<br>\n" "Michael Lauer<br><hr>\n" "<b>www.remote-exploit.org</b>\n" "</p>" ) ); TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); #ifdef QWS TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); + TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); #else TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); + TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); #endif WellenreiterBaseLayout->addWidget( TabWidget ); #ifdef QWS TabWidget->setCurrentTab( tr( "Nets" ) ); #endif } diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h index ad2e96c..e8dc924 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.h +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h @@ -19,24 +19,25 @@ #include <qvariant.h> #include <qwidget.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QLabel; class MScanListView; class MScanListItem; class QPushButton; class MLogWindow; class MHexWindow; class MStatWindow; +class MGraphWindow; #ifdef QWS class OTabWidget; #else class QTabWidget; #endif class WellenreiterBase : public QWidget { Q_OBJECT public: @@ -44,24 +45,25 @@ public: ~WellenreiterBase(); #ifdef QWS OTabWidget* TabWidget; #else QTabWidget* TabWidget; #endif QWidget* ap; MScanListView* netview; MLogWindow* logwindow; MHexWindow* hexwindow; MStatWindow* statwindow; + MGraphWindow* graphwindow; QWidget* about; QLabel* PixmapLabel1_3_2; QLabel* TextLabel1_4_2; protected: QVBoxLayout* WellenreiterBaseLayout; QVBoxLayout* apLayout; QGridLayout* aboutLayout; bool event( QEvent* ); QPixmap* ani1; QPixmap* ani2; diff --git a/noncore/net/wellenreiter/opie-wellenreiter.control b/noncore/net/wellenreiter/opie-wellenreiter.control index f7267b4..8bb5b1c 100644 --- a/noncore/net/wellenreiter/opie-wellenreiter.control +++ b/noncore/net/wellenreiter/opie-wellenreiter.control @@ -1,10 +1,10 @@ Package: opie-wellenreiter Files: bin/wellenreiter share/wellenreiter pics/wellenreiter apps/Applications/wellenreiter.desktop Priority: optional Section: opie/applications Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: 0.9.9-$SUB_VERSION Depends: task-opie-minimal, libpcap0, libopie2 (1.8.1) Description: A WaveLAN Network Monitor A WaveLAN Network Monitor/Sniffer for the Opie Environment. |