-rw-r--r-- | noncore/settings/packagemanager/.cvsignore | 2 | ||||
-rw-r--r-- | noncore/settings/packagemanager/ChangeLog | 7 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 76 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 4 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 188 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.h | 17 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.cpp | 11 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.h | 4 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opie-packagemanager.control | 2 | ||||
-rw-r--r-- | noncore/settings/packagemanager/packagemanager.pro | 9 |
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 @@ -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 @@ -206,8 +206,7 @@ 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 @@ -222,17 +221,37 @@ void InstallDlg::slotBtnStart() return; } - // 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" ) ); } void InstallDlg::slotBtnOptions() @@ -267,43 +286,14 @@ 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 @@ -78,9 +78,7 @@ private slots: 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(); 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 @@ -162,8 +162,7 @@ void MainWindow::initUI() 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 ); @@ -171,7 +170,7 @@ void MainWindow::initUI() connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); actionDownload->addTo( popup ); actionDownload->addTo( &m_toolBar ); - */ +*/ a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); @@ -371,7 +370,6 @@ void MainWindow::slotUpgrade() m_widgetStack.raiseWidget( dlg ); } - // 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 @@ -31,29 +31,48 @@ #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() @@ -62,9 +81,9 @@ OIpkg::~OIpkg() 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() @@ -254,136 +273,71 @@ 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 ); } void OIpkg::loadConfiguration() 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 @@ -32,6 +32,10 @@ #ifndef OIPKG_H #define OIPKG_H +extern "C" { +#include <libipkg.h> +}; + #include <qobject.h> #include <qpe/config.h> @@ -46,7 +50,6 @@ #define FORCE_OVERWRITE 0x0008 class OConfItemList; -class OProcess; class OIpkg : public QObject { @@ -76,25 +79,23 @@ 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(); 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 @@ -317,14 +317,7 @@ 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 @@ -72,9 +72,7 @@ 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: Config *m_config; // Pointer to application configuration file 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 @@ -7,4 +7,4 @@ 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,4 +1,7 @@ CONFIG = qt warn_on release quick-app +//TEMPLATE = app +//CONFIG += qte warn_on debug +//DESTDIR = $(OPIEDIR)/bin SOURCES = opackage.cpp \ oconfitem.cpp \ @@ -22,10 +25,12 @@ HEADERS = opackage.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 ) |