summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/bluebase.cpp
Unidiff
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
@@ -21,2 +21,4 @@
21 21
22#include <stdlib.h>
23
22#include <qframe.h> 24#include <qframe.h>
@@ -46,2 +48,3 @@
46 48
49#include "devicehandler.h"
47#include "btconnectionitem.h" 50#include "btconnectionitem.h"
@@ -68,4 +71,4 @@ using namespace OpieTooth;
68 this, SLOT( deviceActive( const QString& , bool ) ) ); 71 this, SLOT( deviceActive( const QString& , bool ) ) );
69 connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), 72 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
70 this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); 73 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
71 74
@@ -105,2 +108,3 @@ using namespace OpieTooth;
105 m_iconLoader = new BTIconLoader(); 108 m_iconLoader = new BTIconLoader();
109 readSavedDevices();
106 } 110 }
@@ -142,4 +146,5 @@ using namespace OpieTooth;
142 void BlueBase::writeToHciConfig() { 146 void BlueBase::writeToHciConfig() {
143 147 qWarning("writeToHciConfig");
144 HciConfWrapper hciconf ( "/tmp/hcid.conf" ); 148 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
149 hciconf.load();
145 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 150 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
@@ -154,2 +159,3 @@ using namespace OpieTooth;
154 hciconf.setIscan( m_enableInquiryscan ); 159 hciconf.setIscan( m_enableInquiryscan );
160 hciconf.save();
155 } 161 }
@@ -164,22 +170,5 @@ using namespace OpieTooth;
164 QValueList<RemoteDevice> loadedDevices; 170 QValueList<RemoteDevice> loadedDevices;
171 DeviceHandler handler;
172 loadedDevices = handler.load();
165 173
166 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/");
167 // list of .conf files
168 QStringList devicesFileList = deviceListSave.entryList();
169
170 // cut .conf of to get the mac and also read the name entry in it.
171
172 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
173
174 QString name;
175 QString mac;
176 qDebug((*it).latin1() );
177 Config conf((*it));
178 conf.setGroup("Info");
179 name = conf.readEntry("name", "Error");
180 qDebug("MAC: " + mac);
181 qDebug("NAME: " + name);
182 RemoteDevice currentDevice( mac , name );
183 loadedDevices.append( currentDevice );
184 }
185 addSearchedDevices( loadedDevices ); 174 addSearchedDevices( loadedDevices );
@@ -195,3 +184,3 @@ using namespace OpieTooth;
195 BTDeviceItem* device; 184 BTDeviceItem* device;
196 185 RemoteDevice::ValueList list;
197 for ( ; it.current(); ++it ) { 186 for ( ; it.current(); ++it ) {
@@ -201,8 +190,12 @@ using namespace OpieTooth;
201 device = (BTDeviceItem*)item; 190 device = (BTDeviceItem*)item;
202 // seperate config file for each device, to store more information in future. 191
203 qDebug( "/Settings/bluetooth/" + device->mac() + ".conf"); 192 list.append( device->remoteDevice() );
204 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File );
205 conf.setGroup( "Info" );
206 conf.writeEntry( "name", device->name() );
207 } 193 }
194 /*
195 * if not empty save the List through DeviceHandler
196 */
197 if ( list.isEmpty() )
198 return;
199 DeviceHandler handler;
200 handler.save( list );
208 } 201 }
@@ -265,2 +258,5 @@ using namespace OpieTooth;
265 258
259 if (find( (*it) )) // is already inserted
260 continue;
261
266 deviceItem = new BTDeviceItem( ListView2 , (*it) ); 262 deviceItem = new BTDeviceItem( ListView2 , (*it) );
@@ -335,3 +331,4 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
335 QPopupMenu *popup =0l; 331 QPopupMenu *popup =0l;
336 if ( it != list.end() ) 332 if ( it != list.end() ) {
333 qWarning("Searching id %d %s", it.key(), it.data().latin1() );
337 popup = m_popHelper.find( it.key(), 334 popup = m_popHelper.find( it.key(),
@@ -339,2 +336,5 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
339 service->parent() ); 336 service->parent() );
337 }else {
338 qWarning("Empty");
339 }
340 340
@@ -407,5 +407,6 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
407 classIt = list.begin(); 407 classIt = list.begin();
408 int classId; 408 int classId=0;
409 if ( classIt != list.end() ) 409 if ( classIt != list.end() )
410 classId = classIt.key(); 410 classId = classIt.key();
411
411 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 412 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
@@ -512 +513,22 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin
512 513
514/**
515 * find searches the ListView for a BTDeviceItem containig
516 * the same Device if found return true else false
517 * @param dev RemoteDevice to find
518 * @return returns true if found
519 */
520bool BlueBase::find( const RemoteDevice& rem ) {
521 QListViewItemIterator it( ListView2 );
522 BTListItem* item;
523 BTDeviceItem* device;
524 for (; it.current(); ++it ) {
525 item = (BTListItem*) it.current();
526 if ( item->typeId() != BTListItem::Device )
527 continue;
528
529 device = (BTDeviceItem*)item;
530 if ( rem.equals( device->remoteDevice() ) )
531 return true;
532 }
533 return false; // not found
534}