author | zecke <zecke> | 2002-07-08 18:46:40 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-08 18:46:40 (UTC) |
commit | 7d82c654e6a1df83f70b2d81aa05a1175799b66b (patch) (unidiff) | |
tree | 079e87ac4dcd96c304a4e8eb7f928194fffe63f1 | |
parent | 35d0ca5cc59b82af7b7ddb343ec092c3171b11ef (diff) | |
download | opie-7d82c654e6a1df83f70b2d81aa05a1175799b66b.zip opie-7d82c654e6a1df83f70b2d81aa05a1175799b66b.tar.gz opie-7d82c654e6a1df83f70b2d81aa05a1175799b66b.tar.bz2 |
API clean ups
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 7 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btlistitem.cpp | 22 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btlistitem.h | 16 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/main.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 2 |
8 files changed, 31 insertions, 38 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index ff6981b..8ddc161 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -179,279 +179,280 @@ using namespace OpieTooth; | |||
179 | } | 179 | } |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * Write the list of allready known devices | 182 | * Write the list of allready known devices |
183 | * | 183 | * |
184 | */ | 184 | */ |
185 | void BlueBase::writeSavedDevices() { | 185 | void BlueBase::writeSavedDevices() { |
186 | QListViewItemIterator it( ListView2 ); | 186 | QListViewItemIterator it( ListView2 ); |
187 | 187 | ||
188 | for ( ; it.current(); ++it ) { | 188 | for ( ; it.current(); ++it ) { |
189 | // seperate config file for each device, to store more information in future. | 189 | // seperate config file for each device, to store more information in future. |
190 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); | 190 | qDebug( "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf"); |
191 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); | 191 | Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + (((BTListItem*)it.current())->mac()) + ".conf", Config::File ); |
192 | conf.setGroup( "Info" ); | 192 | conf.setGroup( "Info" ); |
193 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); | 193 | conf.writeEntry( "name", ((BTListItem*)it.current())->name() ); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Set up the gui | 199 | * Set up the gui |
200 | */ | 200 | */ |
201 | void BlueBase::initGui() { | 201 | void BlueBase::initGui() { |
202 | StatusLabel->setText( status() ); // maybe move it to getStatus() | 202 | StatusLabel->setText( status() ); // maybe move it to getStatus() |
203 | cryptCheckBox->setChecked( m_useEncryption ); | 203 | cryptCheckBox->setChecked( m_useEncryption ); |
204 | authCheckBox->setChecked( m_enableAuthentification ); | 204 | authCheckBox->setChecked( m_enableAuthentification ); |
205 | pagescanCheckBox->setChecked( m_enablePagescan ); | 205 | pagescanCheckBox->setChecked( m_enablePagescan ); |
206 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); | 206 | inquiryscanCheckBox->setChecked( m_enableInquiryscan ); |
207 | deviceNameLine->setText( m_deviceName ); | 207 | deviceNameLine->setText( m_deviceName ); |
208 | passkeyLine->setText( m_defaultPasskey ); | 208 | passkeyLine->setText( m_defaultPasskey ); |
209 | // set info tab | 209 | // set info tab |
210 | setInfo(); | 210 | setInfo(); |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | /** | 214 | /** |
215 | * Get the status informations and returns it | 215 | * Get the status informations and returns it |
216 | * @return QString the status informations gathered | 216 | * @return QString the status informations gathered |
217 | */ | 217 | */ |
218 | QString BlueBase::status()const{ | 218 | QString BlueBase::status()const{ |
219 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); | 219 | QString infoString = tr( "<b>Device name : </b> Ipaq" ); |
220 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); | 220 | infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); |
221 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); | 221 | infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); |
222 | 222 | ||
223 | return (infoString); | 223 | return (infoString); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | /** | 227 | /** |
228 | * Read the current values from the gui and invoke writeConfig() | 228 | * Read the current values from the gui and invoke writeConfig() |
229 | */ | 229 | */ |
230 | void BlueBase::applyConfigChanges() { | 230 | void BlueBase::applyConfigChanges() { |
231 | m_deviceName = deviceNameLine->text(); | 231 | m_deviceName = deviceNameLine->text(); |
232 | m_defaultPasskey = passkeyLine->text(); | 232 | m_defaultPasskey = passkeyLine->text(); |
233 | m_useEncryption = cryptCheckBox->isChecked(); | 233 | m_useEncryption = cryptCheckBox->isChecked(); |
234 | m_enableAuthentification = authCheckBox->isChecked(); | 234 | m_enableAuthentification = authCheckBox->isChecked(); |
235 | m_enablePagescan = pagescanCheckBox->isChecked(); | 235 | m_enablePagescan = pagescanCheckBox->isChecked(); |
236 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); | 236 | m_enableInquiryscan = inquiryscanCheckBox->isChecked(); |
237 | 237 | ||
238 | writeConfig(); | 238 | writeConfig(); |
239 | 239 | ||
240 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); | 240 | QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); |
241 | } | 241 | } |
242 | 242 | ||
243 | /** | 243 | /** |
244 | * Add fresh found devices from scan dialog to the listing | 244 | * Add fresh found devices from scan dialog to the listing |
245 | * | 245 | * |
246 | */ | 246 | */ |
247 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { | 247 | void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { |
248 | BTListItem * deviceItem; | 248 | BTListItem * deviceItem; |
249 | QValueList<RemoteDevice>::ConstIterator it; | 249 | QValueList<RemoteDevice>::ConstIterator it; |
250 | 250 | ||
251 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { | 251 | for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { |
252 | deviceItem = new BTListItem( ListView2 , (*it).name(), (*it).mac(), "device" ); | 252 | deviceItem = new BTListItem( ListView2 , (*it).name(), (*it).mac(), "device" ); |
253 | deviceItem->setExpandable ( true ); | 253 | deviceItem->setExpandable ( true ); |
254 | 254 | ||
255 | // look if device is avail. atm, async | 255 | // look if device is avail. atm, async |
256 | deviceActive( (*it) ); | 256 | deviceActive( (*it) ); |
257 | 257 | ||
258 | // ggf auch hier? | 258 | // ggf auch hier? |
259 | addServicesToDevice( deviceItem ); | 259 | addServicesToDevice( deviceItem ); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | /** | 264 | /** |
265 | * Action that is toggled on entrys on click | 265 | * Action that is toggled on entrys on click |
266 | */ | 266 | */ |
267 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { | 267 | void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { |
268 | } | 268 | } |
269 | 269 | ||
270 | /** | 270 | /** |
271 | * Action that are toggled on hold (mostly QPopups i guess) | 271 | * Action that are toggled on hold (mostly QPopups i guess) |
272 | */ | 272 | */ |
273 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { | 273 | void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { |
274 | 274 | ||
275 | QPopupMenu *menu = new QPopupMenu(); | 275 | QPopupMenu *menu = new QPopupMenu(); |
276 | int ret=0; | 276 | int ret=0; |
277 | 277 | ||
278 | if ( ((BTListItem*)item)->type() == "device") { | 278 | if ( ((BTListItem*)item)->type() == "device") { |
279 | 279 | ||
280 | QPopupMenu *groups = new QPopupMenu(); | 280 | QPopupMenu *groups = new QPopupMenu(); |
281 | 281 | ||
282 | menu->insertItem( tr("rescan sevices:"), 0); | 282 | menu->insertItem( tr("rescan sevices:"), 0); |
283 | menu->insertItem( tr("to group"), groups , 1); | 283 | menu->insertItem( tr("to group"), groups , 1); |
284 | menu->insertItem( tr("bound device"), 2); | 284 | menu->insertItem( tr("bound device"), 2); |
285 | menu->insertItem( tr("delete"), 3); | 285 | menu->insertItem( tr("delete"), 3); |
286 | 286 | ||
287 | ret = menu->exec( point , 0); | 287 | ret = menu->exec( point , 0); |
288 | 288 | ||
289 | switch(ret) { | 289 | switch(ret) { |
290 | case 0: | 290 | case 0: |
291 | break; | 291 | break; |
292 | case 1: | 292 | case 1: |
293 | break; | 293 | break; |
294 | case 2: | 294 | case 2: |
295 | // make connection | 295 | // make connection |
296 | break; | 296 | break; |
297 | case 3: | 297 | case 3: |
298 | // delete childs too | 298 | // delete childs too |
299 | delete item; | 299 | delete item; |
300 | break; | 300 | break; |
301 | } | 301 | } |
302 | delete groups; | 302 | delete groups; |
303 | 303 | ||
304 | } else if ( ((BTListItem*)item)->type() == "service") { | 304 | } else if ( ((BTListItem*)item)->type() == "service") { |
305 | menu->insertItem( tr("Test1:"), 0); | 305 | menu->insertItem( tr("Test1:"), 0); |
306 | menu->insertItem( tr("connect"), 1); | 306 | menu->insertItem( tr("connect"), 1); |
307 | menu->insertItem( tr("delete"), 2); | 307 | menu->insertItem( tr("delete"), 2); |
308 | 308 | ||
309 | ret = menu->exec( point , 0); | 309 | ret = menu->exec( point , 0); |
310 | 310 | ||
311 | switch(ret) { | 311 | switch(ret) { |
312 | case 0: | 312 | case 0: |
313 | break; | 313 | break; |
314 | case 1: | 314 | case 1: |
315 | break; | 315 | break; |
316 | case 2: | 316 | case 2: |
317 | // delete childs too | 317 | // delete childs too |
318 | delete item; | 318 | delete item; |
319 | break; | 319 | break; |
320 | } | 320 | } |
321 | } | 321 | } |
322 | delete menu; | 322 | delete menu; |
323 | } | 323 | } |
324 | 324 | ||
325 | /** | 325 | /** |
326 | * Search and display avail. services for a device (on expand from device listing) | 326 | * Search and display avail. services for a device (on expand from device listing) |
327 | * | 327 | * |
328 | */ | 328 | */ |
329 | void BlueBase::addServicesToDevice( BTListItem * item ) { | 329 | void BlueBase::addServicesToDevice( BTListItem * item ) { |
330 | qDebug("addServicesToDevice"); | 330 | qDebug("addServicesToDevice"); |
331 | // row of mac adress text(3) | 331 | // row of mac adress text(3) |
332 | RemoteDevice device( item->mac(), item->name() ); | 332 | RemoteDevice device( item->mac(), item->name() ); |
333 | m_deviceList.insert( item->mac() , item ); | 333 | m_deviceList.insert( item->mac() , item ); |
334 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back | 334 | // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back |
335 | m_localDevice->searchServices( device ); | 335 | m_localDevice->searchServices( device ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | /** | 339 | /** |
340 | * Overloaded. This one it the one that is connected to the foundServices signal | 340 | * Overloaded. This one it the one that is connected to the foundServices signal |
341 | * @param device the mac address of the remote device | 341 | * @param device the mac address of the remote device |
342 | * @param servicesList the list with the service the device has. | 342 | * @param servicesList the list with the service the device has. |
343 | */ | 343 | */ |
344 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { | 344 | void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { |
345 | qDebug("fill services list"); | 345 | qDebug("fill services list"); |
346 | 346 | ||
347 | QMap<QString,BTListItem*>::Iterator it; | 347 | QMap<QString,BTListItem*>::Iterator it; |
348 | BTListItem* deviceItem = 0; | 348 | BTListItem* deviceItem = 0; |
349 | 349 | ||
350 | // get the right devices which requested the search | 350 | // get the right devices which requested the search |
351 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { | 351 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { |
352 | if ( it.key() == device ) { | 352 | if ( it.key() == device ) { |
353 | deviceItem = it.data(); | 353 | deviceItem = it.data(); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | QValueList<OpieTooth::Services>::Iterator it2; | 357 | QValueList<OpieTooth::Services>::Iterator it2; |
358 | BTListItem * serviceItem; | 358 | BTListItem * serviceItem; |
359 | 359 | ||
360 | if (!servicesList.isEmpty() ) { | 360 | if (!servicesList.isEmpty() ) { |
361 | // add services | 361 | // add services |
362 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { | 362 | for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { |
363 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); | 363 | serviceItem = new BTListItem( deviceItem , (*it2).serviceName() , "" , "service" ); |
364 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); | 364 | serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); |
365 | } | 365 | } |
366 | } else { | 366 | } else { |
367 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); | 367 | serviceItem = new BTListItem( deviceItem , tr("no services found"), "" , "service" ); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | /** | 372 | /** |
373 | * Add the existing connections (pairs) to the connections tab. | 373 | * Add the existing connections (pairs) to the connections tab. |
374 | * This one triggers the search | 374 | * This one triggers the search |
375 | */ | 375 | */ |
376 | void BlueBase::addConnectedDevices() { | 376 | void BlueBase::addConnectedDevices() { |
377 | m_localDevice->searchConnections(); | 377 | m_localDevice->searchConnections(); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { | 381 | void BlueBase::addConnectedDevices( Connection::ValueList connectionList ) { |
382 | QValueList<OpieTooth::Connection>::Iterator it; | 382 | QValueList<OpieTooth::Connection>::Iterator it; |
383 | BTListItem * connectionItem; | 383 | BTListItem * connectionItem; |
384 | 384 | ||
385 | if ( !connectionList.isEmpty() ) { | 385 | if ( !connectionList.isEmpty() ) { |
386 | 386 | ||
387 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { | 387 | for (it = connectionList.begin(); it != connectionList.end(); ++it) { |
388 | connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" ); | 388 | connectionItem = new BTListItem( ListView4 , (*it).mac() , (*it).mac() , "connection" ); |
389 | } | 389 | } |
390 | } else { | 390 | } else { |
391 | connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" ); | 391 | connectionItem = new BTListItem( ListView4 , tr("No connections found"), "", "connection" ); |
392 | } | 392 | } |
393 | 393 | ||
394 | // recall connection search after some time | 394 | // recall connection search after some time |
395 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); | 395 | QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); |
396 | } | 396 | } |
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Find out if a device can currently be reached | 399 | * Find out if a device can currently be reached |
400 | */ | 400 | */ |
401 | void BlueBase::deviceActive( const RemoteDevice &device ) { | 401 | void BlueBase::deviceActive( const RemoteDevice &device ) { |
402 | // search by mac, async, gets a signal back | 402 | // search by mac, async, gets a signal back |
403 | m_localDevice->isAvailable( device.mac() ); | 403 | m_localDevice->isAvailable( device.mac() ); |
404 | } | 404 | } |
405 | 405 | ||
406 | /** | 406 | /** |
407 | * The signal catcher. Set the avail. status on device. | 407 | * The signal catcher. Set the avail. status on device. |
408 | * @param device - the mac address | 408 | * @param device - the mac address |
409 | * @param connected - if it is avail. or not | 409 | * @param connected - if it is avail. or not |
410 | */ | 410 | */ |
411 | void BlueBase::deviceActive( const QString& device, bool connected ) { | 411 | void BlueBase::deviceActive( const QString& device, bool connected ) { |
412 | qDebug("deviceActive slot"); | 412 | qDebug("deviceActive slot"); |
413 | 413 | ||
414 | QMap<QString,BTListItem*>::Iterator it; | 414 | QMap<QString,BTListItem*>::Iterator it; |
415 | BTListItem* deviceItem = 0; | 415 | BTListItem* deviceItem = 0; |
416 | 416 | ||
417 | // get the right devices which requested the search | 417 | // get the right devices which requested the search |
418 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { | 418 | for( it = m_deviceList.begin(); it != m_deviceList.end(); ++it ) { |
419 | if ( it.key() == device ) { | 419 | if ( it.key() == device ) { |
420 | deviceItem = it.data(); | 420 | deviceItem = it.data(); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | if ( connected ) { | 424 | if ( connected ) { |
425 | deviceItem->setPixmap( 1, m_onPix ); | 425 | deviceItem->setPixmap( 1, m_onPix ); |
426 | } else { | 426 | } else { |
427 | deviceItem->setPixmap( 1, m_offPix ); | 427 | deviceItem->setPixmap( 1, m_offPix ); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | /** | 431 | /** |
432 | * Open the "scan for devices" dialog | 432 | * Open the "scan for devices" dialog |
433 | */ | 433 | */ |
434 | void BlueBase::startScan() { | 434 | void BlueBase::startScan() { |
435 | ScanDialog *scan = new ScanDialog( this, "", true); | 435 | ScanDialog *scan = new ScanDialog( this, "ScanDialog", |
436 | QObject::connect( scan, SIGNAL( selectedDevices( QList<RemoteDevice>& ) ), | 436 | true, WDestructiveClose ); |
437 | this, SLOT( addSearchedDevices( QList<RemoteDevice>& ) ) ); | 437 | QObject::connect( scan, SIGNAL( selectedDevices( QValueList<RemoteDevice>& ) ), |
438 | this, SLOT( addSearchedDevices( QValueList<RemoteDevice>& ) ) ); | ||
438 | 439 | ||
439 | scan->showMaximized(); | 440 | scan->showMaximized(); |
440 | } | 441 | } |
441 | 442 | ||
442 | 443 | ||
443 | /** | 444 | /** |
444 | * Set the informations about the local device in information Tab | 445 | * Set the informations about the local device in information Tab |
445 | */ | 446 | */ |
446 | void BlueBase::setInfo() { | 447 | void BlueBase::setInfo() { |
447 | StatusLabel->setText( status() ); | 448 | StatusLabel->setText( status() ); |
448 | } | 449 | } |
449 | 450 | ||
450 | /** | 451 | /** |
451 | * Decontructor | 452 | * Decontructor |
452 | */ | 453 | */ |
453 | BlueBase::~BlueBase() { | 454 | BlueBase::~BlueBase() { |
454 | writeSavedDevices(); | 455 | writeSavedDevices(); |
455 | delete m_iconLoader; | 456 | delete m_iconLoader; |
456 | } | 457 | } |
457 | 458 | ||
diff --git a/noncore/net/opietooth/manager/btlistitem.cpp b/noncore/net/opietooth/manager/btlistitem.cpp index ce5b141..82e7c00 100644 --- a/noncore/net/opietooth/manager/btlistitem.cpp +++ b/noncore/net/opietooth/manager/btlistitem.cpp | |||
@@ -1,67 +1,61 @@ | |||
1 | 1 | ||
2 | #include "btlistitem.h" | 2 | #include "btlistitem.h" |
3 | 3 | ||
4 | namespace OpieTooth { | 4 | namespace OpieTooth { |
5 | 5 | ||
6 | 6 | ||
7 | BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) { | 7 | BTListItem::BTListItem( QListView * parent ) : QListViewItem( parent ) { |
8 | m_name = ""; | ||
9 | m_mac =""; | ||
10 | m_type =""; | ||
11 | } | 8 | } |
12 | 9 | ||
13 | BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) { | 10 | BTListItem::BTListItem( QListViewItem * parent ) : QListViewItem( parent ) { |
14 | m_name = ""; | ||
15 | m_mac =""; | ||
16 | m_type =""; | ||
17 | } | 11 | } |
18 | 12 | ||
19 | 13 | ||
20 | // name, and then mac and then servicetype | 14 | // name, and then mac and then servicetype |
21 | BTListItem::BTListItem( QListView * parent, QString name , QString mac, QString type ) | 15 | BTListItem::BTListItem( QListView * parent, const QString &name , const QString& mac, const QString& type ) |
22 | : QListViewItem( parent, name ){ | 16 | : QListViewItem( parent, name ){ |
23 | 17 | ||
24 | m_name = name; | 18 | m_name = name; |
25 | m_mac = mac; | 19 | m_mac = mac; |
26 | m_type = type; | 20 | m_type = type; |
27 | 21 | ||
28 | } | 22 | } |
29 | 23 | ||
30 | BTListItem::BTListItem( QListViewItem * parent , QString name, QString mac, QString type ) | 24 | BTListItem::BTListItem( QListViewItem * parent , const QString& name, const QString& mac, const QString& type ) |
31 | : QListViewItem( parent, name ){ | 25 | : QListViewItem( parent, name ){ |
32 | 26 | ||
33 | m_name = name; | 27 | m_name = name; |
34 | m_mac = mac; | 28 | m_mac = mac; |
35 | m_type = type; | 29 | m_type = type; |
36 | } | 30 | } |
37 | 31 | ||
38 | 32 | ||
39 | void BTListItem::setMac( QString mac ) { | 33 | void BTListItem::setMac( const QString& mac ) { |
40 | m_mac = mac; | 34 | m_mac = mac; |
41 | } | 35 | } |
42 | 36 | ||
43 | QString BTListItem::mac() { | 37 | QString BTListItem::mac() const { |
44 | return m_mac; | 38 | return m_mac; |
45 | } | 39 | } |
46 | 40 | ||
47 | void BTListItem::setName( QString name ) { | 41 | void BTListItem::setName( const QString& name ) { |
48 | m_name = name; | 42 | m_name = name; |
49 | } | 43 | } |
50 | 44 | ||
51 | QString BTListItem::name() { | 45 | QString BTListItem::name() const { |
52 | return m_name; | 46 | return m_name; |
53 | } | 47 | } |
54 | 48 | ||
55 | void BTListItem::setType( QString type ) { | 49 | void BTListItem::setType( const QString& type ) { |
56 | m_type = type; | 50 | m_type = type; |
57 | } | 51 | } |
58 | 52 | ||
59 | QString BTListItem::type() { | 53 | QString BTListItem::type() const { |
60 | return m_type; | 54 | return m_type; |
61 | } | 55 | } |
62 | 56 | ||
63 | 57 | ||
64 | BTListItem::~BTListItem() { | 58 | BTListItem::~BTListItem() { |
65 | } | 59 | } |
66 | 60 | ||
67 | }; | 61 | }; |
diff --git a/noncore/net/opietooth/manager/btlistitem.h b/noncore/net/opietooth/manager/btlistitem.h index 8963caa..d7ce03b 100644 --- a/noncore/net/opietooth/manager/btlistitem.h +++ b/noncore/net/opietooth/manager/btlistitem.h | |||
@@ -1,33 +1,33 @@ | |||
1 | #ifndef BTLISTITEM_H | 1 | #ifndef BTLISTITEM_H |
2 | #define BTLISTITEM_H | 2 | #define BTLISTITEM_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | 5 | ||
6 | namespace OpieTooth { | 6 | namespace OpieTooth { |
7 | 7 | ||
8 | class BTListItem : public QListViewItem { | 8 | class BTListItem : public QListViewItem { |
9 | 9 | ||
10 | public: | 10 | public: |
11 | BTListItem( QListView * parent ); | 11 | BTListItem( QListView * parent ); |
12 | BTListItem( QListViewItem * parent ); | 12 | BTListItem( QListViewItem * parent ); |
13 | 13 | ||
14 | // name, and then mac and then servicetype | 14 | // name, and then mac and then servicetype |
15 | BTListItem( QListView * , QString, QString, QString ); | 15 | BTListItem( QListView * , const QString&, const QString&, const QString& ); |
16 | BTListItem( QListViewItem * parent , QString, QString , QString ); | 16 | BTListItem( QListViewItem * parent , const QString&, const QString& , const QString& ); |
17 | ~BTListItem(); | 17 | ~BTListItem(); |
18 | 18 | ||
19 | void setMac( QString ); | 19 | void setMac( const QString& ); |
20 | QString mac(); | 20 | QString mac()const; |
21 | void setName( QString ); | 21 | void setName( const QString& ); |
22 | QString name(); | 22 | QString name()const; |
23 | void setType( QString ); | 23 | void setType( const QString& ); |
24 | QString type(); | 24 | QString type()const; |
25 | private: | 25 | private: |
26 | QString m_name; | 26 | QString m_name; |
27 | QString m_mac; | 27 | QString m_mac; |
28 | QString m_type; | 28 | QString m_type; |
29 | 29 | ||
30 | }; | 30 | }; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | #endif | 33 | #endif |
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 0b90e87..5f74fee 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp | |||
@@ -1,112 +1,112 @@ | |||
1 | #include "hciconfwrapper.h" | 1 | #include "hciconfwrapper.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | #include <qregexp.h> | 6 | #include <qregexp.h> |
7 | 7 | ||
8 | namespace OpieTooth { | 8 | namespace OpieTooth { |
9 | 9 | ||
10 | 10 | ||
11 | HciConfWrapper::HciConfWrapper( const QString &fileName) { | 11 | HciConfWrapper::HciConfWrapper( const QString &fileName) { |
12 | m_fileName = fileName; | 12 | m_fileName = fileName; |
13 | } | 13 | } |
14 | 14 | ||
15 | HciConfWrapper::~HciConfWrapper() { | 15 | HciConfWrapper::~HciConfWrapper() { |
16 | } | 16 | } |
17 | 17 | ||
18 | 18 | ||
19 | void HciConfWrapper::setPinHelper( QString app ) { | 19 | void HciConfWrapper::setPinHelper( const QString& app ) { |
20 | setValue( "pin_helper" , app ); | 20 | setValue( "pin_helper" , app ); |
21 | } | 21 | } |
22 | 22 | ||
23 | void HciConfWrapper::setName( QString name ) { | 23 | void HciConfWrapper::setName( const QString &name ) { |
24 | qDebug ("NAME : " + name); | 24 | qDebug ("NAME : " + name); |
25 | setValue( "name" , "\"" + name + "\"" ); | 25 | setValue( "name" , "\"" + name + "\"" ); |
26 | } | 26 | } |
27 | 27 | ||
28 | void HciConfWrapper::setIscan( bool enable) { | 28 | void HciConfWrapper::setIscan( bool enable) { |
29 | 29 | ||
30 | if ( enable ) { | 30 | if ( enable ) { |
31 | setValue( "iscan" , "enable" ); | 31 | setValue( "iscan" , "enable" ); |
32 | } else { | 32 | } else { |
33 | setValue( "iscan" , "disable" ); | 33 | setValue( "iscan" , "disable" ); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | void HciConfWrapper::setPscan( bool enable) { | 37 | void HciConfWrapper::setPscan( bool enable) { |
38 | 38 | ||
39 | if ( enable ) { | 39 | if ( enable ) { |
40 | setValue( "pscan" , "enable" ); | 40 | setValue( "pscan" , "enable" ); |
41 | } else { | 41 | } else { |
42 | setValue( "pscan" , "disable" ); | 42 | setValue( "pscan" , "disable" ); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | void HciConfWrapper::setAuth( bool enable) { | 47 | void HciConfWrapper::setAuth( bool enable) { |
48 | 48 | ||
49 | if ( enable ) { | 49 | if ( enable ) { |
50 | setValue( "auth" , "enable" ); | 50 | setValue( "auth" , "enable" ); |
51 | } else { | 51 | } else { |
52 | setValue( "auth" , "disable" ); | 52 | setValue( "auth" , "disable" ); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | void HciConfWrapper::setEncrypt( bool enable) { | 57 | void HciConfWrapper::setEncrypt( bool enable) { |
58 | 58 | ||
59 | if ( enable ) { | 59 | if ( enable ) { |
60 | setValue( "encrypt" , "enable" ); | 60 | setValue( "encrypt" , "enable" ); |
61 | } else { | 61 | } else { |
62 | setValue( "encrypt" , "disable" ); | 62 | setValue( "encrypt" , "disable" ); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { | 67 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { |
68 | 68 | ||
69 | QFile f( m_fileName ); | 69 | QFile f( m_fileName ); |
70 | QFile f2( m_fileName ); | 70 | QFile f2( m_fileName ); |
71 | 71 | ||
72 | if ( !f.open( IO_ReadOnly) ) { | 72 | if ( !f.open( IO_ReadOnly) ) { |
73 | qDebug("Could not open readonly"); | 73 | qDebug("Could not open readonly"); |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | 76 | ||
77 | if ( !f2.open( IO_ReadWrite ) ) { | 77 | if ( !f2.open( IO_ReadWrite ) ) { |
78 | qDebug("Just readonly - not enough"); | 78 | qDebug("Just readonly - not enough"); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | 81 | ||
82 | QStringList list; | 82 | QStringList list; |
83 | qDebug(m_fileName); | 83 | qDebug(m_fileName); |
84 | QTextStream stream ( &f); | 84 | QTextStream stream ( &f); |
85 | QTextStream outstream (&f2); | 85 | QTextStream outstream (&f2); |
86 | 86 | ||
87 | QString str; | 87 | QString str; |
88 | while ( !(str=stream.readLine()).isNull() ) { | 88 | while ( !(str=stream.readLine()).isNull() ) { |
89 | 89 | ||
90 | 90 | ||
91 | //qDebug(str); | 91 | //qDebug(str); |
92 | if( (str.contains(key)) > 0 ) { | 92 | if( (str.contains(key)) > 0 ) { |
93 | qDebug("Found"); | 93 | qDebug("Found"); |
94 | // still need to look if its commented out!!! | 94 | // still need to look if its commented out!!! |
95 | str.simplifyWhiteSpace(); | 95 | str.simplifyWhiteSpace(); |
96 | qDebug( key ); | 96 | qDebug( key ); |
97 | if (str.startsWith("#")) { | 97 | if (str.startsWith("#")) { |
98 | str = (key + " " + value + ";"); | 98 | str = (key + " " + value + ";"); |
99 | } else { | 99 | } else { |
100 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); | 100 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); |
101 | } | 101 | } |
102 | qDebug( str ); | 102 | qDebug( str ); |
103 | } | 103 | } |
104 | outstream << str << endl; | 104 | outstream << str << endl; |
105 | } | 105 | } |
106 | 106 | ||
107 | f.close(); | 107 | f.close(); |
108 | 108 | ||
109 | f2.flush(); | 109 | f2.flush(); |
110 | f2.close(); | 110 | f2.close(); |
111 | } | 111 | } |
112 | } | 112 | } |
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.h b/noncore/net/opietooth/manager/hciconfwrapper.h index 10738c0..de8c9a8 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.h +++ b/noncore/net/opietooth/manager/hciconfwrapper.h | |||
@@ -1,30 +1,30 @@ | |||
1 | #ifndef HCICONFWRAPPER_H | 1 | #ifndef HCICONFWRAPPER_H |
2 | #define HCICONFWRAPPER_H | 2 | #define HCICONFWRAPPER_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | namespace OpieTooth { | 6 | namespace OpieTooth { |
7 | 7 | ||
8 | class HciConfWrapper { | 8 | class HciConfWrapper { |
9 | 9 | ||
10 | public: | 10 | public: |
11 | HciConfWrapper( const QString &fileName ); | 11 | HciConfWrapper( const QString &fileName ); |
12 | ~HciConfWrapper(); | 12 | ~HciConfWrapper(); |
13 | 13 | ||
14 | void setPinHelper( QString app ); | 14 | void setPinHelper( const QString& app ); |
15 | void setName( QString name ); | 15 | void setName( const QString& name ); |
16 | void setIscan( bool enable ); | 16 | void setIscan( bool enable ); |
17 | void setPscan( bool enable ); | 17 | void setPscan( bool enable ); |
18 | void setAuth( bool enable); | 18 | void setAuth( bool enable); |
19 | void setEncrypt( bool enable); | 19 | void setEncrypt( bool enable); |
20 | 20 | ||
21 | private: | 21 | private: |
22 | 22 | ||
23 | void setValue(const QString &entry, const QString &value ); | 23 | void setValue(const QString &entry, const QString &value ); |
24 | 24 | ||
25 | QString m_fileName; | 25 | QString m_fileName; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | } | 28 | } |
29 | 29 | ||
30 | #endif | 30 | #endif |
diff --git a/noncore/net/opietooth/manager/main.cpp b/noncore/net/opietooth/manager/main.cpp index d60ef1c..a86e36d 100644 --- a/noncore/net/opietooth/manager/main.cpp +++ b/noncore/net/opietooth/manager/main.cpp | |||
@@ -1,38 +1,38 @@ | |||
1 | /* | 1 | /* |
2 | * main.cpp | 2 | * main.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * begin : Sun 10 17:20:00 CEST 2002 | 6 | * begin : Sun 10 17:20:00 CEST 2002 |
7 | * copyright : (c) 2002 by Maximilian Reiß | 7 | * copyright : (c) 2002 by Maximilian Reiß |
8 | * email : max.reiss@gmx.de | 8 | * email : max.reiss@gmx.de |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | 19 | ||
20 | #include "bluebase.h" | 20 | #include "bluebase.h" |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | 22 | ||
23 | 23 | ||
24 | QPEApplication *BluetoothApp; | 24 | QPEApplication *BluetoothApp; |
25 | 25 | ||
26 | int main( int argc, char ** argv ) { | 26 | int main( int argc, char ** argv ) { |
27 | QPEApplication a(argc, argv); | 27 | QPEApplication a(argc, argv); |
28 | BluetoothApp=&a; | 28 | BluetoothApp=&a; |
29 | 29 | ||
30 | OpieTooth::BlueBase *t = new OpieTooth::BlueBase(); | 30 | OpieTooth::BlueBase t; |
31 | 31 | ||
32 | // t.setCaption( OpieTooth::BlueBase::tr("Bluetooth Manager") ); | 32 | // t.setCaption( OpieTooth::BlueBase::tr("Bluetooth Manager") ); |
33 | a.showMainWidget(t); | 33 | a.showMainWidget(&t); |
34 | 34 | ||
35 | return a.exec(); | 35 | return a.exec(); |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 0e6e93b..3d6c928 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -1,183 +1,181 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
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 | 18 | ||
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | 20 | ||
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qheader.h> | 22 | #include <qheader.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvariant.h> | 27 | #include <qvariant.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #include <qprogressbar.h> | 30 | #include <qprogressbar.h> |
31 | #include <qlist.h> | 31 | #include <qlist.h> |
32 | 32 | ||
33 | #include <manager.h> | 33 | #include <manager.h> |
34 | #include <device.h> | 34 | #include <device.h> |
35 | 35 | ||
36 | 36 | ||
37 | 37 | ||
38 | namespace OpieTooth { | 38 | namespace OpieTooth { |
39 | 39 | ||
40 | #include <remotedevice.h> | 40 | #include <remotedevice.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | */ | 43 | */ |
44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
45 | : QDialog( parent, name, modal, fl ) { | 45 | : QDialog( parent, name, modal, fl ) { |
46 | 46 | ||
47 | if ( !name ) | 47 | if ( !name ) |
48 | setName( "ScanDialog" ); | 48 | setName( "ScanDialog" ); |
49 | resize( 240, 320 ); | 49 | resize( 240, 320 ); |
50 | setCaption( tr( "Scan for devices" ) ); | 50 | setCaption( tr( "Scan for devices" ) ); |
51 | 51 | ||
52 | Frame7 = new QFrame( this, "Frame7" ); | 52 | Frame7 = new QFrame( this, "Frame7" ); |
53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); | 53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); |
54 | Frame7->setFrameShape( QFrame::StyledPanel ); | 54 | Frame7->setFrameShape( QFrame::StyledPanel ); |
55 | Frame7->setFrameShadow( QFrame::Raised ); | 55 | Frame7->setFrameShadow( QFrame::Raised ); |
56 | 56 | ||
57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | 57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); |
58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); | 58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); |
59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); | 59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); |
60 | Layout11->setSpacing( 6 ); | 60 | Layout11->setSpacing( 6 ); |
61 | Layout11->setMargin( 0 ); | 61 | Layout11->setMargin( 0 ); |
62 | 62 | ||
63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); | 63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); |
64 | progress->setTotalSteps(20); | 64 | progress->setTotalSteps(20); |
65 | 65 | ||
66 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
67 | 67 | ||
68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); |
69 | StartButton->setText( tr( "Start scan" ) ); | 69 | StartButton->setText( tr( "Start scan" ) ); |
70 | 70 | ||
71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | 71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); |
72 | StopButton->setText( tr( "Cancel scan" ) ); | 72 | StopButton->setText( tr( "Cancel scan" ) ); |
73 | 73 | ||
74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
75 | 75 | ||
76 | buttonLayout->addWidget(StartButton); | 76 | buttonLayout->addWidget(StartButton); |
77 | buttonLayout->addWidget(StopButton); | 77 | buttonLayout->addWidget(StopButton); |
78 | 78 | ||
79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
80 | 80 | ||
81 | //ListView1->addColumn( tr( "Add" ) ); | 81 | //ListView1->addColumn( tr( "Add" ) ); |
82 | ListView1->addColumn( tr( "Add Device" ) ); | 82 | ListView1->addColumn( tr( "Add Device" ) ); |
83 | //ListView1->addColumn( tr( "Type" ) ); | 83 | //ListView1->addColumn( tr( "Type" ) ); |
84 | 84 | ||
85 | Layout11->addWidget( ListView1); | 85 | Layout11->addWidget( ListView1); |
86 | Layout11->addWidget(progress); | 86 | Layout11->addWidget(progress); |
87 | Layout11->addWidget( buttonFrame); | 87 | Layout11->addWidget( buttonFrame); |
88 | 88 | ||
89 | localDevice = new Manager( "hci0" ); | 89 | localDevice = new Manager( "hci0" ); |
90 | 90 | ||
91 | connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 91 | connect( StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
92 | connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | 92 | connect( StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); |
93 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), | 93 | connect( localDevice, SIGNAL( foundDevices( const QString& , RemoteDevice::ValueList ) ), |
94 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; | 94 | this, SLOT(fillList(const QString& , RemoteDevice::ValueList ) ) ) ; |
95 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); | 95 | // connect( this, SIGNAL( accept() ), this, SLOT( emitToManager() )); |
96 | progressStat = 0; | 96 | progressStat = 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | // hack, make cleaner later | 99 | // hack, make cleaner later |
100 | void ScanDialog::progressTimer() { | 100 | void ScanDialog::progressTimer() { |
101 | 101 | ||
102 | progressStat++; | 102 | progressStat++; |
103 | if (progressStat++ < 20) { | 103 | if (progressStat++ < 20) { |
104 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); | 104 | QTimer::singleShot( 2000, this, SLOT(progressTimer() ) ); |
105 | } | 105 | } |
106 | progress->setProgress(progressStat++); | 106 | progress->setProgress(progressStat++); |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | void ScanDialog::accept() { | 110 | void ScanDialog::accept() { |
111 | emitToManager(); | 111 | emitToManager(); |
112 | QDialog::accept(); | 112 | QDialog::accept(); |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | void ScanDialog::startSearch() { | 116 | void ScanDialog::startSearch() { |
117 | progress->setProgress(0); | 117 | progress->setProgress(0); |
118 | progressStat = 0; | 118 | progressStat = 0; |
119 | 119 | ||
120 | // empty list before a new scan | 120 | // empty list before a new scan |
121 | ListView1->clear(); | 121 | ListView1->clear(); |
122 | 122 | ||
123 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); | 123 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); |
124 | deviceItem2->setText(1, "BLAH" ); | 124 | deviceItem2->setText(1, "BLAH" ); |
125 | 125 | ||
126 | progressTimer(); | 126 | progressTimer(); |
127 | // when finished, it emmite foundDevices() | 127 | // when finished, it emmite foundDevices() |
128 | // checken ob initialisiert , qcop ans applet. | 128 | // checken ob initialisiert , qcop ans applet. |
129 | localDevice->searchDevices(); | 129 | localDevice->searchDevices(); |
130 | 130 | ||
131 | } | 131 | } |
132 | 132 | ||
133 | void ScanDialog::stopSearch() { | 133 | void ScanDialog::stopSearch() { |
134 | 134 | ||
135 | } | 135 | } |
136 | 136 | ||
137 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { | 137 | void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) { |
138 | 138 | ||
139 | qDebug("fill List"); | 139 | qDebug("fill List"); |
140 | QCheckListItem * deviceItem; | 140 | QCheckListItem * deviceItem; |
141 | 141 | ||
142 | RemoteDevice::ValueList::Iterator it; | 142 | RemoteDevice::ValueList::Iterator it; |
143 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 143 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
144 | 144 | ||
145 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); | 145 | deviceItem = new QCheckListItem( ListView1, (*it).name(), QCheckListItem::CheckBox ); |
146 | deviceItem->setText(1, (*it).mac() ); | 146 | deviceItem->setText(1, (*it).mac() ); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | /* | 150 | /* |
151 | * Iterates trough the items, and collects the checked items. | 151 | * Iterates trough the items, and collects the checked items. |
152 | * Then it emits it, so the manager can connect to the signal to fill the listing. | 152 | * Then it emits it, so the manager can connect to the signal to fill the listing. |
153 | */ | 153 | */ |
154 | void ScanDialog::emitToManager() { | 154 | void ScanDialog::emitToManager() { |
155 | qDebug("vor liste durchsuchen"); | 155 | qDebug("vor liste durchsuchen"); |
156 | 156 | ||
157 | if (!ListView1) { | 157 | if (!ListView1) { |
158 | return; | 158 | return; |
159 | } | 159 | } |
160 | 160 | ||
161 | QList<RemoteDevice> *deviceList = new QList<RemoteDevice>; | 161 | QValueList<RemoteDevice> deviceList; |
162 | deviceList->setAutoDelete(true); | ||
163 | 162 | ||
164 | QListViewItemIterator it( ListView1 ); | 163 | QListViewItemIterator it( ListView1 ); |
165 | for ( ; it.current(); ++it ) { | 164 | for ( ; it.current(); ++it ) { |
166 | if ( ((QCheckListItem*)it.current())->isOn() ) { | 165 | if ( ((QCheckListItem*)it.current())->isOn() ) { |
167 | RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0)); | 166 | RemoteDevice device( it.current()->text(1), it.current()->text(0)); |
168 | deviceList->append( device ); | 167 | deviceList.append( device ); |
169 | } | 168 | } |
170 | } | 169 | } |
171 | qDebug("vor emit"); | 170 | qDebug("vor emit"); |
172 | emit selectedDevices( *deviceList ); | 171 | emit selectedDevices( deviceList ); |
173 | delete deviceList; | ||
174 | } | 172 | } |
175 | 173 | ||
176 | /* | 174 | /* |
177 | * Cleanup | 175 | * Cleanup |
178 | */ | 176 | */ |
179 | ScanDialog::~ScanDialog() { | 177 | ScanDialog::~ScanDialog() { |
180 | delete localDevice; | 178 | delete localDevice; |
181 | } | 179 | } |
182 | 180 | ||
183 | } | 181 | } |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index 7c84ce2..cc890f3 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -1,79 +1,79 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
3 | * copyright : (c) 2002 by Maximilian Reiß | 3 | * copyright : (c) 2002 by Maximilian Reiß |
4 | * email : max.reiss@gmx.de | 4 | * email : max.reiss@gmx.de |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | /*************************************************************************** | 7 | /*************************************************************************** |
8 | * * | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License as published by * | 10 | * it under the terms of the GNU General Public License as published by * |
11 | * the Free Software Foundation; either version 2 of the License, or * | 11 | * the Free Software Foundation; either version 2 of the License, or * |
12 | * (at your option) any later version. * | 12 | * (at your option) any later version. * |
13 | * * | 13 | * * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | 15 | ||
16 | 16 | ||
17 | #ifndef SCANDIALOG_H | 17 | #ifndef SCANDIALOG_H |
18 | #define SCANDIALOG_H | 18 | #define SCANDIALOG_H |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qlist.h> | 22 | #include <qlist.h> |
23 | 23 | ||
24 | #include <remotedevice.h> | 24 | #include <remotedevice.h> |
25 | class QVBoxLayout; | 25 | class QVBoxLayout; |
26 | class QHBoxLayout; | 26 | class QHBoxLayout; |
27 | class QGridLayout; | 27 | class QGridLayout; |
28 | class QFrame; | 28 | class QFrame; |
29 | class QLabel; | 29 | class QLabel; |
30 | class QListView; | 30 | class QListView; |
31 | class QListViewItem; | 31 | class QListViewItem; |
32 | class QPushButton; | 32 | class QPushButton; |
33 | class QProgressBar; | 33 | class QProgressBar; |
34 | 34 | ||
35 | 35 | ||
36 | namespace OpieTooth { | 36 | namespace OpieTooth { |
37 | 37 | ||
38 | 38 | ||
39 | class Manager; | 39 | class Manager; |
40 | class Device; | 40 | class Device; |
41 | 41 | ||
42 | class ScanDialog : public QDialog { | 42 | class ScanDialog : public QDialog { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
47 | ~ScanDialog(); | 47 | ~ScanDialog(); |
48 | 48 | ||
49 | QFrame* Frame7; | 49 | QFrame* Frame7; |
50 | QProgressBar* progress; | 50 | QProgressBar* progress; |
51 | QPushButton* StartButton; | 51 | QPushButton* StartButton; |
52 | QPushButton* StopButton; | 52 | QPushButton* StopButton; |
53 | QListView* ListView1; | 53 | QListView* ListView1; |
54 | 54 | ||
55 | public slots: | 55 | public slots: |
56 | void accept(); | 56 | void accept(); |
57 | 57 | ||
58 | protected: | 58 | protected: |
59 | QVBoxLayout* Layout11; | 59 | QVBoxLayout* Layout11; |
60 | 60 | ||
61 | private slots: | 61 | private slots: |
62 | void stopSearch(); | 62 | void stopSearch(); |
63 | void startSearch(); | 63 | void startSearch(); |
64 | void progressTimer(); | 64 | void progressTimer(); |
65 | void fillList(const QString& device, RemoteDevice::ValueList list); | 65 | void fillList(const QString& device, RemoteDevice::ValueList list); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | void emitToManager(); | 68 | void emitToManager(); |
69 | Manager *localDevice; | 69 | Manager *localDevice; |
70 | int progressStat; | 70 | int progressStat; |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void selectedDevices(QList<RemoteDevice>&); | 73 | void selectedDevices(QValueList<RemoteDevice>&); |
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | #endif // SCANDIALOG_H | 79 | #endif // SCANDIALOG_H |