summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp143
-rw-r--r--noncore/net/opietooth/manager/bluebase.h11
-rw-r--r--noncore/net/opietooth/manager/btlistitem.cpp46
-rw-r--r--noncore/net/opietooth/manager/btlistitem.h11
4 files changed, 148 insertions, 63 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 77eb62b..910bb8c 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -50,56 +50,55 @@ namespace OpieTooth {
: BluetoothBase( parent, name, fl ) {
localDevice = new Manager( "hci0" );
connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
// not good since lib is async
// connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
// this, SLOT( addServicesToDevice( QListViewItem * ) ) );
connect( ListView2, SIGNAL( clicked( QListViewItem* )),
this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
- this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
+ this, SLOT(startServiceActionHold( BTListItem *, const QPoint &, int) ) );
connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
- // connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ),
- // this, SLOT() );
+ connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ),
+ this, SLOT( deviceActive( const QString& mac, bool connected ) ) );
//Load all icons needed
offPix = Resource::loadPixmap( "editdelete" );
onPix = Resource::loadPixmap( "installed" );
QPalette pal = this->palette();
QColor col = pal.color( QPalette::Active, QColorGroup::Background );
pal.setColor( QPalette::Active, QColorGroup::Button, col );
pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
pal.setColor( QPalette::Normal, QColorGroup::Button, col );
pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
this->setPalette( pal );
setCaption( tr( "Bluetooth Manager" ) );
readConfig();
initGui();
//TESTING
ListView2->setRootIsDecorated(true);
- QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
+ BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" );
topLV2->setPixmap( 1, onPix );
- topLV2->setText(4, "device" );
- (void) new QListViewItem( topLV2, "Serial" );
- (void) new QListViewItem( topLV2, "BlueNiC" );
+ (void) new BTListItem( topLV2, "Serial" ,"", "service" );
+ (void) new BTListItem( topLV2, "BlueNiC" , "", "service" );
}
/**
* Reads all options from the config file
*/
void BlueBase::readConfig() {
Config cfg( "bluetoothmanager" );
cfg.setGroup( "bluezsettings" );
@@ -162,28 +161,29 @@ namespace OpieTooth {
/**
* Write the list of allready known devices
*
*/
void BlueBase::writeSavedDevices() {
QListViewItemIterator it( ListView2 );
for ( ; it.current(); ++it ) {
// seperate config file for each device, to store more information in future.
+// TO FIX: BTLISTITEM!!!
- Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File );
- conf.setGroup( "Info" );
- conf.writeEntry( "name", it.current()->text(0) );
+ // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File );
+ // conf.setGroup( "Info" );
+ // conf.writeEntry( "name", it.current()->name() );
}
}
/**
* Set up the gui
*/
void BlueBase::initGui() {
StatusLabel->setText( getStatus() ); // maybe move it to getStatus()
cryptCheckBox->setChecked( useEncryption );
@@ -229,187 +229,226 @@ namespace OpieTooth {
box->setText( tr( "Changes applied" ) );
box->show();
// falls nötig hcid killhupen - die funktionalität adden
}
/**
* Add fresh found devices from scan dialog to the listing
*
*/
void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
- QListViewItem * deviceItem;
+ BTListItem * deviceItem;
QListIterator<RemoteDevice> it( newDevices );
for( ; it.current() ; ++it ) {
RemoteDevice *dev = it.current();
- deviceItem = new QListViewItem( ListView2 , dev->name() );
+ deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" );
deviceItem->setExpandable ( true );
- if ( deviceActive( dev ) ) {
- deviceItem->setPixmap( 1 , onPix );
- } else {
- deviceItem->setPixmap( 1, offPix );
- }
+ // look if device is avail. atm, async
+ deviceActive( dev );
- deviceItem->setText( 3, dev->mac() );
+ // move into the c'tor
+ // deviceItem->setMac( dev->mac() );
// what kind of entry is it.
- deviceItem->setText( 4, "device");
+ //deviceItem->setType( "device");
// ggf auch hier?
addServicesToDevice( deviceItem );
}
}
/**
* Action that is toggled on entrys on click
*/
void BlueBase::startServiceActionClicked( QListViewItem *item ) {
}
/**
* Action that are toggled on hold (mostly QPopups i guess)
*/
- void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
+ void BlueBase::startServiceActionHold( BTListItem * item, const QPoint & point, int column ) {
QPopupMenu *menu = new QPopupMenu();
- QPopupMenu *groups = new QPopupMenu();
+
int ret=0;
//QSize s = menu->sizeHint ( );
- if ( item->text(4) == "device") {
+ if ( item->type() == "device") {
+
+ QPopupMenu *groups = new QPopupMenu();
+
menu->insertItem( tr("rescan sevices:"), 0);
menu->insertItem( tr("to group"), groups , 1);
menu->insertItem( tr("delete"), 2);
- } else if ( item->text(4) == "service") {
+
+
+ ret = menu->exec( point , 0);
+
+ switch(ret) {
+ case 0:
+ break;
+ case 1:
+ break;
+ case 2:
+ // delete childs too
+ delete item;
+ break;
+ }
+ delete groups;
+
+ } else if ( item->type() == "service") {
menu->insertItem( tr("Test1:"), 0);
menu->insertItem( tr("connect"), 1);
menu->insertItem( tr("delete"), 2);
- }
- ret = menu->exec( point , 0);
-
-// noch differenzieren
- switch(ret) {
- case 0:
- break;
- case 1:
- break;
- case 2:
- // delete childs too
- delete item;
- break;
+ ret = menu->exec( point , 0);
+
+ switch(ret) {
+ case 0:
+ break;
+ case 1:
+ break;
+ case 2:
+ // delete childs too
+ delete item;
+ break;
+ }
}
delete menu;
- delete groups;
}
/**
* Search and display avail. services for a device (on expand from device listing)
*
*/
- void BlueBase::addServicesToDevice( QListViewItem * item ) {
+ void BlueBase::addServicesToDevice( BTListItem * item ) {
qDebug("addServicesToDevice");
// row of mac adress text(3)
- RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) );
+ RemoteDevice *device = new RemoteDevice( item->mac(), item->name() );
- deviceList.insert( item->text(3) , item );
+ deviceList.insert( item->mac() , item );
// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
localDevice->searchServices( *device );
// delete
}
/**
* 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,QListViewItem*>::Iterator it;
+ QMap<QString,BTListItem*>::Iterator it;
- QListViewItem* deviceItem;
+ BTListItem* deviceItem;
// get the right devices which requested the search
for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
if ( it.key() == device ) {
deviceItem = it.data();
}
}
// empty entries
// QListViewItem * myChild = deviceItem->firstChild();
//QList<QListViewItem*> tmpList;
//while( myChild ) {
// tmpList.append(myChild);
// myChild = myChild->nextSibling();
// }
QValueList<OpieTooth::Services>::Iterator it2;
- QListViewItem * serviceItem;
+ BTListItem * serviceItem;
if (!servicesList.isEmpty() ) {
// add services
for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
- serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
- serviceItem->setText(4, "service");
+ serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" );
+ //serviceItem->setText(4, "service");
}
} else {
- serviceItem = new QListViewItem( deviceItem , tr("no services found") );
- serviceItem->setText(4, "service");
+ serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" );
+ //serviceItem->setText(4, "service");
}
}
/**
* Add the existing connections (pairs) to the connections tab.
*
*/
void BlueBase::addConnectedDevices() {
//mac address
}
/**
* Find out if a device can currently be reached
*/
- bool BlueBase::deviceActive( RemoteDevice *device ) {
-
- // search by mac
- localDevice->isAvailable( device->mac() );
+ void BlueBase::deviceActive( RemoteDevice *device ) {
- return true;
+ // search by mac, async, gets a signal back
+ 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;
+
+ // get the right devices which requested the search
+ for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
+ if ( it.key() == device ) {
+ deviceItem = it.data();
+ }
+ }
+
+ if ( connected ) {
+ deviceItem->setPixmap( 1, onPix );
+ } else {
+ deviceItem->setPixmap( 1, 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>& ) ) );
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index dee721d..481f0c9 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -1,25 +1,25 @@
#ifndef BLUEBASE_H
#define BLUEBASE_H
#include <qvariant.h>
#include <qwidget.h>
#include <qscrollview.h>
#include <qsplitter.h>
#include <qlist.h>
#include <qpixmap.h>
#include "bluetoothbase.h"
-
+#include "btlistitem.h"
#include <remotedevice.h>
#include <manager.h>
class QVBox;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QPushButton;
class QTabWidget;
class QCheckBox;
@@ -40,40 +40,41 @@ namespace OpieTooth {
private slots:
void startScan();
private:
void readConfig();
void writeConfig();
void readSavedDevices();
void writeSavedDevices();
QString getStatus();
void initGui();
void setInfo();
Manager *localDevice;
- QMap<QString,QListViewItem*> deviceList;
+ QMap<QString,BTListItem*> deviceList;
- bool deviceActive( RemoteDevice *device );
+ void deviceActive( RemoteDevice *device );
QString deviceName;
QString defaultPasskey;
int useEncryption;
int enableAuthentification;
int enablePagescan;
int enableInquiryscan;
QPixmap offPix;
QPixmap onPix;
private slots:
void addSearchedDevices( QList<RemoteDevice> &newDevices );
- void addServicesToDevice( QListViewItem *item );
+ void addServicesToDevice( BTListItem *item );
void addServicesToDevice( const QString& device, Services::ValueList );
void addConnectedDevices();
void startServiceActionClicked( QListViewItem *item );
- void startServiceActionHold( QListViewItem *, const QPoint &, int );
+ void startServiceActionHold( BTListItem *, const QPoint &, int );
+ void deviceActive( const QString& mac, bool connected );
void applyConfigChanges();
};
}
#endif
diff --git a/noncore/net/opietooth/manager/btlistitem.cpp b/noncore/net/opietooth/manager/btlistitem.cpp
index 19d1057..ce5b141 100644
--- a/noncore/net/opietooth/manager/btlistitem.cpp
+++ b/noncore/net/opietooth/manager/btlistitem.cpp
@@ -1,33 +1,67 @@
#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 )
: QListViewItem( parent, name ){
- setText(4, mac);
- setText(5, type);
+
+ m_name = name;
+ m_mac = mac;
+ m_type = type;
}
BTListItem::BTListItem( QListViewItem * parent , QString name, QString mac, QString type )
: QListViewItem( parent, name ){
- setText(4, mac);
- setText(5, type);
+
+ m_name = name;
+ m_mac = mac;
+ m_type = type;
+ }
+
+
+ void BTListItem::setMac( QString mac ) {
+ m_mac = mac;
+ }
+
+ QString BTListItem::mac() {
+ return m_mac;
}
+ void BTListItem::setName( QString name ) {
+ m_name = name;
+ }
+
+ QString BTListItem::name() {
+ return m_name;
+ }
+
+ void BTListItem::setType( QString type ) {
+ m_type = type;
+ }
+
+ QString BTListItem::type() {
+ return m_type;
+ }
+
+
BTListItem::~BTListItem() {
}
};
diff --git a/noncore/net/opietooth/manager/btlistitem.h b/noncore/net/opietooth/manager/btlistitem.h
index 92b3803..8963caa 100644
--- a/noncore/net/opietooth/manager/btlistitem.h
+++ b/noncore/net/opietooth/manager/btlistitem.h
@@ -7,16 +7,27 @@ 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();
+ void setMac( QString );
+ QString mac();
+ void setName( QString );
+ QString name();
+ void setType( QString );
+ QString type();
+ private:
+ QString m_name;
+ QString m_mac;
+ QString m_type;
+
};
};
#endif