From ee1d48a9a5f3672f329301a844e69f2e184afcac Mon Sep 17 00:00:00 2001 From: harlekin Date: Fri, 07 Mar 2003 22:55:36 +0000 Subject: show signal strength for connections --- (limited to 'noncore/net') diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index 8ddcfe8..c89d325 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc @@ -260,7 +260,6 @@ void Manager::searchConnections() { } } void Manager::slotConnectionExited( OProcess* proc ) { - qWarning("<<<<<<<<<<<<<<<<setName( mac.latin1() ); + + if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { + emit signalStrength( mac, "-1" ); + delete sig_proc; + } +} + +void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) { + QCString str(cha, len ); + QString temp = QString(str).stripWhiteSpace(); + QStringList value = QStringList::split(' ', temp ); + emit signalStrength( proc->name(), value[2].latin1() ); +} + + +void Manager::slotSignalStrengthExited( OProcess* proc ) { + delete proc; +} diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index 0ebe1b3..abc8ba1 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h @@ -124,6 +124,7 @@ namespace OpieTooth { */ void searchConnections(); + void signalStrength( const QString &mac ); //// not implemented yet /*static*/ QString toDevice( const QString& mac ); /*static*/ QString toMac( const QString &device ); @@ -138,6 +139,7 @@ namespace OpieTooth { void foundServices( const QString& device, Services::ValueList ); void foundDevices( const QString& device, RemoteDevice::ValueList ); void connections( ConnectionState::ValueList ); + void signalStrength( const QString& mac, const QString& strengh ); private slots: void slotProcessExited(OProcess* ); @@ -150,6 +152,9 @@ private slots: void slotConnectionExited(OProcess* ); void slotConnectionOutput(OProcess*, char*, int ); + + void slotSignalStrengthOutput( OProcess*, char*, int ); + void slotSignalStrengthExited( OProcess* ); private: Services::ValueList parseSDPOutput( const QString& ); RemoteDevice::ValueList parseHCIOutput( const QString& ); @@ -157,8 +162,10 @@ private slots: OProcess *m_hcitool; OProcess *m_sdp; // not only one QString m_device; + QMap m_signalStrength; QMap m_out; QMap m_devices; + QMap m_signalMac; QString m_hcitoolCon; }; }; 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 @@ -72,6 +72,8 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 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() @@ -98,9 +100,11 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) ListView2->setRootIsDecorated(true); + writeToHciConfig(); // search conncetions addConnectedDevices(); + addSignalStrength(); m_iconLoader = new BTIconLoader(); readSavedDevices(); } @@ -370,7 +374,8 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { /** - * 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. */ @@ -425,6 +430,29 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s } + + + +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 @@ -433,7 +461,6 @@ void BlueBase::addConnectedDevices() { m_localDevice->searchConnections(); } - /** * This adds the found connections to the connection tab. * @param connectionList the ValueList with all current connections @@ -449,8 +476,13 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) if ( !connectionList.isEmpty() ) { for (it = connectionList.begin(); it != connectionList.end(); ++it) { - connectionItem = new BTConnectionItem( ListView4 , (*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") ); diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 0326daf..743062c 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h @@ -13,6 +13,7 @@ #include "btserviceitem.h" #include "btdeviceitem.h" + #include "popuphelper.h" #include "bticonloader.h" @@ -28,6 +29,7 @@ class QLabel; class QPushButton; class QTabWidget; class QCheckBox; +class BTConnectionItem; namespace OpieTooth { @@ -55,6 +57,7 @@ namespace OpieTooth { QString status()const; void initGui(); void setInfo(); + PopupHelper m_popHelper; Manager *m_localDevice; QMap m_deviceList; @@ -84,6 +87,8 @@ namespace OpieTooth { void startServiceActionHold( QListViewItem *, const QPoint &, int ); void deviceActive( const QString& mac, bool connected ); void applyConfigChanges(); + void addSignalStrength(); + void addSignalStrength( const QString& mac, const QString& strengh ); }; diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index 869a9cb..b51c8c6 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -198,6 +198,20 @@ true + + + text + Signal + + + clickable + true + + + resizeable + true + + name ListView4 diff --git a/noncore/net/opietooth/manager/btconnectionitem.cpp b/noncore/net/opietooth/manager/btconnectionitem.cpp index b57d1b3..c565c47 100644 --- a/noncore/net/opietooth/manager/btconnectionitem.cpp +++ b/noncore/net/opietooth/manager/btconnectionitem.cpp @@ -22,3 +22,21 @@ ConnectionState BTConnectionItem::connection() const { return m_con; } +void BTConnectionItem::setName( QString name ) { + m_name = name; + setText( 0, m_name ); +} + +QString BTConnectionItem::name() { + return m_name; +} + + +void BTConnectionItem::setSignalStrength( QString strength ) { + m_signalStrength = strength; + setText( 2, m_signalStrength ); +} + +QString BTConnectionItem::signalStrength() { + return m_signalStrength; +} diff --git a/noncore/net/opietooth/manager/btconnectionitem.h b/noncore/net/opietooth/manager/btconnectionitem.h index 3c0cd79..9ab745e 100644 --- a/noncore/net/opietooth/manager/btconnectionitem.h +++ b/noncore/net/opietooth/manager/btconnectionitem.h @@ -13,11 +13,17 @@ namespace OpieTooth { BTConnectionItem( QListView* parent, const ConnectionState& state ); ~BTConnectionItem(); QString type()const; + QString name(); + QString signalStrength(); int typeId() const; ConnectionState connection()const; + void setSignalStrength( QString ); + void setName( QString ); + private: ConnectionState m_con; - + QString m_name; + QString m_signalStrength; }; }; -- cgit v0.9.0.2