summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-06 23:17:10 (UTC)
committer harlekin <harlekin>2003-03-06 23:17:10 (UTC)
commit78a2773ef477a4ab7327350e5f1f6c07428ad8a4 (patch) (unidiff)
treed93e516530f66c0b15260c283d21481e92cfeb18
parent94a385f5f6868e930361dc8d25d3e87eacd20feb (diff)
downloadopie-78a2773ef477a4ab7327350e5f1f6c07428ad8a4.zip
opie-78a2773ef477a4ab7327350e5f1f6c07428ad8a4.tar.gz
opie-78a2773ef477a4ab7327350e5f1f6c07428ad8a4.tar.bz2
remove previous found services on rescan
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 5c5f069..8b15c4f 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -34,24 +34,25 @@
34#include <qimage.h> 34#include <qimage.h>
35#include <qpixmap.h> 35#include <qpixmap.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qscrollview.h> 37#include <qscrollview.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qlineedit.h> 41#include <qlineedit.h>
42#include <qlistview.h> 42#include <qlistview.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qtimer.h> 45#include <qtimer.h>
46#include <qlist.h>
46 47
47#include <qpe/qpeapplication.h> 48#include <qpe/qpeapplication.h>
48#include <qpe/resource.h> 49#include <qpe/resource.h>
49#include <qpe/config.h> 50#include <qpe/config.h>
50 51
51 52
52using namespace OpieTooth; 53using namespace OpieTooth;
53 54
54BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 55BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
55 : BluetoothBase( parent, name, fl ) { 56 : BluetoothBase( parent, name, fl ) {
56 57
57 m_localDevice = new Manager( "hci0" ); 58 m_localDevice = new Manager( "hci0" );
@@ -376,45 +377,56 @@ void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
376void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 377void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
377 qDebug("fill services list"); 378 qDebug("fill services list");
378 379
379 QMap<QString,BTDeviceItem*>::Iterator it; 380 QMap<QString,BTDeviceItem*>::Iterator it;
380 BTDeviceItem* deviceItem = 0; 381 BTDeviceItem* deviceItem = 0;
381 382
382 // get the right devices which requested the search 383 // get the right devices which requested the search
383 it = m_deviceList.find( device ); 384 it = m_deviceList.find( device );
384 if( it == m_deviceList.end() ) 385 if( it == m_deviceList.end() )
385 return; 386 return;
386 deviceItem = it.data(); 387 deviceItem = it.data();
387 388
389 // remove previous entries
390 QList<QListViewItem> tempList;
391 tempList.setAutoDelete( true );
392 QListViewItem * child = deviceItem->firstChild();
393 while( child ) {
394 tempList.append( child );
395 child = child->nextSibling();
396 }
397 tempList.clear();
398
388 QValueList<OpieTooth::Services>::Iterator it2; 399 QValueList<OpieTooth::Services>::Iterator it2;
389 BTServiceItem * serviceItem; 400 BTServiceItem* serviceItem;
401
390 402
391 if (!servicesList.isEmpty() ) { 403 if (!servicesList.isEmpty() ) {
392 // add services 404 // add services
393 QMap<int, QString> list; 405 QMap<int, QString> list;
394 QMap<int, QString>::Iterator classIt; 406 QMap<int, QString>::Iterator classIt;
395 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 407 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
396 serviceItem = new BTServiceItem( deviceItem , (*it2) ); 408 serviceItem = new BTServiceItem( deviceItem, (*it2) );
397 list = (*it2).classIdList(); 409 list = (*it2).classIdList();
398 classIt = list.begin(); 410 classIt = list.begin();
399 int classId=0; 411 int classId=0;
400 if ( classIt != list.end() ) { 412 if ( classIt != list.end() ) {
401 classId = classIt.key(); 413 classId = classIt.key();
402 } 414 }
403 415
404 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 416 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
405 } 417 }
406 } else { 418 } else {
407 Services s1; 419 Services s1;
408 s1.setServiceName( tr("no serives found") ); 420 s1.setServiceName( tr("no services found") );
409 serviceItem = new BTServiceItem( deviceItem, s1 ); 421 serviceItem = new BTServiceItem( deviceItem, s1 );
410 } 422 }
411 // now remove them from the list 423 // now remove them from the list
412 m_deviceList.remove( it ); 424 m_deviceList.remove( it );
413} 425}
414 426
415 427
416/** 428/**
417 * Add the existing connections (pairs) to the connections tab. 429 * Add the existing connections (pairs) to the connections tab.
418 * This one triggers the search 430 * This one triggers the search
419 */ 431 */
420void BlueBase::addConnectedDevices() { 432void BlueBase::addConnectedDevices() {
@@ -437,25 +449,25 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
437 if ( !connectionList.isEmpty() ) { 449 if ( !connectionList.isEmpty() ) {
438 450
439 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 451 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
440 connectionItem = new BTConnectionItem( ListView4 , (*it) ); 452 connectionItem = new BTConnectionItem( ListView4 , (*it) );
441 } 453 }
442 } else { 454 } else {
443 ConnectionState con; 455 ConnectionState con;
444 con.setMac( tr("No connections found") ); 456 con.setMac( tr("No connections found") );
445 connectionItem = new BTConnectionItem( ListView4 , con ); 457 connectionItem = new BTConnectionItem( ListView4 , con );
446 } 458 }
447 459
448 // recall connection search after some time 460 // recall connection search after some time
449 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); 461 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) );
450} 462}
451 463
452 464
453/** 465/**
454 * Find out if a device can currently be reached 466 * Find out if a device can currently be reached
455 * @param device 467 * @param device
456 */ 468 */
457void BlueBase::deviceActive( const RemoteDevice &device ) { 469void BlueBase::deviceActive( const RemoteDevice &device ) {
458 // search by mac, async, gets a signal back 470 // search by mac, async, gets a signal back
459 // We should have a BTDeviceItem there or where does it get added to the map -zecke 471 // We should have a BTDeviceItem there or where does it get added to the map -zecke
460 m_localDevice->isAvailable( device.mac() ); 472 m_localDevice->isAvailable( device.mac() );
461} 473}