summaryrefslogtreecommitdiff
authordrw <drw>2004-01-20 19:33:27 (UTC)
committer drw <drw>2004-01-20 19:33:27 (UTC)
commitda0557836c852fade427c03ad59d349f3294bbb8 (patch) (side-by-side diff)
tree979907c816c09f3b3a290b58eac353094cbcd90e
parent996826e77a8f96ada424814716178e65caba9287 (diff)
downloadopie-da0557836c852fade427c03ad59d349f3294bbb8.zip
opie-da0557836c852fade427c03ad59d349f3294bbb8.tar.gz
opie-da0557836c852fade427c03ad59d349f3294bbb8.tar.bz2
Convert to use libipkg
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
@@ -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
@@ -161,149 +161,139 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
}
InstallDlg::~InstallDlg()
{
for( int i = 0; i < m_numCommands; i++ )
{
if ( m_packages[ i ] )
delete m_packages[ i ];
}
}
void InstallDlg::slotDisplayAvailSpace( const QString &destination )
{
// If available space is not displayed, exit
if ( !m_availSpace )
return;
QString space = tr( "Unknown" );
// Get destination
OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination );
if ( dest )
{
// Calculate available space
struct statfs fs;
if ( !statfs( dest->value(), &fs ) )
{
long mult = fs.f_bsize / 1024;
long div = 1024 / fs.f_bsize;
if ( !mult ) mult = 1;
if ( !div ) div = 1;
long avail = fs.f_bavail * mult / div;
space = tr( "%1 Kb" ).arg( avail );
}
}
// Display available space
m_availSpace->setText( space );
}
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;
}
else if ( btnText == tr( "Close" ) )
{
// TODO - force reload of package data
emit closeInstallDlg();
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()
{
QString btnText = m_btnOptions->text();
if ( btnText == tr( "Options" ) )
{
// Display configuration dialog (only options tab is enabled)
m_packman->configureDlg( true );
return;
}
// Save output was clicked
QMap<QString, QStringList> map;
map.insert( tr( "All" ), QStringList() );
QStringList text;
text << "text/*";
map.insert(tr( "Text" ), text );
text << "*";
map.insert( tr( "All" ), text );
QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
if( !filename.isEmpty() )
{
QString currentFileName = QFileInfo( filename ).fileName();
DocLnk doc;
doc.setType( "text/plain" );
doc.setFile( filename );
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
@@ -33,57 +33,55 @@
#include <qwidget.h>
#include <opie/oprocess.h>
#include "opackage.h"
class QComboBox;
class QLabel;
class QMultiLineEdit;
class QPushButton;
class OPackageManager;
class InstallDlg : public QWidget
{
Q_OBJECT
public:
InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null,
bool showDestInfo = true,
OPackage::Command command1 = OPackage::NotDefined, QStringList *packages1 = 0x0,
OPackage::Command command2 = OPackage::NotDefined, QStringList *packages2 = 0x0,
OPackage::Command command3 = OPackage::NotDefined, QStringList *packages3 = 0x0 );
~InstallDlg();
private:
OPackageManager *m_packman; // Pointer to application instance of package manager
// UI controls
QComboBox *m_destination; // Destination selection list
QLabel *m_availSpace; // Text label to display available space on selected destination
QMultiLineEdit *m_output; // Multi-line edit to display status
QPushButton *m_btnStart; // Start/abort/close button
QPushButton *m_btnOptions; // Installation options button
// Commands and packages to execute
int m_numCommands; // Number of commands to be executed
int m_currCommand; // Number of currently executing command
OPackage::Command m_command[3]; // List of commands to be executed
QStringList *m_packages[3]; // Lists of package names associated to commands (m_command[])
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
@@ -117,106 +117,105 @@ void MainWindow::initPackageList()
}
void MainWindow::initStatusWidget()
{
QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
layout->addWidget( &m_statusText );
connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) );
connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
layout->addWidget( &m_statusBar );
}
void MainWindow::initUI()
{
// Build menu and tool bars
setToolBarsMovable( false );
m_menuBar.setHorizontalStretchable( true );
QMenuBar *mb = new QMenuBar( &m_menuBar );
mb->setMargin( 0 );
// Find toolbar
addToolBar( &m_findBar, QMainWindow::Top, true );
m_findBar.setHorizontalStretchable( true );
m_findEdit = new QLineEdit( &m_findBar );
QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
m_findBar.setStretchableWidget( m_findEdit );
connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) );
// Packages menu
QPopupMenu *popup = new QPopupMenu( this );
QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
a->addTo( popup );
a->addTo( &m_toolBar );
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()) );
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)." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
a->addTo( popup );
a->addTo( &m_toolBar );
popup->insertSeparator();
a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to configure this application." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
a->addTo( popup );
mb->insertItem( tr( "Actions" ), popup );
// View menu
popup = new QPopupMenu( this );
m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
m_actionShowNotInstalled->setToggleAction( true );
m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
m_actionShowNotInstalled->addTo( popup );
m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
m_actionShowInstalled->setToggleAction( true );
m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
m_actionShowInstalled->addTo( popup );
m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
m_actionShowUpdated->setToggleAction( true );
m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
m_actionShowUpdated->addTo( popup );
popup->insertSeparator();
a = new QAction( tr( "Configure filter" ), QString::null, 0, this, 0 );
a->setWhatsThis( tr( "Click here to change package filter criteria." ) );
connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
a->addTo( popup );
m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
QString::null, 0, this, 0 );
m_actionFilter->setToggleAction( true );
m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) );
connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
@@ -326,97 +325,96 @@ void MainWindow::slotWidgetStackShow( QWidget *widget )
m_toolBar.show();
}
else
{
m_menuBar.hide();
m_toolBar.hide();
}
}
void MainWindow::slotInitStatusBar( int numSteps )
{
m_statusBar.setTotalSteps( numSteps );
}
void MainWindow::slotStatusText( const QString &status )
{
m_statusText.setText( status );
}
void MainWindow::slotStatusBar( int currStep )
{
m_statusBar.setProgress( currStep );
}
void MainWindow::slotUpdate()
{
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
OPackage::Update );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
void MainWindow::slotUpgrade()
{
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
OPackage::Upgrade );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// 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();
for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
item != 0 ;
item = static_cast<QCheckListItem *>(item->nextSibling()) )
{
if ( item->isOn() )
workingPackages->append( item->text() );
}
if ( workingPackages->isEmpty() )
{
// No packages were selected, prompt for URL of package to download
}
else
{
// Download selected packages
m_config.setGroup( "settings" );
QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this );
// if ( ok && !text.isEmpty() )
// workingDir = text; // user entered something and pressed ok
// else
// return; // user entered nothing or pressed cancel
// // Store download directory in config file
// m_config.writeEntry( "DownloadDir", workingDir );
// Get starting directory
// char initDir[PATH_MAX];
// getcwd( initDir, PATH_MAX );
// Download packages
}
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
OPackage::Download, workingPackages );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
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
@@ -1,115 +1,134 @@
/*
                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.
*/
#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();
}
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;
}
void OIpkg::saveSettings()
{
// Save Ipkg execution options to application configuration file
if ( m_config )
{
m_config->setGroup( "Ipkg" );
m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
}
}
OPackageList *OIpkg::availablePackages( const QString &server )
{
// Load Ipkg configuration info if not already cached
@@ -209,226 +228,161 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString &
if ( pos > -1 )
key = line.mid( 0, pos );
else
key = QString::null;
QString value = line.mid( pos+2, line.length()-pos );
// Allocate new package and insert into list
if ( newPackage && !key.isEmpty() )
{
// Add to list only if it has a valid name and is installed
if ( !name.isNull() && status.contains( " installed" ) )
{
pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
name = QString::null;
version = QString::null;
status = QString::null;
newPackage = false;
}
}
// Update package data
if ( key == "Package" )
name = value;
else if ( key == "Version" )
version = value;
else if ( key == "Status" )
status = value;
else if ( key.isEmpty() && value.isEmpty() )
newPackage = true;
// Skip past all description lines
if ( key == "Description" )
{
line = t.readLine();
while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
line = t.readLine();
}
else
line = t.readLine();
}
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 )
+ // 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()
{
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;
for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++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
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
@@ -1,100 +1,101 @@
/*
                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 OIPKG_H
#define OIPKG_H
+extern "C" {
+#include <libipkg.h>
+};
+
#include <qobject.h>
#include <qpe/config.h>
#include "oconfitem.h"
#include "opackage.h"
// Ipkg execution options (m_ipkgExecOptions)
#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:
OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
~OIpkg();
OConfItemList *configItems();
OConfItemList *servers();
OConfItemList *destinations();
OConfItemList *options();
int ipkgExecOptions() { return m_ipkgExecOptions; }
int ipkgExecVerbosity() { return m_ipkgExecVerbosity; }
void setConfigItems( OConfItemList *configList );
void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; }
void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; }
void saveSettings();
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
@@ -272,59 +272,52 @@ OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &n
if ( confList )
{
for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt )
{
OConfItem *conf = confIt.current();
// Add only active confinations
if ( conf->type() == type && conf->name() == name )
{
confItem = conf;
break;
}
}
}
return confItem;
}
OPackage *OPackageManager::findPackage( const QString &name )
{
return m_packages[ name ];
}
int OPackageManager::compareVersions( const QString &version1, const QString &version2 )
{
// TODO - do proper compare!
if ( version1 < version2 )
return -1;
else if ( version1 > version2 )
return 1;
return 0;
}
bool OPackageManager::configureDlg( bool installOptions )
{
OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
return ( dlg.exec() == QDialog::Accepted );
}
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
@@ -27,65 +27,63 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPACKAGEMANAGER_H
#define OPACKAGEMANAGER_H
#include <qdict.h>
#include <qobject.h>
#include <qstringlist.h>
#include <qpe/config.h>
#include "oipkg.h"
class OPackageManager : public QObject
{
Q_OBJECT
public:
OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
void loadAvailablePackages();
void loadInstalledPackages();
enum Status { All, NotInstalled, Installed, Updated, NotDefined };
OPackageList *packages();
OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0,
const QString &destination = 0x0, Status status = NotDefined,
const QString &category = 0x0 );
const QStringList &categories() { return m_categories; }
QStringList *servers();
QStringList *destinations();
int compareVersions( const QString &version1, const QString &version2 );
OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
const QString &name = QString::null );
OPackage *findPackage( const QString &name = QString::null );
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
signals:
void initStatus( int numSteps );
void statusText( const QString &status );
void statusBar( int currStep );
};
#endif
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
@@ -1,10 +1,10 @@
Package: opie-packagemanager
Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
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,31 +1,36 @@
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 \
mainwindow.cpp \
installdlg.cpp \
packageinfodlg.cpp \
filterdlg.cpp \
promptdlg.cpp \
main.cpp
HEADERS = opackage.h \
oconfitem.h \
oipkg.h \
oipkgconfigdlg.h \
opackagemanager.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 )