Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 117 |
1 files changed, 71 insertions, 46 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,32 +149,43 @@ 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 : |
161 | { | 162 | { |
162 | if ( item->features().contains( "Compressed" ) ) | 163 | if ( item->features().contains( "Compressed" ) ) |
163 | confLine.append( "src/gz " ); | 164 | confLine.append( "src/gz" ); |
164 | else | 165 | else |
165 | confLine.append( "src " ); | 166 | confLine.append( "src" ); |
167 | } | ||
168 | break; | ||
169 | case OConfItem::Destination : confLine.append( "dest" ); break; | ||
170 | case OConfItem::Option : confLine.append( "option" ); 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(); | ||
166 | } | 180 | } |
167 | break; | 181 | break; |
168 | case OConfItem::Destination : confLine.append( "dest " ); break; | ||
169 | case OConfItem::Option : confLine.append( "option " ); break; | ||
170 | case OConfItem::Arch : confLine.append( "arch " ); 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,56 +553,70 @@ 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 ); |
555 | 564 | line = line.simplifyWhiteSpace(); | |
556 | // Type | 565 | comment = true; |
557 | QString typeStr = line.left( pos ); | 566 | } |
558 | OConfItem::Type type; | ||
559 | QString features; | ||
560 | if ( typeStr == "src" || typeStr == "#src" ) | ||
561 | type = OConfItem::Source; | ||
562 | else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) | ||
563 | { | ||
564 | type = OConfItem::Source; | ||
565 | features = "Compressed"; | ||
566 | } | ||
567 | else if ( typeStr == "dest" || typeStr == "#dest" ) | ||
568 | type = OConfItem::Destination; | ||
569 | else if ( typeStr == "option" || typeStr == "#option" ) | ||
570 | type = OConfItem::Option; | ||
571 | else if ( typeStr == "arch" || typeStr == "#arch" ) | ||
572 | type = OConfItem::Arch; | ||
573 | else | ||
574 | type = OConfItem::NotDefined; | ||
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 | 567 | ||
586 | // Active | 568 | bool recognizedOption = true; |
587 | bool active = !line.startsWith( "#" ); | 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; | ||
582 | |||
583 | // Type | ||
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 ); | ||
590 | OConfItem::Type type; | ||
591 | QString features; | ||
592 | if ( typeStr == "src" ) | ||
593 | type = OConfItem::Source; | ||
594 | else if ( typeStr == "src/gz" ) | ||
595 | { | ||
596 | type = OConfItem::Source; | ||
597 | features = "Compressed"; | ||
598 | } | ||
599 | else if ( typeStr == "dest" ) | ||
600 | type = OConfItem::Destination; | ||
601 | else if ( typeStr == "option" ) | ||
602 | type = OConfItem::Option; | ||
603 | else if ( typeStr == "arch" ) | ||
604 | type = OConfItem::Arch; | ||
605 | else if ( typeStr == "lists_dir" ) | ||
606 | { | ||
607 | type = OConfItem::Other; | ||
608 | features = name; | ||
609 | name = typeStr; | ||
610 | } | ||
611 | else | ||
612 | recognizedOption = false; | ||
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 | } | ||
592 | } | 617 | } |
593 | } | 618 | } |
594 | 619 | ||
595 | f.close(); | 620 | f.close(); |
596 | } | 621 | } |
597 | } | 622 | } |