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