Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 84 |
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 @@ -21,2 +21,4 @@ +#include <stdlib.h> + #include <qframe.h> @@ -46,2 +48,3 @@ +#include "devicehandler.h" #include "btconnectionitem.h" @@ -68,4 +71,4 @@ using namespace OpieTooth; 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 ) ) ); @@ -105,2 +108,3 @@ using namespace OpieTooth; m_iconLoader = new BTIconLoader(); + readSavedDevices(); } @@ -142,4 +146,5 @@ 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" ); @@ -154,2 +159,3 @@ using namespace OpieTooth; hciconf.setIscan( m_enableInquiryscan ); + hciconf.save(); } @@ -164,22 +170,5 @@ using namespace OpieTooth; 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 ); @@ -195,3 +184,3 @@ using namespace OpieTooth; BTDeviceItem* device; - + RemoteDevice::ValueList list; for ( ; it.current(); ++it ) { @@ -201,8 +190,12 @@ using namespace OpieTooth; 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 ); } @@ -265,2 +258,5 @@ using namespace OpieTooth; + if (find( (*it) )) // is already inserted + continue; + deviceItem = new BTDeviceItem( ListView2 , (*it) ); @@ -335,3 +331,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin 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(), @@ -339,2 +336,5 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin service->parent() ); + }else { + qWarning("Empty"); + } @@ -407,5 +407,6 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin classIt = list.begin(); - int classId; + int classId=0; if ( classIt != list.end() ) classId = classIt.key(); + serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); @@ -512 +513,22 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin +/** + * 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 +} |