-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 @@ #include "gps.h" #include <unistd.h> + +#include <qtextstream.h> + GPS::GPS( QObject* parent, const char * name ) :QObject( parent, name ) { @@ -35,7 +38,7 @@ bool GPS::open( const QString& host, int port ) } -float GPS::latitude() const +GpsLocation GPS::position() const { char buf[256]; @@ -47,20 +50,20 @@ float GPS::latitude() const qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); if ( numAvail ) { + QTextStream stream( _socket ); - int num = _socket->readLine( &buf[0], sizeof buf ); - if ( num ) - { - qDebug( "GPS got %d bytes ['%s']", num, &buf[0] ); - return 0.0; - } - } + QString str; + stream.readRawBytes( &buf[0], 7 ); + float lat = -111.111; + stream >> lat; + stream.skipWhiteSpace(); + float lon = -111.111; + stream >> lon; + stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF + + return GpsLocation( lat, lon ); } - return -1.0; } - - -float GPS::longitute() const -{ + return GpsLocation( -1.0, -1.0 ); } 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 @@ #include <qobject.h> #include <qsocket.h> +struct GpsLocation +{ + GpsLocation( const float& lat, const float& lon ) : latitude(lat), longitude(lon) {}; + ~GpsLocation() {}; + float latitude; + float longitude; +}; + + class GPS : public QObject { Q_OBJECT @@ -28,8 +37,7 @@ class GPS : public QObject ~GPS(); bool open( const QString& host = "localhost", int port = 2947 ); - float latitude() const; - float longitute() const; + GpsLocation position() const; private: 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 @@ **********************************************************************/ #include "configwindow.h" +#include "gps.h" #include "logwindow.h" #include "hexwindow.h" #include "mainwindow.h" @@ -218,11 +219,11 @@ void WellenreiterMainWindow::demoAddStations() { //mw = 0; // test SIGSGV handling - mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80 ); - mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10 ); - mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10 ); - mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15 ); - mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20 ); + mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); + mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); + mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); + mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); + mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); } 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; const int col_manuf = 7; const int col_firstseen = 8; const int col_lastseen = 9; +const int col_location = 10; MScanListView::MScanListView( QWidget* parent, const char* name ) :OListView( parent, name ) @@ -75,6 +76,8 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) setColumnAlignment( col_firstseen, AlignCenter ); addColumn( tr( "Last Seen" ) ); setColumnAlignment( col_lastseen, AlignCenter ); + addColumn( tr( "Location" ) ); + setColumnAlignment( col_location, AlignCenter ); setRootIsDecorated( true ); setAllColumnsShowFocus( true ); @@ -113,7 +116,13 @@ void MScanListView::serializeFrom( QDataStream& s) } -void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) +void MScanListView::addNewItem( const QString& type, + const QString& essid, + const OMacAddress& mac, + bool wep, + int channel, + int signal, + const GpsLocation& loc ) { QString macaddr = mac.toString(true); @@ -179,6 +188,7 @@ void MScanListView::addNewItem( const QString& type, const QString& essid, const MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); station->setManufacturer( mac.manufacturer() ); + station->setLocation( loc.latitude, loc.longitude ); if ( type == "managed" ) { @@ -468,6 +478,15 @@ void MScanListItem::setManufacturer( const QString& manufacturer ) } +void MScanListItem::setLocation( const float& latitude, const float& longitude ) +{ + if ( latitude == 0.0 || longitude == 0.0 ) + setText( col_location, "N/A" ); + else + setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); +} + + void MScanListItem::playSound( const QString& sound ) const { #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 @@ #ifndef SCANLIST_H #define SCANLIST_H +#include "gps.h" + /* OPIE */ #include <opie2/olistview.h> #include <opie2/onetutils.h> @@ -39,7 +41,8 @@ class MScanListView: public OListView virtual void serializeFrom( QDataStream& s ); public slots: - void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal ); + void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); + void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); @@ -99,6 +102,7 @@ class MScanListItem: public OListViewItem void receivedBeacon(); void setManufacturer( const QString& manufacturer ); + void setLocation( const float& latitude, const float& longitude ); virtual OListViewItem* childFactory(); 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 ) OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); + GpsLocation loc( 0, 0 ); if ( configwindow->enableGPS->isChecked() ) { + // TODO: add check if GPS is working!? qDebug( "Wellenreiter::gathering GPS data..." ); - float lat = gps->latitude(); - qDebug( "Wellenreiter::GPS data received is ( %f , %f )", lat, 0.0 ); + loc = gps->position(); + qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); } - netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); + netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); // update graph window 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 TextLabel1_4_2->setFont( TextLabel1_4_2_font ); TextLabel1_4_2->setText( tr( "<p align=center>\n" "<hr>\n" +"Michael 'Mickey' Lauer<br><hr>\n" "Max Moser<br>\n" "Martin J. Muench<br>\n" -"Michael Lauer<br><hr>\n" -"<b>www.remote-exploit.org</b>\n" +"<b>www.wellenreiter.net</b>\n" "</p>" ) ); TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); |