summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/bluebase.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/bluebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp68
1 files changed, 15 insertions, 53 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
@@ -43,9 +43,8 @@
43 43
44#include <remotedevice.h> 44#include <remotedevice.h>
45 45#include <services.h>
46 46
47namespace OpieTooth { 47namespace 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 ) {
@@ -60,5 +59,4 @@ namespace OpieTooth {
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) ) );
@@ -71,5 +69,4 @@ namespace OpieTooth {
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" );
@@ -95,9 +92,10 @@ namespace OpieTooth {
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 /**
@@ -109,5 +107,4 @@ namespace OpieTooth {
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
@@ -116,5 +113,4 @@ namespace OpieTooth {
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
@@ -124,5 +120,4 @@ namespace OpieTooth {
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" );
@@ -211,14 +206,10 @@ namespace OpieTooth {
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() );
@@ -231,7 +222,5 @@ namespace OpieTooth {
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 );
@@ -250,5 +239,4 @@ namespace OpieTooth {
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" );
@@ -263,5 +251,4 @@ namespace OpieTooth {
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();
@@ -273,11 +260,8 @@ namespace OpieTooth {
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 /**
@@ -286,12 +270,9 @@ namespace OpieTooth {
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" );
@@ -311,6 +292,4 @@ namespace OpieTooth {
311 */ 292 */
312 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 293 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
313
314
315 } 294 }
316 295
@@ -321,10 +300,6 @@ namespace OpieTooth {
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
@@ -333,6 +308,6 @@ namespace OpieTooth {
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);
@@ -344,4 +319,7 @@ namespace OpieTooth {
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;
@@ -368,5 +346,4 @@ namespace OpieTooth {
368 } 346 }
369 } 347 }
370
371 delete menu; 348 delete menu;
372 } 349 }
@@ -377,15 +354,11 @@ namespace OpieTooth {
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
@@ -397,10 +370,8 @@ namespace OpieTooth {
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
@@ -412,5 +383,4 @@ namespace OpieTooth {
412 383
413 QValueList<OpieTooth::Services>::Iterator it2; 384 QValueList<OpieTooth::Services>::Iterator it2;
414
415 BTListItem * serviceItem; 385 BTListItem * serviceItem;
416 386
@@ -419,9 +389,8 @@ namespace OpieTooth {
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 }
@@ -438,5 +407,4 @@ namespace OpieTooth {
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;
@@ -459,5 +427,4 @@ namespace OpieTooth {
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() );
@@ -470,10 +437,8 @@ namespace OpieTooth {
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
@@ -489,14 +454,10 @@ namespace OpieTooth {
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>& ) ),
@@ -519,4 +480,5 @@ namespace OpieTooth {
519 BlueBase::~BlueBase() { 480 BlueBase::~BlueBase() {
520 writeSavedDevices(); 481 writeSavedDevices();
482 delete iconLoader;
521 } 483 }
522} 484}