summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-20 23:36:42 (UTC)
committer harlekin <harlekin>2002-06-20 23:36:42 (UTC)
commit56649b4725b2e98d786d06f83d4b3281ea1090fb (patch) (unidiff)
treee490f77a30e9846fd4b65cdc214227cca71f7216
parent9a3833c28cf7488957abc9e67094ba8ea60f92cd (diff)
downloadopie-56649b4725b2e98d786d06f83d4b3281ea1090fb.zip
opie-56649b4725b2e98d786d06f83d4b3281ea1090fb.tar.gz
opie-56649b4725b2e98d786d06f83d4b3281ea1090fb.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 6caca70..5d742b7 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,362 +1,370 @@
1/* 1/*
2 * bluebase.cpp * 2 * bluebase.cpp *
3 * --------------------- 3 * ---------------------
4 * 4 *
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 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 53 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 54 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
55 connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 55 connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
56 this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 56 this, SLOT( addServicesToDevice( QListViewItem * ) ) );
57 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 57 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 58 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 59 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
60 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 60 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
61 61
62 62
63 //Load all icons needed 63 //Load all icons needed
64 64
65 65
66 offPix = Resource::loadPixmap( "editdelete" ); 66 offPix = Resource::loadPixmap( "editdelete" );
67 onPix = Resource::loadPixmap( "installed" ); 67 onPix = Resource::loadPixmap( "installed" );
68 68
69 QPalette pal = this->palette(); 69 QPalette pal = this->palette();
70 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 70 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
71 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 71 pal.setColor( QPalette::Active, QColorGroup::Button, col );
72 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 72 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
73 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 73 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
74 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 74 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
75 this->setPalette( pal ); 75 this->setPalette( pal );
76 76
77 setCaption( tr( "Bluetooth Manager" ) ); 77 setCaption( tr( "Bluetooth Manager" ) );
78 78
79 readConfig(); 79 readConfig();
80 initGui(); 80 initGui();
81 81
82 82
83 //TESTING 83 //TESTING
84 ListView2->setRootIsDecorated(true); 84 ListView2->setRootIsDecorated(true);
85 85
86 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" ); 86 QListViewItem *topLV2 = new QListViewItem( ListView2, "Siemens S45" , "no" );
87 topLV2->setPixmap( 1, onPix ); 87 topLV2->setPixmap( 1, onPix );
88 (void) new QListViewItem( topLV2, "Serial" ); 88 (void) new QListViewItem( topLV2, "Serial" );
89 (void) new QListViewItem( topLV2, "BlueNiC" ); 89 (void) new QListViewItem( topLV2, "BlueNiC" );
90 } 90 }
91 91
92 92
93 /** 93 /**
94 * Reads all options from the config file 94 * Reads all options from the config file
95 */ 95 */
96 void BlueBase::readConfig() { 96 void BlueBase::readConfig() {
97 97
98 Config cfg( "bluetoothmanager" ); 98 Config cfg( "bluetoothmanager" );
99 cfg.setGroup( "bluezsettings" ); 99 cfg.setGroup( "bluezsettings" );
100 100
101 101
102 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 102 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
103 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 103 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
104 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 104 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
105 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 105 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
106 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 106 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
107 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); 107 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 );
108 108
109 } 109 }
110 110
111 /** 111 /**
112 * Writes all options to the config file 112 * Writes all options to the config file
113 */ 113 */
114 void BlueBase::writeConfig() { 114 void BlueBase::writeConfig() {
115 115
116 116
117 Config cfg( "bluetoothmanager" ); 117 Config cfg( "bluetoothmanager" );
118 cfg.setGroup( "bluezsettings" ); 118 cfg.setGroup( "bluezsettings" );
119 119
120 cfg.writeEntry( "name" , deviceName ); 120 cfg.writeEntry( "name" , deviceName );
121 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 121 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
122 cfg.writeEntry( "useEncryption" , useEncryption ); 122 cfg.writeEntry( "useEncryption" , useEncryption );
123 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 123 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
124 cfg.writeEntry( "enablePagescan" , enablePagescan ); 124 cfg.writeEntry( "enablePagescan" , enablePagescan );
125 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 125 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
126} 126}
127 127
128 128
129 /** 129 /**
130 * Read the list of allready known devices 130 * Read the list of allready known devices
131 * 131 *
132 */ 132 */
133 void BlueBase::readSavedDevices() { 133 void BlueBase::readSavedDevices() {
134 134
135 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; 135 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>;
136 136
137 Config deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File ); 137 Config deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/devicelist.conf", Config::File );
138 138
139 139
140 // RemoteDevice *currentDevice = RemoteDevice( , ); 140 // RemoteDevice *currentDevice = RemoteDevice( , );
141 //loadedDevices->append( currentDevice ); 141 //loadedDevices->append( currentDevice );
142 142
143 addSearchedDevices( *loadedDevices ); 143 addSearchedDevices( *loadedDevices );
144 } 144 }
145 145
146 /** 146 /**
147 * Write the list of allready known devices 147 * Write the list of allready known devices
148 * 148 *
149 */ 149 */
150 void BlueBase::writeSavedDevices() { 150 void BlueBase::writeSavedDevices() {
151 151
152 QListViewItemIterator it( ListView2 ); 152 QListViewItemIterator it( ListView2 );
153 153
154 for ( ; it.current(); ++it ) { 154 for ( ; it.current(); ++it ) {
155 155
156 // seperate config file for each device, to store more information in future. 156 // seperate config file for each device, to store more information in future.
157 157
158 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File ); 158 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (it.current()->text(3)) + ".conf", Config::File );
159 conf.setGroup( "Info" ); 159 conf.setGroup( "Info" );
160 conf.writeEntry( "name", it.current()->text(0) ); 160 conf.writeEntry( "name", it.current()->text(0) );
161 } 161 }
162 } 162 }
163 163
164 164
165 /** 165 /**
166 * Set up the gui 166 * Set up the gui
167 */ 167 */
168 void BlueBase::initGui() { 168 void BlueBase::initGui() {
169 169
170 StatusLabel->setText( getStatus() ); // maybe move it to getStatus() 170 StatusLabel->setText( getStatus() ); // maybe move it to getStatus()
171 171
172 cryptCheckBox->setChecked( useEncryption ); 172 cryptCheckBox->setChecked( useEncryption );
173 authCheckBox->setChecked( enableAuthentification ); 173 authCheckBox->setChecked( enableAuthentification );
174 pagescanCheckBox->setChecked( enablePagescan ); 174 pagescanCheckBox->setChecked( enablePagescan );
175 inquiryscanCheckBox->setChecked( enableInquiryscan ); 175 inquiryscanCheckBox->setChecked( enableInquiryscan );
176 deviceNameLine->setText( deviceName ); 176 deviceNameLine->setText( deviceName );
177 passkeyLine->setText( defaultPasskey ); 177 passkeyLine->setText( defaultPasskey );
178 // set info tab 178 // set info tab
179 setInfo(); 179 setInfo();
180 } 180 }
181 181
182 182
183 /** 183 /**
184 * Get the status informations and returns it 184 * Get the status informations and returns it
185 * @return QString the status informations gathered 185 * @return QString the status informations gathered
186 */ 186 */
187 QString BlueBase::getStatus(){ 187 QString BlueBase::getStatus(){
188 188
189 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 189 QString infoString = tr( "<b>Device name : </b> Ipaq" );
190 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 190 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
191 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 191 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
192 192
193 return (infoString); 193 return (infoString);
194 194
195 } 195 }
196 196
197 197
198 /** 198 /**
199 * Read the current values from the gui and invoke writeConfig() 199 * Read the current values from the gui and invoke writeConfig()
200 */ 200 */
201 void BlueBase::applyConfigChanges() { 201 void BlueBase::applyConfigChanges() {
202 202
203 deviceName = deviceNameLine->text(); 203 deviceName = deviceNameLine->text();
204 defaultPasskey = passkeyLine->text(); 204 defaultPasskey = passkeyLine->text();
205 useEncryption = cryptCheckBox->isChecked(); 205 useEncryption = cryptCheckBox->isChecked();
206 enableAuthentification = authCheckBox->isChecked(); 206 enableAuthentification = authCheckBox->isChecked();
207 enablePagescan = pagescanCheckBox->isChecked(); 207 enablePagescan = pagescanCheckBox->isChecked();
208 enableInquiryscan = inquiryscanCheckBox->isChecked(); 208 enableInquiryscan = inquiryscanCheckBox->isChecked();
209 209
210 writeConfig(); 210 writeConfig();
211 211
212 QMessageBox* box = new QMessageBox( this, "Test" ); 212 QMessageBox* box = new QMessageBox( this, "Test" );
213 box->setText( tr( "Changes applied" ) ); 213 box->setText( tr( "Changes applied" ) );
214 box->show(); 214 box->show();
215 215
216 // falls nötig hcid killhupen - die funktionalität adden 216 // falls nötig hcid killhupen - die funktionalität adden
217 } 217 }
218 218
219 219
220 /** 220 /**
221 * Add fresh found devices from scan dialog to the listing 221 * Add fresh found devices from scan dialog to the listing
222 * 222 *
223 */ 223 */
224 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 224 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
225 225
226 QListViewItem * deviceItem; 226 QListViewItem * deviceItem;
227 227
228 QListIterator<RemoteDevice> it( newDevices ); 228 QListIterator<RemoteDevice> it( newDevices );
229 229
230 for( ; it.current() ; ++it ) { 230 for( ; it.current() ; ++it ) {
231 231
232 232
233 RemoteDevice *dev = it.current(); 233 RemoteDevice *dev = it.current();
234 deviceItem = new QListViewItem( ListView2 , dev->name() ); 234 deviceItem = new QListViewItem( ListView2 , dev->name() );
235 deviceItem->setExpandable ( true );
235 236
236 if ( deviceActive( dev ) ) { 237 if ( deviceActive( dev ) ) {
237 deviceItem->setPixmap( 1 , onPix ); 238 deviceItem->setPixmap( 1 , onPix );
238 } else { 239 } else {
239 deviceItem->setPixmap( 1, offPix ); 240 deviceItem->setPixmap( 1, offPix );
240 } 241 }
241 242
242 deviceItem->setText( 3, dev->mac() ); 243 deviceItem->setText( 3, dev->mac() );
243 244
244 // ggf auch hier? 245 // ggf auch hier?
245 addServicesToDevice( deviceItem ); 246 addServicesToDevice( deviceItem );
246 } 247 }
247 } 248 }
248 249
249 250
250 /** 251 /**
251 * Action that is toggled on entrys on click 252 * Action that is toggled on entrys on click
252 */ 253 */
253 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 254 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
254 255
255 256
256 } 257 }
257 258
258 /** 259 /**
259 * Action that are toggled on hold (mostly QPopups i guess) 260 * Action that are toggled on hold (mostly QPopups i guess)
260 */ 261 */
261 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 262 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
262 263
263 264
264 } 265 }
265 266
266 /** 267 /**
267 * Search and display avail. services for a device (on expand from device listing) 268 * Search and display avail. services for a device (on expand from device listing)
268 * 269 *
269 */ 270 */
270 void BlueBase::addServicesToDevice( QListViewItem * item ) { 271 void BlueBase::addServicesToDevice( QListViewItem * item ) {
271 272
272 qDebug("addServicesToDevice"); 273 qDebug("addServicesToDevice");
273 // row of mac adress 274 // row of mac adress
274 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) ); 275 RemoteDevice *device = new RemoteDevice( item->text(3), item->text(0) );
275 276
276 deviceList.insert( item->text(3) , item ); 277 deviceList.insert( item->text(3) , item );
277 278
278 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 279 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
279 localDevice->searchServices( *device ); 280 localDevice->searchServices( *device );
280 281
281 // delete 282 // delete
282 } 283 }
283 284
284 285
285 /** 286 /**
286 * Overloaded. This one it the one that is connected to the foundServices signal 287 * Overloaded. This one it the one that is connected to the foundServices signal
287 * @param device the mac address of the remote device 288 * @param device the mac address of the remote device
288 * @param servicesList the list with the service the device has. 289 * @param servicesList the list with the service the device has.
289 */ 290 */
290 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 291 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
291 292
292 qDebug("fill services list"); 293 qDebug("fill services list");
293 294
294 295
295 QMap<QString,QListViewItem*>::Iterator it; 296 QMap<QString,QListViewItem*>::Iterator it;
296 297
297 QListViewItem* deviceItem; 298 QListViewItem* deviceItem;
298 299
299 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 300 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
300 if ( it.key() == device ) { 301 if ( it.key() == device ) {
301 deviceItem = it.data(); 302 deviceItem = it.data();
302 } 303 }
303 } 304 }
304 305
305 QValueList<OpieTooth::Services>::Iterator it2; 306 QValueList<OpieTooth::Services>::Iterator it2;
306 307
307 308
308 309
309 QListViewItem * serviceItem; 310 QListViewItem * serviceItem;
310 311
311 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 312 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
312 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() ); 313 serviceItem = new QListViewItem( deviceItem , (*it2).serviceName() );
313 } 314 }
314 } 315 }
315 316
316 317
317 /** 318 /**
318 * Add the existing connections (pairs) to the connections tab. 319 * Add the existing connections (pairs) to the connections tab.
319 * 320 *
320 */ 321 */
321 void BlueBase::addConnectedDevices() { 322 void BlueBase::addConnectedDevices() {
322 323
323 324
325 //mac address
326
324 } 327 }
325 328
326 /** 329 /**
327 * Find out if a device can currently be reached 330 * Find out if a device can currently be reached
328 */ 331 */
329 bool BlueBase::deviceActive( RemoteDevice *device ) { 332 bool BlueBase::deviceActive( RemoteDevice *device ) {
333
334 // search by mac
335 //
336 localDevice->isAvailable( device->mac() );
337
330 return true; 338 return true;
331 } 339 }
332 340
333 341
334 /** 342 /**
335 * Open the "scan for devices" dialog 343 * Open the "scan for devices" dialog
336 */ 344 */
337 void BlueBase::startScan() { 345 void BlueBase::startScan() {
338 346
339 ScanDialog *scan = new ScanDialog( this, "", true); 347 ScanDialog *scan = new ScanDialog( this, "", true);
340 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), 348 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ),
341 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); 349 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) );
342 350
343 scan->showMaximized(); 351 scan->showMaximized();
344 } 352 }
345 353
346 354
347 /** 355 /**
348 * Set the informations about the local device in information Tab 356 * Set the informations about the local device in information Tab
349 */ 357 */
350 void BlueBase::setInfo() { 358 void BlueBase::setInfo() {
351 StatusLabel->setText( getStatus() ); 359 StatusLabel->setText( getStatus() );
352 } 360 }
353 361
354 /** 362 /**
355 * Decontructor 363 * Decontructor
356 */ 364 */
357 BlueBase::~BlueBase() { 365 BlueBase::~BlueBase() {
358 writeSavedDevices(); 366 writeSavedDevices();
359 } 367 }
360 368
361} 369}
362 370