-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() { | |||
261 | } | 261 | } |
262 | void Manager::slotConnectionExited( OProcess* proc ) { | 262 | void Manager::slotConnectionExited( OProcess* proc ) { |
263 | qWarning("<<<<<<<<<<<<<<<<<exited"); | ||
264 | ConnectionState::ValueList list; | 263 | ConnectionState::ValueList list; |
265 | list = parseConnections( m_hcitoolCon ); | 264 | list = parseConnections( m_hcitoolCon ); |
@@ -302,2 +301,34 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) { | |||
302 | return list2; | 301 | return list2; |
303 | } | 302 | } |
303 | |||
304 | void Manager::signalStrength( const QString &mac ) { | ||
305 | |||
306 | OProcess* sig_proc = new OProcess(); | ||
307 | |||
308 | connect(sig_proc, SIGNAL(processExited(OProcess*) ), | ||
309 | this, SLOT(slotSignalStrengthExited( OProcess*) ) ); | ||
310 | connect(sig_proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), | ||
311 | this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); | ||
312 | *sig_proc << "hcitool"; | ||
313 | *sig_proc << "lq"; | ||
314 | *sig_proc << mac; | ||
315 | |||
316 | sig_proc->setName( mac.latin1() ); | ||
317 | |||
318 | if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | ||
319 | emit signalStrength( mac, "-1" ); | ||
320 | delete sig_proc; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) { | ||
325 | QCString str(cha, len ); | ||
326 | QString temp = QString(str).stripWhiteSpace(); | ||
327 | QStringList value = QStringList::split(' ', temp ); | ||
328 | emit signalStrength( proc->name(), value[2].latin1() ); | ||
329 | } | ||
330 | |||
331 | |||
332 | void Manager::slotSignalStrengthExited( OProcess* proc ) { | ||
333 | delete proc; | ||
334 | } | ||
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 { | |||
125 | void searchConnections(); | 125 | void searchConnections(); |
126 | 126 | ||
127 | void signalStrength( const QString &mac ); | ||
127 | //// not implemented yet | 128 | //// not implemented yet |
128 | /*static*/ QString toDevice( const QString& mac ); | 129 | /*static*/ QString toDevice( const QString& mac ); |
@@ -139,4 +140,5 @@ namespace OpieTooth { | |||
139 | void foundDevices( const QString& device, RemoteDevice::ValueList ); | 140 | void foundDevices( const QString& device, RemoteDevice::ValueList ); |
140 | void connections( ConnectionState::ValueList ); | 141 | void connections( ConnectionState::ValueList ); |
142 | void signalStrength( const QString& mac, const QString& strengh ); | ||
141 | 143 | ||
142 | private slots: | 144 | private slots: |
@@ -151,4 +153,7 @@ private slots: | |||
151 | void slotConnectionExited(OProcess* ); | 153 | void slotConnectionExited(OProcess* ); |
152 | void slotConnectionOutput(OProcess*, char*, int ); | 154 | void slotConnectionOutput(OProcess*, char*, int ); |
155 | |||
156 | void slotSignalStrengthOutput( OProcess*, char*, int ); | ||
157 | void slotSignalStrengthExited( OProcess* ); | ||
153 | private: | 158 | private: |
154 | Services::ValueList parseSDPOutput( const QString& ); | 159 | Services::ValueList parseSDPOutput( const QString& ); |
@@ -158,6 +163,8 @@ private slots: | |||
158 | OProcess *m_sdp; // not only one | 163 | OProcess *m_sdp; // not only one |
159 | QString m_device; | 164 | QString m_device; |
165 | QMap<QString, int> m_signalStrength; | ||
160 | QMap<QString, QString> m_out; | 166 | QMap<QString, QString> m_out; |
161 | QMap<QString, QString> m_devices; | 167 | QMap<QString, QString> m_devices; |
168 | QMap<OProcess*, QString> m_signalMac; | ||
162 | QString m_hcitoolCon; | 169 | QString m_hcitoolCon; |
163 | }; | 170 | }; |