summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/pmipkg.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp149
1 files changed, 64 insertions, 85 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 5996e63..75f93cf 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -9,2 +9,3 @@
9#include <qpe/stringutil.h> 9#include <qpe/stringutil.h>
10#include <qpe/qpeapplication.h>
10#include <qdir.h> 11#include <qdir.h>
@@ -39,15 +40,7 @@ PmIpkg::~PmIpkg()
39 40
40//#define PROC 41bool PmIpkg::runIpkg(const QString& args, const QString& dest )
41#define SYSTEM
42#define QT_QPROCESS_DEBUG
43int PmIpkg::runIpkg(const QString& args, const QString& dest )
44{ 42{
45 pvDebug(2,"PmIpkg::runIpkg "+args); 43 bool ret=false;
46 QDir::setCurrent("/tmp"); 44 QDir::setCurrent("/tmp");
47#ifdef PROC
48 QString cmd;
49#endif
50#ifdef SYSTEM
51 QString cmd = "/usr/bin/ipkg "; 45 QString cmd = "/usr/bin/ipkg ";
52#endif
53 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 46 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
@@ -70,38 +63,34 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
70 63
71 out( "<hr><br>Starting to "+ args+"<br>\n"); 64 out( "Starting to "+ args+"\n");
72 cmd += args; 65 cmd += args;
73 int r = 0; 66 out( "running:\n"+cmd+"\n" );
74#ifdef PROC 67 pvDebug(2,"running:"+cmd);
75 QString o = "start"; 68 qApp->processEvents();
76 Process *ipkg = new Process(QStringList() << "ipkg" << cmd ); 69 FILE *fp;
77 out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" ); 70 char line[130];
78 QString description; 71 QString lineStr, lineStrOld;
79 r = ipkg->exec("",o); 72 sleep(1);
80 out( o ); 73 cmd +=" 2>&1";
81#endif 74 fp = popen( (const char *) cmd, "r");
82#ifdef SYSTEM 75 if ( !fp ) {
83 out( "running:<br>\n"+cmd+"<br>\n" ); 76 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
84 QString redirect = "/tmp/oipkg.pipe"; 77 pclose(fp);
85 cmd += " 2>&1 | tee "+redirect+" 2>&1"; 78 out("\nError while executing "+ cmd+"\n\n");
86 pvDebug(2, "running >"+cmd+"<"); 79 return false;
87 r = system(cmd.latin1()); 80 } else {
88 QFile f( redirect ); 81 while ( fgets( line, sizeof line, fp)) {
89 QString line; 82 lineStr = line;
90 QString oldLine; 83 lineStr=lineStr.left(lineStr.length()-1);
91 while ( ! f.open(IO_ReadOnly) ) {}; 84 //Configuring opie-oipkg...Done
92 QTextStream t( &f ); 85 if (lineStr.contains("Done"))
93 while ( !t.eof() ) 86 ret = true;
94 { 87 if (lineStr!=lineStrOld)
95 line = t.readLine(); 88 out(lineStr);
96 if ( line != oldLine ) 89 lineStrOld = lineStr;
97 {
98 out( line +"<br>" );
99 oldLine = line;
100 } 90 }
91 pclose(fp);
101 } 92 }
102 f.close(); 93 //out( "Finished!");
103 out( "Finished!<br>"); 94 pvDebug(2,QString(ret?"success\n":"failure\n"));
104#endif 95 return ret;
105
106 return r;
107} 96}
@@ -129,3 +118,3 @@ QStringList* PmIpkg::getList( QString packFileName, QString d )
129 pvDebug(1," Panik! Could not open"); 118 pvDebug(1," Panik! Could not open");
130 out( "<b>Panik!</b> Could not open:<br>"+packFileName ); 119 out( "Panik!\n Could not open:\n"+packFileName );
131 return (QStringList*)0; 120 return (QStringList*)0;
@@ -245,2 +234,3 @@ void PmIpkg::commit()
245 installDialog->showMaximized(); 234 installDialog->showMaximized();
235 installDialog->show();
246 if ( installDialog->exec() ) doIt(); 236 if ( installDialog->exec() ) doIt();
@@ -248,3 +238,4 @@ void PmIpkg::commit()
248 runwindow->showMaximized(); 238 runwindow->showMaximized();
249 out(tr("<b>All done.</b>")); 239 runwindow->show();
240 out(tr("\nAll done."));
250} 241}
@@ -253,3 +244,4 @@ void PmIpkg::doIt()
253{ 244{
254 show( true ); 245 runwindow->progress->setProgress(0);
246 show();
255 remove(); 247 remove();
@@ -263,3 +255,3 @@ void PmIpkg::remove()
263 255
264 out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>"); 256 out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
265 257
@@ -269,3 +261,3 @@ void PmIpkg::remove()
269 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); 261 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
270 if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() ) == 0) 262 if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() ))
271 { 263 {
@@ -275,4 +267,4 @@ void PmIpkg::remove()
275 { 267 {
276 out( "<br>removing links<br>" ); 268 out( "\nremoving links\n" );
277 out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"<br>" ); 269 out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"\n" );
278 processFileList( fileList, to_remove.at(i)->dest() ); 270 processFileList( fileList, to_remove.at(i)->dest() );
@@ -281,5 +273,5 @@ void PmIpkg::remove()
281 to_remove.take( i ); 273 to_remove.take( i );
282 out("<br><hr>"); 274 out("\n\n");
283 }else{ 275 }else{
284 out("<b>"+tr("Error while removing")+"</b><hr>"+to_remove.at(i)->name()); 276 out(tr("Error while removing")+to_remove.at(i)->name()+"\n");
285 } 277 }
@@ -288,3 +280,3 @@ void PmIpkg::remove()
288 to_remove.clear(); 280 to_remove.clear();
289 out("<br>"); 281 out("\n");
290} 282}
@@ -295,6 +287,6 @@ void PmIpkg::install()
295 if ( to_install.count() == 0 ) return; 287 if ( to_install.count() == 0 ) return;
296 out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); 288 out(tr("Installing")+"\n"+tr("please wait")+"\n");
297 for (uint i=0; i < to_install.count(); i++) 289 for (uint i=0; i < to_install.count(); i++)
298 { 290 {
299 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ) == 0 ) 291 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
300 { 292 {
@@ -304,4 +296,4 @@ void PmIpkg::install()
304 { 296 {
305 out( "<br>creating links<br>" ); 297 out( "\ncreating links\n" );
306 out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"<br>" ); 298 out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"\n" );
307 makeLinks( to_install.at(i) ); 299 makeLinks( to_install.at(i) );
@@ -310,8 +302,8 @@ void PmIpkg::install()
310 to_install.take( i ); 302 to_install.take( i );
311 out("<br><hr>"); 303 out("\n\n");
312 }else{ 304 }else{
313 out("<b>"+tr("Error while installing")+"</b><hr>"+to_install.at(i)->name()); 305 out(tr("Error while installing")+to_install.at(i)->name()+"\n");
314 } 306 }
315 } 307 }
316 out("<br>"); 308 out("\n");
317 to_install.clear(); 309 to_install.clear();
@@ -341,3 +333,3 @@ void PmIpkg::update()
341{ 333{
342 show( false ); 334 show();
343 runIpkg( "update" ); 335 runIpkg( "update" );
@@ -349,5 +341,3 @@ void PmIpkg::out( QString o )
349 runwindow->outPut->append(o); 341 runwindow->outPut->append(o);
350 //runwindow->outPut->setCursorPosition(0, runwindow->outPut->contentsHeight()); 342 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
351 //runwindow->outPut->setText( runwindow->outPut->text()+o );
352 runwindow->outPut->setContentsPos(0, runwindow->outPut->contentsHeight());
353} 343}
@@ -355,28 +345,17 @@ void PmIpkg::out( QString o )
355 345
356void PmIpkg::showButtons(bool b)
357{
358 if ( b )
359 {
360 runwindow->cancelButton->hide();
361 runwindow->doItButton->hide();
362 runwindow->removeButton->hide();
363 runwindow->installButton->hide();
364 }else{
365 runwindow->cancelButton->show();
366 runwindow->doItButton->show();
367 runwindow->removeButton->show();
368 runwindow->installButton->show();
369 346
370 }
371}
372 347
373void PmIpkg::show(bool b) 348void PmIpkg::show()
374{ 349{
375 if (!runwindow->isVisible()) 350 if (!runwindow->isVisible())
351 {
376 runwindow->showMaximized(); 352 runwindow->showMaximized();
377 showButtons(b); 353 runwindow->show();
378 if ( !b ) 354 }
379 runwindow->progress->hide(); 355 runwindow->outPut->setText("");
380 else 356 //showButtons(b);
381 runwindow->progress->show(); 357 //if ( !b )
358 // runwindow->progress->hide();
359// else
360 // runwindow->progress->show();
382} 361}