summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-28 13:39:39 (UTC)
committer mickeyl <mickeyl>2004-03-28 13:39:39 (UTC)
commitca32f9c2a799aec751efd82e73c3154de1afe957 (patch) (unidiff)
tree4577ffe310acac81451235a4b11f0bf2ec86c3bc
parent0821e9018b0a3b1ea11ff5a4454db2e047d94d88 (diff)
downloadopie-ca32f9c2a799aec751efd82e73c3154de1afe957.zip
opie-ca32f9c2a799aec751efd82e73c3154de1afe957.tar.gz
opie-ca32f9c2a799aec751efd82e73c3154de1afe957.tar.bz2
fix stupid bug that broke replaying capture files
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index e8d9de7..c8d77a7 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -329,401 +329,402 @@ void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source,
329 { 329 {
330 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 330 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
331 netView()->identify( source, dhcp->serverAddress().toString() ); 331 netView()->identify( source, dhcp->serverAddress().toString() );
332 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 332 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
333 } 333 }
334 else if ( dhcp->type() == "ACK" ) 334 else if ( dhcp->type() == "ACK" )
335 { 335 {
336 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 336 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
337 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 337 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
338 } 338 }
339 } 339 }
340} 340}
341 341
342 342
343QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 343QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
344{ 344{
345 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 345 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
346 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 346 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
347 return 0; 347 return 0;
348 348
349 return p->child( protocol ); 349 return p->child( protocol );
350} 350}
351 351
352 352
353bool Wellenreiter::checkDumpPacket( OPacket* p ) 353bool Wellenreiter::checkDumpPacket( OPacket* p )
354{ 354{
355 // go through all child packets and see if one is inside the child hierarchy for p 355 // go through all child packets and see if one is inside the child hierarchy for p
356 // if so, do what the user requested (protocolAction), e.g. pass or discard 356 // if so, do what the user requested (protocolAction), e.g. pass or discard
357 if ( !configwindow->writeCaptureFile->isChecked() ) 357 if ( !configwindow->writeCaptureFile->isChecked() )
358 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 358 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
359 359
360 QObjectList* l = p->queryList(); 360 QObjectList* l = p->queryList();
361 QObjectListIt it( *l ); 361 QObjectListIt it( *l );
362 QObject* o; 362 QObject* o;
363 363
364 while ( (o = it.current()) != 0 ) 364 while ( (o = it.current()) != 0 )
365 { 365 {
366 QString name = it.current()->name(); 366 QString name = it.current()->name();
367 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 367 if ( configwindow->capturePackets->isProtocolChecked( name ) )
368 { 368 {
369 QString action = configwindow->capturePackets->protocolAction( name ); 369 QString action = configwindow->capturePackets->protocolAction( name );
370 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 370 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
371 if ( action == "Discard" ) 371 if ( action == "Discard" )
372 { 372 {
373 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 373 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
374 return false; 374 return false;
375 } 375 }
376 } 376 }
377 else 377 else
378 { 378 {
379 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 379 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
380 } 380 }
381 ++it; 381 ++it;
382 } 382 }
383 return true; 383 return true;
384} 384}
385 385
386 386
387void Wellenreiter::receivePacket( OPacket* p ) 387void Wellenreiter::receivePacket( OPacket* p )
388{ 388{
389 hexWindow()->add( p ); 389 hexWindow()->add( p );
390 390
391 if ( checkDumpPacket( p ) ) 391 if ( checkDumpPacket( p ) )
392 { 392 {
393 pcap->dump( p ); 393 pcap->dump( p );
394 } 394 }
395 395
396 // check for a management frame 396 // check for a management frame
397 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 397 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
398 if ( manage ) 398 if ( manage )
399 { 399 {
400 handleManagementFrame( p, manage ); 400 handleManagementFrame( p, manage );
401 return; 401 return;
402 } 402 }
403 403
404 // check for a control frame 404 // check for a control frame
405 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 405 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
406 if ( control ) 406 if ( control )
407 { 407 {
408 handleControlFrame( p, control ); 408 handleControlFrame( p, control );
409 return; 409 return;
410 } 410 }
411 411
412 OMacAddress source; 412 OMacAddress source;
413 OMacAddress dest; 413 OMacAddress dest;
414 414
415 //TODO: WEP check here 415 //TODO: WEP check here
416 416
417 // check for a wireless data frame 417 // check for a wireless data frame
418 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 418 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
419 if ( wlan ) 419 if ( wlan )
420 { 420 {
421 handleWlanData( p, wlan, source, dest ); 421 handleWlanData( p, wlan, source, dest );
422 } 422 }
423 423
424 // check for a wired data frame 424 // check for a wired data frame
425 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 425 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
426 if ( eth ) 426 if ( eth )
427 { 427 {
428 handleEthernetData( p, eth, source, dest ); 428 handleEthernetData( p, eth, source, dest );
429 } 429 }
430 430
431 // check for an arp frame since arp frames come in two flavours: 431 // check for an arp frame since arp frames come in two flavours:
432 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 432 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
433 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 433 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
434 if ( arp ) 434 if ( arp )
435 { 435 {
436 handleARPData( p, arp, source, dest ); 436 handleARPData( p, arp, source, dest );
437 } 437 }
438 438
439 // check for a ip frame 439 // check for a ip frame
440 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 440 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
441 if ( ip ) 441 if ( ip )
442 { 442 {
443 handleIPData( p, ip, source, dest ); 443 handleIPData( p, ip, source, dest );
444 } 444 }
445 445
446 //handleNotification( p ); 446 //handleNotification( p );
447 447
448} 448}
449 449
450 450
451void Wellenreiter::stopClicked() 451void Wellenreiter::stopClicked()
452{ 452{
453 if ( iface ) 453 if ( iface )
454 { 454 {
455 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 455 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
456 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 456 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
457 iface->setChannelHopping(); // stop hopping channels 457 iface->setChannelHopping(); // stop hopping channels
458 } 458 }
459 else 459 else
460 killTimers(); 460 killTimers();
461 461
462 pcap->close(); 462 pcap->close();
463 sniffing = false; 463 sniffing = false;
464 464
465 if ( iface ) 465 if ( iface )
466 { 466 {
467 // switch off monitor mode 467 // switch off monitor mode
468 iface->setMode( "managed" ); 468 iface->setMode( "managed" );
469 // switch off promisc flag 469 // switch off promisc flag
470 iface->setPromiscuousMode( false ); 470 iface->setPromiscuousMode( false );
471 471
472 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 472 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
473 } 473 }
474 474
475 logwindow->log( "(i) Stopped Scanning." ); 475 logwindow->log( "(i) Stopped Scanning." );
476 assert( parent() ); 476 assert( parent() );
477 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 477 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
478 478
479 // message the user 479 // message the user
480 QMessageBox::information( this, "Wellenreiter II", 480 QMessageBox::information( this, "Wellenreiter II",
481 tr( "Your wireless card\nshould now be usable again." ) ); 481 tr( "Your wireless card\nshould now be usable again." ) );
482 482
483 sniffing = false; 483 sniffing = false;
484 emit( stoppedSniffing() ); 484 emit( stoppedSniffing() );
485 485
486 #ifdef QWS 486 #ifdef QWS
487 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 487 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
488 { 488 {
489 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 489 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
490 } 490 }
491 #else 491 #else
492 #warning FIXME: setScreenSaverMode is not operational on the X11 build 492 #warning FIXME: setScreenSaverMode is not operational on the X11 build
493 #endif 493 #endif
494 494
495 // print out statistics 495 // print out statistics
496 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 496 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
497 statwindow->updateCounter( it.key(), it.data() ); 497 statwindow->updateCounter( it.key(), it.data() );
498} 498}
499 499
500 500
501void Wellenreiter::startClicked() 501void Wellenreiter::startClicked()
502{ 502{
503 // get configuration from config window 503 // get configuration from config window
504 504
505 const QString& interface = configwindow->interfaceName->currentText(); 505 const QString& interface = configwindow->interfaceName->currentText();
506 const int cardtype = configwindow->driverType(); 506 const int cardtype = configwindow->driverType();
507 const int interval = configwindow->hoppingInterval(); 507 const int interval = configwindow->hoppingInterval();
508 508
509 if ( ( interface == "" ) || ( cardtype == 0 ) ) 509 if ( ( interface == "" ) || ( cardtype == 0 ) )
510 { 510 {
511 QMessageBox::information( this, "Wellenreiter II", 511 QMessageBox::information( this, "Wellenreiter II",
512 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 512 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
513 return; 513 return;
514 } 514 }
515 515
516 // configure device 516 // configure device
517 ONetwork* net = ONetwork::instance(); 517 ONetwork* net = ONetwork::instance();
518 518
519 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 519 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
520 520
521 if ( !net->isPresent( interface ) )
522 {
523 QMessageBox::information( this, "Wellenreiter II",
524 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
525 return;
526 }
527
528 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
529 assert( iface );
530
531 // bring device UP
532 if ( cardtype != DEVTYPE_FILE ) 521 if ( cardtype != DEVTYPE_FILE )
533 { 522 {
523
524 if ( !net->isPresent( interface ) )
525 {
526 QMessageBox::information( this, "Wellenreiter II",
527 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
528 return;
529 }
530
531 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
532 assert( iface );
533
534 // bring device UP
534 iface->setUp( true ); 535 iface->setUp( true );
535 if ( !iface->isUp() ) 536 if ( !iface->isUp() )
536 { 537 {
537 QMessageBox::warning( this, "Wellenreiter II", 538 QMessageBox::warning( this, "Wellenreiter II",
538 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 539 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
539 return; 540 return;
540 } 541 }
541 } 542 }
542 // set monitor mode 543 // set monitor mode
543 bool usePrism = configwindow->usePrismHeader(); 544 bool usePrism = configwindow->usePrismHeader();
544 545
545 switch ( cardtype ) 546 switch ( cardtype )
546 { 547 {
547 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 548 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
548 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 549 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
549 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 550 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
550 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 551 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
551 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 552 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
552 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 553 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
553 default: assert( 0 ); // shouldn't reach this 554 default: assert( 0 ); // shouldn't reach this
554 } 555 }
555 556
556 // switch device into monitor mode 557 // switch device into monitor mode
557 if ( cardtype < DEVTYPE_FILE ) 558 if ( cardtype < DEVTYPE_FILE )
558 { 559 {
559 if ( cardtype != DEVTYPE_MANUAL ) 560 if ( cardtype != DEVTYPE_MANUAL )
560 iface->setMode( "monitor" ); 561 iface->setMode( "monitor" );
561 if ( iface->mode() != "monitor" ) 562 if ( iface->mode() != "monitor" )
562 { 563 {
563 if ( QMessageBox::warning( this, "Wellenreiter II", 564 if ( QMessageBox::warning( this, "Wellenreiter II",
564 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 565 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
565 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 566 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
566 return; 567 return;
567 } 568 }
568 } 569 }
569 570
570 // open GPS device 571 // open GPS device
571 if ( configwindow->enableGPS->isChecked() ) 572 if ( configwindow->enableGPS->isChecked() )
572 { 573 {
573 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 574 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
574 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 575 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
575 } 576 }
576 577
577 // open pcap and start sniffing 578 // open pcap and start sniffing
578 579
579 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 580 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
580 { 581 {
581 dumpname = configwindow->captureFileName->text(); 582 dumpname = configwindow->captureFileName->text();
582 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 583 if ( dumpname.isEmpty() ) dumpname = "captureFile";
583 dumpname.append( '-' ); 584 dumpname.append( '-' );
584 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 585 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
585 dumpname.append( ".wellenreiter" ); 586 dumpname.append( ".wellenreiter" );
586 } 587 }
587 else // write it anyway ;) 588 else // write it anyway ;)
588 { 589 {
589 dumpname = "/var/log/dump.wellenreiter"; 590 dumpname = "/var/log/dump.wellenreiter";
590 } 591 }
591 592
592 if ( cardtype != DEVTYPE_FILE ) 593 if ( cardtype != DEVTYPE_FILE )
593 pcap->open( interface ); 594 pcap->open( interface );
594 else 595 else
595 pcap->open( QFile( interface ) ); 596 pcap->open( QFile( interface ) );
596 597
597 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); 598 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
598 pcap->openDumpFile( dumpname ); 599 pcap->openDumpFile( dumpname );
599 600
600 if ( !pcap->isOpen() ) 601 if ( !pcap->isOpen() )
601 { 602 {
602 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 603 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
603 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 604 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
604 return; 605 return;
605 } 606 }
606 607
607 // set capturer to non-blocking mode 608 // set capturer to non-blocking mode
608 pcap->setBlocking( false ); 609 pcap->setBlocking( false );
609 610
610 // start channel hopper 611 // start channel hopper
611 if ( cardtype != DEVTYPE_FILE ) 612 if ( cardtype != DEVTYPE_FILE )
612 { 613 {
613 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 614 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
614 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 615 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
615 } 616 }
616 617
617 if ( cardtype != DEVTYPE_FILE ) 618 if ( cardtype != DEVTYPE_FILE )
618 { 619 {
619 // connect socket notifier and start channel hopper 620 // connect socket notifier and start channel hopper
620 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 621 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
621 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 622 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
622 } 623 }
623 else 624 else
624 { 625 {
625 // start timer for reading packets 626 // start timer for reading packets
626 startTimer( 100 ); 627 startTimer( 100 );
627 } 628 }
628 629
629 logwindow->log( "(i) Started Scanning." ); 630 logwindow->log( "(i) Started Scanning." );
630 sniffing = true; 631 sniffing = true;
631 632
632 #ifdef QWS 633 #ifdef QWS
633 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 634 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
634 { 635 {
635 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 636 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
636 } 637 }
637 #else 638 #else
638 #warning FIXME: setScreenSaverMode is not operational on the X11 build 639 #warning FIXME: setScreenSaverMode is not operational on the X11 build
639 #endif 640 #endif
640 641
641 emit( startedSniffing() ); 642 emit( startedSniffing() );
642 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 643 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
643 else 644 else
644 { 645 {
645 assert( parent() ); 646 assert( parent() );
646 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 647 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
647 } 648 }
648} 649}
649 650
650 651
651void Wellenreiter::timerEvent( QTimerEvent* ) 652void Wellenreiter::timerEvent( QTimerEvent* )
652{ 653{
653 qDebug( "Wellenreiter::timerEvent()" ); 654 qDebug( "Wellenreiter::timerEvent()" );
654 OPacket* p = pcap->next(); 655 OPacket* p = pcap->next();
655 if ( !p ) // no more packets available 656 if ( !p ) // no more packets available
656 { 657 {
657 stopClicked(); 658 stopClicked();
658 } 659 }
659 else 660 else
660 { 661 {
661 receivePacket( p ); 662 receivePacket( p );
662 delete p; 663 delete p;
663 } 664 }
664} 665}
665 666
666 667
667void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 668void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
668{ 669{
669 #ifdef QWS 670 #ifdef QWS
670 if ( action == "TouchSound" ) 671 if ( action == "TouchSound" )
671 ODevice::inst()->playTouchSound(); 672 ODevice::inst()->playTouchSound();
672 else if ( action == "AlarmSound" ) 673 else if ( action == "AlarmSound" )
673 ODevice::inst()->playAlarmSound(); 674 ODevice::inst()->playAlarmSound();
674 else if ( action == "KeySound" ) 675 else if ( action == "KeySound" )
675 ODevice::inst()->playKeySound(); 676 ODevice::inst()->playKeySound();
676 else if ( action == "LedOn" ) 677 else if ( action == "LedOn" )
677 ODevice::inst()->setLedState( Led_Mail, Led_On ); 678 ODevice::inst()->setLedState( Led_Mail, Led_On );
678 else if ( action == "LedOff" ) 679 else if ( action == "LedOff" )
679 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 680 ODevice::inst()->setLedState( Led_Mail, Led_Off );
680 else if ( action == "LogMessage" ) 681 else if ( action == "LogMessage" )
681 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 682 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
682 else if ( action == "MessageBox" ) 683 else if ( action == "MessageBox" )
683 QMessageBox::information( this, "Notification!", 684 QMessageBox::information( this, "Notification!",
684 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 685 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
685 #else 686 #else
686 #warning Actions do not work with Qt/X11 yet 687 #warning Actions do not work with Qt/X11 yet
687 #endif 688 #endif
688} 689}
689 690
690void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 691void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
691{ 692{
692 #ifdef QWS 693 #ifdef QWS
693 if ( !iface ) 694 if ( !iface )
694 { 695 {
695 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 696 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
696 return; 697 return;
697 } 698 }
698 699
699 if ( sniffing ) 700 if ( sniffing )
700 { 701 {
701 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 702 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
702 return; 703 return;
703 } 704 }
704 705
705 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 706 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
706 (const char*) iface->name(), 707 (const char*) iface->name(),
707 (const char*) type, 708 (const char*) type,
708 (const char*) essid, 709 (const char*) essid,
709 channel, 710 channel,
710 (const char*) macaddr ); 711 (const char*) macaddr );
711 712
712 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 713 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
713 int count = 3; 714 int count = 3;
714 qDebug("sending %d messages",count); 715 qDebug("sending %d messages",count);
715 msg << QString("count") << QString::number(count); 716 msg << QString("count") << QString::number(count);
716 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 717 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
717 msg << QString(iface->name()) << QString("Mode") << type; 718 msg << QString(iface->name()) << QString("Mode") << type;
718 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 719 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
719 msg << QString(iface->name()) << QString("ESSID") << essid; 720 msg << QString(iface->name()) << QString("ESSID") << essid;
720 qDebug("msg >%s< channel >%d<", iface->name(),channel); 721 qDebug("msg >%s< channel >%d<", iface->name(),channel);
721 msg << QString(iface->name()) << QString("Channel") << channel; 722 msg << QString(iface->name()) << QString("Channel") << channel;
722// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 723// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
723// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 724// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
724 #else 725 #else
725 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 726 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
726 #endif 727 #endif
727 728
728} 729}
729 730