summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/gps.cpp29
-rw-r--r--noncore/net/wellenreiter/gui/gps.h12
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp11
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp21
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h6
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp8
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.cpp4
7 files changed, 64 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp
index 3206655..288afee 100644
--- a/noncore/net/wellenreiter/gui/gps.cpp
+++ b/noncore/net/wellenreiter/gui/gps.cpp
@@ -1,66 +1,69 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "gps.h" 16#include "gps.h"
17#include <unistd.h> 17#include <unistd.h>
18
19#include <qtextstream.h>
20
18GPS::GPS( QObject* parent, const char * name ) 21GPS::GPS( QObject* parent, const char * name )
19 :QObject( parent, name ) 22 :QObject( parent, name )
20{ 23{
21 qDebug( "GPS::GPS()" ); 24 qDebug( "GPS::GPS()" );
22 _socket = new QSocket( this, "gpsd commsock" ); 25 _socket = new QSocket( this, "gpsd commsock" );
23} 26}
24 27
25 28
26GPS::~GPS() 29GPS::~GPS()
27{ 30{
28 qDebug( "GPS::~GPS()" ); 31 qDebug( "GPS::~GPS()" );
29} 32}
30 33
31 34
32bool GPS::open( const QString& host, int port ) 35bool GPS::open( const QString& host, int port )
33{ 36{
34 _socket->connectToHost( host, port ); 37 _socket->connectToHost( host, port );
35} 38}
36 39
37 40
38float GPS::latitude() const 41GpsLocation GPS::position() const
39{ 42{
40 char buf[256]; 43 char buf[256];
41 44
42 int result = _socket->writeBlock( "p\r\n", 3 ); 45 int result = _socket->writeBlock( "p\r\n", 3 );
43 _socket->flush(); 46 _socket->flush();
44 if ( result ) 47 if ( result )
45 { 48 {
46 int numAvail = _socket->bytesAvailable(); 49 int numAvail = _socket->bytesAvailable();
47 qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); 50 qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail );
48 if ( numAvail ) 51 if ( numAvail )
49 { 52 {
53 QTextStream stream( _socket );
50 54
51 int num = _socket->readLine( &buf[0], sizeof buf ); 55 QString str;
52 if ( num ) 56 stream.readRawBytes( &buf[0], 7 );
53 { 57 float lat = -111.111;
54 qDebug( "GPS got %d bytes ['%s']", num, &buf[0] ); 58 stream >> lat;
55 return 0.0; 59 stream.skipWhiteSpace();
56 } 60 float lon = -111.111;
61 stream >> lon;
62 stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF
63
64 return GpsLocation( lat, lon );
57 } 65 }
58 } 66 }
59 return -1.0; 67 return GpsLocation( -1.0, -1.0 );
60}
61
62
63float GPS::longitute() const
64{
65} 68}
66 69
diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h
index ad0b6de..8143fe4 100644
--- a/noncore/net/wellenreiter/gui/gps.h
+++ b/noncore/net/wellenreiter/gui/gps.h
@@ -1,38 +1,46 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef GPS_H 16#ifndef GPS_H
17#define GPS_H 17#define GPS_H
18 18
19#include <qobject.h> 19#include <qobject.h>
20#include <qsocket.h> 20#include <qsocket.h>
21 21
22struct GpsLocation
23{
24 GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {};
25 ~GpsLocation() {};
26 float latitude;
27 float longitude;
28};
29
30
22class GPS : public QObject 31class GPS : public QObject
23{ 32{
24 Q_OBJECT 33 Q_OBJECT
25 34
26 public: 35 public:
27 GPS( QObject* parent = 0, const char * name = "GPS" ); 36 GPS( QObject* parent = 0, const char * name = "GPS" );
28 ~GPS(); 37 ~GPS();
29 38
30 bool open( const QString& host = "localhost", int port = 2947 ); 39 bool open( const QString& host = "localhost", int port = 2947 );
31 float latitude() const; 40 GpsLocation position() const;
32 float longitute() const;
33 41
34 private: 42 private:
35 QSocket* _socket; 43 QSocket* _socket;
36}; 44};
37 45
38#endif // GPS_H 46#endif // GPS_H
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 27ecae3..868b0b0 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,366 +1,367 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "configwindow.h" 16#include "configwindow.h"
17#include "gps.h"
17#include "logwindow.h" 18#include "logwindow.h"
18#include "hexwindow.h" 19#include "hexwindow.h"
19#include "mainwindow.h" 20#include "mainwindow.h"
20#include "wellenreiter.h" 21#include "wellenreiter.h"
21#include "scanlist.h" 22#include "scanlist.h"
22 23
23#include <qcombobox.h> 24#include <qcombobox.h>
24#include <qdatastream.h> 25#include <qdatastream.h>
25#include <qfile.h> 26#include <qfile.h>
26#include <qfileinfo.h> 27#include <qfileinfo.h>
27#include <qiconset.h> 28#include <qiconset.h>
28#include <qmenubar.h> 29#include <qmenubar.h>
29#include <qmessagebox.h> 30#include <qmessagebox.h>
30#include <qpopupmenu.h> 31#include <qpopupmenu.h>
31#include <qstatusbar.h> 32#include <qstatusbar.h>
32#include <qtextstream.h> 33#include <qtextstream.h>
33#include <qtoolbutton.h> 34#include <qtoolbutton.h>
34 35
35#ifdef QWS 36#ifdef QWS
36#include <qpe/resource.h> 37#include <qpe/resource.h>
37#include <opie/ofiledialog.h> 38#include <opie/ofiledialog.h>
38#else 39#else
39#include "resource.h" 40#include "resource.h"
40#include <qapplication.h> 41#include <qapplication.h>
41#include <qfiledialog.h> 42#include <qfiledialog.h>
42#endif 43#endif
43 44
44WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 45WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
45 :QMainWindow( parent, name, f ) 46 :QMainWindow( parent, name, f )
46{ 47{
47 cw = new WellenreiterConfigWindow( this ); 48 cw = new WellenreiterConfigWindow( this );
48 mw = new Wellenreiter( this ); 49 mw = new Wellenreiter( this );
49 mw->setConfigWindow( cw ); 50 mw->setConfigWindow( cw );
50 setCentralWidget( mw ); 51 setCentralWidget( mw );
51 52
52 // setup application icon 53 // setup application icon
53 54
54 #ifndef QWS 55 #ifndef QWS
55 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 56 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
56 setIconText( "Wellenreiter/X11" ); 57 setIconText( "Wellenreiter/X11" );
57 #endif 58 #endif
58 59
59 // setup icon sets 60 // setup icon sets
60 61
61 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); 62 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
62 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); 63 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
63 startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); 64 startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
64 stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); 65 stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
65 66
66 // setup tool buttons 67 // setup tool buttons
67 68
68 startButton = new QToolButton( 0 ); 69 startButton = new QToolButton( 0 );
69 #ifdef QWS 70 #ifdef QWS
70 startButton->setAutoRaise( true ); 71 startButton->setAutoRaise( true );
71 #endif 72 #endif
72 startButton->setIconSet( *startIconSet ); 73 startButton->setIconSet( *startIconSet );
73 startButton->setEnabled( false ); 74 startButton->setEnabled( false );
74 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); 75 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) );
75 76
76 stopButton = new QToolButton( 0 ); 77 stopButton = new QToolButton( 0 );
77 #ifdef QWS 78 #ifdef QWS
78 stopButton->setAutoRaise( true ); 79 stopButton->setAutoRaise( true );
79 #endif 80 #endif
80 stopButton->setIconSet( *stopIconSet ); 81 stopButton->setIconSet( *stopIconSet );
81 stopButton->setEnabled( false ); 82 stopButton->setEnabled( false );
82 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); 83 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) );
83 84
84 QToolButton* c = new QToolButton( 0 ); 85 QToolButton* c = new QToolButton( 0 );
85 #ifdef QWS 86 #ifdef QWS
86 c->setAutoRaise( true ); 87 c->setAutoRaise( true );
87 #endif 88 #endif
88 c->setIconSet( *infoIconSet ); 89 c->setIconSet( *infoIconSet );
89 c->setEnabled( false ); 90 c->setEnabled( false );
90 91
91 QToolButton* d = new QToolButton( 0 ); 92 QToolButton* d = new QToolButton( 0 );
92 #ifdef QWS 93 #ifdef QWS
93 d->setAutoRaise( true ); 94 d->setAutoRaise( true );
94 #endif 95 #endif
95 d->setIconSet( *settingsIconSet ); 96 d->setIconSet( *settingsIconSet );
96 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 97 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
97 98
98 // setup menu bar 99 // setup menu bar
99 100
100 int id; 101 int id;
101 102
102 QMenuBar* mb = menuBar(); 103 QMenuBar* mb = menuBar();
103 104
104 QPopupMenu* fileSave = new QPopupMenu( mb ); 105 QPopupMenu* fileSave = new QPopupMenu( mb );
105 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); 106 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) );
106 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); 107 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) );
107 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); 108 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) );
108 109
109 QPopupMenu* fileLoad = new QPopupMenu( mb ); 110 QPopupMenu* fileLoad = new QPopupMenu( mb );
110 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); 111 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) );
111 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 112 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
112 113
113 QPopupMenu* file = new QPopupMenu( mb ); 114 QPopupMenu* file = new QPopupMenu( mb );
114 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); 115 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) );
115 id = file->insertItem( tr( "&Load" ), fileLoad ); 116 id = file->insertItem( tr( "&Load" ), fileLoad );
116 file->insertItem( tr( "&Save" ), fileSave ); 117 file->insertItem( tr( "&Save" ), fileSave );
117 file->insertSeparator(); 118 file->insertSeparator();
118 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); 119 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) );
119 120
120 QPopupMenu* view = new QPopupMenu( mb ); 121 QPopupMenu* view = new QPopupMenu( mb );
121 view->insertItem( tr( "&Configure..." ) ); 122 view->insertItem( tr( "&Configure..." ) );
122 123
123 QPopupMenu* sniffer = new QPopupMenu( mb ); 124 QPopupMenu* sniffer = new QPopupMenu( mb );
124 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); 125 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) );
125 sniffer->insertSeparator(); 126 sniffer->insertSeparator();
126 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); 127 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) );
127 sniffer->setItemEnabled( startID, false ); 128 sniffer->setItemEnabled( startID, false );
128 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); 129 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) );
129 sniffer->setItemEnabled( stopID, false ); 130 sniffer->setItemEnabled( stopID, false );
130 131
131 QPopupMenu* demo = new QPopupMenu( mb ); 132 QPopupMenu* demo = new QPopupMenu( mb );
132 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); 133 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) );
133 134
134 id = mb->insertItem( tr( "&File" ), file ); 135 id = mb->insertItem( tr( "&File" ), file );
135 //id = mb->insertItem( tr( "&View" ), view ); 136 //id = mb->insertItem( tr( "&View" ), view );
136 //mb->setItemEnabled( id, false ); 137 //mb->setItemEnabled( id, false );
137 id = mb->insertItem( tr( "&Sniffer" ), sniffer ); 138 id = mb->insertItem( tr( "&Sniffer" ), sniffer );
138 139
139 id = mb->insertItem( tr( "&Demo" ), demo ); 140 id = mb->insertItem( tr( "&Demo" ), demo );
140 mb->setItemEnabled( id, true ); 141 mb->setItemEnabled( id, true );
141 142
142 #ifdef QWS 143 #ifdef QWS
143 mb->insertItem( startButton ); 144 mb->insertItem( startButton );
144 mb->insertItem( stopButton ); 145 mb->insertItem( stopButton );
145 mb->insertItem( c ); 146 mb->insertItem( c );
146 mb->insertItem( d ); 147 mb->insertItem( d );
147 #else // Qt3 changed the insertion order. It's now totally random :( 148 #else // Qt3 changed the insertion order. It's now totally random :(
148 mb->insertItem( d ); 149 mb->insertItem( d );
149 mb->insertItem( c ); 150 mb->insertItem( c );
150 mb->insertItem( stopButton ); 151 mb->insertItem( stopButton );
151 mb->insertItem( startButton ); 152 mb->insertItem( startButton );
152 #endif 153 #endif
153 154
154 updateToolButtonState(); 155 updateToolButtonState();
155 156
156 // setup status bar (for now only on X11) 157 // setup status bar (for now only on X11)
157 158
158 #ifndef QWS 159 #ifndef QWS
159 statusBar()->message( tr( "Ready." ) ); 160 statusBar()->message( tr( "Ready." ) );
160 #endif 161 #endif
161 162
162 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); 163 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) );
163 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); 164 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) );
164}; 165};
165 166
166 167
167 168
168void WellenreiterMainWindow::showConfigure() 169void WellenreiterMainWindow::showConfigure()
169{ 170{
170 qDebug( "show configure..." ); 171 qDebug( "show configure..." );
171 cw->setCaption( tr( "Configure" ) ); 172 cw->setCaption( tr( "Configure" ) );
172 #ifdef QWS 173 #ifdef QWS
173 cw->showMaximized(); 174 cw->showMaximized();
174 #endif 175 #endif
175 int result = cw->exec(); 176 int result = cw->exec();
176 177
177 if ( result ) updateToolButtonState(); 178 if ( result ) updateToolButtonState();
178} 179}
179 180
180 181
181 182
182void WellenreiterMainWindow::updateToolButtonState() 183void WellenreiterMainWindow::updateToolButtonState()
183{ 184{
184 const QString& interface = cw->interfaceName->currentText(); 185 const QString& interface = cw->interfaceName->currentText();
185 const int cardtype = cw->driverType(); 186 const int cardtype = cw->driverType();
186 187
187 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 188 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
188 { 189 {
189 startButton->setEnabled( true ); 190 startButton->setEnabled( true );
190 menuBar()->setItemEnabled( startID, true ); 191 menuBar()->setItemEnabled( startID, true );
191 } 192 }
192 else 193 else
193 { 194 {
194 startButton->setEnabled( false ); 195 startButton->setEnabled( false );
195 menuBar()->setItemEnabled( startID, false ); 196 menuBar()->setItemEnabled( startID, false );
196 } 197 }
197} 198}
198 199
199 200
200void WellenreiterMainWindow::changedSniffingState() 201void WellenreiterMainWindow::changedSniffingState()
201{ 202{
202 startButton->setEnabled( !mw->sniffing ); 203 startButton->setEnabled( !mw->sniffing );
203 menuBar()->setItemEnabled( startID, !mw->sniffing ); 204 menuBar()->setItemEnabled( startID, !mw->sniffing );
204 stopButton->setEnabled( mw->sniffing ); 205 stopButton->setEnabled( mw->sniffing );
205 menuBar()->setItemEnabled( stopID, mw->sniffing ); 206 menuBar()->setItemEnabled( stopID, mw->sniffing );
206} 207}
207 208
208 209
209WellenreiterMainWindow::~WellenreiterMainWindow() 210WellenreiterMainWindow::~WellenreiterMainWindow()
210{ 211{
211 delete infoIconSet; 212 delete infoIconSet;
212 delete settingsIconSet; 213 delete settingsIconSet;
213 delete startIconSet; 214 delete startIconSet;
214 delete stopIconSet; 215 delete stopIconSet;
215}; 216};
216 217
217void WellenreiterMainWindow::demoAddStations() 218void WellenreiterMainWindow::demoAddStations()
218{ 219{
219 //mw = 0; // test SIGSGV handling 220 //mw = 0; // test SIGSGV handling
220 221
221 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80 ); 222 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) );
222 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10 ); 223 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) );
223 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10 ); 224 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) );
224 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15 ); 225 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) );
225 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20 ); 226 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) );
226} 227}
227 228
228 229
229QString WellenreiterMainWindow::getFileName( bool save ) 230QString WellenreiterMainWindow::getFileName( bool save )
230{ 231{
231 QMap<QString, QStringList> map; 232 QMap<QString, QStringList> map;
232 map.insert( tr("All"), QStringList() ); 233 map.insert( tr("All"), QStringList() );
233 QStringList text; 234 QStringList text;
234 text << "text/*"; 235 text << "text/*";
235 map.insert( tr("Text"), text ); 236 map.insert( tr("Text"), text );
236 text << "*"; 237 text << "*";
237 map.insert( tr("All"), text ); 238 map.insert( tr("All"), text );
238 239
239 QString str; 240 QString str;
240 if ( save ) 241 if ( save )
241 { 242 {
242 #ifdef QWS 243 #ifdef QWS
243 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 244 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
244 #else 245 #else
245 str = QFileDialog::getSaveFileName(); 246 str = QFileDialog::getSaveFileName();
246 #endif 247 #endif
247 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) 248 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ )
248 return ""; 249 return "";
249 } 250 }
250 else 251 else
251 { 252 {
252 #ifdef QWS 253 #ifdef QWS
253 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 254 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
254 #else 255 #else
255 str = QFileDialog::getOpenFileName(); 256 str = QFileDialog::getOpenFileName();
256 #endif 257 #endif
257 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 258 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
258 return ""; 259 return "";
259 } 260 }
260 return str; 261 return str;
261} 262}
262 263
263 264
264void WellenreiterMainWindow::fileSaveLog() 265void WellenreiterMainWindow::fileSaveLog()
265{ 266{
266 QString fname = getFileName( true ); 267 QString fname = getFileName( true );
267 if ( !fname.isEmpty() ) 268 if ( !fname.isEmpty() )
268 { 269 {
269 QFile f( fname ); 270 QFile f( fname );
270 if ( f.open(IO_WriteOnly) ) 271 if ( f.open(IO_WriteOnly) )
271 { 272 {
272 QTextStream t( &f ); 273 QTextStream t( &f );
273 t << mw->logWindow()->getLog(); 274 t << mw->logWindow()->getLog();
274 f.close(); 275 f.close();
275 qDebug( "Saved log to file '%s'", (const char*) fname ); 276 qDebug( "Saved log to file '%s'", (const char*) fname );
276 } 277 }
277 else 278 else
278 { 279 {
279 qDebug( "Problem saving log to file '%s'", (const char*) fname ); 280 qDebug( "Problem saving log to file '%s'", (const char*) fname );
280 } 281 }
281 } 282 }
282} 283}
283 284
284void WellenreiterMainWindow::fileSaveSession() 285void WellenreiterMainWindow::fileSaveSession()
285{ 286{
286 QString fname = getFileName( true ); 287 QString fname = getFileName( true );
287 if ( !fname.isEmpty() ) 288 if ( !fname.isEmpty() )
288 { 289 {
289 290
290 QFile f( fname ); 291 QFile f( fname );
291 if ( f.open(IO_WriteOnly) ) 292 if ( f.open(IO_WriteOnly) )
292 { 293 {
293 QDataStream t( &f ); 294 QDataStream t( &f );
294 t << *mw->netView(); 295 t << *mw->netView();
295 f.close(); 296 f.close();
296 qDebug( "Saved session to file '%s'", (const char*) fname ); 297 qDebug( "Saved session to file '%s'", (const char*) fname );
297 } 298 }
298 else 299 else
299 { 300 {
300 qDebug( "Problem saving session to file '%s'", (const char*) fname ); 301 qDebug( "Problem saving session to file '%s'", (const char*) fname );
301 } 302 }
302 } 303 }
303} 304}
304 305
305void WellenreiterMainWindow::fileSaveHex() 306void WellenreiterMainWindow::fileSaveHex()
306{ 307{
307 QString fname = getFileName( true ); 308 QString fname = getFileName( true );
308 if ( !fname.isEmpty() ) 309 if ( !fname.isEmpty() )
309 { 310 {
310 QFile f( fname ); 311 QFile f( fname );
311 if ( f.open(IO_WriteOnly) ) 312 if ( f.open(IO_WriteOnly) )
312 { 313 {
313 QTextStream t( &f ); 314 QTextStream t( &f );
314 t << mw->hexWindow()->getLog(); 315 t << mw->hexWindow()->getLog();
315 f.close(); 316 f.close();
316 qDebug( "Saved hex log to file '%s'", (const char*) fname ); 317 qDebug( "Saved hex log to file '%s'", (const char*) fname );
317 } 318 }
318 else 319 else
319 { 320 {
320 qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); 321 qDebug( "Problem saving hex log to file '%s'", (const char*) fname );
321 } 322 }
322 } 323 }
323} 324}
324 325
325void WellenreiterMainWindow::fileLoadSession() 326void WellenreiterMainWindow::fileLoadSession()
326{ 327{
327 QString fname = getFileName( false ); 328 QString fname = getFileName( false );
328 if ( !fname.isEmpty() ) 329 if ( !fname.isEmpty() )
329 { 330 {
330 QFile f( fname ); 331 QFile f( fname );
331 if ( f.open(IO_ReadOnly) ) 332 if ( f.open(IO_ReadOnly) )
332 { 333 {
333 QDataStream t( &f ); 334 QDataStream t( &f );
334 t >> *mw->netView(); 335 t >> *mw->netView();
335 f.close(); 336 f.close();
336 qDebug( "Loaded session from file '%s'", (const char*) fname ); 337 qDebug( "Loaded session from file '%s'", (const char*) fname );
337 } 338 }
338 else 339 else
339 { 340 {
340 qDebug( "Problem loading session from file '%s'", (const char*) fname ); 341 qDebug( "Problem loading session from file '%s'", (const char*) fname );
341 } 342 }
342 } 343 }
343} 344}
344 345
345void WellenreiterMainWindow::fileNew() 346void WellenreiterMainWindow::fileNew()
346{ 347{
347 mw->netView()->clear(); 348 mw->netView()->clear();
348 mw->logWindow()->clear(); 349 mw->logWindow()->clear();
349 mw->hexWindow()->clear(); 350 mw->hexWindow()->clear();
350} 351}
351 352
352void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) 353void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
353{ 354{
354 if ( mw->isDaemonRunning() ) 355 if ( mw->isDaemonRunning() )
355 { 356 {
356 QMessageBox::warning( this, "Wellenreiter/Opie", 357 QMessageBox::warning( this, "Wellenreiter/Opie",
357 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); 358 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) );
358 e->ignore(); 359 e->ignore();
359 } 360 }
360 else 361 else
361 { 362 {
362 QMainWindow::closeEvent( e ); 363 QMainWindow::closeEvent( e );
363 } 364 }
364} 365}
365 366
366 367
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index f4cfe52..d695c17 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,495 +1,514 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "scanlist.h" 16#include "scanlist.h"
17#include "configwindow.h" 17#include "configwindow.h"
18#include "logwindow.h" 18#include "logwindow.h"
19 19
20#include <assert.h> 20#include <assert.h>
21#include <qcursor.h> 21#include <qcursor.h>
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qtextstream.h> 23#include <qtextstream.h>
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <opie/odevice.h> 28#include <opie/odevice.h>
29using namespace Opie; 29using namespace Opie;
30#endif 30#endif
31 31
32 32
33#ifdef QWS 33#ifdef QWS
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#else 35#else
36#include "resource.h" 36#include "resource.h"
37#endif 37#endif
38 38
39const int col_type = 0; 39const int col_type = 0;
40const int col_essid = 0; 40const int col_essid = 0;
41const int col_sig = 1; 41const int col_sig = 1;
42const int col_ap = 2; 42const int col_ap = 2;
43const int col_channel = 3; 43const int col_channel = 3;
44const int col_wep = 4; 44const int col_wep = 4;
45const int col_traffic = 5; 45const int col_traffic = 5;
46const int col_ip = 6; 46const int col_ip = 6;
47const int col_manuf = 7; 47const int col_manuf = 7;
48const int col_firstseen = 8; 48const int col_firstseen = 8;
49const int col_lastseen = 9; 49const int col_lastseen = 9;
50const int col_location = 10;
50 51
51MScanListView::MScanListView( QWidget* parent, const char* name ) 52MScanListView::MScanListView( QWidget* parent, const char* name )
52 :OListView( parent, name ) 53 :OListView( parent, name )
53{ 54{
54 55
55 setFrameShape( QListView::StyledPanel ); 56 setFrameShape( QListView::StyledPanel );
56 setFrameShadow( QListView::Sunken ); 57 setFrameShadow( QListView::Sunken );
57 58
58 addColumn( tr( "Net/Station" ) ); 59 addColumn( tr( "Net/Station" ) );
59 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 60 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
60 addColumn( tr( "#" ) ); 61 addColumn( tr( "#" ) );
61 setColumnAlignment( col_sig, AlignCenter ); 62 setColumnAlignment( col_sig, AlignCenter );
62 addColumn( tr( "MAC" ) ); 63 addColumn( tr( "MAC" ) );
63 setColumnAlignment( col_ap, AlignCenter ); 64 setColumnAlignment( col_ap, AlignCenter );
64 addColumn( tr( "Chn" ) ); 65 addColumn( tr( "Chn" ) );
65 setColumnAlignment( col_channel, AlignCenter ); 66 setColumnAlignment( col_channel, AlignCenter );
66 addColumn( tr( "W" ) ); 67 addColumn( tr( "W" ) );
67 setColumnAlignment( col_wep, AlignCenter ); 68 setColumnAlignment( col_wep, AlignCenter );
68 addColumn( tr( "T" ) ); 69 addColumn( tr( "T" ) );
69 setColumnAlignment( col_traffic, AlignCenter ); 70 setColumnAlignment( col_traffic, AlignCenter );
70 addColumn( tr( "IP" ) ); 71 addColumn( tr( "IP" ) );
71 setColumnAlignment( col_ip, AlignCenter ); 72 setColumnAlignment( col_ip, AlignCenter );
72 addColumn( tr( "Manufacturer" ) ); 73 addColumn( tr( "Manufacturer" ) );
73 setColumnAlignment( col_manuf, AlignCenter ); 74 setColumnAlignment( col_manuf, AlignCenter );
74 addColumn( tr( "First Seen" ) ); 75 addColumn( tr( "First Seen" ) );
75 setColumnAlignment( col_firstseen, AlignCenter ); 76 setColumnAlignment( col_firstseen, AlignCenter );
76 addColumn( tr( "Last Seen" ) ); 77 addColumn( tr( "Last Seen" ) );
77 setColumnAlignment( col_lastseen, AlignCenter ); 78 setColumnAlignment( col_lastseen, AlignCenter );
79 addColumn( tr( "Location" ) );
80 setColumnAlignment( col_location, AlignCenter );
78 setRootIsDecorated( true ); 81 setRootIsDecorated( true );
79 setAllColumnsShowFocus( true ); 82 setAllColumnsShowFocus( true );
80 83
81 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 84 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
82 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 85 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
83 86
84 #ifdef QWS 87 #ifdef QWS
85 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 88 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
86 #endif 89 #endif
87 90
88}; 91};
89 92
90 93
91MScanListView::~MScanListView() 94MScanListView::~MScanListView()
92{ 95{
93}; 96};
94 97
95 98
96OListViewItem* MScanListView::childFactory() 99OListViewItem* MScanListView::childFactory()
97{ 100{
98 return new MScanListItem( this ); 101 return new MScanListItem( this );
99} 102}
100 103
101 104
102void MScanListView::serializeTo( QDataStream& s) const 105void MScanListView::serializeTo( QDataStream& s) const
103{ 106{
104 qDebug( "serializing MScanListView" ); 107 qDebug( "serializing MScanListView" );
105 OListView::serializeTo( s ); 108 OListView::serializeTo( s );
106} 109}
107 110
108 111
109void MScanListView::serializeFrom( QDataStream& s) 112void MScanListView::serializeFrom( QDataStream& s)
110{ 113{
111 qDebug( "serializing MScanListView" ); 114 qDebug( "serializing MScanListView" );
112 OListView::serializeFrom( s ); 115 OListView::serializeFrom( s );
113} 116}
114 117
115 118
116void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) 119void MScanListView::addNewItem( const QString& type,
120 const QString& essid,
121 const OMacAddress& mac,
122 bool wep,
123 int channel,
124 int signal,
125 const GpsLocation& loc )
117{ 126{
118 QString macaddr = mac.toString(true); 127 QString macaddr = mac.toString(true);
119 128
120 #ifdef DEBUG 129 #ifdef DEBUG
121 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 130 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
122 (const char*) essid, (const char*) macaddr, channel ); 131 (const char*) essid, (const char*) macaddr, channel );
123 #endif 132 #endif
124 133
125 // search, if we already have seen this net 134 // search, if we already have seen this net
126 135
127 QString s; 136 QString s;
128 MScanListItem* network; 137 MScanListItem* network;
129 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 138 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
130 139
131 while ( item && ( item->text( col_essid ) != essid ) ) 140 while ( item && ( item->text( col_essid ) != essid ) )
132 { 141 {
133 #ifdef DEBUG 142 #ifdef DEBUG
134 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); 143 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
135 #endif 144 #endif
136 item = static_cast<MScanListItem*> ( item->nextSibling() ); 145 item = static_cast<MScanListItem*> ( item->nextSibling() );
137 } 146 }
138 if ( item ) 147 if ( item )
139 { 148 {
140 // we have already seen this net, check all childs if MAC exists 149 // we have already seen this net, check all childs if MAC exists
141 150
142 network = item; 151 network = item;
143 152
144 item = static_cast<MScanListItem*> ( item->firstChild() ); 153 item = static_cast<MScanListItem*> ( item->firstChild() );
145 assert( item ); // this shouldn't fail 154 assert( item ); // this shouldn't fail
146 155
147 while ( item && ( item->text( col_ap ) != macaddr ) ) 156 while ( item && ( item->text( col_ap ) != macaddr ) )
148 { 157 {
149 #ifdef DEBUG 158 #ifdef DEBUG
150 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); 159 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) );
151 #endif 160 #endif
152 item = static_cast<MScanListItem*> ( item->nextSibling() ); 161 item = static_cast<MScanListItem*> ( item->nextSibling() );
153 } 162 }
154 163
155 if ( item ) 164 if ( item )
156 { 165 {
157 // we have already seen this item, it's a dupe 166 // we have already seen this item, it's a dupe
158 #ifdef DEBUG 167 #ifdef DEBUG
159 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 168 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
160 #endif 169 #endif
161 item->receivedBeacon(); 170 item->receivedBeacon();
162 return; 171 return;
163 } 172 }
164 } 173 }
165 else 174 else
166 { 175 {
167 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 176 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
168 MLogWindow::logwindow()->log( s ); 177 MLogWindow::logwindow()->log( s );
169 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); 178 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 );
170 } 179 }
171 180
172 181
173 // insert new station as child from network 182 // insert new station as child from network
174 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 183 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
175 184
176 #ifdef DEBUG 185 #ifdef DEBUG
177 qDebug( "inserting new station %s", (const char*) macaddr ); 186 qDebug( "inserting new station %s", (const char*) macaddr );
178 #endif 187 #endif
179 188
180 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 189 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
181 station->setManufacturer( mac.manufacturer() ); 190 station->setManufacturer( mac.manufacturer() );
191 station->setLocation( loc.latitude, loc.longitude );
182 192
183 if ( type == "managed" ) 193 if ( type == "managed" )
184 { 194 {
185 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 195 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
186 } 196 }
187 else 197 else
188 { 198 {
189 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 199 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
190 } 200 }
191 MLogWindow::logwindow()->log( s ); 201 MLogWindow::logwindow()->log( s );
192 202
193} 203}
194 204
195 205
196void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 206void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
197{ 207{
198 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 208 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
199 209
200 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 210 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
201 { 211 {
202 #ifdef DEBUG 212 #ifdef DEBUG
203 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 213 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
204 #endif 214 #endif
205 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 215 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
206 } 216 }
207 217
208 if ( subitem ) 218 if ( subitem )
209 { 219 {
210 // we have already seen this item, it's a dupe 220 // we have already seen this item, it's a dupe
211 #ifdef DEBUG 221 #ifdef DEBUG
212 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); 222 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) );
213 #endif 223 #endif
214 subitem->receivedBeacon(); //FIXME: sent data bit 224 subitem->receivedBeacon(); //FIXME: sent data bit
215 return; 225 return;
216 } 226 }
217 227
218 // Hey, it seems to be a new item :-D 228 // Hey, it seems to be a new item :-D
219 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 229 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
220 station->setManufacturer( addr.manufacturer() ); 230 station->setManufacturer( addr.manufacturer() );
221 231
222 QString s; 232 QString s;
223 if ( type == "station" ) 233 if ( type == "station" )
224 { 234 {
225 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 235 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
226 } 236 }
227 else 237 else
228 { 238 {
229 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 239 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
230 } 240 }
231 MLogWindow::logwindow()->log( s ); 241 MLogWindow::logwindow()->log( s );
232} 242}
233 243
234 244
235void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) 245void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
236{ 246{
237 QString s; 247 QString s;
238 MScanListItem* network; 248 MScanListItem* network;
239 249
240 QListViewItemIterator it( this ); 250 QListViewItemIterator it( this );
241 while ( it.current() && 251 while ( it.current() &&
242 it.current()->text( col_ap ) != viaFrom.toString(true) && 252 it.current()->text( col_ap ) != viaFrom.toString(true) &&
243 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; 253 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it;
244 254
245 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 255 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
246 256
247 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations 257 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations
248 { 258 {
249 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); 259 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
250 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); 260 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to );
251 } 261 }
252 else 262 else
253 { 263 {
254 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); 264 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" );
255 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); 265 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" );
256 } 266 }
257} 267}
258 268
259 269
260void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 270void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
261{ 271{
262 QString s; 272 QString s;
263 MScanListItem* network; 273 MScanListItem* network;
264 274
265 QListViewItemIterator it( this ); 275 QListViewItemIterator it( this );
266 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 276 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
267 277
268 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 278 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
269 279
270 if ( item ) // AP has shown up yet, so just add our new "from" - station 280 if ( item ) // AP has shown up yet, so just add our new "from" - station
271 { 281 {
272 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); 282 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" );
273 } 283 }
274 else 284 else
275 { 285 {
276 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); 286 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
277 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); 287 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
278 288
279 } 289 }
280} 290}
281 291
282 292
283void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 293void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
284{ 294{
285 QString s; 295 QString s;
286 MScanListItem* network; 296 MScanListItem* network;
287 297
288 QListViewItemIterator it( this ); 298 QListViewItemIterator it( this );
289 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 299 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
290 300
291 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 301 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
292 302
293 if ( item ) // AP has shown up yet, so just add our new "from" - station 303 if ( item ) // AP has shown up yet, so just add our new "from" - station
294 { 304 {
295 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); 305 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" );
296 } 306 }
297 else 307 else
298 { 308 {
299 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); 309 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
300 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); 310 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" );
301 } 311 }
302} 312}
303 313
304 314
305void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 315void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
306{ 316{
307 qWarning( "D'oh! Not yet implemented..." ); 317 qWarning( "D'oh! Not yet implemented..." );
308 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); 318 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
309} 319}
310 320
311 321
312void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) 322void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
313{ 323{
314 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); 324 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip );
315 325
316 QListViewItemIterator it( this ); 326 QListViewItemIterator it( this );
317 for ( ; it.current(); ++it ) 327 for ( ; it.current(); ++it )
318 { 328 {
319 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 329 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
320 { 330 {
321 it.current()->setText( col_ip, ip ); 331 it.current()->setText( col_ip, ip );
322 return; 332 return;
323 } 333 }
324 } 334 }
325 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 335 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
326 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 336 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
327 (const char*) macaddr.toString(), (const char*) ip ) ); 337 (const char*) macaddr.toString(), (const char*) ip ) );
328} 338}
329 339
330 340
331void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) 341void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
332{ 342{
333 if ( !item ) return; 343 if ( !item ) return;
334 344
335 MScanListItem* itm = static_cast<MScanListItem*>( item ); 345 MScanListItem* itm = static_cast<MScanListItem*>( item );
336 346
337 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", 347 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
338 (const char*) itm->text(0), (const char*) itm->type, col ); 348 (const char*) itm->text(0), (const char*) itm->type, col );
339 349
340 if ( itm->type == "adhoc" || itm->type == "managed" ) 350 if ( itm->type == "adhoc" || itm->type == "managed" )
341 { 351 {
342 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); 352 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
343 353
344 QPopupMenu m( this ); 354 QPopupMenu m( this );
345 m.insertItem( entry, 37773, 0 ); 355 m.insertItem( entry, 37773, 0 );
346 int result = m.exec( QCursor::pos() ); 356 int result = m.exec( QCursor::pos() );
347 if ( result == 37773 ) 357 if ( result == 37773 )
348 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); 358 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
349 } 359 }
350} 360}
351 361
352//============================================================ 362//============================================================
353// MScanListItem 363// MScanListItem
354//============================================================ 364//============================================================
355 365
356MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 366MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
357 bool wep, int channel, int signal ) 367 bool wep, int channel, int signal )
358 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 368 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
359 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 369 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
360 _channel( channel ), _signal( signal ), _beacons( 1 ) 370 _channel( channel ), _signal( signal ), _beacons( 1 )
361{ 371{
362 #ifdef DEBUG 372 #ifdef DEBUG
363 qDebug( "creating scanlist item" ); 373 qDebug( "creating scanlist item" );
364 #endif 374 #endif
365 if ( WellenreiterConfigWindow::instance() && type == "network" ) 375 if ( WellenreiterConfigWindow::instance() && type == "network" )
366 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); 376 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() );
367 decorateItem( type, essid, macaddr, wep, channel, signal ); 377 decorateItem( type, essid, macaddr, wep, channel, signal );
368} 378}
369 379
370MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 380MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
371 bool wep, int channel, int signal ) 381 bool wep, int channel, int signal )
372 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 382 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
373{ 383{
374 #ifdef DEBUG 384 #ifdef DEBUG
375 qDebug( "creating scanlist item" ); 385 qDebug( "creating scanlist item" );
376 #endif 386 #endif
377 decorateItem( type, essid, macaddr, wep, channel, signal ); 387 decorateItem( type, essid, macaddr, wep, channel, signal );
378} 388}
379 389
380const QString& MScanListItem::essid() const 390const QString& MScanListItem::essid() const
381{ 391{
382 if ( type == "network" ) 392 if ( type == "network" )
383 return _essid; 393 return _essid;
384 else 394 else
385 return ( (MScanListItem*) parent() )->essid(); 395 return ( (MScanListItem*) parent() )->essid();
386} 396}
387 397
388OListViewItem* MScanListItem::childFactory() 398OListViewItem* MScanListItem::childFactory()
389{ 399{
390 return new MScanListItem( this ); 400 return new MScanListItem( this );
391} 401}
392 402
393void MScanListItem::serializeTo( QDataStream& s ) const 403void MScanListItem::serializeTo( QDataStream& s ) const
394{ 404{
395 #ifdef DEBUG 405 #ifdef DEBUG
396 qDebug( "serializing MScanListItem" ); 406 qDebug( "serializing MScanListItem" );
397 #endif 407 #endif
398 OListViewItem::serializeTo( s ); 408 OListViewItem::serializeTo( s );
399 409
400 s << _type; 410 s << _type;
401 s << (Q_UINT8) ( _wep ? 'y' : 'n' ); 411 s << (Q_UINT8) ( _wep ? 'y' : 'n' );
402} 412}
403 413
404void MScanListItem::serializeFrom( QDataStream& s ) 414void MScanListItem::serializeFrom( QDataStream& s )
405{ 415{
406 #ifdef DEBUG 416 #ifdef DEBUG
407 qDebug( "serializing MScanListItem" ); 417 qDebug( "serializing MScanListItem" );
408 #endif 418 #endif
409 OListViewItem::serializeFrom( s ); 419 OListViewItem::serializeFrom( s );
410 420
411 char wep; 421 char wep;
412 s >> _type; 422 s >> _type;
413 s >> (Q_UINT8) wep; 423 s >> (Q_UINT8) wep;
414 _wep = (wep == 'y'); 424 _wep = (wep == 'y');
415 425
416 QString name; 426 QString name;
417 name.sprintf( "wellenreiter/%s", (const char*) _type ); 427 name.sprintf( "wellenreiter/%s", (const char*) _type );
418 setPixmap( col_type, Resource::loadPixmap( name ) ); 428 setPixmap( col_type, Resource::loadPixmap( name ) );
419 if ( _wep ) 429 if ( _wep )
420 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 430 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
421 listView()->triggerUpdate(); 431 listView()->triggerUpdate();
422} 432}
423 433
424void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 434void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
425{ 435{
426 #ifdef DEBUG 436 #ifdef DEBUG
427 qDebug( "decorating scanlist item %s / %s / %s [%d]", 437 qDebug( "decorating scanlist item %s / %s / %s [%d]",
428 (const char*) type, 438 (const char*) type,
429 (const char*) essid, 439 (const char*) essid,
430 (const char*) macaddr, 440 (const char*) macaddr,
431 channel ); 441 channel );
432 #endif 442 #endif
433 443
434 // set icon for managed or adhoc mode 444 // set icon for managed or adhoc mode
435 QString name; 445 QString name;
436 name.sprintf( "wellenreiter/%s", (const char*) type ); 446 name.sprintf( "wellenreiter/%s", (const char*) type );
437 setPixmap( col_type, Resource::loadPixmap( name ) ); 447 setPixmap( col_type, Resource::loadPixmap( name ) );
438 448
439 // set icon for wep (wireless encryption protocol) 449 // set icon for wep (wireless encryption protocol)
440 if ( wep ) 450 if ( wep )
441 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 451 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
442 452
443 // set channel and signal text 453 // set channel and signal text
444 454
445 if ( signal != -1 ) 455 if ( signal != -1 )
446 setText( col_sig, QString::number( signal ) ); 456 setText( col_sig, QString::number( signal ) );
447 if ( channel != -1 ) 457 if ( channel != -1 )
448 setText( col_channel, QString::number( channel ) ); 458 setText( col_channel, QString::number( channel ) );
449 459
450 setText( col_firstseen, QTime::currentTime().toString() ); 460 setText( col_firstseen, QTime::currentTime().toString() );
451 //setText( col_lastseen, QTime::currentTime().toString() ); 461 //setText( col_lastseen, QTime::currentTime().toString() );
452 462
453 listView()->triggerUpdate(); 463 listView()->triggerUpdate();
454 464
455 this->type = type; 465 this->type = type;
456 _type = type; 466 _type = type;
457 _essid = essid; 467 _essid = essid;
458 _macaddr = macaddr; 468 _macaddr = macaddr;
459 _channel = channel; 469 _channel = channel;
460 _beacons = 1; 470 _beacons = 1;
461 _signal = 0; 471 _signal = 0;
462} 472}
463 473
464 474
465void MScanListItem::setManufacturer( const QString& manufacturer ) 475void MScanListItem::setManufacturer( const QString& manufacturer )
466{ 476{
467 setText( col_manuf, manufacturer ); 477 setText( col_manuf, manufacturer );
468} 478}
469 479
470 480
481void MScanListItem::setLocation( const float& latitude, const float& longitude )
482{
483 if ( latitude == 0.0 || longitude == 0.0 )
484 setText( col_location, "N/A" );
485 else
486 setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) );
487}
488
489
471void MScanListItem::playSound( const QString& sound ) const 490void MScanListItem::playSound( const QString& sound ) const
472{ 491{
473 #ifdef QWS 492 #ifdef QWS
474 if ( sound == "Ignore" ) return; 493 if ( sound == "Ignore" ) return;
475 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 494 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
476 else if ( sound == "Key" ) ODevice::inst()->keySound(); 495 else if ( sound == "Key" ) ODevice::inst()->keySound();
477 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 496 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
478 #endif 497 #endif
479} 498}
480 499
481 500
482void MScanListItem::receivedBeacon() 501void MScanListItem::receivedBeacon()
483{ 502{
484 _beacons++; 503 _beacons++;
485 #ifdef DEBUG 504 #ifdef DEBUG
486 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 505 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
487 #endif 506 #endif
488 setText( col_sig, QString::number( _beacons ) ); 507 setText( col_sig, QString::number( _beacons ) );
489 setText( col_lastseen, QTime::currentTime().toString() ); 508 setText( col_lastseen, QTime::currentTime().toString() );
490 509
491 MScanListItem* p = (MScanListItem*) parent(); 510 MScanListItem* p = (MScanListItem*) parent();
492 if ( p ) p->receivedBeacon(); 511 if ( p ) p->receivedBeacon();
493 512
494} 513}
495 514
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 5aba0d2..2703b6a 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -1,137 +1,141 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include "gps.h"
20
19/* OPIE */ 21/* OPIE */
20#include <opie2/olistview.h> 22#include <opie2/olistview.h>
21#include <opie2/onetutils.h> 23#include <opie2/onetutils.h>
22 24
23/* QT */ 25/* QT */
24#include <qtextstream.h> 26#include <qtextstream.h>
25 27
26class QString; 28class QString;
27class MScanListItem; 29class MScanListItem;
28 30
29class MScanListView: public OListView 31class MScanListView: public OListView
30{ 32{
31 Q_OBJECT 33 Q_OBJECT
32 34
33 public: 35 public:
34 MScanListView( QWidget* parent = 0, const char* name = 0 ); 36 MScanListView( QWidget* parent = 0, const char* name = 0 );
35 virtual ~MScanListView(); 37 virtual ~MScanListView();
36 38
37 virtual OListViewItem* childFactory(); 39 virtual OListViewItem* childFactory();
38 virtual void serializeTo( QDataStream& s ) const; 40 virtual void serializeTo( QDataStream& s ) const;
39 virtual void serializeFrom( QDataStream& s ); 41 virtual void serializeFrom( QDataStream& s );
40 42
41 public slots: 43 public slots:
42 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal ); 44 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location );
45
43 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 46 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
44 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 47 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
45 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); 48 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo );
46 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 49 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
47 50
48 void identify( const OMacAddress&, const QString& ipaddr ); 51 void identify( const OMacAddress&, const QString& ipaddr );
49 52
50 void contextMenuRequested( QListViewItem* item, const QPoint&, int ); 53 void contextMenuRequested( QListViewItem* item, const QPoint&, int );
51 54
52 signals: 55 signals:
53 void rightButtonClicked(QListViewItem*,const QPoint&,int); 56 void rightButtonClicked(QListViewItem*,const QPoint&,int);
54 void joinNetwork( const QString&, const QString&, int, const QString& ); 57 void joinNetwork( const QString&, const QString&, int, const QString& );
55 58
56 protected: 59 protected:
57 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); 60 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" );
58 61
59}; 62};
60 63
61//****************************** MScanListItem **************************************************************** 64//****************************** MScanListItem ****************************************************************
62 65
63class MScanListItem: public OListViewItem 66class MScanListItem: public OListViewItem
64{ 67{
65 public: 68 public:
66 MScanListItem::MScanListItem( QListView* parent, 69 MScanListItem::MScanListItem( QListView* parent,
67 QString type = "unknown", 70 QString type = "unknown",
68 QString essid = "unknown", 71 QString essid = "unknown",
69 QString macaddr = "unknown", 72 QString macaddr = "unknown",
70 bool wep = false, 73 bool wep = false,
71 int channel = 0, 74 int channel = 0,
72 int signal = 0 ); 75 int signal = 0 );
73 76
74 MScanListItem::MScanListItem( QListViewItem* parent, 77 MScanListItem::MScanListItem( QListViewItem* parent,
75 QString type = "unknown", 78 QString type = "unknown",
76 QString essid = "unknown", 79 QString essid = "unknown",
77 QString macaddr = "unknown", 80 QString macaddr = "unknown",
78 bool wep = false, 81 bool wep = false,
79 int channel = 0, 82 int channel = 0,
80 int signal = 0 ); 83 int signal = 0 );
81 84
82 85
83 protected: 86 protected:
84 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 87 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
85 88
86 public: 89 public:
87 QString type; 90 QString type;
88 91
89 public: 92 public:
90 //const QString& type() { return _type; }; 93 //const QString& type() { return _type; };
91 const QString& essid() const; 94 const QString& essid() const;
92 const QString& macaddr() { return _macaddr; }; 95 const QString& macaddr() { return _macaddr; };
93 bool wep() { return _wep; }; 96 bool wep() { return _wep; };
94 int channel() { return _channel; }; 97 int channel() { return _channel; };
95 int signal() { return _signal; }; 98 int signal() { return _signal; };
96 int beacons() { return _beacons; }; 99 int beacons() { return _beacons; };
97 100
98 void setSignal( int signal ) { /* TODO */ }; 101 void setSignal( int signal ) { /* TODO */ };
99 void receivedBeacon(); 102 void receivedBeacon();
100 103
101 void setManufacturer( const QString& manufacturer ); 104 void setManufacturer( const QString& manufacturer );
105 void setLocation( const float& latitude, const float& longitude );
102 106
103 virtual OListViewItem* childFactory(); 107 virtual OListViewItem* childFactory();
104 virtual void serializeTo( QDataStream& s ) const; 108 virtual void serializeTo( QDataStream& s ) const;
105 virtual void serializeFrom( QDataStream& s ); 109 virtual void serializeFrom( QDataStream& s );
106 110
107 protected: 111 protected:
108 void playSound( const QString& ) const; 112 void playSound( const QString& ) const;
109 113
110 private: 114 private:
111 QString _type; 115 QString _type;
112 QString _essid; 116 QString _essid;
113 QString _macaddr; 117 QString _macaddr;
114 bool _wep; 118 bool _wep;
115 int _channel; 119 int _channel;
116 int _signal; 120 int _signal;
117 int _beacons; 121 int _beacons;
118 122
119}; 123};
120 124
121//****************************** MScanListViewFactory **************************************************************** 125//****************************** MScanListViewFactory ****************************************************************
122 126
123/* 127/*
124 128
125class MScanListViewFactory : public OListViewFactory 129class MScanListViewFactory : public OListViewFactory
126{ 130{
127public: 131public:
128 virtual QListView* listViewFactory(); 132 virtual QListView* listViewFactory();
129 virtual QListViewItem* listViewItemFactory( QListView* lv ); 133 virtual QListViewItem* listViewItemFactory( QListView* lv );
130 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 134 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
131 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 135 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
132 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 136 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
133} 137}
134*/ 138*/
135 139
136#endif 140#endif
137 141
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index c03debb..5dc2e79 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,563 +1,565 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Local 16// Local
17 17
18#include "gps.h" 18#include "gps.h"
19#include "wellenreiter.h" 19#include "wellenreiter.h"
20#include "scanlist.h" 20#include "scanlist.h"
21#include "logwindow.h" 21#include "logwindow.h"
22#include "hexwindow.h" 22#include "hexwindow.h"
23#include "configwindow.h" 23#include "configwindow.h"
24#include "statwindow.h" 24#include "statwindow.h"
25#include "graphwindow.h" 25#include "graphwindow.h"
26#include "protolistview.h" 26#include "protolistview.h"
27 27
28// Opie 28// Opie
29 29
30#ifdef QWS 30#ifdef QWS
31#include <opie/odevice.h> 31#include <opie/odevice.h>
32#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
33using namespace Opie; 33using namespace Opie;
34#endif 34#endif
35 35
36#ifdef QWS 36#ifdef QWS
37#include <opie2/oapplication.h> 37#include <opie2/oapplication.h>
38#else 38#else
39#include <qapplication.h> 39#include <qapplication.h>
40#endif 40#endif
41#include <opie2/onetwork.h> 41#include <opie2/onetwork.h>
42#include <opie2/opcap.h> 42#include <opie2/opcap.h>
43 43
44// Qt 44// Qt
45 45
46#include <qcheckbox.h> 46#include <qcheckbox.h>
47#include <qcombobox.h> 47#include <qcombobox.h>
48#include <qdatetime.h> 48#include <qdatetime.h>
49#include <qpushbutton.h> 49#include <qpushbutton.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qobjectlist.h> 52#include <qobjectlist.h>
53#include <qregexp.h> 53#include <qregexp.h>
54#include <qspinbox.h> 54#include <qspinbox.h>
55#include <qtoolbutton.h> 55#include <qtoolbutton.h>
56#include <qmainwindow.h> 56#include <qmainwindow.h>
57 57
58// Standard 58// Standard
59 59
60#include <assert.h> 60#include <assert.h>
61#include <errno.h> 61#include <errno.h>
62#include <unistd.h> 62#include <unistd.h>
63#include <string.h> 63#include <string.h>
64#include <sys/types.h> 64#include <sys/types.h>
65#include <stdlib.h> 65#include <stdlib.h>
66 66
67Wellenreiter::Wellenreiter( QWidget* parent ) 67Wellenreiter::Wellenreiter( QWidget* parent )
68 : WellenreiterBase( parent, 0, 0 ), 68 : WellenreiterBase( parent, 0, 0 ),
69 sniffing( false ), iface( 0 ), configwindow( 0 ) 69 sniffing( false ), iface( 0 ), configwindow( 0 )
70{ 70{
71 71
72 logwindow->log( "(i) Wellenreiter has been started." ); 72 logwindow->log( "(i) Wellenreiter has been started." );
73 73
74 // 74 //
75 // detect operating system 75 // detect operating system
76 // 76 //
77 77
78 #ifdef QWS 78 #ifdef QWS
79 QString sys; 79 QString sys;
80 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 80 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
81 _system = ODevice::inst()->system(); 81 _system = ODevice::inst()->system();
82 logwindow->log( sys ); 82 logwindow->log( sys );
83 #endif 83 #endif
84 84
85 netview->setColumnWidthMode( 1, QListView::Manual ); 85 netview->setColumnWidthMode( 1, QListView::Manual );
86 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 86 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
87 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 87 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
88 pcap = new OPacketCapturer(); 88 pcap = new OPacketCapturer();
89 89
90 gps = new GPS( this ); 90 gps = new GPS( this );
91} 91}
92 92
93 93
94Wellenreiter::~Wellenreiter() 94Wellenreiter::~Wellenreiter()
95{ 95{
96 delete pcap; 96 delete pcap;
97} 97}
98 98
99 99
100void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 100void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
101{ 101{
102 configwindow = cw; 102 configwindow = cw;
103} 103}
104 104
105 105
106void Wellenreiter::channelHopped(int c) 106void Wellenreiter::channelHopped(int c)
107{ 107{
108 QString title = "Wellenreiter II -scan- ["; 108 QString title = "Wellenreiter II -scan- [";
109 QString left; 109 QString left;
110 if ( c > 1 ) left.fill( '.', c-1 ); 110 if ( c > 1 ) left.fill( '.', c-1 );
111 title.append( left ); 111 title.append( left );
112 title.append( '|' ); 112 title.append( '|' );
113 if ( c < iface->channels() ) 113 if ( c < iface->channels() )
114 { 114 {
115 QString right; 115 QString right;
116 right.fill( '.', iface->channels()-c ); 116 right.fill( '.', iface->channels()-c );
117 title.append( right ); 117 title.append( right );
118 } 118 }
119 title.append( "]" ); 119 title.append( "]" );
120 //title.append( QString().sprintf( " %02d", c ) ); 120 //title.append( QString().sprintf( " %02d", c ) );
121 assert( parent() ); 121 assert( parent() );
122 ( (QMainWindow*) parent() )->setCaption( title ); 122 ( (QMainWindow*) parent() )->setCaption( title );
123} 123}
124 124
125 125
126void Wellenreiter::handleNotification( OPacket* p ) 126void Wellenreiter::handleNotification( OPacket* p )
127{ 127{
128 QObjectList* l = p->queryList(); 128 QObjectList* l = p->queryList();
129 QObjectListIt it( *l ); 129 QObjectListIt it( *l );
130 QObject* o; 130 QObject* o;
131 131
132 while ( (o = it.current()) != 0 ) 132 while ( (o = it.current()) != 0 )
133 { 133 {
134 QString name = it.current()->name(); 134 QString name = it.current()->name();
135 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 135 if ( configwindow->parsePackets->isProtocolChecked( name ) )
136 { 136 {
137 QString action = configwindow->parsePackets->protocolAction( name ); 137 QString action = configwindow->parsePackets->protocolAction( name );
138 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 138 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
139 doAction( action, name, p ); 139 doAction( action, name, p );
140 } 140 }
141 else 141 else
142 { 142 {
143 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 143 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
144 } 144 }
145 ++it; 145 ++it;
146 } 146 }
147} 147}
148 148
149 149
150void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 150void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
151{ 151{
152 QString type; 152 QString type;
153 if ( beacon->canIBSS() ) 153 if ( beacon->canIBSS() )
154 { 154 {
155 type = "adhoc"; 155 type = "adhoc";
156 } 156 }
157 else if ( beacon->canESS() ) 157 else if ( beacon->canESS() )
158 { 158 {
159 type = "managed"; 159 type = "managed";
160 } 160 }
161 else 161 else
162 { 162 {
163 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 163 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
164 return; 164 return;
165 } 165 }
166 166
167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
168 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 168 QString essid = ssid ? ssid->ID() : QString("<unknown>");
169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
170 int channel = ds ? ds->channel() : -1; 170 int channel = ds ? ds->channel() : -1;
171 171
172 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 172 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
173 173
174 GpsLocation loc( 0, 0 );
174 if ( configwindow->enableGPS->isChecked() ) 175 if ( configwindow->enableGPS->isChecked() )
175 { 176 {
177 // TODO: add check if GPS is working!?
176 qDebug( "Wellenreiter::gathering GPS data..." ); 178 qDebug( "Wellenreiter::gathering GPS data..." );
177 float lat = gps->latitude(); 179 loc = gps->position();
178 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", lat, 0.0 ); 180 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude );
179 } 181 }
180 182
181 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); 183 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
182 184
183 // update graph window 185 // update graph window
184 if ( ds ) 186 if ( ds )
185 { 187 {
186 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 188 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
187 if ( prism ) 189 if ( prism )
188 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 190 graphwindow->traffic( ds->channel(), prism->signalStrength() );
189 else 191 else
190 graphwindow->traffic( ds->channel(), 95 ); 192 graphwindow->traffic( ds->channel(), 95 );
191 } 193 }
192} 194}
193 195
194 196
195void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) 197void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
196{ 198{
197 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 199 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
198 if ( wlan->fromDS() && !wlan->toDS() ) 200 if ( wlan->fromDS() && !wlan->toDS() )
199 { 201 {
200 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 202 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
201 } 203 }
202 else if ( !wlan->fromDS() && wlan->toDS() ) 204 else if ( !wlan->fromDS() && wlan->toDS() )
203 { 205 {
204 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 206 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
205 } 207 }
206 else if ( wlan->fromDS() && wlan->toDS() ) 208 else if ( wlan->fromDS() && wlan->toDS() )
207 { 209 {
208 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 210 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
209 } 211 }
210 else 212 else
211 { 213 {
212 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 214 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
213 } 215 }
214 216
215 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 217 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
216 if ( arp ) 218 if ( arp )
217 { 219 {
218 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 220 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
219 if ( arp->type() == "REQUEST" ) 221 if ( arp->type() == "REQUEST" )
220 { 222 {
221 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 223 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
222 } 224 }
223 else if ( arp->type() == "REPLY" ) 225 else if ( arp->type() == "REPLY" )
224 { 226 {
225 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 227 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
226 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 228 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
227 } 229 }
228 } 230 }
229 231
230 OIPPacket* ip = (OIPPacket*) p->child( "IP" ); 232 OIPPacket* ip = (OIPPacket*) p->child( "IP" );
231 if ( ip ) 233 if ( ip )
232 { 234 {
233 qDebug( "Received IP packet." ); 235 qDebug( "Received IP packet." );
234 } 236 }
235} 237}
236 238
237 239
238QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 240QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
239{ 241{
240 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 242 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
241 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 243 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
242 return 0; 244 return 0;
243 245
244 return p->child( protocol ); 246 return p->child( protocol );
245} 247}
246 248
247 249
248bool Wellenreiter::checkDumpPacket( OPacket* p ) 250bool Wellenreiter::checkDumpPacket( OPacket* p )
249{ 251{
250 // go through all child packets and see if one is inside the child hierarchy for p 252 // go through all child packets and see if one is inside the child hierarchy for p
251 // if so, do what the user requested (protocolAction), e.g. pass or discard 253 // if so, do what the user requested (protocolAction), e.g. pass or discard
252 if ( !configwindow->writeCaptureFile->isChecked() ) 254 if ( !configwindow->writeCaptureFile->isChecked() )
253 return false; 255 return false;
254 256
255 QObjectList* l = p->queryList(); 257 QObjectList* l = p->queryList();
256 QObjectListIt it( *l ); 258 QObjectListIt it( *l );
257 QObject* o; 259 QObject* o;
258 260
259 while ( (o = it.current()) != 0 ) 261 while ( (o = it.current()) != 0 )
260 { 262 {
261 QString name = it.current()->name(); 263 QString name = it.current()->name();
262 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 264 if ( configwindow->capturePackets->isProtocolChecked( name ) )
263 { 265 {
264 QString action = configwindow->capturePackets->protocolAction( name ); 266 QString action = configwindow->capturePackets->protocolAction( name );
265 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 267 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
266 if ( action == "Discard" ) 268 if ( action == "Discard" )
267 { 269 {
268 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 270 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
269 return false; 271 return false;
270 } 272 }
271 } 273 }
272 else 274 else
273 { 275 {
274 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 276 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
275 } 277 }
276 ++it; 278 ++it;
277 } 279 }
278 return true; 280 return true;
279} 281}
280 282
281 283
282void Wellenreiter::receivePacket( OPacket* p ) 284void Wellenreiter::receivePacket( OPacket* p )
283{ 285{
284 hexWindow()->log( p->dump( 8 ) ); 286 hexWindow()->log( p->dump( 8 ) );
285 287
286 if ( checkDumpPacket( p ) ) 288 if ( checkDumpPacket( p ) )
287 { 289 {
288 pcap->dump( p ); 290 pcap->dump( p );
289 } 291 }
290 292
291 // check if we received a beacon frame 293 // check if we received a beacon frame
292 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 294 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
293 if ( beacon && beacon->managementType() == "Beacon" ) 295 if ( beacon && beacon->managementType() == "Beacon" )
294 { 296 {
295 handleBeacon( p, beacon ); 297 handleBeacon( p, beacon );
296 return; 298 return;
297 } 299 }
298 300
299 //TODO: WEP check here 301 //TODO: WEP check here
300 302
301 // check for a data frame 303 // check for a data frame
302 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 304 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
303 if ( data ) 305 if ( data )
304 { 306 {
305 handleData( p, data ); 307 handleData( p, data );
306 } 308 }
307 309
308 handleNotification( p ); 310 handleNotification( p );
309 311
310} 312}
311 313
312 314
313void Wellenreiter::stopClicked() 315void Wellenreiter::stopClicked()
314{ 316{
315 if ( iface ) 317 if ( iface )
316 { 318 {
317 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 319 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
318 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 320 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
319 iface->setChannelHopping(); // stop hopping channels 321 iface->setChannelHopping(); // stop hopping channels
320 } 322 }
321 else 323 else
322 killTimers(); 324 killTimers();
323 325
324 pcap->close(); 326 pcap->close();
325 sniffing = false; 327 sniffing = false;
326 328
327 if ( iface ) 329 if ( iface )
328 { 330 {
329 // switch off monitor mode 331 // switch off monitor mode
330 iface->setMonitorMode( false ); 332 iface->setMonitorMode( false );
331 // switch off promisc flag 333 // switch off promisc flag
332 iface->setPromiscuousMode( false ); 334 iface->setPromiscuousMode( false );
333 335
334 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 336 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
335 } 337 }
336 338
337 logwindow->log( "(i) Stopped Scanning." ); 339 logwindow->log( "(i) Stopped Scanning." );
338 assert( parent() ); 340 assert( parent() );
339 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 341 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
340 342
341 // message the user 343 // message the user
342 QMessageBox::information( this, "Wellenreiter II", 344 QMessageBox::information( this, "Wellenreiter II",
343 tr( "Your wireless card\nshould now be usable again." ) ); 345 tr( "Your wireless card\nshould now be usable again." ) );
344 346
345 sniffing = false; 347 sniffing = false;
346 emit( stoppedSniffing() ); 348 emit( stoppedSniffing() );
347 349
348 // print out statistics 350 // print out statistics
349 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 351 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
350 statwindow->updateCounter( it.key(), it.data() ); 352 statwindow->updateCounter( it.key(), it.data() );
351} 353}
352 354
353 355
354void Wellenreiter::startClicked() 356void Wellenreiter::startClicked()
355{ 357{
356 // get configuration from config window 358 // get configuration from config window
357 359
358 const QString& interface = configwindow->interfaceName->currentText(); 360 const QString& interface = configwindow->interfaceName->currentText();
359 const int cardtype = configwindow->driverType(); 361 const int cardtype = configwindow->driverType();
360 const int interval = configwindow->hoppingInterval(); 362 const int interval = configwindow->hoppingInterval();
361 363
362 if ( ( interface == "" ) || ( cardtype == 0 ) ) 364 if ( ( interface == "" ) || ( cardtype == 0 ) )
363 { 365 {
364 QMessageBox::information( this, "Wellenreiter II", 366 QMessageBox::information( this, "Wellenreiter II",
365 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 367 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
366 return; 368 return;
367 } 369 }
368 370
369 // configure device 371 // configure device
370 ONetwork* net = ONetwork::instance(); 372 ONetwork* net = ONetwork::instance();
371 373
372 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 374 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
373 375
374 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 376 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
375 377
376 // bring device UP 378 // bring device UP
377 iface->setUp( true ); 379 iface->setUp( true );
378 if ( !iface->isUp() ) 380 if ( !iface->isUp() )
379 { 381 {
380 QMessageBox::warning( this, "Wellenreiter II", 382 QMessageBox::warning( this, "Wellenreiter II",
381 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 383 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
382 return; 384 return;
383 } 385 }
384 386
385 // set monitor mode 387 // set monitor mode
386 bool usePrism = configwindow->usePrismHeader(); 388 bool usePrism = configwindow->usePrismHeader();
387 389
388 switch ( cardtype ) 390 switch ( cardtype )
389 { 391 {
390 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 392 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
391 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 393 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
392 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 394 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
393 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 395 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
394 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 396 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
395 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 397 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
396 default: assert( 0 ); // shouldn't reach this 398 default: assert( 0 ); // shouldn't reach this
397 } 399 }
398 400
399 // switch device into monitor mode 401 // switch device into monitor mode
400 if ( cardtype < DEVTYPE_FILE ) 402 if ( cardtype < DEVTYPE_FILE )
401 { 403 {
402 if ( cardtype != DEVTYPE_MANUAL ) 404 if ( cardtype != DEVTYPE_MANUAL )
403 iface->setMonitorMode( true ); 405 iface->setMonitorMode( true );
404 if ( !iface->monitorMode() ) 406 if ( !iface->monitorMode() )
405 { 407 {
406 if ( QMessageBox::warning( this, "Wellenreiter II", 408 if ( QMessageBox::warning( this, "Wellenreiter II",
407 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 409 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
408 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 410 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
409 return; 411 return;
410 } 412 }
411 } 413 }
412 414
413 // open GPS device 415 // open GPS device
414 if ( configwindow->enableGPS->isChecked() ) 416 if ( configwindow->enableGPS->isChecked() )
415 { 417 {
416 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 418 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
417 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 419 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
418 } 420 }
419 421
420 // open pcap and start sniffing 422 // open pcap and start sniffing
421 if ( cardtype != DEVTYPE_FILE ) 423 if ( cardtype != DEVTYPE_FILE )
422 { 424 {
423 pcap->open( interface ); 425 pcap->open( interface );
424 426
425 if ( configwindow->writeCaptureFile->isChecked() ) 427 if ( configwindow->writeCaptureFile->isChecked() )
426 { 428 {
427 QString dumpname( configwindow->captureFileName->text() ); 429 QString dumpname( configwindow->captureFileName->text() );
428 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 430 if ( dumpname.isEmpty() ) dumpname = "captureFile";
429 dumpname.append( '-' ); 431 dumpname.append( '-' );
430 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 432 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
431 dumpname.append( ".wellenreiter" ); 433 dumpname.append( ".wellenreiter" );
432 pcap->openDumpFile( dumpname ); 434 pcap->openDumpFile( dumpname );
433 } 435 }
434 else 436 else
435 { 437 {
436 pcap->open( interface ); 438 pcap->open( interface );
437 } 439 }
438 } 440 }
439 else 441 else
440 { 442 {
441 pcap->open( QFile( interface ) ); 443 pcap->open( QFile( interface ) );
442 } 444 }
443 445
444 if ( !pcap->isOpen() ) 446 if ( !pcap->isOpen() )
445 { 447 {
446 QMessageBox::warning( this, "Wellenreiter II", 448 QMessageBox::warning( this, "Wellenreiter II",
447 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); 449 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) ));
448 return; 450 return;
449 } 451 }
450 452
451 // set capturer to non-blocking mode 453 // set capturer to non-blocking mode
452 pcap->setBlocking( false ); 454 pcap->setBlocking( false );
453 455
454 // start channel hopper 456 // start channel hopper
455 if ( cardtype != DEVTYPE_FILE ) 457 if ( cardtype != DEVTYPE_FILE )
456 { 458 {
457 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 459 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
458 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 460 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
459 } 461 }
460 462
461 if ( cardtype != DEVTYPE_FILE ) 463 if ( cardtype != DEVTYPE_FILE )
462 { 464 {
463 // connect socket notifier and start channel hopper 465 // connect socket notifier and start channel hopper
464 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 466 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
465 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 467 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
466 } 468 }
467 else 469 else
468 { 470 {
469 // start timer for reading packets 471 // start timer for reading packets
470 startTimer( 100 ); 472 startTimer( 100 );
471 } 473 }
472 474
473 logwindow->log( "(i) Started Scanning." ); 475 logwindow->log( "(i) Started Scanning." );
474 sniffing = true; 476 sniffing = true;
475 emit( startedSniffing() ); 477 emit( startedSniffing() );
476 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 478 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
477 else 479 else
478 { 480 {
479 assert( parent() ); 481 assert( parent() );
480 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 482 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
481 } 483 }
482} 484}
483 485
484 486
485void Wellenreiter::timerEvent( QTimerEvent* ) 487void Wellenreiter::timerEvent( QTimerEvent* )
486{ 488{
487 qDebug( "Wellenreiter::timerEvent()" ); 489 qDebug( "Wellenreiter::timerEvent()" );
488 OPacket* p = pcap->next(); 490 OPacket* p = pcap->next();
489 if ( !p ) // no more packets available 491 if ( !p ) // no more packets available
490 { 492 {
491 stopClicked(); 493 stopClicked();
492 } 494 }
493 else 495 else
494 { 496 {
495 receivePacket( p ); 497 receivePacket( p );
496 delete p; 498 delete p;
497 } 499 }
498} 500}
499 501
500 502
501void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 503void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
502{ 504{
503 #ifdef QWS 505 #ifdef QWS
504 if ( action == "TouchSound" ) 506 if ( action == "TouchSound" )
505 ODevice::inst()->touchSound(); 507 ODevice::inst()->touchSound();
506 else if ( action == "AlarmSound" ) 508 else if ( action == "AlarmSound" )
507 ODevice::inst()->alarmSound(); 509 ODevice::inst()->alarmSound();
508 else if ( action == "KeySound" ) 510 else if ( action == "KeySound" )
509 ODevice::inst()->keySound(); 511 ODevice::inst()->keySound();
510 else if ( action == "LedOn" ) 512 else if ( action == "LedOn" )
511 ODevice::inst()->setLedState( Led_Mail, Led_On ); 513 ODevice::inst()->setLedState( Led_Mail, Led_On );
512 else if ( action == "LedOff" ) 514 else if ( action == "LedOff" )
513 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 515 ODevice::inst()->setLedState( Led_Mail, Led_Off );
514 else if ( action == "LogMessage" ) 516 else if ( action == "LogMessage" )
515 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 517 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
516 else if ( action == "MessageBox" ) 518 else if ( action == "MessageBox" )
517 QMessageBox::information( this, "Notification!", 519 QMessageBox::information( this, "Notification!",
518 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 520 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
519 #else 521 #else
520 #warning Actions do not work with Qt/X11 yet 522 #warning Actions do not work with Qt/X11 yet
521 #endif 523 #endif
522} 524}
523 525
524void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 526void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
525{ 527{
526 #ifdef QWS 528 #ifdef QWS
527 if ( !iface ) 529 if ( !iface )
528 { 530 {
529 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 531 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
530 return; 532 return;
531 } 533 }
532 534
533 if ( sniffing ) 535 if ( sniffing )
534 { 536 {
535 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 537 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
536 return; 538 return;
537 } 539 }
538 540
539 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 541 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
540 (const char*) iface->name(), 542 (const char*) iface->name(),
541 (const char*) type, 543 (const char*) type,
542 (const char*) essid, 544 (const char*) essid,
543 channel, 545 channel,
544 (const char*) macaddr ); 546 (const char*) macaddr );
545 547
546 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 548 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
547 int count = 3; 549 int count = 3;
548 qDebug("sending %d messages",count); 550 qDebug("sending %d messages",count);
549 msg << QString("count") << QString::number(count); 551 msg << QString("count") << QString::number(count);
550 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 552 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
551 msg << QString(iface->name()) << QString("Mode") << type; 553 msg << QString(iface->name()) << QString("Mode") << type;
552 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 554 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
553 msg << QString(iface->name()) << QString("ESSID") << essid; 555 msg << QString(iface->name()) << QString("ESSID") << essid;
554 qDebug("msg >%s< channel >%d<", iface->name(),channel); 556 qDebug("msg >%s< channel >%d<", iface->name(),channel);
555 msg << QString(iface->name()) << QString("Channel") << channel; 557 msg << QString(iface->name()) << QString("Channel") << channel;
556// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 558// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
557// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 559// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
558 #else 560 #else
559 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 561 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
560 #endif 562 #endif
561 563
562} 564}
563 565
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
index 36fbb9a..eac5d89 100644
--- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
@@ -1,185 +1,185 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16#include "wellenreiterbase.h" 16#include "wellenreiterbase.h"
17 17
18#include <qheader.h> 18#include <qheader.h>
19#include <qlabel.h> 19#include <qlabel.h>
20#include <qlistview.h> 20#include <qlistview.h>
21#include <qmultilineedit.h> 21#include <qmultilineedit.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qvariant.h> 24#include <qvariant.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29 29
30#include "logwindow.h" 30#include "logwindow.h"
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#include "graphwindow.h"
35 35
36#ifdef QWS 36#ifdef QWS
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38#include <opie/otabwidget.h> 38#include <opie/otabwidget.h>
39#else 39#else
40#include "resource.h" 40#include "resource.h"
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#endif 42#endif
43 43
44 44
45/* 45/*
46 * Constructs a WellenreiterBase which is a child of 'parent', with the 46 * Constructs a WellenreiterBase which is a child of 'parent', with the
47 * name 'name' and widget flags set to 'f' 47 * name 'name' and widget flags set to 'f'
48 */ 48 */
49WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) 49WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl )
50 : QWidget( parent, name, fl ) 50 : QWidget( parent, name, fl )
51{ 51{
52 //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); 52 //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) );
53 //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); 53 //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) );
54 //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); 54 //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) );
55 //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); 55 //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) );
56 56
57 if ( !name ) 57 if ( !name )
58 setName( "WellenreiterBase" ); 58 setName( "WellenreiterBase" );
59 resize( 191, 294 ); 59 resize( 191, 294 );
60#ifdef QWS 60#ifdef QWS
61 setCaption( tr( "Wellenreiter/Opie" ) ); 61 setCaption( tr( "Wellenreiter/Opie" ) );
62#else 62#else
63 setCaption( tr( "Wellenreiter/X11" ) ); 63 setCaption( tr( "Wellenreiter/X11" ) );
64#endif 64#endif
65 WellenreiterBaseLayout = new QVBoxLayout( this ); 65 WellenreiterBaseLayout = new QVBoxLayout( this );
66 WellenreiterBaseLayout->setSpacing( 2 ); 66 WellenreiterBaseLayout->setSpacing( 2 );
67 WellenreiterBaseLayout->setMargin( 0 ); 67 WellenreiterBaseLayout->setMargin( 0 );
68#ifdef QWS 68#ifdef QWS
69 TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); 69 TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global );
70#else 70#else
71 TabWidget = new QTabWidget( this, "TabWidget" ); 71 TabWidget = new QTabWidget( this, "TabWidget" );
72#endif 72#endif
73 ap = new QWidget( TabWidget, "ap" ); 73 ap = new QWidget( TabWidget, "ap" );
74 apLayout = new QVBoxLayout( ap ); 74 apLayout = new QVBoxLayout( ap );
75 apLayout->setSpacing( 2 ); 75 apLayout->setSpacing( 2 );
76 apLayout->setMargin( 2 ); 76 apLayout->setMargin( 2 );
77 77
78 //--------- NETVIEW TAB -------------- 78 //--------- NETVIEW TAB --------------
79 79
80 netview = new MScanListView( ap ); 80 netview = new MScanListView( ap );
81 apLayout->addWidget( netview ); 81 apLayout->addWidget( netview );
82 82
83 //--------- GRAPH TAB -------------- 83 //--------- GRAPH TAB --------------
84 84
85 graphwindow = new MGraphWindow( TabWidget, "Graph" ); 85 graphwindow = new MGraphWindow( TabWidget, "Graph" );
86 86
87 //--------- LOG TAB -------------- 87 //--------- LOG TAB --------------
88 88
89 logwindow = new MLogWindow( TabWidget, "Log" ); 89 logwindow = new MLogWindow( TabWidget, "Log" );
90 90
91 //--------- HEX TAB -------------- 91 //--------- HEX TAB --------------
92 92
93 hexwindow = new MHexWindow( TabWidget, "Hex" ); 93 hexwindow = new MHexWindow( TabWidget, "Hex" );
94 94
95 //--------- STAT TAB -------------- 95 //--------- STAT TAB --------------
96 96
97 statwindow = new MStatWindow( TabWidget, "Stat" ); 97 statwindow = new MStatWindow( TabWidget, "Stat" );
98 98
99 //--------- ABOUT TAB -------------- 99 //--------- ABOUT TAB --------------
100 100
101 about = new QWidget( TabWidget, "about" ); 101 about = new QWidget( TabWidget, "about" );
102 aboutLayout = new QGridLayout( about ); 102 aboutLayout = new QGridLayout( about );
103 aboutLayout->setSpacing( 6 ); 103 aboutLayout->setSpacing( 6 );
104 aboutLayout->setMargin( 11 ); 104 aboutLayout->setMargin( 11 );
105 105
106 PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); 106 PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" );
107 PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); 107 PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) );
108 PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); 108 PixmapLabel1_3_2->setFrameShape( QLabel::Panel );
109 PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); 109 PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken );
110 PixmapLabel1_3_2->setLineWidth( 2 ); 110 PixmapLabel1_3_2->setLineWidth( 2 );
111 PixmapLabel1_3_2->setMargin( 0 ); 111 PixmapLabel1_3_2->setMargin( 0 );
112 PixmapLabel1_3_2->setMidLineWidth( 0 ); 112 PixmapLabel1_3_2->setMidLineWidth( 0 );
113 PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); 113 PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) );
114 PixmapLabel1_3_2->setScaledContents( TRUE ); 114 PixmapLabel1_3_2->setScaledContents( TRUE );
115 PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); 115 PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) );
116 116
117 aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); 117 aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 );
118 118
119 TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); 119 TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" );
120 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); 120 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() );
121 TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); 121 TextLabel1_4_2_font.setFamily( "adobe-helvetica" );
122 TextLabel1_4_2_font.setPointSize( 10 ); 122 TextLabel1_4_2_font.setPointSize( 10 );
123 TextLabel1_4_2->setFont( TextLabel1_4_2_font ); 123 TextLabel1_4_2->setFont( TextLabel1_4_2_font );
124 TextLabel1_4_2->setText( tr( "<p align=center>\n" 124 TextLabel1_4_2->setText( tr( "<p align=center>\n"
125"<hr>\n" 125"<hr>\n"
126"Michael 'Mickey' Lauer<br><hr>\n"
126"Max Moser<br>\n" 127"Max Moser<br>\n"
127"Martin J. Muench<br>\n" 128"Martin J. Muench<br>\n"
128"Michael Lauer<br><hr>\n" 129"<b>www.wellenreiter.net</b>\n"
129"<b>www.remote-exploit.org</b>\n"
130"</p>" ) ); 130"</p>" ) );
131 TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); 131 TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) );
132 132
133 aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); 133 aboutLayout->addWidget( TextLabel1_4_2, 1, 0 );
134 134
135#ifdef QWS 135#ifdef QWS
136 TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); 136 TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) );
137 TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); 137 TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) );
138 TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); 138 TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) );
139 TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); 139 TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) );
140 TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); 140 TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) );
141 TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); 141 TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) );
142#else 142#else
143 TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); 143 TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) );
144 TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); 144 TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) );
145 TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); 145 TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) );
146 TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); 146 TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) );
147 TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); 147 TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) );
148 TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); 148 TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) );
149#endif 149#endif
150 WellenreiterBaseLayout->addWidget( TabWidget ); 150 WellenreiterBaseLayout->addWidget( TabWidget );
151 151
152#ifdef QWS 152#ifdef QWS
153 TabWidget->setCurrentTab( tr( "Nets" ) ); 153 TabWidget->setCurrentTab( tr( "Nets" ) );
154#endif 154#endif
155 155
156} 156}
157 157
158/* 158/*
159 * Destroys the object and frees any allocated resources 159 * Destroys the object and frees any allocated resources
160 */ 160 */
161WellenreiterBase::~WellenreiterBase() 161WellenreiterBase::~WellenreiterBase()
162{ 162{
163 // no need to delete child widgets, Qt does it all for us 163 // no need to delete child widgets, Qt does it all for us
164} 164}
165 165
166/* 166/*
167 * Main event handler. Reimplemented to handle application 167 * Main event handler. Reimplemented to handle application
168 * font changes 168 * font changes
169 */ 169 */
170bool WellenreiterBase::event( QEvent* ev ) 170bool WellenreiterBase::event( QEvent* ev )
171{ 171{
172 bool ret = QWidget::event( ev ); 172 bool ret = QWidget::event( ev );
173 if ( ev->type() == QEvent::ApplicationFontChange ) { 173 if ( ev->type() == QEvent::ApplicationFontChange ) {
174 //QFont Log_2_font( Log_2->font() ); 174 //QFont Log_2_font( Log_2->font() );
175 //Log_2_font.setFamily( "adobe-courier" ); 175 //Log_2_font.setFamily( "adobe-courier" );
176 //Log_2_font.setPointSize( 8 ); 176 //Log_2_font.setPointSize( 8 );
177 //Log_2->setFont( Log_2_font ); 177 //Log_2->setFont( Log_2_font );
178 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); 178 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() );
179 TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); 179 TextLabel1_4_2_font.setFamily( "adobe-helvetica" );
180 TextLabel1_4_2_font.setPointSize( 10 ); 180 TextLabel1_4_2_font.setPointSize( 10 );
181 TextLabel1_4_2->setFont( TextLabel1_4_2_font ); 181 TextLabel1_4_2->setFont( TextLabel1_4_2_font );
182 } 182 }
183 return ret; 183 return ret;
184} 184}
185 185