author | drw <drw> | 2004-07-31 16:57:09 (UTC) |
---|---|---|
committer | drw <drw> | 2004-07-31 16:57:09 (UTC) |
commit | bc85059dbd265feb3424215a2c1a4818af7d069e (patch) (unidiff) | |
tree | 6200d0188ac374741fdcd0019e68227a5a966892 | |
parent | b099a3dd18571fcbd5b1211f18ac111ec39f9ce8 (diff) | |
download | opie-bc85059dbd265feb3424215a2c1a4818af7d069e.zip opie-bc85059dbd265feb3424215a2c1a4818af7d069e.tar.gz opie-bc85059dbd265feb3424215a2c1a4818af7d069e.tar.bz2 |
Read ipkg.conf even when /etc/ipkg does not exist, found by Bernardo...thanks\!
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 87a30bb..eca5861 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -468,74 +468,74 @@ void OIpkg::loadConfiguration() | |||
468 | { | 468 | { |
469 | confDir.setNameFilter( "*.conf" ); | 469 | confDir.setNameFilter( "*.conf" ); |
470 | confDir.setFilter( QDir::Files ); | 470 | confDir.setFilter( QDir::Files ); |
471 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 471 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
472 | confFiles << IPKG_CONF; | 472 | } |
473 | confFiles << IPKG_CONF; | ||
473 | 474 | ||
474 | QStringList::Iterator lastFile = confFiles.end(); | 475 | QStringList::Iterator lastFile = confFiles.end(); |
475 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 476 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
477 | { | ||
478 | // Create absolute file path if necessary | ||
479 | QString absFile = (*it); | ||
480 | if ( !absFile.startsWith( "/" ) ) | ||
481 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | ||
482 | |||
483 | // Read in file | ||
484 | QFile f( absFile ); | ||
485 | if ( f.open( IO_ReadOnly ) ) | ||
476 | { | 486 | { |
477 | // Create absolute file path if necessary | 487 | QTextStream s( &f ); |
478 | QString absFile = (*it); | 488 | while ( !s.eof() ) |
479 | if ( !absFile.startsWith( "/" ) ) | ||
480 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | ||
481 | |||
482 | // Read in file | ||
483 | QFile f( absFile ); | ||
484 | if ( f.open( IO_ReadOnly ) ) | ||
485 | { | 489 | { |
486 | QTextStream s( &f ); | ||
487 | while ( !s.eof() ) | ||
488 | { | ||
489 | 490 | ||
490 | QString line = s.readLine().simplifyWhiteSpace(); | 491 | QString line = s.readLine().simplifyWhiteSpace(); |
491 | 492 | ||
492 | // Parse line and save info to the conf options list | 493 | // Parse line and save info to the conf options list |
493 | if ( !line.isEmpty() ) | 494 | if ( !line.isEmpty() ) |
495 | { | ||
496 | if ( !line.startsWith( "#" ) || | ||
497 | line.startsWith( "#src" ) || | ||
498 | line.startsWith( "#dest" ) || | ||
499 | line.startsWith( "#arch" ) || | ||
500 | line.startsWith( "#option" ) ) | ||
494 | { | 501 | { |
495 | if ( !line.startsWith( "#" ) || | 502 | int pos = line.find( ' ', 1 ); |
496 | line.startsWith( "#src" ) || | 503 | |
497 | line.startsWith( "#dest" ) || | 504 | // Type |
498 | line.startsWith( "#arch" ) || | 505 | QString typeStr = line.left( pos ); |
499 | line.startsWith( "#option" ) ) | 506 | OConfItem::Type type; |
500 | { | 507 | if ( typeStr == "src" || typeStr == "#src" ) |
501 | int pos = line.find( ' ', 1 ); | 508 | type = OConfItem::Source; |
502 | 509 | else if ( typeStr == "dest" || typeStr == "#dest" ) | |
503 | // Type | 510 | type = OConfItem::Destination; |
504 | QString typeStr = line.left( pos ); | 511 | else if ( typeStr == "option" || typeStr == "#option" ) |
505 | OConfItem::Type type; | 512 | type = OConfItem::Option; |
506 | if ( typeStr == "src" || typeStr == "#src" ) | 513 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
507 | type = OConfItem::Source; | 514 | type = OConfItem::Arch; |
508 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 515 | else |
509 | type = OConfItem::Destination; | 516 | type = OConfItem::NotDefined; |
510 | else if ( typeStr == "option" || typeStr == "#option" ) | 517 | ++pos; |
511 | type = OConfItem::Option; | 518 | int endpos = line.find( ' ', pos ); |
512 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 519 | |
513 | type = OConfItem::Arch; | 520 | // Name |
514 | else | 521 | QString name = line.mid( pos, endpos - pos ); |
515 | type = OConfItem::NotDefined; | 522 | |
516 | ++pos; | 523 | // Value |
517 | int endpos = line.find( ' ', pos ); | 524 | QString value = ""; |
518 | 525 | if ( endpos > -1 ) | |
519 | // Name | 526 | value = line.right( line.length() - endpos - 1 ); |
520 | QString name = line.mid( pos, endpos - pos ); | 527 | |
521 | 528 | // Active | |
522 | // Value | 529 | bool active = !line.startsWith( "#" ); |
523 | QString value = ""; | 530 | |
524 | if ( endpos > -1 ) | 531 | // Add to list |
525 | value = line.right( line.length() - endpos - 1 ); | 532 | m_confInfo->append( new OConfItem( type, name, value, active ) ); |
526 | |||
527 | // Active | ||
528 | bool active = !line.startsWith( "#" ); | ||
529 | |||
530 | // Add to list | ||
531 | m_confInfo->append( new OConfItem( type, name, value, active ) ); | ||
532 | } | ||
533 | } | 533 | } |
534 | } | 534 | } |
535 | |||
536 | f.close(); | ||
537 | } | 535 | } |
536 | |||
537 | f.close(); | ||
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | // Load Ipkg execution options from application configuration file | 541 | // Load Ipkg execution options from application configuration file |