summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/pmipkg.cpp
authortille <tille>2002-06-21 09:01:39 (UTC)
committer tille <tille>2002-06-21 09:01:39 (UTC)
commit0d5a0129ee055e0f077505b05caa942bf6ef6165 (patch) (unidiff)
treec718cc805ae49c922a126192c7e98747c025b103 /noncore/unsupported/oipkg/pmipkg.cpp
parent48847f165b3ee8d096871c1bde8748d18cfb0f43 (diff)
downloadopie-0d5a0129ee055e0f077505b05caa942bf6ef6165.zip
opie-0d5a0129ee055e0f077505b05caa942bf6ef6165.tar.gz
opie-0d5a0129ee055e0f077505b05caa942bf6ef6165.tar.bz2
some fixes and first version with oprocess (out-ifdefed)
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp72
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
@@ -3,7 +3,9 @@
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>
@@ -32,10 +34,22 @@ PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlag
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
37PmIpkg::~PmIpkg() 48PmIpkg::~PmIpkg()
38{ 49{
50#ifdef OPROCESS
51 delete ipkgProcess;
52#endif
39} 53}
40 54
41bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 55bool PmIpkg::runIpkg(const QString& args, const QString& dest )
@@ -43,6 +57,11 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
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();
@@ -65,6 +84,41 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
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];
@@ -91,6 +145,7 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
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;
@@ -99,7 +154,7 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
99void PmIpkg::makeLinks(Package *pack) 154void 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
105QStringList* PmIpkg::getList( QString packFileName, QString d ) 160QStringList* PmIpkg::getList( QString packFileName, QString d )
@@ -242,6 +297,7 @@ void PmIpkg::commit()
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
@@ -396,3 +452,15 @@ void PmIpkg::clearLists()
396 to_remove.clear(); 452 to_remove.clear();
397 to_install.clear(); 453 to_install.clear();
398} 454}
455
456
457void 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