summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-07 22:55:36 (UTC)
committer harlekin <harlekin>2003-03-07 22:55:36 (UTC)
commitee1d48a9a5f3672f329301a844e69f2e184afcac (patch) (side-by-side diff)
treea549cd37f837e2704527b7b40a0f9f8ef9372a7b
parenteeb28ead6d3050d662783696661d9360a049104f (diff)
downloadopie-ee1d48a9a5f3672f329301a844e69f2e184afcac.zip
opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.gz
opie-ee1d48a9a5f3672f329301a844e69f2e184afcac.tar.bz2
show signal strength for connections
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
@@ -257,13 +257,12 @@ void Manager::searchConnections() {
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) {
@@ -298,6 +297,38 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
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
@@ -121,12 +121,13 @@ namespace OpieTooth {
* 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:
@@ -135,32 +136,38 @@ namespace OpieTooth {
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
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
@@ -69,12 +69,14 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
this, SLOT( deviceActive( const QString& , bool ) ) );
connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
+ connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
+ this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
// let hold be rightButtonClicked()
QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold);
QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold);
@@ -95,15 +97,17 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
readConfig();
initGui();
ListView2->setRootIsDecorated(true);
+
writeToHciConfig();
// search conncetions
addConnectedDevices();
+ addSignalStrength();
m_iconLoader = new BTIconLoader();
readSavedDevices();
}
/**
* Reads all options from the config file
@@ -367,13 +371,14 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
m_localDevice->searchServices( device );
}
/**
- * 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
* @param servicesList the list with the service the device has.
*/
void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
qDebug("fill services list");
@@ -422,21 +427,43 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
}
// now remove them from the list
m_deviceList.remove( it );
}
+
+
+
+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 );
+ }
+ }
+}
+
/**
* Add the existing connections (pairs) to the connections tab.
* This one triggers the search
*/
void BlueBase::addConnectedDevices() {
m_localDevice->searchConnections();
}
-
/**
* This adds the found connections to the connection tab.
* @param connectionList the ValueList with all current connections
*/
void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
@@ -447,12 +474,17 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
BTConnectionItem * connectionItem;
if ( !connectionList.isEmpty() ) {
for (it = connectionList.begin(); it != connectionList.end(); ++it) {
connectionItem = new BTConnectionItem( ListView4 , (*it) );
+
+ if( m_deviceList.find((*it).mac()).data() ) {
+
+ connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
+ }
}
} else {
ConnectionState con;
con.setMac( tr("No connections found") );
connectionItem = new BTConnectionItem( ListView4 , con );
}
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
@@ -10,12 +10,13 @@
#include <qpixmap.h>
#include "bluetoothbase.h"
#include "btserviceitem.h"
#include "btdeviceitem.h"
+
#include "popuphelper.h"
#include "bticonloader.h"
#include <remotedevice.h>
#include <manager.h>
@@ -25,12 +26,13 @@ class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QPushButton;
class QTabWidget;
class QCheckBox;
+class BTConnectionItem;
namespace OpieTooth {
class BlueBase : public BluetoothBase {
Q_OBJECT
@@ -52,12 +54,13 @@ namespace OpieTooth {
void readSavedDevices();
void writeSavedDevices();
void writeToHciConfig();
QString status()const;
void initGui();
void setInfo();
+
PopupHelper m_popHelper;
Manager *m_localDevice;
QMap<QString,BTDeviceItem*> m_deviceList;
void deviceActive( const RemoteDevice &device );
@@ -81,12 +84,14 @@ namespace OpieTooth {
void addConnectedDevices();
void addConnectedDevices( ConnectionState::ValueList );
void startServiceActionClicked( QListViewItem *item );
void startServiceActionHold( QListViewItem *, const QPoint &, int );
void deviceActive( const QString& mac, bool connected );
void applyConfigChanges();
+ void addSignalStrength();
+ void addSignalStrength( const QString& mac, const QString& strengh );
};
}
#endif
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
@@ -195,12 +195,26 @@
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</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">
<name>name</name>
<cstring>ListView4</cstring>
</property>
<property stdset="1">
<name>geometry</name>
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
@@ -19,6 +19,24 @@ int BTConnectionItem::typeId() const {
return Connection;
}
ConnectionState BTConnectionItem::connection() const {
return m_con;
}
+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
@@ -10,17 +10,23 @@ namespace OpieTooth {
class ConnectionState;
class BTConnectionItem : public BTListItem {
public:
BTConnectionItem( QListView* parent, const ConnectionState& state );
~BTConnectionItem();
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;
};
};
#endif