summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/pmipkg.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp74
1 files changed, 5 insertions, 69 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index bffad15..a7deb8f 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -9,13 +9,13 @@
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "pmipkg.h" 10#include "pmipkg.h"
11#include "pksettings.h" 11#include "pksettings.h"
12#include "package.h" 12#include "package.h"
13#include "packagelistitem.h" 13#include "packagelistitem.h"
14 14
15#include <opie/oprocess.h> 15//#include <opie/oprocess.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/stringutil.h> 18#include <qpe/stringutil.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qdir.h> 20#include <qdir.h>
21#include <qfile.h> 21#include <qfile.h>
@@ -33,48 +33,33 @@
33#include <stdlib.h> 33#include <stdlib.h>
34#include <unistd.h> 34#include <unistd.h>
35 35
36#include "mainwindow.h" 36#include "mainwindow.h"
37 37
38 38
39//#define OPROCESS
40 39
41PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 40PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
42 : QObject ( p ) 41 : QObject ( p )
43{ 42{
44 settings = s; 43 settings = s;
45 runwindow = new RunWindow( p, name, true, f ); 44 runwindow = new RunWindow( p, name, true, f );
46#ifdef OPROCESS
47 ipkgProcess = new OProcess();
48 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
49 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
50 45
51 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), 46 Config cfg( "oipkg", Config::User );
52 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 47 cfg.setGroup( "ipkg" );
53 installDialog = 0; 48 ipkg_cmd = cfg.readEntry( "cmd", "ipkg" );
54#endif
55} 49}
56 50
57PmIpkg::~PmIpkg() 51PmIpkg::~PmIpkg()
58{ 52{
59#ifdef OPROCESS
60 delete ipkgProcess;
61#endif
62} 53}
63 54
64bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 55bool PmIpkg::runIpkg(const QString& args, const QString& dest )
65{ 56{
66 bool ret=false; 57 bool ret=false;
67 QDir::setCurrent("/tmp"); 58 QDir::setCurrent("/tmp");
68 QString cmd = "/usr/bin/ipkg "; 59 QString cmd = ipkg_cmd;
69#ifdef OPROCESS
70 ipkgProcess->kill();
71 ipkgProcess->clearArguments();
72 *ipkgProcess << "/usr/bin/ipkg ";
73 cmd = "";
74#endif
75 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 60 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
76 if (!args.contains("update")) 61 if (!args.contains("update"))
77 { 62 {
78 if ( dest == "" ) 63 if ( dest == "" )
79 cmd += " -dest "+settings->getDestinationName(); 64 cmd += " -dest "+settings->getDestinationName();
80 else 65 else
@@ -95,49 +80,12 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
95 80
96 out( "Starting to "+ args+"\n"); 81 out( "Starting to "+ args+"\n");
97 qApp->processEvents(); 82 qApp->processEvents();
98 cmd += args; 83 cmd += args;
99 out( "running:\n"+cmd+"\n" ); 84 out( "running:\n"+cmd+"\n" );
100 pvDebug(2,"running:"+cmd); 85 pvDebug(2,"running:"+cmd);
101#ifdef OPROCESS
102 *ipkgProcess << args;
103 out( "running:\n" + cmd);
104 *ipkgProcess << cmd;
105
106//debug
107 delete ipkgProcess;
108 ipkgProcess = new OProcess();
109 ipkgProcess->clearArguments();
110 *ipkgProcess << "/bin/ls ";
111//debug
112 QValueList<QCString> a = ipkgProcess->args();
113 QValueList<QCString>::Iterator it;
114 for( it = a.begin(); it != a.end(); ++it )
115 {
116 out( *it );
117 cmd += *it;
118 }
119
120 pvDebug(2,"running:"+cmd);
121 qApp->processEvents();
122// sleep(1);
123 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
124 if ( !ret ) {
125 pvDebug(2,"Could not execute '" + cmd);
126 out("\nError while executing "+ cmd+"\n\n");
127 out("\nError while executing\n\n");
128 // return false;
129 }
130
131 while ( ipkgProcess->isRunning() )
132 {
133 out(".");
134 pvDebug(7,"wait for oprocess to terminate");
135 qApp->processEvents();
136 };
137#else
138 qApp->processEvents(); 86 qApp->processEvents();
139 FILE *fp; 87 FILE *fp;
140 char line[130]; 88 char line[130];
141 QString lineStr, lineStrOld; 89 QString lineStr, lineStrOld;
142 sleep(1); 90 sleep(1);
143 cmd +=" 2>&1"; 91 cmd +=" 2>&1";
@@ -157,14 +105,12 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
157 out(lineStr); 105 out(lineStr);
158 lineStrOld = lineStr; 106 lineStrOld = lineStr;
159 qApp->processEvents(); 107 qApp->processEvents();
160 } 108 }
161 } 109 }
162 pclose(fp); 110 pclose(fp);
163#endif
164 //out( "Finished!");
165 pvDebug(2,QString(ret?"success\n":"failure\n")); 111 pvDebug(2,QString(ret?"success\n":"failure\n"));
166 return ret; 112 return ret;
167} 113}
168 114
169void PmIpkg::makeLinks(Package *pack) 115void PmIpkg::makeLinks(Package *pack)
170{ 116{
@@ -490,16 +436,6 @@ void PmIpkg::clearLists()
490{ 436{
491 to_remove.clear(); 437 to_remove.clear();
492 to_install.clear(); 438 to_install.clear();
493} 439}
494 440
495 441
496void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen)
497{
498 QString lineStr, lineStrOld;
499 lineStr = buffer;
500 lineStr=lineStr.left(buflen);
501 //Configuring opie-oipkg...Done
502 if (lineStr!=lineStrOld)
503 out(lineStr);
504 lineStrOld = lineStr;
505}