summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp56
-rw-r--r--noncore/net/opietooth/manager/popuphelper.cpp2
2 files changed, 44 insertions, 14 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 189001d..3f2f138 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -64,66 +64,68 @@ using namespace OpieTooth;
64 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 64 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
65 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 65 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
66 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 66 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
67 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), 67 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
68 this, SLOT( deviceActive( const QString& , bool ) ) ); 68 this, SLOT( deviceActive( const QString& , bool ) ) );
69 connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), 69 connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ),
70 this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); 70 this, SLOT( addConnectedDevices( Connection::ValueList ) ) );
71 71
72 //Load all icons needed 72 //Load all icons needed
73 m_offPix = Resource::loadPixmap( "editdelete" ); 73 m_offPix = Resource::loadPixmap( "editdelete" );
74 m_onPix = Resource::loadPixmap( "installed" ); 74 m_onPix = Resource::loadPixmap( "installed" );
75 75
76 QPalette pal = this->palette(); 76 QPalette pal = this->palette();
77 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 77 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
78 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 78 pal.setColor( QPalette::Active, QColorGroup::Button, col );
79 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 79 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
80 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 80 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
81 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 81 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
82 this->setPalette( pal ); 82 this->setPalette( pal );
83 83
84 setCaption( tr( "Bluetooth Manager" ) ); 84 setCaption( tr( "Bluetooth Manager" ) );
85 85
86 readConfig(); 86 readConfig();
87 initGui(); 87 initGui();
88 88
89 //TESTING 89 //TESTING
90 ListView2->setRootIsDecorated(true); 90 ListView2->setRootIsDecorated(true);
91 91
92 BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); 92 BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) );
93 topLV2->setPixmap( 1, m_onPix ); 93 topLV2->setPixmap( 1, m_onPix );
94 Services s1; 94 Services s1;
95 s1.setServiceName( "Serial" ); 95 s1.setServiceName( "Serial" );
96 s1.insertClassId(1, "BlueNic");
96 (void) new BTServiceItem( topLV2, s1 ); 97 (void) new BTServiceItem( topLV2, s1 );
97 s1.setServiceName( "BlueNic" ); 98 s1.setServiceName( "BlueNic" );
99 s1.insertClassId(2, "Obex");
98 (void) new BTServiceItem( topLV2, s1 ); 100 (void) new BTServiceItem( topLV2, s1 );
99 101
100 writeToHciConfig(); 102 writeToHciConfig();
101 // search conncetions 103 // search conncetions
102 addConnectedDevices(); 104 addConnectedDevices();
103 m_iconLoader = new BTIconLoader(); 105 m_iconLoader = new BTIconLoader();
104 } 106 }
105 107
106 /** 108 /**
107 * Reads all options from the config file 109 * Reads all options from the config file
108 */ 110 */
109 void BlueBase::readConfig() { 111 void BlueBase::readConfig() {
110 112
111 Config cfg( "bluetoothmanager" ); 113 Config cfg( "bluetoothmanager" );
112 cfg.setGroup( "bluezsettings" ); 114 cfg.setGroup( "bluezsettings" );
113 115
114 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 116 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
115 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 117 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
116 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 118 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
117 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 119 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
118 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 120 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
119 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 121 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
120 } 122 }
121 123
122 /** 124 /**
123 * Writes all options to the config file 125 * Writes all options to the config file
124 */ 126 */
125 void BlueBase::writeConfig() { 127 void BlueBase::writeConfig() {
126 128
127 Config cfg( "bluetoothmanager" ); 129 Config cfg( "bluetoothmanager" );
128 cfg.setGroup( "bluezsettings" ); 130 cfg.setGroup( "bluezsettings" );
129 131
@@ -270,95 +272,121 @@ using namespace OpieTooth;
270 // ggf auch hier? 272 // ggf auch hier?
271 addServicesToDevice( deviceItem ); 273 addServicesToDevice( deviceItem );
272 } 274 }
273 } 275 }
274 276
275 277
276 /** 278 /**
277 * Action that is toggled on entrys on click 279 * Action that is toggled on entrys on click
278 */ 280 */
279void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { 281void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
280} 282}
281 283
282 /** 284 /**
283 * Action that are toggled on hold (mostly QPopups i guess) 285 * Action that are toggled on hold (mostly QPopups i guess)
284 */ 286 */
285void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { 287void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) {
286 288
287 QPopupMenu *menu = new QPopupMenu(); 289 QPopupMenu *menu = new QPopupMenu();
288 int ret=0; 290 int ret=0;
289 291
290 if ( ((BTListItem*)item)->type() == "device") { 292 if ( ((BTListItem*)item)->type() == "device") {
291 293
292 QPopupMenu *groups = new QPopupMenu(); 294 QPopupMenu *groups = new QPopupMenu();
293 295
294 menu->insertItem( tr("rescan sevices:"), 0); 296 menu->insertItem( tr("rescan sevices:"), 0);
295 menu->insertItem( tr("to group"), groups , 1); 297 menu->insertItem( tr("to group"), groups , 1);
296 menu->insertItem( tr("bound device"), 2); 298 menu->insertItem( tr("bound device"), 2);
297 menu->insertItem( tr("delete"), 3); 299 menu->insertItem( tr("delete"), 3);
298 300
299 ret = menu->exec( point , 0); 301 ret = menu->exec( point , 0);
300 302
301 switch(ret) { 303 switch(ret) {
302 case 0: 304 case -1:
305
303 break; 306 break;
304 case 1: 307 case 1:
305 break; 308 break;
306 case 2: 309 case 2:
307 // make connection 310 // make connection
308 break; 311 break;
309 case 3: 312 case 3:
310 // delete childs too 313 // delete childs too
311 delete item; 314 delete item;
312 break; 315 break;
313 } 316 }
314 delete groups; 317 delete groups;
315 318
316 } else if ( ((BTListItem*)item)->type() == "service") { 319 }
320 /**
321 * We got service sensitive PopupMenus in our factory
322 * We will create one through the factory and will insert
323 * our Separator + ShowInfo into the menu or create a new
324 * one if the factory returns 0
325 * PopupMenu deletion is kind of weird.
326 * If escaped( -1 ) or any of our items were chosen we'll
327 * delete the PopupMenu otherwise it's the responsibility of
328 * the PopupMenu to delete itself
329 *
330 */
331 else if ( ((BTListItem*)item)->type() == "service") {
332 BTServiceItem* service = (BTServiceItem*)item;
333 QMap<int, QString> list = service->services().classIdList();
334 QMap<int, QString>::Iterator it = list.begin();
335 QPopupMenu *popup =0l;
336 if ( it != list.end() )
337 popup = m_popHelper.find( it.key(),
338 service->services(),
339 service->parent() );
340
341 if ( popup == 0l ) {
342 qWarning("factory returned 0l");
343 popup = new QPopupMenu();
344 }
317 345
318 menu->insertItem( tr("Test1:"), 0); 346 int test1 = popup->insertItem( tr("Test1:"), 0);
319 menu->insertItem( tr("connect"), 1); 347 int con = popup->insertItem( tr("connect"), 1);
320 menu->insertItem( tr("delete"), 2); 348 int del = popup->insertItem( tr("delete"), 2);
321 349
322 ret = menu->exec( point , 0); 350 ret = popup->exec( point );
323 351
324 switch(ret) { 352 if ( ret == -1 )
325 case 0: 353 delete popup;
326 break; 354 else if ( ret == test1 )
327 case 1: 355 delete popup;
328 break; 356 else if ( ret == con )
329 case 2: 357 delete popup;
330 // delete childs too 358 else if ( ret == del ) {
359 // take item first? -zecke
331 delete item; 360 delete item;
332 break;
333 } 361 }
334 } 362 }
335 delete menu; 363 delete menu;
336} 364}
337 365
338 /** 366 /**
339 * Search and display avail. services for a device (on expand from device listing) 367 * Search and display avail. services for a device (on expand from device listing)
340 * 368 *
341 */ 369 */
342 void BlueBase::addServicesToDevice( BTDeviceItem * item ) { 370 void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
343 qDebug("addServicesToDevice"); 371 qDebug("addServicesToDevice");
344 // row of mac adress text(3) 372 // row of mac adress text(3)
345 RemoteDevice device = item->remoteDevice(); 373 RemoteDevice device = item->remoteDevice();
346 m_deviceList.insert( item->mac() , item ); 374 m_deviceList.insert( item->mac() , item );
347 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 375 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
348 m_localDevice->searchServices( device ); 376 m_localDevice->searchServices( device );
349 } 377 }
350 378
351 379
352 /** 380 /**
353 * Overloaded. This one it the one that is connected to the foundServices signal 381 * Overloaded. This one it the one that is connected to the foundServices signal
354 * @param device the mac address of the remote device 382 * @param device the mac address of the remote device
355 * @param servicesList the list with the service the device has. 383 * @param servicesList the list with the service the device has.
356 */ 384 */
357 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 385 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
358 qDebug("fill services list"); 386 qDebug("fill services list");
359 387
360 QMap<QString,BTDeviceItem*>::Iterator it; 388 QMap<QString,BTDeviceItem*>::Iterator it;
361 BTDeviceItem* deviceItem = 0; 389 BTDeviceItem* deviceItem = 0;
362 390
363 // get the right devices which requested the search 391 // get the right devices which requested the search
364 it = m_deviceList.find( device ); 392 it = m_deviceList.find( device );
diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp
index d8404d6..26c4b02 100644
--- a/noncore/net/opietooth/manager/popuphelper.cpp
+++ b/noncore/net/opietooth/manager/popuphelper.cpp
@@ -1,28 +1,30 @@
1 1
2#include "stdpopups.h" 2#include "stdpopups.h"
3 3
4#include "popuphelper.h" 4#include "popuphelper.h"
5 5
6using namespace OpieTooth; 6using namespace OpieTooth;
7 7
8PopupHelper::PopupHelper() { 8PopupHelper::PopupHelper() {
9 init(); 9 init();
10} 10}
11PopupHelper::~PopupHelper() { 11PopupHelper::~PopupHelper() {
12 12
13} 13}
14void PopupHelper::insert( int id, popupFactory fact ) { 14void PopupHelper::insert( int id, popupFactory fact ) {
15 m_map.insert(id, fact ); 15 m_map.insert(id, fact );
16} 16}
17QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) { 17QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) {
18 qWarning("find");
18 FactoryMap::Iterator it = m_map.find(id ); 19 FactoryMap::Iterator it = m_map.find(id );
19 if ( it != m_map.end() ) { 20 if ( it != m_map.end() ) {
21 qWarning("found");
20 popupFactory fact = it.data(); 22 popupFactory fact = it.data();
21 return (*fact)(ser, item); 23 return (*fact)(ser, item);
22 } 24 }
23 return 0l; 25 return 0l;
24} 26}
25void PopupHelper::init() { 27void PopupHelper::init() {
26 insert( 1, newRfcComPopup ); 28 insert( 1, newRfcComPopup );
27 insert(2, newObexPushPopup ); 29 insert(2, newObexPushPopup );
28} 30}