summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/bluebase.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp261
1 files changed, 161 insertions, 100 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 2e68984..0ea45d2 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -24,7 +24,8 @@
-#include <remotedevice.h>
-#include <services.h>
-
-#include <stdlib.h>
+/* OPIE */
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+#include <qpe/config.h>
+/* QT */
#include <qframe.h>
@@ -48,6 +49,6 @@
-#include <qpe/qpeapplication.h>
-#include <qpe/resource.h>
-#include <qpe/config.h>
-
+/* STD */
+#include <remotedevice.h>
+#include <services.h>
+#include <stdlib.h>
@@ -56,3 +57,4 @@ using namespace OpieTooth;
BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
- : BluetoothBase( parent, name, fl ) {
+ : BluetoothBase( parent, name, fl )
+{
@@ -64,3 +66,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) );
-// not good since lib is async
+ // not good since lib is async
// connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
@@ -78,3 +80,3 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
- this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
+ this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
@@ -117,3 +119,4 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
*/
-void BlueBase::readConfig() {
+void BlueBase::readConfig()
+{
@@ -133,3 +136,4 @@ void BlueBase::readConfig() {
*/
-void BlueBase::writeConfig() {
+void BlueBase::writeConfig()
+{
@@ -151,3 +155,4 @@ void BlueBase::writeConfig() {
*/
-void BlueBase::writeToHciConfig() {
+void BlueBase::writeToHciConfig()
+{
qWarning("writeToHciConfig");
@@ -168,3 +173,4 @@ void BlueBase::writeToHciConfig() {
*/
-void BlueBase::readSavedDevices() {
+void BlueBase::readSavedDevices()
+{
@@ -181,3 +187,4 @@ void BlueBase::readSavedDevices() {
*/
-void BlueBase::writeSavedDevices() {
+void BlueBase::writeSavedDevices()
+{
QListViewItemIterator it( ListView2 );
@@ -186,3 +193,4 @@ void BlueBase::writeSavedDevices() {
RemoteDevice::ValueList list;
- for ( ; it.current(); ++it ) {
+ for ( ; it.current(); ++it )
+ {
item = (BTListItem*)it.current();
@@ -207,3 +215,4 @@ void BlueBase::writeSavedDevices() {
*/
-void BlueBase::initGui() {
+void BlueBase::initGui()
+{
StatusLabel->setText( status() ); // maybe move it to getStatus()
@@ -224,3 +233,4 @@ void BlueBase::initGui() {
*/
-QString BlueBase::status()const{
+QString BlueBase::status()const
+{
QString infoString = tr( "<b>Device name : </b> Ipaq" );
@@ -236,3 +246,4 @@ QString BlueBase::status()const{
*/
-void BlueBase::applyConfigChanges() {
+void BlueBase::applyConfigChanges()
+{
m_deviceName = deviceNameLine->text();
@@ -253,8 +264,8 @@ void BlueBase::applyConfigChanges() {
*/
-void BlueBase::rfcommDialog() {
+void BlueBase::rfcommDialog()
+{
RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp );
- rfcommAssign.showMaximized();
-
- if ( rfcommAssign.exec() == QDialog::Accepted ) {
+ if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted )
+ {
rfcommAssign.saveConfig();
@@ -267,3 +278,4 @@ void BlueBase::rfcommDialog() {
*/
-void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) {
+void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
+{
BTDeviceItem * deviceItem;
@@ -271,3 +283,4 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
- for( it = newDevices.begin(); it != newDevices.end() ; ++it ) {
+ for( it = newDevices.begin(); it != newDevices.end() ; ++it )
+ {
@@ -292,4 +305,4 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
*/
-void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
-}
+void BlueBase::startServiceActionClicked( QListViewItem */*item*/ )
+{}
@@ -299,3 +312,4 @@ void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
*/
-void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) {
+void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ )
+{
if (!item )
@@ -306,3 +320,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
- if ( ((BTListItem*)item)->type() == "device") {
+ if ( ((BTListItem*)item)->type() == "device")
+ {
@@ -318,3 +333,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
- switch(ret) {
+ switch(ret)
+ {
case -1:
@@ -345,3 +361,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
*/
- else if ( ((BTListItem*)item)->type() == "service") {
+ else if ( ((BTListItem*)item)->type() == "service")
+ {
BTServiceItem* service = (BTServiceItem*)item;
@@ -350,4 +367,5 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
QPopupMenu *popup =0l;
- if ( it != list.end() ) {
- qWarning("Searching id %d %s", it.key(), it.data().latin1() );
+ if ( it != list.end() )
+ {
+ qWarning("Searching id %d %s", it.key(), it.data().latin1() );
popup = m_popHelper.find( it.key(),
@@ -355,7 +373,10 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
(BTDeviceItem*)service->parent() );
- }else {
- qWarning("Empty");
- }
+ }
+ else
+ {
+ qWarning("Empty");
+ }
- if ( popup == 0l ) {
+ if ( popup == 0l )
+ {
qWarning("factory returned 0l");
@@ -367,5 +388,8 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
qWarning("returned from exec() ");
- if ( ret == -1 ) {
+ if ( ret == -1 )
+ {
;
- } else if ( ret == test1 ) {
+ }
+ else if ( ret == test1 )
+ {
;
@@ -382,3 +406,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
*/
-void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
+void BlueBase::addServicesToDevice( BTDeviceItem * item )
+{
qDebug("addServicesToDevice");
@@ -398,3 +423,4 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
*/
-void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
+void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList )
+{
qDebug("fill services list");
@@ -414,5 +440,6 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
QListViewItem * child = deviceItem->firstChild();
- while( child ) {
- tempList.append( child );
- child = child->nextSibling();
+ while( child )
+ {
+ tempList.append( child );
+ child = child->nextSibling();
}
@@ -424,3 +451,4 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
- if (!servicesList.isEmpty() ) {
+ if (!servicesList.isEmpty() )
+ {
// add services
@@ -428,3 +456,4 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
QMap<int, QString>::Iterator classIt;
- for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
+ for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 )
+ {
serviceItem = new BTServiceItem( deviceItem, (*it2) );
@@ -433,3 +462,4 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
int classId=0;
- if ( classIt != list.end() ) {
+ if ( classIt != list.end() )
+ {
classId = classIt.key();
@@ -439,3 +469,5 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
}
- } else {
+ }
+ else
+ {
Services s1;
@@ -452,20 +484,25 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s
-void BlueBase::addSignalStrength() {
+void BlueBase::addSignalStrength()
+{
- QListViewItemIterator it( ListView4 );
- for ( ; it.current(); ++it ) {
- m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
- }
+ QListViewItemIterator it( ListView4 );
+ for ( ; it.current(); ++it )
+ {
+ m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
+ }
- QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
+ QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
}
-void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) {
+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 );
- }
- }
+ QListViewItemIterator it( ListView4 );
+ for ( ; it.current(); ++it )
+ {
+ if( ((BTConnectionItem*)it.current())->connection().mac() == mac )
+ {
+ ((BTConnectionItem*)it.current() )->setSignalStrength( strength );
+ }
+ }
}
@@ -476,4 +513,5 @@ void BlueBase::addSignalStrength( const QString& mac, const QString& strength )
*/
-void BlueBase::addConnectedDevices() {
- m_localDevice->searchConnections();
+void BlueBase::addConnectedDevices()
+{
+ m_localDevice->searchConnections();
}
@@ -484,3 +522,4 @@ void BlueBase::addConnectedDevices() {
*/
-void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
+void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
+{
@@ -489,36 +528,46 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
- if ( !connectionList.isEmpty() ) {
+ if ( !connectionList.isEmpty() )
+ {
- for (it = connectionList.begin(); it != connectionList.end(); ++it) {
+ for (it = connectionList.begin(); it != connectionList.end(); ++it)
+ {
QListViewItemIterator it2( ListView4 );
- bool found = false;
- for ( ; it2.current(); ++it2 ) {
- if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) {
- found = true;
- }
- }
+ bool found = false;
+ for ( ; it2.current(); ++it2 )
+ {
+ if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() )
+ {
+ found = true;
+ }
+ }
- if ( found == false ) {
- connectionItem = new BTConnectionItem( ListView4, (*it) );
+ if ( found == false )
+ {
+ connectionItem = new BTConnectionItem( ListView4, (*it) );
- if( m_deviceList.find((*it).mac()).data() ) {
- connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
- }
- }
+ if( m_deviceList.find((*it).mac()).data() )
+ {
+ connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
+ }
+ }
- }
+ }
QListViewItemIterator it2( ListView4 );
- for ( ; it2.current(); ++it2 ) {
- bool found = false;
- for (it = connectionList.begin(); it != connectionList.end(); ++it) {
- if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) {
- found = true;
- }
+ for ( ; it2.current(); ++it2 )
+ {
+ bool found = false;
+ for (it = connectionList.begin(); it != connectionList.end(); ++it)
+ {
+ if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() )
+ {
+ found = true;
+ }
}
- if ( !found ) {
- delete it2.current();
- }
+ if ( !found )
+ {
+ delete it2.current();
+ }
@@ -527,3 +576,5 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
- } else {
+ }
+ else
+ {
ListView4->clear();
@@ -543,3 +594,4 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
*/
-void BlueBase::deviceActive( const RemoteDevice &device ) {
+void BlueBase::deviceActive( const RemoteDevice &device )
+{
// search by mac, async, gets a signal back
@@ -555,3 +607,4 @@ void BlueBase::deviceActive( const RemoteDevice &device ) {
*/
-void BlueBase::deviceActive( const QString& device, bool connected ) {
+void BlueBase::deviceActive( const QString& device, bool connected )
+{
qDebug("deviceActive slot");
@@ -567,5 +620,8 @@ void BlueBase::deviceActive( const QString& device, bool connected ) {
- if ( connected ) {
+ if ( connected )
+ {
deviceItem->setPixmap( 1, m_onPix );
- } else {
+ }
+ else
+ {
deviceItem->setPixmap( 1, m_offPix );
@@ -579,3 +635,4 @@ void BlueBase::deviceActive( const QString& device, bool connected ) {
*/
-void BlueBase::startScan() {
+void BlueBase::startScan()
+{
ScanDialog *scan = new ScanDialog( this, "ScanDialog",
@@ -585,3 +642,3 @@ void BlueBase::startScan() {
- scan->showMaximized();
+ QPEApplication::showDialog( scan );
}
@@ -592,3 +649,4 @@ void BlueBase::startScan() {
*/
-void BlueBase::setInfo() {
+void BlueBase::setInfo()
+{
StatusLabel->setText( status() );
@@ -600,3 +658,4 @@ void BlueBase::setInfo() {
*/
-BlueBase::~BlueBase() {
+BlueBase::~BlueBase()
+{
writeSavedDevices();
@@ -612,3 +671,4 @@ BlueBase::~BlueBase() {
*/
-bool BlueBase::find( const RemoteDevice& rem ) {
+bool BlueBase::find( const RemoteDevice& rem )
+{
QListViewItemIterator it( ListView2 );
@@ -616,3 +676,4 @@ bool BlueBase::find( const RemoteDevice& rem ) {
BTDeviceItem* device;
- for (; it.current(); ++it ) {
+ for (; it.current(); ++it )
+ {
item = (BTListItem*) it.current();