summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/oipkg.cpp
authordrw <drw>2005-02-22 22:25:39 (UTC)
committer drw <drw>2005-02-22 22:25:39 (UTC)
commit504c5f59c082106028e3dbc9126d7b655908224f (patch) (unidiff)
tree2cf4465cb2a46b0d13f909d073225585ad4e5092 /noncore/settings/packagemanager/oipkg.cpp
parenta2eea1c6273acd16fed2406493923c52fba19ebc (diff)
downloadopie-504c5f59c082106028e3dbc9126d7b655908224f.zip
opie-504c5f59c082106028e3dbc9126d7b655908224f.tar.gz
opie-504c5f59c082106028e3dbc9126d7b655908224f.tar.bz2
Add support for lists_dir ipkg configuration option, optimize ipkg configuration file read routine, update version to 0.6.2
Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp117
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
@@ -152,6 +152,7 @@ void OIpkg::setConfigItems( OConfItemList *configList )
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
@@ -160,18 +161,28 @@ void OIpkg::setConfigItems( OConfItemList *configList )
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
@@ -545,50 +556,64 @@ void OIpkg::loadConfiguration()
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