Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 142 |
1 files changed, 96 insertions, 46 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index b2ddf95..b23b9ea 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -1,6 +1,5 @@ | |||
1 | #include "pmipkg.h" | 1 | #include "pmipkg.h" |
2 | #include "pkdesc.h" | 2 | #include "pkdesc.h" |
3 | #include "pkfind.h" | ||
4 | #include "pksettings.h" | 3 | #include "pksettings.h" |
5 | #include "package.h" | 4 | #include "package.h" |
6 | #include "packagelistitem.h" | 5 | #include "packagelistitem.h" |
@@ -17,25 +16,22 @@ | |||
17 | #include <qtextstream.h> | 16 | #include <qtextstream.h> |
18 | #include <qtextview.h> | 17 | #include <qtextview.h> |
19 | 18 | ||
19 | #include <qprogressbar.h> | ||
20 | #include <qpushbutton.h> | ||
21 | #include <qlayout.h> | ||
22 | |||
20 | #include <stdlib.h> | 23 | #include <stdlib.h> |
21 | #include <unistd.h> | 24 | #include <unistd.h> |
22 | 25 | ||
23 | #include "mainwindow.h" | 26 | #include "mainwindow.h" |
24 | #include "runwindow.h" | ||
25 | |||
26 | 27 | ||
27 | #define PARSE_FILELIST | ||
28 | // #define IPKG_FILELIST | ||
29 | 28 | ||
30 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 29 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) |
31 | // : RunWindow ( p, name, f ) | ||
32 | : QObject ( p ) | 30 | : QObject ( p ) |
33 | { | 31 | { |
34 | settings = s; | 32 | settings = s; |
35 | runwindow = new RunWindow ( p, name, f ); | 33 | runwindowopen = false; |
36 | linkDest = new QCopChannel( "QPE/oipkg", this ); | 34 | runwindow = new RunWindow( p, name, true, f ); |
37 | connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)), | ||
38 | this, SLOT(linkDestination( const QString &, const QByteArray&)) ); | ||
39 | } | 35 | } |
40 | 36 | ||
41 | PmIpkg::~PmIpkg() | 37 | PmIpkg::~PmIpkg() |
@@ -73,14 +69,17 @@ int PmIpkg::runIpkg(const QString& args) | |||
73 | pvDebug(2, "running >"+cmd+"<"); | 69 | pvDebug(2, "running >"+cmd+"<"); |
74 | r = system(cmd.latin1()); | 70 | r = system(cmd.latin1()); |
75 | QFile f( redirect ); | 71 | QFile f( redirect ); |
72 | QString line; | ||
73 | QString oldLine; | ||
76 | while ( ! f.open(IO_ReadOnly) ) {}; | 74 | while ( ! f.open(IO_ReadOnly) ) {}; |
77 | // if ( f.open(IO_ReadOnly) ) {}; | ||
78 | { | 75 | { |
79 | QTextStream t( &f ); | 76 | QTextStream t( &f ); |
80 | QString fp; | 77 | // QString fp; |
81 | while ( !t.eof() ) | 78 | while ( !t.eof() ) |
82 | { | 79 | { |
83 | out( t.readLine() +"<br>" ); | 80 | line = t.readLine(); |
81 | if ( line != oldLine ) out( line +"<br>" ); | ||
82 | oldLine = line; | ||
84 | } | 83 | } |
85 | } | 84 | } |
86 | f.close(); | 85 | f.close(); |
@@ -96,12 +95,6 @@ void PmIpkg::makeLinks(QString pack) | |||
96 | out( "<br>creating links<br>" ); | 95 | out( "<br>creating links<br>" ); |
97 | QString dest = settings->getDestinationUrl(); | 96 | QString dest = settings->getDestinationUrl(); |
98 | out("for package "+pack+" in "+dest+"<br>"); | 97 | out("for package "+pack+" in "+dest+"<br>"); |
99 | #ifdef IPKG_FILELIST | ||
100 | system(("ipkg -d "+dest+" files "+pack+"> /tmp/oipkg.pipe 2>&1").latin1()); | ||
101 | QFile f( "/tmp/oipkg.pipe" ); | ||
102 | while ( ! f.open(IO_ReadOnly) ) {}; | ||
103 | #endif | ||
104 | #ifdef PARSE_FILELIST | ||
105 | { | 98 | { |
106 | Config cfg( "oipkg", Config::User ); | 99 | Config cfg( "oipkg", Config::User ); |
107 | cfg.setGroup( "Common" ); | 100 | cfg.setGroup( "Common" ); |
@@ -113,7 +106,6 @@ void PmIpkg::makeLinks(QString pack) | |||
113 | { | 106 | { |
114 | out( "<b>Panik!</b> Could not open:<br>"+fn ); | 107 | out( "<b>Panik!</b> Could not open:<br>"+fn ); |
115 | }; | 108 | }; |
116 | #endif | ||
117 | QTextStream t( &f ); | 109 | QTextStream t( &f ); |
118 | QString fp; | 110 | QString fp; |
119 | while ( !t.eof() ) | 111 | while ( !t.eof() ) |
@@ -126,14 +118,8 @@ void PmIpkg::makeLinks(QString pack) | |||
126 | 118 | ||
127 | void PmIpkg::processLinkDir( QString file, QString dest ) | 119 | void PmIpkg::processLinkDir( QString file, QString dest ) |
128 | { | 120 | { |
129 | |||
130 | #ifdef PARSE_FILELIST | ||
131 | QString destFile = file; | 121 | QString destFile = file; |
132 | file = dest+"/"+file; | 122 | file = dest+"/"+file; |
133 | #endif | ||
134 | #ifdef IPKG_FILELIST | ||
135 | QString destFile = file.right( file.length() - dest.length() ); | ||
136 | #endif | ||
137 | QFileInfo fileInfo( file ); | 123 | QFileInfo fileInfo( file ); |
138 | if ( fileInfo.isDir() ) | 124 | if ( fileInfo.isDir() ) |
139 | { | 125 | { |
@@ -146,7 +132,7 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
146 | QFileInfo *fi; | 132 | QFileInfo *fi; |
147 | while ( (fi=it.current()) ) | 133 | while ( (fi=it.current()) ) |
148 | { | 134 | { |
149 | out( "<b>"+fi->absFilePath()+"</b>" ); | 135 | // out( "<b>"+fi->absFilePath()+"</b>" ); |
150 | processLinkDir( fi->absFilePath(), dest ); | 136 | processLinkDir( fi->absFilePath(), dest ); |
151 | ++it; | 137 | ++it; |
152 | } | 138 | } |
@@ -155,7 +141,7 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
155 | { | 141 | { |
156 | const char *instFile = strdup( (file).ascii() ); | 142 | const char *instFile = strdup( (file).ascii() ); |
157 | const char *linkFile = strdup( (destFile).ascii()); | 143 | const char *linkFile = strdup( (destFile).ascii()); |
158 | out( "linking: "+file+" -> "+destFile ); | 144 | // out( "linking: "+file+" -> "+destFile ); |
159 | qDebug( "linking: %s -> %s", instFile, linkFile ); | 145 | qDebug( "linking: %s -> %s", instFile, linkFile ); |
160 | symlink( instFile, linkFile ); | 146 | symlink( instFile, linkFile ); |
161 | } | 147 | } |
@@ -163,11 +149,9 @@ void PmIpkg::processLinkDir( QString file, QString dest ) | |||
163 | 149 | ||
164 | void PmIpkg::commit( PackageList pl ) | 150 | void PmIpkg::commit( PackageList pl ) |
165 | { | 151 | { |
166 | runwindow->showMaximized(); | 152 | show( false ); |
167 | // exec(); | ||
168 | runwindow->outPut->setText(""); | 153 | runwindow->outPut->setText(""); |
169 | out( "<h1>Starting...</h1><br>\n"); | 154 | out( "<h1>"+tr("Todo")+"</h1>\n"); |
170 | QStringList to_remove, to_install; | ||
171 | 155 | ||
172 | QString rem="<b>To remove:</b><br>\n"; | 156 | QString rem="<b>To remove:</b><br>\n"; |
173 | QString inst="<b>To install:</b><br>\n";; | 157 | QString inst="<b>To install:</b><br>\n";; |
@@ -188,17 +172,58 @@ void PmIpkg::commit( PackageList pl ) | |||
188 | } | 172 | } |
189 | } | 173 | } |
190 | 174 | ||
191 | out("<p>"+inst+"</p>"+"<p>"+rem+"</p>"); | 175 | out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); |
192 | bool ok=TRUE; | ||
193 | 176 | ||
194 | qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); | 177 | qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); |
195 | 178 | ||
196 | int jobs = to_remove.count()+to_install.count(); | 179 | connect( runwindow->doItButton, SIGNAL( clicked() ), |
197 | if ( jobs < 1 ) return; | 180 | SLOT( doIt() ) ); |
181 | connect( runwindow->installButton, SIGNAL( clicked() ), | ||
182 | this, SLOT( install() ) ); | ||
183 | connect( runwindow->removeButton, SIGNAL( clicked() ), | ||
184 | this, SLOT( remove() ) ); | ||
185 | connect( runwindow->cancelButton, SIGNAL( clicked() ), | ||
186 | runwindow, SLOT( close() ) ); | ||
187 | |||
188 | runwindow->exec(); | ||
189 | // ##### If we looked in the list of files, we could send out accurate | ||
190 | // ##### messages. But we don't bother yet, and just do an "all". | ||
191 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
192 | QString lf = QString::null; | ||
193 | e << lf; | ||
194 | return; | ||
195 | } | ||
196 | |||
197 | void PmIpkg::doIt() | ||
198 | { | ||
199 | remove(); | ||
200 | install(); | ||
201 | } | ||
202 | |||
198 | 203 | ||
199 | if ( to_remove.count() ) | 204 | void PmIpkg::remove() |
205 | { | ||
206 | if ( to_remove.count() == 0 ) return; | ||
207 | show( true ); | ||
208 | |||
209 | out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); | ||
200 | for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) | 210 | for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) |
201 | if ( runIpkg("remove " + *it) != 0 ) ok = false; | 211 | { |
212 | if ( runIpkg("remove " + *it) == 0) | ||
213 | { | ||
214 | |||
215 | }else{ | ||
216 | out("<b>"+tr("Error while removing")+"</b>"+*it); | ||
217 | } | ||
218 | } | ||
219 | } | ||
220 | |||
221 | |||
222 | void PmIpkg::install() | ||
223 | { | ||
224 | if ( to_install.count() == 0 ) return; | ||
225 | show( true ); | ||
226 | out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"<b><br>"); | ||
202 | if ( to_install.count() ) | 227 | if ( to_install.count() ) |
203 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) | 228 | for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) |
204 | { | 229 | { |
@@ -207,15 +232,10 @@ void PmIpkg::commit( PackageList pl ) | |||
207 | if ( settings->createLinks() ) | 232 | if ( settings->createLinks() ) |
208 | makeLinks( *it ); | 233 | makeLinks( *it ); |
209 | }else{ | 234 | }else{ |
210 | ok = false; | 235 | out("<b>"+tr("Error while installing")+"</b>"+*it); |
211 | } | 236 | } |
212 | } | 237 | } |
213 | 238 | ||
214 | // ##### If we looked in the list of files, we could send out accurate | ||
215 | // ##### messages. But we don't bother yet, and just do an "all". | ||
216 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | ||
217 | QString lf = QString::null; | ||
218 | e << lf; | ||
219 | } | 239 | } |
220 | 240 | ||
221 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) | 241 | void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) |
@@ -236,12 +256,42 @@ void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) | |||
236 | 256 | ||
237 | void PmIpkg::update() | 257 | void PmIpkg::update() |
238 | { | 258 | { |
239 | runwindow->showMaximized(); | 259 | show( false ); |
240 | runIpkg( "update" ); | 260 | runIpkg( "update" ); |
261 | runwindow->close(); | ||
241 | } | 262 | } |
242 | 263 | ||
243 | void PmIpkg::out( QString o ) | 264 | void PmIpkg::out( QString o ) |
244 | { | 265 | { |
245 | runwindow->outPut->setText( runwindow->outPut->text()+o ); | 266 | runwindow->outPut->setText( runwindow->outPut->text()+o ); |
246 | runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight()); | 267 | runwindow->outPut->setContentsPos(0, runwindow->outPut->contentsHeight()); |
268 | } | ||
269 | |||
270 | |||
271 | void PmIpkg::showButtons(bool b) | ||
272 | { | ||
273 | if ( b ) | ||
274 | { | ||
275 | runwindow->cancelButton->hide(); | ||
276 | runwindow->doItButton->hide(); | ||
277 | runwindow->removeButton->hide(); | ||
278 | runwindow->installButton->hide(); | ||
279 | }else{ | ||
280 | runwindow->cancelButton->show(); | ||
281 | runwindow->doItButton->show(); | ||
282 | runwindow->removeButton->show(); | ||
283 | runwindow->installButton->show(); | ||
284 | |||
285 | } | ||
286 | } | ||
287 | |||
288 | void PmIpkg::show(bool b) | ||
289 | { | ||
290 | if (!runwindow->isVisible()) | ||
291 | runwindow->showMaximized(); | ||
292 | showButtons(b); | ||
293 | if ( b ) | ||
294 | runwindow->progress->show(); | ||
295 | else | ||
296 | runwindow->progress->show(); | ||
247 | } | 297 | } |