summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/main.cpp6
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp4
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp149
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h5
-rw-r--r--noncore/unsupported/oipkg/runwindow.ui116
5 files changed, 77 insertions, 203 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp
index d98bcaa..bb3d1db 100644
--- a/noncore/unsupported/oipkg/main.cpp
+++ b/noncore/unsupported/oipkg/main.cpp
@@ -3,7 +3,7 @@
3 3
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <qmessagebox.h> 6//#include <qmessagebox.h>
7int debugLevel; 7int debugLevel;
8 8
9int main( int argc, char ** argv ) 9int main( int argc, char ** argv )
@@ -17,8 +17,8 @@ int main( int argc, char ** argv )
17 } 17 }
18 QPEApplication a( argc, argv ); 18 QPEApplication a( argc, argv );
19 MainWindow mw; 19 MainWindow mw;
20 if (argc > 2) 20// if (argc > 2)
21 QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); 21 // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!");
22 a.showMainDocumentWidget( &mw ); 22 a.showMainDocumentWidget( &mw );
23 return a.exec(); 23 return a.exec();
24} 24}
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index 55f915d..2fa91e3 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -93,8 +93,8 @@ void MainWindow::makeMenu()
93 // menuBar->insertItem( tr( "Sections" ), sectMenu ); 93 // menuBar->insertItem( tr( "Sections" ), sectMenu );
94 94
95 QLabel *spacer = new QLabel( "", toolBar ); 95 QLabel *spacer = new QLabel( "", toolBar );
96 spacer->setBackgroundColor( toolBar->backgroundColor() ); 96// spacer->setBackgroundColor( toolBar->backgroundColor() );
97 toolBar->setStretchableWidget( spacer ); 97// toolBar->setStretchableWidget( spacer );
98 98
99 99
100 runAction = new QAction( tr( "Apply" ), 100 runAction = new QAction( tr( "Apply" ),
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
@@ -7,6 +7,7 @@
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <qpe/config.h> 8#include <qpe/config.h>
9#include <qpe/stringutil.h> 9#include <qpe/stringutil.h>
10#include <qpe/qpeapplication.h>
10#include <qdir.h> 11#include <qdir.h>
11#include <qfile.h> 12#include <qfile.h>
12#include <qgroupbox.h> 13#include <qgroupbox.h>
@@ -37,19 +38,11 @@ PmIpkg::~PmIpkg()
37{ 38{
38} 39}
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);
54 if ( dest == "" ) 47 if ( dest == "" )
55 cmd += " -dest "+settings->getDestinationName(); 48 cmd += " -dest "+settings->getDestinationName();
@@ -68,42 +61,38 @@ int PmIpkg::runIpkg(const QString& args, const QString& dest )
68 cmd += " -force-removal-of-essential-packages "; 61 cmd += " -force-removal-of-essential-packages ";
69 } 62 }
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}
108 97
109void PmIpkg::makeLinks(Package *pack) 98void PmIpkg::makeLinks(Package *pack)
@@ -127,7 +116,7 @@ QStringList* PmIpkg::getList( QString packFileName, QString d )
127 if ( ! f.open(IO_ReadOnly) ) 116 if ( ! f.open(IO_ReadOnly) )
128 { 117 {
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;
132 } 121 }
133 QStringList *fileList = new QStringList(); 122 QStringList *fileList = new QStringList();
@@ -243,15 +232,18 @@ void PmIpkg::commit()
243 runwindow->progress->setTotalSteps(sizecount); 232 runwindow->progress->setTotalSteps(sizecount);
244 qDebug("Install size %i",sizecount); 233 qDebug("Install size %i",sizecount);
245 installDialog->showMaximized(); 234 installDialog->showMaximized();
235 installDialog->show();
246 if ( installDialog->exec() ) doIt(); 236 if ( installDialog->exec() ) doIt();
247 installDialog->close(); 237 installDialog->close();
248 runwindow->showMaximized(); 238 runwindow->showMaximized();
249 out(tr("<b>All done.</b>")); 239 runwindow->show();
240 out(tr("\nAll done."));
250} 241}
251 242
252void PmIpkg::doIt() 243void PmIpkg::doIt()
253{ 244{
254 show( true ); 245 runwindow->progress->setProgress(0);
246 show();
255 remove(); 247 remove();
256 install(); 248 install();
257} 249}
@@ -261,59 +253,59 @@ void PmIpkg::remove()
261{ 253{
262 if ( to_remove.count() == 0 ) return; 254 if ( to_remove.count() == 0 ) return;
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
266 QStringList *fileList; 258 QStringList *fileList;
267 for (uint i=0; i < to_remove.count(); i++) 259 for (uint i=0; i < to_remove.count(); i++)
268 { 260 {
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 {
272 runwindow->progress->setProgress( 1 ); 264 runwindow->progress->setProgress( 1 );
273 linkOpp = removeLink; 265 linkOpp = removeLink;
274 if ( to_remove.at(i)->link() ) 266 if ( to_remove.at(i)->link() )
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() );
279 } 271 }
280 to_remove.at(i)->processed(); 272 to_remove.at(i)->processed();
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 }
286 if ( to_remove.at(i)->link() )delete fileList; 278 if ( to_remove.at(i)->link() )delete fileList;
287 } 279 }
288 to_remove.clear(); 280 to_remove.clear();
289 out("<br>"); 281 out("\n");
290} 282}
291 283
292 284
293void PmIpkg::install() 285void PmIpkg::install()
294{ 286{
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 {
301 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); 293 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
302 linkOpp = createLink; 294 linkOpp = createLink;
303 if ( to_install.at(i)->link() ) 295 if ( to_install.at(i)->link() )
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) );
308 } 300 }
309 to_install.at(i)->processed(); 301 to_install.at(i)->processed();
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();
318} 310}
319 311
@@ -339,7 +331,7 @@ void PmIpkg::removeLinks( const QString &dest )
339 331
340void PmIpkg::update() 332void PmIpkg::update()
341{ 333{
342 show( false ); 334 show();
343 runIpkg( "update" ); 335 runIpkg( "update" );
344 runwindow->close(); 336 runwindow->close();
345} 337}
@@ -347,38 +339,25 @@ void PmIpkg::update()
347void PmIpkg::out( QString o ) 339void PmIpkg::out( QString o )
348{ 340{
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}
354 344
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}
383 362
384void PmIpkg::installFile(const QString &fileName, const QString &dest) 363void PmIpkg::installFile(const QString &fileName, const QString &dest)
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
index 7bc62f1..f8ac39a 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -27,8 +27,7 @@ public:
27 void loadList( PackageList* ); 27 void loadList( PackageList* );
28 void commit(); 28 void commit();
29 void update(); 29 void update();
30 void showButtons(bool b=true); 30 void show();
31 void show( bool buttons=true );
32 31
33public slots: 32public slots:
34 void doIt(); 33 void doIt();
@@ -53,7 +52,7 @@ private:
53 void makeLinks(Package*); 52 void makeLinks(Package*);
54 void linkPackage( QString, QString ); 53 void linkPackage( QString, QString );
55 void processLinkDir( QString , QString ); 54 void processLinkDir( QString , QString );
56 int runIpkg(const QString& args, const QString& dest="" ); 55 bool runIpkg(const QString& args, const QString& dest="" );
57 void out( QString ); 56 void out( QString );
58 QStringList* getList( QString, QString ); 57 QStringList* getList( QString, QString );
59 void processFileList( QStringList*, QString ); 58 void processFileList( QStringList*, QString );
diff --git a/noncore/unsupported/oipkg/runwindow.ui b/noncore/unsupported/oipkg/runwindow.ui
index 8582ce8..839e151 100644
--- a/noncore/unsupported/oipkg/runwindow.ui
+++ b/noncore/unsupported/oipkg/runwindow.ui
@@ -11,7 +11,7 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>344</width> 14 <width>340</width>
15 <height>442</height> 15 <height>442</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
@@ -45,96 +45,11 @@
45 <number>0</number> 45 <number>0</number>
46 </property> 46 </property>
47 </widget> 47 </widget>
48 <widget row="3" column="0" > 48 <widget row="1" column="0" >
49 <class>QLayoutWidget</class> 49 <class>QMultiLineEdit</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>buttons</cstring>
53 </property>
54 <hbox>
55 <property stdset="1">
56 <name>margin</name>
57 <number>0</number>
58 </property>
59 <property stdset="1">
60 <name>spacing</name>
61 <number>6</number>
62 </property>
63 <widget>
64 <class>QPushButton</class>
65 <property stdset="1">
66 <name>name</name>
67 <cstring>doItButton</cstring>
68 </property>
69 <property stdset="1">
70 <name>sizePolicy</name>
71 <sizepolicy>
72 <hsizetype>0</hsizetype>
73 <vsizetype>0</vsizetype>
74 </sizepolicy>
75 </property>
76 <property stdset="1">
77 <name>font</name>
78 <font>
79 <pointsize>8</pointsize>
80 </font>
81 </property>
82 <property stdset="1">
83 <name>text</name>
84 <string>Do all </string>
85 </property>
86 <property stdset="1">
87 <name>autoResize</name>
88 <bool>false</bool>
89 </property>
90 </widget>
91 <widget>
92 <class>QPushButton</class>
93 <property stdset="1">
94 <name>name</name>
95 <cstring>installButton</cstring>
96 </property>
97 <property stdset="1">
98 <name>font</name>
99 <font>
100 <pointsize>8</pointsize>
101 </font>
102 </property>
103 <property stdset="1">
104 <name>text</name>
105 <string>Install</string>
106 </property>
107 <property stdset="1">
108 <name>autoResize</name>
109 <bool>true</bool>
110 </property>
111 </widget>
112 <widget>
113 <class>QPushButton</class>
114 <property stdset="1">
115 <name>name</name>
116 <cstring>removeButton</cstring>
117 </property>
118 <property stdset="1">
119 <name>font</name>
120 <font>
121 <pointsize>7</pointsize>
122 </font>
123 </property>
124 <property stdset="1">
125 <name>text</name>
126 <string>Remove</string>
127 </property>
128 <property stdset="1">
129 <name>autoResize</name>
130 <bool>true</bool>
131 </property>
132 </widget>
133 <widget>
134 <class>QPushButton</class>
135 <property stdset="1"> 50 <property stdset="1">
136 <name>name</name> 51 <name>name</name>
137 <cstring>cancelButton</cstring> 52 <cstring>outPut</cstring>
138 </property> 53 </property>
139 <property stdset="1"> 54 <property stdset="1">
140 <name>font</name> 55 <name>font</name>
@@ -143,27 +58,8 @@
143 </font> 58 </font>
144 </property> 59 </property>
145 <property stdset="1"> 60 <property stdset="1">
146 <name>text</name> 61 <name>wordWrap</name>
147 <string>Cancel</string> 62 <enum>WidgetWidth</enum>
148 </property>
149 <property stdset="1">
150 <name>autoResize</name>
151 <bool>true</bool>
152 </property>
153 </widget>
154 </hbox>
155 </widget>
156 <widget row="1" column="0" >
157 <class>QTextView</class>
158 <property stdset="1">
159 <name>name</name>
160 <cstring>outPut</cstring>
161 </property>
162 <property stdset="1">
163 <name>font</name>
164 <font>
165 <pointsize>6</pointsize>
166 </font>
167 </property> 63 </property>
168 </widget> 64 </widget>
169 </grid> 65 </grid>