Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 36 |
1 files changed, 34 insertions, 2 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 ) connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), this, SLOT( deviceActive( const QString& , bool ) ) ); connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); + connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), + this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); // let hold be rightButtonClicked() QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); //Load all icons needed m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); @@ -93,19 +95,21 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) setCaption( tr( "Bluetooth Manager" ) ); readConfig(); initGui(); ListView2->setRootIsDecorated(true); + writeToHciConfig(); // search conncetions addConnectedDevices(); + addSignalStrength(); m_iconLoader = new BTIconLoader(); readSavedDevices(); } /** * Reads all options from the config file */ void BlueBase::readConfig() { @@ -365,17 +369,18 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { RemoteDevice device = item->remoteDevice(); m_deviceList.insert( item->mac() , item ); // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back m_localDevice->searchServices( device ); } /** - * Overloaded. This one it the one that is connected to the foundServices signal + * Overloaded. This one it the one that is + ted to the foundServices signal * @param device the mac address of the remote device * @param servicesList the list with the service the device has. */ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { qDebug("fill services list"); QMap<QString,BTDeviceItem*>::Iterator it; BTDeviceItem* deviceItem = 0; @@ -420,41 +425,68 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s s1.setServiceName( tr("no services found") ); serviceItem = new BTServiceItem( deviceItem, s1 ); } // now remove them from the list m_deviceList.remove( it ); } + + + +void BlueBase::addSignalStrength() { + + QListViewItemIterator it( ListView4 ); + for ( ; it.current(); ++it ) { + m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); + } + + QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); +} + +void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { + + QListViewItemIterator it( ListView4 ); + for ( ; it.current(); ++it ) { + if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { + ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); + } + } +} + /** * Add the existing connections (pairs) to the connections tab. * This one triggers the search */ void BlueBase::addConnectedDevices() { m_localDevice->searchConnections(); } - /** * This adds the found connections to the connection tab. * @param connectionList the ValueList with all current connections */ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { // clear the ListView first ListView4->clear(); QValueList<OpieTooth::ConnectionState>::Iterator it; BTConnectionItem * connectionItem; if ( !connectionList.isEmpty() ) { for (it = connectionList.begin(); it != connectionList.end(); ++it) { connectionItem = new BTConnectionItem( ListView4 , (*it) ); + + if( m_deviceList.find((*it).mac()).data() ) { + + connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); + } } } else { ConnectionState con; con.setMac( tr("No connections found") ); connectionItem = new BTConnectionItem( ListView4 , con ); } // recall connection search after some time |