Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 81 |
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 | |||
@@ -149,12 +149,13 @@ void OIpkg::setConfigItems( OConfItemList *configList ) | |||
149 | OConfItem *item = it.current(); | 149 | OConfItem *item = it.current(); |
150 | 150 | ||
151 | // Only write out valid conf items | 151 | // Only write out valid conf items |
152 | if ( item->type() != OConfItem::NotDefined ) | 152 | if ( item->type() != OConfItem::NotDefined ) |
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 = "#"; |
157 | 158 | ||
158 | switch ( item->type() ) | 159 | switch ( item->type() ) |
159 | { | 160 | { |
160 | case OConfItem::Source : | 161 | case OConfItem::Source : |
@@ -165,16 +166,26 @@ void OIpkg::setConfigItems( OConfItemList *configList ) | |||
165 | confLine.append( "src " ); | 166 | confLine.append( "src " ); |
166 | } | 167 | } |
167 | break; | 168 | break; |
168 | case OConfItem::Destination : confLine.append( "dest " ); break; | 169 | case OConfItem::Destination : confLine.append( "dest " ); break; |
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 | } |
177 | 188 | ||
178 | confFile.close(); | 189 | confFile.close(); |
179 | } | 190 | } |
180 | else | 191 | else |
@@ -542,58 +553,72 @@ void OIpkg::loadConfiguration() | |||
542 | 553 | ||
543 | QString line = s.readLine().simplifyWhiteSpace(); | 554 | QString line = s.readLine().simplifyWhiteSpace(); |
544 | 555 | ||
545 | // Parse line and save info to the conf options list | 556 | // Parse line and save info to the conf options list |
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(); |
596 | } | 621 | } |
597 | } | 622 | } |
598 | 623 | ||
599 | // Load Ipkg execution options from application configuration file | 624 | // Load Ipkg execution options from application configuration file |