Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/Opietooth.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index b14cc2f..8323549 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp | |||
@@ -348,777 +348,777 @@ void OTPairing::SLOT_Unpair( ) { | |||
348 | // find selected pair | 348 | // find selected pair |
349 | 349 | ||
350 | QListViewItem * it = Pairs_LV->firstChild(); | 350 | QListViewItem * it = Pairs_LV->firstChild(); |
351 | while( it ) { | 351 | while( it ) { |
352 | if( it->isSelected() ) { | 352 | if( it->isSelected() ) { |
353 | // confirm ? | 353 | // confirm ? |
354 | if( QMessageBox::warning(0, | 354 | if( QMessageBox::warning(0, |
355 | tr("Break pairing"), | 355 | tr("Break pairing"), |
356 | tr("Sure ?"), | 356 | tr("Sure ?"), |
357 | tr("Yes, break"), | 357 | tr("Yes, break"), |
358 | tr("No, don't break") ) == 0 ) { | 358 | tr("No, don't break") ) == 0 ) { |
359 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; | 359 | LinkKeyLVI * KPIt = (LinkKeyLVI *)it; |
360 | // break | 360 | // break |
361 | OT->removeLinkKey( KPIt->index() ); | 361 | OT->removeLinkKey( KPIt->index() ); |
362 | delete KPIt; | 362 | delete KPIt; |
363 | } | 363 | } |
364 | return; | 364 | return; |
365 | } | 365 | } |
366 | it= it->nextSibling(); | 366 | it= it->nextSibling(); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | // | 370 | // |
371 | // | 371 | // |
372 | // | 372 | // |
373 | // | 373 | // |
374 | // | 374 | // |
375 | 375 | ||
376 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : | 376 | OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : |
377 | OTScanGUI( parent ), Filter() { | 377 | OTScanGUI( parent ), Filter() { |
378 | 378 | ||
379 | OT = OTGateway::getOTGateway(); | 379 | OT = OTGateway::getOTGateway(); |
380 | Icons = (_IC ) ? _IC : new OTIcons(); | 380 | Icons = (_IC ) ? _IC : new OTIcons(); |
381 | MyIcons = (_IC == 0 ); | 381 | MyIcons = (_IC == 0 ); |
382 | DetectedPeers_LV->header()->hide(); | 382 | DetectedPeers_LV->header()->hide(); |
383 | Current = 0; | 383 | Current = 0; |
384 | SelectedPeer = 0; | 384 | SelectedPeer = 0; |
385 | SelectedChannel = 0; | 385 | SelectedChannel = 0; |
386 | 386 | ||
387 | StrengthTimer = new QTimer( this ); | 387 | StrengthTimer = new QTimer( this ); |
388 | connect( StrengthTimer, | 388 | connect( StrengthTimer, |
389 | SIGNAL( timeout()), | 389 | SIGNAL( timeout()), |
390 | this, | 390 | this, |
391 | SLOT( SLOT_UpdateStrength()) | 391 | SLOT( SLOT_UpdateStrength()) |
392 | ); | 392 | ); |
393 | 393 | ||
394 | connect( OT, | 394 | connect( OT, |
395 | SIGNAL( detectedPeer( OTPeer *, bool )), | 395 | SIGNAL( detectedPeer( OTPeer *, bool )), |
396 | this, | 396 | this, |
397 | SLOT( SLOT_NewPeer( OTPeer *, bool )) | 397 | SLOT( SLOT_NewPeer( OTPeer *, bool )) |
398 | ); | 398 | ); |
399 | connect( OT, | 399 | connect( OT, |
400 | SIGNAL( finishedDetecting()), | 400 | SIGNAL( finishedDetecting()), |
401 | this, | 401 | this, |
402 | SLOT( SLOT_FinishedDetecting()) | 402 | SLOT( SLOT_FinishedDetecting()) |
403 | ); | 403 | ); |
404 | 404 | ||
405 | // populate with peers we already know about | 405 | // populate with peers we already know about |
406 | const PeerVector & P = OT->peers(); | 406 | const PeerVector & P = OT->peers(); |
407 | for( unsigned int i = 0; | 407 | for( unsigned int i = 0; |
408 | i < P.count(); | 408 | i < P.count(); |
409 | i ++ ) { | 409 | i ++ ) { |
410 | SLOT_NewPeer( P[i], TRUE ); | 410 | SLOT_NewPeer( P[i], TRUE ); |
411 | } | 411 | } |
412 | 412 | ||
413 | // populate State fram | 413 | // populate State fram |
414 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); | 414 | { QHBoxLayout * H =new QHBoxLayout( State_Frm ); |
415 | 415 | ||
416 | Paired_Led = new OLedBox( green, State_Frm ); | 416 | Paired_Led = new OLedBox( green, State_Frm ); |
417 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); | 417 | QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); |
418 | 418 | ||
419 | H->addWidget( Paired_Led ); | 419 | H->addWidget( Paired_Led ); |
420 | H->addWidget( L1 ); | 420 | H->addWidget( L1 ); |
421 | H->addStretch( 1 ); | 421 | H->addStretch( 1 ); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | OTScan::~OTScan() { | 425 | OTScan::~OTScan() { |
426 | if( MyIcons ) | 426 | if( MyIcons ) |
427 | delete Icons; | 427 | delete Icons; |
428 | OTGateway::releaseOTGateway(); | 428 | OTGateway::releaseOTGateway(); |
429 | 429 | ||
430 | // send all peers that we do not care about states | 430 | // send all peers that we do not care about states |
431 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 431 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
432 | while( Lit ) { | 432 | while( Lit ) { |
433 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); | 433 | ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); |
434 | Lit = Lit->nextSibling(); | 434 | Lit = Lit->nextSibling(); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | // static scan dialog function | 438 | // static scan dialog function |
439 | int OTScan::getDevice( OTPeer *& Peer, | 439 | int OTScan::getDevice( OTPeer *& Peer, |
440 | int & Channel, | 440 | int & Channel, |
441 | OTGateway * OT, | 441 | OTGateway * OT, |
442 | const UUIDVector & Filter, | 442 | const UUIDVector & Filter, |
443 | QWidget* Parent ) { | 443 | QWidget* Parent ) { |
444 | bool IsUp = 0; | 444 | bool IsUp = 0; |
445 | unsigned int i; | 445 | unsigned int i; |
446 | 446 | ||
447 | // check if bluetooth is up | 447 | // check if bluetooth is up |
448 | OTDriverList & DL = OT->getDriverList(); | 448 | OTDriverList & DL = OT->getDriverList(); |
449 | for( i = 0; | 449 | for( i = 0; |
450 | i < DL.count(); | 450 | i < DL.count(); |
451 | i ++ ) { | 451 | i ++ ) { |
452 | if( DL[i]->isUp() ) { | 452 | if( DL[i]->isUp() ) { |
453 | // one device that is up found | 453 | // one device that is up found |
454 | IsUp = 1; | 454 | IsUp = 1; |
455 | break; | 455 | break; |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | // use this driver | 459 | // use this driver |
460 | OT->setScanWith( OT->driver(i) ); | 460 | OT->setScanWith( OT->driver(i) ); |
461 | 461 | ||
462 | // create dialog | 462 | // create dialog |
463 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); | 463 | QDialog * Dlg = new QDialog( Parent, 0, TRUE ); |
464 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 464 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
465 | OTScan * Scn = new OTScan( Dlg ); | 465 | OTScan * Scn = new OTScan( Dlg ); |
466 | 466 | ||
467 | connect( Scn, | 467 | connect( Scn, |
468 | SIGNAL( selected() ), | 468 | SIGNAL( selected() ), |
469 | Dlg, | 469 | Dlg, |
470 | SLOT( accept() ) | 470 | SLOT( accept() ) |
471 | ); | 471 | ); |
472 | 472 | ||
473 | if( Filter ) { | 473 | if( Filter ) { |
474 | Scn->setScanFilter( Filter ); | 474 | Scn->setScanFilter( Filter ); |
475 | } | 475 | } |
476 | 476 | ||
477 | V->addWidget( Scn ); | 477 | V->addWidget( Scn ); |
478 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); | 478 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); |
479 | Dlg->showMaximized(); | 479 | Dlg->showMaximized(); |
480 | int rv = Dlg->exec(); | 480 | int rv = Dlg->exec(); |
481 | 481 | ||
482 | if( rv == QDialog::Accepted ) { | 482 | if( rv == QDialog::Accepted ) { |
483 | // get peer | 483 | // get peer |
484 | Peer = Scn->selectedPeer(); | 484 | Peer = Scn->selectedPeer(); |
485 | if( Peer == 0 ) { | 485 | if( Peer == 0 ) { |
486 | // no peer selected | 486 | // no peer selected |
487 | rv = QDialog::Rejected; | 487 | rv = QDialog::Rejected; |
488 | } else { | 488 | } else { |
489 | Channel = Scn->selectedChannel(); | 489 | Channel = Scn->selectedChannel(); |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | delete Dlg; | 493 | delete Dlg; |
494 | 494 | ||
495 | return rv; | 495 | return rv; |
496 | } | 496 | } |
497 | 497 | ||
498 | void OTScan::setScanFilter( const UUIDVector & V ) { | 498 | void OTScan::setScanFilter( const UUIDVector & V ) { |
499 | Filter = V; | 499 | Filter = V; |
500 | } | 500 | } |
501 | 501 | ||
502 | void OTScan::resetScanFilter( void ) { | 502 | void OTScan::resetScanFilter( void ) { |
503 | Filter.truncate(0); | 503 | Filter.truncate(0); |
504 | } | 504 | } |
505 | 505 | ||
506 | void OTScan::SLOT_DoScan( bool DoIt ) { | 506 | void OTScan::SLOT_DoScan( bool DoIt ) { |
507 | if( DoIt ) { | 507 | if( DoIt ) { |
508 | OT->scanNeighbourhood(); | 508 | OT->scanNeighbourhood(); |
509 | } else { | 509 | } else { |
510 | OT->stopScanOfNeighbourhood(); | 510 | OT->stopScanOfNeighbourhood(); |
511 | } | 511 | } |
512 | 512 | ||
513 | scanMode( DoIt ); | 513 | scanMode( DoIt ); |
514 | } | 514 | } |
515 | 515 | ||
516 | // double clicked on a device | 516 | // double clicked on a device |
517 | void OTScan::SLOT_Selected( QListViewItem * it ) { | 517 | void OTScan::SLOT_Selected( QListViewItem * it ) { |
518 | if( ! it ) | 518 | if( ! it ) |
519 | return; | 519 | return; |
520 | 520 | ||
521 | if( Filter.count() > 0 ) { | 521 | if( Filter.count() > 0 ) { |
522 | // filter on service | 522 | // filter on service |
523 | if( it->depth() == 0 ) { | 523 | if( it->depth() == 0 ) { |
524 | // select a service and not a device | 524 | // select a service and not a device |
525 | return; | 525 | return; |
526 | } | 526 | } |
527 | 527 | ||
528 | // store result | 528 | // store result |
529 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); | 529 | SelectedPeer = ((PeerLVI *)it->parent())->peer(); |
530 | SelectedChannel = ((ChannelLVI *)it)->channel(); | 530 | SelectedChannel = ((ChannelLVI *)it)->channel(); |
531 | } else { | 531 | } else { |
532 | // click on device | 532 | // click on device |
533 | if( it->depth() != 0 ) { | 533 | if( it->depth() != 0 ) { |
534 | return; | 534 | return; |
535 | } | 535 | } |
536 | 536 | ||
537 | SelectedPeer = ((PeerLVI *)it)->peer(); | 537 | SelectedPeer = ((PeerLVI *)it)->peer(); |
538 | SelectedChannel = 0; | 538 | SelectedChannel = 0; |
539 | } | 539 | } |
540 | owarn << "Selected " << SelectedPeer->address().toString() << | 540 | odebug << "Selected " << SelectedPeer->address().toString() << |
541 | " Channel " << SelectedChannel << oendl; | 541 | " Channel " << SelectedChannel << oendl; |
542 | emit selected(); | 542 | emit selected(); |
543 | } | 543 | } |
544 | 544 | ||
545 | void OTScan::SLOT_FinishedDetecting( ) { | 545 | void OTScan::SLOT_FinishedDetecting( ) { |
546 | scanMode( false ); | 546 | scanMode( false ); |
547 | } | 547 | } |
548 | 548 | ||
549 | void OTScan::SLOT_CleanupOld( ) { | 549 | void OTScan::SLOT_CleanupOld( ) { |
550 | 550 | ||
551 | // iterate over all peers and find those that | 551 | // iterate over all peers and find those that |
552 | // are down and have no pairing info | 552 | // are down and have no pairing info |
553 | OTPeer * TheP; | 553 | OTPeer * TheP; |
554 | const LinkKeyArray & Keys = OT->getLinkKeys(); | 554 | const LinkKeyArray & Keys = OT->getLinkKeys(); |
555 | 555 | ||
556 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 556 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
557 | while( Lit ) { | 557 | while( Lit ) { |
558 | TheP = ((PeerLVI *)Lit)->peer(); | 558 | TheP = ((PeerLVI *)Lit)->peer(); |
559 | if( TheP->state() == OTPeer::Peer_Down ) { | 559 | if( TheP->state() == OTPeer::Peer_Down ) { |
560 | unsigned int k; | 560 | unsigned int k; |
561 | 561 | ||
562 | // what about linkkeys ? | 562 | // what about linkkeys ? |
563 | for( k = 0; k < Keys.count(); k ++ ) { | 563 | for( k = 0; k < Keys.count(); k ++ ) { |
564 | if( TheP->address() == Keys[k].to() || | 564 | if( TheP->address() == Keys[k].to() || |
565 | TheP->address() == Keys[k].from() | 565 | TheP->address() == Keys[k].from() |
566 | ) { | 566 | ) { |
567 | // part of linkkey | 567 | // part of linkkey |
568 | owarn << "LINKKEY " << TheP->address().toString() << oendl; | 568 | odebug << "LINKKEY " << TheP->address().toString() << oendl; |
569 | break; | 569 | break; |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | if( k == Keys.count() ) { | 573 | if( k == Keys.count() ) { |
574 | owarn << "RM LINKKEY " << TheP->address().toString() << oendl; | 574 | odebug << "RM LINKKEY " << TheP->address().toString() << oendl; |
575 | // not found -> remember to remove this peer | 575 | // not found -> remember to remove this peer |
576 | QListViewItem * Nit; | 576 | QListViewItem * Nit; |
577 | OT->removePeer( TheP ); | 577 | OT->removePeer( TheP ); |
578 | Nit = Lit->nextSibling(); | 578 | Nit = Lit->nextSibling(); |
579 | delete Lit; | 579 | delete Lit; |
580 | Lit = Nit; | 580 | Lit = Nit; |
581 | continue; | 581 | continue; |
582 | } | 582 | } |
583 | } else { | 583 | } else { |
584 | owarn << "NODOWN " << TheP->address().toString() << oendl; | 584 | odebug << "NODOWN " << TheP->address().toString() << oendl; |
585 | } | 585 | } |
586 | 586 | ||
587 | Lit = Lit->nextSibling(); | 587 | Lit = Lit->nextSibling(); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ | 591 | void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ |
592 | PeerLVI * it = 0; | 592 | PeerLVI * it = 0; |
593 | 593 | ||
594 | if( IsNew ) { | 594 | if( IsNew ) { |
595 | it = new PeerLVI( P, DetectedPeers_LV ); | 595 | it = new PeerLVI( P, DetectedPeers_LV ); |
596 | } else { | 596 | } else { |
597 | // find peer in table | 597 | // find peer in table |
598 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); | 598 | QListViewItem * Lit = DetectedPeers_LV->firstChild(); |
599 | while( Lit ) { | 599 | while( Lit ) { |
600 | if( ((PeerLVI *)Lit)->peer() == P ) { | 600 | if( ((PeerLVI *)Lit)->peer() == P ) { |
601 | // this item | 601 | // this item |
602 | it = (PeerLVI *)Lit; | 602 | it = (PeerLVI *)Lit; |
603 | break; | 603 | break; |
604 | } | 604 | } |
605 | Lit = Lit->nextSibling(); | 605 | Lit = Lit->nextSibling(); |
606 | } | 606 | } |
607 | 607 | ||
608 | if( ! it ) { | 608 | if( ! it ) { |
609 | owarn << "Should not occur" << oendl; | 609 | odebug << "Should not occur" << oendl; |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | // update/show info | 614 | // update/show info |
615 | it->setText( 0, P->name() ); | 615 | it->setText( 0, P->name() ); |
616 | it->setPixmap(0, Icons->deviceIcon( | 616 | it->setPixmap(0, Icons->deviceIcon( |
617 | OT->deviceTypeToName( P->deviceClass() ) ) ); | 617 | OT->deviceTypeToName( P->deviceClass() ) ) ); |
618 | 618 | ||
619 | // tell peer to report its state async | 619 | // tell peer to report its state async |
620 | connect( P, | 620 | connect( P, |
621 | SIGNAL( peerStateReport( OTPeer *)), | 621 | SIGNAL( peerStateReport( OTPeer *)), |
622 | this, | 622 | this, |
623 | SLOT( SLOT_PeerState( OTPeer *)) | 623 | SLOT( SLOT_PeerState( OTPeer *)) |
624 | ); | 624 | ); |
625 | 625 | ||
626 | if( IsNew ) { | 626 | if( IsNew ) { |
627 | // find state | 627 | // find state |
628 | refreshState( (PeerLVI *)it, 1 ); | 628 | refreshState( (PeerLVI *)it, 1 ); |
629 | } else { | 629 | } else { |
630 | // update staet | 630 | // update staet |
631 | SLOT_PeerState( P ); | 631 | SLOT_PeerState( P ); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | 634 | ||
635 | void OTScan::SLOT_PeerState( OTPeer * P ) { | 635 | void OTScan::SLOT_PeerState( OTPeer * P ) { |
636 | PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); | 636 | PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); |
637 | while( it ) { | 637 | while( it ) { |
638 | if( it->peer() == P ) { | 638 | if( it->peer() == P ) { |
639 | break; | 639 | break; |
640 | } | 640 | } |
641 | it = (PeerLVI * )it->nextSibling(); | 641 | it = (PeerLVI * )it->nextSibling(); |
642 | } | 642 | } |
643 | 643 | ||
644 | if( ! it ) | 644 | if( ! it ) |
645 | return; | 645 | return; |
646 | 646 | ||
647 | switch( P->state() ) { | 647 | switch( P->state() ) { |
648 | case OTPeer::Peer_Unknown : | 648 | case OTPeer::Peer_Unknown : |
649 | case OTPeer::Peer_Down : | 649 | case OTPeer::Peer_Down : |
650 | it->setPixmap( 1, 0 ); | 650 | it->setPixmap( 1, 0 ); |
651 | break; | 651 | break; |
652 | case OTPeer::Peer_Up : | 652 | case OTPeer::Peer_Up : |
653 | it->setPixmap( 1, Icons->loadPixmap( | 653 | it->setPixmap( 1, Icons->loadPixmap( |
654 | ( P->connectedTo() ) ? "connected" : "notconnected" ) ); | 654 | ( P->connectedTo() ) ? "connected" : "notconnected" ) ); |
655 | if( it == Current && ! StrengthTimer->isActive() ) { | 655 | if( it == Current && ! StrengthTimer->isActive() ) { |
656 | // start showing strength | 656 | // start showing strength |
657 | StrengthTimer->start( 1000, FALSE ); | 657 | StrengthTimer->start( 1000, FALSE ); |
658 | SLOT_UpdateStrength(); | 658 | SLOT_UpdateStrength(); |
659 | } | 659 | } |
660 | break; | 660 | break; |
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | void OTScan::SLOT_RefreshState( void ) { | 664 | void OTScan::SLOT_RefreshState( void ) { |
665 | 665 | ||
666 | QListViewItem * it = DetectedPeers_LV->firstChild(); | 666 | QListViewItem * it = DetectedPeers_LV->firstChild(); |
667 | while( it ) { | 667 | while( it ) { |
668 | if( it->isSelected() ) { | 668 | if( it->isSelected() ) { |
669 | break; | 669 | break; |
670 | } | 670 | } |
671 | it = it->nextSibling(); | 671 | it = it->nextSibling(); |
672 | } | 672 | } |
673 | 673 | ||
674 | if( ! it ) | 674 | if( ! it ) |
675 | return; | 675 | return; |
676 | 676 | ||
677 | refreshState( (PeerLVI *)it, 1 ); | 677 | refreshState( (PeerLVI *)it, 1 ); |
678 | } | 678 | } |
679 | 679 | ||
680 | void OTScan::refreshState( PeerLVI * it, bool Force ) { | 680 | void OTScan::refreshState( PeerLVI * it, bool Force ) { |
681 | it->setPixmap( 1, Icons->loadPixmap( "find" ) ); | 681 | it->setPixmap( 1, Icons->loadPixmap( "find" ) ); |
682 | it->peer()->findOutState( 30, Force ); | 682 | it->peer()->findOutState( 30, Force ); |
683 | } | 683 | } |
684 | 684 | ||
685 | void OTScan::SLOT_Show( QListViewItem * it ) { | 685 | void OTScan::SLOT_Show( QListViewItem * it ) { |
686 | 686 | ||
687 | if( ! it || it->depth() > 0 ) | 687 | if( ! it || it->depth() > 0 ) |
688 | return; | 688 | return; |
689 | 689 | ||
690 | QString S; | 690 | QString S; |
691 | 691 | ||
692 | Current = (PeerLVI *)it; | 692 | Current = (PeerLVI *)it; |
693 | 693 | ||
694 | Strength_PB->setProgress( 0 ); // reset | 694 | Strength_PB->setProgress( 0 ); // reset |
695 | Address_LBL->setText( Current->peer()->address().toString() ); | 695 | Address_LBL->setText( Current->peer()->address().toString() ); |
696 | Peer_GB->setTitle( Current->peer()->name() ); | 696 | Peer_GB->setTitle( Current->peer()->name() ); |
697 | 697 | ||
698 | const LinkKeyArray & Keys = OT->getLinkKeys(); | 698 | const LinkKeyArray & Keys = OT->getLinkKeys(); |
699 | 699 | ||
700 | Paired_Led->setOn( FALSE ); | 700 | Paired_Led->setOn( FALSE ); |
701 | for( unsigned int i = 0; | 701 | for( unsigned int i = 0; |
702 | i < Keys.count(); | 702 | i < Keys.count(); |
703 | i ++ ) { | 703 | i ++ ) { |
704 | if( Current->peer()->address() == Keys[i].to() ) { | 704 | if( Current->peer()->address() == Keys[i].to() ) { |
705 | Paired_Led->setOn( TRUE ); | 705 | Paired_Led->setOn( TRUE ); |
706 | break; | 706 | break; |
707 | } | 707 | } |
708 | } | 708 | } |
709 | 709 | ||
710 | if( Current->peer()->state() == OTPeer::Peer_Up ) { | 710 | if( Current->peer()->state() == OTPeer::Peer_Up ) { |
711 | RefreshServices_But->setEnabled( TRUE ); | 711 | RefreshServices_But->setEnabled( TRUE ); |
712 | StrengthTimer->start( 1000, FALSE ); | 712 | StrengthTimer->start( 1000, FALSE ); |
713 | SLOT_UpdateStrength(); | 713 | SLOT_UpdateStrength(); |
714 | } else { | 714 | } else { |
715 | RefreshServices_But->setEnabled( FALSE ); | 715 | RefreshServices_But->setEnabled( FALSE ); |
716 | } | 716 | } |
717 | 717 | ||
718 | } | 718 | } |
719 | 719 | ||
720 | void OTScan::SLOT_UpdateStrength( void ) { | 720 | void OTScan::SLOT_UpdateStrength( void ) { |
721 | OTDriver * D = Current->peer()->connectedTo(); | 721 | OTDriver * D = Current->peer()->connectedTo(); |
722 | 722 | ||
723 | if( D ) { | 723 | if( D ) { |
724 | long Q = D->getLinkQuality( Current->peer()->address() ); | 724 | long Q = D->getLinkQuality( Current->peer()->address() ); |
725 | Strength_PB->setProgress( Q ); | 725 | Strength_PB->setProgress( Q ); |
726 | if( ! Q ) { | 726 | if( ! Q ) { |
727 | // no quality | 727 | // no quality |
728 | Strength_PB->setEnabled( TRUE ); | 728 | Strength_PB->setEnabled( TRUE ); |
729 | StrengthTimer->stop(); | 729 | StrengthTimer->stop(); |
730 | } | 730 | } |
731 | } else { | 731 | } else { |
732 | Strength_PB->setEnabled( FALSE ); | 732 | Strength_PB->setEnabled( FALSE ); |
733 | Strength_PB->setProgress( 0 ); | 733 | Strength_PB->setProgress( 0 ); |
734 | // no point in continuing | 734 | // no point in continuing |
735 | StrengthTimer->stop(); | 735 | StrengthTimer->stop(); |
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
739 | void OTScan::SLOT_RefreshServices( void ) { | 739 | void OTScan::SLOT_RefreshServices( void ) { |
740 | 740 | ||
741 | QListViewItem * it = DetectedPeers_LV->firstChild(); | 741 | QListViewItem * it = DetectedPeers_LV->firstChild(); |
742 | while( it ) { | 742 | while( it ) { |
743 | if( it->isSelected() ) { | 743 | if( it->isSelected() ) { |
744 | break; | 744 | break; |
745 | } | 745 | } |
746 | it = it->nextSibling(); | 746 | it = it->nextSibling(); |
747 | } | 747 | } |
748 | 748 | ||
749 | if( ! it ) | 749 | if( ! it ) |
750 | return; | 750 | return; |
751 | 751 | ||
752 | QString S; | 752 | QString S; |
753 | PeerLVI * PI = (PeerLVI *)it; | 753 | PeerLVI * PI = (PeerLVI *)it; |
754 | 754 | ||
755 | scanMode( true ); | 755 | scanMode( true ); |
756 | qApp->processEvents(0); | 756 | qApp->processEvents(0); |
757 | 757 | ||
758 | ServiceVector & V = PI->peer()->services(); | 758 | ServiceVector & V = PI->peer()->services(); |
759 | 759 | ||
760 | while( PI->firstChild() ) { | 760 | while( PI->firstChild() ) { |
761 | // remove children | 761 | // remove children |
762 | delete PI->firstChild(); | 762 | delete PI->firstChild(); |
763 | } | 763 | } |
764 | 764 | ||
765 | for( unsigned int i = 0 ; | 765 | for( unsigned int i = 0 ; |
766 | i < V.count(); | 766 | i < V.count(); |
767 | i ++ ) { | 767 | i ++ ) { |
768 | QString S; | 768 | QString S; |
769 | S = V[i]->name(); | 769 | S = V[i]->name(); |
770 | 770 | ||
771 | if( S.isEmpty() ) { | 771 | if( S.isEmpty() ) { |
772 | continue; | 772 | continue; |
773 | } | 773 | } |
774 | 774 | ||
775 | { QListViewItem * SIt; | 775 | { QListViewItem * SIt; |
776 | UUIDVector UIDV; | 776 | UUIDVector UIDV; |
777 | QPixmap Pm; | 777 | QPixmap Pm; |
778 | bool Done = 0; | 778 | bool Done = 0; |
779 | bool R; | 779 | bool R; |
780 | short ID; | 780 | short ID; |
781 | 781 | ||
782 | SIt = 0; | 782 | SIt = 0; |
783 | 783 | ||
784 | UIDV = V[i]->classIDList(); | 784 | UIDV = V[i]->classIDList(); |
785 | // first all UUID ! 1200 12ff (Genericprofiles) | 785 | // first all UUID ! 1200 12ff (Genericprofiles) |
786 | for( unsigned int j = 0; | 786 | for( unsigned int j = 0; |
787 | j < UIDV.count(); | 787 | j < UIDV.count(); |
788 | j ++ ) { | 788 | j ++ ) { |
789 | 789 | ||
790 | if( Filter.count() ) { | 790 | if( Filter.count() ) { |
791 | bool FilterOut = 1; | 791 | bool FilterOut = 1; |
792 | // filter out if not in list | 792 | // filter out if not in list |
793 | for( unsigned int ff = 0; | 793 | for( unsigned int ff = 0; |
794 | ff < Filter.count(); | 794 | ff < Filter.count(); |
795 | ff ++ ) { | 795 | ff ++ ) { |
796 | if( UIDV[j] == Filter[ff] ) { | 796 | if( UIDV[j] == Filter[ff] ) { |
797 | FilterOut = 0; | 797 | FilterOut = 0; |
798 | break; | 798 | break; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | 801 | ||
802 | if( FilterOut ) { | 802 | if( FilterOut ) { |
803 | // not in filter list | 803 | // not in filter list |
804 | continue; | 804 | continue; |
805 | } | 805 | } |
806 | } // else show | 806 | } // else show |
807 | 807 | ||
808 | ID = UIDV[j].toShort(); | 808 | ID = UIDV[j].toShort(); |
809 | if( ID < 0x1200 || ID > 0x12ff ) { | 809 | if( ID < 0x1200 || ID > 0x12ff ) { |
810 | // use this profile | 810 | // use this profile |
811 | if( R ) { | 811 | if( R ) { |
812 | unsigned int ch; | 812 | unsigned int ch; |
813 | bool has; | 813 | bool has; |
814 | has = V[i]->rfcommChannel( ch ); | 814 | has = V[i]->rfcommChannel( ch ); |
815 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); | 815 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); |
816 | SIt->setText(0, V[i]->name() ); | 816 | SIt->setText(0, V[i]->name() ); |
817 | 817 | ||
818 | Pm = Icons->serviceIcon( ID, R ); | 818 | Pm = Icons->serviceIcon( ID, R ); |
819 | SIt->setPixmap(0, Pm ); | 819 | SIt->setPixmap(0, Pm ); |
820 | Done = 1; | 820 | Done = 1; |
821 | break; | 821 | break; |
822 | } | 822 | } |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | if( ! Done ) { | 826 | if( ! Done ) { |
827 | // check other range too | 827 | // check other range too |
828 | for( unsigned int j = 0; | 828 | for( unsigned int j = 0; |
829 | j < UIDV.count(); | 829 | j < UIDV.count(); |
830 | j ++ ) { | 830 | j ++ ) { |
831 | 831 | ||
832 | if( Filter.count() ) { | 832 | if( Filter.count() ) { |
833 | bool FilterOut = 1; | 833 | bool FilterOut = 1; |
834 | // filter out if not in list | 834 | // filter out if not in list |
835 | for( unsigned int ff = 0; | 835 | for( unsigned int ff = 0; |
836 | ff < Filter.count(); | 836 | ff < Filter.count(); |
837 | ff ++ ) { | 837 | ff ++ ) { |
838 | if( UIDV[j] == Filter[ff] ) { | 838 | if( UIDV[j] == Filter[ff] ) { |
839 | FilterOut = 0; | 839 | FilterOut = 0; |
840 | break; | 840 | break; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | if( FilterOut ) { | 844 | if( FilterOut ) { |
845 | // not in filter list | 845 | // not in filter list |
846 | continue; | 846 | continue; |
847 | } | 847 | } |
848 | } // else show | 848 | } // else show |
849 | 849 | ||
850 | ID = UIDV[j].toShort(); | 850 | ID = UIDV[j].toShort(); |
851 | if( ID >= 0x1200 && ID <= 0x12ff ) { | 851 | if( ID >= 0x1200 && ID <= 0x12ff ) { |
852 | // use this profile | 852 | // use this profile |
853 | unsigned int ch; | 853 | unsigned int ch; |
854 | bool has; | 854 | bool has; |
855 | has = V[i]->rfcommChannel( ch ); | 855 | has = V[i]->rfcommChannel( ch ); |
856 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); | 856 | SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); |
857 | SIt->setText(0, V[i]->name() ); | 857 | SIt->setText(0, V[i]->name() ); |
858 | 858 | ||
859 | Pm = Icons->serviceIcon( ID, R ); | 859 | Pm = Icons->serviceIcon( ID, R ); |
860 | SIt->setPixmap(0, Pm ); | 860 | SIt->setPixmap(0, Pm ); |
861 | 861 | ||
862 | break; | 862 | break; |
863 | } | 863 | } |
864 | } | 864 | } |
865 | } | 865 | } |
866 | 866 | ||
867 | } | 867 | } |
868 | } | 868 | } |
869 | 869 | ||
870 | scanMode( false ); | 870 | scanMode( false ); |
871 | } | 871 | } |
872 | 872 | ||
873 | void OTScan::scanMode( bool M ) { | 873 | void OTScan::scanMode( bool M ) { |
874 | // avoid infinite loop because it triggers DoScan | 874 | // avoid infinite loop because it triggers DoScan |
875 | Detect_But->blockSignals( TRUE ); | 875 | Detect_But->blockSignals( TRUE ); |
876 | Detect_But->setOn( M ); | 876 | Detect_But->setOn( M ); |
877 | Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); | 877 | Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); |
878 | Detect_But->blockSignals( FALSE ); | 878 | Detect_But->blockSignals( FALSE ); |
879 | } | 879 | } |
880 | 880 | ||
881 | // | 881 | // |
882 | // | 882 | // |
883 | // | 883 | // |
884 | // | 884 | // |
885 | // | 885 | // |
886 | 886 | ||
887 | OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : | 887 | OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : |
888 | OTManageGUI( parent ) { | 888 | OTManageGUI( parent ) { |
889 | 889 | ||
890 | OT = OTGateway::getOTGateway(); | 890 | OT = OTGateway::getOTGateway(); |
891 | 891 | ||
892 | Icons = (_IC ) ? _IC : new OTIcons(); | 892 | Icons = (_IC ) ? _IC : new OTIcons(); |
893 | MyIcons = (_IC == 0 ); | 893 | MyIcons = (_IC == 0 ); |
894 | AllDrivers_LV->setSorting(-1); | 894 | AllDrivers_LV->setSorting(-1); |
895 | 895 | ||
896 | connect( OT, | 896 | connect( OT, |
897 | SIGNAL( driverListChanged() ), | 897 | SIGNAL( driverListChanged() ), |
898 | this, | 898 | this, |
899 | SLOT( SLOT_DriverListChanged() ) | 899 | SLOT( SLOT_DriverListChanged() ) |
900 | ); | 900 | ); |
901 | connect( OT, | 901 | connect( OT, |
902 | SIGNAL( stateChange( OTDriver *, bool ) ), | 902 | SIGNAL( stateChange( OTDriver *, bool ) ), |
903 | this, | 903 | this, |
904 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) | 904 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) |
905 | ); | 905 | ); |
906 | 906 | ||
907 | SLOT_DriverListChanged(); | 907 | SLOT_DriverListChanged(); |
908 | 908 | ||
909 | AllDrivers_LV->header()->hide(); | 909 | AllDrivers_LV->header()->hide(); |
910 | } | 910 | } |
911 | 911 | ||
912 | OTManage::~OTManage() { | 912 | OTManage::~OTManage() { |
913 | if( MyIcons ) | 913 | if( MyIcons ) |
914 | delete Icons; | 914 | delete Icons; |
915 | OTGateway::releaseOTGateway(); | 915 | OTGateway::releaseOTGateway(); |
916 | } | 916 | } |
917 | 917 | ||
918 | void OTManage::SLOT_ShowDriver( QListViewItem * It ) { | 918 | void OTManage::SLOT_ShowDriver( QListViewItem * It ) { |
919 | if( It == 0 || It->depth() > 0 ) | 919 | if( It == 0 || It->depth() > 0 ) |
920 | // not toplevel | 920 | // not toplevel |
921 | return; | 921 | return; |
922 | 922 | ||
923 | DriverLVI * it = (DriverLVI *) It; | 923 | DriverLVI * it = (DriverLVI *) It; |
924 | DriverIsUp_CB->setChecked( it->driver()->isUp() ); | 924 | DriverIsUp_CB->setChecked( it->driver()->isUp() ); |
925 | } | 925 | } |
926 | 926 | ||
927 | void OTManage::SLOT_UpDriver( bool Up ) { | 927 | void OTManage::SLOT_UpDriver( bool Up ) { |
928 | QListViewItem * it = AllDrivers_LV->firstChild(); | 928 | QListViewItem * it = AllDrivers_LV->firstChild(); |
929 | while( it ) { | 929 | while( it ) { |
930 | if( it->isSelected() ) { | 930 | if( it->isSelected() ) { |
931 | OTDriver * D = ((DriverLVI *)it)->driver(); | 931 | OTDriver * D = ((DriverLVI *)it)->driver(); |
932 | owarn << "UP driver " << D->devname() << oendl; | 932 | odebug << "UP driver " << D->devname() << oendl; |
933 | // this | 933 | // this |
934 | D->setUp( Up ); | 934 | D->setUp( Up ); |
935 | return; | 935 | return; |
936 | } | 936 | } |
937 | it = it->nextSibling(); | 937 | it = it->nextSibling(); |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { | 941 | void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { |
942 | QListViewItem * it = AllDrivers_LV->firstChild(); | 942 | QListViewItem * it = AllDrivers_LV->firstChild(); |
943 | while( it ) { | 943 | while( it ) { |
944 | if( ((DriverLVI *)it)->driver() == D ) { | 944 | if( ((DriverLVI *)it)->driver() == D ) { |
945 | it->setPixmap( 0, | 945 | it->setPixmap( 0, |
946 | Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); | 946 | Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); |
947 | return; | 947 | return; |
948 | } | 948 | } |
949 | it = it->nextSibling(); | 949 | it = it->nextSibling(); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | 952 | ||
953 | void OTManage::SLOT_DriverListChanged( ) { | 953 | void OTManage::SLOT_DriverListChanged( ) { |
954 | DriverLVI * It; | 954 | DriverLVI * It; |
955 | QListViewItem * Sub; | 955 | QListViewItem * Sub; |
956 | QListViewItem * First = 0; | 956 | QListViewItem * First = 0; |
957 | OTDriver* D; | 957 | OTDriver* D; |
958 | OTDriverList & DL = OT->getDriverList(); | 958 | OTDriverList & DL = OT->getDriverList(); |
959 | 959 | ||
960 | AllDrivers_LV->clear(); | 960 | AllDrivers_LV->clear(); |
961 | for( unsigned int i = 0; | 961 | for( unsigned int i = 0; |
962 | i < DL.count(); | 962 | i < DL.count(); |
963 | i ++ ) { | 963 | i ++ ) { |
964 | D = DL[i]; | 964 | D = DL[i]; |
965 | It = new DriverLVI( D, AllDrivers_LV ); | 965 | It = new DriverLVI( D, AllDrivers_LV ); |
966 | 966 | ||
967 | if( ! First ) | 967 | if( ! First ) |
968 | First = It; | 968 | First = It; |
969 | 969 | ||
970 | It->setText( 0, D->devname() ); | 970 | It->setText( 0, D->devname() ); |
971 | It->setPixmap( 0, | 971 | It->setPixmap( 0, |
972 | Icons->loadPixmap( (D->isUp()) ? | 972 | Icons->loadPixmap( (D->isUp()) ? |
973 | "bluezon" : "bluezoff" ) ); | 973 | "bluezon" : "bluezoff" ) ); |
974 | 974 | ||
975 | Sub = new QListViewItem( It ); | 975 | Sub = new QListViewItem( It ); |
976 | Sub->setText( 0, tr( "Name" ) ); | 976 | Sub->setText( 0, tr( "Name" ) ); |
977 | Sub->setText( 1, D->name() ); | 977 | Sub->setText( 1, D->name() ); |
978 | 978 | ||
979 | Sub = new QListViewItem( It ); | 979 | Sub = new QListViewItem( It ); |
980 | Sub->setText( 0, tr( "Address" ) ); | 980 | Sub->setText( 0, tr( "Address" ) ); |
981 | Sub->setText( 1, D->address().toString() ); | 981 | Sub->setText( 1, D->address().toString() ); |
982 | 982 | ||
983 | Sub = new QListViewItem( It ); | 983 | Sub = new QListViewItem( It ); |
984 | Sub->setText( 0, tr( "Revision" ) ); | 984 | Sub->setText( 0, tr( "Revision" ) ); |
985 | Sub->setText( 1, D->revision() ); | 985 | Sub->setText( 1, D->revision() ); |
986 | 986 | ||
987 | Sub = new QListViewItem( It ); | 987 | Sub = new QListViewItem( It ); |
988 | Sub->setText( 0, tr( "Manufacturer" ) ); | 988 | Sub->setText( 0, tr( "Manufacturer" ) ); |
989 | Sub->setText( 1, D->manufacturer() ); | 989 | Sub->setText( 1, D->manufacturer() ); |
990 | 990 | ||
991 | QString Service, Device; | 991 | QString Service, Device; |
992 | D->getClass( Service, Device ); | 992 | D->getClass( Service, Device ); |
993 | 993 | ||
994 | Sub = new QListViewItem( It ); | 994 | Sub = new QListViewItem( It ); |
995 | Sub->setText( 0, tr( "Service classes" ) ); | 995 | Sub->setText( 0, tr( "Service classes" ) ); |
996 | Sub->setText( 1, Service ); | 996 | Sub->setText( 1, Service ); |
997 | Sub = new QListViewItem( It ); | 997 | Sub = new QListViewItem( It ); |
998 | Sub->setText( 0, tr( "Device class" ) ); | 998 | Sub->setText( 0, tr( "Device class" ) ); |
999 | Sub->setText( 1, Device ); | 999 | Sub->setText( 1, Device ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | if( DL.count() ) { | 1002 | if( DL.count() ) { |
1003 | AllDrivers_LV->setCurrentItem( First ); | 1003 | AllDrivers_LV->setCurrentItem( First ); |
1004 | DriverIsUp_CB->setEnabled( TRUE ); | 1004 | DriverIsUp_CB->setEnabled( TRUE ); |
1005 | } else { | 1005 | } else { |
1006 | DriverIsUp_CB->setChecked( FALSE ); | 1006 | DriverIsUp_CB->setChecked( FALSE ); |
1007 | DriverIsUp_CB->setEnabled( FALSE ); | 1007 | DriverIsUp_CB->setEnabled( FALSE ); |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void OTManage::SLOT_SetRefreshTimer( int v ) { | 1011 | void OTManage::SLOT_SetRefreshTimer( int v ) { |
1012 | OT->setRefreshTimer( v * 1000 ); | 1012 | OT->setRefreshTimer( v * 1000 ); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | // | 1015 | // |
1016 | // | 1016 | // |
1017 | // | 1017 | // |
1018 | // | 1018 | // |
1019 | // | 1019 | // |
1020 | 1020 | ||
1021 | OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { | 1021 | OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { |
1022 | 1022 | ||
1023 | Icons = new OTIcons(); | 1023 | Icons = new OTIcons(); |
1024 | SnifWindow = 0; | 1024 | SnifWindow = 0; |
1025 | OT = OTGateway::getOTGateway(); | 1025 | OT = OTGateway::getOTGateway(); |
1026 | 1026 | ||
1027 | connect( OT, | 1027 | connect( OT, |
1028 | SIGNAL( deviceEnabled( bool ) ), | 1028 | SIGNAL( deviceEnabled( bool ) ), |
1029 | this, | 1029 | this, |
1030 | SLOT( SLOT_DeviceIsEnabled( bool ) ) | 1030 | SLOT( SLOT_DeviceIsEnabled( bool ) ) |
1031 | ); | 1031 | ); |
1032 | connect( OT, | 1032 | connect( OT, |
1033 | SIGNAL( driverListChanged() ), | 1033 | SIGNAL( driverListChanged() ), |
1034 | this, | 1034 | this, |
1035 | SLOT( SLOT_DriverListChanged() ) | 1035 | SLOT( SLOT_DriverListChanged() ) |
1036 | ); | 1036 | ); |
1037 | connect( OT, | 1037 | connect( OT, |
1038 | SIGNAL( stateChange( OTDriver *, bool ) ), | 1038 | SIGNAL( stateChange( OTDriver *, bool ) ), |
1039 | this, | 1039 | this, |
1040 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) | 1040 | SLOT( SLOT_StateChange( OTDriver *, bool ) ) |
1041 | ); | 1041 | ); |
1042 | 1042 | ||
1043 | if( ! OT->needsEnabling() ) { | 1043 | if( ! OT->needsEnabling() ) { |
1044 | MustBeEnabled_CB->hide(); | 1044 | MustBeEnabled_CB->hide(); |
1045 | } else { | 1045 | } else { |
1046 | // detect current state | 1046 | // detect current state |
1047 | MustBeEnabled_CB->setChecked( | 1047 | MustBeEnabled_CB->setChecked( |
1048 | OT->isEnabled() ); | 1048 | OT->isEnabled() ); |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | SLOT_DriverListChanged(); | 1051 | SLOT_DriverListChanged(); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | OTMain::~OTMain() { | 1054 | OTMain::~OTMain() { |
1055 | OTGateway::releaseOTGateway(); | 1055 | OTGateway::releaseOTGateway(); |
1056 | delete Icons; | 1056 | delete Icons; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | void OTMain::SLOT_DriverListChanged() { | 1059 | void OTMain::SLOT_DriverListChanged() { |
1060 | OTDriver * D; | 1060 | OTDriver * D; |
1061 | OTDriverList & DL = OT->getDriverList(); | 1061 | OTDriverList & DL = OT->getDriverList(); |
1062 | 1062 | ||
1063 | DeviceList_CB->clear(); | 1063 | DeviceList_CB->clear(); |
1064 | for( unsigned int i = 0; | 1064 | for( unsigned int i = 0; |
1065 | i < DL.count(); | 1065 | i < DL.count(); |
1066 | i ++ ) { | 1066 | i ++ ) { |
1067 | D = DL[i]; | 1067 | D = DL[i]; |
1068 | DeviceList_CB->insertItem( | 1068 | DeviceList_CB->insertItem( |
1069 | Icons->loadPixmap( (D->isUp()) ? | 1069 | Icons->loadPixmap( (D->isUp()) ? |
1070 | "bluezon" : "bluezoff" ), | 1070 | "bluezon" : "bluezoff" ), |
1071 | D->devname() ); | 1071 | D->devname() ); |
1072 | if( D == OT->scanWith() ) { | 1072 | if( D == OT->scanWith() ) { |
1073 | DeviceList_CB->setCurrentItem( i ); | 1073 | DeviceList_CB->setCurrentItem( i ); |
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | Scan_But->setEnabled( OT->getDriverList().count() > 0 ); | 1077 | Scan_But->setEnabled( OT->getDriverList().count() > 0 ); |
1078 | DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); | 1078 | DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | void OTMain::SLOT_EnableBluetooth( bool Up ) { | 1081 | void OTMain::SLOT_EnableBluetooth( bool Up ) { |
1082 | OT->SLOT_SetEnabled( Up ); | 1082 | OT->SLOT_SetEnabled( Up ); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | void OTMain::SLOT_DeviceIsEnabled( bool Up ) { | 1085 | void OTMain::SLOT_DeviceIsEnabled( bool Up ) { |
1086 | MustBeEnabled_CB->blockSignals( TRUE ); | 1086 | MustBeEnabled_CB->blockSignals( TRUE ); |
1087 | MustBeEnabled_CB->setChecked( Up ); | 1087 | MustBeEnabled_CB->setChecked( Up ); |
1088 | MustBeEnabled_CB->blockSignals( FALSE ); | 1088 | MustBeEnabled_CB->blockSignals( FALSE ); |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void OTMain::SLOT_Manage( void ) { | 1091 | void OTMain::SLOT_Manage( void ) { |
1092 | QDialog * Dlg = new QDialog( this, 0, TRUE ); | 1092 | QDialog * Dlg = new QDialog( this, 0, TRUE ); |
1093 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 1093 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
1094 | OTManage * Mng = new OTManage( Dlg, Icons ); | 1094 | OTManage * Mng = new OTManage( Dlg, Icons ); |
1095 | 1095 | ||
1096 | V->addWidget( Mng ); | 1096 | V->addWidget( Mng ); |
1097 | 1097 | ||
1098 | Dlg->setCaption( tr("Manage local devices" ) ); | 1098 | Dlg->setCaption( tr("Manage local devices" ) ); |
1099 | Dlg->showMaximized(); | 1099 | Dlg->showMaximized(); |
1100 | Dlg->exec(); | 1100 | Dlg->exec(); |
1101 | delete Dlg; | 1101 | delete Dlg; |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | void OTMain::SLOT_Scan( void ) { | 1104 | void OTMain::SLOT_Scan( void ) { |
1105 | OTDriverList & DL = OT->getDriverList(); | 1105 | OTDriverList & DL = OT->getDriverList(); |
1106 | for( unsigned int i = 0; | 1106 | for( unsigned int i = 0; |
1107 | i < DL.count(); | 1107 | i < DL.count(); |
1108 | i ++ ) { | 1108 | i ++ ) { |
1109 | if( DL[i]->isUp() && | 1109 | if( DL[i]->isUp() && |
1110 | DL[i]->devname() == DeviceList_CB->currentText() | 1110 | DL[i]->devname() == DeviceList_CB->currentText() |
1111 | ) { | 1111 | ) { |
1112 | QDialog * Dlg = new QDialog( this, 0, TRUE ); | 1112 | QDialog * Dlg = new QDialog( this, 0, TRUE ); |
1113 | QVBoxLayout * V = new QVBoxLayout( Dlg ); | 1113 | QVBoxLayout * V = new QVBoxLayout( Dlg ); |
1114 | OTScan * Scn = new OTScan( Dlg, Icons ); | 1114 | OTScan * Scn = new OTScan( Dlg, Icons ); |
1115 | 1115 | ||
1116 | OT->setScanWith( OT->driver(i) ); | 1116 | OT->setScanWith( OT->driver(i) ); |
1117 | V->addWidget( Scn ); | 1117 | V->addWidget( Scn ); |
1118 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); | 1118 | Dlg->setCaption( tr("Scan Neighbourhood" ) ); |
1119 | Dlg->showMaximized(); | 1119 | Dlg->showMaximized(); |
1120 | Dlg->exec(); | 1120 | Dlg->exec(); |
1121 | 1121 | ||
1122 | delete Dlg; | 1122 | delete Dlg; |
1123 | return; | 1123 | return; |
1124 | } | 1124 | } |