-rw-r--r-- | noncore/settings/packagemanager/oconfitem.cpp | 47 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oconfitem.h | 14 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 17 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkgconfigdlg.cpp | 15 |
4 files changed, 57 insertions, 36 deletions
diff --git a/noncore/settings/packagemanager/oconfitem.cpp b/noncore/settings/packagemanager/oconfitem.cpp index a90730c..ffa936e 100644 --- a/noncore/settings/packagemanager/oconfitem.cpp +++ b/noncore/settings/packagemanager/oconfitem.cpp @@ -1,41 +1,42 @@ /* - This file is part of the Opie Project + This file is part of the Opie Project - Copyright (c) 2003 Dan Williams <drw@handhelds.org> + Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. - .>+-= - _;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. - : = ...= . :.=- - -. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + .>+-= +_;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. +: = ...= . :.=- +-. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "oconfitem.h" -OConfItem::OConfItem( Type type, const QString &name, - const QString &value, bool active ) +OConfItem::OConfItem( Type type, const QString &name, const QString &value, + const QString &features, bool active ) : m_type( type ) , m_name( name ) , m_value( value ) + , m_features( features ) , m_active( active ) { } diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index 7c158c9..9972c00 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h @@ -1,92 +1,96 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OCONFITEM_H #define OCONFITEM_H #include <qlist.h> #include <qstring.h> class OConfItem { public: enum Type { Source, Destination, Option, Arch, NotDefined }; OConfItem( Type type = NotDefined, const QString &name = QString::null, - const QString &value = QString::null, bool active = true ); + const QString &value = QString::null, const QString &features = QString::null, + bool active = true ); Type type() { return m_type; } const QString &name() { return m_name; } const QString &value() { return m_value; } + const QString &features() { return m_features; } bool active() { return m_active; } - void setType( Type type ) { m_type = type; } - void setName( const QString &name ) { m_name = name; } - void setValue( const QString &value ) { m_value = value; } - void setActive( bool active ) { m_active = active; } + void setType( Type type ) { m_type = type; } + void setName( const QString &name ) { m_name = name; } + void setValue( const QString &value ) { m_value = value; } + void setFeatures( const QString &features ) { m_features = features; } + void setActive( bool active ) { m_active = active; } private: Type m_type; // Type of configuration item QString m_name; // Name of item QString m_value; // Value of item + QString m_features; // Comma-deliminated list of features this item supports bool m_active; // Indicates whether item is currently active }; class OConfItemList : public QList<OConfItem> { private: int compareItems( QCollection::Item item1, QCollection::Item item2 ) { // Sort by OConfItem location then by type OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); if ( type1 < type2 ) return -1; else if ( type1 == type2 ) { QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); if ( name1 < name2 ) return -1; else if ( name1 == name2 ) return 0; else /*if ( name1 > name2 )*/ return 1; } else /*if ( type1 > type2 )*/ return 1; } }; typedef QListIterator<OConfItem> OConfItemListIterator; #endif diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index b0cc94d..a66bd51 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp @@ -108,97 +108,104 @@ OConfItemList *OIpkg::configItems() } OConfItemList *OIpkg::servers() { // Retrieve only servers return filterConfItems( OConfItem::Source ); } OConfItemList *OIpkg::destinations() { // Retrieve only destinations return filterConfItems( OConfItem::Destination ); } OConfItemList *OIpkg::options() { // Retrieve only destinations return filterConfItems( OConfItem::Option ); } void OIpkg::setConfigItems( OConfItemList *configList ) { if ( m_confInfo ) delete m_confInfo; m_confInfo = configList; // Write out new /etc/ipkg.conf QFile confFile( IPKG_CONF ); if ( confFile.open( IO_WriteOnly ) ) { QTextStream confStream( &confFile ); confStream << "# Generated by Opie Package Manager\n\n"; OConfItemListIterator it( *m_confInfo ); for ( ; it.current(); ++it ) { OConfItem *item = it.current(); // Only write out valid conf items if ( item->type() != OConfItem::NotDefined ) { QString confLine; if ( !item->active() ) confLine = "#"; switch ( item->type() ) { - case OConfItem::Source : confLine.append( "src " ); break; + case OConfItem::Source : + { + if ( item->features().contains( "Compressed" ) ) + confLine.append( "src/gz " ); + else + confLine.append( "src " ); + } + break; case OConfItem::Destination : confLine.append( "dest " ); break; case OConfItem::Option : confLine.append( "option " ); break; case OConfItem::Arch : confLine.append( "arch " ); break; default : break; }; confStream << confLine << " " << item->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() @@ -463,116 +470,122 @@ 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; 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 ) ) { QTextStream s( &f ); while ( !s.eof() ) { QString line = s.readLine().simplifyWhiteSpace(); // 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" ) ) { int pos = line.find( ' ', 1 ); // Type QString typeStr = line.left( pos ); OConfItem::Type type; + QString features; if ( typeStr == "src" || typeStr == "#src" ) type = OConfItem::Source; + else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) + { + type = OConfItem::Source; + features = "Compressed"; + } 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 ) ); + 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; } diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index 886430f..d9a67f3 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp @@ -56,107 +56,109 @@ OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *paren , m_destCurrent( -1 ) , m_layout( this, 2, 4 ) , m_tabWidget( this ) { setCaption( tr( "Configuration" ) ); // Initialize configuration widgets if ( !installOptions ) { initServerWidget(); initDestinationWidget(); initProxyWidget(); } 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 = 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(), m_proxyHttpActive->isChecked() ) ); + m_proxyHttpServer->text(), QString::null, + m_proxyHttpActive->isChecked() ) ); confItem = 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(), m_proxyFtpActive->isChecked() ) ); + m_proxyFtpServer->text(), QString::null, + m_proxyFtpActive->isChecked() ) ); confItem = 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 = 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() ) ); 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 ); @@ -490,151 +492,152 @@ void OIpkgConfigDlg::slotServerNew() m_serverName->setFocus(); } void OIpkgConfigDlg::slotServerDelete() { // Find selected server in list OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); // Delete server if ( server ) { m_configs->removeRef( server ); m_serverList->removeItem( m_serverCurrent ); } } void OIpkgConfigDlg::slotServerUpdate() { QString newName = m_serverName->text(); // Convert any spaces to underscores newName.replace( QRegExp( " " ), "_" ); if ( !m_serverNew ) { // Find selected server in list OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName ); // Delete server if ( server ) { // Update url server->setValue( m_serverLocation->text() ); server->setActive( m_serverActive->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( m_serverCurrName != newName ) { // Update server name server->setName( newName ); // Update list box m_serverList->changeItem( newName, m_serverCurrent ); } } } else { - // Add new destination to configuration list - m_configs->append( new OConfItem( OConfItem::Source, newName, - m_serverLocation->text(), m_serverActive->isChecked() ) ); + // Add new server to configuration list + // TODO - support src/gz + m_configs->append( new OConfItem( OConfItem::Source, newName, m_serverLocation->text(), + QString::null, m_serverActive->isChecked() ) ); m_configs->sort(); m_serverList->insertItem( newName ); m_serverList->setCurrentItem( m_serverList->count() ); m_serverNew = false; } } void OIpkgConfigDlg::slotDestEdit( int index ) { m_destNew = false; m_destCurrent = index; // Find selected destination in list OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); // Display destination details if ( destination ) { m_destCurrName = destination->name(); m_destName->setText( destination->name() ); m_destLocation->setText( destination->value() ); m_destActive->setChecked( destination->active() ); m_destName->setFocus(); } } void OIpkgConfigDlg::slotDestNew() { m_destNew = true; m_destName->setText( QString::null ); m_destLocation->setText( QString::null ); m_destActive->setChecked( true ); m_destName->setFocus(); } void OIpkgConfigDlg::slotDestDelete() { // Find selected destination in list OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); // Delete destination if ( destination ) { m_configs->removeRef( destination ); m_destList->removeItem( m_destCurrent ); } } void OIpkgConfigDlg::slotDestSelectPath() { QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() ); if ( path.at( path.length() - 1 ) == '/' ) path.truncate( path.length() - 1 ); m_destLocation->setText( path ); } void OIpkgConfigDlg::slotDestUpdate() { QString newName = m_destName->text(); // Convert any spaces to underscores newName.replace( QRegExp( " " ), "_" ); if ( !m_destNew ) { // Find selected destination in list OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); // Display destination details if ( destination ) { // Update url destination->setValue( m_destLocation->text() ); destination->setActive( m_destActive->isChecked() ); // Check if destination name has changed, if it has then we need to replace the key in the map if ( m_destCurrName != newName ) { // Update destination name destination->setName( newName ); // Update list box m_destList->changeItem( newName, m_destCurrent ); } } } else { // Add new destination to configuration list m_configs->append( new OConfItem( OConfItem::Destination, newName, - m_destLocation->text(), m_destActive->isChecked() ) ); + m_destLocation->text(), QString::null, m_destActive->isChecked() ) ); m_configs->sort(); m_destList->insertItem( newName ); m_destList->setCurrentItem( m_destList->count() ); m_destNew = false; } } |