-rw-r--r-- | noncore/net/wellenreiter/TODO | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 34 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 1 |
4 files changed, 32 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index fd70fc7..b6ec617 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO | |||
@@ -17,32 +17,34 @@ ENGINE | |||
17 | - infrared | 17 | - infrared |
18 | - bluetooth | 18 | - bluetooth |
19 | - usb? | 19 | - usb? |
20 | 20 | ||
21 | - define packet structure in a metalanguage and generate | 21 | - define packet structure in a metalanguage and generate |
22 | the actual parsing code (hmmm) | 22 | the actual parsing code (hmmm) |
23 | 23 | ||
24 | - pester the ethereal folks to settle for an application independant | 24 | - pester the ethereal folks to settle for an application independant |
25 | packet dissection framework... (unlikely) | 25 | packet dissection framework... (unlikely) |
26 | 26 | ||
27 | - adaptive hopping scheme ! | 27 | - adaptive hopping scheme ! |
28 | 28 | ||
29 | - gather interface capabilities | 29 | - gather interface capabilities |
30 | 30 | ||
31 | - enable sniffing in wired networks | 31 | - enable sniffing in wired networks |
32 | 32 | ||
33 | - fix autodetection (interface name) | ||
34 | |||
33 | --------- | 35 | --------- |
34 | UI | 36 | UI |
35 | --------- | 37 | --------- |
36 | 38 | ||
37 | - display interface capabilities (or rewrite networksettings?) | 39 | - display interface capabilities (or rewrite networksettings?) |
38 | 40 | ||
39 | - distinguish wireless bridges (WDS traffic) | 41 | - distinguish wireless bridges (WDS traffic) |
40 | 42 | ||
41 | - expand/collapse all | 43 | - expand/collapse all |
42 | 44 | ||
43 | - add configuration for scrollback buffer in hex window and log window | 45 | - add configuration for scrollback buffer in hex window and log window |
44 | 46 | ||
45 | - revamp hex window, make it more sophisticated than just a QMultiLineEdit | 47 | - revamp hex window, make it more sophisticated than just a QMultiLineEdit |
46 | - tree view | 48 | - tree view |
47 | 49 | ||
48 | - beep over headphone / customizable | 50 | - beep over headphone / customizable |
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index b814427..5b1b4a4 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -32,53 +32,55 @@ GPS::GPS( QObject* parent, const char * name ) | |||
32 | 32 | ||
33 | GPS::~GPS() | 33 | GPS::~GPS() |
34 | { | 34 | { |
35 | qDebug( "GPS::~GPS()" ); | 35 | qDebug( "GPS::~GPS()" ); |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | bool GPS::open( const QString& host, int port ) | 39 | bool GPS::open( const QString& host, int port ) |
40 | { | 40 | { |
41 | _socket->connectToHost( host, port ); | 41 | _socket->connectToHost( host, port ); |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | GpsLocation GPS::position() const | 45 | GpsLocation GPS::position() const |
46 | { | 46 | { |
47 | char buf[256]; | 47 | char buf[256]; |
48 | double lat = -111.0; | ||
49 | double lon = -111.0; | ||
48 | 50 | ||
49 | int result = _socket->writeBlock( "p\r\n", 3 ); | 51 | int result = _socket->writeBlock( "p\r\n", 3 ); |
50 | _socket->flush(); | 52 | _socket->flush(); |
51 | if ( result ) | 53 | if ( result ) |
52 | { | 54 | { |
53 | int numAvail = _socket->bytesAvailable(); | 55 | int numAvail = _socket->bytesAvailable(); |
54 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); | 56 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); |
55 | if ( numAvail ) | 57 | if ( numAvail ) |
56 | { | 58 | { |
57 | QTextStream stream( _socket ); | 59 | int numRead = _socket->readBlock( &buf[0], sizeof buf ); |
58 | 60 | int numScan = sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); | |
59 | QString str; | 61 | |
60 | stream.readRawBytes( &buf[0], 7 ); | 62 | if ( numRead < 7 || numScan != 2 ) |
61 | float lat = -111; | 63 | { |
62 | stream >> lat; | 64 | qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] ); |
63 | stream.skipWhiteSpace(); | 65 | return GpsLocation( -111, -111 ); |
64 | float lon = -111; | 66 | } |
65 | stream >> lon; | 67 | else |
66 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF | 68 | { |
67 | 69 | return GpsLocation( lat, lon ); | |
68 | return GpsLocation( lat, lon ); | 70 | } |
69 | } | 71 | } |
70 | } | 72 | } |
71 | return GpsLocation( -111, -111 ); | 73 | return GpsLocation( -111, -111 ); |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
75 | QString GpsLocation::dmsPosition() const | 77 | QString GpsLocation::dmsPosition() const |
76 | { | 78 | { |
77 | if ( _latitude == -111 || _longitude == -111 ) | 79 | if ( _latitude == -111 || _longitude == -111 ) |
78 | return "N/A"; | 80 | return "N/A"; |
79 | if ( _latitude == 0.0 && _longitude == 0.0 ) | 81 | if ( _latitude == 0.0 && _longitude == 0.0 ) |
80 | return "NULL"; | 82 | return "NULL"; |
81 | 83 | ||
82 | /* compute latitude */ | 84 | /* compute latitude */ |
83 | 85 | ||
84 | QString dms = "N"; | 86 | QString dms = "N"; |
@@ -110,22 +112,16 @@ QString GpsLocation::dmsPosition() const | |||
110 | 112 | ||
111 | minf = rest * 60; | 113 | minf = rest * 60; |
112 | minutes = int( minf ); | 114 | minutes = int( minf ); |
113 | 115 | ||
114 | rest = minf - minutes; | 116 | rest = minf - minutes; |
115 | seconds = int( rest * 60 ); | 117 | seconds = int( rest * 60 ); |
116 | 118 | ||
117 | dms.append( QString::number( trunc ) ); | 119 | dms.append( QString::number( trunc ) ); |
118 | dms.append( "° " ); | 120 | dms.append( "° " ); |
119 | dms.append( QString::number( ::abs( minutes ) ) ); | 121 | dms.append( QString::number( ::abs( minutes ) ) ); |
120 | dms.append( "' " ); | 122 | dms.append( "' " ); |
121 | dms.append( QString::number( ::abs( seconds ) ) ); | 123 | dms.append( QString::number( ::abs( seconds ) ) ); |
122 | dms.append( "'' " ); | 124 | dms.append( "'' " ); |
123 | 125 | ||
124 | return dms; | 126 | return dms; |
125 | } | 127 | } |
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 05a8913..b462afd 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -21,32 +21,33 @@ | |||
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 <qspinbox.h> | ||
37 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
38 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
39 | 40 | ||
40 | #ifdef QWS | 41 | #ifdef QWS |
41 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
42 | #include <opie2/ofiledialog.h> | 43 | #include <opie2/ofiledialog.h> |
43 | using namespace Opie; | 44 | using namespace Opie; |
44 | #else | 45 | #else |
45 | #include "resource.h" | 46 | #include "resource.h" |
46 | #include <qapplication.h> | 47 | #include <qapplication.h> |
47 | #include <qfiledialog.h> | 48 | #include <qfiledialog.h> |
48 | #endif | 49 | #endif |
49 | 50 | ||
50 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 51 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
51 | :QMainWindow( parent, name, f ) | 52 | :QMainWindow( parent, name, f ) |
52 | { | 53 | { |
@@ -120,32 +121,33 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
120 | file->insertSeparator(); | 121 | file->insertSeparator(); |
121 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 122 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
122 | 123 | ||
123 | QPopupMenu* view = new QPopupMenu( mb ); | 124 | QPopupMenu* view = new QPopupMenu( mb ); |
124 | view->insertItem( tr( "&Configure..." ) ); | 125 | view->insertItem( tr( "&Configure..." ) ); |
125 | 126 | ||
126 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 127 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
127 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 128 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
128 | sniffer->insertSeparator(); | 129 | sniffer->insertSeparator(); |
129 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 130 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
130 | sniffer->setItemEnabled( startID, false ); | 131 | sniffer->setItemEnabled( startID, false ); |
131 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 132 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
132 | sniffer->setItemEnabled( stopID, false ); | 133 | sniffer->setItemEnabled( stopID, false ); |
133 | 134 | ||
134 | QPopupMenu* demo = new QPopupMenu( mb ); | 135 | QPopupMenu* demo = new QPopupMenu( mb ); |
135 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 136 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
137 | demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); | ||
136 | 138 | ||
137 | id = mb->insertItem( tr( "&File" ), file ); | 139 | id = mb->insertItem( tr( "&File" ), file ); |
138 | //id = mb->insertItem( tr( "&View" ), view ); | 140 | //id = mb->insertItem( tr( "&View" ), view ); |
139 | //mb->setItemEnabled( id, false ); | 141 | //mb->setItemEnabled( id, false ); |
140 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 142 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
141 | 143 | ||
142 | id = mb->insertItem( tr( "&Demo" ), demo ); | 144 | id = mb->insertItem( tr( "&Demo" ), demo ); |
143 | mb->setItemEnabled( id, true ); | 145 | mb->setItemEnabled( id, true ); |
144 | mb->setItemEnabled( uploadID, false ); | 146 | mb->setItemEnabled( uploadID, false ); |
145 | 147 | ||
146 | #ifdef QWS | 148 | #ifdef QWS |
147 | mb->insertItem( startButton ); | 149 | mb->insertItem( startButton ); |
148 | mb->insertItem( stopButton ); | 150 | mb->insertItem( stopButton ); |
149 | mb->insertItem( uploadButton ); | 151 | mb->insertItem( uploadButton ); |
150 | mb->insertItem( d ); | 152 | mb->insertItem( d ); |
151 | #else // Qt3 changed the insertion order. It's now totally random :( | 153 | #else // Qt3 changed the insertion order. It's now totally random :( |
@@ -210,42 +212,53 @@ void WellenreiterMainWindow::changedSniffingState() | |||
210 | if ( !mw->sniffing ) | 212 | if ( !mw->sniffing ) |
211 | { | 213 | { |
212 | menuBar()->setItemEnabled( uploadID, true ); | 214 | menuBar()->setItemEnabled( uploadID, true ); |
213 | uploadButton->setEnabled( true ); | 215 | uploadButton->setEnabled( true ); |
214 | } | 216 | } |
215 | } | 217 | } |
216 | 218 | ||
217 | 219 | ||
218 | WellenreiterMainWindow::~WellenreiterMainWindow() | 220 | WellenreiterMainWindow::~WellenreiterMainWindow() |
219 | { | 221 | { |
220 | qDebug( "Wellenreiter:: bye." ); | 222 | qDebug( "Wellenreiter:: bye." ); |
221 | }; | 223 | }; |
222 | 224 | ||
223 | 225 | ||
224 | void WellenreiterMainWindow::demoAddStations() | 226 | void WellenreiterMainWindow::demoAddStations() |
225 | { | 227 | { |
226 | //mw = 0; // test SIGSGV handling | 228 | //mw = 0; // test SIGSEGV handling |
227 | 229 | ||
228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 230 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
229 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 231 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
230 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 232 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
231 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 233 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
232 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 234 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
233 | } | 235 | } |
234 | 236 | ||
235 | 237 | ||
238 | void WellenreiterMainWindow::demoReadFromGps() | ||
239 | { | ||
240 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | ||
241 | GPS* gps = new GPS( this ); | ||
242 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | ||
243 | GpsLocation loc = gps->position(); | ||
244 | |||
245 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n$1" ).arg( loc.dmsPosition() ) ); | ||
246 | } | ||
247 | |||
248 | |||
236 | QString WellenreiterMainWindow::getFileName( bool save ) | 249 | QString WellenreiterMainWindow::getFileName( bool save ) |
237 | { | 250 | { |
238 | QMap<QString, QStringList> map; | 251 | QMap<QString, QStringList> map; |
239 | map.insert( tr("All"), QStringList() ); | 252 | map.insert( tr("All"), QStringList() ); |
240 | QStringList text; | 253 | QStringList text; |
241 | text << "text/*"; | 254 | text << "text/*"; |
242 | map.insert( tr("Text"), text ); | 255 | map.insert( tr("Text"), text ); |
243 | text << "*"; | 256 | text << "*"; |
244 | map.insert( tr("All"), text ); | 257 | map.insert( tr("All"), text ); |
245 | 258 | ||
246 | QString str; | 259 | QString str; |
247 | if ( save ) | 260 | if ( save ) |
248 | { | 261 | { |
249 | #ifdef QWS | 262 | #ifdef QWS |
250 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 263 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
251 | #else | 264 | #else |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 8d4e768..a5cb7a5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h | |||
@@ -37,26 +37,27 @@ class WellenreiterMainWindow: public QMainWindow | |||
37 | WellenreiterConfigWindow* cw; | 37 | WellenreiterConfigWindow* cw; |
38 | 38 | ||
39 | QToolButton* startButton; | 39 | QToolButton* startButton; |
40 | QToolButton* stopButton; | 40 | QToolButton* stopButton; |
41 | QToolButton* uploadButton; | 41 | QToolButton* uploadButton; |
42 | int startID; | 42 | int startID; |
43 | int stopID; | 43 | int stopID; |
44 | int uploadID; | 44 | int uploadID; |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | virtual void closeEvent( QCloseEvent* ); | 47 | virtual void closeEvent( QCloseEvent* ); |
48 | void updateToolButtonState(); | 48 | void updateToolButtonState(); |
49 | 49 | ||
50 | public slots: | 50 | public slots: |
51 | void showConfigure(); | 51 | void showConfigure(); |
52 | void demoAddStations(); | 52 | void demoAddStations(); |
53 | void demoReadFromGps(); | ||
53 | void fileSaveLog(); | 54 | void fileSaveLog(); |
54 | void fileSaveHex(); | 55 | void fileSaveHex(); |
55 | void fileSaveSession(); | 56 | void fileSaveSession(); |
56 | void fileLoadSession(); | 57 | void fileLoadSession(); |
57 | void fileNew(); | 58 | void fileNew(); |
58 | void uploadSession(); | 59 | void uploadSession(); |
59 | void changedSniffingState(); | 60 | void changedSniffingState(); |
60 | }; | 61 | }; |
61 | 62 | ||
62 | #endif | 63 | #endif |