summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-07 22:55:36 (UTC)
committer harlekin <harlekin>2003-03-07 22:55:36 (UTC)
commitee1d48a9a5f3672f329301a844e69f2e184afcac (patch) (unidiff)
treea549cd37f837e2704527b7b40a0f9f8ef9372a7b
parenteeb28ead6d3050d662783696661d9360a049104f (diff)
downloadopie-ee1d48a9a5f3672f329301a844e69f2e184afcac.zip
opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.gz
opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.bz2
show signal strength for connections
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc33
-rw-r--r--noncore/net/opietooth/lib/manager.h7
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp40
-rw-r--r--noncore/net/opietooth/manager/bluebase.h5
-rw-r--r--noncore/net/opietooth/manager/bluetoothbase.ui14
-rw-r--r--noncore/net/opietooth/manager/btconnectionitem.cpp18
-rw-r--r--noncore/net/opietooth/manager/btconnectionitem.h8
7 files changed, 119 insertions, 6 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
@@ -262,3 +262,2 @@ void Manager::searchConnections() {
262void Manager::slotConnectionExited( OProcess* proc ) { 262void Manager::slotConnectionExited( OProcess* proc ) {
263 qWarning("<<<<<<<<<<<<<<<<<exited");
264 ConnectionState::ValueList list; 263 ConnectionState::ValueList list;
@@ -303 +302,33 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
303} 302}
303
304void 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
324void 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
332void 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
@@ -126,2 +126,3 @@ namespace OpieTooth {
126 126
127 void signalStrength( const QString &mac );
127//// not implemented yet 128//// not implemented yet
@@ -140,2 +141,3 @@ namespace OpieTooth {
140 void connections( ConnectionState::ValueList ); 141 void connections( ConnectionState::ValueList );
142 void signalStrength( const QString& mac, const QString& strengh );
141 143
@@ -152,2 +154,5 @@ private slots:
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:
@@ -159,4 +164,6 @@ private slots:
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;
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
@@ -74,2 +74,4 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
74 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); 74 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
75 connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
76 this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
75 77
@@ -100,2 +102,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
100 102
103
101 writeToHciConfig(); 104 writeToHciConfig();
@@ -103,2 +106,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
103 addConnectedDevices(); 106 addConnectedDevices();
107 addSignalStrength();
104 m_iconLoader = new BTIconLoader(); 108 m_iconLoader = new BTIconLoader();
@@ -372,3 +376,4 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
372/** 376/**
373 * Overloaded. This one it the one that is connected to the foundServices signal 377 * Overloaded. This one it the one that is
378 ted to the foundServices signal
374 * @param device the mac address of the remote device 379 * @param device the mac address of the remote device
@@ -427,2 +432,25 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
427 432
433
434
435
436void BlueBase::addSignalStrength() {
437
438 QListViewItemIterator it( ListView4 );
439 for ( ; it.current(); ++it ) {
440 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
441 }
442
443 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
444}
445
446void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) {
447
448 QListViewItemIterator it( ListView4 );
449 for ( ; it.current(); ++it ) {
450 if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) {
451 ((BTConnectionItem*)it.current() )->setSignalStrength( strength );
452 }
453 }
454}
455
428/** 456/**
@@ -435,3 +463,2 @@ void BlueBase::addConnectedDevices() {
435 463
436
437/** 464/**
@@ -451,4 +478,9 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
451 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 478 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
452 connectionItem = new BTConnectionItem( ListView4 , (*it) ); 479 connectionItem = new BTConnectionItem( ListView4, (*it) );
453 } 480
481 if( m_deviceList.find((*it).mac()).data() ) {
482
483 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
484 }
485 }
454 } else { 486 } else {
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
@@ -15,2 +15,3 @@
15#include "btdeviceitem.h" 15#include "btdeviceitem.h"
16
16#include "popuphelper.h" 17#include "popuphelper.h"
@@ -30,2 +31,3 @@ class QTabWidget;
30class QCheckBox; 31class QCheckBox;
32class BTConnectionItem;
31 33
@@ -57,2 +59,3 @@ namespace OpieTooth {
57 void setInfo(); 59 void setInfo();
60
58 PopupHelper m_popHelper; 61 PopupHelper m_popHelper;
@@ -86,2 +89,4 @@ namespace OpieTooth {
86 void applyConfigChanges(); 89 void applyConfigChanges();
90 void addSignalStrength();
91 void addSignalStrength( const QString& mac, const QString& strengh );
87 92
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
@@ -200,2 +200,16 @@
200 </column> 200 </column>
201 <column>
202 <property>
203 <name>text</name>
204 <string>Signal</string>
205 </property>
206 <property>
207 <name>clickable</name>
208 <bool>true</bool>
209 </property>
210 <property>
211 <name>resizeable</name>
212 <bool>true</bool>
213 </property>
214 </column>
201 <property stdset="1"> 215 <property stdset="1">
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
@@ -24 +24,19 @@ ConnectionState BTConnectionItem::connection() const {
24 24
25void BTConnectionItem::setName( QString name ) {
26 m_name = name;
27 setText( 0, m_name );
28}
29
30QString BTConnectionItem::name() {
31 return m_name;
32}
33
34
35void BTConnectionItem::setSignalStrength( QString strength ) {
36 m_signalStrength = strength;
37 setText( 2, m_signalStrength );
38}
39
40QString BTConnectionItem::signalStrength() {
41 return m_signalStrength;
42}
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
@@ -15,7 +15,13 @@ namespace OpieTooth {
15 QString type()const; 15 QString type()const;
16 QString name();
17 QString signalStrength();
16 int typeId() const; 18 int typeId() const;
17 ConnectionState connection()const; 19 ConnectionState connection()const;
20 void setSignalStrength( QString );
21 void setName( QString );
22
18 private: 23 private:
19 ConnectionState m_con; 24 ConnectionState m_con;
20 25 QString m_name;
26 QString m_signalStrength;
21 }; 27 };