Diffstat (limited to 'noncore/settings/aqpkg/ipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 22 |
1 files changed, 22 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 | |||
@@ -36,12 +36,13 @@ using namespace std; | |||
36 | #include "utils.h" | 36 | #include "utils.h" |
37 | #include "ipkg.h" | 37 | #include "ipkg.h" |
38 | #include "global.h" | 38 | #include "global.h" |
39 | 39 | ||
40 | Ipkg :: Ipkg() | 40 | Ipkg :: Ipkg() |
41 | { | 41 | { |
42 | proc = 0; | ||
42 | } | 43 | } |
43 | 44 | ||
44 | Ipkg :: ~Ipkg() | 45 | Ipkg :: ~Ipkg() |
45 | { | 46 | { |
46 | } | 47 | } |
47 | 48 | ||
@@ -134,12 +135,15 @@ bool Ipkg :: runIpkg( ) | |||
134 | // Execute command | 135 | // Execute command |
135 | dependantPackages = new QList<QString>; | 136 | dependantPackages = new QList<QString>; |
136 | dependantPackages->setAutoDelete( true ); | 137 | dependantPackages->setAutoDelete( true ); |
137 | 138 | ||
138 | ret = executeIpkgCommand( commands, option ); | 139 | ret = executeIpkgCommand( commands, option ); |
139 | 140 | ||
141 | if ( aborted ) | ||
142 | return false; | ||
143 | |||
140 | if ( option == "install" || option == "reinstall" ) | 144 | if ( option == "install" || option == "reinstall" ) |
141 | { | 145 | { |
142 | // If we are not removing packages and make links option is selected | 146 | // If we are not removing packages and make links option is selected |
143 | // create the links | 147 | // create the links |
144 | createLinks = true; | 148 | createLinks = true; |
145 | if ( flags & MAKE_LINKS ) | 149 | if ( flags & MAKE_LINKS ) |
@@ -253,14 +257,23 @@ void Ipkg :: removeStatusEntry() | |||
253 | remove( statusFile ); | 257 | remove( statusFile ); |
254 | rename( outStatusFile, statusFile ); | 258 | rename( outStatusFile, statusFile ); |
255 | } | 259 | } |
256 | 260 | ||
257 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option ) | 261 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option ) |
258 | { | 262 | { |
263 | // If one is already running - should never be but just to be safe | ||
264 | if ( proc ) | ||
265 | { | ||
266 | delete proc; | ||
267 | proc = 0; | ||
268 | } | ||
269 | |||
259 | // OK we're gonna use OProcess to run this thing | 270 | // OK we're gonna use OProcess to run this thing |
260 | proc = new OProcess(); | 271 | proc = new OProcess(); |
272 | aborted = false; | ||
273 | |||
261 | 274 | ||
262 | // Connect up our slots | 275 | // Connect up our slots |
263 | connect(proc, SIGNAL(processExited(OProcess *)), | 276 | connect(proc, SIGNAL(processExited(OProcess *)), |
264 | this, SLOT( processFinished())); | 277 | this, SLOT( processFinished())); |
265 | 278 | ||
266 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 279 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), |
@@ -314,16 +327,25 @@ void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) | |||
314 | buffer[0] = '\0'; | 327 | buffer[0] = '\0'; |
315 | } | 328 | } |
316 | 329 | ||
317 | void Ipkg::processFinished() | 330 | void Ipkg::processFinished() |
318 | { | 331 | { |
319 | delete proc; | 332 | delete proc; |
333 | proc = 0; | ||
320 | finished = true; | 334 | finished = true; |
321 | } | 335 | } |
322 | 336 | ||
323 | 337 | ||
338 | void Ipkg :: abort() | ||
339 | { | ||
340 | if ( proc ) | ||
341 | { | ||
342 | proc->kill(); | ||
343 | aborted = true; | ||
344 | } | ||
345 | } | ||
324 | 346 | ||
325 | /* | 347 | /* |
326 | int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) | 348 | int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) |
327 | { | 349 | { |
328 | FILE *fp = NULL; | 350 | FILE *fp = NULL; |
329 | char line[130]; | 351 | char line[130]; |