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) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp84
1 files changed, 53 insertions, 31 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 3f2f138..598ce16 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -19,6 +19,8 @@
#include "scandialog.h"
#include "hciconfwrapper.h"
+#include <stdlib.h>
+
#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
@@ -44,6 +46,7 @@
#include <remotedevice.h>
#include <services.h>
+#include "devicehandler.h"
#include "btconnectionitem.h"
using namespace OpieTooth;
@@ -66,8 +69,8 @@ using namespace OpieTooth;
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( Connection::ValueList ) ),
- this, SLOT( addConnectedDevices( Connection::ValueList ) ) );
+ connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
+ this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
//Load all icons needed
m_offPix = Resource::loadPixmap( "editdelete" );
@@ -103,6 +106,7 @@ using namespace OpieTooth;
// search conncetions
addConnectedDevices();
m_iconLoader = new BTIconLoader();
+ readSavedDevices();
}
/**
@@ -140,8 +144,9 @@ using namespace OpieTooth;
}
void BlueBase::writeToHciConfig() {
-
- HciConfWrapper hciconf ( "/tmp/hcid.conf" );
+ qWarning("writeToHciConfig");
+ HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
+ hciconf.load();
hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
@@ -152,6 +157,7 @@ using namespace OpieTooth;
hciconf.setAuth( m_enableAuthentification );
hciconf.setPscan( m_enablePagescan );
hciconf.setIscan( m_enableInquiryscan );
+ hciconf.save();
}
@@ -162,26 +168,9 @@ using namespace OpieTooth;
void BlueBase::readSavedDevices() {
QValueList<RemoteDevice> loadedDevices;
+ DeviceHandler handler;
+ loadedDevices = handler.load();
- QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/");
- // list of .conf files
- QStringList devicesFileList = deviceListSave.entryList();
-
- // cut .conf of to get the mac and also read the name entry in it.
-
- for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
-
- QString name;
- QString mac;
- qDebug((*it).latin1() );
- Config conf((*it));
- conf.setGroup("Info");
- name = conf.readEntry("name", "Error");
- qDebug("MAC: " + mac);
- qDebug("NAME: " + name);
- RemoteDevice currentDevice( mac , name );
- loadedDevices.append( currentDevice );
- }
addSearchedDevices( loadedDevices );
}
@@ -193,18 +182,22 @@ using namespace OpieTooth;
QListViewItemIterator it( ListView2 );
BTListItem* item;
BTDeviceItem* device;
-
+ RemoteDevice::ValueList list;
for ( ; it.current(); ++it ) {
item = (BTListItem*)it.current();
if(item->typeId() != BTListItem::Device )
continue;
device = (BTDeviceItem*)item;
- // seperate config file for each device, to store more information in future.
- qDebug( "/Settings/bluetooth/" + device->mac() + ".conf");
- Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File );
- conf.setGroup( "Info" );
- conf.writeEntry( "name", device->name() );
+
+ list.append( device->remoteDevice() );
}
+ /*
+ * if not empty save the List through DeviceHandler
+ */
+ if ( list.isEmpty() )
+ return;
+ DeviceHandler handler;
+ handler.save( list );
}
@@ -263,6 +256,9 @@ using namespace OpieTooth;
for( it = newDevices.begin(); it != newDevices.end() ; ++it ) {
+ if (find( (*it) )) // is already inserted
+ continue;
+
deviceItem = new BTDeviceItem( ListView2 , (*it) );
deviceItem->setExpandable ( true );
@@ -333,10 +329,14 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
QMap<int, QString> list = service->services().classIdList();
QMap<int, QString>::Iterator it = list.begin();
QPopupMenu *popup =0l;
- if ( it != list.end() )
+ if ( it != list.end() ) {
+ qWarning("Searching id %d %s", it.key(), it.data().latin1() );
popup = m_popHelper.find( it.key(),
service->services(),
service->parent() );
+ }else {
+ qWarning("Empty");
+ }
if ( popup == 0l ) {
qWarning("factory returned 0l");
@@ -405,9 +405,10 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
serviceItem = new BTServiceItem( deviceItem , (*it2) );
list = (*it2).classIdList();
classIt = list.begin();
- int classId;
+ int classId=0;
if ( classIt != list.end() )
classId = classIt.key();
+
serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
}
} else {
@@ -510,3 +511,24 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
delete m_iconLoader;
}
+/**
+ * find searches the ListView for a BTDeviceItem containig
+ * the same Device if found return true else false
+ * @param dev RemoteDevice to find
+ * @return returns true if found
+ */
+bool BlueBase::find( const RemoteDevice& rem ) {
+ QListViewItemIterator it( ListView2 );
+ BTListItem* item;
+ BTDeviceItem* device;
+ for (; it.current(); ++it ) {
+ item = (BTListItem*) it.current();
+ if ( item->typeId() != BTListItem::Device )
+ continue;
+
+ device = (BTDeviceItem*)item;
+ if ( rem.equals( device->remoteDevice() ) )
+ return true;
+ }
+ return false; // not found
+}