summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/.cvsignore2
-rw-r--r--noncore/settings/packagemanager/ChangeLog7
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp76
-rw-r--r--noncore/settings/packagemanager/installdlg.h4
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp6
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp188
-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, 135 insertions, 191 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
@@ -2,2 +2,4 @@ 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,3 +1,8 @@
-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
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
@@ -207,6 +207,5 @@ void InstallDlg::slotBtnStart()
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;
@@ -223,15 +222,35 @@ void InstallDlg::slotBtnStart()
}
- // Start was clicked, execute first command
+ // Start was clicked, start executing
m_btnOptions->setEnabled( false );
- m_btnStart->setText( tr( "Abort" ) );
- m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
+ 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" ) );
}
@@ -268,42 +287,13 @@ void InstallDlg::slotBtnOptions()
}
-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
@@ -79,7 +79,5 @@ private slots:
// 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:
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
@@ -163,6 +163,5 @@ void MainWindow::initUI()
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" );
@@ -172,5 +171,5 @@ void MainWindow::initUI()
actionDownload->addTo( popup );
actionDownload->addTo( &m_toolBar );
- */
+*/
a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
@@ -372,5 +371,4 @@ void MainWindow::slotUpgrade()
}
- // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
/*
void MainWindow::slotDownload()
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
@@ -32,13 +32,12 @@
#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
@@ -46,13 +45,33 @@ const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing
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;
}
@@ -63,7 +82,7 @@ OIpkg::~OIpkg()
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" ) );
}
@@ -255,134 +274,69 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString &
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 )
+ // 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() )
{
- // TODO - Set destination for installs
- cmdLine.append( "-dest" );
- cmdLine.append( destination );
+ 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 )
+ // Connect output signal to widget
+ if ( rawOutput )
{
- 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 )
- {
- // 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";
+ case OPackage::Update : ipkg_lists_update( &m_ipkgArgs );
break;
- case OPackage::Update: cmd = "update";
+ case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs );
break;
- case OPackage::Upgrade: cmd = "upgrade";
- break;
- case OPackage::Download: cmd = "download";
- break;
- case OPackage::Info: cmd = "info";
+ case OPackage::Install : {
+ for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ {
+ ipkg_packages_install( &m_ipkgArgs, (*it) );
+ }
+ };
break;
- case OPackage::Files: cmd = "files";
+ case OPackage::Remove : {
+ for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ {
+ ipkg_packages_remove( &m_ipkgArgs, (*it), true );
+ }
+ };
break;
- //case OPackage::Version: cmd = "" );
+ //case OPackage::Download : ;
// break;
- default:
- 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() )
- {
- for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
- {
- cmdLine.append( *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
- {
- // TODO - how should it handle partial lines? (i.e. "Installing opi", "e-aqpkg...")
- }
- }
- // 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 );
}
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
@@ -33,4 +33,8 @@
#define OIPKG_H
+extern "C" {
+#include <libipkg.h>
+};
+
#include <qobject.h>
@@ -47,5 +51,4 @@
class OConfItemList;
-class OProcess;
class OIpkg : public QObject
@@ -77,15 +80,15 @@ public:
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();
@@ -93,7 +96,5 @@ private:
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 );
};
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
@@ -318,13 +318,6 @@ void OPackageManager::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
@@ -73,7 +73,5 @@ public:
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:
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
@@ -8,3 +8,3 @@ 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,3 +1,6 @@
CONFIG = qt warn_on release quick-app
+//TEMPLATE = app
+//CONFIG += qte warn_on debug
+//DESTDIR = $(OPIEDIR)/bin
SOURCES = opackage.cpp \
@@ -23,8 +26,10 @@ HEADERS = opackage.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 )