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.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 3d2c621..417ee95 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -198,98 +198,106 @@ void OIpkg::setConfigItems( OConfItemList *configList )
198 QStringList confFiles; 198 QStringList confFiles;
199 QDir confDir( IPKG_CONF_DIR ); 199 QDir confDir( IPKG_CONF_DIR );
200 if ( confDir.exists() ) 200 if ( confDir.exists() )
201 { 201 {
202 confDir.setNameFilter( "*.conf" ); 202 confDir.setNameFilter( "*.conf" );
203 confDir.setFilter( QDir::Files ); 203 confDir.setFilter( QDir::Files );
204 confFiles = confDir.entryList( "*.conf", QDir::Files ); 204 confFiles = confDir.entryList( "*.conf", QDir::Files );
205 205
206 QStringList::Iterator lastFile = confFiles.end(); 206 QStringList::Iterator lastFile = confFiles.end();
207 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 207 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
208 { 208 {
209 // Create absolute file path if necessary 209 // Create absolute file path if necessary
210 QString absFile = (*it); 210 QString absFile = (*it);
211 if ( !absFile.startsWith( "/" ) ) 211 if ( !absFile.startsWith( "/" ) )
212 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 212 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
213 213
214 // Delete file 214 // Delete file
215 QFile::remove( absFile ); 215 QFile::remove( absFile );
216 } 216 }
217 } 217 }
218 218
219 // Reinitialize libipkg to pick up new configuration 219 // Reinitialize libipkg to pick up new configuration
220 ipkg_deinit( &m_ipkgArgs ); 220 ipkg_deinit( &m_ipkgArgs );
221 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 221 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
222 m_ipkgArgs.noaction = false; 222 m_ipkgArgs.noaction = false;
223 m_ipkgArgs.force_defaults = true; 223 m_ipkgArgs.force_defaults = true;
224} 224}
225 225
226void OIpkg::saveSettings() 226void OIpkg::saveSettings()
227{ 227{
228 // Save Ipkg execution options to application configuration file 228 // Save Ipkg execution options to application configuration file
229 if ( m_config ) 229 if ( m_config )
230 { 230 {
231 m_config->setGroup( "Ipkg" ); 231 m_config->setGroup( "Ipkg" );
232 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 232 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
233 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 233 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
234 } 234 }
235} 235}
236 236
237OPackageList *OIpkg::availablePackages( const QString &server ) 237OPackageList *OIpkg::availablePackages( const QString &server )
238{ 238{
239 // Load Ipkg configuration info if not already cached 239 // Load Ipkg configuration info if not already cached
240 if ( !m_confInfo ) 240 if ( !m_confInfo )
241 loadConfiguration(); 241 loadConfiguration();
242 242
243 // Build new server list (caller is responsible for deleting) 243 // Build new server list (caller is responsible for deleting)
244 OPackageList *pl = new OPackageList; 244 OPackageList *pl = new OPackageList;
245 245
246 // Get directory where server lists are located
247 QString listsDir;
248 OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" );
249 if ( confItem )
250 listsDir = confItem->value();
251 else
252 listsDir = IPKG_PKG_PATH;
253
246 // Open package list file 254 // Open package list file
247 QFile f( IPKG_PKG_PATH + "/" + server ); 255 QFile f( listsDir + "/" + server );
248 if ( !f.open( IO_ReadOnly ) ) 256 if ( !f.open( IO_ReadOnly ) )
249 return NULL; 257 return NULL;
250 QTextStream t( &f ); 258 QTextStream t( &f );
251 259
252 // Process all information in package list file 260 // Process all information in package list file
253 OPackage *package = NULL; 261 OPackage *package = NULL;
254 QString line = t.readLine(); 262 QString line = t.readLine();
255 while ( !t.eof() ) 263 while ( !t.eof() )
256 { 264 {
257 // Determine key/value pair 265 // Determine key/value pair
258 int pos = line.find( ':', 0 ); 266 int pos = line.find( ':', 0 );
259 QString key; 267 QString key;
260 if ( pos > -1 ) 268 if ( pos > -1 )
261 key = line.mid( 0, pos ); 269 key = line.mid( 0, pos );
262 else 270 else
263 key = QString::null; 271 key = QString::null;
264 QString value = line.mid( pos+2, line.length()-pos ); 272 QString value = line.mid( pos+2, line.length()-pos );
265 273
266 // Allocate new package and insert into list 274 // Allocate new package and insert into list
267 if ( package == NULL && !key.isEmpty() ) 275 if ( package == NULL && !key.isEmpty() )
268 { 276 {
269 package = new OPackage( value ); 277 package = new OPackage( value );
270 package->setSource( server ); 278 package->setSource( server );
271 pl->append( package ); 279 pl->append( package );
272 } 280 }
273 281
274 // Update package data 282 // Update package data
275 if ( key == "Package" ) 283 if ( key == "Package" )
276 package->setName( value ); 284 package->setName( value );
277 else if ( key == "Version" ) 285 else if ( key == "Version" )
278 package->setVersion( value ); 286 package->setVersion( value );
279 else if ( key == "Section" ) 287 else if ( key == "Section" )
280 package->setCategory( value ); 288 package->setCategory( value );
281 //DataManager::setAvailableCategories( value ); 289 //DataManager::setAvailableCategories( value );
282 else if ( key.isEmpty() && value.isEmpty() ) 290 else if ( key.isEmpty() && value.isEmpty() )
283 package = NULL; 291 package = NULL;
284 292
285 // Skip past all description lines 293 // Skip past all description lines
286 if ( key == "Description" ) 294 if ( key == "Description" )
287 { 295 {
288 line = t.readLine(); 296 line = t.readLine();
289 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 297 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
290 line = t.readLine(); 298 line = t.readLine();
291 } 299 }
292 else 300 else
293 line = t.readLine(); 301 line = t.readLine();
294 } 302 }
295 303
@@ -562,96 +570,100 @@ void OIpkg::loadConfiguration()
562 { 570 {
563 line.remove( 0, 1 ); 571 line.remove( 0, 1 );
564 line = line.simplifyWhiteSpace(); 572 line = line.simplifyWhiteSpace();
565 comment = true; 573 comment = true;
566 } 574 }
567 575
568 bool recognizedOption = true; 576 bool recognizedOption = true;
569 int pos = line.find( ' ', 1 ) + 1; 577 int pos = line.find( ' ', 1 ) + 1;
570 int endpos = line.find( ' ', pos ); 578 int endpos = line.find( ' ', pos );
571 579
572 // Name 580 // Name
573 QString name = line.mid( pos, endpos - pos ); 581 QString name = line.mid( pos, endpos - pos );
574 582
575 // Value 583 // Value
576 QString value = ""; 584 QString value = "";
577 if ( endpos > -1 ) 585 if ( endpos > -1 )
578 value = line.right( line.length() - endpos - 1 ); 586 value = line.right( line.length() - endpos - 1 );
579 587
580 // Active 588 // Active
581 bool active = !comment; 589 bool active = !comment;
582 590
583 // Type 591 // Type
584 // For options w/type = Other, the mapping is as follows: 592 // For options w/type = Other, the mapping is as follows:
585 // name = typeStr (e.g. "lists_dir") 593 // name = typeStr (e.g. "lists_dir")
586 // value = value 594 // value = value
587 // features = name (from configuration file) 595 // features = name (from configuration file)
588 596
589 QString typeStr = line.left( pos - 1 ); 597 QString typeStr = line.left( pos - 1 );
590 OConfItem::Type type; 598 OConfItem::Type type;
591 QString features; 599 QString features;
592 if ( typeStr == "src" ) 600 if ( typeStr == "src" )
593 type = OConfItem::Source; 601 type = OConfItem::Source;
594 else if ( typeStr == "src/gz" ) 602 else if ( typeStr == "src/gz" )
595 { 603 {
596 type = OConfItem::Source; 604 type = OConfItem::Source;
597 features = "Compressed"; 605 features = "Compressed";
598 } 606 }
599 else if ( typeStr == "dest" ) 607 else if ( typeStr == "dest" )
600 type = OConfItem::Destination; 608 type = OConfItem::Destination;
601 else if ( typeStr == "option" ) 609 else if ( typeStr == "option" )
602 type = OConfItem::Option; 610 type = OConfItem::Option;
603 else if ( typeStr == "arch" ) 611 else if ( typeStr == "arch" )
604 type = OConfItem::Arch; 612 type = OConfItem::Arch;
605 else if ( typeStr == "lists_dir" ) 613 else if ( typeStr == "lists_dir" )
606 { 614 {
607 type = OConfItem::Other; 615 type = OConfItem::Other;
608 features = name; 616 features = name;
609 name = typeStr; 617 name = typeStr;
618
619 // Default value when not defined
620 if ( value == QString::null || value == "" )
621 value = IPKG_PKG_PATH;
610 } 622 }
611 else 623 else
612 recognizedOption = false; 624 recognizedOption = false;
613 625
614 // Add to list 626 // Add to list
615 if ( recognizedOption ) 627 if ( recognizedOption )
616 m_confInfo->append( new OConfItem( type, name, value, features, active ) ); 628 m_confInfo->append( new OConfItem( type, name, value, features, active ) );
617 } 629 }
618 } 630 }
619 631
620 f.close(); 632 f.close();
621 } 633 }
622 } 634 }
623 635
624 // Load Ipkg execution options from application configuration file 636 // Load Ipkg execution options from application configuration file
625 if ( m_config ) 637 if ( m_config )
626 { 638 {
627 m_config->setGroup( "Ipkg" ); 639 m_config->setGroup( "Ipkg" );
628 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 640 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
629 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 641 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
630 } 642 }
631} 643}
632 644
633OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 645OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
634{ 646{
635 // Load Ipkg configuration info if not already cached 647 // Load Ipkg configuration info if not already cached
636 if ( !m_confInfo ) 648 if ( !m_confInfo )
637 loadConfiguration(); 649 loadConfiguration();
638 650
639 // Build new server list (caller is responsible for deleting) 651 // Build new server list (caller is responsible for deleting)
640 OConfItemList *sl = new OConfItemList; 652 OConfItemList *sl = new OConfItemList;
641 653
642 // If typefilter is empty, retrieve all items 654 // If typefilter is empty, retrieve all items
643 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 655 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
644 656
645 // Parse configuration info for servers 657 // Parse configuration info for servers
646 OConfItemListIterator it( *m_confInfo ); 658 OConfItemListIterator it( *m_confInfo );
647 for ( ; it.current(); ++it ) 659 for ( ; it.current(); ++it )
648 { 660 {
649 OConfItem *item = it.current(); 661 OConfItem *item = it.current();
650 if ( retrieveAll || item->type() == typefilter ) 662 if ( retrieveAll || item->type() == typefilter )
651 { 663 {
652 sl->append( item ); 664 sl->append( item );
653 } 665 }
654 } 666 }
655 667
656 return sl; 668 return sl;
657} 669}