summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/oipkg.cpp
Side-by-side diff
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
@@ -152,6 +152,7 @@ void OIpkg::setConfigItems( OConfItemList *configList )
if ( item->type() != OConfItem::NotDefined )
{
QString confLine;
+ QString name = item->name();
if ( !item->active() )
confLine = "#";
@@ -168,10 +169,20 @@ void OIpkg::setConfigItems( OConfItemList *configList )
case OConfItem::Destination : confLine.append( "dest " ); break;
case OConfItem::Option : confLine.append( "option " ); break;
case OConfItem::Arch : confLine.append( "arch " ); break;
+ case OConfItem::Other :
+ {
+ // For options w/type = Other, the mapping is as follows:
+ // name = typeStr (e.g. "lists_dir")
+ // value = value
+ // features = name (from configuration file)
+ confLine.append( item->name() );
+ name = item->features();
+ }
+ break;
default : break;
};
- confStream << confLine << " " << item->name() << " " << item->value() << "\n";
+ confStream << confLine << " " << name << " " << item->value() << "\n";
}
}
@@ -545,52 +556,66 @@ void OIpkg::loadConfiguration()
// Parse line and save info to the conf options list
if ( !line.isEmpty() )
{
- if ( !line.startsWith( "#" ) ||
- line.startsWith( "#src" ) ||
- line.startsWith( "#dest" ) ||
- line.startsWith( "#arch" ) ||
- line.startsWith( "#option" ) )
+ // Strip leading comment marker if exists
+ bool comment = false;
+ if ( line.startsWith( "#" ) )
{
- int pos = line.find( ' ', 1 );
+ line.remove( 0, 1 );
+ line = line.simplifyWhiteSpace();
+ comment = true;
+ }
+
+ bool recognizedOption = true;
+ int pos = line.find( ' ', 1 ) + 1;
+ int endpos = line.find( ' ', pos );
+
+ // Name
+ QString name = line.mid( pos, endpos - pos );
+
+ // Value
+ QString value = "";
+ if ( endpos > -1 )
+ value = line.right( line.length() - endpos - 1 );
+
+ // Active
+ bool active = !comment;
// Type
- QString typeStr = line.left( pos );
+ // For options w/type = Other, the mapping is as follows:
+ // name = typeStr (e.g. "lists_dir")
+ // value = value
+ // features = name (from configuration file)
+
+ QString typeStr = line.left( pos - 1 );
OConfItem::Type type;
QString features;
- if ( typeStr == "src" || typeStr == "#src" )
+ if ( typeStr == "src" )
type = OConfItem::Source;
- else if ( typeStr == "src/gz" || typeStr == "#src/gz" )
+ else if ( typeStr == "src/gz" )
{
type = OConfItem::Source;
features = "Compressed";
}
- else if ( typeStr == "dest" || typeStr == "#dest" )
+ else if ( typeStr == "dest" )
type = OConfItem::Destination;
- else if ( typeStr == "option" || typeStr == "#option" )
+ else if ( typeStr == "option" )
type = OConfItem::Option;
- else if ( typeStr == "arch" || typeStr == "#arch" )
+ else if ( typeStr == "arch" )
type = OConfItem::Arch;
+ else if ( typeStr == "lists_dir" )
+ {
+ type = OConfItem::Other;
+ features = name;
+ name = typeStr;
+ }
else
- type = OConfItem::NotDefined;
- ++pos;
- int endpos = line.find( ' ', pos );
-
- // Name
- QString name = line.mid( pos, endpos - pos );
-
- // Value
- QString value = "";
- if ( endpos > -1 )
- value = line.right( line.length() - endpos - 1 );
-
- // Active
- bool active = !line.startsWith( "#" );
+ recognizedOption = false;
// Add to list
+ if ( recognizedOption )
m_confInfo->append( new OConfItem( type, name, value, features, active ) );
}
}
- }
f.close();
}