summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp58
1 files changed, 27 insertions, 31 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 7954cc3..af1cd23 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -32,659 +32,655 @@ using namespace Opie::Core;
32/* QT */ 32/* QT */
33#include <qframe.h> 33#include <qframe.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qvariant.h> 37#include <qvariant.h>
38#include <qimage.h> 38#include <qimage.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qtabwidget.h> 40#include <qtabwidget.h>
41#include <qscrollview.h> 41#include <qscrollview.h>
42#include <qvbox.h> 42#include <qvbox.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qcheckbox.h> 44#include <qcheckbox.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qlistview.h> 46#include <qlistview.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qpopupmenu.h> 48#include <qpopupmenu.h>
49#include <qtimer.h> 49#include <qtimer.h>
50#include <qlist.h> 50#include <qlist.h>
51 51
52/* STD */ 52/* STD */
53#include <remotedevice.h> 53#include <remotedevice.h>
54#include <services.h> 54#include <services.h>
55#include <stdlib.h> 55#include <stdlib.h>
56 56
57using namespace OpieTooth; 57using namespace OpieTooth;
58 58
59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 59BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
60 : BluetoothBase( parent, name, fl ) 60 : BluetoothBase( parent, name, fl )
61{ 61{
62 62
63 m_localDevice = new Manager( "hci0" ); 63 m_localDevice = new Manager( "hci0" );
64 64
65 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 65 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
66 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 66 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
67 67
68 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); 68 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) );
69 // not good since lib is async 69 // not good since lib is async
70 // connect( devicesView, SIGNAL( expanded(QListViewItem*) ), 70 // connect( devicesView, SIGNAL( expanded(QListViewItem*) ),
71 // this, SLOT( addServicesToDevice(QListViewItem*) ) ); 71 // this, SLOT( addServicesToDevice(QListViewItem*) ) );
72 connect( devicesView, SIGNAL( clicked(QListViewItem*)), 72 connect( devicesView, SIGNAL( clicked(QListViewItem*)),
73 this, SLOT( startServiceActionClicked(QListViewItem*) ) ); 73 this, SLOT( startServiceActionClicked(QListViewItem*) ) );
74 connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 74 connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
75 this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) ); 75 this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) );
76 connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ), 76 connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ),
77 this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) ); 77 this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) );
78 connect( m_localDevice, SIGNAL( available(const QString&,bool) ), 78 connect( m_localDevice, SIGNAL( available(const QString&,bool) ),
79 this, SLOT( deviceActive(const QString&,bool) ) ); 79 this, SLOT( deviceActive(const QString&,bool) ) );
80 connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), 80 connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ),
81 this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); 81 this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) );
82 connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), 82 connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ),
83 this, SLOT( addSignalStrength(const QString&,const QString&) ) ); 83 this, SLOT( addSignalStrength(const QString&,const QString&) ) );
84 84
85 85
86 // let hold be rightButtonClicked() 86 // let hold be rightButtonClicked()
87 QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); 87 QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold);
88 QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); 88 QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold);
89 89
90 //Load all icons needed 90 //Load all icons needed
91 m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); 91 m_offPix = Resource::loadPixmap( "opietooth/notconnected" );
92 m_onPix = Resource::loadPixmap( "opietooth/connected" ); 92 m_onPix = Resource::loadPixmap( "opietooth/connected" );
93 m_findPix = Resource::loadPixmap( "opietooth/find" ); 93 m_findPix = Resource::loadPixmap( "opietooth/find" );
94 94
95 QPalette pal = this->palette(); 95 QPalette pal = this->palette();
96 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 96 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
97 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 97 pal.setColor( QPalette::Active, QColorGroup::Button, col );
98 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 98 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
99 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 99 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
100 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 100 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
101 this->setPalette( pal ); 101 this->setPalette( pal );
102 102
103 setCaption( tr( "Bluetooth Manager" ) ); 103 setCaption( tr( "Bluetooth Manager" ) );
104 104
105 readConfig(); 105 readConfig();
106 initGui(); 106 initGui();
107 107
108 devicesView->setRootIsDecorated(true); 108 devicesView->setRootIsDecorated(true);
109 109
110 110
111 writeToHciConfig(); 111 writeToHciConfig();
112 // search conncetions 112 // search conncetions
113 addConnectedDevices(); 113 addConnectedDevices();
114 addSignalStrength(); 114 addSignalStrength();
115 m_iconLoader = new BTIconLoader(); 115 m_iconLoader = new BTIconLoader();
116 readSavedDevices(); 116 readSavedDevices();
117} 117}
118 118
119/** 119/**
120 * Reads all options from the config file 120 * Reads all options from the config file
121 */ 121 */
122void BlueBase::readConfig() 122void BlueBase::readConfig()
123{ 123{
124 124
125 Config cfg( "bluetoothmanager" ); 125 Config cfg( "bluetoothmanager" );
126 cfg.setGroup( "bluezsettings" ); 126 cfg.setGroup( "bluezsettings" );
127 127
128 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 128 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
129 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 129 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
130 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 130 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
131 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 131 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
132 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 132 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
133 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 133 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
134} 134}
135 135
136/** 136/**
137 * Writes all options to the config file 137 * Writes all options to the config file
138 */ 138 */
139void BlueBase::writeConfig() 139void BlueBase::writeConfig()
140{ 140{
141 141
142 Config cfg( "bluetoothmanager" ); 142 Config cfg( "bluetoothmanager" );
143 cfg.setGroup( "bluezsettings" ); 143 cfg.setGroup( "bluezsettings" );
144 144
145 cfg.writeEntry( "name" , m_deviceName ); 145 cfg.writeEntry( "name" , m_deviceName );
146 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); 146 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
147 cfg.writeEntry( "useEncryption" , m_useEncryption ); 147 cfg.writeEntry( "useEncryption" , m_useEncryption );
148 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); 148 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
149 cfg.writeEntry( "enablePagescan" , m_enablePagescan ); 149 cfg.writeEntry( "enablePagescan" , m_enablePagescan );
150 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); 150 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
151 151
152 writeToHciConfig(); 152 writeToHciConfig();
153} 153}
154 154
155/** 155/**
156 * Modify the hcid.conf file to our needs 156 * Modify the hcid.conf file to our needs
157 */ 157 */
158void BlueBase::writeToHciConfig() 158void BlueBase::writeToHciConfig()
159{ 159{
160 owarn << "writeToHciConfig" << oendl; 160 owarn << "writeToHciConfig" << oendl;
161 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); 161 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
162 hciconf.load(); 162 hciconf.load();
163 hciconf.setPinHelper( QPEApplication::qpeDir() + "bin/bluepin" ); 163 hciconf.setPinHelper( QPEApplication::qpeDir() + "bin/bluepin" );
164 hciconf.setName( m_deviceName ); 164 hciconf.setName( m_deviceName );
165 hciconf.setEncrypt( m_useEncryption ); 165 hciconf.setEncrypt( m_useEncryption );
166 hciconf.setAuth( m_enableAuthentification ); 166 hciconf.setAuth( m_enableAuthentification );
167 hciconf.setPscan( m_enablePagescan ); 167 hciconf.setPscan( m_enablePagescan );
168 hciconf.setIscan( m_enableInquiryscan ); 168 hciconf.setIscan( m_enableInquiryscan );
169 hciconf.save(); 169 hciconf.save();
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 */
176void BlueBase::readSavedDevices() 176void BlueBase::readSavedDevices()
177{ 177{
178 178
179 QValueList<RemoteDevice> loadedDevices; 179 QValueList<RemoteDevice> loadedDevices;
180 DeviceHandler handler; 180 DeviceHandler handler;
181 loadedDevices = handler.load(); 181 loadedDevices = handler.load();
182 182
183 addSearchedDevices( loadedDevices ); 183 addSearchedDevices( loadedDevices );
184} 184}
185 185
186 186
187/** 187/**
188 * Write the list of allready known devices 188 * Write the list of allready known devices
189 */ 189 */
190void BlueBase::writeSavedDevices() 190void BlueBase::writeSavedDevices()
191{ 191{
192 QListViewItemIterator it( devicesView ); 192 QListViewItemIterator it( devicesView );
193 BTListItem* item; 193 BTListItem* item;
194 BTDeviceItem* device; 194 BTDeviceItem* device;
195 RemoteDevice::ValueList list; 195 RemoteDevice::ValueList list;
196 for ( ; it.current(); ++it ) 196 for ( ; it.current(); ++it )
197 { 197 {
198 item = (BTListItem*)it.current(); 198 item = (BTListItem*)it.current();
199 if(item->typeId() != BTListItem::Device ) 199 if(item->typeId() != BTListItem::Device )
200 continue; 200 continue;
201 device = (BTDeviceItem*)item; 201 device = (BTDeviceItem*)item;
202 202
203 list.append( device->remoteDevice() ); 203 list.append( device->remoteDevice() );
204 } 204 }
205 /* 205 /*
206 * if not empty save the List through DeviceHandler 206 * if not empty save the List through DeviceHandler
207 */ 207 */
208 if ( list.isEmpty() ) 208 if ( list.isEmpty() )
209 return; 209 return;
210 DeviceHandler handler; 210 DeviceHandler handler;
211 handler.save( list ); 211 handler.save( list );
212} 212}
213 213
214 214
215/** 215/**
216 * Set up the gui 216 * Set up the gui
217 */ 217 */
218void BlueBase::initGui() 218void BlueBase::initGui()
219{ 219{
220 StatusLabel->setText( status() ); // maybe move it to getStatus() 220 StatusLabel->setText( status() ); // maybe move it to getStatus()
221 cryptCheckBox->setChecked( m_useEncryption ); 221 cryptCheckBox->setChecked( m_useEncryption );
222 authCheckBox->setChecked( m_enableAuthentification ); 222 authCheckBox->setChecked( m_enableAuthentification );
223 pagescanCheckBox->setChecked( m_enablePagescan ); 223 pagescanCheckBox->setChecked( m_enablePagescan );
224 inquiryscanCheckBox->setChecked( m_enableInquiryscan ); 224 inquiryscanCheckBox->setChecked( m_enableInquiryscan );
225 deviceNameLine->setText( m_deviceName ); 225 deviceNameLine->setText( m_deviceName );
226 passkeyLine->setText( m_defaultPasskey ); 226 passkeyLine->setText( m_defaultPasskey );
227 // set info tab 227 // set info tab
228 setInfo(); 228 setInfo();
229} 229}
230 230
231 231
232/** 232/**
233 * Get the status informations and returns it 233 * Get the status informations and returns it
234 * @return QString the status informations gathered 234 * @return QString the status informations gathered
235 */ 235 */
236QString BlueBase::status()const 236QString BlueBase::status()const
237{ 237{
238 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 238 QString infoString = tr( "<b>Device name : </b> Ipaq" );
239 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 239 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
240 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 240 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
241 241
242 return (infoString); 242 return (infoString);
243} 243}
244 244
245 245
246/** 246/**
247 * Read the current values from the gui and invoke writeConfig() 247 * Read the current values from the gui and invoke writeConfig()
248 */ 248 */
249void BlueBase::applyConfigChanges() 249void BlueBase::applyConfigChanges()
250{ 250{
251 m_deviceName = deviceNameLine->text(); 251 m_deviceName = deviceNameLine->text();
252 m_defaultPasskey = passkeyLine->text(); 252 m_defaultPasskey = passkeyLine->text();
253 m_useEncryption = cryptCheckBox->isChecked(); 253 m_useEncryption = cryptCheckBox->isChecked();
254 m_enableAuthentification = authCheckBox->isChecked(); 254 m_enableAuthentification = authCheckBox->isChecked();
255 m_enablePagescan = pagescanCheckBox->isChecked(); 255 m_enablePagescan = pagescanCheckBox->isChecked();
256 m_enableInquiryscan = inquiryscanCheckBox->isChecked(); 256 m_enableInquiryscan = inquiryscanCheckBox->isChecked();
257 257
258 writeConfig(); 258 writeConfig();
259 259
260 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); 260 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
261} 261}
262 262
263/** 263/**
264 * Launch Rfcomm Bind dialog 264 * Launch Rfcomm Bind dialog
265 * 265 *
266 */ 266 */
267void BlueBase::rfcommDialog() 267void BlueBase::rfcommDialog()
268{ 268{
269 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); 269 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp );
270 270
271 if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) 271 if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted )
272 { 272 {
273 rfcommAssign.saveConfig(); 273 rfcommAssign.saveConfig();
274 } 274 }
275} 275}
276 276
277/** 277/**
278 * Add fresh found devices from scan dialog to the listing 278 * Add fresh found devices from scan dialog to the listing
279 * 279 *
280 */ 280 */
281void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) 281void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
282{ 282{
283 BTDeviceItem * deviceItem; 283 BTDeviceItem * deviceItem;
284 QValueList<RemoteDevice>::ConstIterator it; 284 QValueList<RemoteDevice>::ConstIterator it;
285 285
286 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) 286 for( it = newDevices.begin(); it != newDevices.end() ; ++it )
287 { 287 {
288 288
289 if (find( (*it) )) // is already inserted 289 if (find( (*it) )) // is already inserted
290 continue; 290 continue;
291 291
292 deviceItem = new BTDeviceItem( devicesView , (*it) ); 292 deviceItem = new BTDeviceItem( devicesView , (*it) );
293 deviceItem->setPixmap( 1, m_findPix ); 293 deviceItem->setPixmap( 1, m_findPix );
294 deviceItem->setExpandable ( true ); 294 deviceItem->setExpandable ( true );
295 295
296 // look if device is avail. atm, async 296 // look if device is avail. atm, async
297 deviceActive( (*it) ); 297 deviceActive( (*it) );
298 298
299 // ggf auch hier? 299 // ggf auch hier?
300 addServicesToDevice( deviceItem ); 300 addServicesToDevice( deviceItem );
301 } 301 }
302} 302}
303 303
304 304
305/** 305/**
306 * Action that is toggled on entrys on click 306 * Action that is toggled on entrys on click
307 */ 307 */
308void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) 308void BlueBase::startServiceActionClicked( QListViewItem */*item*/ )
309{} 309{}
310 310
311 311
312/** 312/**
313 * Action that are toggled on hold (mostly QPopups i guess) 313 * Action that are toggled on hold (mostly QPopups i guess)
314 */ 314 */
315void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) 315void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ )
316{ 316{
317 if (!item ) 317 if (!item )
318 return; 318 return;
319 319
320 QPopupMenu *menu = new QPopupMenu(); 320 QPopupMenu *menu = new QPopupMenu();
321 int ret=0;
322 321
323 if ( ((BTListItem*)item)->type() == "device") 322 if ( static_cast<BTListItem*>( item )->type() == "device")
324 { 323 {
325
326 QPopupMenu *groups = new QPopupMenu(); 324 QPopupMenu *groups = new QPopupMenu();
327 325
328 menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); 326 menu->insertItem( static_cast<BTDeviceItem*>( item )->name(), 0 );
329 menu->insertSeparator(1); 327 menu->insertSeparator( 1 );
330 menu->insertItem( tr("rescan sevices"), 2); 328 menu->insertItem( tr( "&Rescan services" ), 2);
331 menu->insertItem( tr("to group"), groups , 3); 329 // menu->insertItem( tr( "&Add to group" ), groups, 3);
332 menu->insertItem( tr("delete"), 4); 330 menu->insertItem( tr( "&Delete"), 4);
333 331 int ret = menu->exec( point, 0);
334 ret = menu->exec( point , 0);
335 332
336 switch(ret) 333 switch(ret)
337 { 334 {
338 case -1: 335 case -1:
339 break; 336 break;
340 case 2: 337 case 2:
341 addServicesToDevice( (BTDeviceItem*)item ); 338 addServicesToDevice( static_cast<BTDeviceItem*>( item ) );
342 break; 339 break;
343 340
344 case 4: 341 case 4:
345 // deletes childs too 342 // deletes childs too
346 delete item; 343 delete item;
347 break; 344 break;
348 } 345 }
349 delete groups; 346 // delete groups;
350
351 } 347 }
352 348
353 /* 349 /*
354 * We got service sensitive PopupMenus in our factory 350 * We got service sensitive PopupMenus in our factory
355 * We will create one through the factory and will insert 351 * We will create one through the factory and will insert
356 * our Separator + ShowInfo into the menu or create a new 352 * our Separator + ShowInfo into the menu or create a new
357 * one if the factory returns 0 353 * one if the factory returns 0
358 * PopupMenu deletion is kind of weird. 354 * PopupMenu deletion is kind of weird.
359 * If escaped( -1 ) or any of our items were chosen we'll 355 * If escaped( -1 ) or any of our items were chosen we'll
360 * delete the PopupMenu otherwise it's the responsibility of 356 * delete the PopupMenu otherwise it's the responsibility of
361 * the PopupMenu to delete itself 357 * the PopupMenu to delete itself
362 * 358 *
363 */ 359 */
364 else if ( ((BTListItem*)item)->type() == "service") 360 else if ( ((BTListItem*)item)->type() == "service")
365 { 361 {
366 BTServiceItem* service = (BTServiceItem*)item; 362 BTServiceItem* service = (BTServiceItem*)item;
367 QMap<int, QString> list = service->services().classIdList(); 363 QMap<int, QString> list = service->services().classIdList();
368 QMap<int, QString>::Iterator it = list.begin(); 364 QMap<int, QString>::Iterator it = list.begin();
369 QPopupMenu *popup =0l; 365 QPopupMenu *popup =0l;
370 if ( it != list.end() ) 366 if ( it != list.end() )
371 { 367 {
372 owarn << "Searching id " << it.key() << " " << it.data().latin1() << "" << oendl; 368 owarn << "Searching id " << it.key() << " " << it.data().latin1() << "" << oendl;
373 popup = m_popHelper.find( it.key(), 369 popup = m_popHelper.find( it.key(),
374 service->services(), 370 service->services(),
375 (BTDeviceItem*)service->parent() ); 371 (BTDeviceItem*)service->parent() );
376 } 372 }
377 else 373 else
378 { 374 {
379 owarn << "Empty" << oendl; 375 owarn << "Empty" << oendl;
380 } 376 }
381 377
382 if ( popup == 0l ) 378 if ( popup == 0l )
383 { 379 {
384 owarn << "factory returned 0l" << oendl; 380 owarn << "factory returned 0l" << oendl;
385 popup = new QPopupMenu(); 381 popup = new QPopupMenu();
386 } 382 }
387 int test1 = popup->insertItem( tr("Test1:"), 2); 383 int test1 = popup->insertItem( tr("Test1:"), 2);
388 384
389 ret = popup->exec( point ); 385 int ret = popup->exec( point );
390 owarn << "returned from exec() " << oendl; 386 owarn << "returned from exec() " << oendl;
391 if ( ret == -1 ) 387 if ( ret == -1 )
392 { 388 {
393 ; 389 ;
394 } 390 }
395 else if ( ret == test1 ) 391 else if ( ret == test1 )
396 { 392 {
397 ; 393 ;
398 } 394 }
399 delete popup; 395 delete popup;
400 } 396 }
401 delete menu; 397 delete menu;
402} 398}
403 399
404 400
405/** 401/**
406 * Search and display avail. services for a device (on expand from device listing) 402 * Search and display avail. services for a device (on expand from device listing)
407 * @param item the service item returned 403 * @param item the service item returned
408 */ 404 */
409void BlueBase::addServicesToDevice( BTDeviceItem * item ) 405void BlueBase::addServicesToDevice( BTDeviceItem * item )
410{ 406{
411 odebug << "addServicesToDevice" << oendl; 407 odebug << "addServicesToDevice" << oendl;
412 // row of mac adress text(3) 408 // row of mac adress text(3)
413 RemoteDevice device = item->remoteDevice(); 409 RemoteDevice device = item->remoteDevice();
414 m_deviceList.insert( item->mac() , item ); 410 m_deviceList.insert( item->mac() , item );
415 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 411 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
416 m_localDevice->searchServices( device ); 412 m_localDevice->searchServices( device );
417} 413}
418 414
419 415
420/** 416/**
421 * Overloaded. This one it the one that is 417 * Overloaded. This one it the one that is
422 ted to the foundServices signal 418 ted to the foundServices signal
423 * @param device the mac address of the remote device 419 * @param device the mac address of the remote device
424 * @param servicesList the list with the service the device has. 420 * @param servicesList the list with the service the device has.
425 */ 421 */
426void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) 422void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList )
427{ 423{
428 odebug << "fill services list" << oendl; 424 odebug << "fill services list" << oendl;
429 425
430 QMap<QString,BTDeviceItem*>::Iterator it; 426 QMap<QString,BTDeviceItem*>::Iterator it;
431 BTDeviceItem* deviceItem = 0; 427 BTDeviceItem* deviceItem = 0;
432 428
433 // get the right devices which requested the search 429 // get the right devices which requested the search
434 it = m_deviceList.find( device ); 430 it = m_deviceList.find( device );
435 if( it == m_deviceList.end() ) 431 if( it == m_deviceList.end() )
436 return; 432 return;
437 deviceItem = it.data(); 433 deviceItem = it.data();
438 434
439 // remove previous entries 435 // remove previous entries
440 QList<QListViewItem> tempList; 436 QList<QListViewItem> tempList;
441 tempList.setAutoDelete( true ); 437 tempList.setAutoDelete( true );
442 QListViewItem * child = deviceItem->firstChild(); 438 QListViewItem * child = deviceItem->firstChild();
443 while( child ) 439 while( child )
444 { 440 {
445 tempList.append( child ); 441 tempList.append( child );
446 child = child->nextSibling(); 442 child = child->nextSibling();
447 } 443 }
448 tempList.clear(); 444 tempList.clear();
449 445
450 QValueList<OpieTooth::Services>::Iterator it2; 446 QValueList<OpieTooth::Services>::Iterator it2;
451 BTServiceItem* serviceItem; 447 BTServiceItem* serviceItem;
452 448
453 449
454 if (!servicesList.isEmpty() ) 450 if (!servicesList.isEmpty() )
455 { 451 {
456 // add services 452 // add services
457 QMap<int, QString> list; 453 QMap<int, QString> list;
458 QMap<int, QString>::Iterator classIt; 454 QMap<int, QString>::Iterator classIt;
459 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) 455 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 )
460 { 456 {
461 serviceItem = new BTServiceItem( deviceItem, (*it2) ); 457 serviceItem = new BTServiceItem( deviceItem, (*it2) );
462 list = (*it2).classIdList(); 458 list = (*it2).classIdList();
463 classIt = list.begin(); 459 classIt = list.begin();
464 int classId=0; 460 int classId=0;
465 if ( classIt != list.end() ) 461 if ( classIt != list.end() )
466 { 462 {
467 classId = classIt.key(); 463 classId = classIt.key();
468 } 464 }
469 465
470 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 466 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
471 } 467 }
472 } 468 }
473 else 469 else
474 { 470 {
475 Services s1; 471 Services s1;
476 s1.setServiceName( tr("no services found") ); 472 s1.setServiceName( tr("no services found") );
477 serviceItem = new BTServiceItem( deviceItem, s1 ); 473 serviceItem = new BTServiceItem( deviceItem, s1 );
478 } 474 }
479 // now remove them from the list 475 // now remove them from the list
480 m_deviceList.remove( it ); 476 m_deviceList.remove( it );
481} 477}
482 478
483 479
484 480
485 481
486 482
487void BlueBase::addSignalStrength() 483void BlueBase::addSignalStrength()
488{ 484{
489 485
490 QListViewItemIterator it( connectionsView ); 486 QListViewItemIterator it( connectionsView );
491 for ( ; it.current(); ++it ) 487 for ( ; it.current(); ++it )
492 { 488 {
493 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); 489 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
494 } 490 }
495 491
496 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); 492 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
497} 493}
498 494
499void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) 495void BlueBase::addSignalStrength( const QString& mac, const QString& strength )
500{ 496{
501 497
502 QListViewItemIterator it( connectionsView ); 498 QListViewItemIterator it( connectionsView );
503 for ( ; it.current(); ++it ) 499 for ( ; it.current(); ++it )
504 { 500 {
505 if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) 501 if( ((BTConnectionItem*)it.current())->connection().mac() == mac )
506 { 502 {
507 ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); 503 ((BTConnectionItem*)it.current() )->setSignalStrength( strength );
508 } 504 }
509 } 505 }
510} 506}
511 507
512/** 508/**
513 * Add the existing connections (pairs) to the connections tab. 509 * Add the existing connections (pairs) to the connections tab.
514 * This one triggers the search 510 * This one triggers the search
515 */ 511 */
516void BlueBase::addConnectedDevices() 512void BlueBase::addConnectedDevices()
517{ 513{
518 m_localDevice->searchConnections(); 514 m_localDevice->searchConnections();
519} 515}
520 516
521/** 517/**
522 * This adds the found connections to the connection tab. 518 * This adds the found connections to the connection tab.
523 * @param connectionList the ValueList with all current connections 519 * @param connectionList the ValueList with all current connections
524 */ 520 */
525void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) 521void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
526{ 522{
527 523
528 QValueList<OpieTooth::ConnectionState>::Iterator it; 524 QValueList<OpieTooth::ConnectionState>::Iterator it;
529 BTConnectionItem * connectionItem; 525 BTConnectionItem * connectionItem;
530 526
531 if ( !connectionList.isEmpty() ) 527 if ( !connectionList.isEmpty() )
532 { 528 {
533 529
534 for (it = connectionList.begin(); it != connectionList.end(); ++it) 530 for (it = connectionList.begin(); it != connectionList.end(); ++it)
535 { 531 {
536 532
537 QListViewItemIterator it2( connectionsView ); 533 QListViewItemIterator it2( connectionsView );
538 bool found = false; 534 bool found = false;
539 for ( ; it2.current(); ++it2 ) 535 for ( ; it2.current(); ++it2 )
540 { 536 {
541 if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) 537 if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() )
542 { 538 {
543 found = true; 539 found = true;
544 } 540 }
545 } 541 }
546 542
547 if ( found == false ) 543 if ( found == false )
548 { 544 {
549 connectionItem = new BTConnectionItem( connectionsView, (*it) ); 545 connectionItem = new BTConnectionItem( connectionsView, (*it) );
550 546
551 if( m_deviceList.find((*it).mac()).data() ) 547 if( m_deviceList.find((*it).mac()).data() )
552 { 548 {
553 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); 549 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
554 } 550 }
555 } 551 }
556 552
557 } 553 }
558 554
559 QListViewItemIterator it2( connectionsView ); 555 QListViewItemIterator it2( connectionsView );
560 for ( ; it2.current(); ++it2 ) 556 for ( ; it2.current(); ++it2 )
561 { 557 {
562 bool found = false; 558 bool found = false;
563 for (it = connectionList.begin(); it != connectionList.end(); ++it) 559 for (it = connectionList.begin(); it != connectionList.end(); ++it)
564 { 560 {
565 if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) 561 if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() )
566 { 562 {
567 found = true; 563 found = true;
568 } 564 }
569 } 565 }
570 566
571 if ( !found ) 567 if ( !found )
572 { 568 {
573 delete it2.current(); 569 delete it2.current();
574 } 570 }
575 571
576 } 572 }
577 573
578 574
579 } 575 }
580 else 576 else
581 { 577 {
582 connectionsView->clear(); 578 connectionsView->clear();
583 ConnectionState con; 579 ConnectionState con;
584 con.setMac( tr("No connections found") ); 580 con.setMac( tr("No connections found") );
585 connectionItem = new BTConnectionItem( connectionsView , con ); 581 connectionItem = new BTConnectionItem( connectionsView , con );
586 } 582 }
587 583
588 // recall connection search after some time 584 // recall connection search after some time
589 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); 585 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) );
590} 586}
591 587
592 588
593/** 589/**
594 * Find out if a device can currently be reached 590 * Find out if a device can currently be reached
595 * @param device 591 * @param device
596 */ 592 */
597void BlueBase::deviceActive( const RemoteDevice &device ) 593void BlueBase::deviceActive( const RemoteDevice &device )
598{ 594{
599 // search by mac, async, gets a signal back 595 // search by mac, async, gets a signal back
600 // We should have a BTDeviceItem there or where does it get added to the map -zecke 596 // We should have a BTDeviceItem there or where does it get added to the map -zecke
601 m_localDevice->isAvailable( device.mac() ); 597 m_localDevice->isAvailable( device.mac() );
602} 598}
603 599
604 600
605/** 601/**
606 * The signal catcher. Set the avail. status on device. 602 * The signal catcher. Set the avail. status on device.
607 * @param device - the mac address 603 * @param device - the mac address
608 * @param connected - if it is avail. or not 604 * @param connected - if it is avail. or not
609 */ 605 */
610void BlueBase::deviceActive( const QString& device, bool connected ) 606void BlueBase::deviceActive( const QString& device, bool connected )
611{ 607{
612 odebug << "deviceActive slot" << oendl; 608 odebug << "deviceActive slot" << oendl;
613 609
614 QMap<QString,BTDeviceItem*>::Iterator it; 610 QMap<QString,BTDeviceItem*>::Iterator it;
615 611
616 it = m_deviceList.find( device ); 612 it = m_deviceList.find( device );
617 if( it == m_deviceList.end() ) 613 if( it == m_deviceList.end() )
618 return; 614 return;
619 615
620 BTDeviceItem* deviceItem = it.data(); 616 BTDeviceItem* deviceItem = it.data();
621 617
622 618
623 if ( connected ) 619 if ( connected )
624 { 620 {
625 deviceItem->setPixmap( 1, m_onPix ); 621 deviceItem->setPixmap( 1, m_onPix );
626 } 622 }
627 else 623 else
628 { 624 {
629 deviceItem->setPixmap( 1, m_offPix ); 625 deviceItem->setPixmap( 1, m_offPix );
630 } 626 }
631 m_deviceList.remove( it ); 627 m_deviceList.remove( it );
632} 628}
633 629
634 630
635/** 631/**
636 * Open the "scan for devices" dialog 632 * Open the "scan for devices" dialog
637 */ 633 */
638void BlueBase::startScan() 634void BlueBase::startScan()
639{ 635{
640 ScanDialog *scan = new ScanDialog( this, "ScanDialog", 636 ScanDialog *scan = new ScanDialog( this, "ScanDialog",
641 true, WDestructiveClose ); 637 true, WDestructiveClose );
642 QObject::connect( scan, SIGNAL( selectedDevices(const QValueList<RemoteDevice>&) ), 638 QObject::connect( scan, SIGNAL( selectedDevices(const QValueList<RemoteDevice>&) ),
643 this, SLOT( addSearchedDevices(const QValueList<RemoteDevice>&) ) ); 639 this, SLOT( addSearchedDevices(const QValueList<RemoteDevice>&) ) );
644 640
645 QPEApplication::showDialog( scan ); 641 QPEApplication::showDialog( scan );
646} 642}
647 643
648 644
649/** 645/**
650 * Set the informations about the local device in information Tab 646 * Set the informations about the local device in information Tab
651 */ 647 */
652void BlueBase::setInfo() 648void BlueBase::setInfo()
653{ 649{
654 StatusLabel->setText( status() ); 650 StatusLabel->setText( status() );
655} 651}
656 652
657 653
658/** 654/**
659 * Decontructor 655 * Decontructor
660 */ 656 */
661BlueBase::~BlueBase() 657BlueBase::~BlueBase()
662{ 658{
663 writeSavedDevices(); 659 writeSavedDevices();
664 delete m_iconLoader; 660 delete m_iconLoader;
665} 661}
666 662
667 663
668/** 664/**
669 * find searches the ListView for a BTDeviceItem containig 665 * find searches the ListView for a BTDeviceItem containig
670 * the same Device if found return true else false 666 * the same Device if found return true else false
671 * @param dev RemoteDevice to find 667 * @param dev RemoteDevice to find
672 * @return returns true if found 668 * @return returns true if found
673 */ 669 */
674bool BlueBase::find( const RemoteDevice& rem ) 670bool BlueBase::find( const RemoteDevice& rem )
675{ 671{
676 QListViewItemIterator it( devicesView ); 672 QListViewItemIterator it( devicesView );
677 BTListItem* item; 673 BTListItem* item;
678 BTDeviceItem* device; 674 BTDeviceItem* device;
679 for (; it.current(); ++it ) 675 for (; it.current(); ++it )
680 { 676 {
681 item = (BTListItem*) it.current(); 677 item = (BTListItem*) it.current();
682 if ( item->typeId() != BTListItem::Device ) 678 if ( item->typeId() != BTListItem::Device )
683 continue; 679 continue;
684 680
685 device = (BTDeviceItem*)item; 681 device = (BTDeviceItem*)item;
686 if ( rem.equals( device->remoteDevice() ) ) 682 if ( rem.equals( device->remoteDevice() ) )
687 return true; 683 return true;
688 } 684 }
689 return false; // not found 685 return false; // not found
690} 686}