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.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
@@ -1,18 +1,20 @@
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>
13#include <qgroupbox.h> 15#include <qgroupbox.h>
14#include <qmultilineedit.h> 16#include <qmultilineedit.h>
15#include <qstring.h> 17#include <qstring.h>
16#include <qcheckbox.h> 18#include <qcheckbox.h>
17#include <qtextstream.h> 19#include <qtextstream.h>
18#include <qtextview.h> 20#include <qtextview.h>
@@ -23,57 +25,109 @@
23 25
24#include <stdlib.h> 26#include <stdlib.h>
25#include <unistd.h> 27#include <unistd.h>
26 28
27#include "mainwindow.h" 29#include "mainwindow.h"
28 30
29 31
30PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 32PmIpkg::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
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 )
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
52 cmd += " -force-defaults "; 71 cmd += " -force-defaults ";
53 72
54 if (installDialog && installDialog->_force_depends) 73 if (installDialog && installDialog->_force_depends)
55 { 74 {
56 if (installDialog->_force_depends->isChecked()) 75 if (installDialog->_force_depends->isChecked())
57 cmd += " -force-depends "; 76 cmd += " -force-depends ";
58 if (installDialog->_force_reinstall->isChecked()) 77 if (installDialog->_force_reinstall->isChecked())
59 cmd += " -force-reinstall "; 78 cmd += " -force-reinstall ";
60 if (installDialog->_force_remove->isChecked()) 79 if (installDialog->_force_remove->isChecked())
61 cmd += " -force-removal-of-essential-packages "; 80 cmd += " -force-removal-of-essential-packages ";
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";
74 fp = popen( (const char *) cmd, "r"); 128 fp = popen( (const char *) cmd, "r");
75 if ( !fp ) { 129 if ( !fp ) {
76 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 130 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
77 pclose(fp); 131 pclose(fp);
78 out("\nError while executing "+ cmd+"\n\n"); 132 out("\nError while executing "+ cmd+"\n\n");
79 return false; 133 return false;
@@ -82,33 +136,34 @@ bool PmIpkg::runIpkg(const QString& args, const QString& dest )
82 lineStr = line; 136 lineStr = line;
83 lineStr=lineStr.left(lineStr.length()-1); 137 lineStr=lineStr.left(lineStr.length()-1);
84 //Configuring opie-oipkg...Done 138 //Configuring opie-oipkg...Done
85 if (lineStr.contains("Done")) 139 if (lineStr.contains("Done"))
86 ret = true; 140 ret = true;
87 if (lineStr!=lineStrOld) 141 if (lineStr!=lineStrOld)
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
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 )
106{ 161{
107 QString dest = settings->getDestinationUrlByName( d ); 162 QString dest = settings->getDestinationUrlByName( d );
108 dest = dest==""?d:dest; 163 dest = dest==""?d:dest;
109 if (dest == "/" ) return 0; 164 if (dest == "/" ) return 0;
110 { 165 {
111 Config cfg( "oipkg", Config::User ); 166 Config cfg( "oipkg", Config::User );
112 cfg.setGroup( "Common" ); 167 cfg.setGroup( "Common" );
113 QString statusDir = cfg.readEntry( "statusDir", "" ); 168 QString statusDir = cfg.readEntry( "statusDir", "" );
114 } 169 }
@@ -233,24 +288,25 @@ void PmIpkg::commit()
233 runwindow->progress->setTotalSteps(sizecount); 288 runwindow->progress->setTotalSteps(sizecount);
234 qDebug("Install size %i",sizecount); 289 qDebug("Install size %i",sizecount);
235 installDialog->showMaximized(); 290 installDialog->showMaximized();
236 installDialog->show(); 291 installDialog->show();
237 if ( installDialog->exec() ) 292 if ( installDialog->exec() )
238 { 293 {
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
248void PmIpkg::doIt() 304void PmIpkg::doIt()
249{ 305{
250 runwindow->progress->setProgress(0); 306 runwindow->progress->setProgress(0);
251 show(); 307 show();
252 remove(); 308 remove();
253 install(); 309 install();
254} 310}
255 311
256 312
@@ -387,12 +443,24 @@ void PmIpkg::removeFile(const QString &fileName, const QString &dest)
387 if ( dest!="") p->setDest( dest ); 443 if ( dest!="") p->setDest( dest );
388 to_remove.append( p ); 444 to_remove.append( p );
389 commit(); 445 commit();
390 delete p; 446 delete p;
391} 447}
392 448
393 449
394void PmIpkg::clearLists() 450void PmIpkg::clearLists()
395{ 451{
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