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