author | mickeyl <mickeyl> | 2003-09-09 13:42:04 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-09 13:42:04 (UTC) |
commit | 807165ababca1b8c93b88d6b41f75ec96ce5e799 (patch) (unidiff) | |
tree | 5042886f052d34d7d79bf4e784f87cbad171c86c | |
parent | fca4c73a5f0c672db9150f312eb85f1299e80e1b (diff) | |
download | opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.zip opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.tar.gz opie-807165ababca1b8c93b88d6b41f75ec96ce5e799.tar.bz2 |
reading GPS data from gpsd is now working. TODO: save the data
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.h | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 4 |
7 files changed, 64 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index 3206655..288afee 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -15,6 +15,9 @@ | |||
15 | 15 | ||
16 | #include "gps.h" | 16 | #include "gps.h" |
17 | #include <unistd.h> | 17 | #include <unistd.h> |
18 | |||
19 | #include <qtextstream.h> | ||
20 | |||
18 | GPS::GPS( QObject* parent, const char * name ) | 21 | GPS::GPS( QObject* parent, const char * name ) |
19 | :QObject( parent, name ) | 22 | :QObject( parent, name ) |
20 | { | 23 | { |
@@ -35,7 +38,7 @@ bool GPS::open( const QString& host, int port ) | |||
35 | } | 38 | } |
36 | 39 | ||
37 | 40 | ||
38 | float GPS::latitude() const | 41 | GpsLocation GPS::position() const |
39 | { | 42 | { |
40 | char buf[256]; | 43 | char buf[256]; |
41 | 44 | ||
@@ -47,20 +50,20 @@ float GPS::latitude() const | |||
47 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); | 50 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); |
48 | if ( numAvail ) | 51 | if ( numAvail ) |
49 | { | 52 | { |
53 | QTextStream stream( _socket ); | ||
50 | 54 | ||
51 | int num = _socket->readLine( &buf[0], sizeof buf ); | 55 | QString str; |
52 | if ( num ) | 56 | stream.readRawBytes( &buf[0], 7 ); |
53 | { | 57 | float lat = -111.111; |
54 | qDebug( "GPS got %d bytes ['%s']", num, &buf[0] ); | 58 | stream >> lat; |
55 | return 0.0; | 59 | stream.skipWhiteSpace(); |
56 | } | 60 | float lon = -111.111; |
57 | } | 61 | stream >> lon; |
62 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF | ||
63 | |||
64 | return GpsLocation( lat, lon ); | ||
58 | } | 65 | } |
59 | return -1.0; | ||
60 | } | 66 | } |
61 | 67 | return GpsLocation( -1.0, -1.0 ); | |
62 | |||
63 | float GPS::longitute() const | ||
64 | { | ||
65 | } | 68 | } |
66 | 69 | ||
diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h index ad0b6de..8143fe4 100644 --- a/noncore/net/wellenreiter/gui/gps.h +++ b/noncore/net/wellenreiter/gui/gps.h | |||
@@ -19,6 +19,15 @@ | |||
19 | #include <qobject.h> | 19 | #include <qobject.h> |
20 | #include <qsocket.h> | 20 | #include <qsocket.h> |
21 | 21 | ||
22 | struct GpsLocation | ||
23 | { | ||
24 | GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {}; | ||
25 | ~GpsLocation() {}; | ||
26 | float latitude; | ||
27 | float longitude; | ||
28 | }; | ||
29 | |||
30 | |||
22 | class GPS : public QObject | 31 | class GPS : public QObject |
23 | { | 32 | { |
24 | Q_OBJECT | 33 | Q_OBJECT |
@@ -28,8 +37,7 @@ class GPS : public QObject | |||
28 | ~GPS(); | 37 | ~GPS(); |
29 | 38 | ||
30 | bool open( const QString& host = "localhost", int port = 2947 ); | 39 | bool open( const QString& host = "localhost", int port = 2947 ); |
31 | float latitude() const; | 40 | GpsLocation position() const; |
32 | float longitute() const; | ||
33 | 41 | ||
34 | private: | 42 | private: |
35 | QSocket* _socket; | 43 | QSocket* _socket; |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 27ecae3..868b0b0 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -14,6 +14,7 @@ | |||
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "configwindow.h" | 16 | #include "configwindow.h" |
17 | #include "gps.h" | ||
17 | #include "logwindow.h" | 18 | #include "logwindow.h" |
18 | #include "hexwindow.h" | 19 | #include "hexwindow.h" |
19 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
@@ -218,11 +219,11 @@ void WellenreiterMainWindow::demoAddStations() | |||
218 | { | 219 | { |
219 | //mw = 0; // test SIGSGV handling | 220 | //mw = 0; // test SIGSGV handling |
220 | 221 | ||
221 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80 ); | 222 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); |
222 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10 ); | 223 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
223 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10 ); | 224 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
224 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15 ); | 225 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
225 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20 ); | 226 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
226 | } | 227 | } |
227 | 228 | ||
228 | 229 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index f4cfe52..d695c17 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -47,6 +47,7 @@ const int col_ip = 6; | |||
47 | const int col_manuf = 7; | 47 | const int col_manuf = 7; |
48 | const int col_firstseen = 8; | 48 | const int col_firstseen = 8; |
49 | const int col_lastseen = 9; | 49 | const int col_lastseen = 9; |
50 | const int col_location = 10; | ||
50 | 51 | ||
51 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 52 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
52 | :OListView( parent, name ) | 53 | :OListView( parent, name ) |
@@ -75,6 +76,8 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) | |||
75 | setColumnAlignment( col_firstseen, AlignCenter ); | 76 | setColumnAlignment( col_firstseen, AlignCenter ); |
76 | addColumn( tr( "Last Seen" ) ); | 77 | addColumn( tr( "Last Seen" ) ); |
77 | setColumnAlignment( col_lastseen, AlignCenter ); | 78 | setColumnAlignment( col_lastseen, AlignCenter ); |
79 | addColumn( tr( "Location" ) ); | ||
80 | setColumnAlignment( col_location, AlignCenter ); | ||
78 | setRootIsDecorated( true ); | 81 | setRootIsDecorated( true ); |
79 | setAllColumnsShowFocus( true ); | 82 | setAllColumnsShowFocus( true ); |
80 | 83 | ||
@@ -113,7 +116,13 @@ void MScanListView::serializeFrom( QDataStream& s) | |||
113 | } | 116 | } |
114 | 117 | ||
115 | 118 | ||
116 | void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) | 119 | void MScanListView::addNewItem( const QString& type, |
120 | const QString& essid, | ||
121 | const OMacAddress& mac, | ||
122 | bool wep, | ||
123 | int channel, | ||
124 | int signal, | ||
125 | const GpsLocation& loc ) | ||
117 | { | 126 | { |
118 | QString macaddr = mac.toString(true); | 127 | QString macaddr = mac.toString(true); |
119 | 128 | ||
@@ -179,6 +188,7 @@ void MScanListView::addNewItem( const QString& type, const QString& essid, const | |||
179 | 188 | ||
180 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 189 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
181 | station->setManufacturer( mac.manufacturer() ); | 190 | station->setManufacturer( mac.manufacturer() ); |
191 | station->setLocation( loc.latitude, loc.longitude ); | ||
182 | 192 | ||
183 | if ( type == "managed" ) | 193 | if ( type == "managed" ) |
184 | { | 194 | { |
@@ -468,6 +478,15 @@ void MScanListItem::setManufacturer( const QString& manufacturer ) | |||
468 | } | 478 | } |
469 | 479 | ||
470 | 480 | ||
481 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) | ||
482 | { | ||
483 | if ( latitude == 0.0 || longitude == 0.0 ) | ||
484 | setText( col_location, "N/A" ); | ||
485 | else | ||
486 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); | ||
487 | } | ||
488 | |||
489 | |||
471 | void MScanListItem::playSound( const QString& sound ) const | 490 | void MScanListItem::playSound( const QString& sound ) const |
472 | { | 491 | { |
473 | #ifdef QWS | 492 | #ifdef QWS |
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 5aba0d2..2703b6a 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -16,6 +16,8 @@ | |||
16 | #ifndef SCANLIST_H | 16 | #ifndef SCANLIST_H |
17 | #define SCANLIST_H | 17 | #define SCANLIST_H |
18 | 18 | ||
19 | #include "gps.h" | ||
20 | |||
19 | /* OPIE */ | 21 | /* OPIE */ |
20 | #include <opie2/olistview.h> | 22 | #include <opie2/olistview.h> |
21 | #include <opie2/onetutils.h> | 23 | #include <opie2/onetutils.h> |
@@ -39,7 +41,8 @@ class MScanListView: public OListView | |||
39 | virtual void serializeFrom( QDataStream& s ); | 41 | virtual void serializeFrom( QDataStream& s ); |
40 | 42 | ||
41 | public slots: | 43 | public slots: |
42 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal ); | 44 | void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); |
45 | |||
43 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 46 | void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
44 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); | 47 | void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); |
45 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); | 48 | void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); |
@@ -99,6 +102,7 @@ class MScanListItem: public OListViewItem | |||
99 | void receivedBeacon(); | 102 | void receivedBeacon(); |
100 | 103 | ||
101 | void setManufacturer( const QString& manufacturer ); | 104 | void setManufacturer( const QString& manufacturer ); |
105 | void setLocation( const float& latitude, const float& longitude ); | ||
102 | 106 | ||
103 | virtual OListViewItem* childFactory(); | 107 | virtual OListViewItem* childFactory(); |
104 | virtual void serializeTo( QDataStream& s ) const; | 108 | virtual void serializeTo( QDataStream& s ) const; |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index c03debb..5dc2e79 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -171,14 +171,16 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | |||
171 | 171 | ||
172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
173 | 173 | ||
174 | GpsLocation loc( 0, 0 ); | ||
174 | if ( configwindow->enableGPS->isChecked() ) | 175 | if ( configwindow->enableGPS->isChecked() ) |
175 | { | 176 | { |
177 | // TODO: add check if GPS is working!? | ||
176 | qDebug( "Wellenreiter::gathering GPS data..." ); | 178 | qDebug( "Wellenreiter::gathering GPS data..." ); |
177 | float lat = gps->latitude(); | 179 | loc = gps->position(); |
178 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", lat, 0.0 ); | 180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); |
179 | } | 181 | } |
180 | 182 | ||
181 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); | 183 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
182 | 184 | ||
183 | // update graph window | 185 | // update graph window |
184 | if ( ds ) | 186 | if ( ds ) |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 36fbb9a..eac5d89 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp | |||
@@ -123,10 +123,10 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
123 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 123 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
124 | TextLabel1_4_2->setText( tr( "<p align=center>\n" | 124 | TextLabel1_4_2->setText( tr( "<p align=center>\n" |
125 | "<hr>\n" | 125 | "<hr>\n" |
126 | "Michael 'Mickey' Lauer<br><hr>\n" | ||
126 | "Max Moser<br>\n" | 127 | "Max Moser<br>\n" |
127 | "Martin J. Muench<br>\n" | 128 | "Martin J. Muench<br>\n" |
128 | "Michael Lauer<br><hr>\n" | 129 | "<b>www.wellenreiter.net</b>\n" |
129 | "<b>www.remote-exploit.org</b>\n" | ||
130 | "</p>" ) ); | 130 | "</p>" ) ); |
131 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); | 131 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); |
132 | 132 | ||