summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-23 16:18:52 (UTC)
committer harlekin <harlekin>2002-06-23 16:18:52 (UTC)
commit5cf97227889d00e366782d466eef5eafe1d73e5c (patch) (unidiff)
tree3a89e3db99b1ec45f69ec4bf6688fdb45eeab9a7
parent6382b7352205a71557bd87b4f43d7f19f7f3330e (diff)
downloadopie-5cf97227889d00e366782d466eef5eafe1d73e5c.zip
opie-5cf97227889d00e366782d466eef5eafe1d73e5c.tar.gz
opie-5cf97227889d00e366782d466eef5eafe1d73e5c.tar.bz2
little update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp69
-rw-r--r--noncore/net/opietooth/manager/bluebase.h2
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp3
3 files changed, 66 insertions, 8 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index cc51405..772dbd1 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -22,81 +22,85 @@
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qvariant.h> 25#include <qvariant.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qapplication.h> 33#include <qapplication.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 39
39#include <qpe/resource.h> 40#include <qpe/resource.h>
40#include <qpe/config.h> 41#include <qpe/config.h>
41 42
42#include <remotedevice.h> 43#include <remotedevice.h>
43 44
44 45
45namespace OpieTooth { 46namespace OpieTooth {
46 47
47 48
48 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 49 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
49 : BluetoothBase( parent, name, fl ) { 50 : BluetoothBase( parent, name, fl ) {
50 51
51 localDevice = new Manager( "hci0" ); 52 localDevice = new Manager( "hci0" );
52 53
53 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 54 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 55 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
55 connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 56 // not good since lib is async
56 this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 57 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
58 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
57 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 59 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
61 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
62 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 63 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
60 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 64 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
61 65
62 66
63 //Load all icons needed 67 //Load all icons needed
64 68
65
66 offPix = Resource::loadPixmap( "editdelete" ); 69 offPix = Resource::loadPixmap( "editdelete" );
67 onPix = Resource::loadPixmap( "installed" ); 70 onPix = Resource::loadPixmap( "installed" );
68 71
69 QPalette pal = this->palette(); 72 QPalette pal = this->palette();
70 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 73 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
71 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 74 pal.setColor( QPalette::Active, QColorGroup::Button, col );
72 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 75 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
73 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 76 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
74 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 77 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
75 this->setPalette( pal ); 78 this->setPalette( pal );
76 79
77 setCaption( tr( "Bluetooth Manager" ) ); 80 setCaption( tr( "Bluetooth Manager" ) );
78 81
79 readConfig(); 82 readConfig();
80 initGui(); 83 initGui();
81 84
82 //TESTING 85 //TESTING
83 ListView2->setRootIsDecorated(true); 86 ListView2->setRootIsDecorated(true);
84 87
85 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 88 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
86 topLV2->setPixmap( 1, onPix ); 89 topLV2->setPixmap( 1, onPix );
90 topLV2->setText(4, "device" );
87 (void) new QListViewItem( topLV2, "Serial" ); 91 (void) new QListViewItem( topLV2, "Serial" );
88 (void) new QListViewItem( topLV2, "BlueNiC" ); 92 (void) new QListViewItem( topLV2, "BlueNiC" );
89 } 93 }
90 94
91 95
92 /** 96 /**
93 * Reads all options from the config file 97 * Reads all options from the config file
94 */ 98 */
95 void BlueBase::readConfig() { 99 void BlueBase::readConfig() {
96 100
97 Config cfg( "bluetoothmanager" ); 101 Config cfg( "bluetoothmanager" );
98 cfg.setGroup( "bluezsettings" ); 102 cfg.setGroup( "bluezsettings" );
99 103
100 104
101 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 105 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
102 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 106 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
@@ -238,99 +242,150 @@ namespace OpieTooth {
238 QListIterator<RemoteDevice> it( newDevices ); 242 QListIterator<RemoteDevice> it( newDevices );
239 243
240 for( ; it.current() ; ++it ) { 244 for( ; it.current() ; ++it ) {
241 245
242 246
243 RemoteDevice *dev = it.current(); 247 RemoteDevice *dev = it.current();
244 deviceItem = new QListViewItem( ListView2 , dev->name() ); 248 deviceItem = new QListViewItem( ListView2 , dev->name() );
245 deviceItem->setExpandable ( true ); 249 deviceItem->setExpandable ( true );
246 250
247 if ( deviceActive( dev ) ) { 251 if ( deviceActive( dev ) ) {
248 deviceItem->setPixmap( 1 , onPix ); 252 deviceItem->setPixmap( 1 , onPix );
249 } else { 253 } else {
250 deviceItem->setPixmap( 1, offPix ); 254 deviceItem->setPixmap( 1, offPix );
251 } 255 }
252 256
253 deviceItem->setText( 3, dev->mac() ); 257 deviceItem->setText( 3, dev->mac() );
258 // what kind of entry is it.
259 deviceItem->setText( 4, "device");
254 260
255 // ggf auch hier? 261 // ggf auch hier?
256 addServicesToDevice( deviceItem ); 262 addServicesToDevice( deviceItem );
257 } 263 }
258 } 264 }
259 265
260 266
261 /** 267 /**
262 * Action that is toggled on entrys on click 268 * Action that is toggled on entrys on click
263 */ 269 */
264 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 270 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
265 271
266 272
267 } 273 }
268 274
269 /** 275 /**
270 * Action that are toggled on hold (mostly QPopups i guess) 276 * Action that are toggled on hold (mostly QPopups i guess)
271 */ 277 */
272 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 278 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
273 279
280 QPopupMenu *menu = new QPopupMenu();
281 QPopupMenu *groups = new QPopupMenu();
282 int ret=0;
283
284 //QSize s = menu->sizeHint ( );
285
286 if ( item->text(4) == "device") {
287 menu->insertItem( tr("rescan sevices:"), 0);
288 menu->insertItem( tr("to group"), groups , 1);
289 menu->insertItem( tr("delete"), 2);
290 } else if ( item->text(4) == "service") {
291 menu->insertItem( tr("Test1:"), 0);
292 menu->insertItem( tr("connect"), 1);
293 menu->insertItem( tr("delete"), 2);
294 }
295
296 ret = menu->exec( point , 0);
297
298// noch differenzieren
299 switch(ret) {
300 case 0:
301 break;
302 case 1:
303 break;
304 case 2:
305 // delete childs too
306 delete item;
307 break;
308 }
309
310 delete menu;
311 delete groups;
274 } 312 }
275 313
276 /** 314 /**
277 * Search and display avail. services for a device (on expand from device listing) 315 * Search and display avail. services for a device (on expand from device listing)
278 * 316 *
279 */ 317 */
280 void BlueBase::addServicesToDevice( QListViewItem * item ) { 318 void BlueBase::addServicesToDevice( QListViewItem * item ) {
281 319
282 qDebug("addServicesToDevice"); 320 qDebug("addServicesToDevice");
283 // row of mac adress 321 // row of mac adress text(3)
284 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) ); 322 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) );
285 323
286 deviceList.insert( item->text(3) , item ); 324 deviceList.insert( item->text(3) , item );
287 325
288 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 326 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
289 localDevice->searchServices( *device ); 327 localDevice->searchServices( *device );
290 328
291 // delete 329 // delete
292 } 330 }
293 331
294 332
295 /** 333 /**
296 * Overloaded. This one it the one that is connected to the foundServices signal 334 * Overloaded. This one it the one that is connected to the foundServices signal
297 * @param device the mac address of the remote device 335 * @param device the mac address of the remote device
298 * @param servicesList the list with the service the device has. 336 * @param servicesList the list with the service the device has.
299 */ 337 */
300 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 338 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
301 339
302 qDebug("fill services list"); 340 qDebug("fill services list");
303 341
304
305 QMap<QString,QListViewItem*>::Iterator it; 342 QMap<QString,QListViewItem*>::Iterator it;
306 343
307 QListViewItem* deviceItem; 344 QListViewItem* deviceItem;
308 345
346 // get the right devices which requested the search
309 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 347 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
310 if ( it.key() == device ) { 348 if ( it.key() == device ) {
311 deviceItem = it.data(); 349 deviceItem = it.data();
312 } 350 }
313 } 351 }
314 352
353
354 // empty entries
355 // QListViewItem * myChild = deviceItem->firstChild();
356 //QList<QListViewItem*> tmpList;
357 //while( myChild ) {
358 // tmpList.append(myChild);
359 // myChild = myChild->nextSibling();
360 // }
361
362
315 QValueList<OpieTooth::Services>::Iterator it2; 363 QValueList<OpieTooth::Services>::Iterator it2;
316 364
317 QListViewItem * serviceItem; 365 QListViewItem * serviceItem;
318 366
319 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 367 if (!servicesList.isEmpty() ) {
320 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); 368 // add services
369 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
370 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
371 serviceItem->setText(4, "service");
372 }
373 } else {
374 serviceItem = new QListViewItem( deviceItem , tr("no services found") );
375 serviceItem->setText(4, "service");
321 } 376 }
322 } 377 }
323 378
324 379
325 /** 380 /**
326 * Add the existing connections (pairs) to the connections tab. 381 * Add the existing connections (pairs) to the connections tab.
327 * 382 *
328 */ 383 */
329 void BlueBase::addConnectedDevices() { 384 void BlueBase::addConnectedDevices() {
330 385
331 386
332 //mac address 387 //mac address
333 388
334 } 389 }
335 390
336 /** 391 /**
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index 99d2fa6..bc48bb3 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -58,24 +58,24 @@ namespace OpieTooth {
58 QString deviceName; 58 QString deviceName;
59 QString defaultPasskey; 59 QString defaultPasskey;
60 int useEncryption; 60 int useEncryption;
61 int enableAuthentification; 61 int enableAuthentification;
62 int enablePagescan; 62 int enablePagescan;
63 int enableInquiryscan; 63 int enableInquiryscan;
64 64
65 QPixmap offPix; 65 QPixmap offPix;
66 QPixmap onPix; 66 QPixmap onPix;
67 67
68 private slots: 68 private slots:
69 void addSearchedDevices( QList<RemoteDevice> &newDevices ); 69 void addSearchedDevices( QList<RemoteDevice> &newDevices );
70 void addServicesToDevice( QListViewItem *item ); 70 void addServicesToDevice( QListViewItem *item );
71 void addServicesToDevice( const QString& device, Services::ValueList ); 71 void addServicesToDevice( const QString& device, Services::ValueList );
72 void addConnectedDevices(); 72 void addConnectedDevices();
73 void startServiceActionClicked( QListViewItem *item ); 73 void startServiceActionClicked( QListViewItem *item );
74 void startServiceActionHold( QListViewItem *item, const QPoint &point, int column); 74 void startServiceActionHold( QListViewItem *, const QPoint &, int );
75 void applyConfigChanges(); 75 void applyConfigChanges();
76 76
77 }; 77 };
78 78
79} 79}
80 80
81#endif 81#endif
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index 9520e73..0e6e93b 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -104,32 +104,35 @@ namespace OpieTooth {
104 QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); 104 QTimer::singleShot( 2000, this, SLOT(progressTimer() ) );
105 } 105 }
106 progress->setProgress(progressStat++); 106 progress->setProgress(progressStat++);
107 107
108 } 108 }
109 109
110 void ScanDialog::accept() { 110 void ScanDialog::accept() {
111 emitToManager(); 111 emitToManager();
112 QDialog::accept(); 112 QDialog::accept();
113 } 113 }
114 114
115 115
116 void ScanDialog::startSearch() { 116 void ScanDialog::startSearch() {
117 progress->setProgress(0); 117 progress->setProgress(0);
118 progressStat = 0; 118 progressStat = 0;
119 119
120 // empty list before a new scan
121 ListView1->clear();
122
120 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); 123 QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
121 deviceItem2->setText(1, "BLAH" ); 124 deviceItem2->setText(1, "BLAH" );
122 125
123 progressTimer(); 126 progressTimer();
124 // when finished, it emmite foundDevices() 127 // when finished, it emmite foundDevices()
125 // checken ob initialisiert , qcop ans applet. 128 // checken ob initialisiert , qcop ans applet.
126 localDevice->searchDevices(); 129 localDevice->searchDevices();
127 130
128 } 131 }
129 132
130 void ScanDialog::stopSearch() { 133 void ScanDialog::stopSearch() {
131 134
132 } 135 }
133 136
134 void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { 137 void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
135 138