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 @@ -20,4 +20,6 @@ #include "hciconfwrapper.h" +#include <stdlib.h> + #include <qframe.h> #include <qlabel.h> @@ -45,4 +47,5 @@ #include <services.h> +#include "devicehandler.h" #include "btconnectionitem.h" @@ -67,6 +70,6 @@ using namespace OpieTooth; 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 @@ -104,4 +107,5 @@ using namespace OpieTooth; addConnectedDevices(); m_iconLoader = new BTIconLoader(); + readSavedDevices(); } @@ -141,6 +145,7 @@ 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" ); @@ -153,4 +158,5 @@ using namespace OpieTooth; hciconf.setPscan( m_enablePagescan ); hciconf.setIscan( m_enableInquiryscan ); + hciconf.save(); } @@ -163,24 +169,7 @@ 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 ); } @@ -194,5 +183,5 @@ using namespace OpieTooth; BTListItem* item; BTDeviceItem* device; - + RemoteDevice::ValueList list; for ( ; it.current(); ++it ) { item = (BTListItem*)it.current(); @@ -200,10 +189,14 @@ using namespace OpieTooth; 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 ); } @@ -264,4 +257,7 @@ 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 ); @@ -334,8 +330,12 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin 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 ) { @@ -406,7 +406,8 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin 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 ) ); } @@ -511,2 +512,23 @@ 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 +} |