-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 14f251a..405eda8 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -340,167 +340,169 @@ void Wellenreiter::stopClicked() | |||
340 | assert( parent() ); | 340 | assert( parent() ); |
341 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 341 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
342 | 342 | ||
343 | // message the user | 343 | // message the user |
344 | QMessageBox::information( this, "Wellenreiter II", | 344 | QMessageBox::information( this, "Wellenreiter II", |
345 | tr( "Your wireless card\nshould now be usable again." ) ); | 345 | tr( "Your wireless card\nshould now be usable again." ) ); |
346 | 346 | ||
347 | sniffing = false; | 347 | sniffing = false; |
348 | emit( stoppedSniffing() ); | 348 | emit( stoppedSniffing() ); |
349 | 349 | ||
350 | #ifdef QWS | 350 | #ifdef QWS |
351 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 351 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
352 | { | 352 | { |
353 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 353 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
354 | } | 354 | } |
355 | #else | 355 | #else |
356 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 356 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
357 | #endif | 357 | #endif |
358 | 358 | ||
359 | // print out statistics | 359 | // print out statistics |
360 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 360 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
361 | statwindow->updateCounter( it.key(), it.data() ); | 361 | statwindow->updateCounter( it.key(), it.data() ); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void Wellenreiter::startClicked() | 365 | void Wellenreiter::startClicked() |
366 | { | 366 | { |
367 | // get configuration from config window | 367 | // get configuration from config window |
368 | 368 | ||
369 | const QString& interface = configwindow->interfaceName->currentText(); | 369 | const QString& interface = configwindow->interfaceName->currentText(); |
370 | const int cardtype = configwindow->driverType(); | 370 | const int cardtype = configwindow->driverType(); |
371 | const int interval = configwindow->hoppingInterval(); | 371 | const int interval = configwindow->hoppingInterval(); |
372 | 372 | ||
373 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 373 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
374 | { | 374 | { |
375 | QMessageBox::information( this, "Wellenreiter II", | 375 | QMessageBox::information( this, "Wellenreiter II", |
376 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 376 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
377 | return; | 377 | return; |
378 | } | 378 | } |
379 | 379 | ||
380 | // configure device | 380 | // configure device |
381 | ONetwork* net = ONetwork::instance(); | 381 | ONetwork* net = ONetwork::instance(); |
382 | 382 | ||
383 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 383 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
384 | 384 | ||
385 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 385 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
386 | 386 | ||
387 | // bring device UP | 387 | // bring device UP |
388 | iface->setUp( true ); | 388 | if ( cardtype != DEVTYPE_FILE ) |
389 | if ( !iface->isUp() ) | ||
390 | { | 389 | { |
391 | QMessageBox::warning( this, "Wellenreiter II", | 390 | iface->setUp( true ); |
392 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 391 | if ( !iface->isUp() ) |
393 | return; | 392 | { |
393 | QMessageBox::warning( this, "Wellenreiter II", | ||
394 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | ||
395 | return; | ||
396 | } | ||
394 | } | 397 | } |
395 | |||
396 | // set monitor mode | 398 | // set monitor mode |
397 | bool usePrism = configwindow->usePrismHeader(); | 399 | bool usePrism = configwindow->usePrismHeader(); |
398 | 400 | ||
399 | switch ( cardtype ) | 401 | switch ( cardtype ) |
400 | { | 402 | { |
401 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 403 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
402 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 404 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
403 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 405 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
404 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 406 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
405 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 407 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
406 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 408 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
407 | default: assert( 0 ); // shouldn't reach this | 409 | default: assert( 0 ); // shouldn't reach this |
408 | } | 410 | } |
409 | 411 | ||
410 | // switch device into monitor mode | 412 | // switch device into monitor mode |
411 | if ( cardtype < DEVTYPE_FILE ) | 413 | if ( cardtype < DEVTYPE_FILE ) |
412 | { | 414 | { |
413 | if ( cardtype != DEVTYPE_MANUAL ) | 415 | if ( cardtype != DEVTYPE_MANUAL ) |
414 | iface->setMonitorMode( true ); | 416 | iface->setMonitorMode( true ); |
415 | if ( !iface->monitorMode() ) | 417 | if ( !iface->monitorMode() ) |
416 | { | 418 | { |
417 | if ( QMessageBox::warning( this, "Wellenreiter II", | 419 | if ( QMessageBox::warning( this, "Wellenreiter II", |
418 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 420 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
419 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 421 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
420 | return; | 422 | return; |
421 | } | 423 | } |
422 | } | 424 | } |
423 | 425 | ||
424 | // open GPS device | 426 | // open GPS device |
425 | if ( configwindow->enableGPS->isChecked() ) | 427 | if ( configwindow->enableGPS->isChecked() ) |
426 | { | 428 | { |
427 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 429 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
428 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 430 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
429 | } | 431 | } |
430 | 432 | ||
431 | // open pcap and start sniffing | 433 | // open pcap and start sniffing |
432 | if ( cardtype != DEVTYPE_FILE ) | 434 | if ( cardtype != DEVTYPE_FILE ) |
433 | { | 435 | { |
434 | pcap->open( interface ); | 436 | pcap->open( interface ); |
435 | 437 | ||
436 | if ( configwindow->writeCaptureFile->isChecked() ) | 438 | if ( configwindow->writeCaptureFile->isChecked() ) |
437 | { | 439 | { |
438 | QString dumpname( configwindow->captureFileName->text() ); | 440 | QString dumpname( configwindow->captureFileName->text() ); |
439 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 441 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
440 | dumpname.append( '-' ); | 442 | dumpname.append( '-' ); |
441 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 443 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
442 | dumpname.append( ".wellenreiter" ); | 444 | dumpname.append( ".wellenreiter" ); |
443 | pcap->openDumpFile( dumpname ); | 445 | pcap->openDumpFile( dumpname ); |
444 | } | 446 | } |
445 | else | 447 | else |
446 | { | 448 | { |
447 | pcap->open( interface ); | 449 | pcap->open( interface ); |
448 | } | 450 | } |
449 | } | 451 | } |
450 | else | 452 | else |
451 | { | 453 | { |
452 | pcap->open( QFile( interface ) ); | 454 | pcap->open( QFile( interface ) ); |
453 | } | 455 | } |
454 | 456 | ||
455 | if ( !pcap->isOpen() ) | 457 | if ( !pcap->isOpen() ) |
456 | { | 458 | { |
457 | QMessageBox::warning( this, "Wellenreiter II", | 459 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
458 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); | 460 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
459 | return; | 461 | return; |
460 | } | 462 | } |
461 | 463 | ||
462 | // set capturer to non-blocking mode | 464 | // set capturer to non-blocking mode |
463 | pcap->setBlocking( false ); | 465 | pcap->setBlocking( false ); |
464 | 466 | ||
465 | // start channel hopper | 467 | // start channel hopper |
466 | if ( cardtype != DEVTYPE_FILE ) | 468 | if ( cardtype != DEVTYPE_FILE ) |
467 | { | 469 | { |
468 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); | 470 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); |
469 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window | 471 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window |
470 | } | 472 | } |
471 | 473 | ||
472 | if ( cardtype != DEVTYPE_FILE ) | 474 | if ( cardtype != DEVTYPE_FILE ) |
473 | { | 475 | { |
474 | // connect socket notifier and start channel hopper | 476 | // connect socket notifier and start channel hopper |
475 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 477 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
476 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 478 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
477 | } | 479 | } |
478 | else | 480 | else |
479 | { | 481 | { |
480 | // start timer for reading packets | 482 | // start timer for reading packets |
481 | startTimer( 100 ); | 483 | startTimer( 100 ); |
482 | } | 484 | } |
483 | 485 | ||
484 | logwindow->log( "(i) Started Scanning." ); | 486 | logwindow->log( "(i) Started Scanning." ); |
485 | sniffing = true; | 487 | sniffing = true; |
486 | 488 | ||
487 | #ifdef QWS | 489 | #ifdef QWS |
488 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 490 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
489 | { | 491 | { |
490 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | 492 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; |
491 | } | 493 | } |
492 | #else | 494 | #else |
493 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 495 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
494 | #endif | 496 | #endif |
495 | 497 | ||
496 | emit( startedSniffing() ); | 498 | emit( startedSniffing() ); |
497 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 499 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
498 | else | 500 | else |
499 | { | 501 | { |
500 | assert( parent() ); | 502 | assert( parent() ); |
501 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 503 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
502 | } | 504 | } |
503 | } | 505 | } |
504 | 506 | ||
505 | 507 | ||
506 | void Wellenreiter::timerEvent( QTimerEvent* ) | 508 | void Wellenreiter::timerEvent( QTimerEvent* ) |