summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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.cpp36
-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, 117 insertions, 4 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() {
void Manager::slotConnectionExited( OProcess* proc ) {
- qWarning("<<<<<<<<<<<<<<<<<exited");
ConnectionState::ValueList list;
@@ -303 +302,33 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
}
+
+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
@@ -126,2 +126,3 @@ namespace OpieTooth {
+ void signalStrength( const QString &mac );
//// not implemented yet
@@ -140,2 +141,3 @@ namespace OpieTooth {
void connections( ConnectionState::ValueList );
+ void signalStrength( const QString& mac, const QString& strengh );
@@ -152,2 +154,5 @@ private slots:
void slotConnectionOutput(OProcess*, char*, int );
+
+ void slotSignalStrengthOutput( OProcess*, char*, int );
+ void slotSignalStrengthExited( OProcess* );
private:
@@ -159,4 +164,6 @@ private slots:
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;
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 )
this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
+ connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
+ this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
@@ -100,2 +102,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
+
writeToHciConfig();
@@ -103,2 +106,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
addConnectedDevices();
+ addSignalStrength();
m_iconLoader = new BTIconLoader();
@@ -372,3 +376,4 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
/**
- * Overloaded. This one it the one that is connected to the foundServices signal
+ * Overloaded. This one it the one that is
+ ted to the foundServices signal
* @param device the mac address of the remote device
@@ -427,2 +432,25 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
+
+
+
+void BlueBase::addSignalStrength() {
+
+ QListViewItemIterator it( ListView4 );
+ for ( ; it.current(); ++it ) {
+ m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
+ }
+
+ QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
+}
+
+void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) {
+
+ QListViewItemIterator it( ListView4 );
+ for ( ; it.current(); ++it ) {
+ if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) {
+ ((BTConnectionItem*)it.current() )->setSignalStrength( strength );
+ }
+ }
+}
+
/**
@@ -435,3 +463,2 @@ void BlueBase::addConnectedDevices() {
-
/**
@@ -452,2 +479,7 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
connectionItem = new BTConnectionItem( ListView4 , (*it) );
+
+ if( m_deviceList.find((*it).mac()).data() ) {
+
+ connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
+ }
}
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 @@
#include "btdeviceitem.h"
+
#include "popuphelper.h"
@@ -30,2 +31,3 @@ class QTabWidget;
class QCheckBox;
+class BTConnectionItem;
@@ -57,2 +59,3 @@ namespace OpieTooth {
void setInfo();
+
PopupHelper m_popHelper;
@@ -86,2 +89,4 @@ namespace OpieTooth {
void applyConfigChanges();
+ void addSignalStrength();
+ void addSignalStrength( const QString& mac, const QString& strengh );
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 @@
</column>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Signal</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
<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 {
+void BTConnectionItem::setName( QString name ) {
+ m_name = name;
+ setText( 0, m_name );
+}
+
+QString BTConnectionItem::name() {
+ return m_name;
+}
+
+
+void BTConnectionItem::setSignalStrength( QString strength ) {
+ m_signalStrength = strength;
+ setText( 2, m_signalStrength );
+}
+
+QString BTConnectionItem::signalStrength() {
+ return m_signalStrength;
+}
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 {
QString type()const;
+ QString name();
+ QString signalStrength();
int typeId() const;
ConnectionState connection()const;
+ void setSignalStrength( QString );
+ void setName( QString );
+
private:
ConnectionState m_con;
-
+ QString m_name;
+ QString m_signalStrength;
};