author | tille <tille> | 2002-05-04 17:12:04 (UTC) |
---|---|---|
committer | tille <tille> | 2002-05-04 17:12:04 (UTC) |
commit | d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3 (patch) (unidiff) | |
tree | 28b9871643caac8c975008677a2a058a62e8f201 /noncore/unsupported | |
parent | 4fe6b62e42697c68cd54ac3954ffc536e6f2c0f7 (diff) | |
download | opie-d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3.zip opie-d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3.tar.gz opie-d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3.tar.bz2 |
popen thanks to ljp
but still does not work from the launcher
but only from the command line
-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 153 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/runwindow.ui | 118 |
5 files changed, 80 insertions, 206 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 | |||
@@ -5,3 +5,3 @@ | |||
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qmessagebox.h> | 6 | //#include <qmessagebox.h> |
7 | int debugLevel; | 7 | int debugLevel; |
@@ -19,4 +19,4 @@ int main( int argc, char ** 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 ); |
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 | |||
@@ -95,4 +95,4 @@ void MainWindow::makeMenu() | |||
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 | ||
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 | 41 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) |
41 | #define SYSTEM | ||
42 | #define QT_QPROCESS_DEBUG | ||
43 | int 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 | { | 90 | } |
98 | out( line +"<br>" ); | 91 | pclose(fp); |
99 | oldLine = line; | 92 | } |
100 | } | 93 | //out( "Finished!"); |
101 | } | 94 | pvDebug(2,QString(ret?"success\n":"failure\n")); |
102 | f.close(); | 95 | return ret; |
103 | out( "Finished!<br>"); | ||
104 | #endif | ||
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 | ||
356 | void 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 | ||
373 | void PmIpkg::show(bool b) | 348 | void 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 | } |
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 | |||
@@ -29,4 +29,3 @@ public: | |||
29 | void update(); | 29 | void update(); |
30 | void showButtons(bool b=true); | 30 | void show(); |
31 | void show( bool buttons=true ); | ||
32 | 31 | ||
@@ -55,3 +54,3 @@ private: | |||
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 ); |
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 | |||
@@ -13,3 +13,3 @@ | |||
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>344</width> | 14 | <width>340</width> |
15 | <height>442</height> | 15 | <height>442</height> |
@@ -47,112 +47,4 @@ | |||
47 | </widget> | 47 | </widget> |
48 | <widget row="3" column="0" > | ||
49 | <class>QLayoutWidget</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"> | ||
136 | <name>name</name> | ||
137 | <cstring>cancelButton</cstring> | ||
138 | </property> | ||
139 | <property stdset="1"> | ||
140 | <name>font</name> | ||
141 | <font> | ||
142 | <pointsize>8</pointsize> | ||
143 | </font> | ||
144 | </property> | ||
145 | <property stdset="1"> | ||
146 | <name>text</name> | ||
147 | <string>Cancel</string> | ||
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" > | 48 | <widget row="1" column="0" > |
157 | <class>QTextView</class> | 49 | <class>QMultiLineEdit</class> |
158 | <property stdset="1"> | 50 | <property stdset="1"> |
@@ -164,5 +56,9 @@ | |||
164 | <font> | 56 | <font> |
165 | <pointsize>6</pointsize> | 57 | <pointsize>8</pointsize> |
166 | </font> | 58 | </font> |
167 | </property> | 59 | </property> |
60 | <property stdset="1"> | ||
61 | <name>wordWrap</name> | ||
62 | <enum>WidgetWidth</enum> | ||
63 | </property> | ||
168 | </widget> | 64 | </widget> |