-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 87a30bb..eca5861 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp @@ -424,151 +424,151 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, }; break; case OPackage::Info : { connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); }; break; case OPackage::Files : { connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); }; break; default : break; }; return true; } void OIpkg::ipkgMessage( char *msg ) { emit signalIpkgMessage( msg ); } void OIpkg::ipkgStatus( char *status ) { emit signalIpkgStatus( status ); } void OIpkg::ipkgList( char *filelist ) { emit signalIpkgList( filelist ); } void OIpkg::loadConfiguration() { if ( m_confInfo ) delete m_confInfo; // Load configuration item list m_confInfo = new OConfItemList(); QStringList confFiles; QDir confDir( IPKG_CONF_DIR ); if ( confDir.exists() ) { confDir.setNameFilter( "*.conf" ); confDir.setFilter( QDir::Files ); confFiles = confDir.entryList( "*.conf", QDir::Files ); - confFiles << IPKG_CONF; + } + confFiles << IPKG_CONF; - QStringList::Iterator lastFile = confFiles.end(); - for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) + QStringList::Iterator lastFile = confFiles.end(); + for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) + { + // Create absolute file path if necessary + QString absFile = (*it); + if ( !absFile.startsWith( "/" ) ) + absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); + + // Read in file + QFile f( absFile ); + if ( f.open( IO_ReadOnly ) ) { - // Create absolute file path if necessary - QString absFile = (*it); - if ( !absFile.startsWith( "/" ) ) - absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); - - // Read in file - QFile f( absFile ); - if ( f.open( IO_ReadOnly ) ) + QTextStream s( &f ); + while ( !s.eof() ) { - QTextStream s( &f ); - while ( !s.eof() ) - { - QString line = s.readLine().simplifyWhiteSpace(); + QString line = s.readLine().simplifyWhiteSpace(); - // Parse line and save info to the conf options list - if ( !line.isEmpty() ) + // 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" ) ) { - if ( !line.startsWith( "#" ) || - line.startsWith( "#src" ) || - line.startsWith( "#dest" ) || - line.startsWith( "#arch" ) || - line.startsWith( "#option" ) ) - { - int pos = line.find( ' ', 1 ); - - // Type - QString typeStr = line.left( pos ); - OConfItem::Type type; - if ( typeStr == "src" || typeStr == "#src" ) - type = OConfItem::Source; - else if ( typeStr == "dest" || typeStr == "#dest" ) - type = OConfItem::Destination; - else if ( typeStr == "option" || typeStr == "#option" ) - type = OConfItem::Option; - else if ( typeStr == "arch" || typeStr == "#arch" ) - type = OConfItem::Arch; - 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( "#" ); - - // Add to list - m_confInfo->append( new OConfItem( type, name, value, active ) ); - } + int pos = line.find( ' ', 1 ); + + // Type + QString typeStr = line.left( pos ); + OConfItem::Type type; + if ( typeStr == "src" || typeStr == "#src" ) + type = OConfItem::Source; + else if ( typeStr == "dest" || typeStr == "#dest" ) + type = OConfItem::Destination; + else if ( typeStr == "option" || typeStr == "#option" ) + type = OConfItem::Option; + else if ( typeStr == "arch" || typeStr == "#arch" ) + type = OConfItem::Arch; + 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( "#" ); + + // Add to list + m_confInfo->append( new OConfItem( type, name, value, active ) ); } } - - f.close(); } + + f.close(); } } // Load Ipkg execution options from application configuration file if ( m_config ) { m_config->setGroup( "Ipkg" ); m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); } } OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) { // Load Ipkg configuration info if not already cached if ( !m_confInfo ) loadConfiguration(); // Build new server list (caller is responsible for deleting) OConfItemList *sl = new OConfItemList; // If typefilter is empty, retrieve all items bool retrieveAll = ( typefilter == OConfItem::NotDefined ); // Parse configuration info for servers OConfItemListIterator it( *m_confInfo ); for ( ; it.current(); ++it ) { OConfItem *item = it.current(); if ( retrieveAll || item->type() == typefilter ) { sl->append( item ); } } return sl; } |