Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 84 |
1 files changed, 51 insertions, 33 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 85c6717..9cfeaa2 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -44,6 +44,8 @@ | |||
44 | #include <remotedevice.h> | 44 | #include <remotedevice.h> |
45 | #include <services.h> | 45 | #include <services.h> |
46 | 46 | ||
47 | #include "btconnectionitem.h" | ||
48 | |||
47 | using namespace OpieTooth; | 49 | using namespace OpieTooth; |
48 | 50 | ||
49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 51 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
@@ -87,10 +89,13 @@ using namespace OpieTooth; | |||
87 | //TESTING | 89 | //TESTING |
88 | ListView2->setRootIsDecorated(true); | 90 | ListView2->setRootIsDecorated(true); |
89 | 91 | ||
90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); | 92 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); |
91 | topLV2->setPixmap( 1, m_onPix ); | 93 | topLV2->setPixmap( 1, m_onPix ); |
92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 94 | Services s1; |
93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); | 95 | s1.setServiceName( "Serial" ); |
96 | (void) new BTServiceItem( topLV2, s1 ); | ||
97 | s1.setServiceName( "BlueNic" ); | ||
98 | (void) new BTServiceItem( topLV2, s1 ); | ||
94 | 99 | ||
95 | writeToHciConfig(); | 100 | writeToHciConfig(); |
96 | // search conncetions | 101 | // search conncetions |
@@ -184,13 +189,19 @@ using namespace OpieTooth; | |||
184 | */ | 189 | */ |
185 | void BlueBase::writeSavedDevices() { | 190 | void BlueBase::writeSavedDevices() { |
186 | QListViewItemIterator it( ListView2 ); | 191 | QListViewItemIterator it( ListView2 ); |
192 | BTListItem* item; | ||
193 | BTDeviceItem* device; | ||
187 | 194 | ||
188 | for ( ; it.current(); ++it ) { | 195 | for ( ; it.current(); ++it ) { |
196 | item = (BTListItem*)it.current(); | ||
197 | if(item->typeId() != BTListItem::Device ) | ||
198 | continue; | ||
199 | device = (BTDeviceItem*)item; | ||
189 | // seperate config file for each device, to store more information in future. | 200 | // seperate config file for each device, to store more information in future. |
190 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); | 201 | qDebug( "/Settings/bluetooth/" + device->mac() + ".conf"); |
191 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); | 202 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File ); |
192 | conf.setGroup( "Info" ); | 203 | conf.setGroup( "Info" ); |
193 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); | 204 | conf.writeEntry( "name", device->name() ); |
194 | } | 205 | } |
195 | } | 206 | } |
196 | 207 | ||
@@ -245,11 +256,12 @@ using namespace OpieTooth; | |||
245 | * | 256 | * |
246 | */ | 257 | */ |
247 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 258 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
248 | BTListItem * deviceItem; | 259 | BTDeviceItem * deviceItem; |
249 | QValueList<RemoteDevice>::ConstIterator it; | 260 | QValueList<RemoteDevice>::ConstIterator it; |
250 | 261 | ||
251 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 262 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
252 | deviceItem = new BTListItem( ListView2 , (*it).name(), (*it).mac(), "device" ); | 263 | |
264 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | ||
253 | deviceItem->setExpandable ( true ); | 265 | deviceItem->setExpandable ( true ); |
254 | 266 | ||
255 | // look if device is avail. atm, async | 267 | // look if device is avail. atm, async |
@@ -326,10 +338,10 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
326 | * Search and display avail. services for a device (on expand from device listing) | 338 | * Search and display avail. services for a device (on expand from device listing) |
327 | * | 339 | * |
328 | */ | 340 | */ |
329 | void BlueBase::addServicesToDevice( BTListItem * item ) { | 341 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
330 | qDebug("addServicesToDevice"); | 342 | qDebug("addServicesToDevice"); |
331 | // row of mac adress text(3) | 343 | // row of mac adress text(3) |
332 | RemoteDevice device( item->mac(), item->name() ); | 344 | RemoteDevice device = item->remoteDevice(); |
333 | m_deviceList.insert( item->mac() , item ); | 345 | m_deviceList.insert( item->mac() , item ); |
334 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 346 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
335 | m_localDevice->searchServices( device ); | 347 | m_localDevice->searchServices( device ); |
@@ -344,28 +356,31 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
344 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 356 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
345 | qDebug("fill services list"); | 357 | qDebug("fill services list"); |
346 | 358 | ||
347 | QMap<QString,BTListItem*>::Iterator it; | 359 | QMap<QString,BTDeviceItem*>::Iterator it; |
348 | BTListItem* deviceItem = 0; | 360 | BTDeviceItem* deviceItem = 0; |
349 | 361 | ||
350 | // get the right devices which requested the search | 362 | // get the right devices which requested the search |
351 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { | 363 | it = m_deviceList.find( device ); |
352 | if ( it.key() == device ) { | 364 | if( it == m_deviceList.end() ) |
353 | deviceItem = it.data(); | 365 | return; |
354 | } | 366 | deviceItem = it.data(); |
355 | } | ||
356 | 367 | ||
357 | QValueList<OpieTooth::Services>::Iterator it2; | 368 | QValueList<OpieTooth::Services>::Iterator it2; |
358 | BTListItem * serviceItem; | 369 | BTServiceItem * serviceItem; |
359 | 370 | ||
360 | if (!servicesList.isEmpty() ) { | 371 | if (!servicesList.isEmpty() ) { |
361 | // add services | 372 | // add services |
362 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 373 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
363 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 374 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); |
364 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); | 375 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); |
365 | } | 376 | } |
366 | } else { | 377 | } else { |
367 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); | 378 | Services s1; |
379 | s1.setServiceName( tr("no serives found") ); | ||
380 | serviceItem = new BTServiceItem( deviceItem, s1 ); | ||
368 | } | 381 | } |
382 | // now remove them from the list | ||
383 | m_deviceList.remove( it ); | ||
369 | } | 384 | } |
370 | 385 | ||
371 | 386 | ||
@@ -378,17 +393,19 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
378 | } | 393 | } |
379 | 394 | ||
380 | 395 | ||
381 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { | 396 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
382 | QValueList<OpieTooth::Connection>::Iterator it; | 397 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
383 | BTListItem * connectionItem; | 398 | BTConnectionItem * connectionItem; |
384 | 399 | ||
385 | if ( !connectionList.isEmpty() ) { | 400 | if ( !connectionList.isEmpty() ) { |
386 | 401 | ||
387 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 402 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
388 | connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" ); | 403 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); |
389 | } | 404 | } |
390 | } else { | 405 | } else { |
391 | connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" ); | 406 | ConnectionState con; |
407 | con.setMac( tr("No connections found") ); | ||
408 | connectionItem = new BTConnectionItem( ListView4 , con ); | ||
392 | } | 409 | } |
393 | 410 | ||
394 | // recall connection search after some time | 411 | // recall connection search after some time |
@@ -400,6 +417,7 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
400 | */ | 417 | */ |
401 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 418 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
402 | // search by mac, async, gets a signal back | 419 | // search by mac, async, gets a signal back |
420 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | ||
403 | m_localDevice->isAvailable( device.mac() ); | 421 | m_localDevice->isAvailable( device.mac() ); |
404 | } | 422 | } |
405 | 423 | ||
@@ -411,21 +429,21 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
411 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 429 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
412 | qDebug("deviceActive slot"); | 430 | qDebug("deviceActive slot"); |
413 | 431 | ||
414 | QMap<QString,BTListItem*>::Iterator it; | 432 | QMap<QString,BTDeviceItem*>::Iterator it; |
415 | BTListItem* deviceItem = 0; | 433 | |
434 | it = m_deviceList.find( device ); | ||
435 | if( it == m_deviceList.end() ) | ||
436 | return; | ||
437 | |||
438 | BTDeviceItem* deviceItem = it.data(); | ||
416 | 439 | ||
417 | // get the right devices which requested the search | ||
418 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { | ||
419 | if ( it.key() == device ) { | ||
420 | deviceItem = it.data(); | ||
421 | } | ||
422 | } | ||
423 | 440 | ||
424 | if ( connected ) { | 441 | if ( connected ) { |
425 | deviceItem->setPixmap( 1, m_onPix ); | 442 | deviceItem->setPixmap( 1, m_onPix ); |
426 | } else { | 443 | } else { |
427 | deviceItem->setPixmap( 1, m_offPix ); | 444 | deviceItem->setPixmap( 1, m_offPix ); |
428 | } | 445 | } |
446 | m_deviceList.remove( it ); | ||
429 | } | 447 | } |
430 | 448 | ||
431 | /** | 449 | /** |