summaryrefslogtreecommitdiff
authorzecke <zecke>2002-07-13 12:53:59 (UTC)
committer zecke <zecke>2002-07-13 12:53:59 (UTC)
commit8be0a8e108eaf8ff99301aa175298ddeb48eae67 (patch) (unidiff)
tree0fbe4d10476cb39d290fa4a3d6e8bdf76390c30c
parent6337e3836497ede8bb47aea5c7b65f4f8c08c4cd (diff)
downloadopie-8be0a8e108eaf8ff99301aa175298ddeb48eae67.zip
opie-8be0a8e108eaf8ff99301aa175298ddeb48eae67.tar.gz
opie-8be0a8e108eaf8ff99301aa175298ddeb48eae67.tar.bz2
Icon loader updates
and LIB updates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp10
-rw-r--r--noncore/net/opietooth/manager/bticonloader.cpp61
-rw-r--r--noncore/net/opietooth/manager/bticonloader.h8
-rw-r--r--noncore/net/opietooth/manager/btserviceitem.cpp3
-rw-r--r--noncore/net/opietooth/manager/btserviceitem.h1
-rw-r--r--noncore/net/opietooth/manager/stdpopups.cpp5
6 files changed, 52 insertions, 36 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 9cfeaa2..189001d 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,476 +1,484 @@
1/* 1/*
2 * bluebase.cpp * 2 * bluebase.cpp *
3 * --------------------- 3 * ---------------------
4 * 4 *
5 * copyright : (c) 2002 by Maximilian Reiß 5 * copyright : (c) 2002 by Maximilian Reiß
6 * email : max.reiss@gmx.de 6 * email : max.reiss@gmx.de
7 * 7 *
8 */ 8 */
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20#include "hciconfwrapper.h" 20#include "hciconfwrapper.h"
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qvariant.h> 26#include <qvariant.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qimage.h> 28#include <qimage.h>
29#include <qpixmap.h> 29#include <qpixmap.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qscrollview.h> 31#include <qscrollview.h>
32#include <qvbox.h> 32#include <qvbox.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qlistview.h> 36#include <qlistview.h>
37#include <qdir.h> 37#include <qdir.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39#include <qtimer.h> 39#include <qtimer.h>
40 40
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/config.h> 42#include <qpe/config.h>
43 43
44#include <remotedevice.h> 44#include <remotedevice.h>
45#include <services.h> 45#include <services.h>
46 46
47#include "btconnectionitem.h" 47#include "btconnectionitem.h"
48 48
49using namespace OpieTooth; 49using namespace OpieTooth;
50 50
51 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 51 BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
52 : BluetoothBase( parent, name, fl ) { 52 : BluetoothBase( parent, name, fl ) {
53 53
54 m_localDevice = new Manager( "hci0" ); 54 m_localDevice = new Manager( "hci0" );
55 55
56 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 56 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
57 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 57 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
58 // not good since lib is async 58 // not good since lib is async
59 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 59 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
60 // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 60 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
61 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 61 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
62 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 62 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
63 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 63 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
64 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 64 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
65 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 65 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
66 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 66 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
67 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), 67 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
68 this, SLOT( deviceActive( const QString& , bool ) ) ); 68 this, SLOT( deviceActive( const QString& , bool ) ) );
69 connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ), 69 connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ),
70 this, SLOT( addConnectedDevices( Connection::ValueList ) ) ); 70 this, SLOT( addConnectedDevices( Connection::ValueList ) ) );
71 71
72 //Load all icons needed 72 //Load all icons needed
73 m_offPix = Resource::loadPixmap( "editdelete" ); 73 m_offPix = Resource::loadPixmap( "editdelete" );
74 m_onPix = Resource::loadPixmap( "installed" ); 74 m_onPix = Resource::loadPixmap( "installed" );
75 75
76 QPalette pal = this->palette(); 76 QPalette pal = this->palette();
77 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 77 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
78 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 78 pal.setColor( QPalette::Active, QColorGroup::Button, col );
79 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 79 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
80 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 80 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
81 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 81 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
82 this->setPalette( pal ); 82 this->setPalette( pal );
83 83
84 setCaption( tr( "Bluetooth Manager" ) ); 84 setCaption( tr( "Bluetooth Manager" ) );
85 85
86 readConfig(); 86 readConfig();
87 initGui(); 87 initGui();
88 88
89 //TESTING 89 //TESTING
90 ListView2->setRootIsDecorated(true); 90 ListView2->setRootIsDecorated(true);
91 91
92 BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); 92 BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) );
93 topLV2->setPixmap( 1, m_onPix ); 93 topLV2->setPixmap( 1, m_onPix );
94 Services s1; 94 Services s1;
95 s1.setServiceName( "Serial" ); 95 s1.setServiceName( "Serial" );
96 (void) new BTServiceItem( topLV2, s1 ); 96 (void) new BTServiceItem( topLV2, s1 );
97 s1.setServiceName( "BlueNic" ); 97 s1.setServiceName( "BlueNic" );
98 (void) new BTServiceItem( topLV2, s1 ); 98 (void) new BTServiceItem( topLV2, s1 );
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 } 104 }
105 105
106 /** 106 /**
107 * Reads all options from the config file 107 * Reads all options from the config file
108 */ 108 */
109 void BlueBase::readConfig() { 109 void BlueBase::readConfig() {
110 110
111 Config cfg( "bluetoothmanager" ); 111 Config cfg( "bluetoothmanager" );
112 cfg.setGroup( "bluezsettings" ); 112 cfg.setGroup( "bluezsettings" );
113 113
114 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 114 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
115 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 115 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
116 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 116 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
117 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 117 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
118 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 118 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
119 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 119 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
120 } 120 }
121 121
122 /** 122 /**
123 * Writes all options to the config file 123 * Writes all options to the config file
124 */ 124 */
125 void BlueBase::writeConfig() { 125 void BlueBase::writeConfig() {
126 126
127 Config cfg( "bluetoothmanager" ); 127 Config cfg( "bluetoothmanager" );
128 cfg.setGroup( "bluezsettings" ); 128 cfg.setGroup( "bluezsettings" );
129 129
130 cfg.writeEntry( "name" , m_deviceName ); 130 cfg.writeEntry( "name" , m_deviceName );
131 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); 131 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
132 cfg.writeEntry( "useEncryption" , m_useEncryption ); 132 cfg.writeEntry( "useEncryption" , m_useEncryption );
133 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); 133 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
134 cfg.writeEntry( "enablePagescan" , m_enablePagescan ); 134 cfg.writeEntry( "enablePagescan" , m_enablePagescan );
135 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); 135 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
136 136
137 writeToHciConfig(); 137 writeToHciConfig();
138 } 138 }
139 139
140 void BlueBase::writeToHciConfig() { 140 void BlueBase::writeToHciConfig() {
141 141
142 HciConfWrapper hciconf ( "/tmp/hcid.conf" ); 142 HciConfWrapper hciconf ( "/tmp/hcid.conf" );
143 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 143 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
144 144
145 145
146 // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 146 // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" );
147 147
148 hciconf.setName( m_deviceName ); 148 hciconf.setName( m_deviceName );
149 hciconf.setEncrypt( m_useEncryption ); 149 hciconf.setEncrypt( m_useEncryption );
150 hciconf.setAuth( m_enableAuthentification ); 150 hciconf.setAuth( m_enableAuthentification );
151 hciconf.setPscan( m_enablePagescan ); 151 hciconf.setPscan( m_enablePagescan );
152 hciconf.setIscan( m_enableInquiryscan ); 152 hciconf.setIscan( m_enableInquiryscan );
153 } 153 }
154 154
155 155
156 /** 156 /**
157 * Read the list of allready known devices 157 * Read the list of allready known devices
158 * 158 *
159 */ 159 */
160 void BlueBase::readSavedDevices() { 160 void BlueBase::readSavedDevices() {
161 161
162 QValueList<RemoteDevice> loadedDevices; 162 QValueList<RemoteDevice> loadedDevices;
163 163
164 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); 164 QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/");
165 // list of .conf files 165 // list of .conf files
166 QStringList devicesFileList = deviceListSave.entryList(); 166 QStringList devicesFileList = deviceListSave.entryList();
167 167
168 // cut .conf of to get the mac and also read the name entry in it. 168 // cut .conf of to get the mac and also read the name entry in it.
169 169
170 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { 170 for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) {
171 171
172 QString name; 172 QString name;
173 QString mac; 173 QString mac;
174 qDebug((*it).latin1() ); 174 qDebug((*it).latin1() );
175 Config conf((*it)); 175 Config conf((*it));
176 conf.setGroup("Info"); 176 conf.setGroup("Info");
177 name = conf.readEntry("name", "Error"); 177 name = conf.readEntry("name", "Error");
178 qDebug("MAC: " + mac); 178 qDebug("MAC: " + mac);
179 qDebug("NAME: " + name); 179 qDebug("NAME: " + name);
180 RemoteDevice currentDevice( mac , name ); 180 RemoteDevice currentDevice( mac , name );
181 loadedDevices.append( currentDevice ); 181 loadedDevices.append( currentDevice );
182 } 182 }
183 addSearchedDevices( loadedDevices ); 183 addSearchedDevices( loadedDevices );
184 } 184 }
185 185
186 /** 186 /**
187 * Write the list of allready known devices 187 * Write the list of allready known devices
188 * 188 *
189 */ 189 */
190 void BlueBase::writeSavedDevices() { 190 void BlueBase::writeSavedDevices() {
191 QListViewItemIterator it( ListView2 ); 191 QListViewItemIterator it( ListView2 );
192 BTListItem* item; 192 BTListItem* item;
193 BTDeviceItem* device; 193 BTDeviceItem* device;
194 194
195 for ( ; it.current(); ++it ) { 195 for ( ; it.current(); ++it ) {
196 item = (BTListItem*)it.current(); 196 item = (BTListItem*)it.current();
197 if(item->typeId() != BTListItem::Device ) 197 if(item->typeId() != BTListItem::Device )
198 continue; 198 continue;
199 device = (BTDeviceItem*)item; 199 device = (BTDeviceItem*)item;
200 // seperate config file for each device, to store more information in future. 200 // seperate config file for each device, to store more information in future.
201 qDebug( "/Settings/bluetooth/" + device->mac() + ".conf"); 201 qDebug( "/Settings/bluetooth/" + device->mac() + ".conf");
202 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File ); 202 Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File );
203 conf.setGroup( "Info" ); 203 conf.setGroup( "Info" );
204 conf.writeEntry( "name", device->name() ); 204 conf.writeEntry( "name", device->name() );
205 } 205 }
206 } 206 }
207 207
208 208
209 /** 209 /**
210 * Set up the gui 210 * Set up the gui
211 */ 211 */
212 void BlueBase::initGui() { 212 void BlueBase::initGui() {
213 StatusLabel->setText( status() ); // maybe move it to getStatus() 213 StatusLabel->setText( status() ); // maybe move it to getStatus()
214 cryptCheckBox->setChecked( m_useEncryption ); 214 cryptCheckBox->setChecked( m_useEncryption );
215 authCheckBox->setChecked( m_enableAuthentification ); 215 authCheckBox->setChecked( m_enableAuthentification );
216 pagescanCheckBox->setChecked( m_enablePagescan ); 216 pagescanCheckBox->setChecked( m_enablePagescan );
217 inquiryscanCheckBox->setChecked( m_enableInquiryscan ); 217 inquiryscanCheckBox->setChecked( m_enableInquiryscan );
218 deviceNameLine->setText( m_deviceName ); 218 deviceNameLine->setText( m_deviceName );
219 passkeyLine->setText( m_defaultPasskey ); 219 passkeyLine->setText( m_defaultPasskey );
220 // set info tab 220 // set info tab
221 setInfo(); 221 setInfo();
222 } 222 }
223 223
224 224
225 /** 225 /**
226 * Get the status informations and returns it 226 * Get the status informations and returns it
227 * @return QString the status informations gathered 227 * @return QString the status informations gathered
228 */ 228 */
229 QString BlueBase::status()const{ 229 QString BlueBase::status()const{
230 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 230 QString infoString = tr( "<b>Device name : </b> Ipaq" );
231 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 231 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
232 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 232 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
233 233
234 return (infoString); 234 return (infoString);
235 } 235 }
236 236
237 237
238 /** 238 /**
239 * Read the current values from the gui and invoke writeConfig() 239 * Read the current values from the gui and invoke writeConfig()
240 */ 240 */
241 void BlueBase::applyConfigChanges() { 241 void BlueBase::applyConfigChanges() {
242 m_deviceName = deviceNameLine->text(); 242 m_deviceName = deviceNameLine->text();
243 m_defaultPasskey = passkeyLine->text(); 243 m_defaultPasskey = passkeyLine->text();
244 m_useEncryption = cryptCheckBox->isChecked(); 244 m_useEncryption = cryptCheckBox->isChecked();
245 m_enableAuthentification = authCheckBox->isChecked(); 245 m_enableAuthentification = authCheckBox->isChecked();
246 m_enablePagescan = pagescanCheckBox->isChecked(); 246 m_enablePagescan = pagescanCheckBox->isChecked();
247 m_enableInquiryscan = inquiryscanCheckBox->isChecked(); 247 m_enableInquiryscan = inquiryscanCheckBox->isChecked();
248 248
249 writeConfig(); 249 writeConfig();
250 250
251 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); 251 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
252 } 252 }
253 253
254 /** 254 /**
255 * Add fresh found devices from scan dialog to the listing 255 * Add fresh found devices from scan dialog to the listing
256 * 256 *
257 */ 257 */
258 void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { 258 void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) {
259 BTDeviceItem * deviceItem; 259 BTDeviceItem * deviceItem;
260 QValueList<RemoteDevice>::ConstIterator it; 260 QValueList<RemoteDevice>::ConstIterator it;
261 261
262 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { 262 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) {
263 263
264 deviceItem = new BTDeviceItem( ListView2 , (*it) ); 264 deviceItem = new BTDeviceItem( ListView2 , (*it) );
265 deviceItem->setExpandable ( true ); 265 deviceItem->setExpandable ( true );
266 266
267 // look if device is avail. atm, async 267 // look if device is avail. atm, async
268 deviceActive( (*it) ); 268 deviceActive( (*it) );
269 269
270 // ggf auch hier? 270 // ggf auch hier?
271 addServicesToDevice( deviceItem ); 271 addServicesToDevice( deviceItem );
272 } 272 }
273 } 273 }
274 274
275 275
276 /** 276 /**
277 * Action that is toggled on entrys on click 277 * Action that is toggled on entrys on click
278 */ 278 */
279void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { 279void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
280} 280}
281 281
282 /** 282 /**
283 * Action that are toggled on hold (mostly QPopups i guess) 283 * Action that are toggled on hold (mostly QPopups i guess)
284 */ 284 */
285void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { 285void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) {
286 286
287 QPopupMenu *menu = new QPopupMenu(); 287 QPopupMenu *menu = new QPopupMenu();
288 int ret=0; 288 int ret=0;
289 289
290 if ( ((BTListItem*)item)->type() == "device") { 290 if ( ((BTListItem*)item)->type() == "device") {
291 291
292 QPopupMenu *groups = new QPopupMenu(); 292 QPopupMenu *groups = new QPopupMenu();
293 293
294 menu->insertItem( tr("rescan sevices:"), 0); 294 menu->insertItem( tr("rescan sevices:"), 0);
295 menu->insertItem( tr("to group"), groups , 1); 295 menu->insertItem( tr("to group"), groups , 1);
296 menu->insertItem( tr("bound device"), 2); 296 menu->insertItem( tr("bound device"), 2);
297 menu->insertItem( tr("delete"), 3); 297 menu->insertItem( tr("delete"), 3);
298 298
299 ret = menu->exec( point , 0); 299 ret = menu->exec( point , 0);
300 300
301 switch(ret) { 301 switch(ret) {
302 case 0: 302 case 0:
303 break; 303 break;
304 case 1: 304 case 1:
305 break; 305 break;
306 case 2: 306 case 2:
307 // make connection 307 // make connection
308 break; 308 break;
309 case 3: 309 case 3:
310 // delete childs too 310 // delete childs too
311 delete item; 311 delete item;
312 break; 312 break;
313 } 313 }
314 delete groups; 314 delete groups;
315 315
316 } else if ( ((BTListItem*)item)->type() == "service") { 316 } else if ( ((BTListItem*)item)->type() == "service") {
317
317 menu->insertItem( tr("Test1:"), 0); 318 menu->insertItem( tr("Test1:"), 0);
318 menu->insertItem( tr("connect"), 1); 319 menu->insertItem( tr("connect"), 1);
319 menu->insertItem( tr("delete"), 2); 320 menu->insertItem( tr("delete"), 2);
320 321
321 ret = menu->exec( point , 0); 322 ret = menu->exec( point , 0);
322 323
323 switch(ret) { 324 switch(ret) {
324 case 0: 325 case 0:
325 break; 326 break;
326 case 1: 327 case 1:
327 break; 328 break;
328 case 2: 329 case 2:
329 // delete childs too 330 // delete childs too
330 delete item; 331 delete item;
331 break; 332 break;
332 } 333 }
333 } 334 }
334 delete menu; 335 delete menu;
335} 336}
336 337
337 /** 338 /**
338 * Search and display avail. services for a device (on expand from device listing) 339 * Search and display avail. services for a device (on expand from device listing)
339 * 340 *
340 */ 341 */
341 void BlueBase::addServicesToDevice( BTDeviceItem * item ) { 342 void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
342 qDebug("addServicesToDevice"); 343 qDebug("addServicesToDevice");
343 // row of mac adress text(3) 344 // row of mac adress text(3)
344 RemoteDevice device = item->remoteDevice(); 345 RemoteDevice device = item->remoteDevice();
345 m_deviceList.insert( item->mac() , item ); 346 m_deviceList.insert( item->mac() , item );
346 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 347 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
347 m_localDevice->searchServices( device ); 348 m_localDevice->searchServices( device );
348 } 349 }
349 350
350 351
351 /** 352 /**
352 * Overloaded. This one it the one that is connected to the foundServices signal 353 * Overloaded. This one it the one that is connected to the foundServices signal
353 * @param device the mac address of the remote device 354 * @param device the mac address of the remote device
354 * @param servicesList the list with the service the device has. 355 * @param servicesList the list with the service the device has.
355 */ 356 */
356 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 357 void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
357 qDebug("fill services list"); 358 qDebug("fill services list");
358 359
359 QMap<QString,BTDeviceItem*>::Iterator it; 360 QMap<QString,BTDeviceItem*>::Iterator it;
360 BTDeviceItem* deviceItem = 0; 361 BTDeviceItem* deviceItem = 0;
361 362
362 // get the right devices which requested the search 363 // get the right devices which requested the search
363 it = m_deviceList.find( device ); 364 it = m_deviceList.find( device );
364 if( it == m_deviceList.end() ) 365 if( it == m_deviceList.end() )
365 return; 366 return;
366 deviceItem = it.data(); 367 deviceItem = it.data();
367 368
368 QValueList<OpieTooth::Services>::Iterator it2; 369 QValueList<OpieTooth::Services>::Iterator it2;
369 BTServiceItem * serviceItem; 370 BTServiceItem * serviceItem;
370 371
371 if (!servicesList.isEmpty() ) { 372 if (!servicesList.isEmpty() ) {
372 // add services 373 // add services
374 QMap<int, QString> list;
375 QMap<int, QString>::Iterator classIt;
373 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 376 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
374 serviceItem = new BTServiceItem( deviceItem , (*it2) ); 377 serviceItem = new BTServiceItem( deviceItem , (*it2) );
375 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); 378 list = (*it2).classIdList();
379 classIt = list.begin();
380 int classId;
381 if ( classIt != list.end() )
382 classId = classIt.key();
383 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
376 } 384 }
377 } else { 385 } else {
378 Services s1; 386 Services s1;
379 s1.setServiceName( tr("no serives found") ); 387 s1.setServiceName( tr("no serives found") );
380 serviceItem = new BTServiceItem( deviceItem, s1 ); 388 serviceItem = new BTServiceItem( deviceItem, s1 );
381 } 389 }
382 // now remove them from the list 390 // now remove them from the list
383 m_deviceList.remove( it ); 391 m_deviceList.remove( it );
384 } 392 }
385 393
386 394
387 /** 395 /**
388 * Add the existing connections (pairs) to the connections tab. 396 * Add the existing connections (pairs) to the connections tab.
389 * This one triggers the search 397 * This one triggers the search
390 */ 398 */
391 void BlueBase::addConnectedDevices() { 399 void BlueBase::addConnectedDevices() {
392 m_localDevice->searchConnections(); 400 m_localDevice->searchConnections();
393 } 401 }
394 402
395 403
396 void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { 404 void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
397 QValueList<OpieTooth::ConnectionState>::Iterator it; 405 QValueList<OpieTooth::ConnectionState>::Iterator it;
398 BTConnectionItem * connectionItem; 406 BTConnectionItem * connectionItem;
399 407
400 if ( !connectionList.isEmpty() ) { 408 if ( !connectionList.isEmpty() ) {
401 409
402 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 410 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
403 connectionItem = new BTConnectionItem( ListView4 , (*it) ); 411 connectionItem = new BTConnectionItem( ListView4 , (*it) );
404 } 412 }
405 } else { 413 } else {
406 ConnectionState con; 414 ConnectionState con;
407 con.setMac( tr("No connections found") ); 415 con.setMac( tr("No connections found") );
408 connectionItem = new BTConnectionItem( ListView4 , con ); 416 connectionItem = new BTConnectionItem( ListView4 , con );
409 } 417 }
410 418
411 // recall connection search after some time 419 // recall connection search after some time
412 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); 420 QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) );
413 } 421 }
414 422
415 /** 423 /**
416 * Find out if a device can currently be reached 424 * Find out if a device can currently be reached
417 */ 425 */
418 void BlueBase::deviceActive( const RemoteDevice &device ) { 426 void BlueBase::deviceActive( const RemoteDevice &device ) {
419 // search by mac, async, gets a signal back 427 // search by mac, async, gets a signal back
420 // We should have a BTDeviceItem there or where does it get added to the map -zecke 428 // We should have a BTDeviceItem there or where does it get added to the map -zecke
421 m_localDevice->isAvailable( device.mac() ); 429 m_localDevice->isAvailable( device.mac() );
422 } 430 }
423 431
424 /** 432 /**
425 * The signal catcher. Set the avail. status on device. 433 * The signal catcher. Set the avail. status on device.
426 * @param device - the mac address 434 * @param device - the mac address
427 * @param connected - if it is avail. or not 435 * @param connected - if it is avail. or not
428 */ 436 */
429 void BlueBase::deviceActive( const QString& device, bool connected ) { 437 void BlueBase::deviceActive( const QString& device, bool connected ) {
430 qDebug("deviceActive slot"); 438 qDebug("deviceActive slot");
431 439
432 QMap<QString,BTDeviceItem*>::Iterator it; 440 QMap<QString,BTDeviceItem*>::Iterator it;
433 441
434 it = m_deviceList.find( device ); 442 it = m_deviceList.find( device );
435 if( it == m_deviceList.end() ) 443 if( it == m_deviceList.end() )
436 return; 444 return;
437 445
438 BTDeviceItem* deviceItem = it.data(); 446 BTDeviceItem* deviceItem = it.data();
439 447
440 448
441 if ( connected ) { 449 if ( connected ) {
442 deviceItem->setPixmap( 1, m_onPix ); 450 deviceItem->setPixmap( 1, m_onPix );
443 } else { 451 } else {
444 deviceItem->setPixmap( 1, m_offPix ); 452 deviceItem->setPixmap( 1, m_offPix );
445 } 453 }
446 m_deviceList.remove( it ); 454 m_deviceList.remove( it );
447 } 455 }
448 456
449 /** 457 /**
450 * Open the "scan for devices" dialog 458 * Open the "scan for devices" dialog
451 */ 459 */
452 void BlueBase::startScan() { 460 void BlueBase::startScan() {
453 ScanDialog *scan = new ScanDialog( this, "ScanDialog", 461 ScanDialog *scan = new ScanDialog( this, "ScanDialog",
454 true, WDestructiveClose ); 462 true, WDestructiveClose );
455 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), 463 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ),
456 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); 464 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) );
457 465
458 scan->showMaximized(); 466 scan->showMaximized();
459 } 467 }
460 468
461 469
462 /** 470 /**
463 * Set the informations about the local device in information Tab 471 * Set the informations about the local device in information Tab
464 */ 472 */
465 void BlueBase::setInfo() { 473 void BlueBase::setInfo() {
466 StatusLabel->setText( status() ); 474 StatusLabel->setText( status() );
467 } 475 }
468 476
469 /** 477 /**
470 * Decontructor 478 * Decontructor
471 */ 479 */
472 BlueBase::~BlueBase() { 480 BlueBase::~BlueBase() {
473 writeSavedDevices(); 481 writeSavedDevices();
474 delete m_iconLoader; 482 delete m_iconLoader;
475 } 483 }
476 484
diff --git a/noncore/net/opietooth/manager/bticonloader.cpp b/noncore/net/opietooth/manager/bticonloader.cpp
index 3fb0edd..f299117 100644
--- a/noncore/net/opietooth/manager/bticonloader.cpp
+++ b/noncore/net/opietooth/manager/bticonloader.cpp
@@ -1,77 +1,78 @@
1 1
2#include "bticonloader.h" 2#include "bticonloader.h"
3 3
4#include <qpixmap.h> 4#include <qpixmap.h>
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6 6
7namespace OpieTooth { 7namespace OpieTooth {
8 8
9 9
10 BTIconLoader::BTIconLoader() { 10 BTIconLoader::BTIconLoader() {
11 11
12 // still need to find out real ids 12 // still need to find out real ids
13 deviceIcons.insert( "100" , "computer_16" ); 13 deviceIcons.insert( 100 , "computer_16" );
14 deviceIcons.insert( "101" , "phone_16" ); 14 deviceIcons.insert( 101 , "phone_16" );
15 deviceIcons.insert( "102" , "brain_16" ); 15 deviceIcons.insert( 102 , "brain_16" );
16 deviceIcons.insert( "103" , "conduit_16" ); 16 deviceIcons.insert( 103 , "conduit_16" );
17 17
18 18
19 serviceIcons.insert( "0x1105" , "obex_16" ); //OBEXObjectPush 19 serviceIcons.insert( 4357 , "obex_16" ); //OBEXObjectPush
20 serviceIcons.insert( "0x1106" , "obex_16" ); //OBEXFileTransfer 20 serviceIcons.insert( 4358 , "obex_16" ); //OBEXFileTransfer
21 serviceIcons.insert( "0x1111" , "print_16" ); //Fax 21 serviceIcons.insert( 4369 , "print_16" ); //Fax
22 serviceIcons.insert( "0x1101" , "serial_16" ); //SerialPort 22 serviceIcons.insert( 4353 , "serial_16" ); //SerialPort
23 serviceIcons.insert( "0x1104" , "sync_16" ); //IrMCSync 23 serviceIcons.insert( 4356 , "sync_16" ); //IrMCSync
24 serviceIcons.insert( "0x1107" , "sync_16" ); //IrMCSyncCommand 24 serviceIcons.insert( 4359 , "sync_16" ); //IrMCSyncCommand
25 serviceIcons.insert( "0x1102" , "network_16" ); //LANAccessUsingPPP 25 serviceIcons.insert( 4354 , "network_16" ); //LANAccessUsingPPP
26 serviceIcons.insert( "0x1103" , "network_16"); //DialupNetworking 26 serviceIcons.insert( 4355 , "network_16"); //DialupNetworking
27 serviceIcons.insert( "0x1108" , "phone_16"); // Headset 27 serviceIcons.insert( 4360 , "phone_16"); // Headset
28 serviceIcons.insert( "0x1112" , "audio_16"); //HeadsetAudioGateway 28 serviceIcons.insert( 4370 , "audio_16"); //HeadsetAudioGateway
29 serviceIcons.insert( "0x1109" , "phone_16"); // CordlessTelephony 29 serviceIcons.insert( 4361 , "phone_16"); // CordlessTelephony
30 serviceIcons.insert( "0x110A" , "audio_16"); // AudioSource 30 serviceIcons.insert( 4362 , "audio_16"); // AudioSource
31 serviceIcons.insert( "0x110B" , "audio_16"); // AudioSink 31 serviceIcons.insert( 4363 , "audio_16"); // AudioSink
32 serviceIcons.insert( "0x1126" , "print_16" ); //HCR_Print 32 serviceIcons.insert( 4390 , "print_16" ); //HCR_Print
33 serviceIcons.insert( "0x1128" , "phone_16" ); //Common_ISDN_Access 33 serviceIcons.insert( 4392 , "phone_16" ); //Common_ISDN_Access
34 34
35 serviceIcons.insert( "0x1201" , "network_16" ); //GenericNetworking 35 serviceIcons.insert( 4609 , "network_16" ); //GenericNetworking
36 serviceIcons.insert( "0x1202" , "folder_16" ); //GenericFileTransfer 36 serviceIcons.insert( 4610 , "folder_16" ); //GenericFileTransfer
37 serviceIcons.insert( "0x1128" , "audio_16" ); //GenericAudio 37 serviceIcons.insert( 4392 , "audio_16" ); //GenericAudio
38 serviceIcons.insert( "0x1128" , "phone_16" ); //GenericTelephony 38 // serviceIcons.insert( 4392 , "phone_16" ); //GenericTelephony
39 // the above is duplicated? -zecke
39 40
40 //serviceIcons.insert( "106" , "link_16" ); 41 //serviceIcons.insert( "106" , "link_16" );
41 //serviceIcons.insert( "107" , "misc_16" ); 42 //serviceIcons.insert( "107" , "misc_16" );
42 } 43 }
43 44
44 BTIconLoader::~BTIconLoader() { 45 BTIconLoader::~BTIconLoader() {
45 } 46 }
46 47
47 QPixmap BTIconLoader::deviceIcon( const QString &deviceClass ) { 48 QPixmap BTIconLoader::deviceIcon( int deviceClass ) {
48 49
49 QString iconName; 50 QString iconName;
50 51
51 QMap<QString, QString>::Iterator it; 52 QMap<int, QString>::Iterator it;
52 53
53 it = deviceIcons.find( deviceClass ); 54 it = deviceIcons.find( deviceClass );
54 iconName = it.data(); 55 iconName = it.data();
55 56
56 if ( iconName.isEmpty() ) { 57 if ( iconName.isEmpty() ) {
57 iconName = "unknown_16"; 58 iconName = "unknown_16";
58 } 59 }
59 return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); 60 return( Resource::loadPixmap( "opietooth/icons/" + iconName ) );
60 } 61 }
61 62
62 QPixmap BTIconLoader::serviceIcon( const QString &serviceClass ) { 63 QPixmap BTIconLoader::serviceIcon( int serviceClass ) {
63 64
64 QString iconName; 65 QString iconName;
65 66
66 QMap<QString, QString>::Iterator it; 67 QMap<int, QString>::Iterator it;
67 68
68 it = deviceIcons.find( serviceClass ); 69 it = deviceIcons.find( serviceClass );
69 iconName = it.data(); 70 iconName = it.data();
70 71
71 if ( iconName.isEmpty() ) { 72 if ( iconName.isEmpty() ) {
72 iconName = "unknown_16"; 73 iconName = "unknown_16";
73 } 74 }
74 return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); 75 return( Resource::loadPixmap( "opietooth/icons/" + iconName ) );
75 } 76 }
76 77
77} 78}
diff --git a/noncore/net/opietooth/manager/bticonloader.h b/noncore/net/opietooth/manager/bticonloader.h
index 1b48009..9951c4c 100644
--- a/noncore/net/opietooth/manager/bticonloader.h
+++ b/noncore/net/opietooth/manager/bticonloader.h
@@ -1,37 +1,37 @@
1#ifndef BTICONLOADER_H 1#ifndef BTICONLOADER_H
2#define BTICONLOADER_H 2#define BTICONLOADER_H
3 3
4#include <qpixmap.h> 4#include <qpixmap.h>
5#include <qmap.h> 5#include <qmap.h>
6 6
7namespace OpieTooth { 7namespace OpieTooth {
8 8
9 class BTIconLoader { 9 class BTIconLoader {
10 10
11 public: 11 public:
12 12
13 BTIconLoader(); 13 BTIconLoader();
14 ~BTIconLoader(); 14 ~BTIconLoader();
15 15
16 /** 16 /**
17 * Returns an icon depending on device class 17 * Returns an icon depending on device class
18 * @param deviceClass the device class id 18 * @param deviceClass the device class id
19 * @return the pixmap 19 * @return the pixmap
20 */ 20 */
21 QPixmap deviceIcon( const QString &deviceClass ); 21 QPixmap deviceIcon( int );
22 22
23 /** 23 /**
24 * Returns an icon depending on service id 24 * Returns an icon depending on service id
25 * @param serviceClass the service id 25 * @param serviceClass the service id
26 * @return the pixmap 26 * @return the pixmap
27 */ 27 */
28 QPixmap serviceIcon( const QString &serviceClass ); 28 QPixmap serviceIcon( int );
29 29
30 private: 30 private:
31 // first ist id, second is icon name 31 // first ist id, second is icon name
32 QMap<QString,QString> deviceIcons; 32 QMap<int,QString> deviceIcons;
33 QMap<QString,QString> serviceIcons; 33 QMap<int,QString> serviceIcons;
34 }; 34 };
35} 35}
36 36
37#endif 37#endif
diff --git a/noncore/net/opietooth/manager/btserviceitem.cpp b/noncore/net/opietooth/manager/btserviceitem.cpp
index 352e793..7db93c9 100644
--- a/noncore/net/opietooth/manager/btserviceitem.cpp
+++ b/noncore/net/opietooth/manager/btserviceitem.cpp
@@ -1,23 +1,26 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include "btserviceitem.h" 3#include "btserviceitem.h"
4 4
5using namespace OpieTooth; 5using namespace OpieTooth;
6 6
7BTServiceItem::BTServiceItem( QListViewItem* item, const Services& serv ) 7BTServiceItem::BTServiceItem( QListViewItem* item, const Services& serv )
8 : BTListItem( item ) { 8 : BTListItem( item ) {
9 m_service = serv; 9 m_service = serv;
10 setText(0, QObject::tr(serv.serviceName() ) ); 10 setText(0, QObject::tr(serv.serviceName() ) );
11} 11}
12BTServiceItem::~BTServiceItem() { 12BTServiceItem::~BTServiceItem() {
13 13
14} 14}
15QString BTServiceItem::type() const { 15QString BTServiceItem::type() const {
16 return QString::fromLatin1("service"); 16 return QString::fromLatin1("service");
17} 17}
18int BTServiceItem::typeId() const { 18int BTServiceItem::typeId() const {
19 return Service; 19 return Service;
20} 20}
21Services BTServiceItem::services() const { 21Services BTServiceItem::services() const {
22 return m_service; 22 return m_service;
23} 23}
24int BTServiceItem::serviceId() const {
25 return m_service.recHandle();
26};
diff --git a/noncore/net/opietooth/manager/btserviceitem.h b/noncore/net/opietooth/manager/btserviceitem.h
index 6dbd8f1..625a5f7 100644
--- a/noncore/net/opietooth/manager/btserviceitem.h
+++ b/noncore/net/opietooth/manager/btserviceitem.h
@@ -1,26 +1,27 @@
1 1
2 2
3#ifndef OPIE_TOOTH_BT_SERVICE_ITEM 3#ifndef OPIE_TOOTH_BT_SERVICE_ITEM
4#define OPIE_TOOTH_BT_SERVICE_ITEM 4#define OPIE_TOOTH_BT_SERVICE_ITEM
5 5
6#include <services.h> 6#include <services.h>
7 7
8#include "btlistitem.h" 8#include "btlistitem.h"
9 9
10namespace OpieTooth { 10namespace OpieTooth {
11 11
12 class BTServiceItem : public BTListItem { 12 class BTServiceItem : public BTListItem {
13 public: 13 public:
14 BTServiceItem( QListViewItem* item, const Services& ); 14 BTServiceItem( QListViewItem* item, const Services& );
15 ~BTServiceItem(); 15 ~BTServiceItem();
16 QString type() const; 16 QString type() const;
17 int typeId() const; 17 int typeId() const;
18 Services services() const; 18 Services services() const;
19 int serviceId() const;
19 private: 20 private:
20 Services m_service; 21 Services m_service;
21 22
22 }; 23 };
23}; 24};
24 25
25 26
26#endif 27#endif
diff --git a/noncore/net/opietooth/manager/stdpopups.cpp b/noncore/net/opietooth/manager/stdpopups.cpp
index 43a0f62..f462368 100644
--- a/noncore/net/opietooth/manager/stdpopups.cpp
+++ b/noncore/net/opietooth/manager/stdpopups.cpp
@@ -1,10 +1,13 @@
1 1
2//#include "rfccompopup.h"
3
2#include "stdpopups.h" 4#include "stdpopups.h"
3 5
4 6
5QPopupMenu* newRfcComPopup( const OpieTooth::Services&, QListViewItem* ) { 7QPopupMenu* newRfcComPopup( const OpieTooth::Services& servive, QListViewItem* item ) {
8 // return OpieTooth::RfcComPopup( servive, item );
6 return 0l; 9 return 0l;
7} 10}
8QPopupMenu* newObexPushPopup( const OpieTooth::Services&, QListViewItem* ) { 11QPopupMenu* newObexPushPopup( const OpieTooth::Services&, QListViewItem* ) {
9 return 0l; 12 return 0l;
10} 13}