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