summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/graphwindow.cpp159
-rw-r--r--noncore/net/wellenreiter/gui/graphwindow.h118
-rw-r--r--noncore/net/wellenreiter/gui/gui.pro6
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp7
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.cpp9
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.h2
-rw-r--r--noncore/net/wellenreiter/opie-wellenreiter.control2
7 files changed, 299 insertions, 4 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 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include "graphwindow.h"
17
18#include <qpainter.h>
19#include <qpixmap.h>
20#include <qtimer.h>
21
22MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const char* name, WFlags f)
23 :QWidget( parent, name,f ), _channels( channels )
24{
25 _values = new int[_channels];
26 _dirty = new bool[_channels];
27 for ( int i = 0; i < channels; ++i )
28 { _values[i] = 0;
29 _dirty[i] = true;
30 }
31
32 // we draw everything alone
33 setBackgroundMode( QWidget::NoBackground );
34}
35
36
37void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c )
38{
39 p->setPen( c.light() );
40 p->drawPoint( x++, y );
41 p->setPen( c );
42 p->drawLine( x, y, x+width-2, y );
43 p->setPen( c.dark() );
44 p->drawPoint( x+width-1, y );
45}
46
47
48void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight )
49{
50/* int h1 = 133; int h2 = 0;
51 int s1 = 200; int s2 = 255;
52 int v1 = 140; int v2 = 255; */
53
54 int h1 = 196; int h2 = 194;
55 int s1 = 85; int s2 = 15;
56 int v1 = 95; int v2 = 237;
57
58 QColor c( 120, 60, 200 );
59 for ( int i = 0; i < height; ++i )
60 {
61 int h = (h2-h1)*i/maxheight + h1;
62 int s = (s2-s1)*i/maxheight + s1;
63 int v = (v2-v1)*i/maxheight + v1;
64 drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) );
65 }
66
67 /*for ( int i = height; i < maxheight; ++i )
68 drawLine( p, x, y-i, width, QColor( 47, 68, 76 ) );*/
69
70}
71
72
73void MFrequencySpectrum::paintEvent( QPaintEvent* e )
74{
75 QPixmap pm( size() );
76 QPainter p;
77 p.begin( &pm );
78 p.drawTiledPixmap( 0, 0, size().width(), size().height(), QPixmap( (const char**) &background ) );
79
80 int xmargin = 5;
81 int ymargin = 2;
82 int y = size().height() - 2 * ymargin;
83 int x = 0;
84 int width = ( size().width() - 2 * xmargin ) / _channels;
85
86 for ( int i = 0; i < _channels; ++i )
87 {
88 if ( _dirty[i] )
89 {
90 drawBar( &p, xmargin + x, y - ymargin, width-3, _values[i]*y/100, y );
91 _dirty[i] = false;
92 }
93 x+= width;
94 }
95
96 p.end();
97 bitBlt( this, 0, 0, &pm );
98}
99
100
101Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f )
102 :QFrame( parent, name, f ), _channels( channels )
103{
104 setLineWidth( 2 );
105 setFrameStyle( Panel + Sunken );
106 setFixedHeight( 16 );
107
108}
109
110
111void Legende::drawContents( QPainter* p )
112{
113 int xmargin = 5;
114 int ymargin = 2;
115 int x = 0;
116 int width = ( contentsRect().width() - 2 * xmargin ) / _channels;
117
118 for ( int i = 0; i < _channels; ++i )
119 p->drawText( xmargin + (width*i), 12, QString().sprintf( "%02d", i+1 ) );
120}
121
122
123MGraphWindow::MGraphWindow( QWidget* parent, const char* name, WFlags f )
124 :QVBox( parent, name, f )
125{
126 spectrum = new MFrequencySpectrum( 14, this );
127 legende = new Legende( 14, this );
128 startTimer( 50 );
129
130 //testGraph();
131
132};
133
134
135void MGraphWindow::testGraph()
136{
137 static int i = 0;
138 spectrum->setValue( i++, 100 );
139 if ( i == 14 ) i = 0;
140 QTimer::singleShot( 2000, this, SLOT( testGraph() ) );
141
142}
143
144
145void MGraphWindow::timerEvent( QTimerEvent* e )
146{
147 for ( int i = 0; i < 14; i++ )
148 {
149 spectrum->decrease( i, 4 );
150 }
151 spectrum->repaint();
152}
153
154
155void MGraphWindow::traffic( int channel, int signal )
156{
157 spectrum->setValue( channel-1, signal );
158}
159
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 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#ifndef GRAPHWINDOW_H
17#define GRAPHWINDOW_H
18
19#include <qwidget.h>
20#include <qvbox.h>
21
22class MFrequencySpectrum : public QWidget
23{
24 public:
25 MFrequencySpectrum( int channels, QWidget* parent = 0, const char* name = "MFrequencySpectrum", WFlags f = 0 );
26 int value( int channel ) const { return _values[channel]; };
27 void setValue( int channel, int value )
28 {
29 if ( value > _values[channel] )
30 {
31 _values[channel] = value;
32 _dirty[channel] = true;
33 }
34 };
35 void decrease( int channel, int amount )
36 {
37 if ( _values[channel] >= amount )
38 {
39 _values[channel] -= amount;
40 _dirty[channel] = true;
41 }
42 };
43
44 protected:
45 virtual void paintEvent( QPaintEvent* );
46
47 void drawLine( QPainter* p, int x, int y, int width, const QColor& c );
48 void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight );
49
50 private:
51 int _channels;
52 int* _values;
53 bool* _dirty;
54};
55
56
57class Legende : public QFrame
58{
59 public:
60 Legende( int channels, QWidget* parent = 0, const char* name = "Legende", WFlags f = 0 );
61
62 protected:
63 virtual void drawContents( QPainter* );
64
65 private:
66 int _channels;
67};
68
69
70class MGraphWindow : public QVBox
71{
72 Q_OBJECT
73
74 public:
75 MGraphWindow( QWidget* parent = 0, const char* name = "MGraphWindow", WFlags f = 0 );
76 void traffic( int channel, int signal );
77
78 protected:
79 virtual void timerEvent( QTimerEvent* e );
80
81 protected slots:
82 virtual void testGraph();
83
84 protected:
85 MFrequencySpectrum* spectrum;
86 Legende* legende;
87
88};
89
90/* XPM */
91static char * background[] = {
92"16 16 6 1",
93 " c None",
94 ".c #52676E",
95 "+c #3F545B",
96 "@c #394E56",
97 "#c #2F454C",
98 "$c #364B52",
99".+++++++++++++++",
100"@###############",
101"+$$$$$$$$$$$$$$$",
102"@###############",
103"+$$$$$$$$$$$$$$$",
104"@###############",
105"+$$$$$$$$$$$$$$$",
106"@###############",
107"+$$$$$$$$$$$$$$$",
108"@###############",
109"+$$$$$$$$$$$$$$$",
110"@###############",
111"+$$$$$$$$$$$$$$$",
112"@###############",
113"+$$$$$$$$$$$$$$$",
114"@###############"};
115
116
117#endif
118
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
@@ -12,7 +12,8 @@ HEADERS = wellenreiterbase.h \
12 hexwindow.h \ 12 hexwindow.h \
13 statwindow.h \ 13 statwindow.h \
14 configwindow.h \ 14 configwindow.h \
15 manufacturers.h 15 manufacturers.h \
16 graphwindow.h
16 17
17SOURCES = main.cpp \ 18SOURCES = main.cpp \
18 mainwindow.cpp \ 19 mainwindow.cpp \
@@ -23,7 +24,8 @@ SOURCES = main.cpp \
23 hexwindow.cpp \ 24 hexwindow.cpp \
24 statwindow.cpp \ 25 statwindow.cpp \
25 configwindow.cpp \ 26 configwindow.cpp \
26 manufacturers.cpp 27 manufacturers.cpp \
28 graphwindow.cpp
27 29
28INCLUDEPATH += $(OPIEDIR)/include 30INCLUDEPATH += $(OPIEDIR)/include
29DEPENDPATH += $(OPIEDIR)/include 31DEPENDPATH += $(OPIEDIR)/include
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
@@ -58,6 +58,7 @@ using namespace Opie;
58#include "hexwindow.h" 58#include "hexwindow.h"
59#include "configwindow.h" 59#include "configwindow.h"
60#include "statwindow.h" 60#include "statwindow.h"
61#include "graphwindow.h"
61#include "manufacturers.h" 62#include "manufacturers.h"
62 63
63Wellenreiter::Wellenreiter( QWidget* parent ) 64Wellenreiter::Wellenreiter( QWidget* parent )
@@ -166,6 +167,12 @@ void Wellenreiter::receivePacket(OPacket* p)
166 167
167 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 168 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
168 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); 169 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 );
170
171 // do we have a prism header?
172 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
173 if ( ds && prism )
174 graphwindow->traffic( ds->channel(), prism->signalStrength() );
175
169 return; 176 return;
170 } 177 }
171 178
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
@@ -31,6 +31,7 @@
31#include "hexwindow.h" 31#include "hexwindow.h"
32#include "scanlist.h" 32#include "scanlist.h"
33#include "statwindow.h" 33#include "statwindow.h"
34#include "graphwindow.h"
34 35
35#ifdef QWS 36#ifdef QWS
36#include <qpe/resource.h> 37#include <qpe/resource.h>
@@ -79,6 +80,10 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f
79 netview = new MScanListView( ap ); 80 netview = new MScanListView( ap );
80 apLayout->addWidget( netview ); 81 apLayout->addWidget( netview );
81 82
83 //--------- GRAPH TAB --------------
84
85 graphwindow = new MGraphWindow( TabWidget, "Graph" );
86
82 //--------- LOG TAB -------------- 87 //--------- LOG TAB --------------
83 88
84 logwindow = new MLogWindow( TabWidget, "Log" ); 89 logwindow = new MLogWindow( TabWidget, "Log" );
@@ -129,12 +134,14 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f
129 134
130#ifdef QWS 135#ifdef QWS
131 TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); 136 TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) );
137 TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) );
132 TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); 138 TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) );
133 TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); 139 TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) );
134 TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); 140 TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) );
135 TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); 141 TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) );
136#else 142#else
137 TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); 143 TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) );
144 TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) );
138 TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); 145 TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) );
139 TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); 146 TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) );
140 TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); 147 TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) );
@@ -171,7 +178,7 @@ bool WellenreiterBase::event( QEvent* ev )
171 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); 178 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() );
172 TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); 179 TextLabel1_4_2_font.setFamily( "adobe-helvetica" );
173 TextLabel1_4_2_font.setPointSize( 10 ); 180 TextLabel1_4_2_font.setPointSize( 10 );
174 TextLabel1_4_2->setFont( TextLabel1_4_2_font ); 181 TextLabel1_4_2->setFont( TextLabel1_4_2_font );
175 } 182 }
176 return ret; 183 return ret;
177} 184}
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
@@ -28,6 +28,7 @@ class QPushButton;
28class MLogWindow; 28class MLogWindow;
29class MHexWindow; 29class MHexWindow;
30class MStatWindow; 30class MStatWindow;
31class MGraphWindow;
31 32
32#ifdef QWS 33#ifdef QWS
33class OTabWidget; 34class OTabWidget;
@@ -53,6 +54,7 @@ public:
53 MLogWindow* logwindow; 54 MLogWindow* logwindow;
54 MHexWindow* hexwindow; 55 MHexWindow* hexwindow;
55 MStatWindow* statwindow; 56 MStatWindow* statwindow;
57 MGraphWindow* graphwindow;
56 QWidget* about; 58 QWidget* about;
57 QLabel* PixmapLabel1_3_2; 59 QLabel* PixmapLabel1_3_2;
58 QLabel* TextLabel1_4_2; 60 QLabel* TextLabel1_4_2;
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
@@ -4,7 +4,7 @@ Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: 0.9.9-$SUB_VERSION
8Depends: task-opie-minimal, libpcap0, libopie2 (1.8.1) 8Depends: task-opie-minimal, libpcap0, libopie2 (1.8.1)
9Description: A WaveLAN Network Monitor 9Description: A WaveLAN Network Monitor
10 A WaveLAN Network Monitor/Sniffer for the Opie Environment. 10 A WaveLAN Network Monitor/Sniffer for the Opie Environment.