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 @@ -251,25 +251,24 @@ void Manager::searchConnections() { connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); *proc << "hcitool"; *proc << "con"; if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { ConnectionState::ValueList list; emit connections( list ); delete proc; } } void Manager::slotConnectionExited( OProcess* proc ) { - qWarning("<<<<<<<<<<<<<<<<<exited"); ConnectionState::ValueList list; list = parseConnections( m_hcitoolCon ); emit connections(list ); delete proc; } void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) { QCString str(cha, len ); m_hcitoolCon.append( str ); //delete proc; } ConnectionState::ValueList Manager::parseConnections( const QString& out ) { ConnectionState::ValueList list2; @@ -292,12 +291,44 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) { qWarning("8: %s", value[8].latin1() ); ConnectionState con; con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); con.setConnectionMode( value[1] ); con.setMac( value[2] ); con.setHandle( value[4].toInt() ); con.setState( value[6].toInt() ); con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); list2.append( con ); } 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 @@ -115,52 +115,59 @@ namespace OpieTooth { * Starts to connect to the device * in @param */ void connectTo(const QString& ); /** * Searches for active connections * the result is emitted with the * connections signal */ void searchConnections(); + void signalStrength( const QString &mac ); //// not implemented yet /*static*/ QString toDevice( const QString& mac ); /*static*/ QString toMac( const QString &device ); //// not implemented yet over signals: // device either mac or dev name // the first device is the device which you access void available( const QString& device, bool connected ); void addedService( const QString& service, bool added ); void removedService( const QString& service, bool removed ); 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* ); void slotSDPExited(OProcess*); void slotSDPOut(OProcess*, char*, int); void slotHCIExited(OProcess* ); void slotHCIOut(OProcess*, char*, int ); 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& ); ConnectionState::ValueList parseConnections( const QString& ); OProcess *m_hcitool; 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; }; }; #endif |