-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 5dc2e79..14f251a 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -318,64 +318,73 @@ void Wellenreiter::stopClicked() | |||
318 | { | 318 | { |
319 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 319 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
320 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 320 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
321 | iface->setChannelHopping(); // stop hopping channels | 321 | iface->setChannelHopping(); // stop hopping channels |
322 | } | 322 | } |
323 | else | 323 | else |
324 | killTimers(); | 324 | killTimers(); |
325 | 325 | ||
326 | pcap->close(); | 326 | pcap->close(); |
327 | sniffing = false; | 327 | sniffing = false; |
328 | 328 | ||
329 | if ( iface ) | 329 | if ( iface ) |
330 | { | 330 | { |
331 | // switch off monitor mode | 331 | // switch off monitor mode |
332 | iface->setMonitorMode( false ); | 332 | iface->setMonitorMode( false ); |
333 | // switch off promisc flag | 333 | // switch off promisc flag |
334 | iface->setPromiscuousMode( false ); | 334 | iface->setPromiscuousMode( false ); |
335 | 335 | ||
336 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 336 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
337 | } | 337 | } |
338 | 338 | ||
339 | logwindow->log( "(i) Stopped Scanning." ); | 339 | logwindow->log( "(i) Stopped Scanning." ); |
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 | ||
351 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | ||
352 | { | ||
353 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | ||
354 | } | ||
355 | #else | ||
356 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | ||
357 | #endif | ||
358 | |||
350 | // print out statistics | 359 | // print out statistics |
351 | 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 ) |
352 | statwindow->updateCounter( it.key(), it.data() ); | 361 | statwindow->updateCounter( it.key(), it.data() ); |
353 | } | 362 | } |
354 | 363 | ||
355 | 364 | ||
356 | void Wellenreiter::startClicked() | 365 | void Wellenreiter::startClicked() |
357 | { | 366 | { |
358 | // get configuration from config window | 367 | // get configuration from config window |
359 | 368 | ||
360 | const QString& interface = configwindow->interfaceName->currentText(); | 369 | const QString& interface = configwindow->interfaceName->currentText(); |
361 | const int cardtype = configwindow->driverType(); | 370 | const int cardtype = configwindow->driverType(); |
362 | const int interval = configwindow->hoppingInterval(); | 371 | const int interval = configwindow->hoppingInterval(); |
363 | 372 | ||
364 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 373 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
365 | { | 374 | { |
366 | QMessageBox::information( this, "Wellenreiter II", | 375 | QMessageBox::information( this, "Wellenreiter II", |
367 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 376 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
368 | return; | 377 | return; |
369 | } | 378 | } |
370 | 379 | ||
371 | // configure device | 380 | // configure device |
372 | ONetwork* net = ONetwork::instance(); | 381 | ONetwork* net = ONetwork::instance(); |
373 | 382 | ||
374 | // 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 |
375 | 384 | ||
376 | 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! |
377 | 386 | ||
378 | // bring device UP | 387 | // bring device UP |
379 | iface->setUp( true ); | 388 | iface->setUp( true ); |
380 | if ( !iface->isUp() ) | 389 | if ( !iface->isUp() ) |
381 | { | 390 | { |
@@ -445,64 +454,74 @@ void Wellenreiter::startClicked() | |||
445 | 454 | ||
446 | if ( !pcap->isOpen() ) | 455 | if ( !pcap->isOpen() ) |
447 | { | 456 | { |
448 | QMessageBox::warning( this, "Wellenreiter II", | 457 | QMessageBox::warning( this, "Wellenreiter II", |
449 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); | 458 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); |
450 | return; | 459 | return; |
451 | } | 460 | } |
452 | 461 | ||
453 | // set capturer to non-blocking mode | 462 | // set capturer to non-blocking mode |
454 | pcap->setBlocking( false ); | 463 | pcap->setBlocking( false ); |
455 | 464 | ||
456 | // start channel hopper | 465 | // start channel hopper |
457 | if ( cardtype != DEVTYPE_FILE ) | 466 | if ( cardtype != DEVTYPE_FILE ) |
458 | { | 467 | { |
459 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); | 468 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); |
460 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window | 469 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window |
461 | } | 470 | } |
462 | 471 | ||
463 | if ( cardtype != DEVTYPE_FILE ) | 472 | if ( cardtype != DEVTYPE_FILE ) |
464 | { | 473 | { |
465 | // connect socket notifier and start channel hopper | 474 | // connect socket notifier and start channel hopper |
466 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 475 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
467 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 476 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
468 | } | 477 | } |
469 | else | 478 | else |
470 | { | 479 | { |
471 | // start timer for reading packets | 480 | // start timer for reading packets |
472 | startTimer( 100 ); | 481 | startTimer( 100 ); |
473 | } | 482 | } |
474 | 483 | ||
475 | logwindow->log( "(i) Started Scanning." ); | 484 | logwindow->log( "(i) Started Scanning." ); |
476 | sniffing = true; | 485 | sniffing = true; |
486 | |||
487 | #ifdef QWS | ||
488 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | ||
489 | { | ||
490 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | ||
491 | } | ||
492 | #else | ||
493 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | ||
494 | #endif | ||
495 | |||
477 | emit( startedSniffing() ); | 496 | emit( startedSniffing() ); |
478 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 497 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
479 | else | 498 | else |
480 | { | 499 | { |
481 | assert( parent() ); | 500 | assert( parent() ); |
482 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 501 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
483 | } | 502 | } |
484 | } | 503 | } |
485 | 504 | ||
486 | 505 | ||
487 | void Wellenreiter::timerEvent( QTimerEvent* ) | 506 | void Wellenreiter::timerEvent( QTimerEvent* ) |
488 | { | 507 | { |
489 | qDebug( "Wellenreiter::timerEvent()" ); | 508 | qDebug( "Wellenreiter::timerEvent()" ); |
490 | OPacket* p = pcap->next(); | 509 | OPacket* p = pcap->next(); |
491 | if ( !p ) // no more packets available | 510 | if ( !p ) // no more packets available |
492 | { | 511 | { |
493 | stopClicked(); | 512 | stopClicked(); |
494 | } | 513 | } |
495 | else | 514 | else |
496 | { | 515 | { |
497 | receivePacket( p ); | 516 | receivePacket( p ); |
498 | delete p; | 517 | delete p; |
499 | } | 518 | } |
500 | } | 519 | } |
501 | 520 | ||
502 | 521 | ||
503 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 522 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
504 | { | 523 | { |
505 | #ifdef QWS | 524 | #ifdef QWS |
506 | if ( action == "TouchSound" ) | 525 | if ( action == "TouchSound" ) |
507 | ODevice::inst()->touchSound(); | 526 | ODevice::inst()->touchSound(); |
508 | else if ( action == "AlarmSound" ) | 527 | else if ( action == "AlarmSound" ) |