author | mickeyl <mickeyl> | 2004-01-03 18:27:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-03 18:27:07 (UTC) |
commit | 3889c8f853aa2d128f54389b17f08fc7b9150788 (patch) (unidiff) | |
tree | 692bf0541e19d19f9ac93059463e4c4eb2e43e5f | |
parent | c69a2abd7718d8acddb4ce96a1909b33056e2dcd (diff) | |
download | opie-3889c8f853aa2d128f54389b17f08fc7b9150788.zip opie-3889c8f853aa2d128f54389b17f08fc7b9150788.tar.gz opie-3889c8f853aa2d128f54389b17f08fc7b9150788.tar.bz2 |
show GPS coordinates in the more common DMS format
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 66 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.h | 13 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 9 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 2 |
6 files changed, 82 insertions, 18 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index 288afee..31f95ce 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -1,69 +1,131 @@ | |||
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> | ||
18 | 17 | ||
18 | /* QT */ | ||
19 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
20 | 20 | ||
21 | /* STD */ | ||
22 | #include <stdlib.h> | ||
23 | #include <unistd.h> | ||
24 | |||
21 | GPS::GPS( QObject* parent, const char * name ) | 25 | GPS::GPS( QObject* parent, const char * name ) |
22 | :QObject( parent, name ) | 26 | :QObject( parent, name ) |
23 | { | 27 | { |
24 | qDebug( "GPS::GPS()" ); | 28 | qDebug( "GPS::GPS()" ); |
25 | _socket = new QSocket( this, "gpsd commsock" ); | 29 | _socket = new QSocket( this, "gpsd commsock" ); |
26 | } | 30 | } |
27 | 31 | ||
28 | 32 | ||
29 | GPS::~GPS() | 33 | GPS::~GPS() |
30 | { | 34 | { |
31 | qDebug( "GPS::~GPS()" ); | 35 | qDebug( "GPS::~GPS()" ); |
32 | } | 36 | } |
33 | 37 | ||
34 | 38 | ||
35 | bool GPS::open( const QString& host, int port ) | 39 | bool GPS::open( const QString& host, int port ) |
36 | { | 40 | { |
37 | _socket->connectToHost( host, port ); | 41 | _socket->connectToHost( host, port ); |
38 | } | 42 | } |
39 | 43 | ||
40 | 44 | ||
41 | GpsLocation GPS::position() const | 45 | GpsLocation GPS::position() const |
42 | { | 46 | { |
43 | char buf[256]; | 47 | char buf[256]; |
44 | 48 | ||
45 | int result = _socket->writeBlock( "p\r\n", 3 ); | 49 | int result = _socket->writeBlock( "p\r\n", 3 ); |
46 | _socket->flush(); | 50 | _socket->flush(); |
47 | if ( result ) | 51 | if ( result ) |
48 | { | 52 | { |
49 | int numAvail = _socket->bytesAvailable(); | 53 | int numAvail = _socket->bytesAvailable(); |
50 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); | 54 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); |
51 | if ( numAvail ) | 55 | if ( numAvail ) |
52 | { | 56 | { |
53 | QTextStream stream( _socket ); | 57 | QTextStream stream( _socket ); |
54 | 58 | ||
55 | QString str; | 59 | QString str; |
56 | stream.readRawBytes( &buf[0], 7 ); | 60 | stream.readRawBytes( &buf[0], 7 ); |
57 | float lat = -111.111; | 61 | float lat = -111.111; |
58 | stream >> lat; | 62 | stream >> lat; |
59 | stream.skipWhiteSpace(); | 63 | stream.skipWhiteSpace(); |
60 | float lon = -111.111; | 64 | float lon = -111.111; |
61 | stream >> lon; | 65 | stream >> lon; |
62 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF | 66 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF |
63 | 67 | ||
64 | return GpsLocation( lat, lon ); | 68 | return GpsLocation( lat, lon ); |
65 | } | 69 | } |
66 | } | 70 | } |
67 | return GpsLocation( -1.0, -1.0 ); | 71 | return GpsLocation( -111.111, -111.111 ); |
68 | } | 72 | } |
69 | 73 | ||
74 | |||
75 | QString GpsLocation::dmsPosition() const | ||
76 | { | ||
77 | if ( _latitude == -111.111 || _longitude == -111.11 ) | ||
78 | return "N/A"; | ||
79 | if ( _latitude == 0.0 && _longitude == 0.0 ) | ||
80 | return "NULL"; | ||
81 | |||
82 | /* compute latitude */ | ||
83 | |||
84 | QString dms = "N"; | ||
85 | if ( _latitude >= 0 ) dms.append( "+" ); | ||
86 | |||
87 | int trunc = int( _latitude ); | ||
88 | float rest = _latitude - trunc; | ||
89 | |||
90 | float minf = rest * 60; | ||
91 | int minutes = int( minf ); | ||
92 | |||
93 | rest = minf - minutes; | ||
94 | int seconds = int( rest * 60 ); | ||
95 | |||
96 | dms.append( QString::number( trunc ) ); | ||
97 | dms.append( "° " ); | ||
98 | dms.append( QString::number( ::abs( minutes ) ) ); | ||
99 | dms.append( "' " ); | ||
100 | dms.append( QString::number( ::abs( seconds ) ) ); | ||
101 | dms.append( "'' " ); | ||
102 | |||
103 | /* compute longitude */ | ||
104 | |||
105 | dms.append( " | W" ); | ||
106 | if ( _longitude > 0 ) dms.append( "+" ); | ||
107 | |||
108 | trunc = int( _longitude ); | ||
109 | rest = _longitude - trunc; | ||
110 | |||
111 | minf = rest * 60; | ||
112 | minutes = int( minf ); | ||
113 | |||
114 | rest = minf - minutes; | ||
115 | seconds = int( rest * 60 ); | ||
116 | |||
117 | dms.append( QString::number( trunc ) ); | ||
118 | dms.append( "° " ); | ||
119 | dms.append( QString::number( ::abs( minutes ) ) ); | ||
120 | dms.append( "' " ); | ||
121 | dms.append( QString::number( ::abs( seconds ) ) ); | ||
122 | dms.append( "'' " ); | ||
123 | |||
124 | return dms; | ||
125 | } | ||
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h index 8143fe4..cfe1cdb 100644 --- a/noncore/net/wellenreiter/gui/gps.h +++ b/noncore/net/wellenreiter/gui/gps.h | |||
@@ -1,46 +1,51 @@ | |||
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 | 22 | class GpsLocation |
23 | { | 23 | { |
24 | GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {}; | 24 | public: |
25 | GpsLocation( const float& lat, const float& lon ) : _latitude(lat), _longitude(lon) {}; | ||
25 | ~GpsLocation() {}; | 26 | ~GpsLocation() {}; |
26 | float latitude; | 27 | float latitude() const { return _latitude; }; |
27 | float longitude; | 28 | float longitude() const { return _longitude; }; |
29 | QString dmsPosition() const; | ||
30 | private: | ||
31 | float _latitude; | ||
32 | float _longitude; | ||
28 | }; | 33 | }; |
29 | 34 | ||
30 | 35 | ||
31 | class GPS : public QObject | 36 | class GPS : public QObject |
32 | { | 37 | { |
33 | Q_OBJECT | 38 | Q_OBJECT |
34 | 39 | ||
35 | public: | 40 | public: |
36 | GPS( QObject* parent = 0, const char * name = "GPS" ); | 41 | GPS( QObject* parent = 0, const char * name = "GPS" ); |
37 | ~GPS(); | 42 | ~GPS(); |
38 | 43 | ||
39 | bool open( const QString& host = "localhost", int port = 2947 ); | 44 | bool open( const QString& host = "localhost", int port = 2947 ); |
40 | GpsLocation position() const; | 45 | GpsLocation position() const; |
41 | 46 | ||
42 | private: | 47 | private: |
43 | QSocket* _socket; | 48 | QSocket* _socket; |
44 | }; | 49 | }; |
45 | 50 | ||
46 | #endif // GPS_H | 51 | #endif // GPS_H |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index ca9851c..d4e3279 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,541 +1,541 @@ | |||
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 "gps.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | #include "hexwindow.h" | 19 | #include "hexwindow.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | #include "wellenreiter.h" | 21 | #include "wellenreiter.h" |
22 | #include "scanlist.h" | 22 | #include "scanlist.h" |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qdatastream.h> | 25 | #include <qdatastream.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qiconset.h> | 31 | #include <qiconset.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 36 | #include <qstatusbar.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | 39 | ||
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <opie/ofiledialog.h> | 42 | #include <opie/ofiledialog.h> |
43 | #else | 43 | #else |
44 | #include "resource.h" | 44 | #include "resource.h" |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qfiledialog.h> | 46 | #include <qfiledialog.h> |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 49 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
50 | :QMainWindow( parent, name, f ) | 50 | :QMainWindow( parent, name, f ) |
51 | { | 51 | { |
52 | cw = new WellenreiterConfigWindow( this ); | 52 | cw = new WellenreiterConfigWindow( this ); |
53 | mw = new Wellenreiter( this ); | 53 | mw = new Wellenreiter( this ); |
54 | mw->setConfigWindow( cw ); | 54 | mw->setConfigWindow( cw ); |
55 | setCentralWidget( mw ); | 55 | setCentralWidget( mw ); |
56 | 56 | ||
57 | // setup application icon | 57 | // setup application icon |
58 | 58 | ||
59 | #ifndef QWS | 59 | #ifndef QWS |
60 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 60 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
61 | setIconText( "Wellenreiter/X11" ); | 61 | setIconText( "Wellenreiter/X11" ); |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | // setup tool buttons | 64 | // setup tool buttons |
65 | 65 | ||
66 | startButton = new QToolButton( 0 ); | 66 | startButton = new QToolButton( 0 ); |
67 | #ifdef QWS | 67 | #ifdef QWS |
68 | startButton->setAutoRaise( true ); | 68 | startButton->setAutoRaise( true ); |
69 | #endif | 69 | #endif |
70 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 70 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); |
71 | startButton->setEnabled( false ); | 71 | startButton->setEnabled( false ); |
72 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | 72 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); |
73 | 73 | ||
74 | stopButton = new QToolButton( 0 ); | 74 | stopButton = new QToolButton( 0 ); |
75 | #ifdef QWS | 75 | #ifdef QWS |
76 | stopButton->setAutoRaise( true ); | 76 | stopButton->setAutoRaise( true ); |
77 | #endif | 77 | #endif |
78 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); | 78 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); |
79 | stopButton->setEnabled( false ); | 79 | stopButton->setEnabled( false ); |
80 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); | 80 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
81 | 81 | ||
82 | QToolButton* d = new QToolButton( 0 ); | 82 | QToolButton* d = new QToolButton( 0 ); |
83 | #ifdef QWS | 83 | #ifdef QWS |
84 | d->setAutoRaise( true ); | 84 | d->setAutoRaise( true ); |
85 | #endif | 85 | #endif |
86 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); | 86 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); |
87 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 87 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
88 | 88 | ||
89 | uploadButton = new QToolButton( 0 ); | 89 | uploadButton = new QToolButton( 0 ); |
90 | #ifdef QWS | 90 | #ifdef QWS |
91 | uploadButton->setAutoRaise( true ); | 91 | uploadButton->setAutoRaise( true ); |
92 | #endif | 92 | #endif |
93 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 93 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); |
94 | uploadButton->setEnabled( false ); | 94 | uploadButton->setEnabled( false ); |
95 | //uploadButton->setEnabled( true ); // DEBUGGING | 95 | //uploadButton->setEnabled( true ); // DEBUGGING |
96 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 96 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
97 | 97 | ||
98 | // setup menu bar | 98 | // setup menu bar |
99 | 99 | ||
100 | int id; | 100 | int id; |
101 | 101 | ||
102 | QMenuBar* mb = menuBar(); | 102 | QMenuBar* mb = menuBar(); |
103 | 103 | ||
104 | QPopupMenu* fileSave = new QPopupMenu( mb ); | 104 | QPopupMenu* fileSave = new QPopupMenu( mb ); |
105 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); | 105 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); |
106 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); | 106 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); |
107 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); | 107 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); |
108 | 108 | ||
109 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | 109 | QPopupMenu* fileLoad = new QPopupMenu( mb ); |
110 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); | 110 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); |
111 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 111 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
112 | 112 | ||
113 | QPopupMenu* file = new QPopupMenu( mb ); | 113 | QPopupMenu* file = new QPopupMenu( mb ); |
114 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); | 114 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); |
115 | id = file->insertItem( tr( "&Load" ), fileLoad ); | 115 | id = file->insertItem( tr( "&Load" ), fileLoad ); |
116 | file->insertItem( tr( "&Save" ), fileSave ); | 116 | file->insertItem( tr( "&Save" ), fileSave ); |
117 | file->insertSeparator(); | 117 | file->insertSeparator(); |
118 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); | 118 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); |
119 | file->insertSeparator(); | 119 | file->insertSeparator(); |
120 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 120 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
121 | 121 | ||
122 | QPopupMenu* view = new QPopupMenu( mb ); | 122 | QPopupMenu* view = new QPopupMenu( mb ); |
123 | view->insertItem( tr( "&Configure..." ) ); | 123 | view->insertItem( tr( "&Configure..." ) ); |
124 | 124 | ||
125 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 125 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
126 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 126 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
127 | sniffer->insertSeparator(); | 127 | sniffer->insertSeparator(); |
128 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 128 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
129 | sniffer->setItemEnabled( startID, false ); | 129 | sniffer->setItemEnabled( startID, false ); |
130 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 130 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
131 | sniffer->setItemEnabled( stopID, false ); | 131 | sniffer->setItemEnabled( stopID, false ); |
132 | 132 | ||
133 | QPopupMenu* demo = new QPopupMenu( mb ); | 133 | QPopupMenu* demo = new QPopupMenu( mb ); |
134 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 134 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
135 | 135 | ||
136 | id = mb->insertItem( tr( "&File" ), file ); | 136 | id = mb->insertItem( tr( "&File" ), file ); |
137 | //id = mb->insertItem( tr( "&View" ), view ); | 137 | //id = mb->insertItem( tr( "&View" ), view ); |
138 | //mb->setItemEnabled( id, false ); | 138 | //mb->setItemEnabled( id, false ); |
139 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 139 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
140 | 140 | ||
141 | id = mb->insertItem( tr( "&Demo" ), demo ); | 141 | id = mb->insertItem( tr( "&Demo" ), demo ); |
142 | mb->setItemEnabled( id, true ); | 142 | mb->setItemEnabled( id, true ); |
143 | mb->setItemEnabled( uploadID, false ); | 143 | mb->setItemEnabled( uploadID, false ); |
144 | 144 | ||
145 | #ifdef QWS | 145 | #ifdef QWS |
146 | mb->insertItem( startButton ); | 146 | mb->insertItem( startButton ); |
147 | mb->insertItem( stopButton ); | 147 | mb->insertItem( stopButton ); |
148 | mb->insertItem( uploadButton ); | 148 | mb->insertItem( uploadButton ); |
149 | mb->insertItem( d ); | 149 | mb->insertItem( d ); |
150 | #else // Qt3 changed the insertion order. It's now totally random :( | 150 | #else // Qt3 changed the insertion order. It's now totally random :( |
151 | mb->insertItem( d ); | 151 | mb->insertItem( d ); |
152 | mb->insertItem( uploadButton ); | 152 | mb->insertItem( uploadButton ); |
153 | mb->insertItem( stopButton ); | 153 | mb->insertItem( stopButton ); |
154 | mb->insertItem( startButton ); | 154 | mb->insertItem( startButton ); |
155 | #endif | 155 | #endif |
156 | 156 | ||
157 | updateToolButtonState(); | 157 | updateToolButtonState(); |
158 | 158 | ||
159 | // setup status bar (for now only on X11) | 159 | // setup status bar (for now only on X11) |
160 | 160 | ||
161 | #ifndef QWS | 161 | #ifndef QWS |
162 | statusBar()->message( tr( "Ready." ) ); | 162 | statusBar()->message( tr( "Ready." ) ); |
163 | #endif | 163 | #endif |
164 | 164 | ||
165 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 165 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
166 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 166 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
167 | }; | 167 | }; |
168 | 168 | ||
169 | 169 | ||
170 | 170 | ||
171 | void WellenreiterMainWindow::showConfigure() | 171 | void WellenreiterMainWindow::showConfigure() |
172 | { | 172 | { |
173 | qDebug( "show configure..." ); | 173 | qDebug( "show configure..." ); |
174 | cw->setCaption( tr( "Configure" ) ); | 174 | cw->setCaption( tr( "Configure" ) ); |
175 | #ifdef QWS | 175 | #ifdef QWS |
176 | cw->showMaximized(); | 176 | cw->showMaximized(); |
177 | #endif | 177 | #endif |
178 | int result = cw->exec(); | 178 | int result = cw->exec(); |
179 | 179 | ||
180 | if ( result ) updateToolButtonState(); | 180 | if ( result ) updateToolButtonState(); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | void WellenreiterMainWindow::updateToolButtonState() | 184 | void WellenreiterMainWindow::updateToolButtonState() |
185 | { | 185 | { |
186 | const QString& interface = cw->interfaceName->currentText(); | 186 | const QString& interface = cw->interfaceName->currentText(); |
187 | const int cardtype = cw->driverType(); | 187 | const int cardtype = cw->driverType(); |
188 | 188 | ||
189 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 189 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
190 | { | 190 | { |
191 | startButton->setEnabled( true ); | 191 | startButton->setEnabled( true ); |
192 | menuBar()->setItemEnabled( startID, true ); | 192 | menuBar()->setItemEnabled( startID, true ); |
193 | } | 193 | } |
194 | else | 194 | else |
195 | { | 195 | { |
196 | startButton->setEnabled( false ); | 196 | startButton->setEnabled( false ); |
197 | menuBar()->setItemEnabled( startID, false ); | 197 | menuBar()->setItemEnabled( startID, false ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void WellenreiterMainWindow::changedSniffingState() | 202 | void WellenreiterMainWindow::changedSniffingState() |
203 | { | 203 | { |
204 | startButton->setEnabled( !mw->sniffing ); | 204 | startButton->setEnabled( !mw->sniffing ); |
205 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 205 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
206 | stopButton->setEnabled( mw->sniffing ); | 206 | stopButton->setEnabled( mw->sniffing ); |
207 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 207 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
208 | 208 | ||
209 | if ( !mw->sniffing ) | 209 | if ( !mw->sniffing ) |
210 | { | 210 | { |
211 | menuBar()->setItemEnabled( uploadID, true ); | 211 | menuBar()->setItemEnabled( uploadID, true ); |
212 | uploadButton->setEnabled( true ); | 212 | uploadButton->setEnabled( true ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | WellenreiterMainWindow::~WellenreiterMainWindow() | 217 | WellenreiterMainWindow::~WellenreiterMainWindow() |
218 | { | 218 | { |
219 | qDebug( "Wellenreiter:: bye." ); | 219 | qDebug( "Wellenreiter:: bye." ); |
220 | }; | 220 | }; |
221 | 221 | ||
222 | 222 | ||
223 | void WellenreiterMainWindow::demoAddStations() | 223 | void WellenreiterMainWindow::demoAddStations() |
224 | { | 224 | { |
225 | //mw = 0; // test SIGSGV handling | 225 | //mw = 0; // test SIGSGV handling |
226 | 226 | ||
227 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); | 227 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
229 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 229 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | QString WellenreiterMainWindow::getFileName( bool save ) | 235 | QString WellenreiterMainWindow::getFileName( bool save ) |
236 | { | 236 | { |
237 | QMap<QString, QStringList> map; | 237 | QMap<QString, QStringList> map; |
238 | map.insert( tr("All"), QStringList() ); | 238 | map.insert( tr("All"), QStringList() ); |
239 | QStringList text; | 239 | QStringList text; |
240 | text << "text/*"; | 240 | text << "text/*"; |
241 | map.insert( tr("Text"), text ); | 241 | map.insert( tr("Text"), text ); |
242 | text << "*"; | 242 | text << "*"; |
243 | map.insert( tr("All"), text ); | 243 | map.insert( tr("All"), text ); |
244 | 244 | ||
245 | QString str; | 245 | QString str; |
246 | if ( save ) | 246 | if ( save ) |
247 | { | 247 | { |
248 | #ifdef QWS | 248 | #ifdef QWS |
249 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 249 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
250 | #else | 250 | #else |
251 | str = QFileDialog::getSaveFileName(); | 251 | str = QFileDialog::getSaveFileName(); |
252 | #endif | 252 | #endif |
253 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) | 253 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) |
254 | return ""; | 254 | return ""; |
255 | } | 255 | } |
256 | else | 256 | else |
257 | { | 257 | { |
258 | #ifdef QWS | 258 | #ifdef QWS |
259 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 259 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
260 | #else | 260 | #else |
261 | str = QFileDialog::getOpenFileName(); | 261 | str = QFileDialog::getOpenFileName(); |
262 | #endif | 262 | #endif |
263 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 263 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
264 | return ""; | 264 | return ""; |
265 | } | 265 | } |
266 | return str; | 266 | return str; |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | void WellenreiterMainWindow::fileSaveLog() | 270 | void WellenreiterMainWindow::fileSaveLog() |
271 | { | 271 | { |
272 | QString fname = getFileName( true ); | 272 | QString fname = getFileName( true ); |
273 | if ( !fname.isEmpty() ) | 273 | if ( !fname.isEmpty() ) |
274 | { | 274 | { |
275 | QFile f( fname ); | 275 | QFile f( fname ); |
276 | if ( f.open(IO_WriteOnly) ) | 276 | if ( f.open(IO_WriteOnly) ) |
277 | { | 277 | { |
278 | QTextStream t( &f ); | 278 | QTextStream t( &f ); |
279 | t << mw->logWindow()->getLog(); | 279 | t << mw->logWindow()->getLog(); |
280 | f.close(); | 280 | f.close(); |
281 | qDebug( "Saved log to file '%s'", (const char*) fname ); | 281 | qDebug( "Saved log to file '%s'", (const char*) fname ); |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | 285 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); |
286 | } | 286 | } |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | void WellenreiterMainWindow::fileSaveSession() | 290 | void WellenreiterMainWindow::fileSaveSession() |
291 | { | 291 | { |
292 | QString fname = getFileName( true ); | 292 | QString fname = getFileName( true ); |
293 | if ( !fname.isEmpty() ) | 293 | if ( !fname.isEmpty() ) |
294 | { | 294 | { |
295 | 295 | ||
296 | QFile f( fname ); | 296 | QFile f( fname ); |
297 | if ( f.open(IO_WriteOnly) ) | 297 | if ( f.open(IO_WriteOnly) ) |
298 | { | 298 | { |
299 | QDataStream t( &f ); | 299 | QDataStream t( &f ); |
300 | t << *mw->netView(); | 300 | t << *mw->netView(); |
301 | f.close(); | 301 | f.close(); |
302 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 302 | qDebug( "Saved session to file '%s'", (const char*) fname ); |
303 | } | 303 | } |
304 | else | 304 | else |
305 | { | 305 | { |
306 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); | 306 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | void WellenreiterMainWindow::fileSaveHex() | 311 | void WellenreiterMainWindow::fileSaveHex() |
312 | { | 312 | { |
313 | QString fname = getFileName( true ); | 313 | QString fname = getFileName( true ); |
314 | if ( !fname.isEmpty() ) | 314 | if ( !fname.isEmpty() ) |
315 | { | 315 | { |
316 | QFile f( fname ); | 316 | QFile f( fname ); |
317 | if ( f.open(IO_WriteOnly) ) | 317 | if ( f.open(IO_WriteOnly) ) |
318 | { | 318 | { |
319 | QTextStream t( &f ); | 319 | QTextStream t( &f ); |
320 | t << mw->hexWindow()->getLog(); | 320 | t << mw->hexWindow()->getLog(); |
321 | f.close(); | 321 | f.close(); |
322 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); | 322 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); |
323 | } | 323 | } |
324 | else | 324 | else |
325 | { | 325 | { |
326 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); | 326 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | void WellenreiterMainWindow::fileLoadSession() | 331 | void WellenreiterMainWindow::fileLoadSession() |
332 | { | 332 | { |
333 | QString fname = getFileName( false ); | 333 | QString fname = getFileName( false ); |
334 | if ( !fname.isEmpty() ) | 334 | if ( !fname.isEmpty() ) |
335 | { | 335 | { |
336 | QFile f( fname ); | 336 | QFile f( fname ); |
337 | if ( f.open(IO_ReadOnly) ) | 337 | if ( f.open(IO_ReadOnly) ) |
338 | { | 338 | { |
339 | QDataStream t( &f ); | 339 | QDataStream t( &f ); |
340 | t >> *mw->netView(); | 340 | t >> *mw->netView(); |
341 | f.close(); | 341 | f.close(); |
342 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | 342 | qDebug( "Loaded session from file '%s'", (const char*) fname ); |
343 | } | 343 | } |
344 | else | 344 | else |
345 | { | 345 | { |
346 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | 346 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void WellenreiterMainWindow::fileNew() | 352 | void WellenreiterMainWindow::fileNew() |
353 | { | 353 | { |
354 | mw->netView()->clear(); | 354 | mw->netView()->clear(); |
355 | mw->logWindow()->clear(); | 355 | mw->logWindow()->clear(); |
356 | mw->hexWindow()->clear(); | 356 | mw->hexWindow()->clear(); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 360 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
361 | { | 361 | { |
362 | if ( mw->isDaemonRunning() ) | 362 | if ( mw->isDaemonRunning() ) |
363 | { | 363 | { |
364 | QMessageBox::warning( this, "Wellenreiter/Opie", | 364 | QMessageBox::warning( this, "Wellenreiter/Opie", |
365 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); | 365 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); |
366 | e->ignore(); | 366 | e->ignore(); |
367 | } | 367 | } |
368 | else | 368 | else |
369 | { | 369 | { |
370 | QMainWindow::closeEvent( e ); | 370 | QMainWindow::closeEvent( e ); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | static const char* CAP_hostname = "www.vanille.de"; | 374 | static const char* CAP_hostname = "www.vanille.de"; |
375 | 375 | ||
376 | #include <netdb.h> | 376 | #include <netdb.h> |
377 | #include <unistd.h> | 377 | #include <unistd.h> |
378 | #include <sys/types.h> | 378 | #include <sys/types.h> |
379 | #include <sys/socket.h> | 379 | #include <sys/socket.h> |
380 | 380 | ||
381 | void WellenreiterMainWindow::uploadSession() | 381 | void WellenreiterMainWindow::uploadSession() |
382 | { | 382 | { |
383 | QLineEdit* from; | 383 | QLineEdit* from; |
384 | QLineEdit* location; | 384 | QLineEdit* location; |
385 | QLineEdit* comments; | 385 | QLineEdit* comments; |
386 | QPushButton* accept; | 386 | QPushButton* accept; |
387 | QPushButton* reject; | 387 | QPushButton* reject; |
388 | 388 | ||
389 | QDialog* d = new QDialog( 0, "session upload", true ); | 389 | QDialog* d = new QDialog( 0, "session upload", true ); |
390 | d->setCaption( tr( "Upload Session" ) ); | 390 | d->setCaption( tr( "Upload Session" ) ); |
391 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | 391 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); |
392 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | 392 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); |
393 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | 393 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); |
394 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | 394 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); |
395 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | 395 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); |
396 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | 396 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); |
397 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | 397 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); |
398 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | 398 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); |
399 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 399 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
400 | accept->setDefault( true ); | 400 | accept->setDefault( true ); |
401 | accept->setAutoDefault( true ); | 401 | accept->setAutoDefault( true ); |
402 | from->setText( "WL II User" ); | 402 | from->setText( "WL II User" ); |
403 | location->setText( "WL II Location" ); | 403 | location->setText( "WL II Location" ); |
404 | comments->setText( "No Comments." ); | 404 | comments->setText( "No Comments." ); |
405 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 405 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
406 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 406 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
407 | int result = d->exec(); | 407 | int result = d->exec(); |
408 | 408 | ||
409 | if ( !result ) | 409 | if ( !result ) |
410 | { | 410 | { |
411 | qDebug( "Session upload cancelled :(" ); | 411 | qDebug( "Session upload cancelled :(" ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | 414 | ||
415 | qDebug( "Starting upload..." ); | 415 | qDebug( "Starting upload..." ); |
416 | 416 | ||
417 | struct sockaddr_in raddr; | 417 | struct sockaddr_in raddr; |
418 | struct hostent *rhost_info; | 418 | struct hostent *rhost_info; |
419 | int sock = -1; | 419 | int sock = -1; |
420 | bool ok = false; | 420 | bool ok = false; |
421 | 421 | ||
422 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 422 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
423 | if ( rhost_info ) | 423 | if ( rhost_info ) |
424 | { | 424 | { |
425 | 425 | ||
426 | 426 | ||
427 | if ( !QFile::exists( mw->captureFileName() ) ) | 427 | if ( !QFile::exists( mw->captureFileName() ) ) |
428 | { | 428 | { |
429 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); | 429 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); |
430 | return; | 430 | return; |
431 | } | 431 | } |
432 | 432 | ||
433 | QFile f( mw->captureFileName() ); | 433 | QFile f( mw->captureFileName() ); |
434 | if ( !f.open( IO_ReadOnly ) ) | 434 | if ( !f.open( IO_ReadOnly ) ) |
435 | { | 435 | { |
436 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); | 436 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | 439 | ||
440 | int content_length = f.size(); | 440 | int content_length = f.size(); |
441 | 441 | ||
442 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); | 442 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); |
443 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 443 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
444 | raddr.sin_family = rhost_info-> h_addrtype; | 444 | raddr.sin_family = rhost_info-> h_addrtype; |
445 | raddr.sin_port = htons ( 80 ); | 445 | raddr.sin_port = htons ( 80 ); |
446 | 446 | ||
447 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); | 447 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); |
448 | 448 | ||
449 | if ( sock >= 0 ) | 449 | if ( sock >= 0 ) |
450 | { | 450 | { |
451 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) | 451 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) |
452 | { | 452 | { |
453 | QString header; | 453 | QString header; |
454 | QString content; | 454 | QString content; |
455 | QString preambel; | 455 | QString preambel; |
456 | 456 | ||
457 | header = "" | 457 | header = "" |
458 | "POST /projects/capturedump.spy HTTP/1.1\r\n" | 458 | "POST /projects/capturedump.spy HTTP/1.1\r\n" |
459 | "Host: www.vanille.de\r\n" | 459 | "Host: www.vanille.de\r\n" |
460 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" | 460 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" |
461 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" | 461 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" |
462 | "Accept-Language: en\r\n" | 462 | "Accept-Language: en\r\n" |
463 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" | 463 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" |
464 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" | 464 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" |
465 | "Keep-Alive: 300\r\n" | 465 | "Keep-Alive: 300\r\n" |
466 | "Connection: keep-alive\r\n" | 466 | "Connection: keep-alive\r\n" |
467 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" | 467 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" |
468 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" | 468 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" |
469 | "Content-Length: %1\r\n" | 469 | "Content-Length: %1\r\n" |
470 | "\r\n"; | 470 | "\r\n"; |
471 | 471 | ||
472 | content = "" | 472 | content = "" |
473 | "-----------------------------97267758015830030481215568065\r\n" | 473 | "-----------------------------97267758015830030481215568065\r\n" |
474 | "Content-Disposition: form-data; name=\"Name\"\r\n" | 474 | "Content-Disposition: form-data; name=\"Name\"\r\n" |
475 | "\r\n" | 475 | "\r\n" |
476 | "%1\r\n" | 476 | "%1\r\n" |
477 | "-----------------------------97267758015830030481215568065\r\n" | 477 | "-----------------------------97267758015830030481215568065\r\n" |
478 | "Content-Disposition: form-data; name=\"Location\"\r\n" | 478 | "Content-Disposition: form-data; name=\"Location\"\r\n" |
479 | "\r\n" | 479 | "\r\n" |
480 | "%2\r\n" | 480 | "%2\r\n" |
481 | "-----------------------------97267758015830030481215568065\r\n" | 481 | "-----------------------------97267758015830030481215568065\r\n" |
482 | "Content-Disposition: form-data; name=\"Comments\"\r\n" | 482 | "Content-Disposition: form-data; name=\"Comments\"\r\n" |
483 | "\r\n" | 483 | "\r\n" |
484 | "%3\r\n" | 484 | "%3\r\n" |
485 | "-----------------------------97267758015830030481215568065\r\n" | 485 | "-----------------------------97267758015830030481215568065\r\n" |
486 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" | 486 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" |
487 | "Content-Type: application/octet-stream\r\n" | 487 | "Content-Type: application/octet-stream\r\n" |
488 | "\r\n"; | 488 | "\r\n"; |
489 | 489 | ||
490 | preambel = "" | 490 | preambel = "" |
491 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; | 491 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; |
492 | 492 | ||
493 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); | 493 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); |
494 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); | 494 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); |
495 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); | 495 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); |
496 | content = content.arg( mw->captureFileName() ); | 496 | content = content.arg( mw->captureFileName() ); |
497 | 497 | ||
498 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); | 498 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); |
499 | 499 | ||
500 | // write header | 500 | // write header |
501 | 501 | ||
502 | const char* ascii = header.latin1(); | 502 | const char* ascii = header.latin1(); |
503 | uint ascii_len = ::strlen( ascii ); | 503 | uint ascii_len = ::strlen( ascii ); |
504 | ::write ( sock, ascii, ascii_len ); | 504 | ::write ( sock, ascii, ascii_len ); |
505 | 505 | ||
506 | // write fixed content | 506 | // write fixed content |
507 | 507 | ||
508 | ascii = content.latin1(); | 508 | ascii = content.latin1(); |
509 | ascii_len = ::strlen( ascii ); | 509 | ascii_len = ::strlen( ascii ); |
510 | ::write ( sock, ascii, ascii_len ); | 510 | ::write ( sock, ascii, ascii_len ); |
511 | 511 | ||
512 | // write variable content | 512 | // write variable content |
513 | 513 | ||
514 | char ch; | 514 | char ch; |
515 | while ( !f.atEnd() ) | 515 | while ( !f.atEnd() ) |
516 | { | 516 | { |
517 | f.readBlock( &ch, 1 ); | 517 | f.readBlock( &ch, 1 ); |
518 | ::write ( sock, &ch, 1 ); | 518 | ::write ( sock, &ch, 1 ); |
519 | } | 519 | } |
520 | 520 | ||
521 | // write preambel | 521 | // write preambel |
522 | 522 | ||
523 | ascii = preambel.latin1(); | 523 | ascii = preambel.latin1(); |
524 | ascii_len = ::strlen( ascii ); | 524 | ascii_len = ::strlen( ascii ); |
525 | ::write ( sock, ascii, ascii_len ); | 525 | ::write ( sock, ascii, ascii_len ); |
526 | 526 | ||
527 | // done! | 527 | // done! |
528 | 528 | ||
529 | ok = true; | 529 | ok = true; |
530 | } | 530 | } |
531 | } | 531 | } |
532 | ::close ( sock ); | 532 | ::close ( sock ); |
533 | } | 533 | } |
534 | if ( ok ) | 534 | if ( ok ) |
535 | QMessageBox::information( 0, tr( "Success" ), | 535 | QMessageBox::information( 0, tr( "Success" ), |
536 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); | 536 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); |
537 | else | 537 | else |
538 | QMessageBox::warning( 0, tr( "Error" ), | 538 | QMessageBox::warning( 0, tr( "Error" ), |
539 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); | 539 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); |
540 | } | 540 | } |
541 | 541 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 1cca507..d89c71f 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,569 +1,566 @@ | |||
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 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | 26 | ||
27 | #ifdef QWS | 27 | #ifdef QWS |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <opie/odevice.h> | 29 | #include <opie/odevice.h> |
30 | using namespace Opie; | 30 | using namespace Opie; |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | 33 | ||
34 | #ifdef QWS | 34 | #ifdef QWS |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #else | 36 | #else |
37 | #include "resource.h" | 37 | #include "resource.h" |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | const int col_type = 0; | 40 | const int col_type = 0; |
41 | const int col_essid = 0; | 41 | const int col_essid = 0; |
42 | const int col_sig = 1; | 42 | const int col_sig = 1; |
43 | const int col_ap = 2; | 43 | const int col_ap = 2; |
44 | const int col_channel = 3; | 44 | const int col_channel = 3; |
45 | const int col_wep = 4; | 45 | const int col_wep = 4; |
46 | const int col_traffic = 5; | 46 | const int col_traffic = 5; |
47 | const int col_ip = 6; | 47 | const int col_ip = 6; |
48 | const int col_manuf = 7; | 48 | const int col_manuf = 7; |
49 | const int col_firstseen = 8; | 49 | const int col_firstseen = 8; |
50 | const int col_lastseen = 9; | 50 | const int col_lastseen = 9; |
51 | const int col_location = 10; | 51 | const int col_location = 10; |
52 | 52 | ||
53 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 53 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
54 | :OListView( parent, name ) | 54 | :OListView( parent, name ) |
55 | { | 55 | { |
56 | 56 | ||
57 | setFrameShape( QListView::StyledPanel ); | 57 | setFrameShape( QListView::StyledPanel ); |
58 | setFrameShadow( QListView::Sunken ); | 58 | setFrameShadow( QListView::Sunken ); |
59 | 59 | ||
60 | addColumn( tr( "Net/Station" ) ); | 60 | addColumn( tr( "Net/Station" ) ); |
61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
62 | addColumn( tr( "#" ) ); | 62 | addColumn( tr( "#" ) ); |
63 | setColumnAlignment( col_sig, AlignCenter ); | 63 | setColumnAlignment( col_sig, AlignCenter ); |
64 | addColumn( tr( "MAC" ) ); | 64 | addColumn( tr( "MAC" ) ); |
65 | setColumnAlignment( col_ap, AlignCenter ); | 65 | setColumnAlignment( col_ap, AlignCenter ); |
66 | addColumn( tr( "Chn" ) ); | 66 | addColumn( tr( "Chn" ) ); |
67 | setColumnAlignment( col_channel, AlignCenter ); | 67 | setColumnAlignment( col_channel, AlignCenter ); |
68 | addColumn( tr( "W" ) ); | 68 | addColumn( tr( "W" ) ); |
69 | setColumnAlignment( col_wep, AlignCenter ); | 69 | setColumnAlignment( col_wep, AlignCenter ); |
70 | addColumn( tr( "T" ) ); | 70 | addColumn( tr( "T" ) ); |
71 | setColumnAlignment( col_traffic, AlignCenter ); | 71 | setColumnAlignment( col_traffic, AlignCenter ); |
72 | addColumn( tr( "IP" ) ); | 72 | addColumn( tr( "IP" ) ); |
73 | setColumnAlignment( col_ip, AlignCenter ); | 73 | setColumnAlignment( col_ip, AlignCenter ); |
74 | addColumn( tr( "Manufacturer" ) ); | 74 | addColumn( tr( "Manufacturer" ) ); |
75 | setColumnAlignment( col_manuf, AlignCenter ); | 75 | setColumnAlignment( col_manuf, AlignCenter ); |
76 | addColumn( tr( "First Seen" ) ); | 76 | addColumn( tr( "First Seen" ) ); |
77 | setColumnAlignment( col_firstseen, AlignCenter ); | 77 | setColumnAlignment( col_firstseen, AlignCenter ); |
78 | addColumn( tr( "Last Seen" ) ); | 78 | addColumn( tr( "Last Seen" ) ); |
79 | setColumnAlignment( col_lastseen, AlignCenter ); | 79 | setColumnAlignment( col_lastseen, AlignCenter ); |
80 | addColumn( tr( "Location" ) ); | 80 | addColumn( tr( "Location" ) ); |
81 | setColumnAlignment( col_location, AlignCenter ); | 81 | setColumnAlignment( col_location, AlignCenter ); |
82 | setRootIsDecorated( true ); | 82 | setRootIsDecorated( true ); |
83 | setAllColumnsShowFocus( true ); | 83 | setAllColumnsShowFocus( true ); |
84 | 84 | ||
85 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 85 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
86 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 86 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
87 | 87 | ||
88 | #ifdef QWS | 88 | #ifdef QWS |
89 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 89 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | MScanListView::~MScanListView() | 95 | MScanListView::~MScanListView() |
96 | { | 96 | { |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | OListViewItem* MScanListView::childFactory() | 100 | OListViewItem* MScanListView::childFactory() |
101 | { | 101 | { |
102 | return new MScanListItem( this ); | 102 | return new MScanListItem( this ); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void MScanListView::serializeTo( QDataStream& s) const | 106 | void MScanListView::serializeTo( QDataStream& s) const |
107 | { | 107 | { |
108 | qDebug( "serializing MScanListView" ); | 108 | qDebug( "serializing MScanListView" ); |
109 | OListView::serializeTo( s ); | 109 | OListView::serializeTo( s ); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void MScanListView::serializeFrom( QDataStream& s) | 113 | void MScanListView::serializeFrom( QDataStream& s) |
114 | { | 114 | { |
115 | qDebug( "serializing MScanListView" ); | 115 | qDebug( "serializing MScanListView" ); |
116 | OListView::serializeFrom( s ); | 116 | OListView::serializeFrom( s ); |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void MScanListView::addNewItem( const QString& type, | 120 | void MScanListView::addNewItem( const QString& type, |
121 | const QString& essid, | 121 | const QString& essid, |
122 | const OMacAddress& mac, | 122 | const OMacAddress& mac, |
123 | bool wep, | 123 | bool wep, |
124 | int channel, | 124 | int channel, |
125 | int signal, | 125 | int signal, |
126 | const GpsLocation& loc ) | 126 | const GpsLocation& loc ) |
127 | { | 127 | { |
128 | QString macaddr = mac.toString(true); | 128 | QString macaddr = mac.toString(true); |
129 | 129 | ||
130 | #ifdef DEBUG | 130 | #ifdef DEBUG |
131 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 131 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
132 | (const char*) essid, (const char*) macaddr, channel ); | 132 | (const char*) essid, (const char*) macaddr, channel ); |
133 | #endif | 133 | #endif |
134 | 134 | ||
135 | // search, if we already have seen this net | 135 | // search, if we already have seen this net |
136 | 136 | ||
137 | QString s; | 137 | QString s; |
138 | MScanListItem* network; | 138 | MScanListItem* network; |
139 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 139 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
140 | 140 | ||
141 | while ( item && ( item->text( col_essid ) != essid ) ) | 141 | while ( item && ( item->text( col_essid ) != essid ) ) |
142 | { | 142 | { |
143 | #ifdef DEBUG | 143 | #ifdef DEBUG |
144 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 144 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
145 | #endif | 145 | #endif |
146 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 146 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
147 | } | 147 | } |
148 | if ( item ) | 148 | if ( item ) |
149 | { | 149 | { |
150 | // we have already seen this net, check all childs if MAC exists | 150 | // we have already seen this net, check all childs if MAC exists |
151 | 151 | ||
152 | network = item; | 152 | network = item; |
153 | 153 | ||
154 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 154 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
155 | assert( item ); // this shouldn't fail | 155 | assert( item ); // this shouldn't fail |
156 | 156 | ||
157 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 157 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
158 | { | 158 | { |
159 | #ifdef DEBUG | 159 | #ifdef DEBUG |
160 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 160 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
161 | #endif | 161 | #endif |
162 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 162 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
163 | } | 163 | } |
164 | 164 | ||
165 | if ( item ) | 165 | if ( item ) |
166 | { | 166 | { |
167 | // we have already seen this item, it's a dupe | 167 | // we have already seen this item, it's a dupe |
168 | #ifdef DEBUG | 168 | #ifdef DEBUG |
169 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 169 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
170 | #endif | 170 | #endif |
171 | item->receivedBeacon(); | 171 | item->receivedBeacon(); |
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | else | 175 | else |
176 | { | 176 | { |
177 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 177 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
178 | MLogWindow::logwindow()->log( s ); | 178 | MLogWindow::logwindow()->log( s ); |
179 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 179 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | // insert new station as child from network | 183 | // insert new station as child from network |
184 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 184 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
185 | 185 | ||
186 | #ifdef DEBUG | 186 | #ifdef DEBUG |
187 | qDebug( "inserting new station %s", (const char*) macaddr ); | 187 | qDebug( "inserting new station %s", (const char*) macaddr ); |
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
191 | station->setManufacturer( mac.manufacturer() ); | 191 | station->setManufacturer( mac.manufacturer() ); |
192 | station->setLocation( loc.latitude, loc.longitude ); | 192 | station->setLocation( loc.dmsPosition() ); |
193 | 193 | ||
194 | if ( type == "managed" ) | 194 | if ( type == "managed" ) |
195 | { | 195 | { |
196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
197 | } | 197 | } |
198 | else | 198 | else |
199 | { | 199 | { |
200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
201 | } | 201 | } |
202 | MLogWindow::logwindow()->log( s ); | 202 | MLogWindow::logwindow()->log( s ); |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
208 | { | 208 | { |
209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
210 | 210 | ||
211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
212 | { | 212 | { |
213 | #ifdef DEBUG | 213 | #ifdef DEBUG |
214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
215 | #endif | 215 | #endif |
216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
217 | } | 217 | } |
218 | 218 | ||
219 | if ( subitem ) | 219 | if ( subitem ) |
220 | { | 220 | { |
221 | // we have already seen this item, it's a dupe | 221 | // we have already seen this item, it's a dupe |
222 | #ifdef DEBUG | 222 | #ifdef DEBUG |
223 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 223 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
224 | #endif | 224 | #endif |
225 | subitem->receivedBeacon(); //FIXME: sent data bit | 225 | subitem->receivedBeacon(); //FIXME: sent data bit |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | // Hey, it seems to be a new item :-D | 229 | // Hey, it seems to be a new item :-D |
230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
231 | station->setManufacturer( addr.manufacturer() ); | 231 | station->setManufacturer( addr.manufacturer() ); |
232 | 232 | ||
233 | QString s; | 233 | QString s; |
234 | if ( type == "station" ) | 234 | if ( type == "station" ) |
235 | { | 235 | { |
236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
237 | } | 237 | } |
238 | else | 238 | else |
239 | { | 239 | { |
240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
241 | } | 241 | } |
242 | MLogWindow::logwindow()->log( s ); | 242 | MLogWindow::logwindow()->log( s ); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
247 | { | 247 | { |
248 | QString s; | 248 | QString s; |
249 | MScanListItem* network; | 249 | MScanListItem* network; |
250 | 250 | ||
251 | QListViewItemIterator it( this ); | 251 | QListViewItemIterator it( this ); |
252 | while ( it.current() && | 252 | while ( it.current() && |
253 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 253 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
254 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 254 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
255 | 255 | ||
256 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 256 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
257 | 257 | ||
258 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 258 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
259 | { | 259 | { |
260 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 260 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
262 | } | 262 | } |
263 | else | 263 | else |
264 | { | 264 | { |
265 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 265 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
266 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 266 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 271 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
272 | { | 272 | { |
273 | QString s; | 273 | QString s; |
274 | MScanListItem* network; | 274 | MScanListItem* network; |
275 | 275 | ||
276 | QListViewItemIterator it( this ); | 276 | QListViewItemIterator it( this ); |
277 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 277 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
278 | 278 | ||
279 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 279 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
280 | 280 | ||
281 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 281 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
282 | { | 282 | { |
283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
289 | 289 | ||
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
295 | { | 295 | { |
296 | QString s; | 296 | QString s; |
297 | MScanListItem* network; | 297 | MScanListItem* network; |
298 | 298 | ||
299 | QListViewItemIterator it( this ); | 299 | QListViewItemIterator it( this ); |
300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
301 | 301 | ||
302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
303 | 303 | ||
304 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 304 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
305 | { | 305 | { |
306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
317 | { | 317 | { |
318 | qWarning( "D'oh! Not yet implemented..." ); | 318 | qWarning( "D'oh! Not yet implemented..." ); |
319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
324 | { | 324 | { |
325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
326 | 326 | ||
327 | QListViewItemIterator it( this ); | 327 | QListViewItemIterator it( this ); |
328 | for ( ; it.current(); ++it ) | 328 | for ( ; it.current(); ++it ) |
329 | { | 329 | { |
330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
331 | { | 331 | { |
332 | it.current()->setText( col_ip, ip ); | 332 | it.current()->setText( col_ip, ip ); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
338 | (const char*) macaddr.toString(), (const char*) ip ) ); | 338 | (const char*) macaddr.toString(), (const char*) ip ) ); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
343 | { | 343 | { |
344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); |
345 | 345 | ||
346 | //TODO: Refactor that out, we need it all over the place. | 346 | //TODO: Refactor that out, we need it all over the place. |
347 | // Best to do it in a more comfortable abstraction in OListView | 347 | // Best to do it in a more comfortable abstraction in OListView |
348 | // (Hmm, didn't I already start something in this direction?) | 348 | // (Hmm, didn't I already start something in this direction?) |
349 | 349 | ||
350 | QListViewItemIterator it( this ); | 350 | QListViewItemIterator it( this ); |
351 | for ( ; it.current(); ++it ) | 351 | for ( ; it.current(); ++it ) |
352 | { | 352 | { |
353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
354 | { | 354 | { |
355 | 355 | ||
356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
357 | 357 | ||
358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
359 | { | 359 | { |
360 | #ifdef DEBUG | 360 | #ifdef DEBUG |
361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); |
362 | #endif | 362 | #endif |
363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
364 | } | 364 | } |
365 | 365 | ||
366 | if ( subitem ) | 366 | if ( subitem ) |
367 | { | 367 | { |
368 | // we have already seen this item, it's a dupe | 368 | // we have already seen this item, it's a dupe |
369 | #ifdef DEBUG | 369 | #ifdef DEBUG |
370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); |
371 | #endif | 371 | #endif |
372 | subitem->receivedBeacon(); //FIXME: sent data bit | 372 | subitem->receivedBeacon(); //FIXME: sent data bit |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | // never seen that - add new item | 376 | // never seen that - add new item |
377 | 377 | ||
378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
379 | item->setText( col_essid, name ); | 379 | item->setText( col_essid, name ); |
380 | 380 | ||
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
386 | (const char*) macaddr.toString(), (const char*) ip ) ); | 386 | (const char*) macaddr.toString(), (const char*) ip ) ); |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
391 | { | 391 | { |
392 | if ( !item ) return; | 392 | if ( !item ) return; |
393 | 393 | ||
394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
395 | 395 | ||
396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
397 | (const char*) itm->text(0), (const char*) itm->type, col ); | 397 | (const char*) itm->text(0), (const char*) itm->type, col ); |
398 | 398 | ||
399 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 399 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
400 | { | 400 | { |
401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
402 | 402 | ||
403 | QPopupMenu m( this ); | 403 | QPopupMenu m( this ); |
404 | m.insertItem( entry, 37773, 0 ); | 404 | m.insertItem( entry, 37773, 0 ); |
405 | int result = m.exec( QCursor::pos() ); | 405 | int result = m.exec( QCursor::pos() ); |
406 | if ( result == 37773 ) | 406 | if ( result == 37773 ) |
407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | //============================================================ | 411 | //============================================================ |
412 | // MScanListItem | 412 | // MScanListItem |
413 | //============================================================ | 413 | //============================================================ |
414 | 414 | ||
415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
416 | bool wep, int channel, int signal ) | 416 | bool wep, int channel, int signal ) |
417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
419 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 419 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
420 | { | 420 | { |
421 | #ifdef DEBUG | 421 | #ifdef DEBUG |
422 | qDebug( "creating scanlist item" ); | 422 | qDebug( "creating scanlist item" ); |
423 | #endif | 423 | #endif |
424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) | 424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) |
425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
426 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 426 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
427 | } | 427 | } |
428 | 428 | ||
429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
430 | bool wep, int channel, int signal ) | 430 | bool wep, int channel, int signal ) |
431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
432 | { | 432 | { |
433 | #ifdef DEBUG | 433 | #ifdef DEBUG |
434 | qDebug( "creating scanlist item" ); | 434 | qDebug( "creating scanlist item" ); |
435 | #endif | 435 | #endif |
436 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 436 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
437 | } | 437 | } |
438 | 438 | ||
439 | const QString& MScanListItem::essid() const | 439 | const QString& MScanListItem::essid() const |
440 | { | 440 | { |
441 | if ( type == "network" ) | 441 | if ( type == "network" ) |
442 | return _essid; | 442 | return _essid; |
443 | else | 443 | else |
444 | return ( (MScanListItem*) parent() )->essid(); | 444 | return ( (MScanListItem*) parent() )->essid(); |
445 | } | 445 | } |
446 | 446 | ||
447 | OListViewItem* MScanListItem::childFactory() | 447 | OListViewItem* MScanListItem::childFactory() |
448 | { | 448 | { |
449 | return new MScanListItem( this ); | 449 | return new MScanListItem( this ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void MScanListItem::serializeTo( QDataStream& s ) const | 452 | void MScanListItem::serializeTo( QDataStream& s ) const |
453 | { | 453 | { |
454 | #ifdef DEBUG | 454 | #ifdef DEBUG |
455 | qDebug( "serializing MScanListItem" ); | 455 | qDebug( "serializing MScanListItem" ); |
456 | #endif | 456 | #endif |
457 | OListViewItem::serializeTo( s ); | 457 | OListViewItem::serializeTo( s ); |
458 | 458 | ||
459 | s << _type; | 459 | s << _type; |
460 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 460 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void MScanListItem::serializeFrom( QDataStream& s ) | 463 | void MScanListItem::serializeFrom( QDataStream& s ) |
464 | { | 464 | { |
465 | #ifdef DEBUG | 465 | #ifdef DEBUG |
466 | qDebug( "serializing MScanListItem" ); | 466 | qDebug( "serializing MScanListItem" ); |
467 | #endif | 467 | #endif |
468 | OListViewItem::serializeFrom( s ); | 468 | OListViewItem::serializeFrom( s ); |
469 | 469 | ||
470 | char wep; | 470 | char wep; |
471 | s >> _type; | 471 | s >> _type; |
472 | s >> (Q_UINT8) wep; | 472 | s >> (Q_UINT8) wep; |
473 | _wep = (wep == 'y'); | 473 | _wep = (wep == 'y'); |
474 | 474 | ||
475 | QString name; | 475 | QString name; |
476 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 476 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
477 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 477 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
478 | if ( _wep ) | 478 | if ( _wep ) |
479 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 479 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
480 | listView()->triggerUpdate(); | 480 | listView()->triggerUpdate(); |
481 | } | 481 | } |
482 | 482 | ||
483 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 483 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
484 | { | 484 | { |
485 | #ifdef DEBUG | 485 | #ifdef DEBUG |
486 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 486 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
487 | (const char*) type, | 487 | (const char*) type, |
488 | (const char*) essid, | 488 | (const char*) essid, |
489 | (const char*) macaddr, | 489 | (const char*) macaddr, |
490 | channel ); | 490 | channel ); |
491 | #endif | 491 | #endif |
492 | 492 | ||
493 | // set icon for managed or adhoc mode | 493 | // set icon for managed or adhoc mode |
494 | QString name; | 494 | QString name; |
495 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 495 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
496 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 496 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
497 | 497 | ||
498 | // set icon for wep (wireless encryption protocol) | 498 | // set icon for wep (wireless encryption protocol) |
499 | if ( wep ) | 499 | if ( wep ) |
500 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 500 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
501 | 501 | ||
502 | // set channel and signal text | 502 | // set channel and signal text |
503 | 503 | ||
504 | if ( signal != -1 ) | 504 | if ( signal != -1 ) |
505 | setText( col_sig, QString::number( signal ) ); | 505 | setText( col_sig, QString::number( signal ) ); |
506 | if ( channel != -1 ) | 506 | if ( channel != -1 ) |
507 | setText( col_channel, QString::number( channel ) ); | 507 | setText( col_channel, QString::number( channel ) ); |
508 | 508 | ||
509 | setText( col_firstseen, QTime::currentTime().toString() ); | 509 | setText( col_firstseen, QTime::currentTime().toString() ); |
510 | //setText( col_lastseen, QTime::currentTime().toString() ); | 510 | //setText( col_lastseen, QTime::currentTime().toString() ); |
511 | 511 | ||
512 | listView()->triggerUpdate(); | 512 | listView()->triggerUpdate(); |
513 | 513 | ||
514 | this->type = type; | 514 | this->type = type; |
515 | _type = type; | 515 | _type = type; |
516 | _essid = essid; | 516 | _essid = essid; |
517 | _macaddr = macaddr; | 517 | _macaddr = macaddr; |
518 | _channel = channel; | 518 | _channel = channel; |
519 | _beacons = 1; | 519 | _beacons = 1; |
520 | _signal = 0; | 520 | _signal = 0; |
521 | 521 | ||
522 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 522 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
523 | { | 523 | { |
524 | listView()->ensureItemVisible( this ); | 524 | listView()->ensureItemVisible( this ); |
525 | } | 525 | } |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 530 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
531 | { | 531 | { |
532 | setText( col_manuf, manufacturer ); | 532 | setText( col_manuf, manufacturer ); |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) | 536 | void MScanListItem::setLocation( const QString& location ) |
537 | { | 537 | { |
538 | if ( latitude == 0.0 || longitude == 0.0 ) | 538 | setText( col_location, location ); |
539 | setText( col_location, "N/A" ); | ||
540 | else | ||
541 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); | ||
542 | } | 539 | } |
543 | 540 | ||
544 | 541 | ||
545 | void MScanListItem::playSound( const QString& sound ) const | 542 | void MScanListItem::playSound( const QString& sound ) const |
546 | { | 543 | { |
547 | #ifdef QWS | 544 | #ifdef QWS |
548 | if ( sound == "Ignore" ) return; | 545 | if ( sound == "Ignore" ) return; |
549 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 546 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); |
550 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 547 | else if ( sound == "Key" ) ODevice::inst()->keySound(); |
551 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 548 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); |
552 | #endif | 549 | #endif |
553 | } | 550 | } |
554 | 551 | ||
555 | 552 | ||
556 | void MScanListItem::receivedBeacon() | 553 | void MScanListItem::receivedBeacon() |
557 | { | 554 | { |
558 | _beacons++; | 555 | _beacons++; |
559 | #ifdef DEBUG | 556 | #ifdef DEBUG |
560 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 557 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
561 | #endif | 558 | #endif |
562 | setText( col_sig, QString::number( _beacons ) ); | 559 | setText( col_sig, QString::number( _beacons ) ); |
563 | setText( col_lastseen, QTime::currentTime().toString() ); | 560 | setText( col_lastseen, QTime::currentTime().toString() ); |
564 | 561 | ||
565 | MScanListItem* p = (MScanListItem*) parent(); | 562 | MScanListItem* p = (MScanListItem*) parent(); |
566 | if ( p ) p->receivedBeacon(); | 563 | if ( p ) p->receivedBeacon(); |
567 | 564 | ||
568 | } | 565 | } |
569 | 566 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index a9b74f1..6cd8fc0 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -1,142 +1,142 @@ | |||
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" | 19 | #include "gps.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/olistview.h> | 22 | #include <opie2/olistview.h> |
23 | #include <opie2/onetutils.h> | 23 | #include <opie2/onetutils.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | 27 | ||
28 | class QString; | 28 | class QString; |
29 | class MScanListItem; | 29 | class MScanListItem; |
30 | 30 | ||
31 | class MScanListView: public OListView | 31 | class MScanListView: public OListView |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | public: | 35 | public: |
36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); | 36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); |
37 | virtual ~MScanListView(); | 37 | virtual ~MScanListView(); |
38 | 38 | ||
39 | virtual OListViewItem* childFactory(); | 39 | virtual OListViewItem* childFactory(); |
40 | virtual void serializeTo( QDataStream& s ) const; | 40 | virtual void serializeTo( QDataStream& s ) const; |
41 | virtual void serializeFrom( QDataStream& s ); | 41 | virtual void serializeFrom( QDataStream& s ); |
42 | 42 | ||
43 | public slots: | 43 | public slots: |
44 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); | 44 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); |
45 | void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); | 45 | void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); |
46 | 46 | ||
47 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 47 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
48 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 48 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
49 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); | 49 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); |
50 | void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 50 | void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
51 | 51 | ||
52 | void identify( const OMacAddress&, const QString& ipaddr ); | 52 | void identify( const OMacAddress&, const QString& ipaddr ); |
53 | 53 | ||
54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); | 54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); |
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); | 57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); |
58 | void joinNetwork( const QString&, const QString&, int, const QString& ); | 58 | void joinNetwork( const QString&, const QString&, int, const QString& ); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); | 61 | void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); |
62 | 62 | ||
63 | }; | 63 | }; |
64 | 64 | ||
65 | //****************************** MScanListItem **************************************************************** | 65 | //****************************** MScanListItem **************************************************************** |
66 | 66 | ||
67 | class MScanListItem: public OListViewItem | 67 | class MScanListItem: public OListViewItem |
68 | { | 68 | { |
69 | public: | 69 | public: |
70 | MScanListItem::MScanListItem( QListView* parent, | 70 | MScanListItem::MScanListItem( QListView* parent, |
71 | QString type = "unknown", | 71 | QString type = "unknown", |
72 | QString essid = "unknown", | 72 | QString essid = "unknown", |
73 | QString macaddr = "unknown", | 73 | QString macaddr = "unknown", |
74 | bool wep = false, | 74 | bool wep = false, |
75 | int channel = 0, | 75 | int channel = 0, |
76 | int signal = 0 ); | 76 | int signal = 0 ); |
77 | 77 | ||
78 | MScanListItem::MScanListItem( QListViewItem* parent, | 78 | MScanListItem::MScanListItem( QListViewItem* parent, |
79 | QString type = "unknown", | 79 | QString type = "unknown", |
80 | QString essid = "unknown", | 80 | QString essid = "unknown", |
81 | QString macaddr = "unknown", | 81 | QString macaddr = "unknown", |
82 | bool wep = false, | 82 | bool wep = false, |
83 | int channel = 0, | 83 | int channel = 0, |
84 | int signal = 0 ); | 84 | int signal = 0 ); |
85 | 85 | ||
86 | 86 | ||
87 | protected: | 87 | protected: |
88 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | 88 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); |
89 | 89 | ||
90 | public: | 90 | public: |
91 | QString type; | 91 | QString type; |
92 | 92 | ||
93 | public: | 93 | public: |
94 | //const QString& type() { return _type; }; | 94 | //const QString& type() { return _type; }; |
95 | const QString& essid() const; | 95 | const QString& essid() const; |
96 | const QString& macaddr() { return _macaddr; }; | 96 | const QString& macaddr() { return _macaddr; }; |
97 | bool wep() { return _wep; }; | 97 | bool wep() { return _wep; }; |
98 | int channel() { return _channel; }; | 98 | int channel() { return _channel; }; |
99 | int signal() { return _signal; }; | 99 | int signal() { return _signal; }; |
100 | int beacons() { return _beacons; }; | 100 | int beacons() { return _beacons; }; |
101 | 101 | ||
102 | void setSignal( int signal ) { /* TODO */ }; | 102 | void setSignal( int signal ) { /* TODO */ }; |
103 | void receivedBeacon(); | 103 | void receivedBeacon(); |
104 | 104 | ||
105 | void setManufacturer( const QString& manufacturer ); | 105 | void setManufacturer( const QString& manufacturer ); |
106 | void setLocation( const float& latitude, const float& longitude ); | 106 | void setLocation( const QString& location ); |
107 | 107 | ||
108 | virtual OListViewItem* childFactory(); | 108 | virtual OListViewItem* childFactory(); |
109 | virtual void serializeTo( QDataStream& s ) const; | 109 | virtual void serializeTo( QDataStream& s ) const; |
110 | virtual void serializeFrom( QDataStream& s ); | 110 | virtual void serializeFrom( QDataStream& s ); |
111 | 111 | ||
112 | protected: | 112 | protected: |
113 | void playSound( const QString& ) const; | 113 | void playSound( const QString& ) const; |
114 | 114 | ||
115 | private: | 115 | private: |
116 | QString _type; | 116 | QString _type; |
117 | QString _essid; | 117 | QString _essid; |
118 | QString _macaddr; | 118 | QString _macaddr; |
119 | bool _wep; | 119 | bool _wep; |
120 | int _channel; | 120 | int _channel; |
121 | int _signal; | 121 | int _signal; |
122 | int _beacons; | 122 | int _beacons; |
123 | 123 | ||
124 | }; | 124 | }; |
125 | 125 | ||
126 | //****************************** MScanListViewFactory **************************************************************** | 126 | //****************************** MScanListViewFactory **************************************************************** |
127 | 127 | ||
128 | /* | 128 | /* |
129 | 129 | ||
130 | class MScanListViewFactory : public OListViewFactory | 130 | class MScanListViewFactory : public OListViewFactory |
131 | { | 131 | { |
132 | public: | 132 | public: |
133 | virtual QListView* listViewFactory(); | 133 | virtual QListView* listViewFactory(); |
134 | virtual QListViewItem* listViewItemFactory( QListView* lv ); | 134 | virtual QListViewItem* listViewItemFactory( QListView* lv ); |
135 | virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); | 135 | virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); |
136 | virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); | 136 | virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); |
137 | virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); | 137 | virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); |
138 | } | 138 | } |
139 | */ | 139 | */ |
140 | 140 | ||
141 | #endif | 141 | #endif |
142 | 142 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 9255a6d..5575d6e 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,660 +1,660 @@ | |||
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> |
33 | using namespace Opie; | 33 | using 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/omanufacturerdb.h> | 41 | #include <opie2/omanufacturerdb.h> |
42 | #include <opie2/onetwork.h> | 42 | #include <opie2/onetwork.h> |
43 | #include <opie2/opcap.h> | 43 | #include <opie2/opcap.h> |
44 | 44 | ||
45 | // Qt | 45 | // Qt |
46 | 46 | ||
47 | #include <qcheckbox.h> | 47 | #include <qcheckbox.h> |
48 | #include <qcombobox.h> | 48 | #include <qcombobox.h> |
49 | #include <qdatetime.h> | 49 | #include <qdatetime.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | #include <qlineedit.h> | 51 | #include <qlineedit.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qobjectlist.h> | 53 | #include <qobjectlist.h> |
54 | #include <qregexp.h> | 54 | #include <qregexp.h> |
55 | #include <qspinbox.h> | 55 | #include <qspinbox.h> |
56 | #include <qtimer.h> | 56 | #include <qtimer.h> |
57 | #include <qtoolbutton.h> | 57 | #include <qtoolbutton.h> |
58 | #include <qmainwindow.h> | 58 | #include <qmainwindow.h> |
59 | 59 | ||
60 | // Standard | 60 | // Standard |
61 | 61 | ||
62 | #include <assert.h> | 62 | #include <assert.h> |
63 | #include <errno.h> | 63 | #include <errno.h> |
64 | #include <unistd.h> | 64 | #include <unistd.h> |
65 | #include <string.h> | 65 | #include <string.h> |
66 | #include <sys/types.h> | 66 | #include <sys/types.h> |
67 | #include <stdlib.h> | 67 | #include <stdlib.h> |
68 | 68 | ||
69 | Wellenreiter::Wellenreiter( QWidget* parent ) | 69 | Wellenreiter::Wellenreiter( QWidget* parent ) |
70 | : WellenreiterBase( parent, 0, 0 ), | 70 | : WellenreiterBase( parent, 0, 0 ), |
71 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 71 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
72 | { | 72 | { |
73 | 73 | ||
74 | logwindow->log( "(i) Wellenreiter has been started." ); | 74 | logwindow->log( "(i) Wellenreiter has been started." ); |
75 | 75 | ||
76 | // | 76 | // |
77 | // detect operating system | 77 | // detect operating system |
78 | // | 78 | // |
79 | 79 | ||
80 | #ifdef QWS | 80 | #ifdef QWS |
81 | QString sys; | 81 | QString sys; |
82 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 82 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
83 | _system = ODevice::inst()->system(); | 83 | _system = ODevice::inst()->system(); |
84 | logwindow->log( sys ); | 84 | logwindow->log( sys ); |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | netview->setColumnWidthMode( 1, QListView::Manual ); | 87 | netview->setColumnWidthMode( 1, QListView::Manual ); |
88 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 88 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
89 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 89 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
90 | pcap = new OPacketCapturer(); | 90 | pcap = new OPacketCapturer(); |
91 | 91 | ||
92 | gps = new GPS( this ); | 92 | gps = new GPS( this ); |
93 | 93 | ||
94 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); | 94 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | Wellenreiter::~Wellenreiter() | 99 | Wellenreiter::~Wellenreiter() |
100 | { | 100 | { |
101 | delete pcap; | 101 | delete pcap; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | void Wellenreiter::initialTimer() | 105 | void Wellenreiter::initialTimer() |
106 | { | 106 | { |
107 | qDebug( "Wellenreiter::preloading manufacturer database..." ); | 107 | qDebug( "Wellenreiter::preloading manufacturer database..." ); |
108 | OManufacturerDB::instance(); | 108 | OManufacturerDB::instance(); |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 112 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
113 | { | 113 | { |
114 | configwindow = cw; | 114 | configwindow = cw; |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | void Wellenreiter::channelHopped(int c) | 118 | void Wellenreiter::channelHopped(int c) |
119 | { | 119 | { |
120 | QString title = "Wellenreiter II -scan- ["; | 120 | QString title = "Wellenreiter II -scan- ["; |
121 | QString left; | 121 | QString left; |
122 | if ( c > 1 ) left.fill( '.', c-1 ); | 122 | if ( c > 1 ) left.fill( '.', c-1 ); |
123 | title.append( left ); | 123 | title.append( left ); |
124 | title.append( '|' ); | 124 | title.append( '|' ); |
125 | if ( c < iface->channels() ) | 125 | if ( c < iface->channels() ) |
126 | { | 126 | { |
127 | QString right; | 127 | QString right; |
128 | right.fill( '.', iface->channels()-c ); | 128 | right.fill( '.', iface->channels()-c ); |
129 | title.append( right ); | 129 | title.append( right ); |
130 | } | 130 | } |
131 | title.append( "]" ); | 131 | title.append( "]" ); |
132 | //title.append( QString().sprintf( " %02d", c ) ); | 132 | //title.append( QString().sprintf( " %02d", c ) ); |
133 | assert( parent() ); | 133 | assert( parent() ); |
134 | ( (QMainWindow*) parent() )->setCaption( title ); | 134 | ( (QMainWindow*) parent() )->setCaption( title ); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void Wellenreiter::handleNotification( OPacket* p ) | 138 | void Wellenreiter::handleNotification( OPacket* p ) |
139 | { | 139 | { |
140 | QObjectList* l = p->queryList(); | 140 | QObjectList* l = p->queryList(); |
141 | QObjectListIt it( *l ); | 141 | QObjectListIt it( *l ); |
142 | QObject* o; | 142 | QObject* o; |
143 | 143 | ||
144 | while ( (o = it.current()) != 0 ) | 144 | while ( (o = it.current()) != 0 ) |
145 | { | 145 | { |
146 | QString name = it.current()->name(); | 146 | QString name = it.current()->name(); |
147 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 147 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
148 | { | 148 | { |
149 | QString action = configwindow->parsePackets->protocolAction( name ); | 149 | QString action = configwindow->parsePackets->protocolAction( name ); |
150 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 150 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
151 | doAction( action, name, p ); | 151 | doAction( action, name, p ); |
152 | } | 152 | } |
153 | else | 153 | else |
154 | { | 154 | { |
155 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 155 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
156 | } | 156 | } |
157 | ++it; | 157 | ++it; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 162 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
163 | { | 163 | { |
164 | QString type; | 164 | QString type; |
165 | if ( beacon->canIBSS() ) | 165 | if ( beacon->canIBSS() ) |
166 | { | 166 | { |
167 | type = "adhoc"; | 167 | type = "adhoc"; |
168 | } | 168 | } |
169 | else if ( beacon->canESS() ) | 169 | else if ( beacon->canESS() ) |
170 | { | 170 | { |
171 | type = "managed"; | 171 | type = "managed"; |
172 | } | 172 | } |
173 | else | 173 | else |
174 | { | 174 | { |
175 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 175 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
176 | return; | 176 | return; |
177 | } | 177 | } |
178 | 178 | ||
179 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 179 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
180 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 180 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
181 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 181 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
182 | int channel = ds ? ds->channel() : -1; | 182 | int channel = ds ? ds->channel() : -1; |
183 | 183 | ||
184 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 184 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
185 | 185 | ||
186 | GpsLocation loc( 0, 0 ); | 186 | GpsLocation loc( 0, 0 ); |
187 | if ( configwindow->enableGPS->isChecked() ) | 187 | if ( configwindow->enableGPS->isChecked() ) |
188 | { | 188 | { |
189 | // TODO: add check if GPS is working!? | 189 | // TODO: add check if GPS is working!? |
190 | qDebug( "Wellenreiter::gathering GPS data..." ); | 190 | qDebug( "Wellenreiter::gathering GPS data..." ); |
191 | loc = gps->position(); | 191 | loc = gps->position(); |
192 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); | 192 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
193 | } | 193 | } |
194 | 194 | ||
195 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 195 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
196 | 196 | ||
197 | // update graph window | 197 | // update graph window |
198 | if ( ds ) | 198 | if ( ds ) |
199 | { | 199 | { |
200 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 200 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
201 | if ( prism ) | 201 | if ( prism ) |
202 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 202 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
203 | else | 203 | else |
204 | graphwindow->traffic( ds->channel(), 95 ); | 204 | graphwindow->traffic( ds->channel(), 95 ); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 209 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
210 | { | 210 | { |
211 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 211 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
212 | if ( wlan->fromDS() && !wlan->toDS() ) | 212 | if ( wlan->fromDS() && !wlan->toDS() ) |
213 | { | 213 | { |
214 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 214 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
215 | from = wlan->macAddress3(); | 215 | from = wlan->macAddress3(); |
216 | to = wlan->macAddress2(); | 216 | to = wlan->macAddress2(); |
217 | } | 217 | } |
218 | else if ( !wlan->fromDS() && wlan->toDS() ) | 218 | else if ( !wlan->fromDS() && wlan->toDS() ) |
219 | { | 219 | { |
220 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 220 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
221 | from = wlan->macAddress2(); | 221 | from = wlan->macAddress2(); |
222 | to = wlan->macAddress3(); | 222 | to = wlan->macAddress3(); |
223 | } | 223 | } |
224 | else if ( wlan->fromDS() && wlan->toDS() ) | 224 | else if ( wlan->fromDS() && wlan->toDS() ) |
225 | { | 225 | { |
226 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 226 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
227 | from = wlan->macAddress4(); | 227 | from = wlan->macAddress4(); |
228 | to = wlan->macAddress3(); | 228 | to = wlan->macAddress3(); |
229 | } | 229 | } |
230 | else | 230 | else |
231 | { | 231 | { |
232 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); | 232 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); |
233 | from = wlan->macAddress2(); | 233 | from = wlan->macAddress2(); |
234 | to = wlan->macAddress1(); | 234 | to = wlan->macAddress1(); |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) | 239 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) |
240 | { | 240 | { |
241 | from = data->sourceAddress(); | 241 | from = data->sourceAddress(); |
242 | to = data->destinationAddress(); | 242 | to = data->destinationAddress(); |
243 | 243 | ||
244 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); | 244 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) | 248 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) |
249 | { | 249 | { |
250 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 250 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
251 | if ( arp ) | 251 | if ( arp ) |
252 | { | 252 | { |
253 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 253 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); |
254 | if ( arp->type() == "REQUEST" ) | 254 | if ( arp->type() == "REQUEST" ) |
255 | { | 255 | { |
256 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 256 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
257 | } | 257 | } |
258 | else if ( arp->type() == "REPLY" ) | 258 | else if ( arp->type() == "REPLY" ) |
259 | { | 259 | { |
260 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 260 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
261 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 261 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 267 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
268 | { | 268 | { |
269 | //TODO: Implement more IP based protocols | 269 | //TODO: Implement more IP based protocols |
270 | 270 | ||
271 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 271 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
272 | if ( dhcp ) | 272 | if ( dhcp ) |
273 | { | 273 | { |
274 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); | 274 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); |
275 | if ( dhcp->type() == "OFFER" ) | 275 | if ( dhcp->type() == "OFFER" ) |
276 | { | 276 | { |
277 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); | 277 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); |
278 | netView()->identify( source, dhcp->serverAddress().toString() ); | 278 | netView()->identify( source, dhcp->serverAddress().toString() ); |
279 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 279 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
280 | } | 280 | } |
281 | else if ( dhcp->type() == "ACK" ) | 281 | else if ( dhcp->type() == "ACK" ) |
282 | { | 282 | { |
283 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); | 283 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); |
284 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | 284 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 290 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
291 | { | 291 | { |
292 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 292 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
293 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 293 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
294 | return 0; | 294 | return 0; |
295 | 295 | ||
296 | return p->child( protocol ); | 296 | return p->child( protocol ); |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 300 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
301 | { | 301 | { |
302 | // go through all child packets and see if one is inside the child hierarchy for p | 302 | // go through all child packets and see if one is inside the child hierarchy for p |
303 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 303 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
304 | if ( !configwindow->writeCaptureFile->isChecked() ) | 304 | if ( !configwindow->writeCaptureFile->isChecked() ) |
305 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter | 305 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter |
306 | 306 | ||
307 | QObjectList* l = p->queryList(); | 307 | QObjectList* l = p->queryList(); |
308 | QObjectListIt it( *l ); | 308 | QObjectListIt it( *l ); |
309 | QObject* o; | 309 | QObject* o; |
310 | 310 | ||
311 | while ( (o = it.current()) != 0 ) | 311 | while ( (o = it.current()) != 0 ) |
312 | { | 312 | { |
313 | QString name = it.current()->name(); | 313 | QString name = it.current()->name(); |
314 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 314 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
315 | { | 315 | { |
316 | QString action = configwindow->capturePackets->protocolAction( name ); | 316 | QString action = configwindow->capturePackets->protocolAction( name ); |
317 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 317 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
318 | if ( action == "Discard" ) | 318 | if ( action == "Discard" ) |
319 | { | 319 | { |
320 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 320 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
321 | return false; | 321 | return false; |
322 | } | 322 | } |
323 | } | 323 | } |
324 | else | 324 | else |
325 | { | 325 | { |
326 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 326 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
327 | } | 327 | } |
328 | ++it; | 328 | ++it; |
329 | } | 329 | } |
330 | return true; | 330 | return true; |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | void Wellenreiter::receivePacket( OPacket* p ) | 334 | void Wellenreiter::receivePacket( OPacket* p ) |
335 | { | 335 | { |
336 | hexWindow()->log( p->dump( 8 ) ); | 336 | hexWindow()->log( p->dump( 8 ) ); |
337 | 337 | ||
338 | if ( checkDumpPacket( p ) ) | 338 | if ( checkDumpPacket( p ) ) |
339 | { | 339 | { |
340 | pcap->dump( p ); | 340 | pcap->dump( p ); |
341 | } | 341 | } |
342 | 342 | ||
343 | // check if we received a beacon frame | 343 | // check if we received a beacon frame |
344 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 344 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
345 | if ( beacon && beacon->managementType() == "Beacon" ) | 345 | if ( beacon && beacon->managementType() == "Beacon" ) |
346 | { | 346 | { |
347 | handleBeacon( p, beacon ); | 347 | handleBeacon( p, beacon ); |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
351 | OMacAddress source; | 351 | OMacAddress source; |
352 | OMacAddress dest; | 352 | OMacAddress dest; |
353 | 353 | ||
354 | //TODO: WEP check here | 354 | //TODO: WEP check here |
355 | 355 | ||
356 | // check for a wireless data frame | 356 | // check for a wireless data frame |
357 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 357 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
358 | if ( wlan ) | 358 | if ( wlan ) |
359 | { | 359 | { |
360 | handleWlanData( p, wlan, source, dest ); | 360 | handleWlanData( p, wlan, source, dest ); |
361 | } | 361 | } |
362 | 362 | ||
363 | // check for a wired data frame | 363 | // check for a wired data frame |
364 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); | 364 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); |
365 | if ( eth ) | 365 | if ( eth ) |
366 | { | 366 | { |
367 | handleEthernetData( p, eth, source, dest ); | 367 | handleEthernetData( p, eth, source, dest ); |
368 | } | 368 | } |
369 | 369 | ||
370 | // check for an arp frame since arp frames come in two flavours: | 370 | // check for an arp frame since arp frames come in two flavours: |
371 | // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. | 371 | // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. |
372 | OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); | 372 | OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); |
373 | if ( arp ) | 373 | if ( arp ) |
374 | { | 374 | { |
375 | handleARPData( p, arp, source, dest ); | 375 | handleARPData( p, arp, source, dest ); |
376 | } | 376 | } |
377 | 377 | ||
378 | // check for a ip frame | 378 | // check for a ip frame |
379 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); | 379 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); |
380 | if ( ip ) | 380 | if ( ip ) |
381 | { | 381 | { |
382 | handleIPData( p, ip, source, dest ); | 382 | handleIPData( p, ip, source, dest ); |
383 | } | 383 | } |
384 | 384 | ||
385 | //handleNotification( p ); | 385 | //handleNotification( p ); |
386 | 386 | ||
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void Wellenreiter::stopClicked() | 390 | void Wellenreiter::stopClicked() |
391 | { | 391 | { |
392 | if ( iface ) | 392 | if ( iface ) |
393 | { | 393 | { |
394 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 394 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
395 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 395 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
396 | iface->setChannelHopping(); // stop hopping channels | 396 | iface->setChannelHopping(); // stop hopping channels |
397 | } | 397 | } |
398 | else | 398 | else |
399 | killTimers(); | 399 | killTimers(); |
400 | 400 | ||
401 | pcap->close(); | 401 | pcap->close(); |
402 | sniffing = false; | 402 | sniffing = false; |
403 | 403 | ||
404 | if ( iface ) | 404 | if ( iface ) |
405 | { | 405 | { |
406 | // switch off monitor mode | 406 | // switch off monitor mode |
407 | iface->setMode( "managed" ); | 407 | iface->setMode( "managed" ); |
408 | // switch off promisc flag | 408 | // switch off promisc flag |
409 | iface->setPromiscuousMode( false ); | 409 | iface->setPromiscuousMode( false ); |
410 | 410 | ||
411 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 411 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
412 | } | 412 | } |
413 | 413 | ||
414 | logwindow->log( "(i) Stopped Scanning." ); | 414 | logwindow->log( "(i) Stopped Scanning." ); |
415 | assert( parent() ); | 415 | assert( parent() ); |
416 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 416 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
417 | 417 | ||
418 | // message the user | 418 | // message the user |
419 | QMessageBox::information( this, "Wellenreiter II", | 419 | QMessageBox::information( this, "Wellenreiter II", |
420 | tr( "Your wireless card\nshould now be usable again." ) ); | 420 | tr( "Your wireless card\nshould now be usable again." ) ); |
421 | 421 | ||
422 | sniffing = false; | 422 | sniffing = false; |
423 | emit( stoppedSniffing() ); | 423 | emit( stoppedSniffing() ); |
424 | 424 | ||
425 | #ifdef QWS | 425 | #ifdef QWS |
426 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 426 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
427 | { | 427 | { |
428 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 428 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
429 | } | 429 | } |
430 | #else | 430 | #else |
431 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 431 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
432 | #endif | 432 | #endif |
433 | 433 | ||
434 | // print out statistics | 434 | // print out statistics |
435 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 435 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
436 | statwindow->updateCounter( it.key(), it.data() ); | 436 | statwindow->updateCounter( it.key(), it.data() ); |
437 | } | 437 | } |
438 | 438 | ||
439 | 439 | ||
440 | void Wellenreiter::startClicked() | 440 | void Wellenreiter::startClicked() |
441 | { | 441 | { |
442 | // get configuration from config window | 442 | // get configuration from config window |
443 | 443 | ||
444 | const QString& interface = configwindow->interfaceName->currentText(); | 444 | const QString& interface = configwindow->interfaceName->currentText(); |
445 | const int cardtype = configwindow->driverType(); | 445 | const int cardtype = configwindow->driverType(); |
446 | const int interval = configwindow->hoppingInterval(); | 446 | const int interval = configwindow->hoppingInterval(); |
447 | 447 | ||
448 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 448 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
449 | { | 449 | { |
450 | QMessageBox::information( this, "Wellenreiter II", | 450 | QMessageBox::information( this, "Wellenreiter II", |
451 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 451 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
452 | return; | 452 | return; |
453 | } | 453 | } |
454 | 454 | ||
455 | // configure device | 455 | // configure device |
456 | ONetwork* net = ONetwork::instance(); | 456 | ONetwork* net = ONetwork::instance(); |
457 | 457 | ||
458 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 458 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
459 | 459 | ||
460 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 460 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
461 | 461 | ||
462 | // bring device UP | 462 | // bring device UP |
463 | if ( cardtype != DEVTYPE_FILE ) | 463 | if ( cardtype != DEVTYPE_FILE ) |
464 | { | 464 | { |
465 | iface->setUp( true ); | 465 | iface->setUp( true ); |
466 | if ( !iface->isUp() ) | 466 | if ( !iface->isUp() ) |
467 | { | 467 | { |
468 | QMessageBox::warning( this, "Wellenreiter II", | 468 | QMessageBox::warning( this, "Wellenreiter II", |
469 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 469 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
470 | return; | 470 | return; |
471 | } | 471 | } |
472 | } | 472 | } |
473 | // set monitor mode | 473 | // set monitor mode |
474 | bool usePrism = configwindow->usePrismHeader(); | 474 | bool usePrism = configwindow->usePrismHeader(); |
475 | 475 | ||
476 | switch ( cardtype ) | 476 | switch ( cardtype ) |
477 | { | 477 | { |
478 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 478 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
479 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 479 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
480 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 480 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
481 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 481 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
482 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 482 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
483 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 483 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
484 | default: assert( 0 ); // shouldn't reach this | 484 | default: assert( 0 ); // shouldn't reach this |
485 | } | 485 | } |
486 | 486 | ||
487 | // switch device into monitor mode | 487 | // switch device into monitor mode |
488 | if ( cardtype < DEVTYPE_FILE ) | 488 | if ( cardtype < DEVTYPE_FILE ) |
489 | { | 489 | { |
490 | if ( cardtype != DEVTYPE_MANUAL ) | 490 | if ( cardtype != DEVTYPE_MANUAL ) |
491 | iface->setMode( "monitor" ); | 491 | iface->setMode( "monitor" ); |
492 | if ( iface->mode() != "monitor" ) | 492 | if ( iface->mode() != "monitor" ) |
493 | { | 493 | { |
494 | if ( QMessageBox::warning( this, "Wellenreiter II", | 494 | if ( QMessageBox::warning( this, "Wellenreiter II", |
495 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 495 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
496 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 496 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
497 | return; | 497 | return; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | // open GPS device | 501 | // open GPS device |
502 | if ( configwindow->enableGPS->isChecked() ) | 502 | if ( configwindow->enableGPS->isChecked() ) |
503 | { | 503 | { |
504 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 504 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
505 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 505 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
506 | } | 506 | } |
507 | 507 | ||
508 | // open pcap and start sniffing | 508 | // open pcap and start sniffing |
509 | 509 | ||
510 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? | 510 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? |
511 | { | 511 | { |
512 | dumpname = configwindow->captureFileName->text(); | 512 | dumpname = configwindow->captureFileName->text(); |
513 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 513 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
514 | dumpname.append( '-' ); | 514 | dumpname.append( '-' ); |
515 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 515 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
516 | dumpname.append( ".wellenreiter" ); | 516 | dumpname.append( ".wellenreiter" ); |
517 | } | 517 | } |
518 | else // write it anyway ;) | 518 | else // write it anyway ;) |
519 | { | 519 | { |
520 | dumpname = "/var/log/dump.wellenreiter"; | 520 | dumpname = "/var/log/dump.wellenreiter"; |
521 | } | 521 | } |
522 | 522 | ||
523 | if ( cardtype != DEVTYPE_FILE ) | 523 | if ( cardtype != DEVTYPE_FILE ) |
524 | pcap->open( interface ); | 524 | pcap->open( interface ); |
525 | else | 525 | else |
526 | pcap->open( QFile( interface ) ); | 526 | pcap->open( QFile( interface ) ); |
527 | 527 | ||
528 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); | 528 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); |
529 | pcap->openDumpFile( dumpname ); | 529 | pcap->openDumpFile( dumpname ); |
530 | 530 | ||
531 | if ( !pcap->isOpen() ) | 531 | if ( !pcap->isOpen() ) |
532 | { | 532 | { |
533 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( | 533 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
534 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); | 534 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
535 | return; | 535 | return; |
536 | } | 536 | } |
537 | 537 | ||
538 | // set capturer to non-blocking mode | 538 | // set capturer to non-blocking mode |
539 | pcap->setBlocking( false ); | 539 | pcap->setBlocking( false ); |
540 | 540 | ||
541 | // start channel hopper | 541 | // start channel hopper |
542 | if ( cardtype != DEVTYPE_FILE ) | 542 | if ( cardtype != DEVTYPE_FILE ) |
543 | { | 543 | { |
544 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); | 544 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); |
545 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window | 545 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window |
546 | } | 546 | } |
547 | 547 | ||
548 | if ( cardtype != DEVTYPE_FILE ) | 548 | if ( cardtype != DEVTYPE_FILE ) |
549 | { | 549 | { |
550 | // connect socket notifier and start channel hopper | 550 | // connect socket notifier and start channel hopper |
551 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 551 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
552 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 552 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
553 | } | 553 | } |
554 | else | 554 | else |
555 | { | 555 | { |
556 | // start timer for reading packets | 556 | // start timer for reading packets |
557 | startTimer( 100 ); | 557 | startTimer( 100 ); |
558 | } | 558 | } |
559 | 559 | ||
560 | logwindow->log( "(i) Started Scanning." ); | 560 | logwindow->log( "(i) Started Scanning." ); |
561 | sniffing = true; | 561 | sniffing = true; |
562 | 562 | ||
563 | #ifdef QWS | 563 | #ifdef QWS |
564 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 564 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
565 | { | 565 | { |
566 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | 566 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; |
567 | } | 567 | } |
568 | #else | 568 | #else |
569 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 569 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
570 | #endif | 570 | #endif |
571 | 571 | ||
572 | emit( startedSniffing() ); | 572 | emit( startedSniffing() ); |
573 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 573 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
574 | else | 574 | else |
575 | { | 575 | { |
576 | assert( parent() ); | 576 | assert( parent() ); |
577 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 577 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | 581 | ||
582 | void Wellenreiter::timerEvent( QTimerEvent* ) | 582 | void Wellenreiter::timerEvent( QTimerEvent* ) |
583 | { | 583 | { |
584 | qDebug( "Wellenreiter::timerEvent()" ); | 584 | qDebug( "Wellenreiter::timerEvent()" ); |
585 | OPacket* p = pcap->next(); | 585 | OPacket* p = pcap->next(); |
586 | if ( !p ) // no more packets available | 586 | if ( !p ) // no more packets available |
587 | { | 587 | { |
588 | stopClicked(); | 588 | stopClicked(); |
589 | } | 589 | } |
590 | else | 590 | else |
591 | { | 591 | { |
592 | receivePacket( p ); | 592 | receivePacket( p ); |
593 | delete p; | 593 | delete p; |
594 | } | 594 | } |
595 | } | 595 | } |
596 | 596 | ||
597 | 597 | ||
598 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 598 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
599 | { | 599 | { |
600 | #ifdef QWS | 600 | #ifdef QWS |
601 | if ( action == "TouchSound" ) | 601 | if ( action == "TouchSound" ) |
602 | ODevice::inst()->touchSound(); | 602 | ODevice::inst()->touchSound(); |
603 | else if ( action == "AlarmSound" ) | 603 | else if ( action == "AlarmSound" ) |
604 | ODevice::inst()->alarmSound(); | 604 | ODevice::inst()->alarmSound(); |
605 | else if ( action == "KeySound" ) | 605 | else if ( action == "KeySound" ) |
606 | ODevice::inst()->keySound(); | 606 | ODevice::inst()->keySound(); |
607 | else if ( action == "LedOn" ) | 607 | else if ( action == "LedOn" ) |
608 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 608 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
609 | else if ( action == "LedOff" ) | 609 | else if ( action == "LedOff" ) |
610 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 610 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
611 | else if ( action == "LogMessage" ) | 611 | else if ( action == "LogMessage" ) |
612 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 612 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
613 | else if ( action == "MessageBox" ) | 613 | else if ( action == "MessageBox" ) |
614 | QMessageBox::information( this, "Notification!", | 614 | QMessageBox::information( this, "Notification!", |
615 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 615 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
616 | #else | 616 | #else |
617 | #warning Actions do not work with Qt/X11 yet | 617 | #warning Actions do not work with Qt/X11 yet |
618 | #endif | 618 | #endif |
619 | } | 619 | } |
620 | 620 | ||
621 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) | 621 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) |
622 | { | 622 | { |
623 | #ifdef QWS | 623 | #ifdef QWS |
624 | if ( !iface ) | 624 | if ( !iface ) |
625 | { | 625 | { |
626 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); | 626 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); |
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | 629 | ||
630 | if ( sniffing ) | 630 | if ( sniffing ) |
631 | { | 631 | { |
632 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); | 632 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); |
633 | return; | 633 | return; |
634 | } | 634 | } |
635 | 635 | ||
636 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 636 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
637 | (const char*) iface->name(), | 637 | (const char*) iface->name(), |
638 | (const char*) type, | 638 | (const char*) type, |
639 | (const char*) essid, | 639 | (const char*) essid, |
640 | channel, | 640 | channel, |
641 | (const char*) macaddr ); | 641 | (const char*) macaddr ); |
642 | 642 | ||
643 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 643 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
644 | int count = 3; | 644 | int count = 3; |
645 | qDebug("sending %d messages",count); | 645 | qDebug("sending %d messages",count); |
646 | msg << QString("count") << QString::number(count); | 646 | msg << QString("count") << QString::number(count); |
647 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | 647 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); |
648 | msg << QString(iface->name()) << QString("Mode") << type; | 648 | msg << QString(iface->name()) << QString("Mode") << type; |
649 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | 649 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); |
650 | msg << QString(iface->name()) << QString("ESSID") << essid; | 650 | msg << QString(iface->name()) << QString("ESSID") << essid; |
651 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | 651 | qDebug("msg >%s< channel >%d<", iface->name(),channel); |
652 | msg << QString(iface->name()) << QString("Channel") << channel; | 652 | msg << QString(iface->name()) << QString("Channel") << channel; |
653 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); | 653 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); |
654 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 654 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
655 | #else | 655 | #else |
656 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | 656 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); |
657 | #endif | 657 | #endif |
658 | 658 | ||
659 | } | 659 | } |
660 | 660 | ||