author | drw <drw> | 2005-03-22 22:57:07 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-22 22:57:07 (UTC) |
commit | 3011e3f1741057b9163c3658a8847c528da5da05 (patch) (unidiff) | |
tree | d4ddecfd5073465973cbeb92a3301a3247df5594 | |
parent | 63d19f6ef6eeeb362323e3301daab03df1588faa (diff) | |
download | opie-3011e3f1741057b9163c3658a8847c528da5da05.zip opie-3011e3f1741057b9163c3658a8847c528da5da05.tar.gz opie-3011e3f1741057b9163c3658a8847c528da5da05.tar.bz2 |
Disconnect signals after command executes to prevent bug where messages show up multiple times in install dialog
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 417ee95..127204d 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -254,443 +254,450 @@ OPackageList *OIpkg::availablePackages( const QString &server ) | |||
254 | // Open package list file | 254 | // Open package list file |
255 | QFile f( listsDir + "/" + server ); | 255 | QFile f( listsDir + "/" + server ); |
256 | if ( !f.open( IO_ReadOnly ) ) | 256 | if ( !f.open( IO_ReadOnly ) ) |
257 | return NULL; | 257 | return NULL; |
258 | QTextStream t( &f ); | 258 | QTextStream t( &f ); |
259 | 259 | ||
260 | // Process all information in package list file | 260 | // Process all information in package list file |
261 | OPackage *package = NULL; | 261 | OPackage *package = NULL; |
262 | QString line = t.readLine(); | 262 | QString line = t.readLine(); |
263 | while ( !t.eof() ) | 263 | while ( !t.eof() ) |
264 | { | 264 | { |
265 | // Determine key/value pair | 265 | // Determine key/value pair |
266 | int pos = line.find( ':', 0 ); | 266 | int pos = line.find( ':', 0 ); |
267 | QString key; | 267 | QString key; |
268 | if ( pos > -1 ) | 268 | if ( pos > -1 ) |
269 | key = line.mid( 0, pos ); | 269 | key = line.mid( 0, pos ); |
270 | else | 270 | else |
271 | key = QString::null; | 271 | key = QString::null; |
272 | QString value = line.mid( pos+2, line.length()-pos ); | 272 | QString value = line.mid( pos+2, line.length()-pos ); |
273 | 273 | ||
274 | // Allocate new package and insert into list | 274 | // Allocate new package and insert into list |
275 | if ( package == NULL && !key.isEmpty() ) | 275 | if ( package == NULL && !key.isEmpty() ) |
276 | { | 276 | { |
277 | package = new OPackage( value ); | 277 | package = new OPackage( value ); |
278 | package->setSource( server ); | 278 | package->setSource( server ); |
279 | pl->append( package ); | 279 | pl->append( package ); |
280 | } | 280 | } |
281 | 281 | ||
282 | // Update package data | 282 | // Update package data |
283 | if ( key == "Package" ) | 283 | if ( key == "Package" ) |
284 | package->setName( value ); | 284 | package->setName( value ); |
285 | else if ( key == "Version" ) | 285 | else if ( key == "Version" ) |
286 | package->setVersion( value ); | 286 | package->setVersion( value ); |
287 | else if ( key == "Section" ) | 287 | else if ( key == "Section" ) |
288 | package->setCategory( value ); | 288 | package->setCategory( value ); |
289 | //DataManager::setAvailableCategories( value ); | 289 | //DataManager::setAvailableCategories( value ); |
290 | else if ( key.isEmpty() && value.isEmpty() ) | 290 | else if ( key.isEmpty() && value.isEmpty() ) |
291 | package = NULL; | 291 | package = NULL; |
292 | 292 | ||
293 | // Skip past all description lines | 293 | // Skip past all description lines |
294 | if ( key == "Description" ) | 294 | if ( key == "Description" ) |
295 | { | 295 | { |
296 | line = t.readLine(); | 296 | line = t.readLine(); |
297 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 297 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
298 | line = t.readLine(); | 298 | line = t.readLine(); |
299 | } | 299 | } |
300 | else | 300 | else |
301 | line = t.readLine(); | 301 | line = t.readLine(); |
302 | } | 302 | } |
303 | 303 | ||
304 | f.close(); | 304 | f.close(); |
305 | 305 | ||
306 | return pl; | 306 | return pl; |
307 | } | 307 | } |
308 | 308 | ||
309 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 309 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
310 | { | 310 | { |
311 | // Load Ipkg configuration info if not already cached | 311 | // Load Ipkg configuration info if not already cached |
312 | if ( !m_confInfo ) | 312 | if ( !m_confInfo ) |
313 | loadConfiguration(); | 313 | loadConfiguration(); |
314 | 314 | ||
315 | // Build new server list (caller is responsible for deleting) | 315 | // Build new server list (caller is responsible for deleting) |
316 | OPackageList *pl = new OPackageList; | 316 | OPackageList *pl = new OPackageList; |
317 | 317 | ||
318 | // Open status file | 318 | // Open status file |
319 | QString path = destPath; | 319 | QString path = destPath; |
320 | if ( path.right( 1 ) != "/" ) | 320 | if ( path.right( 1 ) != "/" ) |
321 | path.append( "/" ); | 321 | path.append( "/" ); |
322 | path.append( IPKG_STATUS_PATH ); | 322 | path.append( IPKG_STATUS_PATH ); |
323 | 323 | ||
324 | QFile f( path ); | 324 | QFile f( path ); |
325 | if ( !f.open( IO_ReadOnly ) ) | 325 | if ( !f.open( IO_ReadOnly ) ) |
326 | return NULL; | 326 | return NULL; |
327 | QTextStream t( &f ); | 327 | QTextStream t( &f ); |
328 | 328 | ||
329 | // Process all information in status file | 329 | // Process all information in status file |
330 | bool newPackage = false; | 330 | bool newPackage = false; |
331 | QString line = t.readLine(); | 331 | QString line = t.readLine(); |
332 | QString name; | 332 | QString name; |
333 | QString version; | 333 | QString version; |
334 | QString status; | 334 | QString status; |
335 | 335 | ||
336 | while ( !t.eof() ) | 336 | while ( !t.eof() ) |
337 | { | 337 | { |
338 | // Determine key/value pair | 338 | // Determine key/value pair |
339 | int pos = line.find( ':', 0 ); | 339 | int pos = line.find( ':', 0 ); |
340 | QString key; | 340 | QString key; |
341 | if ( pos > -1 ) | 341 | if ( pos > -1 ) |
342 | key = line.mid( 0, pos ); | 342 | key = line.mid( 0, pos ); |
343 | else | 343 | else |
344 | key = QString::null; | 344 | key = QString::null; |
345 | QString value = line.mid( pos+2, line.length()-pos ); | 345 | QString value = line.mid( pos+2, line.length()-pos ); |
346 | 346 | ||
347 | // Allocate new package and insert into list | 347 | // Allocate new package and insert into list |
348 | if ( newPackage && !key.isEmpty() ) | 348 | if ( newPackage && !key.isEmpty() ) |
349 | { | 349 | { |
350 | // Add to list only if it has a valid name and is installed | 350 | // Add to list only if it has a valid name and is installed |
351 | if ( !name.isNull() && status.contains( " installed" ) ) | 351 | if ( !name.isNull() && status.contains( " installed" ) ) |
352 | { | 352 | { |
353 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 353 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
354 | name = QString::null; | 354 | name = QString::null; |
355 | version = QString::null; | 355 | version = QString::null; |
356 | status = QString::null; | 356 | status = QString::null; |
357 | 357 | ||
358 | newPackage = false; | 358 | newPackage = false; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | // Update package data | 362 | // Update package data |
363 | if ( key == "Package" ) | 363 | if ( key == "Package" ) |
364 | name = value; | 364 | name = value; |
365 | else if ( key == "Version" ) | 365 | else if ( key == "Version" ) |
366 | version = value; | 366 | version = value; |
367 | else if ( key == "Status" ) | 367 | else if ( key == "Status" ) |
368 | status = value; | 368 | status = value; |
369 | else if ( key.isEmpty() && value.isEmpty() ) | 369 | else if ( key.isEmpty() && value.isEmpty() ) |
370 | newPackage = true; | 370 | newPackage = true; |
371 | 371 | ||
372 | // Skip past all description lines | 372 | // Skip past all description lines |
373 | if ( key == "Description" ) | 373 | if ( key == "Description" ) |
374 | { | 374 | { |
375 | line = t.readLine(); | 375 | line = t.readLine(); |
376 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 376 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
377 | line = t.readLine(); | 377 | line = t.readLine(); |
378 | } | 378 | } |
379 | else | 379 | else |
380 | line = t.readLine(); | 380 | line = t.readLine(); |
381 | } | 381 | } |
382 | 382 | ||
383 | f.close(); | 383 | f.close(); |
384 | 384 | ||
385 | // Make sure to add to list last entry | 385 | // Make sure to add to list last entry |
386 | if ( !name.isNull() && status.contains( " installed" ) ) | 386 | if ( !name.isNull() && status.contains( " installed" ) ) |
387 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 387 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
388 | 388 | ||
389 | return pl; | 389 | return pl; |
390 | } | 390 | } |
391 | 391 | ||
392 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) | 392 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) |
393 | { | 393 | { |
394 | // Find configuration item in list | 394 | // Find configuration item in list |
395 | OConfItemListIterator configIt( *m_confInfo ); | 395 | OConfItemListIterator configIt( *m_confInfo ); |
396 | OConfItem *config = 0l; | 396 | OConfItem *config = 0l; |
397 | for ( ; configIt.current(); ++configIt ) | 397 | for ( ; configIt.current(); ++configIt ) |
398 | { | 398 | { |
399 | config = configIt.current(); | 399 | config = configIt.current(); |
400 | if ( config->type() == type && config->name() == name ) | 400 | if ( config->type() == type && config->name() == name ) |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | 403 | ||
404 | if ( config && config->type() == type && config->name() == name ) | 404 | if ( config && config->type() == type && config->name() == name ) |
405 | return config; | 405 | return config; |
406 | 406 | ||
407 | return 0l; | 407 | return 0l; |
408 | } | 408 | } |
409 | 409 | ||
410 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, | 410 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
411 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 411 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
412 | { | 412 | { |
413 | if ( command == OPackage::NotDefined ) | 413 | if ( command == OPackage::NotDefined ) |
414 | return false; | 414 | return false; |
415 | 415 | ||
416 | // Set ipkg run-time options/arguments | 416 | // Set ipkg run-time options/arguments |
417 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 417 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
418 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 418 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
419 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 419 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
420 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 420 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
421 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 421 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
422 | if ( m_ipkgArgs.dest ) | 422 | if ( m_ipkgArgs.dest ) |
423 | free( m_ipkgArgs.dest ); | 423 | free( m_ipkgArgs.dest ); |
424 | if ( !destination.isNull() ) | 424 | if ( !destination.isNull() ) |
425 | { | 425 | { |
426 | int len = destination.length() + 1; | 426 | int len = destination.length() + 1; |
427 | m_ipkgArgs.dest = (char *)malloc( len ); | 427 | m_ipkgArgs.dest = (char *)malloc( len ); |
428 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 428 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
429 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 429 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
430 | } | 430 | } |
431 | else | 431 | else |
432 | m_ipkgArgs.dest = 0l; | 432 | m_ipkgArgs.dest = 0l; |
433 | 433 | ||
434 | // Connect output signal to widget | 434 | // Connect output signal to widget |
435 | 435 | ||
436 | if ( !rawOutput ) | 436 | if ( !rawOutput ) |
437 | { | 437 | { |
438 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 438 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
439 | } | 439 | } |
440 | 440 | ||
441 | switch( command ) | 441 | switch( command ) |
442 | { | 442 | { |
443 | case OPackage::Update : { | 443 | case OPackage::Update : { |
444 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 444 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
445 | ipkg_lists_update( &m_ipkgArgs ); | 445 | ipkg_lists_update( &m_ipkgArgs ); |
446 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | ||
446 | }; | 447 | }; |
447 | break; | 448 | break; |
448 | case OPackage::Upgrade : { | 449 | case OPackage::Upgrade : { |
449 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 450 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
450 | ipkg_packages_upgrade( &m_ipkgArgs ); | 451 | ipkg_packages_upgrade( &m_ipkgArgs ); |
451 | 452 | ||
452 | // Re-link non-root destinations to make sure everything is in sync | 453 | // Re-link non-root destinations to make sure everything is in sync |
453 | OConfItemList *destList = destinations(); | 454 | OConfItemList *destList = destinations(); |
454 | OConfItemListIterator it( *destList ); | 455 | OConfItemListIterator it( *destList ); |
455 | for ( ; it.current(); ++it ) | 456 | for ( ; it.current(); ++it ) |
456 | { | 457 | { |
457 | OConfItem *dest = it.current(); | 458 | OConfItem *dest = it.current(); |
458 | if ( dest->name() != "root" ) | 459 | if ( dest->name() != "root" ) |
459 | linkPackageDir( dest->name() ); | 460 | linkPackageDir( dest->name() ); |
460 | } | 461 | } |
461 | delete destList; | 462 | delete destList; |
463 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | ||
462 | }; | 464 | }; |
463 | break; | 465 | break; |
464 | case OPackage::Install : { | 466 | case OPackage::Install : { |
465 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 467 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
466 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 468 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
467 | { | 469 | { |
468 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 470 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
469 | } | 471 | } |
470 | if ( destination != "root" ) | 472 | if ( destination != "root" ) |
471 | linkPackageDir( destination ); | 473 | linkPackageDir( destination ); |
474 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | ||
472 | }; | 475 | }; |
473 | break; | 476 | break; |
474 | case OPackage::Remove : { | 477 | case OPackage::Remove : { |
475 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 478 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
476 | 479 | ||
477 | // Get list of destinations for unlinking of packages not installed to root | 480 | // Get list of destinations for unlinking of packages not installed to root |
478 | OConfItemList *destList = destinations(); | 481 | OConfItemList *destList = destinations(); |
479 | 482 | ||
480 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 483 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
481 | { | 484 | { |
482 | unlinkPackage( (*it), destList ); | 485 | unlinkPackage( (*it), destList ); |
483 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 486 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
484 | } | 487 | } |
485 | 488 | ||
486 | delete destList; | 489 | delete destList; |
490 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | ||
487 | }; | 491 | }; |
488 | break; | 492 | break; |
489 | case OPackage::Download : { | 493 | case OPackage::Download : { |
490 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 494 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
491 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 495 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
492 | { | 496 | { |
493 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 497 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
494 | } | 498 | } |
499 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | ||
495 | }; | 500 | }; |
496 | break; | 501 | break; |
497 | case OPackage::Info : { | 502 | case OPackage::Info : { |
498 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); | 503 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); |
499 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); | 504 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); |
505 | disconnect( this, SIGNAL(signalIpkgStatus(const QString &)), 0, 0 ); | ||
500 | }; | 506 | }; |
501 | break; | 507 | break; |
502 | case OPackage::Files : { | 508 | case OPackage::Files : { |
503 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); | 509 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); |
504 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); | 510 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); |
511 | disconnect( this, SIGNAL(signalIpkgList(const QString &)), 0, 0 ); | ||
505 | }; | 512 | }; |
506 | break; | 513 | break; |
507 | default : break; | 514 | default : break; |
508 | }; | 515 | }; |
509 | 516 | ||
510 | return true; | 517 | return true; |
511 | } | 518 | } |
512 | 519 | ||
513 | void OIpkg::ipkgMessage( char *msg ) | 520 | void OIpkg::ipkgMessage( char *msg ) |
514 | { | 521 | { |
515 | emit signalIpkgMessage( msg ); | 522 | emit signalIpkgMessage( msg ); |
516 | } | 523 | } |
517 | 524 | ||
518 | void OIpkg::ipkgStatus( char *status ) | 525 | void OIpkg::ipkgStatus( char *status ) |
519 | { | 526 | { |
520 | emit signalIpkgStatus( status ); | 527 | emit signalIpkgStatus( status ); |
521 | } | 528 | } |
522 | 529 | ||
523 | void OIpkg::ipkgList( char *filelist ) | 530 | void OIpkg::ipkgList( char *filelist ) |
524 | { | 531 | { |
525 | emit signalIpkgList( filelist ); | 532 | emit signalIpkgList( filelist ); |
526 | } | 533 | } |
527 | 534 | ||
528 | void OIpkg::loadConfiguration() | 535 | void OIpkg::loadConfiguration() |
529 | { | 536 | { |
530 | if ( m_confInfo ) | 537 | if ( m_confInfo ) |
531 | delete m_confInfo; | 538 | delete m_confInfo; |
532 | 539 | ||
533 | // Load configuration item list | 540 | // Load configuration item list |
534 | m_confInfo = new OConfItemList(); | 541 | m_confInfo = new OConfItemList(); |
535 | 542 | ||
536 | QStringList confFiles; | 543 | QStringList confFiles; |
537 | QDir confDir( IPKG_CONF_DIR ); | 544 | QDir confDir( IPKG_CONF_DIR ); |
538 | if ( confDir.exists() ) | 545 | if ( confDir.exists() ) |
539 | { | 546 | { |
540 | confDir.setNameFilter( "*.conf" ); | 547 | confDir.setNameFilter( "*.conf" ); |
541 | confDir.setFilter( QDir::Files ); | 548 | confDir.setFilter( QDir::Files ); |
542 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 549 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
543 | } | 550 | } |
544 | confFiles << IPKG_CONF; | 551 | confFiles << IPKG_CONF; |
545 | 552 | ||
546 | QStringList::Iterator lastFile = confFiles.end(); | 553 | QStringList::Iterator lastFile = confFiles.end(); |
547 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 554 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
548 | { | 555 | { |
549 | // Create absolute file path if necessary | 556 | // Create absolute file path if necessary |
550 | QString absFile = (*it); | 557 | QString absFile = (*it); |
551 | if ( !absFile.startsWith( "/" ) ) | 558 | if ( !absFile.startsWith( "/" ) ) |
552 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 559 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
553 | 560 | ||
554 | // Read in file | 561 | // Read in file |
555 | QFile f( absFile ); | 562 | QFile f( absFile ); |
556 | if ( f.open( IO_ReadOnly ) ) | 563 | if ( f.open( IO_ReadOnly ) ) |
557 | { | 564 | { |
558 | QTextStream s( &f ); | 565 | QTextStream s( &f ); |
559 | while ( !s.eof() ) | 566 | while ( !s.eof() ) |
560 | { | 567 | { |
561 | 568 | ||
562 | QString line = s.readLine().simplifyWhiteSpace(); | 569 | QString line = s.readLine().simplifyWhiteSpace(); |
563 | 570 | ||
564 | // Parse line and save info to the conf options list | 571 | // Parse line and save info to the conf options list |
565 | if ( !line.isEmpty() ) | 572 | if ( !line.isEmpty() ) |
566 | { | 573 | { |
567 | // Strip leading comment marker if exists | 574 | // Strip leading comment marker if exists |
568 | bool comment = false; | 575 | bool comment = false; |
569 | if ( line.startsWith( "#" ) ) | 576 | if ( line.startsWith( "#" ) ) |
570 | { | 577 | { |
571 | line.remove( 0, 1 ); | 578 | line.remove( 0, 1 ); |
572 | line = line.simplifyWhiteSpace(); | 579 | line = line.simplifyWhiteSpace(); |
573 | comment = true; | 580 | comment = true; |
574 | } | 581 | } |
575 | 582 | ||
576 | bool recognizedOption = true; | 583 | bool recognizedOption = true; |
577 | int pos = line.find( ' ', 1 ) + 1; | 584 | int pos = line.find( ' ', 1 ) + 1; |
578 | int endpos = line.find( ' ', pos ); | 585 | int endpos = line.find( ' ', pos ); |
579 | 586 | ||
580 | // Name | 587 | // Name |
581 | QString name = line.mid( pos, endpos - pos ); | 588 | QString name = line.mid( pos, endpos - pos ); |
582 | 589 | ||
583 | // Value | 590 | // Value |
584 | QString value = ""; | 591 | QString value = ""; |
585 | if ( endpos > -1 ) | 592 | if ( endpos > -1 ) |
586 | value = line.right( line.length() - endpos - 1 ); | 593 | value = line.right( line.length() - endpos - 1 ); |
587 | 594 | ||
588 | // Active | 595 | // Active |
589 | bool active = !comment; | 596 | bool active = !comment; |
590 | 597 | ||
591 | // Type | 598 | // Type |
592 | // For options w/type = Other, the mapping is as follows: | 599 | // For options w/type = Other, the mapping is as follows: |
593 | // name = typeStr (e.g. "lists_dir") | 600 | // name = typeStr (e.g. "lists_dir") |
594 | // value = value | 601 | // value = value |
595 | // features = name (from configuration file) | 602 | // features = name (from configuration file) |
596 | 603 | ||
597 | QString typeStr = line.left( pos - 1 ); | 604 | QString typeStr = line.left( pos - 1 ); |
598 | OConfItem::Type type; | 605 | OConfItem::Type type; |
599 | QString features; | 606 | QString features; |
600 | if ( typeStr == "src" ) | 607 | if ( typeStr == "src" ) |
601 | type = OConfItem::Source; | 608 | type = OConfItem::Source; |
602 | else if ( typeStr == "src/gz" ) | 609 | else if ( typeStr == "src/gz" ) |
603 | { | 610 | { |
604 | type = OConfItem::Source; | 611 | type = OConfItem::Source; |
605 | features = "Compressed"; | 612 | features = "Compressed"; |
606 | } | 613 | } |
607 | else if ( typeStr == "dest" ) | 614 | else if ( typeStr == "dest" ) |
608 | type = OConfItem::Destination; | 615 | type = OConfItem::Destination; |
609 | else if ( typeStr == "option" ) | 616 | else if ( typeStr == "option" ) |
610 | type = OConfItem::Option; | 617 | type = OConfItem::Option; |
611 | else if ( typeStr == "arch" ) | 618 | else if ( typeStr == "arch" ) |
612 | type = OConfItem::Arch; | 619 | type = OConfItem::Arch; |
613 | else if ( typeStr == "lists_dir" ) | 620 | else if ( typeStr == "lists_dir" ) |
614 | { | 621 | { |
615 | type = OConfItem::Other; | 622 | type = OConfItem::Other; |
616 | features = name; | 623 | features = name; |
617 | name = typeStr; | 624 | name = typeStr; |
618 | 625 | ||
619 | // Default value when not defined | 626 | // Default value when not defined |
620 | if ( value == QString::null || value == "" ) | 627 | if ( value == QString::null || value == "" ) |
621 | value = IPKG_PKG_PATH; | 628 | value = IPKG_PKG_PATH; |
622 | } | 629 | } |
623 | else | 630 | else |
624 | recognizedOption = false; | 631 | recognizedOption = false; |
625 | 632 | ||
626 | // Add to list | 633 | // Add to list |
627 | if ( recognizedOption ) | 634 | if ( recognizedOption ) |
628 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); | 635 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); |
629 | } | 636 | } |
630 | } | 637 | } |
631 | 638 | ||
632 | f.close(); | 639 | f.close(); |
633 | } | 640 | } |
634 | } | 641 | } |
635 | 642 | ||
636 | // Load Ipkg execution options from application configuration file | 643 | // Load Ipkg execution options from application configuration file |
637 | if ( m_config ) | 644 | if ( m_config ) |
638 | { | 645 | { |
639 | m_config->setGroup( "Ipkg" ); | 646 | m_config->setGroup( "Ipkg" ); |
640 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 647 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
641 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 648 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
642 | } | 649 | } |
643 | } | 650 | } |
644 | 651 | ||
645 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 652 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
646 | { | 653 | { |
647 | // Load Ipkg configuration info if not already cached | 654 | // Load Ipkg configuration info if not already cached |
648 | if ( !m_confInfo ) | 655 | if ( !m_confInfo ) |
649 | loadConfiguration(); | 656 | loadConfiguration(); |
650 | 657 | ||
651 | // Build new server list (caller is responsible for deleting) | 658 | // Build new server list (caller is responsible for deleting) |
652 | OConfItemList *sl = new OConfItemList; | 659 | OConfItemList *sl = new OConfItemList; |
653 | 660 | ||
654 | // If typefilter is empty, retrieve all items | 661 | // If typefilter is empty, retrieve all items |
655 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 662 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
656 | 663 | ||
657 | // Parse configuration info for servers | 664 | // Parse configuration info for servers |
658 | OConfItemListIterator it( *m_confInfo ); | 665 | OConfItemListIterator it( *m_confInfo ); |
659 | for ( ; it.current(); ++it ) | 666 | for ( ; it.current(); ++it ) |
660 | { | 667 | { |
661 | OConfItem *item = it.current(); | 668 | OConfItem *item = it.current(); |
662 | if ( retrieveAll || item->type() == typefilter ) | 669 | if ( retrieveAll || item->type() == typefilter ) |
663 | { | 670 | { |
664 | sl->append( item ); | 671 | sl->append( item ); |
665 | } | 672 | } |
666 | } | 673 | } |
667 | 674 | ||
668 | return sl; | 675 | return sl; |
669 | } | 676 | } |
670 | 677 | ||
671 | const QString &OIpkg::rootPath() | 678 | const QString &OIpkg::rootPath() |
672 | { | 679 | { |
673 | if ( m_rootPath.isEmpty() ) | 680 | if ( m_rootPath.isEmpty() ) |
674 | { | 681 | { |
675 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); | 682 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); |
676 | rootDest ? m_rootPath = rootDest->value() | 683 | rootDest ? m_rootPath = rootDest->value() |
677 | : m_rootPath = '/'; | 684 | : m_rootPath = '/'; |
678 | if ( m_rootPath.right( 1 ) == '/' ) | 685 | if ( m_rootPath.right( 1 ) == '/' ) |
679 | m_rootPath.truncate( m_rootPath.length() - 1 ); | 686 | m_rootPath.truncate( m_rootPath.length() - 1 ); |
680 | } | 687 | } |
681 | return m_rootPath; | 688 | return m_rootPath; |
682 | } | 689 | } |
683 | 690 | ||
684 | void OIpkg::linkPackageDir( const QString &dest ) | 691 | void OIpkg::linkPackageDir( const QString &dest ) |
685 | { | 692 | { |
686 | if ( !dest.isNull() ) | 693 | if ( !dest.isNull() ) |
687 | { | 694 | { |
688 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); | 695 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); |
689 | 696 | ||
690 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); | 697 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); |
691 | 698 | ||
692 | // Set package destination directory | 699 | // Set package destination directory |
693 | QString destDir = destConfItem->value(); | 700 | QString destDir = destConfItem->value(); |
694 | QString destInfoDir = destDir; | 701 | QString destInfoDir = destDir; |
695 | if ( destInfoDir.right( 1 ) != '/' ) | 702 | if ( destInfoDir.right( 1 ) != '/' ) |
696 | destInfoDir.append( '/' ); | 703 | destInfoDir.append( '/' ); |