summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oconfitem.h7
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp7
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control4
3 files changed, 5 insertions, 13 deletions
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h
index 7b52ce4..9972c00 100644
--- a/noncore/settings/packagemanager/oconfitem.h
+++ b/noncore/settings/packagemanager/oconfitem.h
@@ -1,94 +1,89 @@
/*
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=0x01,
- GzSource=0x02,
- Destination=0x04,
- Option=0x08,
- Arch=0x10,
- NotDefined=0x20 };
+ enum Type { Source, Destination, Option, Arch, NotDefined };
OConfItem( Type type = NotDefined, const QString &name = QString::null,
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 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 )*/
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index a885ef8..f2d7e39 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -69,98 +69,97 @@ int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/
oipkg->ipkgStatus( desc );
return 0;
}
int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
void */*userdata*/ )
{
oipkg->ipkgList( desc );
return 0;
}
OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
: QObject( parent, name )
, m_config( config )
, m_confInfo( NULL )
, m_ipkgExecOptions( 0 )
, m_ipkgExecVerbosity( 1 )
{
// Keep pointer to self for the Ipkg callback functions
oipkg = this;
// Initialize libipkg
ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
// Default ipkg run-time arguments
m_ipkgArgs.noaction = false;
m_ipkgArgs.force_defaults = true;
}
OIpkg::~OIpkg()
{
// Upon destruction, ensure that items in config list are deleted with list
if ( m_confInfo )
m_confInfo->setAutoDelete( true );
// Free up libipkg resources
ipkg_deinit( &m_ipkgArgs );
}
OConfItemList *OIpkg::configItems()
{
// Retrieve all configuration items
return filterConfItems();
}
OConfItemList *OIpkg::servers()
{
// Retrieve only servers
- return filterConfItems( (OConfItem::Type)((int)OConfItem::Source |
- (int)OConfItem::GzSource) );
+ 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 :
{
if ( item->features().contains( "Compressed" ) )
confLine.append( "src/gz " );
else
confLine.append( "src " );
@@ -499,174 +498,172 @@ void OIpkg::ipkgStatus( char *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;
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( "#src/gz" ) ||
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, 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 ) )
+ 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 )
{
if ( !dest.isNull() )
{
OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest );
emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) );
// Set package destination directory
QString destDir = destConfItem->value();
QString destInfoDir = destDir;
if ( destInfoDir.right( 1 ) != '/' )
destInfoDir.append( '/' );
destInfoDir.append( IPKG_INFO_PATH );
// Get list of installed packages in destination
QDir packageDir( destInfoDir );
QStringList packageFiles;
if ( packageDir.exists() )
{
packageDir.setNameFilter( "*.list" );
packageDir.setFilter( QDir::Files );
packageFiles = packageDir.entryList( "*.list", QDir::Files );
}
// Link all files for every package installed in desination
QStringList::Iterator lastFile = packageFiles.end();
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index 0153d40..da3ddfe 100644
--- a/noncore/settings/packagemanager/opie-packagemanager.control
+++ b/noncore/settings/packagemanager/opie-packagemanager.control
@@ -1,10 +1,10 @@
Package: opie-packagemanager
Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
Priority: optional
Section: opie/settings
-Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg0 (>=0.99.120), ipkg-link
+Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120)
Replaces: packagemanager
Architecture: arm
Maintainer: Dan Williams (drw@handhelds.org)
Description: Opie package management client
-Version: $QPE_VERSION$EXTRAVERSION
+Version: 0.6.1$EXTRAVERSION