Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 7b3fa1e..2a534d2 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -1,12 +1,14 @@ | |||
1 | #include "pmipkg.h" | 1 | #include "pmipkg.h" |
2 | #include "pksettings.h" | 2 | #include "pksettings.h" |
3 | #include "package.h" | 3 | #include "package.h" |
4 | #include "packagelistitem.h" | 4 | #include "packagelistitem.h" |
5 | 5 | ||
6 | #include <qpe/process.h> | 6 | //#infdef OPROCESS |
7 | #include <opie/oprocess.h> | ||
8 | //#endif | ||
7 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
8 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
9 | #include <qpe/stringutil.h> | 11 | #include <qpe/stringutil.h> |
10 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
11 | #include <qdir.h> | 13 | #include <qdir.h> |
12 | #include <qfile.h> | 14 | #include <qfile.h> |
@@ -29,23 +31,40 @@ | |||
29 | 31 | ||
30 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 32 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) |
31 | : QObject ( p ) | 33 | : QObject ( p ) |
32 | { | 34 | { |
33 | settings = s; | 35 | settings = s; |
34 | runwindow = new RunWindow( p, name, true, f ); | 36 | runwindow = new RunWindow( p, name, true, f ); |
37 | #ifdef OPROCESS | ||
38 | ipkgProcess = new OProcess(); | ||
39 | connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | ||
40 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); | ||
41 | |||
42 | connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), | ||
43 | this, SLOT(getIpkgOutput(OProcess*,char*,int))); | ||
44 | installDialog = 0; | ||
45 | #endif | ||
35 | } | 46 | } |
36 | 47 | ||
37 | PmIpkg::~PmIpkg() | 48 | PmIpkg::~PmIpkg() |
38 | { | 49 | { |
50 | #ifdef OPROCESS | ||
51 | delete ipkgProcess; | ||
52 | #endif | ||
39 | } | 53 | } |
40 | 54 | ||
41 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | 55 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) |
42 | { | 56 | { |
43 | bool ret=false; | 57 | bool ret=false; |
44 | QDir::setCurrent("/tmp"); | 58 | QDir::setCurrent("/tmp"); |
45 | QString cmd = "/usr/bin/ipkg "; | 59 | QString cmd = "/usr/bin/ipkg "; |
60 | #ifdef OPROCESS | ||
61 | ipkgProcess->clearArguments(); | ||
62 | *ipkgProcess << "/usr/bin/ipkg "; | ||
63 | QString cmd = ""; | ||
64 | #endif | ||
46 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); | 65 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); |
47 | if ( dest == "" ) | 66 | if ( dest == "" ) |
48 | cmd += " -dest "+settings->getDestinationName(); | 67 | cmd += " -dest "+settings->getDestinationName(); |
49 | else | 68 | else |
50 | cmd += " -dest "+ dest; | 69 | cmd += " -dest "+ dest; |
51 | 70 | ||
@@ -62,12 +81,47 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | |||
62 | } | 81 | } |
63 | 82 | ||
64 | out( "Starting to "+ args+"\n"); | 83 | out( "Starting to "+ args+"\n"); |
65 | cmd += args; | 84 | cmd += args; |
66 | out( "running:\n"+cmd+"\n" ); | 85 | out( "running:\n"+cmd+"\n" ); |
67 | pvDebug(2,"running:"+cmd); | 86 | pvDebug(2,"running:"+cmd); |
87 | #ifdef OPROCESS | ||
88 | *ipkgProcess << args; | ||
89 | out( "running:\n" + cmd); | ||
90 | *ipkgProcess << cmd; | ||
91 | |||
92 | //debug | ||
93 | ipkgProcess->clearArguments(); | ||
94 | *ipkgProcess << "/bin/ls "; | ||
95 | //debug | ||
96 | QValueList<QCString> a = ipkgProcess->args(); | ||
97 | QValueList<QCString>::Iterator it; | ||
98 | for( it = a.begin(); it != a.end(); ++it ) | ||
99 | { | ||
100 | out( *it ); | ||
101 | cmd += *it; | ||
102 | } | ||
103 | |||
104 | pvDebug(2,"running:"+cmd); | ||
105 | qApp->processEvents(); | ||
106 | // sleep(1); | ||
107 | ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | ||
108 | if ( !ret ) { | ||
109 | pvDebug(2,"Could not execute '" + cmd); | ||
110 | out("\nError while executing "+ cmd+"\n\n"); | ||
111 | out("\nError while executing\n\n"); | ||
112 | // return false; | ||
113 | } | ||
114 | |||
115 | while ( ipkgProcess->isRunning() ) | ||
116 | { | ||
117 | out("."); | ||
118 | pvDebug(7,"wait for oprocess to terminate"); | ||
119 | qApp->processEvents(); | ||
120 | }; | ||
121 | #else | ||
68 | qApp->processEvents(); | 122 | qApp->processEvents(); |
69 | FILE *fp; | 123 | FILE *fp; |
70 | char line[130]; | 124 | char line[130]; |
71 | QString lineStr, lineStrOld; | 125 | QString lineStr, lineStrOld; |
72 | sleep(1); | 126 | sleep(1); |
73 | cmd +=" 2>&1"; | 127 | cmd +=" 2>&1"; |
@@ -88,21 +142,22 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | |||
88 | out(lineStr); | 142 | out(lineStr); |
89 | lineStrOld = lineStr; | 143 | lineStrOld = lineStr; |
90 | qApp->processEvents(); | 144 | qApp->processEvents(); |
91 | } | 145 | } |
92 | pclose(fp); | 146 | pclose(fp); |
93 | } | 147 | } |
148 | #endif | ||
94 | //out( "Finished!"); | 149 | //out( "Finished!"); |
95 | pvDebug(2,QString(ret?"success\n":"failure\n")); | 150 | pvDebug(2,QString(ret?"success\n":"failure\n")); |
96 | return ret; | 151 | return ret; |
97 | } | 152 | } |
98 | 153 | ||
99 | void PmIpkg::makeLinks(Package *pack) | 154 | void PmIpkg::makeLinks(Package *pack) |
100 | { | 155 | { |
101 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); | 156 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
102 | linkPackage( pack->installName(), pack->dest() ); | 157 | linkPackage( pack->name(), pack->dest() ); |
103 | } | 158 | } |
104 | 159 | ||
105 | QStringList* PmIpkg::getList( QString packFileName, QString d ) | 160 | QStringList* PmIpkg::getList( QString packFileName, QString d ) |
106 | { | 161 | { |
107 | QString dest = settings->getDestinationUrlByName( d ); | 162 | QString dest = settings->getDestinationUrlByName( d ); |
108 | dest = dest==""?d:dest; | 163 | dest = dest==""?d:dest; |
@@ -239,12 +294,13 @@ void PmIpkg::commit() | |||
239 | doIt(); | 294 | doIt(); |
240 | runwindow->showMaximized(); | 295 | runwindow->showMaximized(); |
241 | runwindow->show(); | 296 | runwindow->show(); |
242 | } | 297 | } |
243 | installDialog->close(); | 298 | installDialog->close(); |
244 | delete installDialog; | 299 | delete installDialog; |
300 | installDialog = 0; | ||
245 | out(tr("\nAll done.")); | 301 | out(tr("\nAll done.")); |
246 | } | 302 | } |
247 | 303 | ||
248 | void PmIpkg::doIt() | 304 | void PmIpkg::doIt() |
249 | { | 305 | { |
250 | runwindow->progress->setProgress(0); | 306 | runwindow->progress->setProgress(0); |
@@ -393,6 +449,18 @@ void PmIpkg::removeFile(const QString &fileName, const QString &dest) | |||
393 | 449 | ||
394 | void PmIpkg::clearLists() | 450 | void PmIpkg::clearLists() |
395 | { | 451 | { |
396 | to_remove.clear(); | 452 | to_remove.clear(); |
397 | to_install.clear(); | 453 | to_install.clear(); |
398 | } | 454 | } |
455 | |||
456 | |||
457 | void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) | ||
458 | { | ||
459 | QString lineStr, lineStrOld; | ||
460 | lineStr = buffer; | ||
461 | lineStr=lineStr.left(buflen); | ||
462 | //Configuring opie-oipkg...Done | ||
463 | if (lineStr!=lineStrOld) | ||
464 | out(lineStr); | ||
465 | lineStrOld = lineStr; | ||
466 | } \ No newline at end of file | ||