Diffstat (limited to 'noncore/net/opietooth/manager') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 68 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bticonloader.cpp | 77 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bticonloader.h | 37 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 4 |
6 files changed, 135 insertions, 56 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index d023302..2001db1 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -39,41 +39,38 @@ | |||
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | 40 | ||
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
43 | 43 | ||
44 | #include <remotedevice.h> | 44 | #include <remotedevice.h> |
45 | 45 | #include <services.h> | |
46 | 46 | ||
47 | namespace OpieTooth { | 47 | namespace OpieTooth { |
48 | 48 | ||
49 | |||
50 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 49 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
51 | : BluetoothBase( parent, name, fl ) { | 50 | : BluetoothBase( parent, name, fl ) { |
52 | 51 | ||
53 | localDevice = new Manager( "hci0" ); | 52 | localDevice = new Manager( "hci0" ); |
54 | 53 | ||
55 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 54 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
56 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 55 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
57 | // not good since lib is async | 56 | // not good since lib is async |
58 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 57 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
59 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 58 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
60 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 59 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
61 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 60 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
62 | // hehe, cast right later | ||
63 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 61 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
64 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 62 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
65 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 63 | connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
66 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 64 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
67 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), | 65 | connect( localDevice, SIGNAL( available( const QString&, bool ) ), |
68 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 66 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
69 | connect( localDevice, SIGNAL( connections( Connection::ValueList ) ), | 67 | connect( localDevice, SIGNAL( connections( Connection::ValueList ) ), |
70 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); | 68 | this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); |
71 | 69 | ||
72 | //Load all icons needed | 70 | //Load all icons needed |
73 | |||
74 | offPix = Resource::loadPixmap( "editdelete" ); | 71 | offPix = Resource::loadPixmap( "editdelete" ); |
75 | onPix = Resource::loadPixmap( "installed" ); | 72 | onPix = Resource::loadPixmap( "installed" ); |
76 | 73 | ||
77 | QPalette pal = this->palette(); | 74 | QPalette pal = this->palette(); |
78 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 75 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
79 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 76 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
@@ -91,42 +88,40 @@ namespace OpieTooth { | |||
91 | ListView2->setRootIsDecorated(true); | 88 | ListView2->setRootIsDecorated(true); |
92 | 89 | ||
93 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); | 90 | BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); |
94 | topLV2->setPixmap( 1, onPix ); | 91 | topLV2->setPixmap( 1, onPix ); |
95 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); | 92 | (void) new BTListItem( topLV2, "Serial" ,"", "service" ); |
96 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); | 93 | (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); |
94 | |||
97 | writeToHciConfig(); | 95 | writeToHciConfig(); |
98 | // search conncetions | 96 | // search conncetions |
99 | addConnectedDevices(); | 97 | addConnectedDevices(); |
100 | } | 98 | iconLoader = new BTIconLoader(); |
101 | 99 | } | |
102 | 100 | ||
103 | /** | 101 | /** |
104 | * Reads all options from the config file | 102 | * Reads all options from the config file |
105 | */ | 103 | */ |
106 | void BlueBase::readConfig() { | 104 | void BlueBase::readConfig() { |
107 | 105 | ||
108 | Config cfg( "bluetoothmanager" ); | 106 | Config cfg( "bluetoothmanager" ); |
109 | cfg.setGroup( "bluezsettings" ); | 107 | cfg.setGroup( "bluezsettings" ); |
110 | 108 | ||
111 | |||
112 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 109 | deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
113 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 110 | defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
114 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); | 111 | useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); |
115 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); | 112 | enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); |
116 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); | 113 | enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); |
117 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); | 114 | enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); |
118 | |||
119 | } | 115 | } |
120 | 116 | ||
121 | /** | 117 | /** |
122 | * Writes all options to the config file | 118 | * Writes all options to the config file |
123 | */ | 119 | */ |
124 | void BlueBase::writeConfig() { | 120 | void BlueBase::writeConfig() { |
125 | 121 | ||
126 | |||
127 | Config cfg( "bluetoothmanager" ); | 122 | Config cfg( "bluetoothmanager" ); |
128 | cfg.setGroup( "bluezsettings" ); | 123 | cfg.setGroup( "bluezsettings" ); |
129 | 124 | ||
130 | cfg.writeEntry( "name" , deviceName ); | 125 | cfg.writeEntry( "name" , deviceName ); |
131 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); | 126 | cfg.writeEntryCrypt( "passkey" , defaultPasskey ); |
132 | cfg.writeEntry( "useEncryption" , useEncryption ); | 127 | cfg.writeEntry( "useEncryption" , useEncryption ); |
@@ -207,35 +202,29 @@ namespace OpieTooth { | |||
207 | 202 | ||
208 | /** | 203 | /** |
209 | * Write the list of allready known devices | 204 | * Write the list of allready known devices |
210 | * | 205 | * |
211 | */ | 206 | */ |
212 | void BlueBase::writeSavedDevices() { | 207 | void BlueBase::writeSavedDevices() { |
213 | |||
214 | QListViewItemIterator it( ListView2 ); | 208 | QListViewItemIterator it( ListView2 ); |
215 | 209 | ||
216 | for ( ; it.current(); ++it ) { | 210 | for ( ; it.current(); ++it ) { |
217 | |||
218 | // seperate config file for each device, to store more information in future. | 211 | // seperate config file for each device, to store more information in future. |
219 | // TO FIX: BTLISTITEM!!! | ||
220 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); | 212 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); |
221 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); | 213 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); |
222 | |||
223 | conf.setGroup( "Info" ); | 214 | conf.setGroup( "Info" ); |
224 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); | 215 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); |
225 | } | 216 | } |
226 | } | 217 | } |
227 | 218 | ||
228 | 219 | ||
229 | /** | 220 | /** |
230 | * Set up the gui | 221 | * Set up the gui |
231 | */ | 222 | */ |
232 | void BlueBase::initGui() { | 223 | void BlueBase::initGui() { |
233 | |||
234 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() | 224 | StatusLabel->setText( getStatus() ); // maybe move it to getStatus() |
235 | |||
236 | cryptCheckBox->setChecked( useEncryption ); | 225 | cryptCheckBox->setChecked( useEncryption ); |
237 | authCheckBox->setChecked( enableAuthentification ); | 226 | authCheckBox->setChecked( enableAuthentification ); |
238 | pagescanCheckBox->setChecked( enablePagescan ); | 227 | pagescanCheckBox->setChecked( enablePagescan ); |
239 | inquiryscanCheckBox->setChecked( enableInquiryscan ); | 228 | inquiryscanCheckBox->setChecked( enableInquiryscan ); |
240 | deviceNameLine->setText( deviceName ); | 229 | deviceNameLine->setText( deviceName ); |
241 | passkeyLine->setText( defaultPasskey ); | 230 | passkeyLine->setText( defaultPasskey ); |
@@ -246,56 +235,48 @@ namespace OpieTooth { | |||
246 | 235 | ||
247 | /** | 236 | /** |
248 | * Get the status informations and returns it | 237 | * Get the status informations and returns it |
249 | * @return QString the status informations gathered | 238 | * @return QString the status informations gathered |
250 | */ | 239 | */ |
251 | QString BlueBase::getStatus(){ | 240 | QString BlueBase::getStatus(){ |
252 | |||
253 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 241 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
254 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 242 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
255 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 243 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
256 | 244 | ||
257 | return (infoString); | 245 | return (infoString); |
258 | } | 246 | } |
259 | 247 | ||
260 | 248 | ||
261 | /** | 249 | /** |
262 | * Read the current values from the gui and invoke writeConfig() | 250 | * Read the current values from the gui and invoke writeConfig() |
263 | */ | 251 | */ |
264 | void BlueBase::applyConfigChanges() { | 252 | void BlueBase::applyConfigChanges() { |
265 | |||
266 | deviceName = deviceNameLine->text(); | 253 | deviceName = deviceNameLine->text(); |
267 | defaultPasskey = passkeyLine->text(); | 254 | defaultPasskey = passkeyLine->text(); |
268 | useEncryption = cryptCheckBox->isChecked(); | 255 | useEncryption = cryptCheckBox->isChecked(); |
269 | enableAuthentification = authCheckBox->isChecked(); | 256 | enableAuthentification = authCheckBox->isChecked(); |
270 | enablePagescan = pagescanCheckBox->isChecked(); | 257 | enablePagescan = pagescanCheckBox->isChecked(); |
271 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 258 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
272 | 259 | ||
273 | writeConfig(); | 260 | writeConfig(); |
274 | 261 | ||
275 | |||
276 | QMessageBox* box = new QMessageBox( this, "Test" ); | 262 | QMessageBox* box = new QMessageBox( this, "Test" ); |
277 | box->setText( tr( "Changes applied" ) ); | 263 | box->setText( tr( "Changes applied" ) ); |
278 | box->show(); | 264 | box->show(); |
279 | // falls nötig hcid killhupen - die funktionalität adden | 265 | } |
280 | } | ||
281 | |||
282 | 266 | ||
283 | /** | 267 | /** |
284 | * Add fresh found devices from scan dialog to the listing | 268 | * Add fresh found devices from scan dialog to the listing |
285 | * | 269 | * |
286 | */ | 270 | */ |
287 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { | 271 | void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { |
288 | |||
289 | BTListItem * deviceItem; | 272 | BTListItem * deviceItem; |
290 | |||
291 | QListIterator<RemoteDevice> it( newDevices ); | 273 | QListIterator<RemoteDevice> it( newDevices ); |
292 | 274 | ||
293 | for( ; it.current() ; ++it ) { | 275 | for( ; it.current() ; ++it ) { |
294 | 276 | ||
295 | |||
296 | RemoteDevice *dev = it.current(); | 277 | RemoteDevice *dev = it.current(); |
297 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); | 278 | deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); |
298 | deviceItem->setExpandable ( true ); | 279 | deviceItem->setExpandable ( true ); |
299 | 280 | ||
300 | // look if device is avail. atm, async | 281 | // look if device is avail. atm, async |
301 | deviceActive( dev ); | 282 | deviceActive( dev ); |
@@ -307,45 +288,42 @@ namespace OpieTooth { | |||
307 | 288 | ||
308 | 289 | ||
309 | /** | 290 | /** |
310 | * Action that is toggled on entrys on click | 291 | * Action that is toggled on entrys on click |
311 | */ | 292 | */ |
312 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { | 293 | void BlueBase::startServiceActionClicked( QListViewItem *item ) { |
313 | |||
314 | |||
315 | } | 294 | } |
316 | 295 | ||
317 | /** | 296 | /** |
318 | * Action that are toggled on hold (mostly QPopups i guess) | 297 | * Action that are toggled on hold (mostly QPopups i guess) |
319 | */ | 298 | */ |
320 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { | 299 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { |
321 | 300 | ||
322 | QPopupMenu *menu = new QPopupMenu(); | 301 | QPopupMenu *menu = new QPopupMenu(); |
323 | |||
324 | int ret=0; | 302 | int ret=0; |
325 | 303 | ||
326 | |||
327 | //QSize s = menu->sizeHint ( ); | ||
328 | |||
329 | if ( ((BTListItem*)item)->type() == "device") { | 304 | if ( ((BTListItem*)item)->type() == "device") { |
330 | 305 | ||
331 | QPopupMenu *groups = new QPopupMenu(); | 306 | QPopupMenu *groups = new QPopupMenu(); |
332 | 307 | ||
333 | menu->insertItem( tr("rescan sevices:"), 0); | 308 | menu->insertItem( tr("rescan sevices:"), 0); |
334 | menu->insertItem( tr("to group"), groups , 1); | 309 | menu->insertItem( tr("to group"), groups , 1); |
335 | menu->insertItem( tr("delete"), 2); | 310 | menu->insertItem( tr("bound device"), 2); |
336 | 311 | menu->insertItem( tr("delete"), 3); | |
337 | 312 | ||
338 | ret = menu->exec( point , 0); | 313 | ret = menu->exec( point , 0); |
339 | 314 | ||
340 | switch(ret) { | 315 | switch(ret) { |
341 | case 0: | 316 | case 0: |
342 | break; | 317 | break; |
343 | case 1: | 318 | case 1: |
344 | break; | 319 | break; |
345 | case 2: | 320 | case 2: |
321 | // make connection | ||
322 | break; | ||
323 | case 3: | ||
346 | // delete childs too | 324 | // delete childs too |
347 | delete item; | 325 | delete item; |
348 | break; | 326 | break; |
349 | } | 327 | } |
350 | delete groups; | 328 | delete groups; |
351 | 329 | ||
@@ -364,68 +342,59 @@ namespace OpieTooth { | |||
364 | case 2: | 342 | case 2: |
365 | // delete childs too | 343 | // delete childs too |
366 | delete item; | 344 | delete item; |
367 | break; | 345 | break; |
368 | } | 346 | } |
369 | } | 347 | } |
370 | |||
371 | delete menu; | 348 | delete menu; |
372 | } | 349 | } |
373 | 350 | ||
374 | /** | 351 | /** |
375 | * Search and display avail. services for a device (on expand from device listing) | 352 | * Search and display avail. services for a device (on expand from device listing) |
376 | * | 353 | * |
377 | */ | 354 | */ |
378 | void BlueBase::addServicesToDevice( BTListItem * item ) { | 355 | void BlueBase::addServicesToDevice( BTListItem * item ) { |
379 | |||
380 | qDebug("addServicesToDevice"); | 356 | qDebug("addServicesToDevice"); |
381 | // row of mac adress text(3) | 357 | // row of mac adress text(3) |
382 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); | 358 | RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); |
383 | |||
384 | deviceList.insert( item->mac() , item ); | 359 | deviceList.insert( item->mac() , item ); |
385 | |||
386 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 360 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
387 | localDevice->searchServices( *device ); | 361 | localDevice->searchServices( *device ); |
388 | 362 | delete device; | |
389 | // delete | ||
390 | } | 363 | } |
391 | 364 | ||
392 | 365 | ||
393 | /** | 366 | /** |
394 | * Overloaded. This one it the one that is connected to the foundServices signal | 367 | * Overloaded. This one it the one that is connected to the foundServices signal |
395 | * @param device the mac address of the remote device | 368 | * @param device the mac address of the remote device |
396 | * @param servicesList the list with the service the device has. | 369 | * @param servicesList the list with the service the device has. |
397 | */ | 370 | */ |
398 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 371 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
399 | |||
400 | qDebug("fill services list"); | 372 | qDebug("fill services list"); |
401 | 373 | ||
402 | QMap<QString,BTListItem*>::Iterator it; | 374 | QMap<QString,BTListItem*>::Iterator it; |
403 | 375 | BTListItem* deviceItem = 0; | |
404 | BTListItem* deviceItem; | ||
405 | 376 | ||
406 | // get the right devices which requested the search | 377 | // get the right devices which requested the search |
407 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 378 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
408 | if ( it.key() == device ) { | 379 | if ( it.key() == device ) { |
409 | deviceItem = it.data(); | 380 | deviceItem = it.data(); |
410 | } | 381 | } |
411 | } | 382 | } |
412 | 383 | ||
413 | QValueList<OpieTooth::Services>::Iterator it2; | 384 | QValueList<OpieTooth::Services>::Iterator it2; |
414 | |||
415 | BTListItem * serviceItem; | 385 | BTListItem * serviceItem; |
416 | 386 | ||
417 | if (!servicesList.isEmpty() ) { | 387 | if (!servicesList.isEmpty() ) { |
418 | // add services | 388 | // add services |
419 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 389 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
420 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 390 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); |
421 | //serviceItem->setText(4, "service"); | 391 | serviceItem->setPixmap( 0, iconLoader->serviceIcon( (*it2).classIdList() ) ); |
422 | } | 392 | } |
423 | } else { | 393 | } else { |
424 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); | 394 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); |
425 | //serviceItem->setText(4, "service"); | ||
426 | } | 395 | } |
427 | } | 396 | } |
428 | 397 | ||
429 | 398 | ||
430 | /** | 399 | /** |
431 | * Add the existing connections (pairs) to the connections tab. | 400 | * Add the existing connections (pairs) to the connections tab. |
@@ -434,13 +403,12 @@ namespace OpieTooth { | |||
434 | void BlueBase::addConnectedDevices() { | 403 | void BlueBase::addConnectedDevices() { |
435 | localDevice->searchConnections(); | 404 | localDevice->searchConnections(); |
436 | } | 405 | } |
437 | 406 | ||
438 | 407 | ||
439 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { | 408 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { |
440 | |||
441 | QValueList<OpieTooth::Connection>::Iterator it; | 409 | QValueList<OpieTooth::Connection>::Iterator it; |
442 | BTListItem * connectionItem; | 410 | BTListItem * connectionItem; |
443 | 411 | ||
444 | if ( !connectionList.isEmpty() ) { | 412 | if ( !connectionList.isEmpty() ) { |
445 | 413 | ||
446 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 414 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
@@ -455,29 +423,26 @@ namespace OpieTooth { | |||
455 | } | 423 | } |
456 | 424 | ||
457 | /** | 425 | /** |
458 | * Find out if a device can currently be reached | 426 | * Find out if a device can currently be reached |
459 | */ | 427 | */ |
460 | void BlueBase::deviceActive( RemoteDevice *device ) { | 428 | void BlueBase::deviceActive( RemoteDevice *device ) { |
461 | |||
462 | // search by mac, async, gets a signal back | 429 | // search by mac, async, gets a signal back |
463 | localDevice->isAvailable( device->mac() ); | 430 | localDevice->isAvailable( device->mac() ); |
464 | } | 431 | } |
465 | 432 | ||
466 | /** | 433 | /** |
467 | * The signal catcher. Set the avail. status on device. | 434 | * The signal catcher. Set the avail. status on device. |
468 | * @param device - the mac address | 435 | * @param device - the mac address |
469 | * @param connected - if it is avail. or not | 436 | * @param connected - if it is avail. or not |
470 | */ | 437 | */ |
471 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 438 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
472 | |||
473 | qDebug("deviceActive slot"); | 439 | qDebug("deviceActive slot"); |
474 | 440 | ||
475 | QMap<QString,BTListItem*>::Iterator it; | 441 | QMap<QString,BTListItem*>::Iterator it; |
476 | 442 | BTListItem* deviceItem = 0; | |
477 | BTListItem* deviceItem; | ||
478 | 443 | ||
479 | // get the right devices which requested the search | 444 | // get the right devices which requested the search |
480 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 445 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
481 | if ( it.key() == device ) { | 446 | if ( it.key() == device ) { |
482 | deviceItem = it.data(); | 447 | deviceItem = it.data(); |
483 | } | 448 | } |
@@ -485,22 +450,18 @@ namespace OpieTooth { | |||
485 | 450 | ||
486 | if ( connected ) { | 451 | if ( connected ) { |
487 | deviceItem->setPixmap( 1, onPix ); | 452 | deviceItem->setPixmap( 1, onPix ); |
488 | } else { | 453 | } else { |
489 | deviceItem->setPixmap( 1, offPix ); | 454 | deviceItem->setPixmap( 1, offPix ); |
490 | } | 455 | } |
491 | |||
492 | } | 456 | } |
493 | 457 | ||
494 | |||
495 | |||
496 | /** | 458 | /** |
497 | * Open the "scan for devices" dialog | 459 | * Open the "scan for devices" dialog |
498 | */ | 460 | */ |
499 | void BlueBase::startScan() { | 461 | void BlueBase::startScan() { |
500 | |||
501 | ScanDialog *scan = new ScanDialog( this, "", true); | 462 | ScanDialog *scan = new ScanDialog( this, "", true); |
502 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), | 463 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), |
503 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); | 464 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); |
504 | 465 | ||
505 | scan->showMaximized(); | 466 | scan->showMaximized(); |
506 | } | 467 | } |
@@ -515,9 +476,10 @@ namespace OpieTooth { | |||
515 | 476 | ||
516 | /** | 477 | /** |
517 | * Decontructor | 478 | * Decontructor |
518 | */ | 479 | */ |
519 | BlueBase::~BlueBase() { | 480 | BlueBase::~BlueBase() { |
520 | writeSavedDevices(); | 481 | writeSavedDevices(); |
482 | delete iconLoader; | ||
521 | } | 483 | } |
522 | } | 484 | } |
523 | 485 | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 0516c16..ce0483f 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -8,12 +8,13 @@ | |||
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | #include <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | 11 | ||
12 | #include "bluetoothbase.h" | 12 | #include "bluetoothbase.h" |
13 | #include "btlistitem.h" | 13 | #include "btlistitem.h" |
14 | #include "bticonloader.h" | ||
14 | 15 | ||
15 | #include <remotedevice.h> | 16 | #include <remotedevice.h> |
16 | #include <manager.h> | 17 | #include <manager.h> |
17 | 18 | ||
18 | class QVBox; | 19 | class QVBox; |
19 | class QHBoxLayout; | 20 | class QHBoxLayout; |
@@ -61,12 +62,14 @@ namespace OpieTooth { | |||
61 | int enablePagescan; | 62 | int enablePagescan; |
62 | int enableInquiryscan; | 63 | int enableInquiryscan; |
63 | 64 | ||
64 | QPixmap offPix; | 65 | QPixmap offPix; |
65 | QPixmap onPix; | 66 | QPixmap onPix; |
66 | 67 | ||
68 | BTIconLoader *iconLoader; | ||
69 | |||
67 | private slots: | 70 | private slots: |
68 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); | 71 | void addSearchedDevices( QList<RemoteDevice> &newDevices ); |
69 | void addServicesToDevice( BTListItem *item ); | 72 | void addServicesToDevice( BTListItem *item ); |
70 | void addServicesToDevice( const QString& device, Services::ValueList ); | 73 | void addServicesToDevice( const QString& device, Services::ValueList ); |
71 | void addConnectedDevices(); | 74 | void addConnectedDevices(); |
72 | void addConnectedDevices( Connection::ValueList ); | 75 | void addConnectedDevices( Connection::ValueList ); |
diff --git a/noncore/net/opietooth/manager/bticonloader.cpp b/noncore/net/opietooth/manager/bticonloader.cpp new file mode 100644 index 0000000..3fb0edd --- a/dev/null +++ b/noncore/net/opietooth/manager/bticonloader.cpp | |||
@@ -0,0 +1,77 @@ | |||
1 | |||
2 | #include "bticonloader.h" | ||
3 | |||
4 | #include <qpixmap.h> | ||
5 | #include <qpe/resource.h> | ||
6 | |||
7 | namespace OpieTooth { | ||
8 | |||
9 | |||
10 | BTIconLoader::BTIconLoader() { | ||
11 | |||
12 | // still need to find out real ids | ||
13 | deviceIcons.insert( "100" , "computer_16" ); | ||
14 | deviceIcons.insert( "101" , "phone_16" ); | ||
15 | deviceIcons.insert( "102" , "brain_16" ); | ||
16 | deviceIcons.insert( "103" , "conduit_16" ); | ||
17 | |||
18 | |||
19 | serviceIcons.insert( "0x1105" , "obex_16" ); //OBEXObjectPush | ||
20 | serviceIcons.insert( "0x1106" , "obex_16" ); //OBEXFileTransfer | ||
21 | serviceIcons.insert( "0x1111" , "print_16" ); //Fax | ||
22 | serviceIcons.insert( "0x1101" , "serial_16" ); //SerialPort | ||
23 | serviceIcons.insert( "0x1104" , "sync_16" ); //IrMCSync | ||
24 | serviceIcons.insert( "0x1107" , "sync_16" ); //IrMCSyncCommand | ||
25 | serviceIcons.insert( "0x1102" , "network_16" ); //LANAccessUsingPPP | ||
26 | serviceIcons.insert( "0x1103" , "network_16"); //DialupNetworking | ||
27 | serviceIcons.insert( "0x1108" , "phone_16"); // Headset | ||
28 | serviceIcons.insert( "0x1112" , "audio_16"); //HeadsetAudioGateway | ||
29 | serviceIcons.insert( "0x1109" , "phone_16"); // CordlessTelephony | ||
30 | serviceIcons.insert( "0x110A" , "audio_16"); // AudioSource | ||
31 | serviceIcons.insert( "0x110B" , "audio_16"); // AudioSink | ||
32 | serviceIcons.insert( "0x1126" , "print_16" ); //HCR_Print | ||
33 | serviceIcons.insert( "0x1128" , "phone_16" ); //Common_ISDN_Access | ||
34 | |||
35 | serviceIcons.insert( "0x1201" , "network_16" ); //GenericNetworking | ||
36 | serviceIcons.insert( "0x1202" , "folder_16" ); //GenericFileTransfer | ||
37 | serviceIcons.insert( "0x1128" , "audio_16" ); //GenericAudio | ||
38 | serviceIcons.insert( "0x1128" , "phone_16" ); //GenericTelephony | ||
39 | |||
40 | //serviceIcons.insert( "106" , "link_16" ); | ||
41 | //serviceIcons.insert( "107" , "misc_16" ); | ||
42 | } | ||
43 | |||
44 | BTIconLoader::~BTIconLoader() { | ||
45 | } | ||
46 | |||
47 | QPixmap BTIconLoader::deviceIcon( const QString &deviceClass ) { | ||
48 | |||
49 | QString iconName; | ||
50 | |||
51 | QMap<QString, QString>::Iterator it; | ||
52 | |||
53 | it = deviceIcons.find( deviceClass ); | ||
54 | iconName = it.data(); | ||
55 | |||
56 | if ( iconName.isEmpty() ) { | ||
57 | iconName = "unknown_16"; | ||
58 | } | ||
59 | return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); | ||
60 | } | ||
61 | |||
62 | QPixmap BTIconLoader::serviceIcon( const QString &serviceClass ) { | ||
63 | |||
64 | QString iconName; | ||
65 | |||
66 | QMap<QString, QString>::Iterator it; | ||
67 | |||
68 | it = deviceIcons.find( serviceClass ); | ||
69 | iconName = it.data(); | ||
70 | |||
71 | if ( iconName.isEmpty() ) { | ||
72 | iconName = "unknown_16"; | ||
73 | } | ||
74 | return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); | ||
75 | } | ||
76 | |||
77 | } | ||
diff --git a/noncore/net/opietooth/manager/bticonloader.h b/noncore/net/opietooth/manager/bticonloader.h new file mode 100644 index 0000000..1b48009 --- a/dev/null +++ b/noncore/net/opietooth/manager/bticonloader.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #ifndef BTICONLOADER_H | ||
2 | #define BTICONLOADER_H | ||
3 | |||
4 | #include <qpixmap.h> | ||
5 | #include <qmap.h> | ||
6 | |||
7 | namespace OpieTooth { | ||
8 | |||
9 | class BTIconLoader { | ||
10 | |||
11 | public: | ||
12 | |||
13 | BTIconLoader(); | ||
14 | ~BTIconLoader(); | ||
15 | |||
16 | /** | ||
17 | * Returns an icon depending on device class | ||
18 | * @param deviceClass the device class id | ||
19 | * @return the pixmap | ||
20 | */ | ||
21 | QPixmap deviceIcon( const QString &deviceClass ); | ||
22 | |||
23 | /** | ||
24 | * Returns an icon depending on service id | ||
25 | * @param serviceClass the service id | ||
26 | * @return the pixmap | ||
27 | */ | ||
28 | QPixmap serviceIcon( const QString &serviceClass ); | ||
29 | |||
30 | private: | ||
31 | // first ist id, second is icon name | ||
32 | QMap<QString,QString> deviceIcons; | ||
33 | QMap<QString,QString> serviceIcons; | ||
34 | }; | ||
35 | } | ||
36 | |||
37 | #endif | ||
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 2d6d7da..0b90e87 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | #include "hciconfwrapper.h" | 1 | #include "hciconfwrapper.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | #include <qregexp.h> | 6 | #include <qregexp.h> |
7 | 7 | ||
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 4fcf010..55f2fd2 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro | |||
@@ -1,11 +1,11 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on debug | 2 | CONFIG = qt warn_on debug |
3 | #CONFIG = qt warn_on release | 3 | #CONFIG = qt warn_on release |
4 | HEADERS = bluebase.h scandialog.h btlistitem.h hciconfwrapper.h | 4 | HEADERS = bluebase.h scandialog.h btlistitem.h hciconfwrapper.h bticonloader.h |
5 | SOURCES = main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp | 5 | SOURCES = main.cpp bluebase.cpp scandialog.cpp btlistitem.cpp hciconfwrapper.cpp bticonloader.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib | 7 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopietooth -lopie | 9 | LIBS += -lqpe -lopietooth -lopie |
10 | INTERFACES = bluetoothbase.ui devicedialog.ui | 10 | INTERFACES = bluetoothbase.ui devicedialog.ui |
11 | DESTDIR = $(OPIEDIR)/bin | 11 | DESTDIR = $(OPIEDIR)/bin |