summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp7
-rw-r--r--noncore/net/opietooth/manager/btlistitem.cpp22
-rw-r--r--noncore/net/opietooth/manager/btlistitem.h16
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.cpp4
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.h4
-rw-r--r--noncore/net/opietooth/manager/main.cpp4
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp10
-rw-r--r--noncore/net/opietooth/manager/scandialog.h2
8 files changed, 31 insertions, 38 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index ff6981b..8ddc161 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -307,151 +307,152 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
menu->insertItem( tr("delete"), 2);
ret = menu->exec( point , 0);
switch(ret) {
case 0:
break;
case 1:
break;
case 2:
// delete childs too
delete item;
break;
}
}
delete menu;
}
/**
* Search and display avail. services for a device (on expand from device listing)
*
*/
void BlueBase::addServicesToDevice( BTListItem * item ) {
qDebug("addServicesToDevice");
// row of mac adress text(3)
RemoteDevice device( item->mac(), item->name() );
m_deviceList.insert( item->mac() , 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
* @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");
QMap<QString,BTListItem*>::Iterator it;
BTListItem* deviceItem = 0;
// get the right devices which requested the search
for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) {
if ( it.key() == device ) {
deviceItem = it.data();
}
}
QValueList<OpieTooth::Services>::Iterator it2;
BTListItem * serviceItem;
if (!servicesList.isEmpty() ) {
// add services
for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" );
serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) );
}
} else {
serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" );
}
}
/**
* Add the existing connections (pairs) to the connections tab.
* This one triggers the search
*/
void BlueBase::addConnectedDevices() {
m_localDevice->searchConnections();
}
void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) {
QValueList<OpieTooth::Connection>::Iterator it;
BTListItem * connectionItem;
if ( !connectionList.isEmpty() ) {
for (it = connectionList.begin(); it != connectionList.end(); ++it) {
connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" );
}
} else {
connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" );
}
// recall connection search after some time
QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) );
}
/**
* Find out if a device can currently be reached
*/
void BlueBase::deviceActive( const RemoteDevice &device ) {
// search by mac, async, gets a signal back
m_localDevice->isAvailable( device.mac() );
}
/**
* The signal catcher. Set the avail. status on device.
* @param device - the mac address
* @param connected - if it is avail. or not
*/
void BlueBase::deviceActive( const QString& device, bool connected ) {
qDebug("deviceActive slot");
QMap<QString,BTListItem*>::Iterator it;
BTListItem* deviceItem = 0;
// get the right devices which requested the search
for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) {
if ( it.key() == device ) {
deviceItem = it.data();
}
}
if ( connected ) {
deviceItem->setPixmap( 1, m_onPix );
} else {
deviceItem->setPixmap( 1, m_offPix );
}
}
/**
* Open the "scan for devices" dialog
*/
void BlueBase::startScan() {
- ScanDialog *scan = new ScanDialog( this, "", true);
- QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ),
- this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) );
+ ScanDialog *scan = new ScanDialog( this, "ScanDialog",
+ true, WDestructiveClose );
+ QObject::connect( scan, SIGNAL( selectedDevices( QValueList<RemoteDevice>& ) ),
+ this, SLOT( addSearchedDevices( QValueList<RemoteDevice>& ) ) );
scan->showMaximized();
}
/**
* Set the informations about the local device in information Tab
*/
void BlueBase::setInfo() {
StatusLabel->setText( status() );
}
/**
* Decontructor
*/
BlueBase::~BlueBase() {
writeSavedDevices();
delete m_iconLoader;
}
diff --git a/noncore/net/opietooth/manager/btlistitem.cpp b/noncore/net/opietooth/manager/btlistitem.cpp
index ce5b141..82e7c00 100644
--- a/noncore/net/opietooth/manager/btlistitem.cpp
+++ b/noncore/net/opietooth/manager/btlistitem.cpp
@@ -1,67 +1,61 @@
#include "btlistitem.h"
namespace OpieTooth {
BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) {
- m_name = "";
- m_mac ="";
- m_type ="";
}
BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) {
- m_name = "";
- m_mac ="";
- m_type ="";
}
// name, and then mac and then servicetype
- BTListItem::BTListItem( QListView * parent, QString name , QString mac, QString type )
+ BTListItem::BTListItem( QListView * parent, const QString &name , const QString& mac, const QString& type )
: QListViewItem( parent, name ){
m_name = name;
m_mac = mac;
m_type = type;
}
- BTListItem::BTListItem( QListViewItem * parent , QString name, QString mac, QString type )
+ BTListItem::BTListItem( QListViewItem * parent , const QString& name, const QString& mac, const QString& type )
: QListViewItem( parent, name ){
m_name = name;
m_mac = mac;
m_type = type;
}
- void BTListItem::setMac( QString mac ) {
+ void BTListItem::setMac( const QString& mac ) {
m_mac = mac;
}
- QString BTListItem::mac() {
+ QString BTListItem::mac() const {
return m_mac;
}
- void BTListItem::setName( QString name ) {
+ void BTListItem::setName( const QString& name ) {
m_name = name;
}
- QString BTListItem::name() {
+ QString BTListItem::name() const {
return m_name;
}
- void BTListItem::setType( QString type ) {
+ void BTListItem::setType( const QString& type ) {
m_type = type;
}
- QString BTListItem::type() {
+ QString BTListItem::type() const {
return m_type;
}
BTListItem::~BTListItem() {
}
};
diff --git a/noncore/net/opietooth/manager/btlistitem.h b/noncore/net/opietooth/manager/btlistitem.h
index 8963caa..d7ce03b 100644
--- a/noncore/net/opietooth/manager/btlistitem.h
+++ b/noncore/net/opietooth/manager/btlistitem.h
@@ -1,33 +1,33 @@
#ifndef BTLISTITEM_H
#define BTLISTITEM_H
#include <qlistview.h>
namespace OpieTooth {
class BTListItem : public QListViewItem {
public:
BTListItem( QListView * parent );
BTListItem( QListViewItem * parent );
// name, and then mac and then servicetype
- BTListItem( QListView * , QString, QString, QString );
- BTListItem( QListViewItem * parent , QString, QString , QString );
+ BTListItem( QListView * , const QString&, const QString&, const QString& );
+ BTListItem( QListViewItem * parent , const QString&, const QString& , const QString& );
~BTListItem();
- void setMac( QString );
- QString mac();
- void setName( QString );
- QString name();
- void setType( QString );
- QString type();
+ void setMac( const QString& );
+ QString mac()const;
+ void setName( const QString& );
+ QString name()const;
+ void setType( const QString& );
+ QString type()const;
private:
QString m_name;
QString m_mac;
QString m_type;
};
};
#endif
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp
index 0b90e87..5f74fee 100644
--- a/noncore/net/opietooth/manager/hciconfwrapper.cpp
+++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp
@@ -1,112 +1,112 @@
#include "hciconfwrapper.h"
#include <qfile.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <qregexp.h>
namespace OpieTooth {
HciConfWrapper::HciConfWrapper( const QString &fileName) {
m_fileName = fileName;
}
HciConfWrapper::~HciConfWrapper() {
}
- void HciConfWrapper::setPinHelper( QString app ) {
+ void HciConfWrapper::setPinHelper( const QString& app ) {
setValue( "pin_helper" , app );
}
- void HciConfWrapper::setName( QString name ) {
+ void HciConfWrapper::setName( const QString &name ) {
qDebug ("NAME : " + name);
setValue( "name" , "\"" + name + "\"" );
}
void HciConfWrapper::setIscan( bool enable) {
if ( enable ) {
setValue( "iscan" , "enable" );
} else {
setValue( "iscan" , "disable" );
}
}
void HciConfWrapper::setPscan( bool enable) {
if ( enable ) {
setValue( "pscan" , "enable" );
} else {
setValue( "pscan" , "disable" );
}
}
void HciConfWrapper::setAuth( bool enable) {
if ( enable ) {
setValue( "auth" , "enable" );
} else {
setValue( "auth" , "disable" );
}
}
void HciConfWrapper::setEncrypt( bool enable) {
if ( enable ) {
setValue( "encrypt" , "enable" );
} else {
setValue( "encrypt" , "disable" );
}
}
void HciConfWrapper::setValue(const QString &key, const QString &value ) {
QFile f( m_fileName );
QFile f2( m_fileName );
if ( !f.open( IO_ReadOnly) ) {
qDebug("Could not open readonly");
return;
}
if ( !f2.open( IO_ReadWrite ) ) {
qDebug("Just readonly - not enough");
return;
}
QStringList list;
qDebug(m_fileName);
QTextStream stream ( &f);
QTextStream outstream (&f2);
QString str;
while ( !(str=stream.readLine()).isNull() ) {
//qDebug(str);
if( (str.contains(key)) > 0 ) {
qDebug("Found");
// still need to look if its commented out!!!
str.simplifyWhiteSpace();
qDebug( key );
if (str.startsWith("#")) {
str = (key + " " + value + ";");
} else {
str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";");
}
qDebug( str );
}
outstream << str << endl;
}
f.close();
f2.flush();
f2.close();
}
}
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.h b/noncore/net/opietooth/manager/hciconfwrapper.h
index 10738c0..de8c9a8 100644
--- a/noncore/net/opietooth/manager/hciconfwrapper.h
+++ b/noncore/net/opietooth/manager/hciconfwrapper.h
@@ -1,30 +1,30 @@
#ifndef HCICONFWRAPPER_H
#define HCICONFWRAPPER_H
#include <qstring.h>
namespace OpieTooth {
class HciConfWrapper {
public:
HciConfWrapper( const QString &fileName );
~HciConfWrapper();
- void setPinHelper( QString app );
- void setName( QString name );
+ void setPinHelper( const QString& app );
+ void setName( const QString& name );
void setIscan( bool enable );
void setPscan( bool enable );
void setAuth( bool enable);
void setEncrypt( bool enable);
private:
void setValue(const QString &entry, const QString &value );
QString m_fileName;
};
}
#endif
diff --git a/noncore/net/opietooth/manager/main.cpp b/noncore/net/opietooth/manager/main.cpp
index d60ef1c..a86e36d 100644
--- a/noncore/net/opietooth/manager/main.cpp
+++ b/noncore/net/opietooth/manager/main.cpp
@@ -1,38 +1,38 @@
/*
* main.cpp
*
* ---------------------
*
* begin : Sun 10 17:20:00 CEST 2002
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.de
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "bluebase.h"
#include <qpe/qpeapplication.h>
QPEApplication *BluetoothApp;
int main( int argc, char ** argv ) {
QPEApplication a(argc, argv);
BluetoothApp=&a;
- OpieTooth::BlueBase *t = new OpieTooth::BlueBase();
+ OpieTooth::BlueBase t;
// t.setCaption( OpieTooth::BlueBase::tr("Bluetooth Manager") );
- a.showMainWidget(t);
+ a.showMainWidget(&t);
return a.exec();
}
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index 0e6e93b..3d6c928 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -33,151 +33,149 @@
#include <manager.h>
#include <device.h>
namespace OpieTooth {
#include <remotedevice.h>
/*
*/
ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
if ( !name )
setName( "ScanDialog" );
resize( 240, 320 );
setCaption( tr( "Scan for devices" ) );
Frame7 = new QFrame( this, "Frame7" );
Frame7->setGeometry( QRect( 0, 0, 240, 331 ) );
Frame7->setFrameShape( QFrame::StyledPanel );
Frame7->setFrameShadow( QFrame::Raised );
QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" );
privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) );
Layout11 = new QVBoxLayout( privateLayoutWidget );
Layout11->setSpacing( 6 );
Layout11->setMargin( 0 );
progress = new QProgressBar(privateLayoutWidget, "progbar");
progress->setTotalSteps(20);
QFrame *buttonFrame = new QFrame(Frame7, "");
StartButton = new QPushButton( buttonFrame, "StartButton" );
StartButton->setText( tr( "Start scan" ) );
StopButton = new QPushButton( buttonFrame, "StopButton" );
StopButton->setText( tr( "Cancel scan" ) );
QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame);
buttonLayout->addWidget(StartButton);
buttonLayout->addWidget(StopButton);
ListView1 = new QListView( privateLayoutWidget, "ListView1" );
//ListView1->addColumn( tr( "Add" ) );
ListView1->addColumn( tr( "Add Device" ) );
//ListView1->addColumn( tr( "Type" ) );
Layout11->addWidget( ListView1);
Layout11->addWidget(progress);
Layout11->addWidget( buttonFrame);
localDevice = new Manager( "hci0" );
connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ),
this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ;
// connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() ));
progressStat = 0;
}
// hack, make cleaner later
void ScanDialog::progressTimer() {
progressStat++;
if (progressStat++ < 20) {
QTimer::singleShot( 2000, this, SLOT(progressTimer() ) );
}
progress->setProgress(progressStat++);
}
void ScanDialog::accept() {
emitToManager();
QDialog::accept();
}
void ScanDialog::startSearch() {
progress->setProgress(0);
progressStat = 0;
// empty list before a new scan
ListView1->clear();
QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
deviceItem2->setText(1, "BLAH" );
progressTimer();
// when finished, it emmite foundDevices()
// checken ob initialisiert , qcop ans applet.
localDevice->searchDevices();
}
void ScanDialog::stopSearch() {
}
void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
qDebug("fill List");
QCheckListItem * deviceItem;
RemoteDevice::ValueList::Iterator it;
for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox );
deviceItem->setText(1, (*it).mac() );
}
}
/*
* Iterates trough the items, and collects the checked items.
* Then it emits it, so the manager can connect to the signal to fill the listing.
*/
void ScanDialog::emitToManager() {
qDebug("vor liste durchsuchen");
if (!ListView1) {
return;
}
- QList<RemoteDevice> *deviceList = new QList<RemoteDevice>;
- deviceList->setAutoDelete(true);
+ QValueList<RemoteDevice> deviceList;
QListViewItemIterator it( ListView1 );
for ( ; it.current(); ++it ) {
if ( ((QCheckListItem*)it.current())->isOn() ) {
- RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0));
- deviceList->append( device );
+ RemoteDevice device( it.current()->text(1), it.current()->text(0));
+ deviceList.append( device );
}
}
qDebug("vor emit");
- emit selectedDevices( *deviceList );
- delete deviceList;
+ emit selectedDevices( deviceList );
}
/*
* Cleanup
*/
ScanDialog::~ScanDialog() {
delete localDevice;
}
}
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h
index 7c84ce2..cc890f3 100644
--- a/noncore/net/opietooth/manager/scandialog.h
+++ b/noncore/net/opietooth/manager/scandialog.h
@@ -1,79 +1,79 @@
/* main.cpp
*
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.de
*
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SCANDIALOG_H
#define SCANDIALOG_H
#include <qvariant.h>
#include <qdialog.h>
#include <qlist.h>
#include <remotedevice.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QListView;
class QListViewItem;
class QPushButton;
class QProgressBar;
namespace OpieTooth {
class Manager;
class Device;
class ScanDialog : public QDialog {
Q_OBJECT
public:
ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~ScanDialog();
QFrame* Frame7;
QProgressBar* progress;
QPushButton* StartButton;
QPushButton* StopButton;
QListView* ListView1;
public slots:
void accept();
protected:
QVBoxLayout* Layout11;
private slots:
void stopSearch();
void startSearch();
void progressTimer();
void fillList(const QString& device, RemoteDevice::ValueList list);
private:
void emitToManager();
Manager *localDevice;
int progressStat;
signals:
- void selectedDevices(QList<RemoteDevice>&);
+ void selectedDevices(QValueList<RemoteDevice>&);
};
}
#endif // SCANDIALOG_H