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