author | harlekin <harlekin> | 2002-07-21 21:59:53 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-21 21:59:53 (UTC) |
commit | 5eca9401acbc4e683f1a78126272c5bd0c23c796 (patch) (unidiff) | |
tree | 8211d3f33ebade18539659f36188dcda37f59553 | |
parent | 536f6562d6f12210527814afbcd05a02d05afe83 (diff) | |
download | opie-5eca9401acbc4e683f1a78126272c5bd0c23c796.zip opie-5eca9401acbc4e683f1a78126272c5bd0c23c796.tar.gz opie-5eca9401acbc4e683f1a78126272c5bd0c23c796.tar.bz2 |
paperbag
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 1fd0ea2..6c17974 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -156,401 +156,398 @@ void BlueBase::writeToHciConfig() { | |||
156 | qWarning("writeToHciConfig"); | 156 | qWarning("writeToHciConfig"); |
157 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | 157 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); |
158 | hciconf.load(); | 158 | hciconf.load(); |
159 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 159 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
160 | hciconf.setName( m_deviceName ); | 160 | hciconf.setName( m_deviceName ); |
161 | hciconf.setEncrypt( m_useEncryption ); | 161 | hciconf.setEncrypt( m_useEncryption ); |
162 | hciconf.setAuth( m_enableAuthentification ); | 162 | hciconf.setAuth( m_enableAuthentification ); |
163 | hciconf.setPscan( m_enablePagescan ); | 163 | hciconf.setPscan( m_enablePagescan ); |
164 | hciconf.setIscan( m_enableInquiryscan ); | 164 | hciconf.setIscan( m_enableInquiryscan ); |
165 | hciconf.save(); | 165 | hciconf.save(); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Read the list of allready known devices | 170 | * Read the list of allready known devices |
171 | */ | 171 | */ |
172 | void BlueBase::readSavedDevices() { | 172 | void BlueBase::readSavedDevices() { |
173 | 173 | ||
174 | QValueList<RemoteDevice> loadedDevices; | 174 | QValueList<RemoteDevice> loadedDevices; |
175 | DeviceHandler handler; | 175 | DeviceHandler handler; |
176 | loadedDevices = handler.load(); | 176 | loadedDevices = handler.load(); |
177 | 177 | ||
178 | addSearchedDevices( loadedDevices ); | 178 | addSearchedDevices( loadedDevices ); |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | /** | 182 | /** |
183 | * Write the list of allready known devices | 183 | * Write the list of allready known devices |
184 | */ | 184 | */ |
185 | void BlueBase::writeSavedDevices() { | 185 | void BlueBase::writeSavedDevices() { |
186 | QListViewItemIterator it( ListView2 ); | 186 | QListViewItemIterator it( ListView2 ); |
187 | BTListItem* item; | 187 | BTListItem* item; |
188 | BTDeviceItem* device; | 188 | BTDeviceItem* device; |
189 | RemoteDevice::ValueList list; | 189 | RemoteDevice::ValueList list; |
190 | for ( ; it.current(); ++it ) { | 190 | for ( ; it.current(); ++it ) { |
191 | item = (BTListItem*)it.current(); | 191 | item = (BTListItem*)it.current(); |
192 | if(item->typeId() != BTListItem::Device ) | 192 | if(item->typeId() != BTListItem::Device ) |
193 | continue; | 193 | continue; |
194 | device = (BTDeviceItem*)item; | 194 | device = (BTDeviceItem*)item; |
195 | 195 | ||
196 | list.append( device->remoteDevice() ); | 196 | list.append( device->remoteDevice() ); |
197 | } | 197 | } |
198 | /* | 198 | /* |
199 | * if not empty save the List through DeviceHandler | 199 | * if not empty save the List through DeviceHandler |
200 | */ | 200 | */ |
201 | if ( list.isEmpty() ) | 201 | if ( list.isEmpty() ) |
202 | return; | 202 | return; |
203 | DeviceHandler handler; | 203 | DeviceHandler handler; |
204 | handler.save( list ); | 204 | handler.save( list ); |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Set up the gui | 209 | * Set up the gui |
210 | */ | 210 | */ |
211 | void BlueBase::initGui() { | 211 | void BlueBase::initGui() { |
212 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 212 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
213 | cryptCheckBox->setChecked( m_useEncryption ); | 213 | cryptCheckBox->setChecked( m_useEncryption ); |
214 | authCheckBox->setChecked( m_enableAuthentification ); | 214 | authCheckBox->setChecked( m_enableAuthentification ); |
215 | pagescanCheckBox->setChecked( m_enablePagescan ); | 215 | pagescanCheckBox->setChecked( m_enablePagescan ); |
216 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 216 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
217 | deviceNameLine->setText( m_deviceName ); | 217 | deviceNameLine->setText( m_deviceName ); |
218 | passkeyLine->setText( m_defaultPasskey ); | 218 | passkeyLine->setText( m_defaultPasskey ); |
219 | // set info tab | 219 | // set info tab |
220 | setInfo(); | 220 | setInfo(); |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Get the status informations and returns it | 225 | * Get the status informations and returns it |
226 | * @return QString the status informations gathered | 226 | * @return QString the status informations gathered |
227 | */ | 227 | */ |
228 | QString BlueBase::status()const{ | 228 | QString BlueBase::status()const{ |
229 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 229 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
230 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 230 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
231 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 231 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
232 | 232 | ||
233 | return (infoString); | 233 | return (infoString); |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | /** | 237 | /** |
238 | * Read the current values from the gui and invoke writeConfig() | 238 | * Read the current values from the gui and invoke writeConfig() |
239 | */ | 239 | */ |
240 | void BlueBase::applyConfigChanges() { | 240 | void BlueBase::applyConfigChanges() { |
241 | m_deviceName = deviceNameLine->text(); | 241 | m_deviceName = deviceNameLine->text(); |
242 | m_defaultPasskey = passkeyLine->text(); | 242 | m_defaultPasskey = passkeyLine->text(); |
243 | m_useEncryption = cryptCheckBox->isChecked(); | 243 | m_useEncryption = cryptCheckBox->isChecked(); |
244 | m_enableAuthentification = authCheckBox->isChecked(); | 244 | m_enableAuthentification = authCheckBox->isChecked(); |
245 | m_enablePagescan = pagescanCheckBox->isChecked(); | 245 | m_enablePagescan = pagescanCheckBox->isChecked(); |
246 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 246 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
247 | 247 | ||
248 | writeConfig(); | 248 | writeConfig(); |
249 | 249 | ||
250 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 250 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
251 | } | 251 | } |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Add fresh found devices from scan dialog to the listing | 254 | * Add fresh found devices from scan dialog to the listing |
255 | * | 255 | * |
256 | */ | 256 | */ |
257 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 257 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
258 | BTDeviceItem * deviceItem; | 258 | BTDeviceItem * deviceItem; |
259 | QValueList<RemoteDevice>::ConstIterator it; | 259 | QValueList<RemoteDevice>::ConstIterator it; |
260 | 260 | ||
261 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 261 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
262 | 262 | ||
263 | if (find( (*it) )) // is already inserted | 263 | if (find( (*it) )) // is already inserted |
264 | continue; | 264 | continue; |
265 | 265 | ||
266 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); | 266 | deviceItem = new BTDeviceItem( ListView2 , (*it) ); |
267 | deviceItem->setPixmap( 1, m_findPix ); | 267 | deviceItem->setPixmap( 1, m_findPix ); |
268 | deviceItem->setExpandable ( true ); | 268 | deviceItem->setExpandable ( true ); |
269 | 269 | ||
270 | // look if device is avail. atm, async | 270 | // look if device is avail. atm, async |
271 | deviceActive( (*it) ); | 271 | deviceActive( (*it) ); |
272 | 272 | ||
273 | // ggf auch hier? | 273 | // ggf auch hier? |
274 | addServicesToDevice( deviceItem ); | 274 | addServicesToDevice( deviceItem ); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | /** | 279 | /** |
280 | * Action that is toggled on entrys on click | 280 | * Action that is toggled on entrys on click |
281 | */ | 281 | */ |
282 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 282 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | /** | 286 | /** |
287 | * Action that are toggled on hold (mostly QPopups i guess) | 287 | * Action that are toggled on hold (mostly QPopups i guess) |
288 | */ | 288 | */ |
289 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 289 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
290 | if (!item ) | 290 | if (!item ) |
291 | return; | 291 | return; |
292 | 292 | ||
293 | QPopupMenu *menu = new QPopupMenu(); | 293 | QPopupMenu *menu = new QPopupMenu(); |
294 | int ret=0; | 294 | int ret=0; |
295 | 295 | ||
296 | if ( ((BTListItem*)item)->type() == "device") { | 296 | if ( ((BTListItem*)item)->type() == "device") { |
297 | 297 | ||
298 | QPopupMenu *groups = new QPopupMenu(); | 298 | QPopupMenu *groups = new QPopupMenu(); |
299 | 299 | ||
300 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); | 300 | menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); |
301 | menu->insertSeparator(1); | 301 | menu->insertSeparator(1); |
302 | menu->insertItem( tr("rescan sevices"), 2); | 302 | menu->insertItem( tr("rescan sevices"), 2); |
303 | menu->insertItem( tr("to group"), groups , 3); | 303 | menu->insertItem( tr("to group"), groups , 3); |
304 | menu->insertItem( tr("delete"), 4); | 304 | menu->insertItem( tr("delete"), 4); |
305 | 305 | ||
306 | ret = menu->exec( point , 0); | 306 | ret = menu->exec( point , 0); |
307 | 307 | ||
308 | switch(ret) { | 308 | switch(ret) { |
309 | case -1: | 309 | case -1: |
310 | break; | 310 | break; |
311 | case 0: | 311 | case 0: |
312 | addServicesToDevice( (BTDeviceItem*)item ); | 312 | addServicesToDevice( (BTDeviceItem*)item ); |
313 | break; | 313 | break; |
314 | case 1: | 314 | case 1: |
315 | 315 | ||
316 | break; | 316 | break; |
317 | 317 | ||
318 | // NO need to, since hcid does that on the fly | 318 | // NO need to, since hcid does that on the fly |
319 | // case 2: | 319 | // case 2: |
320 | // make connection | 320 | // make connection |
321 | //m_localDevice->connectTo( ((BTDeviceItem*)item)->mac() ); | 321 | //m_localDevice->connectTo( ((BTDeviceItem*)item)->mac() ); |
322 | //break; | 322 | //break; |
323 | case 3: | 323 | case 3: |
324 | // deletes childs too | 324 | // deletes childs too |
325 | delete item; | 325 | delete item; |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | delete groups; | 328 | delete groups; |
329 | 329 | ||
330 | } | 330 | } |
331 | 331 | ||
332 | /* | 332 | /* |
333 | * We got service sensitive PopupMenus in our factory | 333 | * We got service sensitive PopupMenus in our factory |
334 | * We will create one through the factory and will insert | 334 | * We will create one through the factory and will insert |
335 | * our Separator + ShowInfo into the menu or create a new | 335 | * our Separator + ShowInfo into the menu or create a new |
336 | * one if the factory returns 0 | 336 | * one if the factory returns 0 |
337 | * PopupMenu deletion is kind of weird. | 337 | * PopupMenu deletion is kind of weird. |
338 | * If escaped( -1 ) or any of our items were chosen we'll | 338 | * If escaped( -1 ) or any of our items were chosen we'll |
339 | * delete the PopupMenu otherwise it's the responsibility of | 339 | * delete the PopupMenu otherwise it's the responsibility of |
340 | * the PopupMenu to delete itself | 340 | * the PopupMenu to delete itself |
341 | * | 341 | * |
342 | */ | 342 | */ |
343 | else if ( ((BTListItem*)item)->type() == "service") { | 343 | else if ( ((BTListItem*)item)->type() == "service") { |
344 | BTServiceItem* service = (BTServiceItem*)item; | 344 | BTServiceItem* service = (BTServiceItem*)item; |
345 | QMap<int, QString> list = service->services().classIdList(); | 345 | QMap<int, QString> list = service->services().classIdList(); |
346 | QMap<int, QString>::Iterator it = list.begin(); | 346 | QMap<int, QString>::Iterator it = list.begin(); |
347 | QPopupMenu *popup =0l; | 347 | QPopupMenu *popup =0l; |
348 | popup->insertItem( (service->services()).serviceName() ); | ||
349 | popup->insertSeparator(); | ||
350 | if ( it != list.end() ) { | 348 | if ( it != list.end() ) { |
351 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); | 349 | qWarning("Searching id %d %s", it.key(), it.data().latin1() ); |
352 | popup = m_popHelper.find( it.key() /*1*/, | 350 | popup = m_popHelper.find( it.key() /*1*/, |
353 | service->services(), | 351 | service->services(), |
354 | (BTDeviceItem*)service->parent() ); | 352 | (BTDeviceItem*)service->parent() ); |
355 | }else { | 353 | }else { |
356 | qWarning("Empty"); | 354 | qWarning("Empty"); |
357 | } | 355 | } |
358 | 356 | ||
359 | if ( popup == 0l ) { | 357 | if ( popup == 0l ) { |
360 | qWarning("factory returned 0l"); | 358 | qWarning("factory returned 0l"); |
361 | popup = new QPopupMenu(); | 359 | popup = new QPopupMenu(); |
362 | } | 360 | } |
363 | 361 | int test1 = popup->insertItem( tr("Test1:"), 2); | |
364 | int test1 = popup->insertItem( tr("Test1:"), 0); | ||
365 | 362 | ||
366 | ret = popup->exec( point ); | 363 | ret = popup->exec( point ); |
367 | qWarning("returned from exec() "); | 364 | qWarning("returned from exec() "); |
368 | if ( ret == -1 ) { | 365 | if ( ret == -1 ) { |
369 | ; | 366 | ; |
370 | } else if ( ret == test1 ) { | 367 | } else if ( ret == test1 ) { |
371 | ; | 368 | ; |
372 | } | 369 | } |
373 | delete popup; | 370 | delete popup; |
374 | } | 371 | } |
375 | delete menu; | 372 | delete menu; |
376 | } | 373 | } |
377 | 374 | ||
378 | 375 | ||
379 | /** | 376 | /** |
380 | * Search and display avail. services for a device (on expand from device listing) | 377 | * Search and display avail. services for a device (on expand from device listing) |
381 | * @param item the service item returned | 378 | * @param item the service item returned |
382 | */ | 379 | */ |
383 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { | 380 | void BlueBase::addServicesToDevice( BTDeviceItem * item ) { |
384 | qDebug("addServicesToDevice"); | 381 | qDebug("addServicesToDevice"); |
385 | // row of mac adress text(3) | 382 | // row of mac adress text(3) |
386 | RemoteDevice device = item->remoteDevice(); | 383 | RemoteDevice device = item->remoteDevice(); |
387 | m_deviceList.insert( item->mac() , item ); | 384 | m_deviceList.insert( item->mac() , item ); |
388 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 385 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
389 | m_localDevice->searchServices( device ); | 386 | m_localDevice->searchServices( device ); |
390 | } | 387 | } |
391 | 388 | ||
392 | 389 | ||
393 | /** | 390 | /** |
394 | * Overloaded. This one it the one that is connected to the foundServices signal | 391 | * Overloaded. This one it the one that is connected to the foundServices signal |
395 | * @param device the mac address of the remote device | 392 | * @param device the mac address of the remote device |
396 | * @param servicesList the list with the service the device has. | 393 | * @param servicesList the list with the service the device has. |
397 | */ | 394 | */ |
398 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 395 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
399 | qDebug("fill services list"); | 396 | qDebug("fill services list"); |
400 | 397 | ||
401 | QMap<QString,BTDeviceItem*>::Iterator it; | 398 | QMap<QString,BTDeviceItem*>::Iterator it; |
402 | BTDeviceItem* deviceItem = 0; | 399 | BTDeviceItem* deviceItem = 0; |
403 | 400 | ||
404 | // get the right devices which requested the search | 401 | // get the right devices which requested the search |
405 | it = m_deviceList.find( device ); | 402 | it = m_deviceList.find( device ); |
406 | if( it == m_deviceList.end() ) | 403 | if( it == m_deviceList.end() ) |
407 | return; | 404 | return; |
408 | deviceItem = it.data(); | 405 | deviceItem = it.data(); |
409 | 406 | ||
410 | QValueList<OpieTooth::Services>::Iterator it2; | 407 | QValueList<OpieTooth::Services>::Iterator it2; |
411 | BTServiceItem * serviceItem; | 408 | BTServiceItem * serviceItem; |
412 | 409 | ||
413 | if (!servicesList.isEmpty() ) { | 410 | if (!servicesList.isEmpty() ) { |
414 | // add services | 411 | // add services |
415 | QMap<int, QString> list; | 412 | QMap<int, QString> list; |
416 | QMap<int, QString>::Iterator classIt; | 413 | QMap<int, QString>::Iterator classIt; |
417 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 414 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
418 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); | 415 | serviceItem = new BTServiceItem( deviceItem , (*it2) ); |
419 | list = (*it2).classIdList(); | 416 | list = (*it2).classIdList(); |
420 | classIt = list.begin(); | 417 | classIt = list.begin(); |
421 | int classId=0; | 418 | int classId=0; |
422 | if ( classIt != list.end() ) { | 419 | if ( classIt != list.end() ) { |
423 | classId = classIt.key(); | 420 | classId = classIt.key(); |
424 | } | 421 | } |
425 | 422 | ||
426 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); | 423 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); |
427 | } | 424 | } |
428 | } else { | 425 | } else { |
429 | Services s1; | 426 | Services s1; |
430 | s1.setServiceName( tr("no serives found") ); | 427 | s1.setServiceName( tr("no serives found") ); |
431 | serviceItem = new BTServiceItem( deviceItem, s1 ); | 428 | serviceItem = new BTServiceItem( deviceItem, s1 ); |
432 | } | 429 | } |
433 | // now remove them from the list | 430 | // now remove them from the list |
434 | m_deviceList.remove( it ); | 431 | m_deviceList.remove( it ); |
435 | } | 432 | } |
436 | 433 | ||
437 | 434 | ||
438 | /** | 435 | /** |
439 | * Add the existing connections (pairs) to the connections tab. | 436 | * Add the existing connections (pairs) to the connections tab. |
440 | * This one triggers the search | 437 | * This one triggers the search |
441 | */ | 438 | */ |
442 | void BlueBase::addConnectedDevices() { | 439 | void BlueBase::addConnectedDevices() { |
443 | m_localDevice->searchConnections(); | 440 | m_localDevice->searchConnections(); |
444 | } | 441 | } |
445 | 442 | ||
446 | 443 | ||
447 | /** | 444 | /** |
448 | * This adds the found connections to the connection tab. | 445 | * This adds the found connections to the connection tab. |
449 | * @param connectionList the ValueList with all current connections | 446 | * @param connectionList the ValueList with all current connections |
450 | */ | 447 | */ |
451 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { | 448 | void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { |
452 | 449 | ||
453 | // clear the ListView first | 450 | // clear the ListView first |
454 | ListView4->clear(); | 451 | ListView4->clear(); |
455 | 452 | ||
456 | QValueList<OpieTooth::ConnectionState>::Iterator it; | 453 | QValueList<OpieTooth::ConnectionState>::Iterator it; |
457 | BTConnectionItem * connectionItem; | 454 | BTConnectionItem * connectionItem; |
458 | 455 | ||
459 | if ( !connectionList.isEmpty() ) { | 456 | if ( !connectionList.isEmpty() ) { |
460 | 457 | ||
461 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 458 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
462 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); | 459 | connectionItem = new BTConnectionItem( ListView4 , (*it) ); |
463 | } | 460 | } |
464 | } else { | 461 | } else { |
465 | ConnectionState con; | 462 | ConnectionState con; |
466 | con.setMac( tr("No connections found") ); | 463 | con.setMac( tr("No connections found") ); |
467 | connectionItem = new BTConnectionItem( ListView4 , con ); | 464 | connectionItem = new BTConnectionItem( ListView4 , con ); |
468 | } | 465 | } |
469 | 466 | ||
470 | // recall connection search after some time | 467 | // recall connection search after some time |
471 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | 468 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); |
472 | } | 469 | } |
473 | 470 | ||
474 | 471 | ||
475 | /** | 472 | /** |
476 | * Find out if a device can currently be reached | 473 | * Find out if a device can currently be reached |
477 | * @param device | 474 | * @param device |
478 | */ | 475 | */ |
479 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 476 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
480 | // search by mac, async, gets a signal back | 477 | // search by mac, async, gets a signal back |
481 | // We should have a BTDeviceItem there or where does it get added to the map -zecke | 478 | // We should have a BTDeviceItem there or where does it get added to the map -zecke |
482 | m_localDevice->isAvailable( device.mac() ); | 479 | m_localDevice->isAvailable( device.mac() ); |
483 | } | 480 | } |
484 | 481 | ||
485 | 482 | ||
486 | /** | 483 | /** |
487 | * The signal catcher. Set the avail. status on device. | 484 | * The signal catcher. Set the avail. status on device. |
488 | * @param device - the mac address | 485 | * @param device - the mac address |
489 | * @param connected - if it is avail. or not | 486 | * @param connected - if it is avail. or not |
490 | */ | 487 | */ |
491 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 488 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
492 | qDebug("deviceActive slot"); | 489 | qDebug("deviceActive slot"); |
493 | 490 | ||
494 | QMap<QString,BTDeviceItem*>::Iterator it; | 491 | QMap<QString,BTDeviceItem*>::Iterator it; |
495 | 492 | ||
496 | it = m_deviceList.find( device ); | 493 | it = m_deviceList.find( device ); |
497 | if( it == m_deviceList.end() ) | 494 | if( it == m_deviceList.end() ) |
498 | return; | 495 | return; |
499 | 496 | ||
500 | BTDeviceItem* deviceItem = it.data(); | 497 | BTDeviceItem* deviceItem = it.data(); |
501 | 498 | ||
502 | 499 | ||
503 | if ( connected ) { | 500 | if ( connected ) { |
504 | deviceItem->setPixmap( 1, m_onPix ); | 501 | deviceItem->setPixmap( 1, m_onPix ); |
505 | } else { | 502 | } else { |
506 | deviceItem->setPixmap( 1, m_offPix ); | 503 | deviceItem->setPixmap( 1, m_offPix ); |
507 | } | 504 | } |
508 | m_deviceList.remove( it ); | 505 | m_deviceList.remove( it ); |
509 | } | 506 | } |
510 | 507 | ||
511 | 508 | ||
512 | /** | 509 | /** |
513 | * Open the "scan for devices" dialog | 510 | * Open the "scan for devices" dialog |
514 | */ | 511 | */ |
515 | void BlueBase::startScan() { | 512 | void BlueBase::startScan() { |
516 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", | 513 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
517 | true, WDestructiveClose ); | 514 | true, WDestructiveClose ); |
518 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), | 515 | QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), |
519 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); | 516 | this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); |
520 | 517 | ||
521 | scan->showMaximized(); | 518 | scan->showMaximized(); |
522 | } | 519 | } |
523 | 520 | ||
524 | 521 | ||
525 | /** | 522 | /** |
526 | * Set the informations about the local device in information Tab | 523 | * Set the informations about the local device in information Tab |
527 | */ | 524 | */ |
528 | void BlueBase::setInfo() { | 525 | void BlueBase::setInfo() { |
529 | StatusLabel->setText( status() ); | 526 | StatusLabel->setText( status() ); |
530 | } | 527 | } |
531 | 528 | ||
532 | 529 | ||
533 | /** | 530 | /** |
534 | * Decontructor | 531 | * Decontructor |
535 | */ | 532 | */ |
536 | BlueBase::~BlueBase() { | 533 | BlueBase::~BlueBase() { |
537 | writeSavedDevices(); | 534 | writeSavedDevices(); |
538 | delete m_iconLoader; | 535 | delete m_iconLoader; |
539 | } | 536 | } |
540 | 537 | ||
541 | 538 | ||
542 | /** | 539 | /** |
543 | * find searches the ListView for a BTDeviceItem containig | 540 | * find searches the ListView for a BTDeviceItem containig |
544 | * the same Device if found return true else false | 541 | * the same Device if found return true else false |
545 | * @param dev RemoteDevice to find | 542 | * @param dev RemoteDevice to find |
546 | * @return returns true if found | 543 | * @return returns true if found |
547 | */ | 544 | */ |
548 | bool BlueBase::find( const RemoteDevice& rem ) { | 545 | bool BlueBase::find( const RemoteDevice& rem ) { |
549 | QListViewItemIterator it( ListView2 ); | 546 | QListViewItemIterator it( ListView2 ); |
550 | BTListItem* item; | 547 | BTListItem* item; |
551 | BTDeviceItem* device; | 548 | BTDeviceItem* device; |
552 | for (; it.current(); ++it ) { | 549 | for (; it.current(); ++it ) { |
553 | item = (BTListItem*) it.current(); | 550 | item = (BTListItem*) it.current(); |
554 | if ( item->typeId() != BTListItem::Device ) | 551 | if ( item->typeId() != BTListItem::Device ) |
555 | continue; | 552 | continue; |
556 | 553 | ||