Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 30 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/logwindow.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 15 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 57 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/resource.cpp | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 77 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 74 |
9 files changed, 140 insertions, 139 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index da39113..bfdb20a 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -14,50 +14,46 @@ | |||
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | /* LOCAL */ | 16 | /* LOCAL */ |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "mainwindow.h" | 18 | #include "mainwindow.h" |
19 | 19 | ||
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | #include <opie2/onetwork.h> | 21 | #include <opie2/onetwork.h> |
22 | #ifdef QWS | 22 | #ifdef QWS |
23 | #include <opie2/oapplication.h> | 23 | #include <opie2/oapplication.h> |
24 | #include <opie2/oconfig.h> | 24 | #include <opie2/oconfig.h> |
25 | #include <opie2/odevice.h> | 25 | #include <opie2/odevice.h> |
26 | using namespace Opie; | 26 | #include <opie2/odebug.h> |
27 | using namespace Opie::Core; | ||
28 | using namespace Opie::Net; | ||
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | /* QT */ | 31 | /* QT */ |
30 | #include <qapplication.h> | 32 | #include <qapplication.h> |
31 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
33 | #include <qfile.h> | 35 | #include <qfile.h> |
34 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
35 | #include <qlayout.h> | 37 | #include <qlayout.h> |
36 | #include <qmap.h> | 38 | #include <qmap.h> |
37 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
38 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
39 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 42 | #include <qspinbox.h> |
41 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
42 | 44 | ||
43 | /* POSIX */ | 45 | /* STD */ |
44 | #include <assert.h> | 46 | #include <assert.h> |
45 | 47 | ||
46 | using namespace Opie::Core; | ||
47 | using namespace Opie::Net; | ||
48 | using namespace Opie::Core; | ||
49 | using namespace Opie::Net; | ||
50 | using namespace Opie::Core; | ||
51 | using namespace Opie::Net; | ||
52 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 48 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
53 | 49 | ||
54 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 50 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
55 | :WellenreiterConfigBase( parent, name, true, f ) | 51 | :WellenreiterConfigBase( parent, name, true, f ) |
56 | { | 52 | { |
57 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 53 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
58 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 54 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
59 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 55 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
60 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 56 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
61 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 57 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
62 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 58 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
63 | 59 | ||
@@ -107,46 +103,46 @@ void WellenreiterConfigWindow::accept() | |||
107 | 103 | ||
108 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 104 | WellenreiterConfigWindow::~WellenreiterConfigWindow() |
109 | { | 105 | { |
110 | } | 106 | } |
111 | 107 | ||
112 | 108 | ||
113 | void WellenreiterConfigWindow::performAutodetection() | 109 | void WellenreiterConfigWindow::performAutodetection() |
114 | { | 110 | { |
115 | //TODO: insert modal splash screen here | 111 | //TODO: insert modal splash screen here |
116 | // and sleep a second, so that it looks | 112 | // and sleep a second, so that it looks |
117 | // like we're actually doing something fancy... ;-) | 113 | // like we're actually doing something fancy... ;-) |
118 | 114 | ||
119 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 115 | odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl; |
120 | 116 | ||
121 | // try to guess device type | 117 | // try to guess device type |
122 | QFile m( "/proc/modules" ); | 118 | QFile m( "/proc/modules" ); |
123 | if ( m.open( IO_ReadOnly ) ) | 119 | if ( m.open( IO_ReadOnly ) ) |
124 | { | 120 | { |
125 | int devicetype(0); | 121 | int devicetype(0); |
126 | QString line; | 122 | QString line; |
127 | QTextStream modules( &m ); | 123 | QTextStream modules( &m ); |
128 | while( !modules.atEnd() && !devicetype ) | 124 | while( !modules.atEnd() && !devicetype ) |
129 | { | 125 | { |
130 | modules >> line; | 126 | modules >> line; |
131 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 127 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
132 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 128 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
133 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 129 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
134 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 130 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
135 | } | 131 | } |
136 | if ( devicetype ) | 132 | if ( devicetype ) |
137 | { | 133 | { |
138 | deviceType->setCurrentItem( devicetype ); | 134 | deviceType->setCurrentItem( devicetype ); |
139 | _guess = devicetype; | 135 | _guess = devicetype; |
140 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 136 | odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl; |
141 | } | 137 | } |
142 | } | 138 | } |
143 | } | 139 | } |
144 | 140 | ||
145 | 141 | ||
146 | int WellenreiterConfigWindow::driverType() const | 142 | int WellenreiterConfigWindow::driverType() const |
147 | { | 143 | { |
148 | QString name = deviceType->currentText(); | 144 | QString name = deviceType->currentText(); |
149 | if ( _devicetype.contains( name ) ) | 145 | if ( _devicetype.contains( name ) ) |
150 | { | 146 | { |
151 | return _devicetype[name]; | 147 | return _devicetype[name]; |
152 | } | 148 | } |
@@ -232,25 +228,25 @@ void WellenreiterConfigWindow::changedClientAction(int t) | |||
232 | } | 228 | } |
233 | 229 | ||
234 | 230 | ||
235 | void WellenreiterConfigWindow::changedStationAction(int t) | 231 | void WellenreiterConfigWindow::changedStationAction(int t) |
236 | { | 232 | { |
237 | synchronizeActionsAndScripts(); | 233 | synchronizeActionsAndScripts(); |
238 | } | 234 | } |
239 | 235 | ||
240 | 236 | ||
241 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | 237 | void WellenreiterConfigWindow::getCaptureFileNameClicked() |
242 | { | 238 | { |
243 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | 239 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); |
244 | qDebug( "name = %s", (const char*) name ); | 240 | odebug << "name = " << (const char*) name << "" << oendl; |
245 | if ( !name.isEmpty() ) | 241 | if ( !name.isEmpty() ) |
246 | { | 242 | { |
247 | captureFileName->setText( name ); | 243 | captureFileName->setText( name ); |
248 | } | 244 | } |
249 | } | 245 | } |
250 | 246 | ||
251 | 247 | ||
252 | void WellenreiterConfigWindow::channelAllClicked(int state) | 248 | void WellenreiterConfigWindow::channelAllClicked(int state) |
253 | { | 249 | { |
254 | bool b = state; | 250 | bool b = state; |
255 | channel1->setChecked( b ); | 251 | channel1->setChecked( b ); |
256 | channel2->setChecked( b ); | 252 | channel2->setChecked( b ); |
@@ -307,70 +303,70 @@ void WellenreiterConfigWindow::performAction( const QString& type, | |||
307 | else if ( type == "managed" || type == "adhoc" ) | 303 | else if ( type == "managed" || type == "adhoc" ) |
308 | { | 304 | { |
309 | action = newClientAction->currentItem(); | 305 | action = newClientAction->currentItem(); |
310 | script = newClientScript->text(); | 306 | script = newClientScript->text(); |
311 | } | 307 | } |
312 | else if ( type == "station" ) | 308 | else if ( type == "station" ) |
313 | { | 309 | { |
314 | action = newStationAction->currentItem(); | 310 | action = newStationAction->currentItem(); |
315 | script = newStationScript->text(); | 311 | script = newStationScript->text(); |
316 | } | 312 | } |
317 | else | 313 | else |
318 | { | 314 | { |
319 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 315 | owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << (const char*) type << "'" << oendl; |
320 | return; | 316 | return; |
321 | } | 317 | } |
322 | 318 | ||
323 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); | 319 | odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << (const char*) script << "')" << oendl; |
324 | 320 | ||
325 | switch( action ) | 321 | switch( action ) |
326 | { | 322 | { |
327 | case 0: /* Ignore */ return; | 323 | case 0: /* Ignore */ return; |
328 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; | 324 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; |
329 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; | 325 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; |
330 | case 3: /* Blink LED */ break; //FIXME: Implement this | 326 | case 3: /* Blink LED */ break; //FIXME: Implement this |
331 | case 4: /* Run Script */ | 327 | case 4: /* Run Script */ |
332 | { | 328 | { |
333 | /** | 329 | /** |
334 | * | 330 | * |
335 | * Script Substitution Information: | 331 | * Script Substitution Information: |
336 | * | 332 | * |
337 | * $SSID = SSID | 333 | * $SSID = SSID |
338 | * $MAC = MAC | 334 | * $MAC = MAC |
339 | * $WEP = Wep | 335 | * $WEP = Wep |
340 | * $CHAN = Channel | 336 | * $CHAN = Channel |
341 | * | 337 | * |
342 | **/ | 338 | **/ |
343 | script = script.replace( QRegExp( "$SSID" ), essid ); | 339 | script = script.replace( QRegExp( "$SSID" ), essid ); |
344 | script = script.replace( QRegExp( "$MAC" ), mac ); | 340 | script = script.replace( QRegExp( "$MAC" ), mac ); |
345 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | 341 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); |
346 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | 342 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); |
347 | 343 | ||
348 | qDebug( "going to call script '%s'", (const char*) script ); | 344 | odebug << "going to call script '" << (const char*) script << "'" << oendl; |
349 | ::system( script ); | 345 | ::system( script ); |
350 | qDebug( "script returned." ); | 346 | odebug << "script returned." << oendl; |
351 | return; | 347 | return; |
352 | } | 348 | } |
353 | default: assert( false ); | 349 | default: assert( false ); |
354 | } | 350 | } |
355 | } | 351 | } |
356 | 352 | ||
357 | 353 | ||
358 | void WellenreiterConfigWindow::load() | 354 | void WellenreiterConfigWindow::load() |
359 | { | 355 | { |
360 | #ifdef Q_WS_X11 | 356 | #ifdef Q_WS_X11 |
361 | #warning Persistent Configuration not yet implemented for standalone X11 build | 357 | #warning Persistent Configuration not yet implemented for standalone X11 build |
362 | performAutodetection(); | 358 | performAutodetection(); |
363 | #else | 359 | #else |
364 | qDebug( "loading configuration settings..." ); | 360 | odebug << "loading configuration settings..." << oendl; |
365 | 361 | ||
366 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 362 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
367 | 363 | ||
368 | OConfig* c = oApp->config(); | 364 | OConfig* c = oApp->config(); |
369 | 365 | ||
370 | c->setGroup( "Interface" ); | 366 | c->setGroup( "Interface" ); |
371 | 367 | ||
372 | QString interface = c->readEntry( "name", "<none>" ); | 368 | QString interface = c->readEntry( "name", "<none>" ); |
373 | if ( interface != "<none>" ) | 369 | if ( interface != "<none>" ) |
374 | { | 370 | { |
375 | #if QT_VERSION < 300 | 371 | #if QT_VERSION < 300 |
376 | interfaceName->insertItem( interface, 0 ); | 372 | interfaceName->insertItem( interface, 0 ); |
@@ -430,25 +426,25 @@ void WellenreiterConfigWindow::load() | |||
430 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 426 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
431 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 427 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
432 | 428 | ||
433 | #endif | 429 | #endif |
434 | } | 430 | } |
435 | 431 | ||
436 | 432 | ||
437 | void WellenreiterConfigWindow::save() | 433 | void WellenreiterConfigWindow::save() |
438 | { | 434 | { |
439 | #ifdef Q_WS_X11 | 435 | #ifdef Q_WS_X11 |
440 | #warning Persistent Configuration not yet implemented for standalone X11 build | 436 | #warning Persistent Configuration not yet implemented for standalone X11 build |
441 | #else | 437 | #else |
442 | qDebug( "saving configuration settings..." ); | 438 | odebug << "saving configuration settings..." << oendl; |
443 | 439 | ||
444 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 440 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
445 | 441 | ||
446 | OConfig* c = oApp->config(); | 442 | OConfig* c = oApp->config(); |
447 | 443 | ||
448 | c->setGroup( "Interface" ); | 444 | c->setGroup( "Interface" ); |
449 | c->writeEntry( "name", interfaceName->currentText() ); | 445 | c->writeEntry( "name", interfaceName->currentText() ); |
450 | c->writeEntry( "type", deviceType->currentText() ); | 446 | c->writeEntry( "type", deviceType->currentText() ); |
451 | c->writeEntry( "prism", prismHeader->isChecked() ); | 447 | c->writeEntry( "prism", prismHeader->isChecked() ); |
452 | c->writeEntry( "hop", hopChannels->isChecked() ); | 448 | c->writeEntry( "hop", hopChannels->isChecked() ); |
453 | c->writeEntry( "interval", hopInterval->value() ); | 449 | c->writeEntry( "interval", hopInterval->value() ); |
454 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 450 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index a47b4ec..bd91e35 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -6,71 +6,75 @@ | |||
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 | 17 | ||
18 | /* OPIE */ | ||
19 | #include <opie2/odebug.h> | ||
20 | using namespace Opie::Core; | ||
21 | |||
18 | /* QT */ | 22 | /* QT */ |
19 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
20 | 24 | ||
21 | /* STD */ | 25 | /* STD */ |
22 | #include <stdlib.h> | 26 | #include <stdlib.h> |
23 | #include <unistd.h> | 27 | #include <unistd.h> |
24 | 28 | ||
25 | GPS::GPS( QObject* parent, const char * name ) | 29 | GPS::GPS( QObject* parent, const char * name ) |
26 | :QObject( parent, name ) | 30 | :QObject( parent, name ) |
27 | { | 31 | { |
28 | qDebug( "GPS::GPS()" ); | 32 | odebug << "GPS::GPS()" << oendl; |
29 | _socket = new QSocket( this, "gpsd commsock" ); | 33 | _socket = new QSocket( this, "gpsd commsock" ); |
30 | } | 34 | } |
31 | 35 | ||
32 | 36 | ||
33 | GPS::~GPS() | 37 | GPS::~GPS() |
34 | { | 38 | { |
35 | qDebug( "GPS::~GPS()" ); | 39 | odebug << "GPS::~GPS()" << oendl; |
36 | } | 40 | } |
37 | 41 | ||
38 | 42 | ||
39 | bool GPS::open( const QString& host, int port ) | 43 | bool GPS::open( const QString& host, int port ) |
40 | { | 44 | { |
41 | _socket->connectToHost( host, port ); | 45 | _socket->connectToHost( host, port ); |
42 | } | 46 | } |
43 | 47 | ||
44 | 48 | ||
45 | GpsLocation GPS::position() const | 49 | GpsLocation GPS::position() const |
46 | { | 50 | { |
47 | char buf[256]; | 51 | char buf[256]; |
48 | double lat = -111.0; | 52 | double lat = -111.0; |
49 | double lon = -111.0; | 53 | double lon = -111.0; |
50 | 54 | ||
51 | int result = _socket->writeBlock( "p\r\n", 3 ); | 55 | int result = _socket->writeBlock( "p\r\n", 3 ); |
52 | _socket->flush(); | 56 | _socket->flush(); |
53 | if ( result ) | 57 | if ( result ) |
54 | { | 58 | { |
55 | int numAvail = _socket->bytesAvailable(); | 59 | int numAvail = _socket->bytesAvailable(); |
56 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); | 60 | odebug << "GPS write succeeded, " << numAvail << " bytes available for reading..." << oendl; |
57 | if ( numAvail ) | 61 | if ( numAvail ) |
58 | { | 62 | { |
59 | int numRead = _socket->readBlock( &buf[0], sizeof buf ); | 63 | int numRead = _socket->readBlock( &buf[0], sizeof buf ); |
60 | int numScan = ::sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); | 64 | int numScan = ::sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); |
61 | 65 | ||
62 | if ( numRead < 7 || numScan != 2 ) | 66 | if ( numRead < 7 || numScan != 2 ) |
63 | { | 67 | { |
64 | qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] ); | 68 | odebug << "GPS read " << numRead << " bytes succeeded, invalid response: '" << &buf[0] << "'" << oendl; |
65 | return GpsLocation( -111, -111 ); | 69 | return GpsLocation( -111, -111 ); |
66 | } | 70 | } |
67 | else | 71 | else |
68 | { | 72 | { |
69 | return GpsLocation( lat, lon ); | 73 | return GpsLocation( lat, lon ); |
70 | } | 74 | } |
71 | } | 75 | } |
72 | } | 76 | } |
73 | return GpsLocation( -111, -111 ); | 77 | return GpsLocation( -111, -111 ); |
74 | } | 78 | } |
75 | 79 | ||
76 | 80 | ||
diff --git a/noncore/net/wellenreiter/gui/logwindow.cpp b/noncore/net/wellenreiter/gui/logwindow.cpp index 1c72cf4..714a9a9 100644 --- a/noncore/net/wellenreiter/gui/logwindow.cpp +++ b/noncore/net/wellenreiter/gui/logwindow.cpp | |||
@@ -5,49 +5,55 @@ | |||
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 "logwindow.h" | 16 | #include "logwindow.h" |
17 | |||
18 | /* OPIE */ | ||
19 | #include <opie2/odebug.h> | ||
20 | using namespace Opie::Core; | ||
21 | |||
22 | /* QT */ | ||
17 | #include <qmultilineedit.h> | 23 | #include <qmultilineedit.h> |
18 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
19 | 25 | ||
20 | MLogWindow* MLogWindow::_instance; | 26 | MLogWindow* MLogWindow::_instance; |
21 | 27 | ||
22 | MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f ) | 28 | MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f ) |
23 | :QVBox( parent, name, f ) | 29 | :QVBox( parent, name, f ) |
24 | { | 30 | { |
25 | ledit = new QMultiLineEdit( this ); | 31 | ledit = new QMultiLineEdit( this ); |
26 | ledit->setReadOnly( true ); | 32 | ledit->setReadOnly( true ); |
27 | 33 | ||
28 | MLogWindow::_instance = this; | 34 | MLogWindow::_instance = this; |
29 | } | 35 | } |
30 | 36 | ||
31 | 37 | ||
32 | void MLogWindow::log( QString text ) | 38 | void MLogWindow::log( QString text ) |
33 | { | 39 | { |
34 | QTime time = QTime::currentTime(); | 40 | QTime time = QTime::currentTime(); |
35 | QString line; | 41 | QString line; |
36 | line.sprintf( "[%s] %s\n", (const char*) time.toString(), (const char*) text ); | 42 | line.sprintf( "[%s] %s\n", (const char*) time.toString(), (const char*) text ); |
37 | int col; | 43 | int col; |
38 | int row; | 44 | int row; |
39 | ledit->getCursorPosition( &col, &row ); | 45 | ledit->getCursorPosition( &col, &row ); |
40 | ledit->insertAt( line, col, row ); | 46 | ledit->insertAt( line, col, row ); |
41 | qDebug( line ); | 47 | odebug << line << oendl; |
42 | } | 48 | } |
43 | 49 | ||
44 | 50 | ||
45 | void MLogWindow::clear() | 51 | void MLogWindow::clear() |
46 | { | 52 | { |
47 | ledit->clear(); | 53 | ledit->clear(); |
48 | } | 54 | } |
49 | 55 | ||
50 | 56 | ||
51 | const QString MLogWindow::getLog() const | 57 | const QString MLogWindow::getLog() const |
52 | { | 58 | { |
53 | return ledit->text(); | 59 | return ledit->text(); |
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 6bbc39b..62db967 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp | |||
@@ -5,97 +5,100 @@ | |||
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 "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | |||
17 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <opie2/odebug.h> | ||
18 | #include <opie2/oapplication.h> | 20 | #include <opie2/oapplication.h> |
19 | #include <opie2/oprocess.h> | 21 | #include <opie2/oprocess.h> |
20 | #else | 22 | #else |
21 | #include <qapplication.h> | 23 | #include <qapplication.h> |
22 | #endif | 24 | #endif |
23 | 25 | ||
26 | /* QT */ | ||
24 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
25 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
26 | 29 | ||
30 | /* STD */ | ||
27 | #include <errno.h> | 31 | #include <errno.h> |
28 | #include <signal.h> | 32 | #include <signal.h> |
29 | #include <string.h> | 33 | #include <string.h> |
30 | #include <unistd.h> | 34 | #include <unistd.h> |
31 | 35 | ||
32 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
33 | using namespace Opie::Core; | 37 | |
34 | using namespace Opie::Core; | ||
35 | int main( int argc, char **argv ) | 38 | int main( int argc, char **argv ) |
36 | { | 39 | { |
37 | #ifdef QWS | 40 | #ifdef QWS |
38 | OApplication a( argc, argv, "Wellenreiter II" ); | 41 | OApplication a( argc, argv, "Wellenreiter II" ); |
39 | #else | 42 | #else |
40 | QApplication a( argc, argv ); | 43 | QApplication a( argc, argv ); |
41 | #endif | 44 | #endif |
42 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); | 45 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); |
43 | #ifdef QWS | 46 | #ifdef QWS |
44 | a.showMainWidget( w ); | 47 | a.showMainWidget( w ); |
45 | #else | 48 | #else |
46 | a.setMainWidget( w ); | 49 | a.setMainWidget( w ); |
47 | w->setCaption( "Wellenreiter II" ); | 50 | w->setCaption( "Wellenreiter II" ); |
48 | w->show(); | 51 | w->show(); |
49 | #endif | 52 | #endif |
50 | 53 | ||
51 | a.processEvents(); // show the window before doing the safety checks | 54 | a.processEvents(); // show the window before doing the safety checks |
52 | int result = -1; | 55 | int result = -1; |
53 | static int killed = false; | 56 | static int killed = false; |
54 | 57 | ||
55 | bool check = true; | 58 | bool check = true; |
56 | for ( int i = 1; i < argc; ++i ) | 59 | for ( int i = 1; i < argc; ++i ) |
57 | { | 60 | { |
58 | qDebug( "Wellenreiter::main() parsing argument %d = '%s'", i, argv[i] ); | 61 | odebug << "Wellenreiter::main() parsing argument " << i << " = '" << argv[i] << "'" << oendl; |
59 | if ( !strcmp( "-nocheck", argv[i] ) ) | 62 | if ( !strcmp( "-nocheck", argv[i] ) ) |
60 | { | 63 | { |
61 | qDebug( "-nocheck found" ); | 64 | odebug << "-nocheck found" << oendl; |
62 | check = false; | 65 | check = false; |
63 | break; | 66 | break; |
64 | } | 67 | } |
65 | } | 68 | } |
66 | 69 | ||
67 | if ( check ) | 70 | if ( check ) |
68 | { | 71 | { |
69 | // root check | 72 | // root check |
70 | if ( getuid() ) | 73 | if ( getuid() ) |
71 | { | 74 | { |
72 | qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); | 75 | owarn << QObject::tr( "Wellenreiter: trying to run as non-root!" ) << oendl; |
73 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" | 76 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" |
74 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), | 77 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), |
75 | QMessageBox::Yes, QMessageBox::No ); | 78 | QMessageBox::Yes, QMessageBox::No ); |
76 | if ( result == QMessageBox::No ) return -1; | 79 | if ( result == QMessageBox::No ) return -1; |
77 | } | 80 | } |
78 | 81 | ||
79 | int dhcpid = OProcess::processPID( "dhcpc" ); | 82 | int dhcpid = OProcess::processPID( "dhcpc" ); |
80 | 83 | ||
81 | if ( dhcpid ) | 84 | if ( dhcpid ) |
82 | { | 85 | { |
83 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" | 86 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" |
84 | "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), | 87 | "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), |
85 | QMessageBox::Yes, QMessageBox::No ); | 88 | QMessageBox::Yes, QMessageBox::No ); |
86 | if ( result == QMessageBox::Yes ) | 89 | if ( result == QMessageBox::Yes ) |
87 | { | 90 | { |
88 | if ( -1 == ::kill( dhcpid, SIGTERM ) ) | 91 | if ( -1 == ::kill( dhcpid, SIGTERM ) ) |
89 | qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); | 92 | owarn << "Wellenreiter: can't kill process #" << result << " (" << strerror( errno ) << ")" << oendl; |
90 | else | 93 | else |
91 | killed = true; | 94 | killed = true; |
92 | } | 95 | } |
93 | } | 96 | } |
94 | } | 97 | } |
95 | 98 | ||
96 | a.exec(); | 99 | a.exec(); |
97 | 100 | ||
98 | if ( check ) | 101 | if ( check ) |
99 | { | 102 | { |
100 | 103 | ||
101 | if ( killed ) | 104 | if ( killed ) |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 7add6cd..a4b8839 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -12,59 +12,60 @@ | |||
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 "packetview.h" | 19 | #include "packetview.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 | /* OPIE */ | ||
25 | #ifdef QWS | ||
26 | #include <qpe/resource.h> | ||
27 | #include <opie2/odebug.h> | ||
28 | #include <opie2/ofiledialog.h> | ||
29 | #else | ||
30 | #include "resource.h" | ||
31 | #include <qapplication.h> | ||
32 | #include <qfiledialog.h> | ||
33 | #endif | ||
34 | using namespace Opie::Core; | ||
35 | using namespace Opie::Net; | ||
36 | using namespace Opie::Ui; | ||
37 | |||
38 | /* QT */ | ||
24 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
25 | #include <qdatastream.h> | 40 | #include <qdatastream.h> |
26 | #include <qfile.h> | 41 | #include <qfile.h> |
27 | #include <qfileinfo.h> | 42 | #include <qfileinfo.h> |
28 | #include <qlabel.h> | 43 | #include <qlabel.h> |
29 | #include <qlayout.h> | 44 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
31 | #include <qiconset.h> | 46 | #include <qiconset.h> |
32 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 51 | #include <qstatusbar.h> |
37 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
38 | #include <qtextstream.h> | 53 | #include <qtextstream.h> |
39 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
40 | #include <qwhatsthis.h> | 55 | #include <qwhatsthis.h> |
41 | 56 | ||
42 | #ifdef QWS | 57 | /* STD */ |
43 | #include <qpe/resource.h> | ||
44 | #include <opie2/ofiledialog.h> | ||
45 | using namespace Opie; | ||
46 | #else | ||
47 | #include "resource.h" | ||
48 | #include <qapplication.h> | ||
49 | #include <qfiledialog.h> | ||
50 | #endif | ||
51 | |||
52 | #include <unistd.h> | 58 | #include <unistd.h> |
53 | 59 | ||
54 | using namespace Opie::Ui; | ||
55 | using namespace Opie::Net; | ||
56 | using namespace Opie::Ui; | ||
57 | using namespace Opie::Net; | ||
58 | using namespace Opie::Net; | ||
59 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 60 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
60 | :QMainWindow( parent, name, f ) | 61 | :QMainWindow( parent, name, f ) |
61 | { | 62 | { |
62 | cw = new WellenreiterConfigWindow( this ); | 63 | cw = new WellenreiterConfigWindow( this ); |
63 | mw = new Wellenreiter( this ); | 64 | mw = new Wellenreiter( this ); |
64 | mw->setConfigWindow( cw ); | 65 | mw->setConfigWindow( cw ); |
65 | setCentralWidget( mw ); | 66 | setCentralWidget( mw ); |
66 | 67 | ||
67 | // setup application icon | 68 | // setup application icon |
68 | 69 | ||
69 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 70 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
70 | #ifndef QWS | 71 | #ifndef QWS |
@@ -179,25 +180,25 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
179 | #ifndef QWS | 180 | #ifndef QWS |
180 | statusBar()->message( tr( "Ready." ) ); | 181 | statusBar()->message( tr( "Ready." ) ); |
181 | #endif | 182 | #endif |
182 | 183 | ||
183 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 184 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
184 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 185 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
185 | }; | 186 | }; |
186 | 187 | ||
187 | 188 | ||
188 | 189 | ||
189 | void WellenreiterMainWindow::showConfigure() | 190 | void WellenreiterMainWindow::showConfigure() |
190 | { | 191 | { |
191 | qDebug( "show configure..." ); | 192 | odebug << "show configure..." << oendl; |
192 | cw->setCaption( tr( "Configure" ) ); | 193 | cw->setCaption( tr( "Configure" ) ); |
193 | int result = QPEApplication::execDialog( cw ); | 194 | int result = QPEApplication::execDialog( cw ); |
194 | 195 | ||
195 | if ( result ) updateToolButtonState(); | 196 | if ( result ) updateToolButtonState(); |
196 | } | 197 | } |
197 | 198 | ||
198 | 199 | ||
199 | void WellenreiterMainWindow::updateToolButtonState() | 200 | void WellenreiterMainWindow::updateToolButtonState() |
200 | { | 201 | { |
201 | const QString& interface = cw->interfaceName->currentText(); | 202 | const QString& interface = cw->interfaceName->currentText(); |
202 | const int cardtype = cw->driverType(); | 203 | const int cardtype = cw->driverType(); |
203 | 204 | ||
@@ -222,45 +223,45 @@ void WellenreiterMainWindow::changedSniffingState() | |||
222 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 223 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
223 | 224 | ||
224 | if ( !mw->sniffing ) | 225 | if ( !mw->sniffing ) |
225 | { | 226 | { |
226 | menuBar()->setItemEnabled( uploadID, true ); | 227 | menuBar()->setItemEnabled( uploadID, true ); |
227 | uploadButton->setEnabled( true ); | 228 | uploadButton->setEnabled( true ); |
228 | } | 229 | } |
229 | } | 230 | } |
230 | 231 | ||
231 | 232 | ||
232 | WellenreiterMainWindow::~WellenreiterMainWindow() | 233 | WellenreiterMainWindow::~WellenreiterMainWindow() |
233 | { | 234 | { |
234 | qDebug( "Wellenreiter: bye." ); | 235 | odebug << "Wellenreiter: bye." << oendl; |
235 | }; | 236 | }; |
236 | 237 | ||
237 | 238 | ||
238 | void WellenreiterMainWindow::demoAddStations() | 239 | void WellenreiterMainWindow::demoAddStations() |
239 | { | 240 | { |
240 | //mw = 0; // test SIGSEGV handling | 241 | //mw = 0; // test SIGSEGV handling |
241 | 242 | ||
242 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 243 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
243 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 244 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
244 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 245 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
245 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 246 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
246 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 247 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
247 | } | 248 | } |
248 | 249 | ||
249 | 250 | ||
250 | void WellenreiterMainWindow::demoReadFromGps() | 251 | void WellenreiterMainWindow::demoReadFromGps() |
251 | { | 252 | { |
252 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | 253 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); |
253 | GPS* gps = new GPS( this ); | 254 | GPS* gps = new GPS( this ); |
254 | qDebug( "Wellenreiter::demoReadFromGps(): url=gps://%s:%d/", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 255 | odebug << "Wellenreiter::demoReadFromGps(): url=gps://" << (const char*) configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "/" << oendl; |
255 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 256 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
256 | GpsLocation loc = gps->position(); | 257 | GpsLocation loc = gps->position(); |
257 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); | 258 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); |
258 | delete gps; | 259 | delete gps; |
259 | } | 260 | } |
260 | 261 | ||
261 | 262 | ||
262 | QString WellenreiterMainWindow::getFileName( bool save ) | 263 | QString WellenreiterMainWindow::getFileName( bool save ) |
263 | { | 264 | { |
264 | QMap<QString, QStringList> map; | 265 | QMap<QString, QStringList> map; |
265 | map.insert( tr("All"), QStringList() ); | 266 | map.insert( tr("All"), QStringList() ); |
266 | QStringList text; | 267 | QStringList text; |
@@ -296,93 +297,93 @@ QString WellenreiterMainWindow::getFileName( bool save ) | |||
296 | 297 | ||
297 | void WellenreiterMainWindow::fileSaveLog() | 298 | void WellenreiterMainWindow::fileSaveLog() |
298 | { | 299 | { |
299 | QString fname = getFileName( true ); | 300 | QString fname = getFileName( true ); |
300 | if ( !fname.isEmpty() ) | 301 | if ( !fname.isEmpty() ) |
301 | { | 302 | { |
302 | QFile f( fname ); | 303 | QFile f( fname ); |
303 | if ( f.open(IO_WriteOnly) ) | 304 | if ( f.open(IO_WriteOnly) ) |
304 | { | 305 | { |
305 | QTextStream t( &f ); | 306 | QTextStream t( &f ); |
306 | t << mw->logWindow()->getLog(); | 307 | t << mw->logWindow()->getLog(); |
307 | f.close(); | 308 | f.close(); |
308 | qDebug( "Saved log to file '%s'", (const char*) fname ); | 309 | odebug << "Saved log to file '" << (const char*) fname << "'" << oendl; |
309 | } | 310 | } |
310 | else | 311 | else |
311 | { | 312 | { |
312 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | 313 | odebug << "Problem saving log to file '" << (const char*) fname << "'" << oendl; |
313 | } | 314 | } |
314 | } | 315 | } |
315 | } | 316 | } |
316 | 317 | ||
317 | void WellenreiterMainWindow::fileSaveSession() | 318 | void WellenreiterMainWindow::fileSaveSession() |
318 | { | 319 | { |
319 | QString fname = getFileName( true ); | 320 | QString fname = getFileName( true ); |
320 | if ( !fname.isEmpty() ) | 321 | if ( !fname.isEmpty() ) |
321 | { | 322 | { |
322 | 323 | ||
323 | QFile f( fname ); | 324 | QFile f( fname ); |
324 | if ( f.open(IO_WriteOnly) ) | 325 | if ( f.open(IO_WriteOnly) ) |
325 | { | 326 | { |
326 | QDataStream t( &f ); | 327 | QDataStream t( &f ); |
327 | t << *mw->netView(); | 328 | t << *mw->netView(); |
328 | f.close(); | 329 | f.close(); |
329 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 330 | odebug << "Saved session to file '" << (const char*) fname << "'" << oendl; |
330 | } | 331 | } |
331 | else | 332 | else |
332 | { | 333 | { |
333 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); | 334 | odebug << "Problem saving session to file '" << (const char*) fname << "'" << oendl; |
334 | } | 335 | } |
335 | } | 336 | } |
336 | } | 337 | } |
337 | 338 | ||
338 | void WellenreiterMainWindow::fileSaveHex() | 339 | void WellenreiterMainWindow::fileSaveHex() |
339 | { | 340 | { |
340 | #warning DOES NOT WORK AT THE MOMENT | 341 | #warning DOES NOT WORK AT THE MOMENT |
341 | /* | 342 | /* |
342 | QString fname = getFileName( true ); | 343 | QString fname = getFileName( true ); |
343 | if ( !fname.isEmpty() ) | 344 | if ( !fname.isEmpty() ) |
344 | { | 345 | { |
345 | QFile f( fname ); | 346 | QFile f( fname ); |
346 | if ( f.open(IO_WriteOnly) ) | 347 | if ( f.open(IO_WriteOnly) ) |
347 | { | 348 | { |
348 | QTextStream t( &f ); | 349 | QTextStream t( &f ); |
349 | t << mw->hexWindow()->getLog(); | 350 | t << mw->hexWindow()->getLog(); |
350 | f.close(); | 351 | f.close(); |
351 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); | 352 | odebug << "Saved hex log to file '" << (const char*) fname << "'" << oendl; |
352 | } | 353 | } |
353 | else | 354 | else |
354 | { | 355 | { |
355 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); | 356 | odebug << "Problem saving hex log to file '" << (const char*) fname << "'" << oendl; |
356 | } | 357 | } |
357 | } | 358 | } |
358 | */ | 359 | */ |
359 | } | 360 | } |
360 | 361 | ||
361 | void WellenreiterMainWindow::fileLoadSession() | 362 | void WellenreiterMainWindow::fileLoadSession() |
362 | { | 363 | { |
363 | QString fname = getFileName( false ); | 364 | QString fname = getFileName( false ); |
364 | if ( !fname.isEmpty() ) | 365 | if ( !fname.isEmpty() ) |
365 | { | 366 | { |
366 | QFile f( fname ); | 367 | QFile f( fname ); |
367 | if ( f.open(IO_ReadOnly) ) | 368 | if ( f.open(IO_ReadOnly) ) |
368 | { | 369 | { |
369 | QDataStream t( &f ); | 370 | QDataStream t( &f ); |
370 | t >> *mw->netView(); | 371 | t >> *mw->netView(); |
371 | f.close(); | 372 | f.close(); |
372 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | 373 | odebug << "Loaded session from file '" << (const char*) fname << "'" << oendl; |
373 | } | 374 | } |
374 | else | 375 | else |
375 | { | 376 | { |
376 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | 377 | odebug << "Problem loading session from file '" << (const char*) fname << "'" << oendl; |
377 | } | 378 | } |
378 | } | 379 | } |
379 | } | 380 | } |
380 | 381 | ||
381 | 382 | ||
382 | void WellenreiterMainWindow::fileNew() | 383 | void WellenreiterMainWindow::fileNew() |
383 | { | 384 | { |
384 | mw->netView()->clear(); | 385 | mw->netView()->clear(); |
385 | mw->logWindow()->clear(); | 386 | mw->logWindow()->clear(); |
386 | mw->hexWindow()->clear(); | 387 | mw->hexWindow()->clear(); |
387 | } | 388 | } |
388 | 389 | ||
@@ -429,29 +430,29 @@ void WellenreiterMainWindow::uploadSession() | |||
429 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 430 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
430 | accept->setDefault( true ); | 431 | accept->setDefault( true ); |
431 | accept->setAutoDefault( true ); | 432 | accept->setAutoDefault( true ); |
432 | from->setText( "WL II User" ); | 433 | from->setText( "WL II User" ); |
433 | location->setText( "WL II Location" ); | 434 | location->setText( "WL II Location" ); |
434 | comments->setText( "No Comments." ); | 435 | comments->setText( "No Comments." ); |
435 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 436 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
436 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 437 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
437 | int result = d->exec(); | 438 | int result = d->exec(); |
438 | 439 | ||
439 | if ( !result ) | 440 | if ( !result ) |
440 | { | 441 | { |
441 | qDebug( "Session upload cancelled :(" ); | 442 | odebug << "Session upload cancelled :(" << oendl; |
442 | return; | 443 | return; |
443 | } | 444 | } |
444 | 445 | ||
445 | qDebug( "Starting upload..." ); | 446 | odebug << "Starting upload..." << oendl; |
446 | 447 | ||
447 | struct sockaddr_in raddr; | 448 | struct sockaddr_in raddr; |
448 | struct hostent *rhost_info; | 449 | struct hostent *rhost_info; |
449 | int sock = -1; | 450 | int sock = -1; |
450 | bool ok = false; | 451 | bool ok = false; |
451 | 452 | ||
452 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 453 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
453 | if ( rhost_info ) | 454 | if ( rhost_info ) |
454 | { | 455 | { |
455 | 456 | ||
456 | 457 | ||
457 | if ( !QFile::exists( mw->captureFileName() ) ) | 458 | if ( !QFile::exists( mw->captureFileName() ) ) |
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp index 3d3aa18..4df01da 100644 --- a/noncore/net/wellenreiter/gui/packetview.cpp +++ b/noncore/net/wellenreiter/gui/packetview.cpp | |||
@@ -75,25 +75,25 @@ void PacketView::showPacket( int number ) | |||
75 | { | 75 | { |
76 | _list->clear(); | 76 | _list->clear(); |
77 | _hex->setText(""); | 77 | _hex->setText(""); |
78 | const OPacket* p = _packets.at( number ); | 78 | const OPacket* p = _packets.at( number ); |
79 | 79 | ||
80 | if ( p ) | 80 | if ( p ) |
81 | { | 81 | { |
82 | _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); | 82 | _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); |
83 | _doHexPacket( p ); | 83 | _doHexPacket( p ); |
84 | } | 84 | } |
85 | else | 85 | else |
86 | { | 86 | { |
87 | qDebug( "D'oh! No packet!" ); | 87 | odebug << "D'oh! No packet!" << oendl; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void PacketView::_doSubPackets( QObjectList* l, int counter ) | 91 | void PacketView::_doSubPackets( QObjectList* l, int counter ) |
92 | { | 92 | { |
93 | if (!l) return; | 93 | if (!l) return; |
94 | QObject* o = l->first(); | 94 | QObject* o = l->first(); |
95 | while ( o ) | 95 | while ( o ) |
96 | { | 96 | { |
97 | new OListViewItem( _list, QString::number( counter++ ), o->name() ); | 97 | new OListViewItem( _list, QString::number( counter++ ), o->name() ); |
98 | _doSubPackets( const_cast<QObjectList*>( o->children() ), counter ); | 98 | _doSubPackets( const_cast<QObjectList*>( o->children() ), counter ); |
99 | o = l->next(); | 99 | o = l->next(); |
diff --git a/noncore/net/wellenreiter/gui/resource.cpp b/noncore/net/wellenreiter/gui/resource.cpp index d98ef0b..cb17f51 100644 --- a/noncore/net/wellenreiter/gui/resource.cpp +++ b/noncore/net/wellenreiter/gui/resource.cpp | |||
@@ -20,30 +20,30 @@ | |||
20 | #include <qiconset.h> | 20 | #include <qiconset.h> |
21 | 21 | ||
22 | namespace Resource | 22 | namespace Resource |
23 | { | 23 | { |
24 | 24 | ||
25 | QPixmap loadPixmap( const QString& pix ) | 25 | QPixmap loadPixmap( const QString& pix ) |
26 | { | 26 | { |
27 | QString filename; | 27 | QString filename; |
28 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); | 28 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); |
29 | QPixmap pixmap( filename ); | 29 | QPixmap pixmap( filename ); |
30 | if ( pixmap.isNull() ) | 30 | if ( pixmap.isNull() ) |
31 | { | 31 | { |
32 | qDebug( "Wellenreiter::Resource: can't find pixmap " + filename ); | 32 | odebug << "Wellenreiter::Resource: can't find pixmap " + filename << oendl; |
33 | } | 33 | } |
34 | return pixmap; | 34 | return pixmap; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | QIconSet loadIconSet( const QString& pix ) | 37 | QIconSet loadIconSet( const QString& pix ) |
38 | { | 38 | { |
39 | QString filename; | 39 | QString filename; |
40 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); | 40 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); |
41 | QPixmap pixmap( filename ); | 41 | QPixmap pixmap( filename ); |
42 | if ( pixmap.isNull() ) | 42 | if ( pixmap.isNull() ) |
43 | { | 43 | { |
44 | qDebug( "Wellenreiter::Resource: can't find pixmap " + filename ); | 44 | odebug << "Wellenreiter::Resource: can't find pixmap " + filename << oendl; |
45 | } | 45 | } |
46 | return QIconSet( pixmap ); | 46 | return QIconSet( pixmap ); |
47 | }; | 47 | }; |
48 | 48 | ||
49 | }; | 49 | }; |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 3b7120a..a2be782 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -8,59 +8,58 @@ | |||
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 | /* OPIE */ |
21 | #include <qcursor.h> | ||
22 | #include <qdatetime.h> | ||
23 | #include <qpopupmenu.h> | ||
24 | #include <qcheckbox.h> | ||
25 | |||
26 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie2/odebug.h> | ||
27 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
28 | #endif | ||
29 | |||
30 | #ifdef QWS | ||
31 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
32 | #else | 25 | #else |
33 | #include "resource.h" | 26 | #include "resource.h" |
34 | #endif | 27 | #endif |
28 | using namespace Opie::Core; | ||
29 | using namespace Opie::Ui; | ||
30 | using namespace Opie::Net; | ||
31 | |||
32 | /* QT */ | ||
33 | #include <qcursor.h> | ||
34 | #include <qdatetime.h> | ||
35 | #include <qpopupmenu.h> | ||
36 | #include <qcheckbox.h> | ||
37 | |||
38 | /* STD */ | ||
39 | #include <assert.h> | ||
35 | 40 | ||
36 | const int col_type = 0; | 41 | const int col_type = 0; |
37 | const int col_essid = 0; | 42 | const int col_essid = 0; |
38 | const int col_sig = 1; | 43 | const int col_sig = 1; |
39 | const int col_ap = 2; | 44 | const int col_ap = 2; |
40 | const int col_channel = 3; | 45 | const int col_channel = 3; |
41 | const int col_wep = 4; | 46 | const int col_wep = 4; |
42 | const int col_traffic = 5; | 47 | const int col_traffic = 5; |
43 | const int col_ip = 6; | 48 | const int col_ip = 6; |
44 | const int col_manuf = 7; | 49 | const int col_manuf = 7; |
45 | const int col_firstseen = 8; | 50 | const int col_firstseen = 8; |
46 | const int col_lastseen = 9; | 51 | const int col_lastseen = 9; |
47 | const int col_location = 10; | 52 | const int col_location = 10; |
48 | 53 | ||
49 | using namespace Opie::Net; | ||
50 | using namespace Opie::Ui; | ||
51 | using namespace Opie::Net; | ||
52 | using namespace Opie::Ui; | ||
53 | using namespace Opie::Ui; | ||
54 | using namespace Opie::Net; | ||
55 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 54 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
56 | :OListView( parent, name ) | 55 | :OListView( parent, name ) |
57 | { | 56 | { |
58 | setFrameShape( QListView::StyledPanel ); | 57 | setFrameShape( QListView::StyledPanel ); |
59 | setFrameShadow( QListView::Sunken ); | 58 | setFrameShadow( QListView::Sunken ); |
60 | 59 | ||
61 | addColumn( tr( "Net/Station" ) ); | 60 | addColumn( tr( "Net/Station" ) ); |
62 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
63 | addColumn( tr( "#" ) ); | 62 | addColumn( tr( "#" ) ); |
64 | setColumnAlignment( col_sig, AlignCenter ); | 63 | setColumnAlignment( col_sig, AlignCenter ); |
65 | addColumn( tr( "MAC" ) ); | 64 | addColumn( tr( "MAC" ) ); |
66 | setColumnAlignment( col_ap, AlignCenter ); | 65 | setColumnAlignment( col_ap, AlignCenter ); |
@@ -97,32 +96,32 @@ MScanListView::~MScanListView() | |||
97 | { | 96 | { |
98 | }; | 97 | }; |
99 | 98 | ||
100 | 99 | ||
101 | OListViewItem* MScanListView::childFactory() | 100 | OListViewItem* MScanListView::childFactory() |
102 | { | 101 | { |
103 | return new MScanListItem( this ); | 102 | return new MScanListItem( this ); |
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | void MScanListView::serializeTo( QDataStream& s) const | 106 | void MScanListView::serializeTo( QDataStream& s) const |
108 | { | 107 | { |
109 | qDebug( "serializing MScanListView" ); | 108 | odebug << "serializing MScanListView" << oendl; |
110 | OListView::serializeTo( s ); | 109 | OListView::serializeTo( s ); |
111 | } | 110 | } |
112 | 111 | ||
113 | 112 | ||
114 | void MScanListView::serializeFrom( QDataStream& s) | 113 | void MScanListView::serializeFrom( QDataStream& s) |
115 | { | 114 | { |
116 | qDebug( "serializing MScanListView" ); | 115 | odebug << "serializing MScanListView" << oendl; |
117 | OListView::serializeFrom( s ); | 116 | OListView::serializeFrom( s ); |
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
121 | void MScanListView::addNewItem( const QString& type, | 120 | void MScanListView::addNewItem( const QString& type, |
122 | const QString& essid, | 121 | const QString& essid, |
123 | const OMacAddress& mac, | 122 | const OMacAddress& mac, |
124 | bool wep, | 123 | bool wep, |
125 | int channel, | 124 | int channel, |
126 | int signal, | 125 | int signal, |
127 | const GpsLocation& loc, | 126 | const GpsLocation& loc, |
128 | bool probe ) | 127 | bool probe ) |
@@ -134,68 +133,68 @@ void MScanListView::addNewItem( const QString& type, | |||
134 | (const char*) essid, (const char*) macaddr, channel ); | 133 | (const char*) essid, (const char*) macaddr, channel ); |
135 | #endif | 134 | #endif |
136 | 135 | ||
137 | // search, if we already have seen this net | 136 | // search, if we already have seen this net |
138 | 137 | ||
139 | QString s; | 138 | QString s; |
140 | MScanListItem* network; | 139 | MScanListItem* network; |
141 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 140 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
142 | 141 | ||
143 | while ( item && ( item->text( col_essid ) != essid ) ) | 142 | while ( item && ( item->text( col_essid ) != essid ) ) |
144 | { | 143 | { |
145 | #ifdef DEBUG | 144 | #ifdef DEBUG |
146 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 145 | odebug << "itemtext: " << (const char*) item->text( col_essid ) << "" << oendl; |
147 | #endif | 146 | #endif |
148 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 147 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
149 | } | 148 | } |
150 | if ( item ) | 149 | if ( item ) |
151 | { | 150 | { |
152 | // we have already seen this net, check all childs if MAC exists | 151 | // we have already seen this net, check all childs if MAC exists |
153 | 152 | ||
154 | network = item; | 153 | network = item; |
155 | 154 | ||
156 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 155 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
157 | assert( item ); // this shouldn't fail | 156 | assert( item ); // this shouldn't fail |
158 | 157 | ||
159 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 158 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
160 | { | 159 | { |
161 | #ifdef DEBUG | 160 | #ifdef DEBUG |
162 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 161 | odebug << "subitemtext: " << (const char*) item->text( col_ap ) << "" << oendl; |
163 | #endif | 162 | #endif |
164 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 163 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
165 | } | 164 | } |
166 | 165 | ||
167 | if ( item ) | 166 | if ( item ) |
168 | { | 167 | { |
169 | // we have already seen this item, it's a dupe | 168 | // we have already seen this item, it's a dupe |
170 | #ifdef DEBUG | 169 | #ifdef DEBUG |
171 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 170 | odebug << "" << (const char*) macaddr << " is a dupe - ignoring..." << oendl; |
172 | #endif | 171 | #endif |
173 | item->receivedBeacon(); | 172 | item->receivedBeacon(); |
174 | return; | 173 | return; |
175 | } | 174 | } |
176 | } | 175 | } |
177 | else | 176 | else |
178 | { | 177 | { |
179 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 178 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
180 | MLogWindow::logwindow()->log( s ); | 179 | MLogWindow::logwindow()->log( s ); |
181 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 180 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
182 | } | 181 | } |
183 | 182 | ||
184 | 183 | ||
185 | // insert new station as child from network | 184 | // insert new station as child from network |
186 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 185 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
187 | 186 | ||
188 | #ifdef DEBUG | 187 | #ifdef DEBUG |
189 | qDebug( "inserting new station %s", (const char*) macaddr ); | 188 | odebug << "inserting new station " << (const char*) macaddr << "" << oendl; |
190 | #endif | 189 | #endif |
191 | 190 | ||
192 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 191 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
193 | station->setManufacturer( mac.manufacturer() ); | 192 | station->setManufacturer( mac.manufacturer() ); |
194 | station->setLocation( loc.dmsPosition() ); | 193 | station->setLocation( loc.dmsPosition() ); |
195 | 194 | ||
196 | if ( type == "managed" ) | 195 | if ( type == "managed" ) |
197 | { | 196 | { |
198 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 197 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
199 | } | 198 | } |
200 | else | 199 | else |
201 | { | 200 | { |
@@ -203,196 +202,196 @@ void MScanListView::addNewItem( const QString& type, | |||
203 | } | 202 | } |
204 | MLogWindow::logwindow()->log( s ); | 203 | MLogWindow::logwindow()->log( s ); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
209 | { | 208 | { |
210 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
211 | 210 | ||
212 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
213 | { | 212 | { |
214 | #ifdef DEBUG | 213 | #ifdef DEBUG |
215 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | odebug << "subitemtext: " << (const char*) subitem->text( col_ap ) << "" << oendl; |
216 | #endif | 215 | #endif |
217 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
218 | } | 217 | } |
219 | 218 | ||
220 | if ( subitem ) | 219 | if ( subitem ) |
221 | { | 220 | { |
222 | // we have already seen this item, it's a dupe | 221 | // we have already seen this item, it's a dupe |
223 | #ifdef DEBUG | 222 | #ifdef DEBUG |
224 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 223 | odebug << "" << (const char*) addr.toString(true) << " is a dupe - ignoring..." << oendl; |
225 | #endif | 224 | #endif |
226 | subitem->receivedBeacon(); //FIXME: sent data bit | 225 | subitem->receivedBeacon(); //FIXME: sent data bit |
227 | return; | 226 | return; |
228 | } | 227 | } |
229 | 228 | ||
230 | // Hey, it seems to be a new item :-D | 229 | // Hey, it seems to be a new item :-D |
231 | 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 ); |
232 | station->setManufacturer( addr.manufacturer() ); | 231 | station->setManufacturer( addr.manufacturer() ); |
233 | 232 | ||
234 | QString s; | 233 | QString s; |
235 | if ( type == "station" ) | 234 | if ( type == "station" ) |
236 | { | 235 | { |
237 | 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 ) ); |
238 | } | 237 | } |
239 | else | 238 | else |
240 | { | 239 | { |
241 | 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 ) ); |
242 | } | 241 | } |
243 | MLogWindow::logwindow()->log( s ); | 242 | MLogWindow::logwindow()->log( s ); |
244 | } | 243 | } |
245 | 244 | ||
246 | 245 | ||
247 | 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 ) |
248 | { | 247 | { |
249 | qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() ); | 248 | odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << (const char*) viaTo.toString() << " seem to form a WDS" << oendl; |
250 | QString s; | 249 | QString s; |
251 | MScanListItem* network; | 250 | MScanListItem* network; |
252 | 251 | ||
253 | QListViewItemIterator it( this ); | 252 | QListViewItemIterator it( this ); |
254 | while ( it.current() && | 253 | while ( it.current() && |
255 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 254 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
256 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 255 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
257 | 256 | ||
258 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 257 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
259 | 258 | ||
260 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 259 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
261 | { | 260 | { |
262 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
263 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 262 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
264 | } | 263 | } |
265 | else | 264 | else |
266 | { | 265 | { |
267 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 266 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; |
268 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 267 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
269 | } | 268 | } |
270 | } | 269 | } |
271 | 270 | ||
272 | 271 | ||
273 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 272 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
274 | { | 273 | { |
275 | QString s; | 274 | QString s; |
276 | MScanListItem* network; | 275 | MScanListItem* network; |
277 | 276 | ||
278 | QListViewItemIterator it( this ); | 277 | QListViewItemIterator it( this ); |
279 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 278 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
280 | 279 | ||
281 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 280 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
282 | 281 | ||
283 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 282 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
284 | { | 283 | { |
285 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 284 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
286 | } | 285 | } |
287 | else | 286 | else |
288 | { | 287 | { |
289 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 288 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
290 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 289 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
291 | 290 | ||
292 | } | 291 | } |
293 | } | 292 | } |
294 | 293 | ||
295 | 294 | ||
296 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 295 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
297 | { | 296 | { |
298 | QString s; | 297 | QString s; |
299 | MScanListItem* network; | 298 | MScanListItem* network; |
300 | 299 | ||
301 | QListViewItemIterator it( this ); | 300 | QListViewItemIterator it( this ); |
302 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 301 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
303 | 302 | ||
304 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 303 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
305 | 304 | ||
306 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 305 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
307 | { | 306 | { |
308 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 307 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
309 | } | 308 | } |
310 | else | 309 | else |
311 | { | 310 | { |
312 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 311 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
313 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 312 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
314 | } | 313 | } |
315 | } | 314 | } |
316 | 315 | ||
317 | 316 | ||
318 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 317 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
319 | { | 318 | { |
320 | qWarning( "D'oh! Not yet implemented..." ); | 319 | owarn << "D'oh! Not yet implemented..." << oendl; |
321 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 320 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
322 | } | 321 | } |
323 | 322 | ||
324 | 323 | ||
325 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 324 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
326 | { | 325 | { |
327 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 326 | odebug << "identify " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl; |
328 | 327 | ||
329 | QListViewItemIterator it( this ); | 328 | QListViewItemIterator it( this ); |
330 | for ( ; it.current(); ++it ) | 329 | for ( ; it.current(); ++it ) |
331 | { | 330 | { |
332 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 331 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
333 | { | 332 | { |
334 | it.current()->setText( col_ip, ip ); | 333 | it.current()->setText( col_ip, ip ); |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | } | 336 | } |
338 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 337 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
339 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 338 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
340 | (const char*) macaddr.toString(), (const char*) ip ) ); | 339 | (const char*) macaddr.toString(), (const char*) ip ) ); |
341 | } | 340 | } |
342 | 341 | ||
343 | 342 | ||
344 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 343 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
345 | { | 344 | { |
346 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 345 | odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl; |
347 | 346 | ||
348 | //TODO: Refactor that out, we need it all over the place. | 347 | //TODO: Refactor that out, we need it all over the place. |
349 | // Best to do it in a more comfortable abstraction in OListView | 348 | // Best to do it in a more comfortable abstraction in OListView |
350 | // (Hmm, didn't I already start something in this direction?) | 349 | // (Hmm, didn't I already start something in this direction?) |
351 | 350 | ||
352 | QListViewItemIterator it( this ); | 351 | QListViewItemIterator it( this ); |
353 | for ( ; it.current(); ++it ) | 352 | for ( ; it.current(); ++it ) |
354 | { | 353 | { |
355 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 354 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
356 | { | 355 | { |
357 | 356 | ||
358 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 357 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
359 | 358 | ||
360 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 359 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
361 | { | 360 | { |
362 | #ifdef DEBUG | 361 | #ifdef DEBUG |
363 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 362 | odebug << "subitemtext: " << (const char*) subitem->text( col_essid ) << "" << oendl; |
364 | #endif | 363 | #endif |
365 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 364 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
366 | } | 365 | } |
367 | 366 | ||
368 | if ( subitem ) | 367 | if ( subitem ) |
369 | { | 368 | { |
370 | // we have already seen this item, it's a dupe | 369 | // we have already seen this item, it's a dupe |
371 | #ifdef DEBUG | 370 | #ifdef DEBUG |
372 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 371 | odebug << "" << (const char*) name << " is a dupe - ignoring..." << oendl; |
373 | #endif | 372 | #endif |
374 | subitem->receivedBeacon(); //FIXME: sent data bit | 373 | subitem->receivedBeacon(); //FIXME: sent data bit |
375 | return; | 374 | return; |
376 | } | 375 | } |
377 | 376 | ||
378 | // never seen that - add new item | 377 | // never seen that - add new item |
379 | 378 | ||
380 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 379 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
381 | item->setText( col_essid, name ); | 380 | item->setText( col_essid, name ); |
382 | 381 | ||
383 | return; | 382 | return; |
384 | } | 383 | } |
385 | } | 384 | } |
386 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 385 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
387 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 386 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
388 | (const char*) macaddr.toString(), (const char*) ip ) ); | 387 | (const char*) macaddr.toString(), (const char*) ip ) ); |
389 | } | 388 | } |
390 | 389 | ||
391 | 390 | ||
392 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 391 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
393 | { | 392 | { |
394 | if ( !item ) return; | 393 | if ( !item ) return; |
395 | 394 | ||
396 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 395 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
397 | 396 | ||
398 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 397 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
@@ -412,74 +411,74 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in | |||
412 | 411 | ||
413 | //============================================================ | 412 | //============================================================ |
414 | // MScanListItem | 413 | // MScanListItem |
415 | //============================================================ | 414 | //============================================================ |
416 | 415 | ||
417 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 416 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
418 | bool wep, int channel, int signal, bool probed ) | 417 | bool wep, int channel, int signal, bool probed ) |
419 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 418 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
420 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 419 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
421 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 420 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
422 | { | 421 | { |
423 | #ifdef DEBUG | 422 | #ifdef DEBUG |
424 | qDebug( "creating scanlist item" ); | 423 | odebug << "creating scanlist item" << oendl; |
425 | #endif | 424 | #endif |
426 | 425 | ||
427 | if ( WellenreiterConfigWindow::instance() ) | 426 | if ( WellenreiterConfigWindow::instance() ) |
428 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 427 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
429 | 428 | ||
430 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 429 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
431 | } | 430 | } |
432 | 431 | ||
433 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 432 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
434 | bool wep, int channel, int signal ) | 433 | bool wep, int channel, int signal ) |
435 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 434 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
436 | { | 435 | { |
437 | #ifdef DEBUG | 436 | #ifdef DEBUG |
438 | qDebug( "creating scanlist item" ); | 437 | odebug << "creating scanlist item" << oendl; |
439 | #endif | 438 | #endif |
440 | if ( WellenreiterConfigWindow::instance() ) | 439 | if ( WellenreiterConfigWindow::instance() ) |
441 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 440 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
442 | 441 | ||
443 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 442 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
444 | } | 443 | } |
445 | 444 | ||
446 | const QString& MScanListItem::essid() const | 445 | const QString& MScanListItem::essid() const |
447 | { | 446 | { |
448 | if ( type == "network" ) | 447 | if ( type == "network" ) |
449 | return _essid; | 448 | return _essid; |
450 | else | 449 | else |
451 | return ( (MScanListItem*) parent() )->essid(); | 450 | return ( (MScanListItem*) parent() )->essid(); |
452 | } | 451 | } |
453 | 452 | ||
454 | OListViewItem* MScanListItem::childFactory() | 453 | OListViewItem* MScanListItem::childFactory() |
455 | { | 454 | { |
456 | return new MScanListItem( this ); | 455 | return new MScanListItem( this ); |
457 | } | 456 | } |
458 | 457 | ||
459 | void MScanListItem::serializeTo( QDataStream& s ) const | 458 | void MScanListItem::serializeTo( QDataStream& s ) const |
460 | { | 459 | { |
461 | #ifdef DEBUG | 460 | #ifdef DEBUG |
462 | qDebug( "serializing MScanListItem" ); | 461 | odebug << "serializing MScanListItem" << oendl; |
463 | #endif | 462 | #endif |
464 | OListViewItem::serializeTo( s ); | 463 | OListViewItem::serializeTo( s ); |
465 | 464 | ||
466 | s << _type; | 465 | s << _type; |
467 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 466 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
468 | } | 467 | } |
469 | 468 | ||
470 | void MScanListItem::serializeFrom( QDataStream& s ) | 469 | void MScanListItem::serializeFrom( QDataStream& s ) |
471 | { | 470 | { |
472 | #ifdef DEBUG | 471 | #ifdef DEBUG |
473 | qDebug( "serializing MScanListItem" ); | 472 | odebug << "serializing MScanListItem" << oendl; |
474 | #endif | 473 | #endif |
475 | OListViewItem::serializeFrom( s ); | 474 | OListViewItem::serializeFrom( s ); |
476 | 475 | ||
477 | char wep; | 476 | char wep; |
478 | s >> _type; | 477 | s >> _type; |
479 | s >> (Q_UINT8) wep; | 478 | s >> (Q_UINT8) wep; |
480 | _wep = (wep == 'y'); | 479 | _wep = (wep == 'y'); |
481 | 480 | ||
482 | QString name; | 481 | QString name; |
483 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 482 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
484 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 483 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
485 | if ( _wep ) | 484 | if ( _wep ) |
@@ -547,22 +546,22 @@ void MScanListItem::setManufacturer( const QString& manufacturer ) | |||
547 | 546 | ||
548 | 547 | ||
549 | void MScanListItem::setLocation( const QString& location ) | 548 | void MScanListItem::setLocation( const QString& location ) |
550 | { | 549 | { |
551 | setText( col_location, location ); | 550 | setText( col_location, location ); |
552 | } | 551 | } |
553 | 552 | ||
554 | 553 | ||
555 | void MScanListItem::receivedBeacon() | 554 | void MScanListItem::receivedBeacon() |
556 | { | 555 | { |
557 | _beacons++; | 556 | _beacons++; |
558 | #ifdef DEBUG | 557 | #ifdef DEBUG |
559 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 558 | odebug << "MScanListItem " << (const char*) _macaddr << ": received beacon #" << _beacons << "" << oendl; |
560 | #endif | 559 | #endif |
561 | setText( col_sig, QString::number( _beacons ) ); | 560 | setText( col_sig, QString::number( _beacons ) ); |
562 | setText( col_lastseen, QTime::currentTime().toString() ); | 561 | setText( col_lastseen, QTime::currentTime().toString() ); |
563 | 562 | ||
564 | MScanListItem* p = (MScanListItem*) parent(); | 563 | MScanListItem* p = (MScanListItem*) parent(); |
565 | if ( p ) p->receivedBeacon(); | 564 | if ( p ) p->receivedBeacon(); |
566 | 565 | ||
567 | } | 566 | } |
568 | 567 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index fff7c35..fad6efd 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -2,80 +2,72 @@ | |||
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
5 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
7 | ** packaging of this file. | 7 | ** packaging of this file. |
8 | ** | 8 | ** |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
11 | ** | 11 | ** |
12 | ***********************************************************************/ | 12 | ***********************************************************************/ |
13 | 13 | ||
14 | // Local | ||
15 | |||
16 | #include "gps.h" | 14 | #include "gps.h" |
17 | #include "wellenreiter.h" | 15 | #include "wellenreiter.h" |
18 | #include "scanlist.h" | 16 | #include "scanlist.h" |
19 | #include "logwindow.h" | 17 | #include "logwindow.h" |
20 | #include "packetview.h" | 18 | #include "packetview.h" |
21 | #include "configwindow.h" | 19 | #include "configwindow.h" |
22 | #include "statwindow.h" | 20 | #include "statwindow.h" |
23 | #include "graphwindow.h" | 21 | #include "graphwindow.h" |
24 | #include "protolistview.h" | 22 | #include "protolistview.h" |
25 | 23 | ||
26 | // Opie | 24 | /* OPIE */ |
27 | |||
28 | #ifdef QWS | 25 | #ifdef QWS |
29 | #include <opie2/oapplication.h> | 26 | #include <opie2/oapplication.h> |
27 | #include <opie2/odebug.h> | ||
30 | #include <opie2/odevice.h> | 28 | #include <opie2/odevice.h> |
31 | #else | 29 | #else |
32 | #include <qapplication.h> | 30 | #include <qapplication.h> |
33 | #endif | 31 | #endif |
34 | #include <opie2/omanufacturerdb.h> | 32 | #include <opie2/omanufacturerdb.h> |
35 | #include <opie2/onetwork.h> | 33 | #include <opie2/onetwork.h> |
36 | #include <opie2/opcap.h> | 34 | #include <opie2/opcap.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
38 | using namespace Opie; | 36 | using namespace Opie::Core; |
39 | 37 | using namespace Opie::Net; | |
40 | // Qt | 38 | using namespace Opie::Ui; |
41 | 39 | ||
40 | /* QT */ | ||
42 | #include <qcheckbox.h> | 41 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
44 | #include <qdatetime.h> | 43 | #include <qdatetime.h> |
45 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
46 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
47 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
48 | #include <qobjectlist.h> | 47 | #include <qobjectlist.h> |
49 | #include <qregexp.h> | 48 | #include <qregexp.h> |
50 | #include <qspinbox.h> | 49 | #include <qspinbox.h> |
51 | #include <qtimer.h> | 50 | #include <qtimer.h> |
52 | #include <qtoolbutton.h> | 51 | #include <qtoolbutton.h> |
53 | #include <qmainwindow.h> | 52 | #include <qmainwindow.h> |
54 | 53 | ||
55 | // Standard | 54 | /* STD */ |
56 | |||
57 | #include <assert.h> | 55 | #include <assert.h> |
58 | #include <errno.h> | 56 | #include <errno.h> |
59 | #include <unistd.h> | 57 | #include <unistd.h> |
60 | #include <string.h> | 58 | #include <string.h> |
61 | #include <sys/types.h> | 59 | #include <sys/types.h> |
62 | #include <stdlib.h> | 60 | #include <stdlib.h> |
63 | 61 | ||
64 | using namespace Opie::Core; | ||
65 | using namespace Opie::Net; | ||
66 | using namespace Opie::Net; | ||
67 | using namespace Opie::Core; | ||
68 | using namespace Opie::Net; | ||
69 | using namespace Opie::Core; | ||
70 | Wellenreiter::Wellenreiter( QWidget* parent ) | 62 | Wellenreiter::Wellenreiter( QWidget* parent ) |
71 | : WellenreiterBase( parent, 0, 0 ), | 63 | : WellenreiterBase( parent, 0, 0 ), |
72 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 64 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
73 | { | 65 | { |
74 | 66 | ||
75 | logwindow->log( "(i) Wellenreiter has been started." ); | 67 | logwindow->log( "(i) Wellenreiter has been started." ); |
76 | 68 | ||
77 | // | 69 | // |
78 | // detect operating system | 70 | // detect operating system |
79 | // | 71 | // |
80 | 72 | ||
81 | #ifdef QWS | 73 | #ifdef QWS |
@@ -97,25 +89,25 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
97 | 89 | ||
98 | } | 90 | } |
99 | 91 | ||
100 | 92 | ||
101 | Wellenreiter::~Wellenreiter() | 93 | Wellenreiter::~Wellenreiter() |
102 | { | 94 | { |
103 | delete pcap; | 95 | delete pcap; |
104 | } | 96 | } |
105 | 97 | ||
106 | 98 | ||
107 | void Wellenreiter::initialTimer() | 99 | void Wellenreiter::initialTimer() |
108 | { | 100 | { |
109 | qDebug( "Wellenreiter::preloading manufacturer database..." ); | 101 | odebug << "Wellenreiter::preloading manufacturer database..." << oendl; |
110 | OManufacturerDB::instance(); | 102 | OManufacturerDB::instance(); |
111 | } | 103 | } |
112 | 104 | ||
113 | 105 | ||
114 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
115 | { | 107 | { |
116 | configwindow = cw; | 108 | configwindow = cw; |
117 | } | 109 | } |
118 | 110 | ||
119 | 111 | ||
120 | void Wellenreiter::channelHopped(int c) | 112 | void Wellenreiter::channelHopped(int c) |
121 | { | 113 | { |
@@ -140,104 +132,104 @@ void Wellenreiter::channelHopped(int c) | |||
140 | void Wellenreiter::handleNotification( OPacket* p ) | 132 | void Wellenreiter::handleNotification( OPacket* p ) |
141 | { | 133 | { |
142 | QObjectList* l = p->queryList(); | 134 | QObjectList* l = p->queryList(); |
143 | QObjectListIt it( *l ); | 135 | QObjectListIt it( *l ); |
144 | QObject* o; | 136 | QObject* o; |
145 | 137 | ||
146 | while ( (o = it.current()) != 0 ) | 138 | while ( (o = it.current()) != 0 ) |
147 | { | 139 | { |
148 | QString name = it.current()->name(); | 140 | QString name = it.current()->name(); |
149 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 141 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
150 | { | 142 | { |
151 | QString action = configwindow->parsePackets->protocolAction( name ); | 143 | QString action = configwindow->parsePackets->protocolAction( name ); |
152 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 144 | odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl; |
153 | doAction( action, name, p ); | 145 | doAction( action, name, p ); |
154 | } | 146 | } |
155 | else | 147 | else |
156 | { | 148 | { |
157 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 149 | odebug << "protocol '" << (const char*) name << "' not checked in parsePackets." << oendl; |
158 | } | 150 | } |
159 | ++it; | 151 | ++it; |
160 | } | 152 | } |
161 | } | 153 | } |
162 | 154 | ||
163 | 155 | ||
164 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) | 156 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) |
165 | { | 157 | { |
166 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); | 158 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); |
167 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); | 159 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); |
168 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); | 160 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); |
169 | else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); | 161 | else owarn << "Wellenreiter::handleManagementFrame(): '" << (const char*) manage->managementType() << "' - please handle me!" << oendl; |
170 | } | 162 | } |
171 | 163 | ||
172 | 164 | ||
173 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) | 165 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) |
174 | { | 166 | { |
175 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
176 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 168 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
177 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
178 | int channel = ds ? ds->channel() : -1; | 170 | int channel = ds ? ds->channel() : -1; |
179 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 171 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
180 | 172 | ||
181 | GpsLocation loc( -111, -111 ); | 173 | GpsLocation loc( -111, -111 ); |
182 | if ( configwindow->enableGPS->isChecked() ) | 174 | if ( configwindow->enableGPS->isChecked() ) |
183 | { | 175 | { |
184 | // TODO: add check if GPS is working!? | 176 | // TODO: add check if GPS is working!? |
185 | qDebug( "Wellenreiter::gathering GPS data..." ); | 177 | odebug << "Wellenreiter::gathering GPS data..." << oendl; |
186 | loc = gps->position(); | 178 | loc = gps->position(); |
187 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 179 | odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; |
188 | } | 180 | } |
189 | 181 | ||
190 | if ( essid.length() ) | 182 | if ( essid.length() ) |
191 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); | 183 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); |
192 | qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 184 | odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; |
193 | } | 185 | } |
194 | 186 | ||
195 | 187 | ||
196 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) | 188 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) |
197 | { | 189 | { |
198 | } | 190 | } |
199 | 191 | ||
200 | 192 | ||
201 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 193 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
202 | { | 194 | { |
203 | QString type; | 195 | QString type; |
204 | if ( beacon->canIBSS() ) | 196 | if ( beacon->canIBSS() ) |
205 | { | 197 | { |
206 | type = "adhoc"; | 198 | type = "adhoc"; |
207 | } | 199 | } |
208 | else if ( beacon->canESS() ) | 200 | else if ( beacon->canESS() ) |
209 | { | 201 | { |
210 | type = "managed"; | 202 | type = "managed"; |
211 | } | 203 | } |
212 | else | 204 | else |
213 | { | 205 | { |
214 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 206 | owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; |
215 | return; | 207 | return; |
216 | } | 208 | } |
217 | 209 | ||
218 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 210 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
219 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 211 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
220 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 212 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
221 | int channel = ds ? ds->channel() : -1; | 213 | int channel = ds ? ds->channel() : -1; |
222 | 214 | ||
223 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 215 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
224 | 216 | ||
225 | GpsLocation loc( -111, -111 ); | 217 | GpsLocation loc( -111, -111 ); |
226 | if ( configwindow->enableGPS->isChecked() ) | 218 | if ( configwindow->enableGPS->isChecked() ) |
227 | { | 219 | { |
228 | // TODO: add check if GPS is working!? | 220 | // TODO: add check if GPS is working!? |
229 | qDebug( "Wellenreiter::gathering GPS data..." ); | 221 | odebug << "Wellenreiter::gathering GPS data..." << oendl; |
230 | loc = gps->position(); | 222 | loc = gps->position(); |
231 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 223 | odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; |
232 | } | 224 | } |
233 | 225 | ||
234 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 226 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
235 | 227 | ||
236 | // update graph window | 228 | // update graph window |
237 | if ( ds ) | 229 | if ( ds ) |
238 | { | 230 | { |
239 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 231 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
240 | if ( prism ) | 232 | if ( prism ) |
241 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 233 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
242 | else | 234 | else |
243 | graphwindow->traffic( ds->channel(), 95 ); | 235 | graphwindow->traffic( ds->channel(), 95 ); |
@@ -246,25 +238,25 @@ void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPa | |||
246 | 238 | ||
247 | 239 | ||
248 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) | 240 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) |
249 | { | 241 | { |
250 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 242 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
251 | 243 | ||
252 | if ( control->controlType() == "Acknowledge" ) | 244 | if ( control->controlType() == "Acknowledge" ) |
253 | { | 245 | { |
254 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); | 246 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); |
255 | } | 247 | } |
256 | else | 248 | else |
257 | { | 249 | { |
258 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); | 250 | odebug << "Wellenreiter::handleControlFrame - please handle " << (const char*) control->controlType() << " in a future version! :D" << oendl; |
259 | } | 251 | } |
260 | } | 252 | } |
261 | 253 | ||
262 | 254 | ||
263 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 255 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
264 | { | 256 | { |
265 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 257 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
266 | if ( wlan->fromDS() && !wlan->toDS() ) | 258 | if ( wlan->fromDS() && !wlan->toDS() ) |
267 | { | 259 | { |
268 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 260 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
269 | from = wlan->macAddress3(); | 261 | from = wlan->macAddress3(); |
270 | to = wlan->macAddress2(); | 262 | to = wlan->macAddress2(); |
@@ -295,55 +287,55 @@ void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAd | |||
295 | from = data->sourceAddress(); | 287 | from = data->sourceAddress(); |
296 | to = data->destinationAddress(); | 288 | to = data->destinationAddress(); |
297 | 289 | ||
298 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); | 290 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); |
299 | } | 291 | } |
300 | 292 | ||
301 | 293 | ||
302 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) | 294 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) |
303 | { | 295 | { |
304 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 296 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
305 | if ( arp ) | 297 | if ( arp ) |
306 | { | 298 | { |
307 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 299 | odebug << "Received ARP traffic (type '" << (const char*) arp->type() << "'): " << oendl; |
308 | if ( arp->type() == "REQUEST" ) | 300 | if ( arp->type() == "REQUEST" ) |
309 | { | 301 | { |
310 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 302 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
311 | } | 303 | } |
312 | else if ( arp->type() == "REPLY" ) | 304 | else if ( arp->type() == "REPLY" ) |
313 | { | 305 | { |
314 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 306 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
315 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 307 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
316 | } | 308 | } |
317 | } | 309 | } |
318 | } | 310 | } |
319 | 311 | ||
320 | 312 | ||
321 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 313 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
322 | { | 314 | { |
323 | //TODO: Implement more IP based protocols | 315 | //TODO: Implement more IP based protocols |
324 | 316 | ||
325 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 317 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
326 | if ( dhcp ) | 318 | if ( dhcp ) |
327 | { | 319 | { |
328 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); | 320 | odebug << "Received DHCP '" << (const char*) dhcp->type() << "' packet" << oendl; |
329 | if ( dhcp->type() == "OFFER" ) | 321 | if ( dhcp->type() == "OFFER" ) |
330 | { | 322 | { |
331 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); | 323 | odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << (const char*) dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; |
332 | netView()->identify( source, dhcp->serverAddress().toString() ); | 324 | netView()->identify( source, dhcp->serverAddress().toString() ); |
333 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 325 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
334 | } | 326 | } |
335 | else if ( dhcp->type() == "ACK" ) | 327 | else if ( dhcp->type() == "ACK" ) |
336 | { | 328 | { |
337 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); | 329 | odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << (const char*) dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; |
338 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | 330 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); |
339 | } | 331 | } |
340 | } | 332 | } |
341 | } | 333 | } |
342 | 334 | ||
343 | 335 | ||
344 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 336 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
345 | { | 337 | { |
346 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 338 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
347 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 339 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
348 | return 0; | 340 | return 0; |
349 | 341 | ||
@@ -359,34 +351,34 @@ bool Wellenreiter::checkDumpPacket( OPacket* p ) | |||
359 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter | 351 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter |
360 | 352 | ||
361 | QObjectList* l = p->queryList(); | 353 | QObjectList* l = p->queryList(); |
362 | QObjectListIt it( *l ); | 354 | QObjectListIt it( *l ); |
363 | QObject* o; | 355 | QObject* o; |
364 | 356 | ||
365 | while ( (o = it.current()) != 0 ) | 357 | while ( (o = it.current()) != 0 ) |
366 | { | 358 | { |
367 | QString name = it.current()->name(); | 359 | QString name = it.current()->name(); |
368 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 360 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
369 | { | 361 | { |
370 | QString action = configwindow->capturePackets->protocolAction( name ); | 362 | QString action = configwindow->capturePackets->protocolAction( name ); |
371 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 363 | odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl; |
372 | if ( action == "Discard" ) | 364 | if ( action == "Discard" ) |
373 | { | 365 | { |
374 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 366 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
375 | return false; | 367 | return false; |
376 | } | 368 | } |
377 | } | 369 | } |
378 | else | 370 | else |
379 | { | 371 | { |
380 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 372 | odebug << "protocol '" << (const char*) name << "' not checked in capturePackets." << oendl; |
381 | } | 373 | } |
382 | ++it; | 374 | ++it; |
383 | } | 375 | } |
384 | return true; | 376 | return true; |
385 | } | 377 | } |
386 | 378 | ||
387 | 379 | ||
388 | void Wellenreiter::receivePacket( OPacket* p ) | 380 | void Wellenreiter::receivePacket( OPacket* p ) |
389 | { | 381 | { |
390 | hexWindow()->add( p ); | 382 | hexWindow()->add( p ); |
391 | 383 | ||
392 | if ( checkDumpPacket( p ) ) | 384 | if ( checkDumpPacket( p ) ) |
@@ -542,70 +534,70 @@ void Wellenreiter::startClicked() | |||
542 | } | 534 | } |
543 | } | 535 | } |
544 | // set monitor mode | 536 | // set monitor mode |
545 | bool usePrism = configwindow->usePrismHeader(); | 537 | bool usePrism = configwindow->usePrismHeader(); |
546 | 538 | ||
547 | switch ( cardtype ) | 539 | switch ( cardtype ) |
548 | { | 540 | { |
549 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 541 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
550 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 542 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
551 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 543 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
552 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 544 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
553 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 545 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
554 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 546 | case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << (const char*) interface << "'" << oendl; break; |
555 | default: assert( 0 ); // shouldn't reach this | 547 | default: assert( 0 ); // shouldn't reach this |
556 | } | 548 | } |
557 | 549 | ||
558 | // switch device into monitor mode | 550 | // switch device into monitor mode |
559 | if ( cardtype < DEVTYPE_FILE ) | 551 | if ( cardtype < DEVTYPE_FILE ) |
560 | { | 552 | { |
561 | if ( cardtype != DEVTYPE_MANUAL ) | 553 | if ( cardtype != DEVTYPE_MANUAL ) |
562 | iface->setMode( "monitor" ); | 554 | iface->setMode( "monitor" ); |
563 | if ( iface->mode() != "monitor" ) | 555 | if ( iface->mode() != "monitor" ) |
564 | { | 556 | { |
565 | if ( QMessageBox::warning( this, "Wellenreiter II", | 557 | if ( QMessageBox::warning( this, "Wellenreiter II", |
566 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 558 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
567 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 559 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
568 | return; | 560 | return; |
569 | } | 561 | } |
570 | } | 562 | } |
571 | 563 | ||
572 | // open GPS device | 564 | // open GPS device |
573 | if ( configwindow->enableGPS->isChecked() ) | 565 | if ( configwindow->enableGPS->isChecked() ) |
574 | { | 566 | { |
575 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 567 | odebug << "Wellenreiter:GPS enabled @ " << (const char*) configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; |
576 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 568 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
577 | } | 569 | } |
578 | 570 | ||
579 | // open pcap and start sniffing | 571 | // open pcap and start sniffing |
580 | 572 | ||
581 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? | 573 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? |
582 | { | 574 | { |
583 | dumpname = configwindow->captureFileName->text(); | 575 | dumpname = configwindow->captureFileName->text(); |
584 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 576 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
585 | dumpname.append( '-' ); | 577 | dumpname.append( '-' ); |
586 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 578 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
587 | dumpname.append( ".wellenreiter" ); | 579 | dumpname.append( ".wellenreiter" ); |
588 | } | 580 | } |
589 | else // write it anyway ;) | 581 | else // write it anyway ;) |
590 | { | 582 | { |
591 | dumpname = "/var/log/dump.wellenreiter"; | 583 | dumpname = "/var/log/dump.wellenreiter"; |
592 | } | 584 | } |
593 | 585 | ||
594 | if ( cardtype != DEVTYPE_FILE ) | 586 | if ( cardtype != DEVTYPE_FILE ) |
595 | pcap->open( interface ); | 587 | pcap->open( interface ); |
596 | else | 588 | else |
597 | pcap->open( QFile( interface ) ); | 589 | pcap->open( QFile( interface ) ); |
598 | 590 | ||
599 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); | 591 | odebug << "Wellenreiter:: dumping to " << (const char*) dumpname << "" << oendl; |
600 | pcap->openDumpFile( dumpname ); | 592 | pcap->openDumpFile( dumpname ); |
601 | 593 | ||
602 | if ( !pcap->isOpen() ) | 594 | if ( !pcap->isOpen() ) |
603 | { | 595 | { |
604 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( | 596 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
605 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); | 597 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
606 | return; | 598 | return; |
607 | } | 599 | } |
608 | 600 | ||
609 | // set capturer to non-blocking mode | 601 | // set capturer to non-blocking mode |
610 | pcap->setBlocking( false ); | 602 | pcap->setBlocking( false ); |
611 | 603 | ||
@@ -643,25 +635,25 @@ void Wellenreiter::startClicked() | |||
643 | emit( startedSniffing() ); | 635 | emit( startedSniffing() ); |
644 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 636 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
645 | else | 637 | else |
646 | { | 638 | { |
647 | assert( parent() ); | 639 | assert( parent() ); |
648 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 640 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
649 | } | 641 | } |
650 | } | 642 | } |
651 | 643 | ||
652 | 644 | ||
653 | void Wellenreiter::timerEvent( QTimerEvent* ) | 645 | void Wellenreiter::timerEvent( QTimerEvent* ) |
654 | { | 646 | { |
655 | qDebug( "Wellenreiter::timerEvent()" ); | 647 | odebug << "Wellenreiter::timerEvent()" << oendl; |
656 | OPacket* p = pcap->next(); | 648 | OPacket* p = pcap->next(); |
657 | if ( !p ) // no more packets available | 649 | if ( !p ) // no more packets available |
658 | { | 650 | { |
659 | stopClicked(); | 651 | stopClicked(); |
660 | } | 652 | } |
661 | else | 653 | else |
662 | { | 654 | { |
663 | receivePacket( p ); | 655 | receivePacket( p ); |
664 | // We no longer delete packets here. Ownership of the packets is | 656 | // We no longer delete packets here. Ownership of the packets is |
665 | // transferred to the PacketView. | 657 | // transferred to the PacketView. |
666 | //delete p; | 658 | //delete p; |
667 | } | 659 | } |
@@ -706,28 +698,28 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch | |||
706 | return; | 698 | return; |
707 | } | 699 | } |
708 | 700 | ||
709 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 701 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
710 | (const char*) iface->name(), | 702 | (const char*) iface->name(), |
711 | (const char*) type, | 703 | (const char*) type, |
712 | (const char*) essid, | 704 | (const char*) essid, |
713 | channel, | 705 | channel, |
714 | (const char*) macaddr ); | 706 | (const char*) macaddr ); |
715 | 707 | ||
716 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 708 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
717 | int count = 3; | 709 | int count = 3; |
718 | qDebug("sending %d messages",count); | 710 | odebug << "sending " << count << " messages" << oendl; |
719 | msg << QString("count") << QString::number(count); | 711 | msg << QString("count") << QString::number(count); |
720 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | 712 | odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; |
721 | msg << QString(iface->name()) << QString("Mode") << type; | 713 | msg << QString(iface->name()) << QString("Mode") << type; |
722 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | 714 | odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; |
723 | msg << QString(iface->name()) << QString("ESSID") << essid; | 715 | msg << QString(iface->name()) << QString("ESSID") << essid; |
724 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | 716 | odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; |
725 | msg << QString(iface->name()) << QString("Channel") << channel; | 717 | msg << QString(iface->name()) << QString("Channel") << channel; |
726 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); | 718 | // odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; |
727 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 719 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
728 | #else | 720 | #else |
729 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | 721 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); |
730 | #endif | 722 | #endif |
731 | 723 | ||
732 | } | 724 | } |
733 | 725 | ||