summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/oipkg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp81
1 files changed, 53 insertions, 28 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index e7e292e..3d2c621 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -153,4 +153,5 @@ void OIpkg::setConfigItems( OConfItemList *configList )
153 { 153 {
154 QString confLine; 154 QString confLine;
155 QString name = item->name();
155 if ( !item->active() ) 156 if ( !item->active() )
156 confLine = "#"; 157 confLine = "#";
@@ -169,8 +170,18 @@ void OIpkg::setConfigItems( OConfItemList *configList )
169 case OConfItem::Option : confLine.append( "option " ); break; 170 case OConfItem::Option : confLine.append( "option " ); break;
170 case OConfItem::Arch : confLine.append( "arch " ); break; 171 case OConfItem::Arch : confLine.append( "arch " ); break;
172 case OConfItem::Other :
173 {
174 // For options w/type = Other, the mapping is as follows:
175 // name = typeStr (e.g. "lists_dir")
176 // value = value
177 // features = name (from configuration file)
178 confLine.append( item->name() );
179 name = item->features();
180 }
181 break;
171 default : break; 182 default : break;
172 }; 183 };
173 184
174 confStream << confLine << " " << item->name() << " " << item->value() << "\n"; 185 confStream << confLine << " " << name << " " << item->value() << "\n";
175 } 186 }
176 } 187 }
@@ -546,50 +557,64 @@ void OIpkg::loadConfiguration()
546 if ( !line.isEmpty() ) 557 if ( !line.isEmpty() )
547 { 558 {
548 if ( !line.startsWith( "#" ) || 559 // Strip leading comment marker if exists
549 line.startsWith( "#src" ) || 560 bool comment = false;
550 line.startsWith( "#dest" ) || 561 if ( line.startsWith( "#" ) )
551 line.startsWith( "#arch" ) ||
552 line.startsWith( "#option" ) )
553 { 562 {
554 int pos = line.find( ' ', 1 ); 563 line.remove( 0, 1 );
564 line = line.simplifyWhiteSpace();
565 comment = true;
566 }
567
568 bool recognizedOption = true;
569 int pos = line.find( ' ', 1 ) + 1;
570 int endpos = line.find( ' ', pos );
571
572 // Name
573 QString name = line.mid( pos, endpos - pos );
574
575 // Value
576 QString value = "";
577 if ( endpos > -1 )
578 value = line.right( line.length() - endpos - 1 );
579
580 // Active
581 bool active = !comment;
555 582
556 // Type 583 // Type
557 QString typeStr = line.left( pos ); 584 // For options w/type = Other, the mapping is as follows:
585 // name = typeStr (e.g. "lists_dir")
586 // value = value
587 // features = name (from configuration file)
588
589 QString typeStr = line.left( pos - 1 );
558 OConfItem::Type type; 590 OConfItem::Type type;
559 QString features; 591 QString features;
560 if ( typeStr == "src" || typeStr == "#src" ) 592 if ( typeStr == "src" )
561 type = OConfItem::Source; 593 type = OConfItem::Source;
562 else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) 594 else if ( typeStr == "src/gz" )
563 { 595 {
564 type = OConfItem::Source; 596 type = OConfItem::Source;
565 features = "Compressed"; 597 features = "Compressed";
566 } 598 }
567 else if ( typeStr == "dest" || typeStr == "#dest" ) 599 else if ( typeStr == "dest" )
568 type = OConfItem::Destination; 600 type = OConfItem::Destination;
569 else if ( typeStr == "option" || typeStr == "#option" ) 601 else if ( typeStr == "option" )
570 type = OConfItem::Option; 602 type = OConfItem::Option;
571 else if ( typeStr == "arch" || typeStr == "#arch" ) 603 else if ( typeStr == "arch" )
572 type = OConfItem::Arch; 604 type = OConfItem::Arch;
605 else if ( typeStr == "lists_dir" )
606 {
607 type = OConfItem::Other;
608 features = name;
609 name = typeStr;
610 }
573 else 611 else
574 type = OConfItem::NotDefined; 612 recognizedOption = false;
575 ++pos;
576 int endpos = line.find( ' ', pos );
577
578 // Name
579 QString name = line.mid( pos, endpos - pos );
580
581 // Value
582 QString value = "";
583 if ( endpos > -1 )
584 value = line.right( line.length() - endpos - 1 );
585
586 // Active
587 bool active = !line.startsWith( "#" );
588 613
589 // Add to list 614 // Add to list
615 if ( recognizedOption )
590 m_confInfo->append( new OConfItem( type, name, value, features, active ) ); 616 m_confInfo->append( new OConfItem( type, name, value, features, active ) );
591 } 617 }
592 } 618 }
593 }
594 619
595 f.close(); 620 f.close();