summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp40
-rw-r--r--noncore/net/opietooth/manager/bluebase.h1
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.cpp4
3 files changed, 25 insertions, 20 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 3e7e2ab..d023302 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -23,88 +23,93 @@
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qvariant.h> 26#include <qvariant.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qimage.h> 28#include <qimage.h>
29#include <qpixmap.h> 29#include <qpixmap.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qscrollview.h> 31#include <qscrollview.h>
32#include <qvbox.h> 32#include <qvbox.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qlistview.h> 36#include <qlistview.h>
37#include <qdir.h> 37#include <qdir.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39#include <qtimer.h>
39 40
40#include <qpe/resource.h> 41#include <qpe/resource.h>
41#include <qpe/config.h> 42#include <qpe/config.h>
42 43
43#include <remotedevice.h> 44#include <remotedevice.h>
44 45
45 46
46namespace OpieTooth { 47namespace OpieTooth {
47 48
48 49
49 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 50 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
50 : BluetoothBase( parent, name, fl ) { 51 : BluetoothBase( parent, name, fl ) {
51 52
52 localDevice = new Manager( "hci0" ); 53 localDevice = new Manager( "hci0" );
53 54
54 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 55 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
55 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 56 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
56 // not good since lib is async 57 // not good since lib is async
57 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 58 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
58 // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 59 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
59 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 60 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 61 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
61 // hehe, cast right later 62 // hehe, cast right later
62 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 63 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
63 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 64 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
64 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 65 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
65 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 66 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
66 connect( localDevice, SIGNAL( available( const QString&, bool ) ), 67 connect( localDevice, SIGNAL( available( const QString&, bool ) ),
67 this, SLOT( deviceActive( const QString& , bool ) ) ); 68 this, SLOT( deviceActive( const QString& , bool ) ) );
69 connect( localDevice, SIGNAL( connections( Connection::ValueList ) ),
70 this, SLOT( addConnectedDevices( Connection::ValueList ) ) );
68 71
69 //Load all icons needed 72 //Load all icons needed
70 73
71 offPix = Resource::loadPixmap( "editdelete" ); 74 offPix = Resource::loadPixmap( "editdelete" );
72 onPix = Resource::loadPixmap( "installed" ); 75 onPix = Resource::loadPixmap( "installed" );
73 76
74 QPalette pal = this->palette(); 77 QPalette pal = this->palette();
75 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 78 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
76 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 79 pal.setColor( QPalette::Active, QColorGroup::Button, col );
77 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 80 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
78 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 81 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
79 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 82 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
80 this->setPalette( pal ); 83 this->setPalette( pal );
81 84
82 setCaption( tr( "Bluetooth Manager" ) ); 85 setCaption( tr( "Bluetooth Manager" ) );
83 86
84 readConfig(); 87 readConfig();
85 initGui(); 88 initGui();
86 89
87 //TESTING 90 //TESTING
88 ListView2->setRootIsDecorated(true); 91 ListView2->setRootIsDecorated(true);
89 92
90 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); 93 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" );
91 topLV2->setPixmap( 1, onPix ); 94 topLV2->setPixmap( 1, onPix );
92 (void) new BTListItem( topLV2, "Serial" ,"", "service" ); 95 (void) new BTListItem( topLV2, "Serial" ,"", "service" );
93 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); 96 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" );
94 writeToHciConfig(); 97 writeToHciConfig();
98 // search conncetions
99 addConnectedDevices();
95 } 100 }
96 101
97 102
98 /** 103 /**
99 * Reads all options from the config file 104 * Reads all options from the config file
100 */ 105 */
101 void BlueBase::readConfig() { 106 void BlueBase::readConfig() {
102 107
103 Config cfg( "bluetoothmanager" ); 108 Config cfg( "bluetoothmanager" );
104 cfg.setGroup( "bluezsettings" ); 109 cfg.setGroup( "bluezsettings" );
105 110
106 111
107 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 112 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
108 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 113 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
109 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 114 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
110 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 115 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
@@ -282,37 +287,32 @@ namespace OpieTooth {
282 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 287 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
283 288
284 BTListItem * deviceItem; 289 BTListItem * deviceItem;
285 290
286 QListIterator<RemoteDevice> it( newDevices ); 291 QListIterator<RemoteDevice> it( newDevices );
287 292
288 for( ; it.current() ; ++it ) { 293 for( ; it.current() ; ++it ) {
289 294
290 295
291 RemoteDevice *dev = it.current(); 296 RemoteDevice *dev = it.current();
292 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); 297 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" );
293 deviceItem->setExpandable ( true ); 298 deviceItem->setExpandable ( true );
294 299
295 // look if device is avail. atm, async 300 // look if device is avail. atm, async
296 deviceActive( dev ); 301 deviceActive( dev );
297 302
298 // move into the c'tor
299 // deviceItem->setMac( dev->mac() );
300 // what kind of entry is it.
301 //deviceItem->setType( "device");
302
303 // ggf auch hier? 303 // ggf auch hier?
304 addServicesToDevice( deviceItem ); 304 addServicesToDevice( deviceItem );
305 } 305 }
306 } 306 }
307 307
308 308
309 /** 309 /**
310 * Action that is toggled on entrys on click 310 * Action that is toggled on entrys on click
311 */ 311 */
312 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 312 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
313 313
314 314
315 } 315 }
316 316
317 /** 317 /**
318 * Action that are toggled on hold (mostly QPopups i guess) 318 * Action that are toggled on hold (mostly QPopups i guess)
@@ -397,68 +397,74 @@ namespace OpieTooth {
397 */ 397 */
398 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 398 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
399 399
400 qDebug("fill services list"); 400 qDebug("fill services list");
401 401
402 QMap<QString,BTListItem*>::Iterator it; 402 QMap<QString,BTListItem*>::Iterator it;
403 403
404 BTListItem* deviceItem; 404 BTListItem* deviceItem;
405 405
406 // get the right devices which requested the search 406 // get the right devices which requested the search
407 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 407 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
408 if ( it.key() == device ) { 408 if ( it.key() == device ) {
409 deviceItem = it.data(); 409 deviceItem = it.data();
410 } 410 }
411 } 411 }
412 412
413
414 // empty entries
415 // QListViewItem * myChild = deviceItem->firstChild();
416 //QList<QListViewItem*> tmpList;
417 //while( myChild ) {
418 // tmpList.append(myChild);
419 // myChild = myChild->nextSibling();
420 // }
421
422
423 QValueList<OpieTooth::Services>::Iterator it2; 413 QValueList<OpieTooth::Services>::Iterator it2;
424 414
425 BTListItem * serviceItem; 415 BTListItem * serviceItem;
426 416
427 if (!servicesList.isEmpty() ) { 417 if (!servicesList.isEmpty() ) {
428 // add services 418 // add services
429 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 419 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
430 serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); 420 serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" );
431 //serviceItem->setText(4, "service"); 421 //serviceItem->setText(4, "service");
432 } 422 }
433 } else { 423 } else {
434 serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); 424 serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" );
435 //serviceItem->setText(4, "service"); 425 //serviceItem->setText(4, "service");
436 } 426 }
437 } 427 }
438 428
439 429
440 /** 430 /**
441 * Add the existing connections (pairs) to the connections tab. 431 * Add the existing connections (pairs) to the connections tab.
442 * 432 * This one triggers the search
443 */ 433 */
444 void BlueBase::addConnectedDevices() { 434 void BlueBase::addConnectedDevices() {
435 localDevice->searchConnections();
436 }
445 437
446 438
447 //mac address 439 void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) {
440
441 QValueList<OpieTooth::Connection>::Iterator it;
442 BTListItem * connectionItem;
443
444 if ( !connectionList.isEmpty() ) {
445
446 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
447 connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" );
448 }
449 } else {
450 connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" );
451 }
448 452
453 // recall connection search after some time
454 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) );
449 } 455 }
450 456
451 /** 457 /**
452 * Find out if a device can currently be reached 458 * Find out if a device can currently be reached
453 */ 459 */
454 void BlueBase::deviceActive( RemoteDevice *device ) { 460 void BlueBase::deviceActive( RemoteDevice *device ) {
455 461
456 // search by mac, async, gets a signal back 462 // search by mac, async, gets a signal back
457 localDevice->isAvailable( device->mac() ); 463 localDevice->isAvailable( device->mac() );
458 } 464 }
459 465
460 /** 466 /**
461 * The signal catcher. Set the avail. status on device. 467 * The signal catcher. Set the avail. status on device.
462 * @param device - the mac address 468 * @param device - the mac address
463 * @param connected - if it is avail. or not 469 * @param connected - if it is avail. or not
464 */ 470 */
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index ef67aa2..0516c16 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -56,26 +56,27 @@ namespace OpieTooth {
56 56
57 QString deviceName; 57 QString deviceName;
58 QString defaultPasskey; 58 QString defaultPasskey;
59 int useEncryption; 59 int useEncryption;
60 int enableAuthentification; 60 int enableAuthentification;
61 int enablePagescan; 61 int enablePagescan;
62 int enableInquiryscan; 62 int enableInquiryscan;
63 63
64 QPixmap offPix; 64 QPixmap offPix;
65 QPixmap onPix; 65 QPixmap onPix;
66 66
67 private slots: 67 private slots:
68 void addSearchedDevices( QList<RemoteDevice> &newDevices ); 68 void addSearchedDevices( QList<RemoteDevice> &newDevices );
69 void addServicesToDevice( BTListItem *item ); 69 void addServicesToDevice( BTListItem *item );
70 void addServicesToDevice( const QString& device, Services::ValueList ); 70 void addServicesToDevice( const QString& device, Services::ValueList );
71 void addConnectedDevices(); 71 void addConnectedDevices();
72 void addConnectedDevices( Connection::ValueList );
72 void startServiceActionClicked( QListViewItem *item ); 73 void startServiceActionClicked( QListViewItem *item );
73 void startServiceActionHold( QListViewItem *, const QPoint &, int ); 74 void startServiceActionHold( QListViewItem *, const QPoint &, int );
74 void deviceActive( const QString& mac, bool connected ); 75 void deviceActive( const QString& mac, bool connected );
75 void applyConfigChanges(); 76 void applyConfigChanges();
76 77
77 }; 78 };
78 79
79} 80}
80 81
81#endif 82#endif
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp
index 7b2497a..2d6d7da 100644
--- a/noncore/net/opietooth/manager/hciconfwrapper.cpp
+++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp
@@ -86,29 +86,27 @@ namespace OpieTooth {
86 86
87 QString str; 87 QString str;
88 while ( !(str=stream.readLine()).isNull() ) { 88 while ( !(str=stream.readLine()).isNull() ) {
89 89
90 90
91 //qDebug(str); 91 //qDebug(str);
92 if( (str.contains(key)) > 0 ) { 92 if( (str.contains(key)) > 0 ) {
93 qDebug("Found"); 93 qDebug("Found");
94 // still need to look if its commented out!!! 94 // still need to look if its commented out!!!
95 str.simplifyWhiteSpace(); 95 str.simplifyWhiteSpace();
96 qDebug( key ); 96 qDebug( key );
97 if (str.startsWith("#")) { 97 if (str.startsWith("#")) {
98 str = (key + " " + value + ";"); 98 str = (key + " " + value + ";");
99 } else { 99 } else {
100 str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); 100 str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";");
101 } 101 }
102
103 qDebug( str ); 102 qDebug( str );
104 } 103 }
105
106 outstream << str << endl; 104 outstream << str << endl;
107 } 105 }
108 106
109 f.close(); 107 f.close();
108
110 f2.flush(); 109 f2.flush();
111 f2.close(); 110 f2.close();
112 } 111 }
113
114} 112}