summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp143
-rw-r--r--noncore/net/opietooth/manager/bluebase.h11
-rw-r--r--noncore/net/opietooth/manager/btlistitem.cpp46
-rw-r--r--noncore/net/opietooth/manager/btlistitem.h11
4 files changed, 148 insertions, 63 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 77eb62b..910bb8c 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -59,11 +59,11 @@ namespace OpieTooth {
59 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 59 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
61 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 61 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
62 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 62 this, SLOT(startServiceActionHold( BTListItem *, const QPoint &, int) ) );
63 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 63 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
64 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 64 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
65 // connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ), 65 connect( localDevice, SIGNAL( available( const QString& device, bool connected ) ),
66 // this, SLOT() ); 66 this, SLOT( deviceActive( const QString& mac, bool connected ) ) );
67 67
68 //Load all icons needed 68 //Load all icons needed
69 69
@@ -86,11 +86,10 @@ namespace OpieTooth {
86 //TESTING 86 //TESTING
87 ListView2->setRootIsDecorated(true); 87 ListView2->setRootIsDecorated(true);
88 88
89 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 89 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" );
90 topLV2->setPixmap( 1, onPix ); 90 topLV2->setPixmap( 1, onPix );
91 topLV2->setText(4, "device" ); 91 (void) new BTListItem( topLV2, "Serial" ,"", "service" );
92 (void) new QListViewItem( topLV2, "Serial" ); 92 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" );
93 (void) new QListViewItem( topLV2, "BlueNiC" );
94 } 93 }
95 94
96 95
@@ -171,10 +170,11 @@ namespace OpieTooth {
171 for ( ; it.current(); ++it ) { 170 for ( ; it.current(); ++it ) {
172 171
173 // seperate config file for each device, to store more information in future. 172 // seperate config file for each device, to store more information in future.
173// TO FIX: BTLISTITEM!!!
174 174
175 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File ); 175 // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File );
176 conf.setGroup( "Info" ); 176 // conf.setGroup( "Info" );
177 conf.writeEntry( "name", it.current()->text(0) ); 177 // conf.writeEntry( "name", it.current()->name() );
178 } 178 }
179 } 179 }
180 180
@@ -238,7 +238,7 @@ namespace OpieTooth {
238 */ 238 */
239 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 239 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
240 240
241 QListViewItem * deviceItem; 241 BTListItem * deviceItem;
242 242
243 QListIterator<RemoteDevice> it( newDevices ); 243 QListIterator<RemoteDevice> it( newDevices );
244 244
@@ -246,18 +246,16 @@ namespace OpieTooth {
246 246
247 247
248 RemoteDevice *dev = it.current(); 248 RemoteDevice *dev = it.current();
249 deviceItem = new QListViewItem( ListView2 , dev->name() ); 249 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" );
250 deviceItem->setExpandable ( true ); 250 deviceItem->setExpandable ( true );
251 251
252 if ( deviceActive( dev ) ) { 252 // look if device is avail. atm, async
253 deviceItem->setPixmap( 1 , onPix ); 253 deviceActive( dev );
254 } else {
255 deviceItem->setPixmap( 1, offPix );
256 }
257 254
258 deviceItem->setText( 3, dev->mac() ); 255 // move into the c'tor
256 // deviceItem->setMac( dev->mac() );
259 // what kind of entry is it. 257 // what kind of entry is it.
260 deviceItem->setText( 4, "device"); 258 //deviceItem->setType( "device");
261 259
262 // ggf auch hier? 260 // ggf auch hier?
263 addServicesToDevice( deviceItem ); 261 addServicesToDevice( deviceItem );
@@ -276,53 +274,70 @@ namespace OpieTooth {
276 /** 274 /**
277 * Action that are toggled on hold (mostly QPopups i guess) 275 * Action that are toggled on hold (mostly QPopups i guess)
278 */ 276 */
279 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 277 void BlueBase::startServiceActionHold( BTListItem * item, const QPoint & point, int column ) {
280 278
281 QPopupMenu *menu = new QPopupMenu(); 279 QPopupMenu *menu = new QPopupMenu();
282 QPopupMenu *groups = new QPopupMenu(); 280
283 int ret=0; 281 int ret=0;
284 282
285 //QSize s = menu->sizeHint ( ); 283 //QSize s = menu->sizeHint ( );
286 284
287 if ( item->text(4) == "device") { 285 if ( item->type() == "device") {
286
287 QPopupMenu *groups = new QPopupMenu();
288
288 menu->insertItem( tr("rescan sevices:"), 0); 289 menu->insertItem( tr("rescan sevices:"), 0);
289 menu->insertItem( tr("to group"), groups , 1); 290 menu->insertItem( tr("to group"), groups , 1);
290 menu->insertItem( tr("delete"), 2); 291 menu->insertItem( tr("delete"), 2);
291 } else if ( item->text(4) == "service") { 292
293
294 ret = menu->exec( point , 0);
295
296 switch(ret) {
297 case 0:
298 break;
299 case 1:
300 break;
301 case 2:
302 // delete childs too
303 delete item;
304 break;
305 }
306 delete groups;
307
308 } else if ( item->type() == "service") {
292 menu->insertItem( tr("Test1:"), 0); 309 menu->insertItem( tr("Test1:"), 0);
293 menu->insertItem( tr("connect"), 1); 310 menu->insertItem( tr("connect"), 1);
294 menu->insertItem( tr("delete"), 2); 311 menu->insertItem( tr("delete"), 2);
295 }
296 312
297 ret = menu->exec( point , 0); 313 ret = menu->exec( point , 0);
298 314
299// noch differenzieren 315 switch(ret) {
300 switch(ret) { 316 case 0:
301 case 0: 317 break;
302 break; 318 case 1:
303 case 1: 319 break;
304 break; 320 case 2:
305 case 2: 321 // delete childs too
306 // delete childs too 322 delete item;
307 delete item; 323 break;
308 break; 324 }
309 } 325 }
310 326
311 delete menu; 327 delete menu;
312 delete groups;
313 } 328 }
314 329
315 /** 330 /**
316 * Search and display avail. services for a device (on expand from device listing) 331 * Search and display avail. services for a device (on expand from device listing)
317 * 332 *
318 */ 333 */
319 void BlueBase::addServicesToDevice( QListViewItem * item ) { 334 void BlueBase::addServicesToDevice( BTListItem * item ) {
320 335
321 qDebug("addServicesToDevice"); 336 qDebug("addServicesToDevice");
322 // row of mac adress text(3) 337 // row of mac adress text(3)
323 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) ); 338 RemoteDevice *device = new RemoteDevice( item->mac(), item->name() );
324 339
325 deviceList.insert( item->text(3) , item ); 340 deviceList.insert( item->mac() , item );
326 341
327 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 342 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
328 localDevice->searchServices( *device ); 343 localDevice->searchServices( *device );
@@ -340,9 +355,9 @@ namespace OpieTooth {
340 355
341 qDebug("fill services list"); 356 qDebug("fill services list");
342 357
343 QMap<QString,QListViewItem*>::Iterator it; 358 QMap<QString,BTListItem*>::Iterator it;
344 359
345 QListViewItem* deviceItem; 360 BTListItem* deviceItem;
346 361
347 // get the right devices which requested the search 362 // get the right devices which requested the search
348 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 363 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
@@ -363,17 +378,17 @@ namespace OpieTooth {
363 378
364 QValueList<OpieTooth::Services>::Iterator it2; 379 QValueList<OpieTooth::Services>::Iterator it2;
365 380
366 QListViewItem * serviceItem; 381 BTListItem * serviceItem;
367 382
368 if (!servicesList.isEmpty() ) { 383 if (!servicesList.isEmpty() ) {
369 // add services 384 // add services
370 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 385 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
371 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); 386 serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" );
372 serviceItem->setText(4, "service"); 387 //serviceItem->setText(4, "service");
373 } 388 }
374 } else { 389 } else {
375 serviceItem = new QListViewItem( deviceItem , tr("no services found") ); 390 serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" );
376 serviceItem->setText(4, "service"); 391 //serviceItem->setText(4, "service");
377 } 392 }
378 } 393 }
379 394
@@ -392,15 +407,39 @@ namespace OpieTooth {
392 /** 407 /**
393 * Find out if a device can currently be reached 408 * Find out if a device can currently be reached
394 */ 409 */
395 bool BlueBase::deviceActive( RemoteDevice *device ) { 410 void BlueBase::deviceActive( RemoteDevice *device ) {
396
397 // search by mac
398 localDevice->isAvailable( device->mac() );
399 411
400 return true; 412 // search by mac, async, gets a signal back
413 localDevice->isAvailable( device->mac() );
401 } 414 }
402 415
416 /**
417 * The signal catcher. Set the avail. status on device.
418 * @param device - the mac address
419 * @param connected - if it is avail. or not
420 */
421 void BlueBase::deviceActive( const QString& device, bool connected ) {
422
423 qDebug("deviceActive slot");
403 424
425 QMap<QString,BTListItem*>::Iterator it;
426
427 BTListItem* deviceItem;
428
429 // get the right devices which requested the search
430 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
431 if ( it.key() == device ) {
432 deviceItem = it.data();
433 }
434 }
435
436 if ( connected ) {
437 deviceItem->setPixmap( 1, onPix );
438 } else {
439 deviceItem->setPixmap( 1, offPix );
440 }
441
442 }
404 443
405 444
406 445
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index dee721d..481f0c9 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -10,7 +10,7 @@
10#include <qpixmap.h> 10#include <qpixmap.h>
11 11
12#include "bluetoothbase.h" 12#include "bluetoothbase.h"
13 13#include "btlistitem.h"
14 14
15#include <remotedevice.h> 15#include <remotedevice.h>
16#include <manager.h> 16#include <manager.h>
@@ -49,9 +49,9 @@ namespace OpieTooth {
49 void initGui(); 49 void initGui();
50 void setInfo(); 50 void setInfo();
51 Manager *localDevice; 51 Manager *localDevice;
52 QMap<QString,QListViewItem*> deviceList; 52 QMap<QString,BTListItem*> deviceList;
53 53
54 bool deviceActive( RemoteDevice *device ); 54 void deviceActive( RemoteDevice *device );
55 55
56 QString deviceName; 56 QString deviceName;
57 QString defaultPasskey; 57 QString defaultPasskey;
@@ -65,11 +65,12 @@ namespace OpieTooth {
65 65
66 private slots: 66 private slots:
67 void addSearchedDevices( QList<RemoteDevice> &newDevices ); 67 void addSearchedDevices( QList<RemoteDevice> &newDevices );
68 void addServicesToDevice( QListViewItem *item ); 68 void addServicesToDevice( BTListItem *item );
69 void addServicesToDevice( const QString& device, Services::ValueList ); 69 void addServicesToDevice( const QString& device, Services::ValueList );
70 void addConnectedDevices(); 70 void addConnectedDevices();
71 void startServiceActionClicked( QListViewItem *item ); 71 void startServiceActionClicked( QListViewItem *item );
72 void startServiceActionHold( QListViewItem *, const QPoint &, int ); 72 void startServiceActionHold( BTListItem *, const QPoint &, int );
73 void deviceActive( const QString& mac, bool connected );
73 void applyConfigChanges(); 74 void applyConfigChanges();
74 75
75 }; 76 };
diff --git a/noncore/net/opietooth/manager/btlistitem.cpp b/noncore/net/opietooth/manager/btlistitem.cpp
index 19d1057..ce5b141 100644
--- a/noncore/net/opietooth/manager/btlistitem.cpp
+++ b/noncore/net/opietooth/manager/btlistitem.cpp
@@ -5,28 +5,62 @@ namespace OpieTooth {
5 5
6 6
7 BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) { 7 BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) {
8 8 m_name = "";
9 m_mac ="";
10 m_type ="";
9 } 11 }
10 12
11 BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) { 13 BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) {
12 14 m_name = "";
15 m_mac ="";
16 m_type ="";
13 } 17 }
14 18
15 19
16 // name, and then mac and then servicetype 20 // name, and then mac and then servicetype
17 BTListItem::BTListItem( QListView * parent, QString name , QString mac, QString type ) 21 BTListItem::BTListItem( QListView * parent, QString name , QString mac, QString type )
18 : QListViewItem( parent, name ){ 22 : QListViewItem( parent, name ){
19 setText(4, mac); 23
20 setText(5, type); 24 m_name = name;
25 m_mac = mac;
26 m_type = type;
21 27
22 } 28 }
23 29
24 BTListItem::BTListItem( QListViewItem * parent , QString name, QString mac, QString type ) 30 BTListItem::BTListItem( QListViewItem * parent , QString name, QString mac, QString type )
25 : QListViewItem( parent, name ){ 31 : QListViewItem( parent, name ){
26 setText(4, mac); 32
27 setText(5, type); 33 m_name = name;
34 m_mac = mac;
35 m_type = type;
36 }
37
38
39 void BTListItem::setMac( QString mac ) {
40 m_mac = mac;
41 }
42
43 QString BTListItem::mac() {
44 return m_mac;
28 } 45 }
29 46
47 void BTListItem::setName( QString name ) {
48 m_name = name;
49 }
50
51 QString BTListItem::name() {
52 return m_name;
53 }
54
55 void BTListItem::setType( QString type ) {
56 m_type = type;
57 }
58
59 QString BTListItem::type() {
60 return m_type;
61 }
62
63
30 BTListItem::~BTListItem() { 64 BTListItem::~BTListItem() {
31 } 65 }
32 66
diff --git a/noncore/net/opietooth/manager/btlistitem.h b/noncore/net/opietooth/manager/btlistitem.h
index 92b3803..8963caa 100644
--- a/noncore/net/opietooth/manager/btlistitem.h
+++ b/noncore/net/opietooth/manager/btlistitem.h
@@ -16,6 +16,17 @@ namespace OpieTooth {
16 BTListItem( QListViewItem * parent , QString, QString , QString ); 16 BTListItem( QListViewItem * parent , QString, QString , QString );
17 ~BTListItem(); 17 ~BTListItem();
18 18
19 void setMac( QString );
20 QString mac();
21 void setName( QString );
22 QString name();
23 void setType( QString );
24 QString type();
25 private:
26 QString m_name;
27 QString m_mac;
28 QString m_type;
29
19 }; 30 };
20}; 31};
21 32