author | mickeyl <mickeyl> | 2003-09-09 13:42:04 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-09 13:42:04 (UTC) |
commit | 807165ababca1b8c93b88d6b41f75ec96ce5e799 (patch) (unidiff) | |
tree | 5042886f052d34d7d79bf4e784f87cbad171c86c | |
parent | fca4c73a5f0c672db9150f312eb85f1299e80e1b (diff) | |
download | opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.zip opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.tar.gz opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.tar.bz2 |
reading GPS data from gpsd is now working. TODO: save the data
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.h | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 4 |
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 | |||
18 | GPS::GPS( QObject* parent, const char * name ) | 21 | GPS::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 | ||
26 | GPS::~GPS() | 29 | GPS::~GPS() |
27 | { | 30 | { |
28 | qDebug( "GPS::~GPS()" ); | 31 | qDebug( "GPS::~GPS()" ); |
29 | } | 32 | } |
30 | 33 | ||
31 | 34 | ||
32 | bool GPS::open( const QString& host, int port ) | 35 | bool 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 | ||
38 | float GPS::latitude() const | 41 | GpsLocation 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 | |||
63 | float 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 | ||
22 | struct 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 | |||
22 | class GPS : public QObject | 31 | class 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,80 +1,81 @@ | |||
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 | ||
44 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 45 | WellenreiterMainWindow::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 ); |
@@ -157,133 +158,133 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
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 | ||
168 | void WellenreiterMainWindow::showConfigure() | 169 | void 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 | ||
182 | void WellenreiterMainWindow::updateToolButtonState() | 183 | void 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 | ||
200 | void WellenreiterMainWindow::changedSniffingState() | 201 | void 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 | ||
209 | WellenreiterMainWindow::~WellenreiterMainWindow() | 210 | WellenreiterMainWindow::~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 | ||
217 | void WellenreiterMainWindow::demoAddStations() | 218 | void 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 | ||
229 | QString WellenreiterMainWindow::getFileName( bool save ) | 230 | QString 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 | ||
264 | void WellenreiterMainWindow::fileSaveLog() | 265 | void 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 | ||
284 | void WellenreiterMainWindow::fileSaveSession() | 285 | void 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 | ||
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,245 +1,255 @@ | |||
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> |
29 | using namespace Opie; | 29 | using 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 | ||
39 | const int col_type = 0; | 39 | const int col_type = 0; |
40 | const int col_essid = 0; | 40 | const int col_essid = 0; |
41 | const int col_sig = 1; | 41 | const int col_sig = 1; |
42 | const int col_ap = 2; | 42 | const int col_ap = 2; |
43 | const int col_channel = 3; | 43 | const int col_channel = 3; |
44 | const int col_wep = 4; | 44 | const int col_wep = 4; |
45 | const int col_traffic = 5; | 45 | const int col_traffic = 5; |
46 | const int col_ip = 6; | 46 | const int col_ip = 6; |
47 | const int col_manuf = 7; | 47 | const int col_manuf = 7; |
48 | const int col_firstseen = 8; | 48 | const int col_firstseen = 8; |
49 | const int col_lastseen = 9; | 49 | const int col_lastseen = 9; |
50 | const int col_location = 10; | ||
50 | 51 | ||
51 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 52 | MScanListView::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 | ||
91 | MScanListView::~MScanListView() | 94 | MScanListView::~MScanListView() |
92 | { | 95 | { |
93 | }; | 96 | }; |
94 | 97 | ||
95 | 98 | ||
96 | OListViewItem* MScanListView::childFactory() | 99 | OListViewItem* MScanListView::childFactory() |
97 | { | 100 | { |
98 | return new MScanListItem( this ); | 101 | return new MScanListItem( this ); |
99 | } | 102 | } |
100 | 103 | ||
101 | 104 | ||
102 | void MScanListView::serializeTo( QDataStream& s) const | 105 | void 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 | ||
109 | void MScanListView::serializeFrom( QDataStream& s) | 112 | void 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 | ||
116 | void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) | 119 | void 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 | ||
196 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 206 | void 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 | ||
235 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 245 | void 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() ); |
@@ -407,89 +417,98 @@ void MScanListItem::serializeFrom( QDataStream& s ) | |||
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 | ||
424 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 434 | void 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 | ||
465 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 475 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
466 | { | 476 | { |
467 | setText( col_manuf, manufacturer ); | 477 | setText( col_manuf, manufacturer ); |
468 | } | 478 | } |
469 | 479 | ||
470 | 480 | ||
481 | void 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 | |||
471 | void MScanListItem::playSound( const QString& sound ) const | 490 | void 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 | ||
482 | void MScanListItem::receivedBeacon() | 501 | void 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 | ||
26 | class QString; | 28 | class QString; |
27 | class MScanListItem; | 29 | class MScanListItem; |
28 | 30 | ||
29 | class MScanListView: public OListView | 31 | class 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 | ||
63 | class MScanListItem: public OListViewItem | 66 | class 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 | ||
125 | class MScanListViewFactory : public OListViewFactory | 129 | class MScanListViewFactory : public OListViewFactory |
126 | { | 130 | { |
127 | public: | 131 | public: |
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 | |||
@@ -110,136 +110,138 @@ void Wellenreiter::channelHopped(int c) | |||
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 | ||
126 | void Wellenreiter::handleNotification( OPacket* p ) | 126 | void 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 | ||
150 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 150 | void 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 | ||
195 | void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) | 197 | void 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 | ||
238 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 240 | QObject* 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 | } |
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 | |||
@@ -62,124 +62,124 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
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 | */ |
161 | WellenreiterBase::~WellenreiterBase() | 161 | WellenreiterBase::~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 | */ |
170 | bool WellenreiterBase::event( QEvent* ev ) | 170 | bool 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 | ||