summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/.cvsignore2
-rw-r--r--noncore/settings/packagemanager/ChangeLog7
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp72
-rw-r--r--noncore/settings/packagemanager/installdlg.h4
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp2
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp186
-rw-r--r--noncore/settings/packagemanager/oipkg.h17
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp11
-rw-r--r--noncore/settings/packagemanager/opackagemanager.h4
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control2
-rw-r--r--noncore/settings/packagemanager/packagemanager.pro9
11 files changed, 130 insertions, 186 deletions
diff --git a/noncore/settings/packagemanager/.cvsignore b/noncore/settings/packagemanager/.cvsignore
index 4183697..9f2b524 100644
--- a/noncore/settings/packagemanager/.cvsignore
+++ b/noncore/settings/packagemanager/.cvsignore
@@ -1,3 +1,5 @@
Makefile*
moc*
.moc*
+.obj
+.moc
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index a01c8b3..1ba12af 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,4 +1,9 @@
-2004-01-nn Dan Williams <drw@handhelds.org>
+2004-01-20 Dan Williams <drw@handhelds.org>
+
+ * Released version 0.2.0
+ * Converted to use libipkg in place of spawning ipkg process
+
+2004-01-13 Dan Williams <drw@handhelds.org>
* Released version 0.1.0
* Initial check-in of new package management client to eventually replace AQPkg
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 980d5eb..6a9ccbd 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -203,14 +203,13 @@ void InstallDlg::slotDisplayAvailSpace( const QString &destination )
void InstallDlg::slotBtnStart()
{
QString btnText = m_btnStart->text();
if ( btnText == tr( "Abort" ) )
{
- // Stop execution of current command and prevent any others from executing
- m_packman->abortCommand();
+ // Prevent unexecuted commands from executing
m_currCommand = 999;
// Allow user to close dialog
m_btnStart->setText( tr( "Close" ) );
m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
return;
@@ -219,23 +218,43 @@ void InstallDlg::slotBtnStart()
{
// TODO - force reload of package data
emit closeInstallDlg();
return;
}
- // Start was clicked, execute first command
+ // Start was clicked, start executing
m_btnOptions->setEnabled( false );
+ if ( m_numCommands > 1 )
+ {
m_btnStart->setText( tr( "Abort" ) );
m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
+ }
+ else
+ {
+ m_btnStart->setEnabled( false );
+ }
QString dest;
if ( m_destination )
dest = m_destination->currentText();
- m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], dest, this,
- SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)),
- SLOT(slotFinished(OProcess*)), true );
+
+ for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
+ {
+ // Execute next command
+ m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
+ this, SLOT(slotOutput(char*)), true );
+ }
+
+ // All commands executed, allow user to close dialog
+ m_btnStart->setEnabled( true );
+ m_btnStart->setText( tr( "Close" ) );
+ m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
+
+ m_btnOptions->setEnabled( true );
+ m_btnOptions->setText( tr( "Save output" ) );
+ m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
}
void InstallDlg::slotBtnOptions()
{
QString btnText = m_btnOptions->text();
if ( btnText == tr( "Options" ) )
@@ -264,46 +283,17 @@ void InstallDlg::slotBtnOptions()
doc.setName( currentFileName );
FileManager fm;
fm.saveFile( doc, m_output->text() );
}
}
-void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen )
+void InstallDlg::slotOutput( char *msg )
{
- QString lineStr = buffer;
- if ( lineStr[buffLen-1] == '\n' )
- lineStr.truncate( buffLen - 1 );
- m_output->append( lineStr );
- m_output->setCursorPosition( m_output->numLines(), 0 );
-}
+ // Allow processing of other events
+ qApp->processEvents();
-void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen )
-{
- QString lineStr = buffer;
- if ( lineStr[buffLen-1] == '\n' )
- lineStr.truncate( buffLen - 1 );
+ QString lineStr = msg;
+ if ( lineStr[lineStr.length()-1] == '\n' )
+ lineStr.truncate( lineStr.length() - 1 );
m_output->append( lineStr );
m_output->setCursorPosition( m_output->numLines(), 0 );
}
-
-void InstallDlg::slotFinished( OProcess */*process*/ )
-{
- ++m_currCommand;
- if ( m_currCommand < m_numCommands )
- {
- // More commands left, execute next one
- m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(),
- this, SLOT(slotOutput(OProcess*,char*,int)),
- SLOT(slotErrors(OProcess*,char*,int)),
- SLOT(slotFinished(OProcess*)), true );
- }
- else
- {
- // All commands executed, allow user to close dialog
- m_btnStart->setText( tr( "Close" ) );
- m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
-
- m_btnOptions->setEnabled( true );
- m_btnOptions->setText( tr( "Save output" ) );
- m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
- }
-}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
index 8075f1d..7efe721 100644
--- a/noncore/settings/packagemanager/installdlg.h
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -75,15 +75,13 @@ private slots:
// UI control slots
void slotDisplayAvailSpace( const QString &destination );
void slotBtnStart();
void slotBtnOptions();
// Execution slots
- void slotOutput( OProcess *process, char *buffer, int buffLen );
- void slotErrors( OProcess *process, char *buffer, int buffLen );
- void slotFinished( OProcess *process );
+ void slotOutput( char *msg );
signals:
void closeInstallDlg();
};
#endif
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 311b5fc..4611404 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -159,13 +159,12 @@ void MainWindow::initUI()
QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
actionUpgrade->addTo( popup );
actionUpgrade->addTo( &m_toolBar );
- // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
/*
QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
@@ -368,13 +367,12 @@ void MainWindow::slotUpgrade()
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
- // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
/*
void MainWindow::slotDownload()
{
// Retrieve list of packages selected for download (if any)
QStringList *workingPackages = new QStringList();
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 13f3d7d..eeb0131 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -28,46 +28,65 @@
Boston, MA 02111-1307, USA.
*/
#include "oipkg.h"
-#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <qdir.h>
#include <qfile.h>
+#include <qmessagebox.h>
#include <qtextstream.h>
-#include <opie/oprocess.h>
-
-const QString IPKG_EXEC = "ipkg"; // Fully-qualified name of Ipkg executable
const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
+OIpkg *oipkg;
+
+int fIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg )
+{
+ oipkg->ipkgOutput( msg );
+ return 0;
+}
+
+char* fIpkgResponse( char */*question*/ )
+{
+ return 0x0;
+}
+
OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
: QObject( parent, name )
, m_config( config )
- , m_ipkgExec( IPKG_EXEC ) // TODO - find executable?
, m_confInfo( NULL )
, m_ipkgExecOptions( 0 )
, m_ipkgExecVerbosity( 1 )
- , m_ipkgProcess( NULL )
{
+ oipkg = this;
+
+ // Initialize libipkg
+ if ( ipkg_init( &fIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) )
+ QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) );
+
+ // 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 );
- // Terminate any running ipkg processes
- if ( m_ipkgProcess )
- delete m_ipkgProcess;
+ // Free up libipkg resources
+ if ( ipkg_deinit( &m_ipkgArgs ) )
+ QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) );
}
OConfItemList *OIpkg::configItems()
{
// Retrieve all configuration items
return filterConfItems();
@@ -251,142 +270,77 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString &
f.close();
return pl;
}
bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
- const QObject *receiver, const char *slotOutput, const char *slotErrors,
- const char *slotFinished, bool rawOutput )
+ const QObject *receiver, const char *slotOutput, bool rawOutput )
{
if ( command == OPackage::NotDefined )
return false;
- // Set up command line for execution
- QStringList cmdLine;
- cmdLine.append( IPKG_EXEC );
-
- QString verbosity( "-V" );
- verbosity.append( QString::number( m_ipkgExecVerbosity ) );
- cmdLine.append( verbosity );
-
- // Determine Ipkg execution options
- if ( command == OPackage::Install && destination != QString::null )
- {
- // TODO - Set destination for installs
- cmdLine.append( "-dest" );
- cmdLine.append( destination );
+ // Set ipkg run-time options/arguments
+ m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
+ m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
+ // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
+ m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
+ m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
+ if ( m_ipkgArgs.dest )
+ free( m_ipkgArgs.dest );
+ if ( !destination.isNull() )
+ {
+ int len = destination.length() + 1;
+ m_ipkgArgs.dest = (char *)malloc( len );
+ strncpy( m_ipkgArgs.dest, destination, destination.length() );
+ m_ipkgArgs.dest[ len - 1 ] = '\0';
}
+ else
+ m_ipkgArgs.dest = 0x0;
- if ( command != OPackage::Update && command != OPackage::Download )
- {
- if ( m_ipkgExecOptions & FORCE_DEPENDS )
- cmdLine.append( "-force-depends" );
- if ( m_ipkgExecOptions & FORCE_REINSTALL )
- cmdLine.append( "-force-reinstall" );
- if ( m_ipkgExecOptions & FORCE_REMOVE )
- cmdLine.append( "-force-removal-of-essential-packages" );
- if ( m_ipkgExecOptions & FORCE_OVERWRITE )
- cmdLine.append( "-force-overwrite" );
- if ( m_ipkgExecVerbosity == 3 )
- cmdLine.append( "-verbose_wget" );
-
- // TODO
- // Handle make links
- // Rules - If make links is switched on, create links to root
- // if destDir is NOT /
- /*
- if ( m_ipkgExecOptions & MAKE_LINKS )
+ // Connect output signal to widget
+ if ( rawOutput )
{
- // If destDir == / turn off make links as package is being insalled
- // to root already.
- if ( destDir == "/" )
- m_ipkgExecOptions ^= MAKE_LINKS;
+ if ( slotOutput )
+ connect( this, SIGNAL(execOutput(char *)), receiver, slotOutput );
}
- */
+ else
+ {
+ // TODO - connect to local slot and parse output before emitting execOutput
}
- QString cmd;
switch( command )
{
- case OPackage::Install: cmd = "install";
- break;
- case OPackage::Remove: cmd = "remove";
- break;
- case OPackage::Update: cmd = "update";
- break;
- case OPackage::Upgrade: cmd = "upgrade";
- break;
- case OPackage::Download: cmd = "download";
- break;
- case OPackage::Info: cmd = "info";
+ case OPackage::Update : ipkg_lists_update( &m_ipkgArgs );
break;
- case OPackage::Files: cmd = "files";
+ case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs );
break;
- //case OPackage::Version: cmd = "" );
- // break;
- default:
- break;
- };
- cmdLine.append( cmd );
-
- // TODO
- // If we are removing, reinstalling or upgrading packages and make links option is selected
- // create the links
-/*
- if ( command == Remove || command == Upgrade )
- {
- createLinks = false;
- if ( flags & MAKE_LINKS )
- {
- emit outputText( tr( "Removing symbolic links...\n" ) );
- linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
- emit outputText( QString( " " ) );
- }
- }
-*/
- // Append package list (if any) to end of command line
- if ( parameters && !parameters->isEmpty() )
- {
+ case OPackage::Install : {
for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
{
- cmdLine.append( *it );
+ ipkg_packages_install( &m_ipkgArgs, (*it) );
}
- }
-
- // Create OProcess
- if ( m_ipkgProcess )
- delete m_ipkgProcess;
- m_ipkgProcess = new OProcess( cmdLine, this );
-
- // Connect signals (if any)
- if ( receiver )
- {
- if ( rawOutput )
- {
- if ( slotOutput )
- connect( m_ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), receiver, slotOutput );
- if ( slotErrors )
- connect( m_ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), receiver, slotErrors );
- if ( slotFinished )
- connect( m_ipkgProcess, SIGNAL(processExited(OProcess*)), receiver, slotFinished );
- }
- else // !rawOutput
+ };
+ break;
+ case OPackage::Remove : {
+ for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
{
- // TODO - how should it handle partial lines? (i.e. "Installing opi", "e-aqpkg...")
- }
+ ipkg_packages_remove( &m_ipkgArgs, (*it), true );
}
+ };
+ break;
+ //case OPackage::Download : ;
+ // break;
+ default : break;
+ };
- // Run process
-printf( "Running: \'%s\'\n", cmdLine.join( " " ).latin1() );
- return m_ipkgProcess->start( OProcess::NotifyOnExit, OProcess::All );
+ return true;
}
-void OIpkg::abortCommand()
+void OIpkg::ipkgOutput( char *msg )
{
- if ( m_ipkgProcess )
- delete m_ipkgProcess;
+ emit execOutput( msg );
}
void OIpkg::loadConfiguration()
{
if ( m_confInfo )
delete m_confInfo;
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index 4065f48..824fa17 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -29,12 +29,16 @@
*/
#ifndef OIPKG_H
#define OIPKG_H
+extern "C" {
+#include <libipkg.h>
+};
+
#include <qobject.h>
#include <qpe/config.h>
#include "oconfitem.h"
#include "opackage.h"
@@ -43,13 +47,12 @@
#define FORCE_DEPENDS 0x0001
#define FORCE_REMOVE 0x0002
#define FORCE_REINSTALL 0x0004
#define FORCE_OVERWRITE 0x0008
class OConfItemList;
-class OProcess;
class OIpkg : public QObject
{
Q_OBJECT
public:
@@ -73,28 +76,26 @@ public:
OPackageList *availablePackages( const QString &server = QString::null );
OPackageList *installedPackages( const QString &destName = QString::null,
const QString &destPath = QString::null );
bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
const QString &destination = QString::null, const QObject *receiver = 0x0,
- const char *slotOutput = 0x0, const char *slotErrors = 0x0,
- const char *slotFinished = 0x0, bool rawOutput = true );
+ const char *slotOutput = 0x0, bool rawOutput = true );
void abortCommand();
+ void ipkgOutput( char *msg );
+
private:
Config *m_config; // Pointer to application configuration file
- QString m_ipkgExec; // Fully qualified path/filename of ipkg binary
+ args_t m_ipkgArgs; // libipkg configuration arguments
OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
int m_ipkgExecVerbosity; // Ipkg execution verbosity level
- OProcess *m_ipkgProcess; // Pointer to process which Ipkg will run in
void loadConfiguration();
OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
signals:
- void execOutput( OProcess *process, char *buffer, int length );
- void execErrors( OProcess *process, char *buffer, int length );
- void execFinished( OProcess *process, char *buffer, int length );
+ void execOutput( char *msg );
};
#endif
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
index 6bef918..e1c8a21 100644
--- a/noncore/settings/packagemanager/opackagemanager.cpp
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -314,17 +314,10 @@ void OPackageManager::saveSettings()
{
m_ipkg.saveSettings();
}
bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
const QString &destination, const QObject *receiver,
- const char *slotOutput, const char *slotErrors,
- const char *slotFinished, bool rawOutput )
+ const char *slotOutput, bool rawOutput )
{
- return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, slotErrors,
- slotFinished, rawOutput );
-}
-
-void OPackageManager::abortCommand()
-{
- m_ipkg.abortCommand();
+ return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
}
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h
index 5e1a30a..871af0c 100644
--- a/noncore/settings/packagemanager/opackagemanager.h
+++ b/noncore/settings/packagemanager/opackagemanager.h
@@ -69,15 +69,13 @@ public:
bool configureDlg( bool installOptions = false );
void saveSettings();
bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
const QString &destination = QString::null, const QObject *receiver = 0x0,
- const char *slotOutput = 0x0, const char *slotErrors = 0x0,
- const char *slotFinished = 0x0, bool rawOutput = true );
- void abortCommand();
+ const char *slotOutput = 0x0, bool rawOutput = true );
private:
Config *m_config; // Pointer to application configuration file
OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information
QDict<OPackage> m_packages; // Global list of available packages
QStringList m_categories; // List of all categories
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index db06761..095e3be 100644
--- a/noncore/settings/packagemanager/opie-packagemanager.control
+++ b/noncore/settings/packagemanager/opie-packagemanager.control
@@ -4,7 +4,7 @@ Priority: optional
Section: Settings
Depends: task-opie-minimal
Replaces: packagemanager
Architecture: arm
Maintainer: Dan Williams (drw@handhelds.org)
Description: Opie package management client
-Version: 0.1.0
+Version: 0.2.0
diff --git a/noncore/settings/packagemanager/packagemanager.pro b/noncore/settings/packagemanager/packagemanager.pro
index 9aa3dc6..55af13e 100644
--- a/noncore/settings/packagemanager/packagemanager.pro
+++ b/noncore/settings/packagemanager/packagemanager.pro
@@ -1,7 +1,10 @@
CONFIG = qt warn_on release quick-app
+//TEMPLATE = app
+//CONFIG += qte warn_on debug
+//DESTDIR = $(OPIEDIR)/bin
SOURCES = opackage.cpp \
oconfitem.cpp \
oipkg.cpp \
oipkgconfigdlg.cpp \
opackagemanager.cpp \
@@ -19,13 +22,15 @@ HEADERS = opackage.h \
mainwindow.h \
installdlg.h \
packageinfodlg.h \
filterdlg.h \
promptdlg.h
+DEFINES += IPKG_LIB
+DEFINES += HAVE_MKDTEMP
TARGET = packagemanager
-INCLUDEPATH += $(OPIEDIR)/include
+INCLUDEPATH += $(OPIEDIR)/include $(IPKGDIR)
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopie
+LIBS += -lqpe -lopie -lipkg
include ( $(OPIEDIR)/include.pro )