summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp29
-rw-r--r--noncore/net/opietooth/manager/bluebase.h8
2 files changed, 20 insertions, 17 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index c7e1fe4..6328b59 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -5,135 +5,134 @@
5 * copyright : (c) 2002 by Maximilian Reiß 5 * copyright : (c) 2002 by Maximilian Reiß
6 * email : max.reiss@gmx.de 6 * email : max.reiss@gmx.de
7 * 7 *
8 */ 8 */
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20 20
21#include <qframe.h> 21#include <qframe.h>
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 38
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41 41
42#include <remotedevice.h> 42#include <remotedevice.h>
43 43
44 44
45namespace OpieTooth { 45namespace OpieTooth {
46 46
47 47
48 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 48 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
49 : BluetoothBase( parent, name, fl ) { 49 : BluetoothBase( parent, name, fl ) {
50 50
51 localDevice = new Manager( "hci0" ); 51 localDevice = new Manager( "hci0" );
52 52
53 QObject::connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 53 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
54 QObject::connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
55 QObject::connect( ListView2, SIGNAL( expanded( QListViewItem * item ) ), 55 connect( ListView2, SIGNAL( expanded ( QListViewItem *item ) ),
56 this, SLOT( addServicesToDevice( QListViewItem * item ) ) ); 56 this, SLOT( addServicesToDevice( QListViewItem *item ) ) );
57 QObject::connect( ListView2, SIGNAL( clicked( QListViewItem * )), 57 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
58 this, SLOT( startServiceActionClicked( QListViewItem * item ) ) ); 58 this, SLOT( startServiceActionClicked( QListViewItem *item ) ) );
59 connect( localDevice, SIGNAL( foundServices( const QString& device, Services::ValueList ) ), 59 connect( localDevice, SIGNAL( foundServices( const QString& device, Services::ValueList ) ),
60 this, SLOT( addServicesToDevice( const QString& device, Services::ValueList ) ) ); 60 this, SLOT( addServicesToDevice( const QString& device, Services::ValueList ) ) );
61 61
62 // QObject::connect( (QObject*) Manager, SIGNAL (foundServices( const QString& device, Services::ValueList ), this () ) );
63 62
64 //Load all icons needed 63 //Load all icons needed
65 64
66 65
67 QPixmap offPix = Resource::loadPixmap( "editdelete" ); 66 QPixmap offPix = Resource::loadPixmap( "editdelete" );
68 QPixmap onPix = Resource::loadPixmap( "installed" ); 67 QPixmap onPix = Resource::loadPixmap( "installed" );
69 68
70 QPalette pal = this->palette(); 69 QPalette pal = this->palette();
71 QColor col = pal.color(QPalette::Active, QColorGroup::Background); 70 QColor col = pal.color(QPalette::Active, QColorGroup::Background);
72 pal.setColor(QPalette::Active, QColorGroup::Button, col); 71 pal.setColor(QPalette::Active, QColorGroup::Button, col);
73 pal.setColor(QPalette::Inactive, QColorGroup::Button, col); 72 pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
74 pal.setColor(QPalette::Normal, QColorGroup::Button, col); 73 pal.setColor(QPalette::Normal, QColorGroup::Button, col);
75 pal.setColor(QPalette::Disabled, QColorGroup::Button, col); 74 pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
76 this->setPalette(pal); 75 this->setPalette(pal);
77 76
78 setCaption( tr( "Bluetooth Manager" ) ); 77 setCaption( tr( "Bluetooth Manager" ) );
79 78
80 readConfig(); 79 readConfig();
81 initGui(); 80 initGui();
82 81
83 82
84 //TESTING 83 //TESTING
85 84
86 ListView2->setRootIsDecorated(true); 85 ListView2->setRootIsDecorated(true);
87 86
88 QListViewItem *topLV = new QListViewItem( ListView2, "Harlekins Dongle" , "yes"); 87 QListViewItem *topLV = new QListViewItem( ListView2, "Harlekins Dongle" , "yes");
89 topLV->setPixmap( 0, offPix ); 88 topLV->setPixmap( 0, offPix );
90 (void) new QListViewItem( topLV, "on" ); 89 // (void) new QListViewItem( topLV, "on" );
91 (void) new QListViewItem( topLV, "off" ); 90 //(void) new QListViewItem( topLV, "off" );
92 91
93 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 92 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
94 topLV2->setPixmap( 0, onPix ); 93 topLV2->setPixmap( 0, onPix );
95 (void) new QListViewItem( topLV2, "on" ); 94 (void) new QListViewItem( topLV2, "on" );
96 (void) new QListViewItem( topLV2, "off" ); 95 (void) new QListViewItem( topLV2, "off" );
97 96
98 } 97 }
99 98
100 99
101 /** 100 /**
102 * Reads all options from the config file 101 * Reads all options from the config file
103 */ 102 */
104 void BlueBase::readConfig() { 103 void BlueBase::readConfig() {
105 104
106 Config cfg( "bluetoothmanager" ); 105 Config cfg( "bluetoothmanager" );
107 cfg.setGroup( "bluezsettings" ); 106 cfg.setGroup( "bluezsettings" );
108 107
109 108
110 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
111 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
112 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 111 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
113 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 112 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
114 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 113 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
115 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); 114 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 );
116 115
117 } 116 }
118 117
119 /** 118 /**
120 * Writes all options to the config file 119 * Writes all options to the config file
121 */ 120 */
122 void BlueBase::writeConfig() { 121 void BlueBase::writeConfig() {
123 122
124 123
125 Config cfg( "bluetoothmanager" ); 124 Config cfg( "bluetoothmanager" );
126 cfg.setGroup( "bluezsettings" ); 125 cfg.setGroup( "bluezsettings" );
127 126
128 cfg.writeEntry( "name" , deviceName ); 127 cfg.writeEntry( "name" , deviceName );
129 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 128 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
130 cfg.writeEntry( "useEncryption" , useEncryption ); 129 cfg.writeEntry( "useEncryption" , useEncryption );
131 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 130 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
132 cfg.writeEntry( "enablePagescan" , enablePagescan ); 131 cfg.writeEntry( "enablePagescan" , enablePagescan );
133 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 132 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
134} 133}
135 134
136 135
137 /* 136 /*
138 * Read the list of allready known devices 137 * Read the list of allready known devices
139 * 138 *
@@ -194,163 +193,167 @@ namespace OpieTooth {
194 */ 193 */
195 QString BlueBase::getStatus(){ 194 QString BlueBase::getStatus(){
196 195
197 QString infoString = tr("<b>Device name : </b> Ipaq" ); 196 QString infoString = tr("<b>Device name : </b> Ipaq" );
198 infoString += QString("<br><b>" + tr("MAC adress: ") +"</b> No idea"); 197 infoString += QString("<br><b>" + tr("MAC adress: ") +"</b> No idea");
199 infoString += QString("<br><b>" + tr("Class") + "</b> PDA"); 198 infoString += QString("<br><b>" + tr("Class") + "</b> PDA");
200 199
201 return (infoString); 200 return (infoString);
202 201
203 } 202 }
204 203
205 204
206 /** 205 /**
207 * Read the current values from the gui and invoke writeConfig() 206 * Read the current values from the gui and invoke writeConfig()
208 */ 207 */
209 void BlueBase::applyConfigChanges() { 208 void BlueBase::applyConfigChanges() {
210 209
211 deviceName = deviceNameLine->text(); 210 deviceName = deviceNameLine->text();
212 defaultPasskey = passkeyLine->text(); 211 defaultPasskey = passkeyLine->text();
213 useEncryption = cryptCheckBox->isChecked(); 212 useEncryption = cryptCheckBox->isChecked();
214 enableAuthentification = authCheckBox->isChecked(); 213 enableAuthentification = authCheckBox->isChecked();
215 enablePagescan = pagescanCheckBox->isChecked(); 214 enablePagescan = pagescanCheckBox->isChecked();
216 enableInquiryscan = inquiryscanCheckBox->isChecked(); 215 enableInquiryscan = inquiryscanCheckBox->isChecked();
217 216
218 writeConfig(); 217 writeConfig();
219 218
220 QMessageBox* box = new QMessageBox( this, "Test" ); 219 QMessageBox* box = new QMessageBox( this, "Test" );
221 box->setText( tr( "Changes applied" ) ); 220 box->setText( tr( "Changes applied" ) );
222 box->show(); 221 box->show();
223 222
224 // falls nötig hcid killhupen - die funktionalität adden 223 // falls nötig hcid killhupen - die funktionalität adden
225} 224}
226 225
227 226
228 /* 227 /*
229 * Add fresh found devices from scan dialog to the listing 228 * Add fresh found devices from scan dialog to the listing
230 * 229 *
231 */ 230 */
232 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 231 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
233 232
234 QListViewItem * deviceItem; 233 QListViewItem * deviceItem;
235 234
236 QListIterator<RemoteDevice> it( newDevices ); 235 QListIterator<RemoteDevice> it( newDevices );
237 236
238 for( ; it.current() ; ++it ) { 237 for( ; it.current() ; ++it ) {
239 238
240 239
241 RemoteDevice *dev = it.current(); 240 RemoteDevice *dev = it.current();
242 deviceItem = new QListViewItem( ListView2, dev->name() ); 241 deviceItem = new QListViewItem( ListView2 , dev->name() );
243 242
244 if ( deviceActive( dev ) ) { 243 if ( deviceActive( dev ) ) {
245 deviceItem->setPixmap( 1 , onPix ); 244 deviceItem->setPixmap( 1 , onPix );
246 } else { 245 } else {
247 deviceItem->setPixmap( 1, offPix ); 246 deviceItem->setPixmap( 1, offPix );
248 } 247 }
249 248
250 deviceItem->setText( 3, dev->mac() ); 249 deviceItem->setText( 3, dev->mac() );
250
251 // ggf auch hier?
252 addServicesToDevice( deviceItem );
251 } 253 }
252 } 254 }
253 255
254 256
255 /* 257 /*
256 * Action that is toggled on entrys on click 258 * Action that is toggled on entrys on click
257 */ 259 */
258 void BlueBase::startServiceActionClicked( QListViewItem * item ) { 260 void BlueBase::startServiceActionClicked( QListViewItem * item ) {
259 261
260 262
261 } 263 }
262 264
263 /* 265 /*
264 * Action that are toggled on hold (mostly QPopups i guess) 266 * Action that are toggled on hold (mostly QPopups i guess)
265 */ 267 */
266 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 268 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
267 269
268 270
269 } 271 }
270 272
271 /* 273 /*
272 * Search and display avail. services for a device (on expand from device listing) 274 * Search and display avail. services for a device (on expand from device listing)
273 * 275 *
274 */ 276 */
275 void BlueBase::addServicesToDevice( QListViewItem * item ) { 277 void BlueBase::addServicesToDevice( QListViewItem * item ) {
276 278
279 qDebug("addServicesToDevice");
277 // row of mac adress 280 // row of mac adress
278 RemoteDevice *device = new RemoteDevice(item->text(3), item->text(0)); 281 RemoteDevice *device = new RemoteDevice(item->text(3), item->text(0));
279 282
280 deviceList.insert( item->text(3) , item ); 283 deviceList.insert( item->text(3) , item );
281 284
282// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 285// and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
283 localDevice->searchServices( *device ); 286 localDevice->searchServices( *device );
284 287
285 // delete 288 // delete
286 } 289 }
287 290
288 291
289 /** 292 /**
290 * Overloaded. This one it the one that is connected to the foundServices signal 293 * Overloaded. This one it the one that is connected to the foundServices signal
291 * @param device the mac address of the remote device 294 * @param device the mac address of the remote device
292 * @param servicesList the list with the service the device has. 295 * @param servicesList the list with the service the device has.
293 */ 296 */
294 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 297 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
295 298
296 qDebug("fill services list"); 299 qDebug("fill services list");
297 300
298 301
299 QMap<QString,QListViewItem*>::Iterator it; 302 QMap<QString,QListViewItem*>::Iterator it;
300 303
301 QListViewItem* deviceItem; 304 QListViewItem* deviceItem;
302 305
303 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 306 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
304 if (it.key() == device ) { 307 if (it.key() == device ) {
305 deviceItem = it.data(); 308 deviceItem = it.data();
306 } 309 }
307 } 310 }
308 311
309 QValueList<OpieTooth::Services>::Iterator it2; 312 QValueList<OpieTooth::Services>::Iterator it2;
310 313
311 314
312 315
313 QListViewItem * serviceItem; 316 QListViewItem * serviceItem;
314 317
315 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 318 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
316 it2.serviceName() 319// it2.serviceName()
317 serviceItem = new QListViewItem( deviceItem , it2.serviceName() ); 320 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
318 } 321 }
319 322
320 } 323 }
321 324
322 325
323 /* 326 /*
324 * Find out if a device can currently be reached 327 * Find out if a device can currently be reached
325 */ 328 */
326 bool BlueBase::deviceActive( RemoteDevice *device ) { 329 bool BlueBase::deviceActive( RemoteDevice *device ) {
327 return true; 330 return true;
328 } 331 }
329 332
330 333
331 /** 334 /**
332 * Open the "scan for devices" dialog 335 * Open the "scan for devices" dialog
333 */ 336 */
334 void BlueBase::startScan() { 337 void BlueBase::startScan() {
335 338
336 ScanDialog *scan = new ScanDialog( this, "", true); 339 ScanDialog *scan = new ScanDialog( this, "", true);
337 QObject::connect( scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ), 340 QObject::connect( scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ),
338 this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) )); 341 this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) ));
339 342
340 scan->showMaximized(); 343 scan->showMaximized();
341 } 344 }
342 345
343 346
344 void BlueBase::setInfo() { 347 void BlueBase::setInfo() {
345 StatusLabel->setText( getStatus() ); 348 StatusLabel->setText( getStatus() );
346 } 349 }
347 350
348 /** 351 /**
349 * Decontructor 352 * Decontructor
350 */ 353 */
351 BlueBase::~BlueBase() { 354 BlueBase::~BlueBase() {
352 writeSavedDevices(); 355 writeSavedDevices();
353 } 356 }
354 357
355} 358}
356 359
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index dcb7681..d20d05c 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -20,61 +20,61 @@ class QHBoxLayout;
20class QGridLayout; 20class QGridLayout;
21class QFrame; 21class QFrame;
22class QLabel; 22class QLabel;
23class QPushButton; 23class QPushButton;
24class QTabWidget; 24class QTabWidget;
25class QCheckBox; 25class QCheckBox;
26 26
27 27
28namespace OpieTooth { 28namespace OpieTooth {
29 29
30 30
31 31
32 class BlueBase : public BluetoothBase { 32 class BlueBase : public BluetoothBase {
33 Q_OBJECT 33 Q_OBJECT
34 34
35 public: 35 public:
36 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 36 BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
37 ~BlueBase(); 37 ~BlueBase();
38 38
39 protected: 39 protected:
40 40
41 41
42 private slots: 42 private slots:
43 void startScan(); 43 void startScan();
44 44
45 private: 45 private:
46 void readConfig(); 46 void readConfig();
47 void writeConfig(); 47 void writeConfig();
48 void readSavedDevices(); 48 void readSavedDevices();
49 void writeSavedDevices(); 49 void writeSavedDevices();
50 QString getStatus(); 50 QString getStatus();
51 void initGui(); 51 void initGui();
52 void setInfo(); 52 void setInfo();
53 Manager *localDevice; 53 Manager *localDevice;
54 QMap<QString,QListViewItem*> deviceList; 54 QMap<QString,QListViewItem*> deviceList;
55 55
56 bool deviceActive( RemoteDevice *device ); 56 bool deviceActive( RemoteDevice *device );
57 57
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 public 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 startServiceActionClicked( QListViewItem * item ); 72 void startServiceActionClicked( QListViewItem *item );
73 void startServiceActionHold( QListViewItem * item, const QPoint & point, int column); 73 void startServiceActionHold( QListViewItem *item, const QPoint &point, int column);
74 void applyConfigChanges(); 74 void applyConfigChanges();
75 75
76 }; 76 };
77 77
78} 78}
79 79
80#endif 80#endif