author | drw <drw> | 2005-03-11 16:32:21 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-11 16:32:21 (UTC) |
commit | abcc52307706794537bb579daff1a82668ebde00 (patch) (side-by-side diff) | |
tree | 4c25d4ea425a22d0b881c79418ff5b51b829be49 | |
parent | 3dc7db665775377453f999a3eaee8c225af45a79 (diff) | |
download | opie-abcc52307706794537bb579daff1a82668ebde00.zip opie-abcc52307706794537bb579daff1a82668ebde00.tar.gz opie-abcc52307706794537bb579daff1a82668ebde00.tar.bz2 |
Fix bug where lists_dir was not being honored at startup - thanks to hrw for identifying, also provide default value for lists_dir when none is entered in the configuration dialog
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 14 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkgconfigdlg.cpp | 7 |
2 files changed, 18 insertions, 3 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 @@ -182,130 +182,138 @@ void OIpkg::setConfigItems( OConfItemList *configList ) default : break; }; confStream << confLine << " " << name << " " << item->value() << "\n"; } } confFile.close(); } else { // Problem writing to /etc/ipkg.conf, exit before removing other conf files return; } // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings QStringList confFiles; QDir confDir( IPKG_CONF_DIR ); if ( confDir.exists() ) { confDir.setNameFilter( "*.conf" ); confDir.setFilter( QDir::Files ); confFiles = confDir.entryList( "*.conf", QDir::Files ); 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 ) + "/" ); // Delete file QFile::remove( absFile ); } } // Reinitialize libipkg to pick up new configuration ipkg_deinit( &m_ipkgArgs ); ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); m_ipkgArgs.noaction = false; m_ipkgArgs.force_defaults = true; } void OIpkg::saveSettings() { // Save Ipkg execution options to application configuration file if ( m_config ) { m_config->setGroup( "Ipkg" ); m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); } } OPackageList *OIpkg::availablePackages( const QString &server ) { // Load Ipkg configuration info if not already cached if ( !m_confInfo ) loadConfiguration(); // Build new server list (caller is responsible for deleting) OPackageList *pl = new OPackageList; + // Get directory where server lists are located + QString listsDir; + OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" ); + if ( confItem ) + listsDir = confItem->value(); + else + listsDir = IPKG_PKG_PATH; + // Open package list file - QFile f( IPKG_PKG_PATH + "/" + server ); + QFile f( listsDir + "/" + server ); if ( !f.open( IO_ReadOnly ) ) return NULL; QTextStream t( &f ); // Process all information in package list file OPackage *package = NULL; QString line = t.readLine(); while ( !t.eof() ) { // Determine key/value pair int pos = line.find( ':', 0 ); QString key; if ( pos > -1 ) key = line.mid( 0, pos ); else key = QString::null; QString value = line.mid( pos+2, line.length()-pos ); // Allocate new package and insert into list if ( package == NULL && !key.isEmpty() ) { package = new OPackage( value ); package->setSource( server ); pl->append( package ); } // Update package data if ( key == "Package" ) package->setName( value ); else if ( key == "Version" ) package->setVersion( value ); else if ( key == "Section" ) package->setCategory( value ); //DataManager::setAvailableCategories( value ); else if ( key.isEmpty() && value.isEmpty() ) package = NULL; // Skip past all description lines if ( key == "Description" ) { line = t.readLine(); while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) line = t.readLine(); } else line = t.readLine(); } f.close(); return pl; } OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) { // Load Ipkg configuration info if not already cached if ( !m_confInfo ) loadConfiguration(); // Build new server list (caller is responsible for deleting) OPackageList *pl = new OPackageList; // Open status file QString path = destPath; @@ -546,128 +554,132 @@ void OIpkg::loadConfiguration() // Read in file QFile f( absFile ); if ( f.open( IO_ReadOnly ) ) { QTextStream s( &f ); while ( !s.eof() ) { QString line = s.readLine().simplifyWhiteSpace(); // Parse line and save info to the conf options list if ( !line.isEmpty() ) { // Strip leading comment marker if exists bool comment = false; if ( line.startsWith( "#" ) ) { 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 // 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" ) type = OConfItem::Source; else if ( typeStr == "src/gz" ) { type = OConfItem::Source; features = "Compressed"; } else if ( typeStr == "dest" ) type = OConfItem::Destination; else if ( typeStr == "option" ) type = OConfItem::Option; else if ( typeStr == "arch" ) type = OConfItem::Arch; else if ( typeStr == "lists_dir" ) { type = OConfItem::Other; features = name; name = typeStr; + + // Default value when not defined + if ( value == QString::null || value == "" ) + value = IPKG_PKG_PATH; } else recognizedOption = false; // Add to list if ( recognizedOption ) m_confInfo->append( new OConfItem( type, name, value, features, active ) ); } } 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; } const QString &OIpkg::rootPath() { if ( m_rootPath.isEmpty() ) { OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); rootDest ? m_rootPath = rootDest->value() : m_rootPath = '/'; if ( m_rootPath.right( 1 ) == '/' ) m_rootPath.truncate( m_rootPath.length() - 1 ); } return m_rootPath; } void OIpkg::linkPackageDir( const QString &dest ) { diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index d234251..0ad1c82 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp @@ -67,134 +67,137 @@ OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *paren } initOptionsWidget(); // Load configuration information initData(); // Setup tabs for all info m_layout.addWidget( &m_tabWidget ); if ( !m_installOptions ) { m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); m_tabWidget.setCurrentTab( tr( "Servers" ) ); } else { m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); } } void OIpkgConfigDlg::accept() { // Save server, destination and proxy configuration if ( !m_installOptions ) { // Update proxy information before saving settings OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" ); if ( confItem ) { confItem->setValue( m_proxyHttpServer->text() ); confItem->setActive( m_proxyHttpActive->isChecked() ); } else m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", m_proxyHttpServer->text(), QString::null, m_proxyHttpActive->isChecked() ) ); confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" ); if ( confItem ) { confItem->setValue( m_proxyFtpServer->text() ); confItem->setActive( m_proxyFtpActive->isChecked() ); } else m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", m_proxyFtpServer->text(), QString::null, m_proxyFtpActive->isChecked() ) ); confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" ); if ( confItem ) confItem->setValue( m_proxyUsername->text() ); else m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", m_proxyUsername->text() ) ); confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" ); if ( confItem ) confItem->setValue( m_proxyPassword->text() ); else m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", m_proxyPassword->text() ) ); + QString listsDir = m_optSourceLists->text(); + if ( listsDir == QString::null || listsDir == "" ) + listsDir = "/usr/lib/ipkg/lists"; // TODO - use proper libipkg define confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" ); if ( confItem ) - confItem->setValue( m_optSourceLists->text() ); + confItem->setValue( listsDir ); else m_configs->append( new OConfItem( OConfItem::Other, "lists_dir", - m_optSourceLists->text(), "name" ) ); + listsDir, "name" ) ); m_ipkg->setConfigItems( m_configs ); } // Save options configuration int options = 0; if ( m_optForceDepends->isChecked() ) options |= FORCE_DEPENDS; if ( m_optForceReinstall->isChecked() ) options |= FORCE_REINSTALL; if ( m_optForceRemove->isChecked() ) options |= FORCE_REMOVE; if ( m_optForceOverwrite->isChecked() ) options |= FORCE_OVERWRITE; m_ipkg->setIpkgExecOptions( options ); m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); QDialog::accept(); } void OIpkgConfigDlg::reject() { if ( m_configs ) delete m_configs; } void OIpkgConfigDlg::initServerWidget() { m_serverWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); QScrollView *sv = new QScrollView( m_serverWidget ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); m_serverList = new QListBox( container ); QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); QPixmap pic; pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); btn->setMinimumHeight( AppLnk::smallIconSize() ); QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); layout->addWidget( btn, 1, 0 ); pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_serverEditBtn = new QPushButton( pic, tr( "Edit" ), container ); m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); m_serverEditBtn->setEnabled( false ); QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); layout->addWidget( m_serverEditBtn, 1, 1 ); pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_serverDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); |