summaryrefslogtreecommitdiff
Unidiff
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
@@ -3 +3,3 @@ moc*
3.moc* 3.moc*
4.obj
5.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,2 +1,7 @@
12004-01-nn Dan Williams <drw@handhelds.org> 12004-01-20 Dan Williams <drw@handhelds.org>
2
3 * Released version 0.2.0
4 * Converted to use libipkg in place of spawning ipkg process
5
62004-01-13 Dan Williams <drw@handhelds.org>
2 7
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
@@ -208,4 +208,3 @@ void InstallDlg::slotBtnStart()
208 { 208 {
209 // Stop execution of current command and prevent any others from executing 209 // Prevent unexecuted commands from executing
210 m_packman->abortCommand();
211 m_currCommand = 999; 210 m_currCommand = 999;
@@ -224,6 +223,13 @@ void InstallDlg::slotBtnStart()
224 223
225 // Start was clicked, execute first command 224 // Start was clicked, start executing
226 m_btnOptions->setEnabled( false ); 225 m_btnOptions->setEnabled( false );
227 m_btnStart->setText( tr( "Abort" ) ); 226 if ( m_numCommands > 1 )
228 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 227 {
228 m_btnStart->setText( tr( "Abort" ) );
229 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
230 }
231 else
232 {
233 m_btnStart->setEnabled( false );
234 }
229 235
@@ -232,5 +238,18 @@ void InstallDlg::slotBtnStart()
232 dest = m_destination->currentText(); 238 dest = m_destination->currentText();
233 m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], dest, this, 239
234 SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)), 240 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
235 SLOT(slotFinished(OProcess*)), true ); 241 {
242 // Execute next command
243 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
244 this, SLOT(slotOutput(char*)), true );
245 }
246
247 // All commands executed, allow user to close dialog
248 m_btnStart->setEnabled( true );
249 m_btnStart->setText( tr( "Close" ) );
250 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
251
252 m_btnOptions->setEnabled( true );
253 m_btnOptions->setText( tr( "Save output" ) );
254 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
236} 255}
@@ -269,16 +288,10 @@ void InstallDlg::slotBtnOptions()
269 288
270void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen ) 289void InstallDlg::slotOutput( char *msg )
271{ 290{
272 QString lineStr = buffer; 291 // Allow processing of other events
273 if ( lineStr[buffLen-1] == '\n' ) 292 qApp->processEvents();
274 lineStr.truncate( buffLen - 1 );
275 m_output->append( lineStr );
276 m_output->setCursorPosition( m_output->numLines(), 0 );
277}
278 293
279void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen ) 294 QString lineStr = msg;
280{ 295 if ( lineStr[lineStr.length()-1] == '\n' )
281 QString lineStr = buffer; 296 lineStr.truncate( lineStr.length() - 1 );
282 if ( lineStr[buffLen-1] == '\n' )
283 lineStr.truncate( buffLen - 1 );
284 m_output->append( lineStr ); 297 m_output->append( lineStr );
@@ -286,24 +299 @@ void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen )
286} 299}
287
288void InstallDlg::slotFinished( OProcess */*process*/ )
289{
290 ++m_currCommand;
291 if ( m_currCommand < m_numCommands )
292 {
293 // More commands left, execute next one
294 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(),
295 this, SLOT(slotOutput(OProcess*,char*,int)),
296 SLOT(slotErrors(OProcess*,char*,int)),
297 SLOT(slotFinished(OProcess*)), true );
298 }
299 else
300 {
301 // All commands executed, allow user to close dialog
302 m_btnStart->setText( tr( "Close" ) );
303 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
304
305 m_btnOptions->setEnabled( true );
306 m_btnOptions->setText( tr( "Save output" ) );
307 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
308 }
309}
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
@@ -80,5 +80,3 @@ private slots:
80 // Execution slots 80 // Execution slots
81 void slotOutput( OProcess *process, char *buffer, int buffLen ); 81 void slotOutput( char *msg );
82 void slotErrors( OProcess *process, char *buffer, int buffLen );
83 void slotFinished( OProcess *process );
84 82
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
@@ -164,4 +164,3 @@ void MainWindow::initUI()
164 164
165 // Ipkg implementation does not seem to work currently? (not working in aqpkg either) 165/*
166 /*
167 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); 166 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
@@ -173,3 +172,3 @@ void MainWindow::initUI()
173 actionDownload->addTo( &m_toolBar ); 172 actionDownload->addTo( &m_toolBar );
174 */ 173*/
175 174
@@ -373,3 +372,2 @@ void MainWindow::slotUpgrade()
373 372
374 // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
375/* 373/*
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
@@ -33,3 +33,4 @@
33 33
34#include <stdio.h> 34#include <stdlib.h>
35#include <string.h>
35 36
@@ -37,7 +38,5 @@
37#include <qfile.h> 38#include <qfile.h>
39#include <qmessagebox.h>
38#include <qtextstream.h> 40#include <qtextstream.h>
39 41
40#include <opie/oprocess.h>
41
42const QString IPKG_EXEC = "ipkg"; // Fully-qualified name of Ipkg executable
43const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 42const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
@@ -47,2 +46,15 @@ const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status fi
47 46
47OIpkg *oipkg;
48
49int fIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg )
50{
51 oipkg->ipkgOutput( msg );
52 return 0;
53}
54
55char* fIpkgResponse( char */*question*/ )
56{
57 return 0x0;
58}
59
48OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 60OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
@@ -50,3 +62,2 @@ OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
50 , m_config( config ) 62 , m_config( config )
51 , m_ipkgExec( IPKG_EXEC ) // TODO - find executable?
52 , m_confInfo( NULL ) 63 , m_confInfo( NULL )
@@ -54,4 +65,12 @@ OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
54 , m_ipkgExecVerbosity( 1 ) 65 , m_ipkgExecVerbosity( 1 )
55 , m_ipkgProcess( NULL )
56{ 66{
67 oipkg = this;
68
69 // Initialize libipkg
70 if ( ipkg_init( &fIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) )
71 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) );
72
73 // Default ipkg run-time arguments
74 m_ipkgArgs.noaction = false;
75 m_ipkgArgs.force_defaults = true;
57} 76}
@@ -64,5 +83,5 @@ OIpkg::~OIpkg()
64 83
65 // Terminate any running ipkg processes 84 // Free up libipkg resources
66 if ( m_ipkgProcess ) 85 if ( ipkg_deinit( &m_ipkgArgs ) )
67 delete m_ipkgProcess; 86 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) );
68} 87}
@@ -256,4 +275,3 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString &
256bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, 275bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
257 const QObject *receiver, const char *slotOutput, const char *slotErrors, 276 const QObject *receiver, const char *slotOutput, bool rawOutput )
258 const char *slotFinished, bool rawOutput )
259{ 277{
@@ -262,126 +280,62 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters,
262 280
263 // Set up command line for execution 281 // Set ipkg run-time options/arguments
264 QStringList cmdLine; 282 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
265 cmdLine.append( IPKG_EXEC ); 283 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
266 284 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
267 QString verbosity( "-V" ); 285 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
268 verbosity.append( QString::number( m_ipkgExecVerbosity ) ); 286 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
269 cmdLine.append( verbosity ); 287 if ( m_ipkgArgs.dest )
270 288 free( m_ipkgArgs.dest );
271 // Determine Ipkg execution options 289 if ( !destination.isNull() )
272 if ( command == OPackage::Install && destination != QString::null )
273 { 290 {
274 // TODO - Set destination for installs 291 int len = destination.length() + 1;
275 cmdLine.append( "-dest" ); 292 m_ipkgArgs.dest = (char *)malloc( len );
276 cmdLine.append( destination ); 293 strncpy( m_ipkgArgs.dest, destination, destination.length() );
294 m_ipkgArgs.dest[ len - 1 ] = '\0';
277 } 295 }
296 else
297 m_ipkgArgs.dest = 0x0;
278 298
279 if ( command != OPackage::Update && command != OPackage::Download ) 299 // Connect output signal to widget
300 if ( rawOutput )
280 { 301 {
281 if ( m_ipkgExecOptions & FORCE_DEPENDS ) 302 if ( slotOutput )
282 cmdLine.append( "-force-depends" ); 303 connect( this, SIGNAL(execOutput(char *)), receiver, slotOutput );
283 if ( m_ipkgExecOptions & FORCE_REINSTALL ) 304 }
284 cmdLine.append( "-force-reinstall" ); 305 else
285 if ( m_ipkgExecOptions & FORCE_REMOVE ) 306 {
286 cmdLine.append( "-force-removal-of-essential-packages" ); 307 // TODO - connect to local slot and parse output before emitting execOutput
287 if ( m_ipkgExecOptions & FORCE_OVERWRITE )
288 cmdLine.append( "-force-overwrite" );
289 if ( m_ipkgExecVerbosity == 3 )
290 cmdLine.append( "-verbose_wget" );
291
292 // TODO
293 // Handle make links
294 // Rules - If make links is switched on, create links to root
295 // if destDir is NOT /
296 /*
297 if ( m_ipkgExecOptions & MAKE_LINKS )
298 {
299 // If destDir == / turn off make links as package is being insalled
300 // to root already.
301 if ( destDir == "/" )
302 m_ipkgExecOptions ^= MAKE_LINKS;
303 }
304 */
305 } 308 }
306 309
307 QString cmd;
308 switch( command ) 310 switch( command )
309 { 311 {
310 case OPackage::Install: cmd = "install"; 312 case OPackage::Update : ipkg_lists_update( &m_ipkgArgs );
311 break;
312 case OPackage::Remove: cmd = "remove";
313 break; 313 break;
314 case OPackage::Update: cmd = "update"; 314 case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs );
315 break; 315 break;
316 case OPackage::Upgrade: cmd = "upgrade"; 316 case OPackage::Install : {
317 break; 317 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
318 case OPackage::Download: cmd = "download"; 318 {
319 break; 319 ipkg_packages_install( &m_ipkgArgs, (*it) );
320 case OPackage::Info: cmd = "info"; 320 }
321 };
321 break; 322 break;
322 case OPackage::Files: cmd = "files"; 323 case OPackage::Remove : {
324 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
325 {
326 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
327 }
328 };
323 break; 329 break;
324 //case OPackage::Version: cmd = "" ); 330 //case OPackage::Download : ;
325 // break; 331 // break;
326 default: 332 default : break;
327 break;
328 }; 333 };
329 cmdLine.append( cmd );
330
331 // TODO
332 // If we are removing, reinstalling or upgrading packages and make links option is selected
333 // create the links
334/*
335 if ( command == Remove || command == Upgrade )
336 {
337 createLinks = false;
338 if ( flags & MAKE_LINKS )
339 {
340 emit outputText( tr( "Removing symbolic links...\n" ) );
341 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
342 emit outputText( QString( " " ) );
343 }
344 }
345*/
346 // Append package list (if any) to end of command line
347 if ( parameters && !parameters->isEmpty() )
348 {
349 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
350 {
351 cmdLine.append( *it );
352 }
353 }
354
355 // Create OProcess
356 if ( m_ipkgProcess )
357 delete m_ipkgProcess;
358 m_ipkgProcess = new OProcess( cmdLine, this );
359
360 // Connect signals (if any)
361 if ( receiver )
362 {
363 if ( rawOutput )
364 {
365 if ( slotOutput )
366 connect( m_ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), receiver, slotOutput );
367 if ( slotErrors )
368 connect( m_ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), receiver, slotErrors );
369 if ( slotFinished )
370 connect( m_ipkgProcess, SIGNAL(processExited(OProcess*)), receiver, slotFinished );
371 }
372 else // !rawOutput
373 {
374 // TODO - how should it handle partial lines? (i.e. "Installing opi", "e-aqpkg...")
375 }
376 }
377 334
378 // Run process 335 return true;
379printf( "Running: \'%s\'\n", cmdLine.join( " " ).latin1() );
380 return m_ipkgProcess->start( OProcess::NotifyOnExit, OProcess::All );
381} 336}
382 337
383void OIpkg::abortCommand() 338void OIpkg::ipkgOutput( char *msg )
384{ 339{
385 if ( m_ipkgProcess ) 340 emit execOutput( msg );
386 delete m_ipkgProcess;
387} 341}
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
@@ -34,2 +34,6 @@
34 34
35extern "C" {
36#include <libipkg.h>
37};
38
35#include <qobject.h> 39#include <qobject.h>
@@ -48,3 +52,2 @@
48class OConfItemList; 52class OConfItemList;
49class OProcess;
50 53
@@ -78,9 +81,10 @@ public:
78 const QString &destination = QString::null, const QObject *receiver = 0x0, 81 const QString &destination = QString::null, const QObject *receiver = 0x0,
79 const char *slotOutput = 0x0, const char *slotErrors = 0x0, 82 const char *slotOutput = 0x0, bool rawOutput = true );
80 const char *slotFinished = 0x0, bool rawOutput = true );
81 void abortCommand(); 83 void abortCommand();
82 84
85 void ipkgOutput( char *msg );
86
83private: 87private:
84 Config *m_config; // Pointer to application configuration file 88 Config *m_config; // Pointer to application configuration file
85 QString m_ipkgExec; // Fully qualified path/filename of ipkg binary 89 args_t m_ipkgArgs; // libipkg configuration arguments
86 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files 90 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
@@ -88,3 +92,2 @@ private:
88 int m_ipkgExecVerbosity; // Ipkg execution verbosity level 92 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
89 OProcess *m_ipkgProcess; // Pointer to process which Ipkg will run in
90 93
@@ -94,5 +97,3 @@ private:
94signals: 97signals:
95 void execOutput( OProcess *process, char *buffer, int length ); 98 void execOutput( char *msg );
96 void execErrors( OProcess *process, char *buffer, int length );
97 void execFinished( OProcess *process, char *buffer, int length );
98}; 99};
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
@@ -319,12 +319,5 @@ bool OPackageManager::executeCommand( OPackage::Command command, QStringList *pa
319 const QString &destination, const QObject *receiver, 319 const QString &destination, const QObject *receiver,
320 const char *slotOutput, const char *slotErrors, 320 const char *slotOutput, bool rawOutput )
321 const char *slotFinished, bool rawOutput )
322{ 321{
323 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, slotErrors, 322 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
324 slotFinished, rawOutput );
325}
326
327void OPackageManager::abortCommand()
328{
329 m_ipkg.abortCommand();
330} 323}
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
@@ -74,5 +74,3 @@ public:
74 const QString &destination = QString::null, const QObject *receiver = 0x0, 74 const QString &destination = QString::null, const QObject *receiver = 0x0,
75 const char *slotOutput = 0x0, const char *slotErrors = 0x0, 75 const char *slotOutput = 0x0, bool rawOutput = true );
76 const char *slotFinished = 0x0, bool rawOutput = true );
77 void abortCommand();
78 76
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
@@ -9,2 +9,2 @@ Maintainer: Dan Williams (drw@handhelds.org)
9Description: Opie package management client 9Description: Opie package management client
10Version: 0.1.0 10Version: 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,2 +1,5 @@
1CONFIG = qt warn_on release quick-app 1CONFIG = qt warn_on release quick-app
2//TEMPLATE = app
3//CONFIG += qte warn_on debug
4//DESTDIR = $(OPIEDIR)/bin
2 5
@@ -24,6 +27,8 @@ HEADERS = opackage.h \
24 27
28DEFINES += IPKG_LIB
29DEFINES += HAVE_MKDTEMP
25TARGET = packagemanager 30TARGET = packagemanager
26INCLUDEPATH += $(OPIEDIR)/include 31INCLUDEPATH += $(OPIEDIR)/include $(IPKGDIR)
27DEPENDPATH += $(OPIEDIR)/include 32DEPENDPATH += $(OPIEDIR)/include
28LIBS += -lqpe -lopie 33LIBS += -lqpe -lopie -lipkg
29 34