summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-28 21:08:44 (UTC)
committer harlekin <harlekin>2002-06-28 21:08:44 (UTC)
commit4aa30fb2582bcbc4f8819afb0b5f612c6441ae1d (patch) (unidiff)
treeb2e892b6a301d60fb86fe3916df53763ce09b7c9
parent5223240e859a0433605ee642b3aac68a05e4d0f4 (diff)
downloadopie-4aa30fb2582bcbc4f8819afb0b5f612c6441ae1d.zip
opie-4aa30fb2582bcbc4f8819afb0b5f612c6441ae1d.tar.gz
opie-4aa30fb2582bcbc4f8819afb0b5f612c6441ae1d.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 0385cb1..3e7e2ab 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,516 +1,517 @@
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#include "hciconfwrapper.h" 20#include "hciconfwrapper.h"
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qvariant.h> 26#include <qvariant.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qimage.h> 28#include <qimage.h>
29#include <qpixmap.h> 29#include <qpixmap.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qscrollview.h> 31#include <qscrollview.h>
32#include <qvbox.h> 32#include <qvbox.h>
33#include <qmessagebox.h> 33#include <qmessagebox.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#include <qpopupmenu.h>
39 39
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/config.h> 41#include <qpe/config.h>
42 42
43#include <remotedevice.h> 43#include <remotedevice.h>
44 44
45 45
46namespace OpieTooth { 46namespace OpieTooth {
47 47
48 48
49 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 49 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
50 : BluetoothBase( parent, name, fl ) { 50 : BluetoothBase( parent, name, fl ) {
51 51
52 localDevice = new Manager( "hci0" ); 52 localDevice = new Manager( "hci0" );
53 53
54 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 54 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
55 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 55 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
56 // not good since lib is async 56 // not good since lib is async
57 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 57 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
58 // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 58 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
59 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 59 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 60 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
61 // hehe, cast right later 61 // hehe, cast right later
62 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 62 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
63 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 63 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
64 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 64 connect( localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
65 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 65 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
66 connect( localDevice, SIGNAL( available( const QString&, bool ) ), 66 connect( localDevice, SIGNAL( available( const QString&, bool ) ),
67 this, SLOT( deviceActive( const QString& , bool ) ) ); 67 this, SLOT( deviceActive( const QString& , bool ) ) );
68 68
69 //Load all icons needed 69 //Load all icons needed
70 70
71 offPix = Resource::loadPixmap( "editdelete" ); 71 offPix = Resource::loadPixmap( "editdelete" );
72 onPix = Resource::loadPixmap( "installed" ); 72 onPix = Resource::loadPixmap( "installed" );
73 73
74 QPalette pal = this->palette(); 74 QPalette pal = this->palette();
75 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 75 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
76 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 76 pal.setColor( QPalette::Active, QColorGroup::Button, col );
77 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 77 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
78 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 78 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
79 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 79 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
80 this->setPalette( pal ); 80 this->setPalette( pal );
81 81
82 setCaption( tr( "Bluetooth Manager" ) ); 82 setCaption( tr( "Bluetooth Manager" ) );
83 83
84 readConfig(); 84 readConfig();
85 initGui(); 85 initGui();
86 86
87 //TESTING 87 //TESTING
88 ListView2->setRootIsDecorated(true); 88 ListView2->setRootIsDecorated(true);
89 89
90 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" ); 90 BTListItem *topLV2 = new BTListItem( ListView2, "Siemens S45", "", "device" );
91 topLV2->setPixmap( 1, onPix ); 91 topLV2->setPixmap( 1, onPix );
92 (void) new BTListItem( topLV2, "Serial" ,"", "service" ); 92 (void) new BTListItem( topLV2, "Serial" ,"", "service" );
93 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" ); 93 (void) new BTListItem( topLV2, "BlueNiC" , "", "service" );
94 writeToHciConfig(); 94 writeToHciConfig();
95 } 95 }
96 96
97 97
98 /** 98 /**
99 * Reads all options from the config file 99 * Reads all options from the config file
100 */ 100 */
101 void BlueBase::readConfig() { 101 void BlueBase::readConfig() {
102 102
103 Config cfg( "bluetoothmanager" ); 103 Config cfg( "bluetoothmanager" );
104 cfg.setGroup( "bluezsettings" ); 104 cfg.setGroup( "bluezsettings" );
105 105
106 106
107 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 107 deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
108 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 108 defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
109 useEncryption = cfg.readNumEntry( "useEncryption" , 1 ); 109 useEncryption = cfg.readNumEntry( "useEncryption" , 1 );
110 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 ); 110 enableAuthentification = cfg.readNumEntry( "enableAuthentification" , 1 );
111 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 ); 111 enablePagescan = cfg.readNumEntry( "enablePagescan" , 1 );
112 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 ); 112 enableInquiryscan = cfg.readNumEntry( "enableInquiryscan" , 1 );
113 113
114 } 114 }
115 115
116 /** 116 /**
117 * Writes all options to the config file 117 * Writes all options to the config file
118 */ 118 */
119 void BlueBase::writeConfig() { 119 void BlueBase::writeConfig() {
120 120
121 121
122 Config cfg( "bluetoothmanager" ); 122 Config cfg( "bluetoothmanager" );
123 cfg.setGroup( "bluezsettings" ); 123 cfg.setGroup( "bluezsettings" );
124 124
125 cfg.writeEntry( "name" , deviceName ); 125 cfg.writeEntry( "name" , deviceName );
126 cfg.writeEntryCrypt( "passkey" , defaultPasskey ); 126 cfg.writeEntryCrypt( "passkey" , defaultPasskey );
127 cfg.writeEntry( "useEncryption" , useEncryption ); 127 cfg.writeEntry( "useEncryption" , useEncryption );
128 cfg.writeEntry( "enableAuthentification" , enableAuthentification ); 128 cfg.writeEntry( "enableAuthentification" , enableAuthentification );
129 cfg.writeEntry( "enablePagescan" , enablePagescan ); 129 cfg.writeEntry( "enablePagescan" , enablePagescan );
130 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan ); 130 cfg.writeEntry( "enableInquiryscan" , enableInquiryscan );
131 131
132 writeToHciConfig(); 132 writeToHciConfig();
133 } 133 }
134 134
135 void BlueBase::writeToHciConfig() { 135 void BlueBase::writeToHciConfig() {
136 136
137 HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" ); 137 HciConfWrapper *hciconf = new HciConfWrapper( "/tmp/hcid.conf" );
138 hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 138 hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
139 139
140 140
141 // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 141 // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
142 142
143 hciconf->setName( deviceName ); 143 hciconf->setName( deviceName );
144 144
145 if ( useEncryption == 1) { 145 if ( useEncryption == 1) {
146 hciconf->setEncrypt( true ); 146 hciconf->setEncrypt( true );
147 } else { 147 } else {
148 hciconf->setEncrypt( false ); 148 hciconf->setEncrypt( false );
149 } 149 }
150 150
151 151
152 if ( enableAuthentification == 1) { 152 if ( enableAuthentification == 1) {
153 hciconf->setAuth( true ); 153 hciconf->setAuth( true );
154 } else { 154 } else {
155 hciconf->setAuth( false ); 155 hciconf->setAuth( false );
156 } 156 }
157 157
158 if ( enablePagescan == 1) { 158 if ( enablePagescan == 1) {
159 hciconf->setPscan( true ); 159 hciconf->setPscan( true );
160 } else { 160 } else {
161 hciconf->setPscan( false ); 161 hciconf->setPscan( false );
162 } 162 }
163 163
164 if ( enableInquiryscan == 1) { 164 if ( enableInquiryscan == 1) {
165 hciconf->setIscan( true ); 165 hciconf->setIscan( true );
166 } else { 166 } else {
167 hciconf->setIscan( false ); 167 hciconf->setIscan( false );
168 } 168 }
169 delete hciconf; 169 delete hciconf;
170 } 170 }
171 171
172 172
173 /** 173 /**
174 * Read the list of allready known devices 174 * Read the list of allready known devices
175 * 175 *
176 */ 176 */
177 void BlueBase::readSavedDevices() { 177 void BlueBase::readSavedDevices() {
178 178
179 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>; 179 QList<RemoteDevice> *loadedDevices = new QList<RemoteDevice>;
180 180
181 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); 181 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/");
182 // list of .conf files 182 // list of .conf files
183 QStringList devicesFileList = deviceListSave.entryList(); 183 QStringList devicesFileList = deviceListSave.entryList();
184 184
185 // cut .conf of to get the mac and also read the name entry in it. 185 // cut .conf of to get the mac and also read the name entry in it.
186 186
187 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { 187 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
188 188
189 QString name; 189 QString name;
190 QString mac; 190 QString mac;
191 qDebug((*it).latin1() ); 191 qDebug((*it).latin1() );
192 Config conf((*it)); 192 Config conf((*it));
193 conf.setGroup("Info"); 193 conf.setGroup("Info");
194 name = conf.readEntry("name", "Error"); 194 name = conf.readEntry("name", "Error");
195 qDebug("MAC: " + mac); 195 qDebug("MAC: " + mac);
196 qDebug("NAME: " + name); 196 qDebug("NAME: " + name);
197 RemoteDevice currentDevice = RemoteDevice( mac , name ); 197 RemoteDevice currentDevice = RemoteDevice( mac , name );
198 loadedDevices->append( &currentDevice ); 198 loadedDevices->append( &currentDevice );
199 } 199 }
200 addSearchedDevices( *loadedDevices ); 200 addSearchedDevices( *loadedDevices );
201 } 201 }
202 202
203 /** 203 /**
204 * Write the list of allready known devices 204 * Write the list of allready known devices
205 * 205 *
206 */ 206 */
207 void BlueBase::writeSavedDevices() { 207 void BlueBase::writeSavedDevices() {
208 208
209 QListViewItemIterator it( ListView2 ); 209 QListViewItemIterator it( ListView2 );
210 210
211 for ( ; it.current(); ++it ) { 211 for ( ; it.current(); ++it ) {
212 212
213 // seperate config file for each device, to store more information in future. 213 // seperate config file for each device, to store more information in future.
214// TO FIX: BTLISTITEM!!! 214// TO FIX: BTLISTITEM!!!
215 qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf");
216 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File );
215 217
216 // Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem)it.current())->mac()) + ".conf", Config::File ); 218 conf.setGroup( "Info" );
217 // conf.setGroup( "Info" ); 219 conf.writeEntry( "name", ((BTListItem*)it.current())->name() );
218 // conf.writeEntry( "name", it.current()->name() );
219 } 220 }
220 } 221 }
221 222
222 223
223 /** 224 /**
224 * Set up the gui 225 * Set up the gui
225 */ 226 */
226 void BlueBase::initGui() { 227 void BlueBase::initGui() {
227 228
228 StatusLabel->setText( getStatus() ); // maybe move it to getStatus() 229 StatusLabel->setText( getStatus() ); // maybe move it to getStatus()
229 230
230 cryptCheckBox->setChecked( useEncryption ); 231 cryptCheckBox->setChecked( useEncryption );
231 authCheckBox->setChecked( enableAuthentification ); 232 authCheckBox->setChecked( enableAuthentification );
232 pagescanCheckBox->setChecked( enablePagescan ); 233 pagescanCheckBox->setChecked( enablePagescan );
233 inquiryscanCheckBox->setChecked( enableInquiryscan ); 234 inquiryscanCheckBox->setChecked( enableInquiryscan );
234 deviceNameLine->setText( deviceName ); 235 deviceNameLine->setText( deviceName );
235 passkeyLine->setText( defaultPasskey ); 236 passkeyLine->setText( defaultPasskey );
236 // set info tab 237 // set info tab
237 setInfo(); 238 setInfo();
238 } 239 }
239 240
240 241
241 /** 242 /**
242 * Get the status informations and returns it 243 * Get the status informations and returns it
243 * @return QString the status informations gathered 244 * @return QString the status informations gathered
244 */ 245 */
245 QString BlueBase::getStatus(){ 246 QString BlueBase::getStatus(){
246 247
247 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 248 QString infoString = tr( "<b>Device name : </b> Ipaq" );
248 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 249 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
249 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 250 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
250 251
251 return (infoString); 252 return (infoString);
252 } 253 }
253 254
254 255
255 /** 256 /**
256 * Read the current values from the gui and invoke writeConfig() 257 * Read the current values from the gui and invoke writeConfig()
257 */ 258 */
258 void BlueBase::applyConfigChanges() { 259 void BlueBase::applyConfigChanges() {
259 260
260 deviceName = deviceNameLine->text(); 261 deviceName = deviceNameLine->text();
261 defaultPasskey = passkeyLine->text(); 262 defaultPasskey = passkeyLine->text();
262 useEncryption = cryptCheckBox->isChecked(); 263 useEncryption = cryptCheckBox->isChecked();
263 enableAuthentification = authCheckBox->isChecked(); 264 enableAuthentification = authCheckBox->isChecked();
264 enablePagescan = pagescanCheckBox->isChecked(); 265 enablePagescan = pagescanCheckBox->isChecked();
265 enableInquiryscan = inquiryscanCheckBox->isChecked(); 266 enableInquiryscan = inquiryscanCheckBox->isChecked();
266 267
267 writeConfig(); 268 writeConfig();
268 269
269 270
270 QMessageBox* box = new QMessageBox( this, "Test" ); 271 QMessageBox* box = new QMessageBox( this, "Test" );
271 box->setText( tr( "Changes applied" ) ); 272 box->setText( tr( "Changes applied" ) );
272 box->show(); 273 box->show();
273 // falls nötig hcid killhupen - die funktionalität adden 274 // falls nötig hcid killhupen - die funktionalität adden
274 } 275 }
275 276
276 277
277 /** 278 /**
278 * Add fresh found devices from scan dialog to the listing 279 * Add fresh found devices from scan dialog to the listing
279 * 280 *
280 */ 281 */
281 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) { 282 void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
282 283
283 BTListItem * deviceItem; 284 BTListItem * deviceItem;
284 285
285 QListIterator<RemoteDevice> it( newDevices ); 286 QListIterator<RemoteDevice> it( newDevices );
286 287
287 for( ; it.current() ; ++it ) { 288 for( ; it.current() ; ++it ) {
288 289
289 290
290 RemoteDevice *dev = it.current(); 291 RemoteDevice *dev = it.current();
291 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" ); 292 deviceItem = new BTListItem( ListView2 , dev->name(), dev->mac(), "device" );
292 deviceItem->setExpandable ( true ); 293 deviceItem->setExpandable ( true );
293 294
294 // look if device is avail. atm, async 295 // look if device is avail. atm, async
295 deviceActive( dev ); 296 deviceActive( dev );
296 297
297 // move into the c'tor 298 // move into the c'tor
298 // deviceItem->setMac( dev->mac() ); 299 // deviceItem->setMac( dev->mac() );
299 // what kind of entry is it. 300 // what kind of entry is it.
300 //deviceItem->setType( "device"); 301 //deviceItem->setType( "device");
301 302
302 // ggf auch hier? 303 // ggf auch hier?
303 addServicesToDevice( deviceItem ); 304 addServicesToDevice( deviceItem );
304 } 305 }
305 } 306 }
306 307
307 308
308 /** 309 /**
309 * Action that is toggled on entrys on click 310 * Action that is toggled on entrys on click
310 */ 311 */
311 void BlueBase::startServiceActionClicked( QListViewItem *item ) { 312 void BlueBase::startServiceActionClicked( QListViewItem *item ) {
312 313
313 314
314 } 315 }
315 316
316 /** 317 /**
317 * Action that are toggled on hold (mostly QPopups i guess) 318 * Action that are toggled on hold (mostly QPopups i guess)
318 */ 319 */
319 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) { 320 void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int column ) {
320 321
321 QPopupMenu *menu = new QPopupMenu(); 322 QPopupMenu *menu = new QPopupMenu();
322 323
323 int ret=0; 324 int ret=0;
324 325
325 326
326 //QSize s = menu->sizeHint ( ); 327 //QSize s = menu->sizeHint ( );
327 328
328 if ( ((BTListItem*)item)->type() == "device") { 329 if ( ((BTListItem*)item)->type() == "device") {
329 330
330 QPopupMenu *groups = new QPopupMenu(); 331 QPopupMenu *groups = new QPopupMenu();
331 332
332 menu->insertItem( tr("rescan sevices:"), 0); 333 menu->insertItem( tr("rescan sevices:"), 0);
333 menu->insertItem( tr("to group"), groups , 1); 334 menu->insertItem( tr("to group"), groups , 1);
334 menu->insertItem( tr("delete"), 2); 335 menu->insertItem( tr("delete"), 2);
335 336
336 337
337 ret = menu->exec( point , 0); 338 ret = menu->exec( point , 0);
338 339
339 switch(ret) { 340 switch(ret) {
340 case 0: 341 case 0:
341 break; 342 break;
342 case 1: 343 case 1:
343 break; 344 break;
344 case 2: 345 case 2:
345 // delete childs too 346 // delete childs too
346 delete item; 347 delete item;
347 break; 348 break;
348 } 349 }
349 delete groups; 350 delete groups;
350 351
351 } else if ( ((BTListItem*)item)->type() == "service") { 352 } else if ( ((BTListItem*)item)->type() == "service") {
352 menu->insertItem( tr("Test1:"), 0); 353 menu->insertItem( tr("Test1:"), 0);
353 menu->insertItem( tr("connect"), 1); 354 menu->insertItem( tr("connect"), 1);
354 menu->insertItem( tr("delete"), 2); 355 menu->insertItem( tr("delete"), 2);
355 356
356 ret = menu->exec( point , 0); 357 ret = menu->exec( point , 0);
357 358
358 switch(ret) { 359 switch(ret) {
359 case 0: 360 case 0:
360 break; 361 break;
361 case 1: 362 case 1:
362 break; 363 break;
363 case 2: 364 case 2:
364 // delete childs too 365 // delete childs too
365 delete item; 366 delete item;
366 break; 367 break;
367 } 368 }
368 } 369 }
369 370
370 delete menu; 371 delete menu;
371 } 372 }
372 373
373 /** 374 /**
374 * Search and display avail. services for a device (on expand from device listing) 375 * Search and display avail. services for a device (on expand from device listing)
375 * 376 *
376 */ 377 */
377 void BlueBase::addServicesToDevice( BTListItem * item ) { 378 void BlueBase::addServicesToDevice( BTListItem * item ) {
378 379
379 qDebug("addServicesToDevice"); 380 qDebug("addServicesToDevice");
380 // row of mac adress text(3) 381 // row of mac adress text(3)
381 RemoteDevice *device = new RemoteDevice( item->mac(), item->name() ); 382 RemoteDevice *device = new RemoteDevice( item->mac(), item->name() );
382 383
383 deviceList.insert( item->mac() , item ); 384 deviceList.insert( item->mac() , item );
384 385
385 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 386 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
386 localDevice->searchServices( *device ); 387 localDevice->searchServices( *device );
387 388
388 // delete 389 // delete
389 } 390 }
390 391
391 392
392 /** 393 /**
393 * Overloaded. This one it the one that is connected to the foundServices signal 394 * Overloaded. This one it the one that is connected to the foundServices signal
394 * @param device the mac address of the remote device 395 * @param device the mac address of the remote device
395 * @param servicesList the list with the service the device has. 396 * @param servicesList the list with the service the device has.
396 */ 397 */
397 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 398 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
398 399
399 qDebug("fill services list"); 400 qDebug("fill services list");
400 401
401 QMap<QString,BTListItem*>::Iterator it; 402 QMap<QString,BTListItem*>::Iterator it;
402 403
403 BTListItem* deviceItem; 404 BTListItem* deviceItem;
404 405
405 // get the right devices which requested the search 406 // get the right devices which requested the search
406 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 407 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
407 if ( it.key() == device ) { 408 if ( it.key() == device ) {
408 deviceItem = it.data(); 409 deviceItem = it.data();
409 } 410 }
410 } 411 }
411 412
412 413
413 // empty entries 414 // empty entries
414 // QListViewItem * myChild = deviceItem->firstChild(); 415 // QListViewItem * myChild = deviceItem->firstChild();
415 //QList<QListViewItem*> tmpList; 416 //QList<QListViewItem*> tmpList;
416 //while( myChild ) { 417 //while( myChild ) {
417 // tmpList.append(myChild); 418 // tmpList.append(myChild);
418 // myChild = myChild->nextSibling(); 419 // myChild = myChild->nextSibling();
419 // } 420 // }
420 421
421 422
422 QValueList<OpieTooth::Services>::Iterator it2; 423 QValueList<OpieTooth::Services>::Iterator it2;
423 424
424 BTListItem * serviceItem; 425 BTListItem * serviceItem;
425 426
426 if (!servicesList.isEmpty() ) { 427 if (!servicesList.isEmpty() ) {
427 // add services 428 // add services
428 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 429 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
429 serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); 430 serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" );
430 //serviceItem->setText(4, "service"); 431 //serviceItem->setText(4, "service");
431 } 432 }
432 } else { 433 } else {
433 serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); 434 serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" );
434 //serviceItem->setText(4, "service"); 435 //serviceItem->setText(4, "service");
435 } 436 }
436 } 437 }
437 438
438 439
439 /** 440 /**
440 * Add the existing connections (pairs) to the connections tab. 441 * Add the existing connections (pairs) to the connections tab.
441 * 442 *
442 */ 443 */
443 void BlueBase::addConnectedDevices() { 444 void BlueBase::addConnectedDevices() {
444 445
445 446
446 //mac address 447 //mac address
447 448
448 } 449 }
449 450
450 /** 451 /**
451 * Find out if a device can currently be reached 452 * Find out if a device can currently be reached
452 */ 453 */
453 void BlueBase::deviceActive( RemoteDevice *device ) { 454 void BlueBase::deviceActive( RemoteDevice *device ) {
454 455
455 // search by mac, async, gets a signal back 456 // search by mac, async, gets a signal back
456 localDevice->isAvailable( device->mac() ); 457 localDevice->isAvailable( device->mac() );
457 } 458 }
458 459
459 /** 460 /**
460 * The signal catcher. Set the avail. status on device. 461 * The signal catcher. Set the avail. status on device.
461 * @param device - the mac address 462 * @param device - the mac address
462 * @param connected - if it is avail. or not 463 * @param connected - if it is avail. or not
463 */ 464 */
464 void BlueBase::deviceActive( const QString& device, bool connected ) { 465 void BlueBase::deviceActive( const QString& device, bool connected ) {
465 466
466 qDebug("deviceActive slot"); 467 qDebug("deviceActive slot");
467 468
468 QMap<QString,BTListItem*>::Iterator it; 469 QMap<QString,BTListItem*>::Iterator it;
469 470
470 BTListItem* deviceItem; 471 BTListItem* deviceItem;
471 472
472 // get the right devices which requested the search 473 // get the right devices which requested the search
473 for( it = deviceList.begin(); it != deviceList.end(); ++it ) { 474 for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
474 if ( it.key() == device ) { 475 if ( it.key() == device ) {
475 deviceItem = it.data(); 476 deviceItem = it.data();
476 } 477 }
477 } 478 }
478 479
479 if ( connected ) { 480 if ( connected ) {
480 deviceItem->setPixmap( 1, onPix ); 481 deviceItem->setPixmap( 1, onPix );
481 } else { 482 } else {
482 deviceItem->setPixmap( 1, offPix ); 483 deviceItem->setPixmap( 1, offPix );
483 } 484 }
484 485
485 } 486 }
486 487
487 488
488 489
489 /** 490 /**
490 * Open the "scan for devices" dialog 491 * Open the "scan for devices" dialog
491 */ 492 */
492 void BlueBase::startScan() { 493 void BlueBase::startScan() {
493 494
494 ScanDialog *scan = new ScanDialog( this, "", true); 495 ScanDialog *scan = new ScanDialog( this, "", true);
495 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), 496 QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ),
496 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); 497 this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) );
497 498
498 scan->showMaximized(); 499 scan->showMaximized();
499 } 500 }
500 501
501 502
502 /** 503 /**
503 * Set the informations about the local device in information Tab 504 * Set the informations about the local device in information Tab
504 */ 505 */
505 void BlueBase::setInfo() { 506 void BlueBase::setInfo() {
506 StatusLabel->setText( getStatus() ); 507 StatusLabel->setText( getStatus() );
507 } 508 }
508 509
509 /** 510 /**
510 * Decontructor 511 * Decontructor
511 */ 512 */
512 BlueBase::~BlueBase() { 513 BlueBase::~BlueBase() {
513 writeSavedDevices(); 514 writeSavedDevices();
514 } 515 }
515} 516}
516 517