author | mickeyl <mickeyl> | 2005-07-09 13:42:36 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-07-09 13:42:36 (UTC) |
commit | 5dbfa604bcc5dd32401d862372af806bfe674e89 (patch) (unidiff) | |
tree | 38abbfa6cf68bca36ce397e5e1e69c12f8674dc2 | |
parent | 7bccb3143fbfb4dd70cc22d5233e6275245d0285 (diff) | |
download | opie-5dbfa604bcc5dd32401d862372af806bfe674e89.zip opie-5dbfa604bcc5dd32401d862372af806bfe674e89.tar.gz opie-5dbfa604bcc5dd32401d862372af806bfe674e89.tar.bz2 |
- sanitize 'ret' scoping
- fix orthography in popupmenu
- remove 'add to group', since groups seem unfinished :/
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 7954cc3..af1cd23 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -136,49 +136,49 @@ void BlueBase::readConfig() | |||
136 | /** | 136 | /** |
137 | * Writes all options to the config file | 137 | * Writes all options to the config file |
138 | */ | 138 | */ |
139 | void BlueBase::writeConfig() | 139 | void BlueBase::writeConfig() |
140 | { | 140 | { |
141 | 141 | ||
142 | Config cfg( "bluetoothmanager" ); | 142 | Config cfg( "bluetoothmanager" ); |
143 | cfg.setGroup( "bluezsettings" ); | 143 | cfg.setGroup( "bluezsettings" ); |
144 | 144 | ||
145 | cfg.writeEntry( "name" , m_deviceName ); | 145 | cfg.writeEntry( "name" , m_deviceName ); |
146 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 146 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
147 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | 147 | cfg.writeEntry( "useEncryption" , m_useEncryption ); |
148 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | 148 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); |
149 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | 149 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); |
150 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | 150 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); |
151 | 151 | ||
152 | writeToHciConfig(); | 152 | writeToHciConfig(); |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Modify the hcid.conf file to our needs | 156 | * Modify the hcid.conf file to our needs |
157 | */ | 157 | */ |
158 | void BlueBase::writeToHciConfig() | 158 | void BlueBase::writeToHciConfig() |
159 | { | 159 | { |
160 | owarn << "writeToHciConfig" << oendl; | 160 | owarn << "writeToHciConfig" << oendl; |
161 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | 161 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); |
162 | hciconf.load(); | 162 | hciconf.load(); |
163 | hciconf.setPinHelper( QPEApplication::qpeDir() + "bin/bluepin" ); | 163 | hciconf.setPinHelper( QPEApplication::qpeDir() + "bin/bluepin" ); |
164 | hciconf.setName( m_deviceName ); | 164 | hciconf.setName( m_deviceName ); |
165 | hciconf.setEncrypt( m_useEncryption ); | 165 | hciconf.setEncrypt( m_useEncryption ); |
166 | hciconf.setAuth( m_enableAuthentification ); | 166 | hciconf.setAuth( m_enableAuthentification ); |
167 | hciconf.setPscan( m_enablePagescan ); | 167 | hciconf.setPscan( m_enablePagescan ); |
168 | hciconf.setIscan( m_enableInquiryscan ); | 168 | hciconf.setIscan( m_enableInquiryscan ); |
169 | hciconf.save(); | 169 | hciconf.save(); |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | /** | 173 | /** |
174 | * Read the list of allready known devices | 174 | * Read the list of allready known devices |
175 | */ | 175 | */ |
176 | void BlueBase::readSavedDevices() | 176 | void BlueBase::readSavedDevices() |
177 | { | 177 | { |
178 | 178 | ||
179 | QValueList<RemoteDevice> loadedDevices; | 179 | QValueList<RemoteDevice> loadedDevices; |
180 | DeviceHandler handler; | 180 | DeviceHandler handler; |
181 | loadedDevices = handler.load(); | 181 | loadedDevices = handler.load(); |
182 | 182 | ||
183 | addSearchedDevices( loadedDevices ); | 183 | addSearchedDevices( loadedDevices ); |
184 | } | 184 | } |
@@ -297,156 +297,152 @@ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) | |||
297 | deviceActive( (*it) ); | 297 | deviceActive( (*it) ); |
298 | 298 | ||
299 | // ggf auch hier? | 299 | // ggf auch hier? |
300 | addServicesToDevice( deviceItem ); | 300 | addServicesToDevice( deviceItem ); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | /** | 305 | /** |
306 | * Action that is toggled on entrys on click | 306 | * Action that is toggled on entrys on click |
307 | */ | 307 | */ |
308 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) | 308 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) |
309 | {} | 309 | {} |
310 | 310 | ||
311 | 311 | ||
312 | /** | 312 | /** |
313 | * Action that are toggled on hold (mostly QPopups i guess) | 313 | * Action that are toggled on hold (mostly QPopups i guess) |
314 | */ | 314 | */ |
315 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) | 315 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) |
316 | { | 316 | { |
317 | if (!item ) | 317 | if (!item ) |
318 | return; | 318 | return; |
319 | 319 | ||
320 | QPopupMenu *menu = new QPopupMenu(); | 320 | QPopupMenu *menu = new QPopupMenu(); |
321 | int ret=0; | ||
322 | 321 | ||
323 | if ( ((BTListItem*)item)->type() == "device") | 322 | if ( static_cast<BTListItem*>( item )->type() == "device") |
324 | { | 323 | { |
325 | |||
326 | QPopupMenu *groups = new QPopupMenu(); | 324 | QPopupMenu *groups = new QPopupMenu(); |
327 | 325 | ||
328 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); | 326 | menu->insertItem( static_cast<BTDeviceItem*>( item )->name(), 0 ); |
329 | menu->insertSeparator(1); | 327 | menu->insertSeparator( 1 ); |
330 | menu->insertItem( tr("rescan sevices"), 2); | 328 | menu->insertItem( tr( "&Rescan services" ), 2); |
331 | menu->insertItem( tr("to group"), groups , 3); | 329 | // menu->insertItem( tr( "&Add to group" ), groups, 3); |
332 | menu->insertItem( tr("delete"), 4); | 330 | menu->insertItem( tr( "&Delete"), 4); |
333 | 331 | int ret = menu->exec( point, 0); | |
334 | ret = menu->exec( point , 0); | ||
335 | 332 | ||
336 | switch(ret) | 333 | switch(ret) |
337 | { | 334 | { |
338 | case -1: | 335 | case -1: |
339 | break; | 336 | break; |
340 | case 2: | 337 | case 2: |
341 | addServicesToDevice( (BTDeviceItem*)item ); | 338 | addServicesToDevice( static_cast<BTDeviceItem*>( item ) ); |
342 | break; | 339 | break; |
343 | 340 | ||
344 | case 4: | 341 | case 4: |
345 | // deletes childs too | 342 | // deletes childs too |
346 | delete item; | 343 | delete item; |
347 | break; | 344 | break; |
348 | } | 345 | } |
349 | delete groups; | 346 | // delete groups; |
350 | |||
351 | } | 347 | } |
352 | 348 | ||
353 | /* | 349 | /* |
354 | * We got service sensitive PopupMenus in our factory | 350 | * We got service sensitive PopupMenus in our factory |
355 | * We will create one through the factory and will insert | 351 | * We will create one through the factory and will insert |
356 | * our Separator + ShowInfo into the menu or create a new | 352 | * our Separator + ShowInfo into the menu or create a new |
357 | * one if the factory returns 0 | 353 | * one if the factory returns 0 |
358 | * PopupMenu deletion is kind of weird. | 354 | * PopupMenu deletion is kind of weird. |
359 | * If escaped( -1 ) or any of our items were chosen we'll | 355 | * If escaped( -1 ) or any of our items were chosen we'll |
360 | * delete the PopupMenu otherwise it's the responsibility of | 356 | * delete the PopupMenu otherwise it's the responsibility of |
361 | * the PopupMenu to delete itself | 357 | * the PopupMenu to delete itself |
362 | * | 358 | * |
363 | */ | 359 | */ |
364 | else if ( ((BTListItem*)item)->type() == "service") | 360 | else if ( ((BTListItem*)item)->type() == "service") |
365 | { | 361 | { |
366 | BTServiceItem* service = (BTServiceItem*)item; | 362 | BTServiceItem* service = (BTServiceItem*)item; |
367 | QMap<int, QString> list = service->services().classIdList(); | 363 | QMap<int, QString> list = service->services().classIdList(); |
368 | QMap<int, QString>::Iterator it = list.begin(); | 364 | QMap<int, QString>::Iterator it = list.begin(); |
369 | QPopupMenu *popup =0l; | 365 | QPopupMenu *popup =0l; |
370 | if ( it != list.end() ) | 366 | if ( it != list.end() ) |
371 | { | 367 | { |
372 | owarn << "Searching id " << it.key() << " " << it.data().latin1() << "" << oendl; | 368 | owarn << "Searching id " << it.key() << " " << it.data().latin1() << "" << oendl; |
373 | popup = m_popHelper.find( it.key(), | 369 | popup = m_popHelper.find( it.key(), |
374 | service->services(), | 370 | service->services(), |
375 | (BTDeviceItem*)service->parent() ); | 371 | (BTDeviceItem*)service->parent() ); |
376 | } | 372 | } |
377 | else | 373 | else |
378 | { | 374 | { |
379 | owarn << "Empty" << oendl; | 375 | owarn << "Empty" << oendl; |
380 | } | 376 | } |
381 | 377 | ||
382 | if ( popup == 0l ) | 378 | if ( popup == 0l ) |
383 | { | 379 | { |
384 | owarn << "factory returned 0l" << oendl; | 380 | owarn << "factory returned 0l" << oendl; |
385 | popup = new QPopupMenu(); | 381 | popup = new QPopupMenu(); |
386 | } | 382 | } |
387 | int test1 = popup->insertItem( tr("Test1:"), 2); | 383 | int test1 = popup->insertItem( tr("Test1:"), 2); |
388 | 384 | ||
389 | ret = popup->exec( point ); | 385 | int ret = popup->exec( point ); |
390 | owarn << "returned from exec() " << oendl; | 386 | owarn << "returned from exec() " << oendl; |
391 | if ( ret == -1 ) | 387 | if ( ret == -1 ) |
392 | { | 388 | { |
393 | ; | 389 | ; |
394 | } | 390 | } |
395 | else if ( ret == test1 ) | 391 | else if ( ret == test1 ) |
396 | { | 392 | { |
397 | ; | 393 | ; |
398 | } | 394 | } |
399 | delete popup; | 395 | delete popup; |
400 | } | 396 | } |
401 | delete menu; | 397 | delete menu; |
402 | } | 398 | } |
403 | 399 | ||
404 | 400 | ||
405 | /** | 401 | /** |
406 | * Search and display avail. services for a device (on expand from device listing) | 402 | * Search and display avail. services for a device (on expand from device listing) |
407 | * @param item the service item returned | 403 | * @param item the service item returned |
408 | */ | 404 | */ |
409 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) | 405 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) |
410 | { | 406 | { |
411 | odebug << "addServicesToDevice" << oendl; | 407 | odebug << "addServicesToDevice" << oendl; |
412 | // row of mac adress text(3) | 408 | // row of mac adress text(3) |
413 | RemoteDevice device = item->remoteDevice(); | 409 | RemoteDevice device = item->remoteDevice(); |
414 | m_deviceList.insert( item->mac() , item ); | 410 | m_deviceList.insert( item->mac() , item ); |
415 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 411 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
416 | m_localDevice->searchServices( device ); | 412 | m_localDevice->searchServices( device ); |
417 | } | 413 | } |
418 | 414 | ||
419 | 415 | ||
420 | /** | 416 | /** |
421 | * Overloaded. This one it the one that is | 417 | * Overloaded. This one it the one that is |
422 | ted to the foundServices signal | 418 | ted to the foundServices signal |
423 | * @param device the mac address of the remote device | 419 | * @param device the mac address of the remote device |
424 | * @param servicesList the list with the service the device has. | 420 | * @param servicesList the list with the service the device has. |
425 | */ | 421 | */ |
426 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) | 422 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) |
427 | { | 423 | { |
428 | odebug << "fill services list" << oendl; | 424 | odebug << "fill services list" << oendl; |
429 | 425 | ||
430 | QMap<QString,BTDeviceItem*>::Iterator it; | 426 | QMap<QString,BTDeviceItem*>::Iterator it; |
431 | BTDeviceItem* deviceItem = 0; | 427 | BTDeviceItem* deviceItem = 0; |
432 | 428 | ||
433 | // get the right devices which requested the search | 429 | // get the right devices which requested the search |
434 | it = m_deviceList.find( device ); | 430 | it = m_deviceList.find( device ); |
435 | if( it == m_deviceList.end() ) | 431 | if( it == m_deviceList.end() ) |
436 | return; | 432 | return; |
437 | deviceItem = it.data(); | 433 | deviceItem = it.data(); |
438 | 434 | ||
439 | // remove previous entries | 435 | // remove previous entries |
440 | QList<QListViewItem> tempList; | 436 | QList<QListViewItem> tempList; |
441 | tempList.setAutoDelete( true ); | 437 | tempList.setAutoDelete( true ); |
442 | QListViewItem * child = deviceItem->firstChild(); | 438 | QListViewItem * child = deviceItem->firstChild(); |
443 | while( child ) | 439 | while( child ) |
444 | { | 440 | { |
445 | tempList.append( child ); | 441 | tempList.append( child ); |
446 | child = child->nextSibling(); | 442 | child = child->nextSibling(); |
447 | } | 443 | } |
448 | tempList.clear(); | 444 | tempList.clear(); |
449 | 445 | ||
450 | QValueList<OpieTooth::Services>::Iterator it2; | 446 | QValueList<OpieTooth::Services>::Iterator it2; |
451 | BTServiceItem* serviceItem; | 447 | BTServiceItem* serviceItem; |
452 | 448 | ||
@@ -588,49 +584,49 @@ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) | |||
588 | // recall connection search after some time | 584 | // recall connection search after some time |
589 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); | 585 | QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); |
590 | } | 586 | } |
591 | 587 | ||
592 | 588 | ||
593 | /** | 589 | /** |
594 | * Find out if a device can currently be reached | 590 | * Find out if a device can currently be reached |
595 | * @param device | 591 | * @param device |
596 | */ | 592 | */ |
597 | void BlueBase::deviceActive( const RemoteDevice &device ) | 593 | void BlueBase::deviceActive( const RemoteDevice &device ) |
598 | { | 594 | { |
599 | // search by mac, async, gets a signal back | 595 | // search by mac, async, gets a signal back |
600 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 596 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
601 | m_localDevice->isAvailable( device.mac() ); | 597 | m_localDevice->isAvailable( device.mac() ); |
602 | } | 598 | } |
603 | 599 | ||
604 | 600 | ||
605 | /** | 601 | /** |
606 | * The signal catcher. Set the avail. status on device. | 602 | * The signal catcher. Set the avail. status on device. |
607 | * @param device - the mac address | 603 | * @param device - the mac address |
608 | * @param connected - if it is avail. or not | 604 | * @param connected - if it is avail. or not |
609 | */ | 605 | */ |
610 | void BlueBase::deviceActive( const QString& device, bool connected ) | 606 | void BlueBase::deviceActive( const QString& device, bool connected ) |
611 | { | 607 | { |
612 | odebug << "deviceActive slot" << oendl; | 608 | odebug << "deviceActive slot" << oendl; |
613 | 609 | ||
614 | QMap<QString,BTDeviceItem*>::Iterator it; | 610 | QMap<QString,BTDeviceItem*>::Iterator it; |
615 | 611 | ||
616 | it = m_deviceList.find( device ); | 612 | it = m_deviceList.find( device ); |
617 | if( it == m_deviceList.end() ) | 613 | if( it == m_deviceList.end() ) |
618 | return; | 614 | return; |
619 | 615 | ||
620 | BTDeviceItem* deviceItem = it.data(); | 616 | BTDeviceItem* deviceItem = it.data(); |
621 | 617 | ||
622 | 618 | ||
623 | if ( connected ) | 619 | if ( connected ) |
624 | { | 620 | { |
625 | deviceItem->setPixmap( 1, m_onPix ); | 621 | deviceItem->setPixmap( 1, m_onPix ); |
626 | } | 622 | } |
627 | else | 623 | else |
628 | { | 624 | { |
629 | deviceItem->setPixmap( 1, m_offPix ); | 625 | deviceItem->setPixmap( 1, m_offPix ); |
630 | } | 626 | } |
631 | m_deviceList.remove( it ); | 627 | m_deviceList.remove( it ); |
632 | } | 628 | } |
633 | 629 | ||
634 | 630 | ||
635 | /** | 631 | /** |
636 | * Open the "scan for devices" dialog | 632 | * Open the "scan for devices" dialog |