author | harlekin <harlekin> | 2003-03-07 22:55:36 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-07 22:55:36 (UTC) |
commit | ee1d48a9a5f3672f329301a844e69f2e184afcac (patch) (side-by-side diff) | |
tree | a549cd37f837e2704527b7b40a0f9f8ef9372a7b /noncore/net/opietooth/lib | |
parent | eeb28ead6d3050d662783696661d9360a049104f (diff) | |
download | opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.zip opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.gz opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.bz2 |
show signal strength for connections
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 33 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 7 |
2 files changed, 39 insertions, 1 deletions
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 @@ -261,5 +261,4 @@ void Manager::searchConnections() { } void Manager::slotConnectionExited( OProcess* proc ) { - qWarning("<<<<<<<<<<<<<<<<<exited"); ConnectionState::ValueList list; list = parseConnections( m_hcitoolCon ); @@ -302,2 +301,34 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) { return list2; } + +void Manager::signalStrength( const QString &mac ) { + + OProcess* sig_proc = new OProcess(); + + connect(sig_proc, SIGNAL(processExited(OProcess*) ), + this, SLOT(slotSignalStrengthExited( OProcess*) ) ); + connect(sig_proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), + this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); + *sig_proc << "hcitool"; + *sig_proc << "lq"; + *sig_proc << mac; + + sig_proc->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 @@ -125,4 +125,5 @@ namespace OpieTooth { void searchConnections(); + void signalStrength( const QString &mac ); //// not implemented yet /*static*/ QString toDevice( const QString& mac ); @@ -139,4 +140,5 @@ namespace OpieTooth { void foundDevices( const QString& device, RemoteDevice::ValueList ); void connections( ConnectionState::ValueList ); + void signalStrength( const QString& mac, const QString& strengh ); private slots: @@ -151,4 +153,7 @@ private slots: void slotConnectionExited(OProcess* ); void slotConnectionOutput(OProcess*, char*, int ); + + void slotSignalStrengthOutput( OProcess*, char*, int ); + void slotSignalStrengthExited( OProcess* ); private: Services::ValueList parseSDPOutput( const QString& ); @@ -158,6 +163,8 @@ private slots: OProcess *m_sdp; // not only one QString m_device; + QMap<QString, int> m_signalStrength; QMap<QString, QString> m_out; QMap<QString, QString> m_devices; + QMap<OProcess*, QString> m_signalMac; QString m_hcitoolCon; }; |