author | harlekin <harlekin> | 2002-06-19 22:24:52 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-19 22:24:52 (UTC) |
commit | 3cff4da41a61679e0222be190af8a98682f07393 (patch) (unidiff) | |
tree | 6b791ffc929c1347826b949935d37e046e8a9930 | |
parent | 6afbacb8353e539b9e6d279d20220445614b42c2 (diff) | |
download | opie-3cff4da41a61679e0222be190af8a98682f07393.zip opie-3cff4da41a61679e0222be190af8a98682f07393.tar.gz opie-3cff4da41a61679e0222be190af8a98682f07393.tar.bz2 |
update
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 29 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 8 |
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 | |||
@@ -29,87 +29,86 @@ | |||
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 | ||
45 | namespace OpieTooth { | 45 | namespace 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 ); |
@@ -218,124 +217,128 @@ namespace OpieTooth { | |||
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 | } |
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 | |||
@@ -44,37 +44,37 @@ namespace OpieTooth { | |||
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 |