summaryrefslogtreecommitdiff
authorandyq <andyq>2002-12-17 22:31:10 (UTC)
committer andyq <andyq>2002-12-17 22:31:10 (UTC)
commit995f9ff51e4a687471500765ff40aea27a677197 (patch) (side-by-side diff)
tree376f3f7351a0192d42f0c2e351f39b1e1e0a38f7
parent01640bfdce16d2fd23722a59004a6efd4600c0cf (diff)
downloadopie-995f9ff51e4a687471500765ff40aea27a677197.zip
opie-995f9ff51e4a687471500765ff40aea27a677197.tar.gz
opie-995f9ff51e4a687471500765ff40aea27a677197.tar.bz2
Added abort functionality
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp22
-rw-r--r--noncore/settings/aqpkg/ipkg.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 407abe9..7afe04f 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -34,16 +34,17 @@ using namespace std;
#include <opie/oprocess.h>
#include "utils.h"
#include "ipkg.h"
#include "global.h"
Ipkg :: Ipkg()
{
+ proc = 0;
}
Ipkg :: ~Ipkg()
{
}
// Option is what we are going to do - install, upgrade, download, reinstall
// package is the package name to install - either a fully qualified path and ipk
@@ -132,16 +133,19 @@ bool Ipkg :: runIpkg( )
}
// Execute command
dependantPackages = new QList<QString>;
dependantPackages->setAutoDelete( true );
ret = executeIpkgCommand( commands, option );
+ if ( aborted )
+ return false;
+
if ( option == "install" || option == "reinstall" )
{
// If we are not removing packages and make links option is selected
// create the links
createLinks = true;
if ( flags & MAKE_LINKS )
{
emit outputText( " " );
@@ -251,18 +255,27 @@ void Ipkg :: removeStatusEntry()
// Remove old status file and put tmp stats file in its place
remove( statusFile );
rename( outStatusFile, statusFile );
}
int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option )
{
+ // If one is already running - should never be but just to be safe
+ if ( proc )
+ {
+ delete proc;
+ proc = 0;
+ }
+
// OK we're gonna use OProcess to run this thing
proc = new OProcess();
+ aborted = false;
+
// Connect up our slots
connect(proc, SIGNAL(processExited(OProcess *)),
this, SLOT( processFinished()));
connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
this, SLOT(commandStdout(OProcess *, char *, int)));
@@ -312,20 +325,29 @@ void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
lineStr=lineStr.left( buflen );
emit outputText( lineStr );
buffer[0] = '\0';
}
void Ipkg::processFinished()
{
delete proc;
+ proc = 0;
finished = true;
}
+void Ipkg :: abort()
+{
+ if ( proc )
+ {
+ proc->kill();
+ aborted = true;
+ }
+}
/*
int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
{
FILE *fp = NULL;
char line[130];
QString lineStr, lineStrOld;
int ret = false;
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index 25bae59..f08667b 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -54,20 +54,22 @@ public:
signals:
void outputText( const QString &text );
public slots:
void commandStdout(OProcess*, char *buffer, int buflen);
void commandStderr(OProcess*, char *buffer, int buflen);
void processFinished();
+ void abort();
private:
bool createLinks;
+ bool aborted;
QString option;
QString package;
QString destination;
QString destDir;
QString runtimeDir;
OProcess *proc;
int flags;
bool finished;