Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 8b15c4f..9663b52 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -67,16 +67,18 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
67 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 67 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
68 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 68 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
69 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 69 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
70 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 70 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
71 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 71 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
72 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 72 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
73 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), | 73 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
74 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); | 74 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
75 | connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), | ||
76 | this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); | ||
75 | 77 | ||
76 | 78 | ||
77 | // let hold be rightButtonClicked() | 79 | // let hold be rightButtonClicked() |
78 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); | 80 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); |
79 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); | 81 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); |
80 | 82 | ||
81 | //Load all icons needed | 83 | //Load all icons needed |
82 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); | 84 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); |
@@ -93,19 +95,21 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
93 | 95 | ||
94 | setCaption( tr( "Bluetooth Manager" ) ); | 96 | setCaption( tr( "Bluetooth Manager" ) ); |
95 | 97 | ||
96 | readConfig(); | 98 | readConfig(); |
97 | initGui(); | 99 | initGui(); |
98 | 100 | ||
99 | ListView2->setRootIsDecorated(true); | 101 | ListView2->setRootIsDecorated(true); |
100 | 102 | ||
103 | |||
101 | writeToHciConfig(); | 104 | writeToHciConfig(); |
102 | // search conncetions | 105 | // search conncetions |
103 | addConnectedDevices(); | 106 | addConnectedDevices(); |
107 | addSignalStrength(); | ||
104 | m_iconLoader = new BTIconLoader(); | 108 | m_iconLoader = new BTIconLoader(); |
105 | readSavedDevices(); | 109 | readSavedDevices(); |
106 | } | 110 | } |
107 | 111 | ||
108 | /** | 112 | /** |
109 | * Reads all options from the config file | 113 | * Reads all options from the config file |
110 | */ | 114 | */ |
111 | void BlueBase::readConfig() { | 115 | void BlueBase::readConfig() { |
@@ -365,17 +369,18 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | |||
365 | RemoteDevice device = item->remoteDevice(); | 369 | RemoteDevice device = item->remoteDevice(); |
366 | m_deviceList.insert( item->mac() , item ); | 370 | m_deviceList.insert( item->mac() , item ); |
367 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 371 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
368 | m_localDevice->searchServices( device ); | 372 | m_localDevice->searchServices( device ); |
369 | } | 373 | } |
370 | 374 | ||
371 | 375 | ||
372 | /** | 376 | /** |
373 | * Overloaded. This one it the one that is connected to the foundServices signal | 377 | * Overloaded. This one it the one that is |
378 | ted to the foundServices signal | ||
374 | * @param device the mac address of the remote device | 379 | * @param device the mac address of the remote device |
375 | * @param servicesList the list with the service the device has. | 380 | * @param servicesList the list with the service the device has. |
376 | */ | 381 | */ |
377 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 382 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
378 | qDebug("fill services list"); | 383 | qDebug("fill services list"); |
379 | 384 | ||
380 | QMap<QString,BTDeviceItem*>::Iterator it; | 385 | QMap<QString,BTDeviceItem*>::Iterator it; |
381 | BTDeviceItem* deviceItem = 0; | 386 | BTDeviceItem* deviceItem = 0; |
@@ -420,42 +425,69 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s | |||
420 | s1.setServiceName( tr("no services found") ); | 425 | s1.setServiceName( tr("no services found") ); |
421 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 426 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
422 | } | 427 | } |
423 | // now remove them from the list | 428 | // now remove them from the list |
424 | m_deviceList.remove( it ); | 429 | m_deviceList.remove( it ); |
425 | } | 430 | } |
426 | 431 | ||
427 | 432 | ||
433 | |||
434 | |||
435 | |||
436 | void BlueBase::addSignalStrength() { | ||
437 | |||
438 | QListViewItemIterator it( ListView4 ); | ||
439 | for ( ; it.current(); ++it ) { | ||
440 | m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); | ||
441 | } | ||
442 | |||
443 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); | ||
444 | } | ||
445 | |||
446 | void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { | ||
447 | |||
448 | QListViewItemIterator it( ListView4 ); | ||
449 | for ( ; it.current(); ++it ) { | ||
450 | if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { | ||
451 | ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); | ||
452 | } | ||
453 | } | ||
454 | } | ||
455 | |||
428 | /** | 456 | /** |
429 | * Add the existing connections (pairs) to the connections tab. | 457 | * Add the existing connections (pairs) to the connections tab. |
430 | * This one triggers the search | 458 | * This one triggers the search |
431 | */ | 459 | */ |
432 | void BlueBase::addConnectedDevices() { | 460 | void BlueBase::addConnectedDevices() { |
433 | m_localDevice->searchConnections(); | 461 | m_localDevice->searchConnections(); |
434 | } | 462 | } |
435 | 463 | ||
436 | |||
437 | /** | 464 | /** |
438 | * This adds the found connections to the connection tab. | 465 | * This adds the found connections to the connection tab. |
439 | * @param connectionList the ValueList with all current connections | 466 | * @param connectionList the ValueList with all current connections |
440 | */ | 467 | */ |
441 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 468 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
442 | 469 | ||
443 | // clear the ListView first | 470 | // clear the ListView first |
444 | ListView4->clear(); | 471 | ListView4->clear(); |
445 | 472 | ||
446 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 473 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
447 | BTConnectionItem * connectionItem; | 474 | BTConnectionItem * connectionItem; |
448 | 475 | ||
449 | if ( !connectionList.isEmpty() ) { | 476 | if ( !connectionList.isEmpty() ) { |
450 | 477 | ||
451 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 478 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
452 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); | 479 | connectionItem = new BTConnectionItem( ListView4, (*it) ); |
453 | } | 480 | |
481 | if( m_deviceList.find((*it).mac()).data() ) { | ||
482 | |||
483 | connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); | ||
484 | } | ||
485 | } | ||
454 | } else { | 486 | } else { |
455 | ConnectionState con; | 487 | ConnectionState con; |
456 | con.setMac( tr("No connections found") ); | 488 | con.setMac( tr("No connections found") ); |
457 | connectionItem = new BTConnectionItem( ListView4 , con ); | 489 | connectionItem = new BTConnectionItem( ListView4 , con ); |
458 | } | 490 | } |
459 | 491 | ||
460 | // recall connection search after some time | 492 | // recall connection search after some time |
461 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); | 493 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); |