author | mickeyl <mickeyl> | 2005-07-09 16:05:57 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-07-09 16:05:57 (UTC) |
commit | 9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f (patch) (unidiff) | |
tree | 9d42efed66329ad925f3079e2739d9a3a9ced880 /noncore/net/opietooth/manager | |
parent | 5dbfa604bcc5dd32401d862372af806bfe674e89 (diff) | |
download | opie-9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f.zip opie-9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f.tar.gz opie-9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f.tar.bz2 |
autopopulate services list, use odebug where appropriate instead of owarn
Diffstat (limited to 'noncore/net/opietooth/manager') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 44 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 9 |
2 files changed, 25 insertions, 28 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index af1cd23..0649514 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -56,22 +56,19 @@ using namespace Opie::Core; | |||
56 | 56 | ||
57 | using namespace OpieTooth; | 57 | using namespace OpieTooth; |
58 | 58 | ||
59 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 59 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
60 | : BluetoothBase( parent, name, fl ) | 60 | : BluetoothBase( parent, name, fl ) |
61 | { | 61 | { |
62 | |||
63 | m_localDevice = new Manager( "hci0" ); | 62 | m_localDevice = new Manager( "hci0" ); |
64 | 63 | ||
65 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 64 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
66 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 65 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
67 | 66 | ||
68 | connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); | 67 | connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); |
69 | // not good since lib is async | 68 | |
70 | // connect( devicesView, SIGNAL( expanded(QListViewItem*) ), | ||
71 | // this, SLOT( addServicesToDevice(QListViewItem*) ) ); | ||
72 | connect( devicesView, SIGNAL( clicked(QListViewItem*)), | 69 | connect( devicesView, SIGNAL( clicked(QListViewItem*)), |
73 | this, SLOT( startServiceActionClicked(QListViewItem*) ) ); | 70 | this, SLOT( startServiceActionClicked(QListViewItem*) ) ); |
74 | connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 71 | connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
75 | this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) ); | 72 | this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) ); |
76 | connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ), | 73 | connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ), |
77 | this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) ); | 74 | this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) ); |
@@ -79,13 +76,12 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
79 | this, SLOT( deviceActive(const QString&,bool) ) ); | 76 | this, SLOT( deviceActive(const QString&,bool) ) ); |
80 | connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), | 77 | connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), |
81 | this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); | 78 | this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); |
82 | connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), | 79 | connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), |
83 | this, SLOT( addSignalStrength(const QString&,const QString&) ) ); | 80 | this, SLOT( addSignalStrength(const QString&,const QString&) ) ); |
84 | 81 | ||
85 | |||
86 | // let hold be rightButtonClicked() | 82 | // let hold be rightButtonClicked() |
87 | QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); | 83 | QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); |
88 | QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); | 84 | QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); |
89 | 85 | ||
90 | //Load all icons needed | 86 | //Load all icons needed |
91 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); | 87 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); |
@@ -103,20 +99,18 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
103 | setCaption( tr( "Bluetooth Manager" ) ); | 99 | setCaption( tr( "Bluetooth Manager" ) ); |
104 | 100 | ||
105 | readConfig(); | 101 | readConfig(); |
106 | initGui(); | 102 | initGui(); |
107 | 103 | ||
108 | devicesView->setRootIsDecorated(true); | 104 | devicesView->setRootIsDecorated(true); |
109 | 105 | m_iconLoader = new BTIconLoader(); | |
110 | |||
111 | writeToHciConfig(); | 106 | writeToHciConfig(); |
112 | // search conncetions | ||
113 | addConnectedDevices(); | 107 | addConnectedDevices(); |
114 | addSignalStrength(); | ||
115 | m_iconLoader = new BTIconLoader(); | ||
116 | readSavedDevices(); | 108 | readSavedDevices(); |
109 | addServicesToDevices(); | ||
110 | QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); | ||
117 | } | 111 | } |
118 | 112 | ||
119 | /** | 113 | /** |
120 | * Reads all options from the config file | 114 | * Reads all options from the config file |
121 | */ | 115 | */ |
122 | void BlueBase::readConfig() | 116 | void BlueBase::readConfig() |
@@ -168,13 +162,13 @@ void BlueBase::writeToHciConfig() | |||
168 | hciconf.setIscan( m_enableInquiryscan ); | 162 | hciconf.setIscan( m_enableInquiryscan ); |
169 | hciconf.save(); | 163 | hciconf.save(); |
170 | } | 164 | } |
171 | 165 | ||
172 | 166 | ||
173 | /** | 167 | /** |
174 | * Read the list of allready known devices | 168 | * Read the list of already known devices |
175 | */ | 169 | */ |
176 | void BlueBase::readSavedDevices() | 170 | void BlueBase::readSavedDevices() |
177 | { | 171 | { |
178 | 172 | ||
179 | QValueList<RemoteDevice> loadedDevices; | 173 | QValueList<RemoteDevice> loadedDevices; |
180 | DeviceHandler handler; | 174 | DeviceHandler handler; |
@@ -182,13 +176,13 @@ void BlueBase::readSavedDevices() | |||
182 | 176 | ||
183 | addSearchedDevices( loadedDevices ); | 177 | addSearchedDevices( loadedDevices ); |
184 | } | 178 | } |
185 | 179 | ||
186 | 180 | ||
187 | /** | 181 | /** |
188 | * Write the list of allready known devices | 182 | * Write the list of already known devices |
189 | */ | 183 | */ |
190 | void BlueBase::writeSavedDevices() | 184 | void BlueBase::writeSavedDevices() |
191 | { | 185 | { |
192 | QListViewItemIterator it( devicesView ); | 186 | QListViewItemIterator it( devicesView ); |
193 | BTListItem* item; | 187 | BTListItem* item; |
194 | BTDeviceItem* device; | 188 | BTDeviceItem* device; |
@@ -292,15 +286,12 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) | |||
292 | deviceItem = new BTDeviceItem( devicesView , (*it) ); | 286 | deviceItem = new BTDeviceItem( devicesView , (*it) ); |
293 | deviceItem->setPixmap( 1, m_findPix ); | 287 | deviceItem->setPixmap( 1, m_findPix ); |
294 | deviceItem->setExpandable ( true ); | 288 | deviceItem->setExpandable ( true ); |
295 | 289 | ||
296 | // look if device is avail. atm, async | 290 | // look if device is avail. atm, async |
297 | deviceActive( (*it) ); | 291 | deviceActive( (*it) ); |
298 | |||
299 | // ggf auch hier? | ||
300 | addServicesToDevice( deviceItem ); | ||
301 | } | 292 | } |
302 | } | 293 | } |
303 | 294 | ||
304 | 295 | ||
305 | /** | 296 | /** |
306 | * Action that is toggled on entrys on click | 297 | * Action that is toggled on entrys on click |
@@ -395,36 +386,45 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin | |||
395 | delete popup; | 386 | delete popup; |
396 | } | 387 | } |
397 | delete menu; | 388 | delete menu; |
398 | } | 389 | } |
399 | 390 | ||
400 | 391 | ||
392 | void BlueBase::addServicesToDevices() | ||
393 | { | ||
394 | odebug << "BlueBase::addServicesToDevices()" << oendl; | ||
395 | BTDeviceItem* item = (BTDeviceItem*) devicesView->firstChild(); | ||
396 | while ( item ) | ||
397 | { | ||
398 | addServicesToDevice( item ); | ||
399 | item = (BTDeviceItem*) static_cast<QListViewItem*>( item )->nextSibling(); | ||
400 | } | ||
401 | } | ||
402 | |||
401 | /** | 403 | /** |
402 | * Search and display avail. services for a device (on expand from device listing) | 404 | * Search and display avail. services for a device (on expand from device listing) |
403 | * @param item the service item returned | 405 | * @param item the service item returned |
404 | */ | 406 | */ |
405 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) | 407 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) |
406 | { | 408 | { |
407 | odebug << "addServicesToDevice" << oendl; | 409 | odebug << "BlueBase::addServicesToDevice" << oendl; |
408 | // row of mac adress text(3) | 410 | // row of mac adress text(3) |
409 | RemoteDevice device = item->remoteDevice(); | 411 | RemoteDevice device = item->remoteDevice(); |
410 | m_deviceList.insert( item->mac() , item ); | 412 | m_deviceList.insert( item->mac() , item ); |
411 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 413 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
412 | m_localDevice->searchServices( device ); | 414 | m_localDevice->searchServices( device ); |
413 | } | 415 | } |
414 | 416 | ||
415 | 417 | ||
416 | /** | 418 | /** |
417 | * Overloaded. This one it the one that is | ||
418 | ted to the foundServices signal | ||
419 | * @param device the mac address of the remote device | 419 | * @param device the mac address of the remote device |
420 | * @param servicesList the list with the service the device has. | 420 | * @param servicesList the list with the service the device has. |
421 | */ | 421 | */ |
422 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) | 422 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) |
423 | { | 423 | { |
424 | odebug << "fill services list" << oendl; | 424 | odebug << "BlueBase::fill services list" << oendl; |
425 | 425 | ||
426 | QMap<QString,BTDeviceItem*>::Iterator it; | 426 | QMap<QString,BTDeviceItem*>::Iterator it; |
427 | BTDeviceItem* deviceItem = 0; | 427 | BTDeviceItem* deviceItem = 0; |
428 | 428 | ||
429 | // get the right devices which requested the search | 429 | // get the right devices which requested the search |
430 | it = m_deviceList.find( device ); | 430 | it = m_deviceList.find( device ); |
@@ -473,16 +473,12 @@ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList s | |||
473 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 473 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
474 | } | 474 | } |
475 | // now remove them from the list | 475 | // now remove them from the list |
476 | m_deviceList.remove( it ); | 476 | m_deviceList.remove( it ); |
477 | } | 477 | } |
478 | 478 | ||
479 | |||
480 | |||
481 | |||
482 | |||
483 | void BlueBase::addSignalStrength() | 479 | void BlueBase::addSignalStrength() |
484 | { | 480 | { |
485 | 481 | ||
486 | QListViewItemIterator it( connectionsView ); | 482 | QListViewItemIterator it( connectionsView ); |
487 | for ( ; it.current(); ++it ) | 483 | for ( ; it.current(); ++it ) |
488 | { | 484 | { |
@@ -509,12 +505,13 @@ void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) | |||
509 | * Add the existing connections (pairs) to the connections tab. | 505 | * Add the existing connections (pairs) to the connections tab. |
510 | * This one triggers the search | 506 | * This one triggers the search |
511 | */ | 507 | */ |
512 | void BlueBase::addConnectedDevices() | 508 | void BlueBase::addConnectedDevices() |
513 | { | 509 | { |
514 | m_localDevice->searchConnections(); | 510 | m_localDevice->searchConnections(); |
511 | QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); | ||
515 | } | 512 | } |
516 | 513 | ||
517 | /** | 514 | /** |
518 | * This adds the found connections to the connection tab. | 515 | * This adds the found connections to the connection tab. |
519 | * @param connectionList the ValueList with all current connections | 516 | * @param connectionList the ValueList with all current connections |
520 | */ | 517 | */ |
@@ -612,13 +609,12 @@ void BlueBase::deviceActive( const QString& device, bool connected ) | |||
612 | it = m_deviceList.find( device ); | 609 | it = m_deviceList.find( device ); |
613 | if( it == m_deviceList.end() ) | 610 | if( it == m_deviceList.end() ) |
614 | return; | 611 | return; |
615 | 612 | ||
616 | BTDeviceItem* deviceItem = it.data(); | 613 | BTDeviceItem* deviceItem = it.data(); |
617 | 614 | ||
618 | |||
619 | if ( connected ) | 615 | if ( connected ) |
620 | { | 616 | { |
621 | deviceItem->setPixmap( 1, m_onPix ); | 617 | deviceItem->setPixmap( 1, m_onPix ); |
622 | } | 618 | } |
623 | else | 619 | else |
624 | { | 620 | { |
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index a8ab3db..48883d2 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -37,22 +37,22 @@ namespace OpieTooth { | |||
37 | class BlueBase : public BluetoothBase { | 37 | class BlueBase : public BluetoothBase { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
42 | ~BlueBase(); | 42 | ~BlueBase(); |
43 | 43 | ||
44 | static QString appName() { return QString::fromLatin1("bluetooth-manager"); } | 44 | static QString appName() { return QString::fromLatin1("bluetooth-manager"); } |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | 47 | ||
48 | 48 | ||
49 | private slots: | 49 | private slots: |
50 | void startScan(); | 50 | void startScan(); |
51 | 51 | ||
52 | 52 | ||
53 | private: | 53 | private: |
54 | bool find( const RemoteDevice& device ); | 54 | bool find( const RemoteDevice& device ); |
55 | void readConfig(); | 55 | void readConfig(); |
56 | void writeConfig(); | 56 | void writeConfig(); |
57 | void readSavedDevices(); | 57 | void readSavedDevices(); |
58 | void writeSavedDevices(); | 58 | void writeSavedDevices(); |
@@ -79,12 +79,13 @@ namespace OpieTooth { | |||
79 | QPixmap m_findPix; | 79 | QPixmap m_findPix; |
80 | 80 | ||
81 | BTIconLoader *m_iconLoader; | 81 | BTIconLoader *m_iconLoader; |
82 | 82 | ||
83 | private slots: | 83 | private slots: |
84 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); | 84 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); |
85 | void addServicesToDevices(); | ||
85 | void addServicesToDevice( BTDeviceItem *item ); | 86 | void addServicesToDevice( BTDeviceItem *item ); |
86 | void addServicesToDevice( const QString& device, Services::ValueList ); | 87 | void addServicesToDevice( const QString& device, Services::ValueList ); |
87 | void addConnectedDevices(); | 88 | void addConnectedDevices(); |
88 | void addConnectedDevices( ConnectionState::ValueList ); | 89 | void addConnectedDevices( ConnectionState::ValueList ); |
89 | void startServiceActionClicked( QListViewItem *item ); | 90 | void startServiceActionClicked( QListViewItem *item ); |
90 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); | 91 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |