author | harlekin <harlekin> | 2003-03-07 22:55:36 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-07 22:55:36 (UTC) |
commit | ee1d48a9a5f3672f329301a844e69f2e184afcac (patch) (unidiff) | |
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 | |||
@@ -260,7 +260,6 @@ void Manager::searchConnections() { | |||
260 | } | 260 | } |
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 ); |
266 | emit connections(list ); | 265 | emit connections(list ); |
@@ -301,3 +300,35 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) { | |||
301 | } | 300 | } |
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 | |||
@@ -124,6 +124,7 @@ namespace OpieTooth { | |||
124 | */ | 124 | */ |
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 ); |
129 | /*static*/ QString toMac( const QString &device ); | 130 | /*static*/ QString toMac( const QString &device ); |
@@ -138,6 +139,7 @@ namespace OpieTooth { | |||
138 | void foundServices( const QString& device, Services::ValueList ); | 139 | void foundServices( const QString& device, Services::ValueList ); |
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: |
143 | void slotProcessExited(OProcess* ); | 145 | void slotProcessExited(OProcess* ); |
@@ -150,6 +152,9 @@ private slots: | |||
150 | 152 | ||
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& ); |
155 | RemoteDevice::ValueList parseHCIOutput( const QString& ); | 160 | RemoteDevice::ValueList parseHCIOutput( const QString& ); |
@@ -157,8 +162,10 @@ private slots: | |||
157 | OProcess *m_hcitool; | 162 | OProcess *m_hcitool; |
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 | }; |
164 | }; | 171 | }; |