summaryrefslogtreecommitdiff
authortille <tille>2002-06-25 11:24:49 (UTC)
committer tille <tille>2002-06-25 11:24:49 (UTC)
commitd282b4f9cba20305e237910aca531b0360666f13 (patch) (unidiff)
tree38845ae936110de2b60fe67191d83ba5a2232726
parent8b39fcc7dbc0579c27e42918974a407104dc9fac (diff)
downloadopie-d282b4f9cba20305e237910aca531b0360666f13.zip
opie-d282b4f9cba20305e237910aca531b0360666f13.tar.gz
opie-d282b4f9cba20305e237910aca531b0360666f13.tar.bz2
getting the list file right now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/package.cpp8
-rw-r--r--noncore/unsupported/oipkg/package.h1
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp5
3 files changed, 12 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 517b37a..8bbdd77 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,453 +1,461 @@
1#include "package.h" 1#include "package.h"
2 2
3#include <qpe/process.h> 3#include <qpe/process.h>
4#include <qpe/stringutil.h> 4#include <qpe/stringutil.h>
5#include <qfile.h> 5#include <qfile.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <unistd.h> 8#include <unistd.h>
9 9
10#include "debug.h" 10#include "debug.h"
11 11
12Package::Package( QObject *parent, const char *name ) 12Package::Package( QObject *parent, const char *name )
13 : QObject(parent,name) 13 : QObject(parent,name)
14{ 14{
15 15
16} 16}
17 17
18Package::~Package() 18Package::~Package()
19{ 19{
20} 20}
21 21
22Package::Package( PackageManagerSettings *s, QObject *parent, const char *name ) 22Package::Package( PackageManagerSettings *s, QObject *parent, const char *name )
23 : QObject(parent,name) 23 : QObject(parent,name)
24{ 24{
25 Package(parent,name); 25 Package(parent,name);
26 init(s); 26 init(s);
27} 27}
28 28
29void Package::init( PackageManagerSettings *s ) 29void Package::init( PackageManagerSettings *s )
30{ 30{
31 settings = s; 31 settings = s;
32 _size = ""; 32 _size = "";
33 _section = ""; 33 _section = "";
34 _subsection = ""; 34 _subsection = "";
35 _shortDesc = ""; 35 _shortDesc = "";
36 _desc = ""; 36 _desc = "";
37 _name = ""; 37 _name = "";
38 _toProcess = false; 38 _toProcess = false;
39 _useFileName = false; 39 _useFileName = false;
40 _old = false; 40 _old = false;
41 _status = ""; 41 _status = "";
42 _dest = settings->getDestinationName(); 42 _dest = settings->getDestinationName();
43 _link = settings->createLinks(); 43 _link = settings->createLinks();
44 _versions=0; 44 _versions=0;
45 _version=""; 45 _version="";
46} 46}
47 47
48Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) 48Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name )
49 : QObject(parent,name) 49 : QObject(parent,name)
50 { 50 {
51 init(s); 51 init(s);
52 parsePackage( pack ); 52 parsePackage( pack );
53} 53}
54 54
55Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) 55Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name )
56 { 56 {
57 init(s); 57 init(s);
58 if ( !QFile::exists( n ) ) 58 if ( !QFile::exists( n ) )
59 { 59 {
60 _name = QString( n ); 60 _name = QString( n );
61 }else{ 61 }else{
62 pvDebug(4,"remote file: "+n); 62 pvDebug(4,"remote file: "+n);
63 parseIpkgFile( n ); 63 parseIpkgFile( n );
64 _useFileName = true; 64 _useFileName = true;
65 _fileName = QString( n ); 65 _fileName = QString( n );
66 } 66 }
67} 67}
68 68
69Package::Package( Package *pi, QObject *parent, const char *name ) 69Package::Package( Package *pi, QObject *parent, const char *name )
70{ 70{
71 init(pi->settings); 71 init(pi->settings);
72 copyValues( pi ); 72 copyValues( pi );
73} 73}
74 74
75 75
76void Package::setValue( QString n, QString t ) 76void Package::setValue( QString n, QString t )
77{ 77{
78 if ( n == "Package" ) 78 if ( n == "Package" )
79 { 79 {
80 _name = QString( t ); 80 _name = QString( t );
81 }else if ( n == "Installed-Size" ) 81 }else if ( n == "Installed-Size" )
82 { 82 {
83 _size = t; 83 _size = t;
84// }else if ( n == "Priority") 84// }else if ( n == "Priority")
85// { 85// {
86 86
87 }else if ( n == "Section") 87 }else if ( n == "Section")
88 { 88 {
89 setSection( t ); 89 setSection( t );
90// }else if ( n == "Maintainer") 90// }else if ( n == "Maintainer")
91// { 91// {
92// 92//
93// }else if ( n == "Architecture") 93// }else if ( n == "Architecture")
94// { 94// {
95 95
96 }else if ( n == "Version") 96 }else if ( n == "Version")
97 { 97 {
98 _version = t; 98 _version = t;
99// }else if ( n == "Pre-Depends") 99// }else if ( n == "Pre-Depends")
100// { 100// {
101// 101//
102// }else if ( n == "Depends") 102// }else if ( n == "Depends")
103// { 103// {
104 104
105 }else if ( n == "Filename") 105 }else if ( n == "Filename")
106 { 106 {
107 _fileName = t; 107 _fileName = t;
108// }else if ( n == "Size") 108// }else if ( n == "Size")
109 // { 109 // {
110 // 110 //
111 //}else if ( n == "MD5Sum") 111 //}else if ( n == "MD5Sum")
112 //{ 112 //{
113 113
114 }else if ( n == "Description") 114 }else if ( n == "Description")
115 { 115 {
116 setDesc( t ); 116 setDesc( t );
117 }else if ( n == "Status") 117 }else if ( n == "Status")
118 { 118 {
119 if ( installed() ) return; 119 if ( installed() ) return;
120 _status = t; 120 _status = t;
121// }else if ( n == "Essential") 121// }else if ( n == "Essential")
122// { 122// {
123 123
124 }else{ 124 }else{
125 _values.insert(n,new QString(t)); 125 _values.insert(n,new QString(t));
126 } 126 }
127} 127}
128 128
129QString Package::name() 129QString Package::name()
130{ 130{
131 if (_displayName.isEmpty() ) return _name; 131 if (_displayName.isEmpty() ) return _name;
132 else return _displayName; 132 else return _displayName;
133} 133}
134 134
135 135
136QString Package::installName() 136QString Package::installName()
137{ 137{
138 if (_useFileName) return _fileName; 138 if (_useFileName) return _fileName;
139 else return _name; 139 else return _name;
140} 140}
141 141
142QString Package::packageName()
143{
144 QString pn = installName();
145 pn = pn.right(pn.length()-pn.findRev("/"));
146 pn = pn.left(pn.find("_"));
147 return pn;
148}
149
142bool Package::installed() 150bool Package::installed()
143{ 151{
144 if (_status.contains("installed")) 152 if (_status.contains("installed"))
145 { 153 {
146 if (_status.contains("not-installed")) 154 if (_status.contains("not-installed"))
147 { 155 {
148 _toProcess = true; 156 _toProcess = true;
149 return false; 157 return false;
150 } 158 }
151 else return true; 159 else return true;
152 } 160 }
153 else 161 else
154 if (_versions) 162 if (_versions)
155 { 163 {
156 QDictIterator<Package> other( *_versions ); 164 QDictIterator<Package> other( *_versions );
157 while ( other.current() ) 165 while ( other.current() )
158 { 166 {
159 if (other.current()->status().contains("installed") 167 if (other.current()->status().contains("installed")
160 && other.current()->version() == version()) 168 && other.current()->version() == version())
161 return true; 169 return true;
162 ++other; 170 ++other;
163 } 171 }
164 } 172 }
165 return false; 173 return false;
166} 174}
167 175
168bool Package::otherInstalled() 176bool Package::otherInstalled()
169{ 177{
170 if (_versions) 178 if (_versions)
171 { 179 {
172 QDictIterator<Package> other( *_versions ); 180 QDictIterator<Package> other( *_versions );
173 while ( other.current() ) 181 while ( other.current() )
174 { 182 {
175 if (other.current()->installed()) return true; 183 if (other.current()->installed()) return true;
176 ++other; 184 ++other;
177 } 185 }
178 } 186 }
179 return false; 187 return false;
180} 188}
181 189
182void Package::setDesc( QString s ) 190void Package::setDesc( QString s )
183{ 191{
184 _desc = s; 192 _desc = s;
185 _shortDesc = s.left( s.find("\n") ); 193 _shortDesc = s.left( s.find("\n") );
186} 194}
187 195
188QString Package::desc() 196QString Package::desc()
189{ 197{
190 return _desc; 198 return _desc;
191} 199}
192 200
193QString Package::shortDesc() 201QString Package::shortDesc()
194{ 202{
195 return _shortDesc; 203 return _shortDesc;
196} 204}
197 205
198QString Package::size() 206QString Package::size()
199{ 207{
200 return _size; 208 return _size;
201} 209}
202 210
203 211
204QString Package::version() 212QString Package::version()
205{ 213{
206 return _version; 214 return _version;
207} 215}
208 216
209QString Package::sizeUnits() 217QString Package::sizeUnits()
210{ 218{
211 int i = _size.toInt(); 219 int i = _size.toInt();
212 int c = 0; 220 int c = 0;
213 QString ret; 221 QString ret;
214 QStringList unit; 222 QStringList unit;
215 unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) 223 unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;)
216 while (i > 1) 224 while (i > 1)
217 { 225 {
218 ret=QString::number(i)+" "+unit[c]; 226 ret=QString::number(i)+" "+unit[c];
219 c++; 227 c++;
220 i /= 1024; 228 i /= 1024;
221 } 229 }
222 return ret; 230 return ret;
223} 231}
224 232
225bool Package::toProcess() 233bool Package::toProcess()
226{ 234{
227 return _toProcess; 235 return _toProcess;
228} 236}
229 237
230bool Package::toRemove() 238bool Package::toRemove()
231{ 239{
232 if ( _toProcess && installed() ) return true; 240 if ( _toProcess && installed() ) return true;
233 else return false; 241 else return false;
234} 242}
235 243
236bool Package::toInstall() 244bool Package::toInstall()
237{ 245{
238 if ( _toProcess && !installed() ) return true; 246 if ( _toProcess && !installed() ) return true;
239 else return false; 247 else return false;
240} 248}
241 249
242void Package::toggleProcess() 250void Package::toggleProcess()
243{ 251{
244 _toProcess = ! _toProcess; 252 _toProcess = ! _toProcess;
245} 253}
246 254
247 255
248 256
249void Package::copyValues( Package* pack ) 257void Package::copyValues( Package* pack )
250{ 258{
251 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); 259 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size );
252 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); 260 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section );
253 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); 261 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection );
254 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); 262 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc );
255 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); 263 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc );
256 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); 264 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name );
257 if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); 265 if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest );
258 if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); 266 if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName );
259 if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); 267 if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName );
260 if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); 268 if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version );
261 if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); 269 if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values );
262 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); 270 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status );
263} 271}
264 272
265QString Package::section() 273QString Package::section()
266{ 274{
267 return _section; 275 return _section;
268} 276}
269 277
270void Package::setSection( QString s) 278void Package::setSection( QString s)
271{ 279{
272 int i = s.find("/"); 280 int i = s.find("/");
273 if ( i > 0 ) 281 if ( i > 0 )
274 { 282 {
275 _section = s.left(i); 283 _section = s.left(i);
276 _subsection = s.mid(i+1); 284 _subsection = s.mid(i+1);
277 }else{ 285 }else{
278 _section = s; 286 _section = s;
279 _subsection = ""; 287 _subsection = "";
280 } 288 }
281} 289}
282 290
283QString Package::subSection() 291QString Package::subSection()
284{ 292{
285 return _subsection; 293 return _subsection;
286} 294}
287 295
288void Package::parsePackage( QStringList pack ) 296void Package::parsePackage( QStringList pack )
289{ 297{
290 if ( pack.isEmpty() ) return; 298 if ( pack.isEmpty() ) return;
291 int count = pack.count(); 299 int count = pack.count();
292 for( int i = 0; i < count; i++ ) 300 for( int i = 0; i < count; i++ )
293 { 301 {
294 QString line = pack[i]; 302 QString line = pack[i];
295 int sep = line.find( QRegExp(":[\t ]+") ); 303 int sep = line.find( QRegExp(":[\t ]+") );
296 if ( sep >= 0 ) 304 if ( sep >= 0 )
297 { 305 {
298 QString tag = line.left(sep); 306 QString tag = line.left(sep);
299 QString value = line.mid(sep+2).simplifyWhiteSpace(); 307 QString value = line.mid(sep+2).simplifyWhiteSpace();
300 setValue( tag, value ); 308 setValue( tag, value );
301 }else{ 309 }else{
302 } 310 }
303 } 311 }
304 return; 312 return;
305} 313}
306 314
307QString Package::details() 315QString Package::details()
308{ 316{
309 QString status; 317 QString status;
310 Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); 318 Process ipkg_status(QStringList() << "ipkg" << "info" << name() );
311 QString description; 319 QString description;
312 if ( ipkg_status.exec("",status) ) 320 if ( ipkg_status.exec("",status) )
313 { 321 {
314 QStringList lines = QStringList::split('\n',status,TRUE); 322 QStringList lines = QStringList::split('\n',status,TRUE);
315 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { 323 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
316 QString line = *it; 324 QString line = *it;
317 if ( line == " ." ) 325 if ( line == " ." )
318 { 326 {
319 description.append("<p>"); 327 description.append("<p>");
320 } else 328 } else
321 if ( line[0] == ' ' || line[0] == '\t' ) 329 if ( line[0] == ' ' || line[0] == '\t' )
322 { 330 {
323 // continuation 331 // continuation
324 description.append(" "); 332 description.append(" ");
325 description.append(Qtopia::escapeString(line)); 333 description.append(Qtopia::escapeString(line));
326 } else { 334 } else {
327 int sep = line.find(QRegExp(":[\t ]+")); 335 int sep = line.find(QRegExp(":[\t ]+"));
328 if ( sep >= 0 ) 336 if ( sep >= 0 )
329 { 337 {
330 QString tag = line.left(sep); 338 QString tag = line.left(sep);
331 description.append("<br>"); 339 description.append("<br>");
332 description.append("<b>"); 340 description.append("<b>");
333 description.append(Qtopia::escapeString(tag)); 341 description.append(Qtopia::escapeString(tag));
334 description.append(":</b> "); 342 description.append(":</b> ");
335 description.append(Qtopia::escapeString(line.mid(sep+2))); 343 description.append(Qtopia::escapeString(line.mid(sep+2)));
336 } else { 344 } else {
337 description.append(" "); 345 description.append(" ");
338 description.append(Qtopia::escapeString(line)); 346 description.append(Qtopia::escapeString(line));
339 } 347 }
340 } 348 }
341 } 349 }
342 } 350 }
343 return description; 351 return description;
344} 352}
345 353
346void Package::processed() 354void Package::processed()
347{ 355{
348 _toProcess = false; 356 _toProcess = false;
349 //hack, but we're not writing status anyway... 357 //hack, but we're not writing status anyway...
350 if ( installed() ) _status = "install"; 358 if ( installed() ) _status = "install";
351 else _status = "installed"; 359 else _status = "installed";
352} 360}
353 361
354QString Package::dest() 362QString Package::dest()
355{ 363{
356 if ( installed()||(!installed() && _toProcess) ) 364 if ( installed()||(!installed() && _toProcess) )
357 return _dest!=""?_dest:settings->getDestinationName(); 365 return _dest!=""?_dest:settings->getDestinationName();
358 else return ""; 366 else return "";
359} 367}
360 368
361void Package::setDest( QString d ) 369void Package::setDest( QString d )
362{ 370{
363 if ( d == "remote") _useFileName = true; 371 if ( d == "remote") _useFileName = true;
364 else _dest = d; 372 else _dest = d;
365} 373}
366 374
367void Package::setOn() 375void Package::setOn()
368{ 376{
369 _toProcess = true; 377 _toProcess = true;
370} 378}
371 379
372bool Package::link() 380bool Package::link()
373{ 381{
374 if ( _dest == "root" || (!installed() && !_toProcess) ) return false; 382 if ( _dest == "root" || (!installed() && !_toProcess) ) return false;
375 return _link; 383 return _link;
376} 384}
377 385
378void Package::setLink(bool b) 386void Package::setLink(bool b)
379{ 387{
380 _link = b; 388 _link = b;
381} 389}
382 390
383void Package::parseIpkgFile( QString file) 391void Package::parseIpkgFile( QString file)
384{ 392{
385 system("tar xzf "+file+" -C /tmp"); 393 system("tar xzf "+file+" -C /tmp");
386 system("tar xzf /tmp/control.tar.gz -C /tmp"); 394 system("tar xzf /tmp/control.tar.gz -C /tmp");
387 QFile f("/tmp/control"); 395 QFile f("/tmp/control");
388 if ( f.open(IO_ReadOnly) ) 396 if ( f.open(IO_ReadOnly) )
389 { 397 {
390 QTextStream t( &f ); 398 QTextStream t( &f );
391 QStringList pack; 399 QStringList pack;
392 while ( !t.eof() ) 400 while ( !t.eof() )
393 { 401 {
394 pack << t.readLine(); 402 pack << t.readLine();
395 } 403 }
396 f.close(); 404 f.close();
397 parsePackage( pack ); 405 parsePackage( pack );
398 } 406 }
399 407
400} 408}
401 409
402//QString Package::getPackageName() 410//QString Package::getPackageName()
403//{ 411//{
404 //if ( _packageName.isEmpty() ) return _name; 412 //if ( _packageName.isEmpty() ) return _name;
405 //else return _packageName; 413 //else return _packageName;
406//} 414//}
407 415
408void Package::instalFromFile(bool iff) 416void Package::instalFromFile(bool iff)
409{ 417{
410 _useFileName = iff; 418 _useFileName = iff;
411} 419}
412 420
413void Package::setName(QString n) 421void Package::setName(QString n)
414{ 422{
415 _displayName = n; 423 _displayName = n;
416} 424}
417 425
418QDict<QString>* Package::getFields() 426QDict<QString>* Package::getFields()
419{ 427{
420 return &_values; 428 return &_values;
421} 429}
422 430
423QString Package::status() 431QString Package::status()
424{ 432{
425 return _status; 433 return _status;
426} 434}
427 435
428bool Package::isOld() 436bool Package::isOld()
429{ 437{
430 if (!_versions) return false; 438 if (!_versions) return false;
431 QDictIterator<Package> other( *_versions ); 439 QDictIterator<Package> other( *_versions );
432 while ( other.current() ) { 440 while ( other.current() ) {
433 if (other.current()->version() > version() ) return true; 441 if (other.current()->version() > version() ) return true;
434 ++other; 442 ++other;
435 } 443 }
436 return false; 444 return false;
437} 445}
438 446
439bool Package::hasVersions() 447bool Package::hasVersions()
440{ 448{
441 if (!_versions) return false; 449 if (!_versions) return false;
442 else return true; 450 else return true;
443} 451}
444 452
445QDict<Package>* Package::getOtherVersions() 453QDict<Package>* Package::getOtherVersions()
446{ 454{
447 return _versions; 455 return _versions;
448} 456}
449 457
450void Package::setOtherVersions(QDict<Package> *v) 458void Package::setOtherVersions(QDict<Package> *v)
451{ 459{
452 _versions=v; 460 _versions=v;
453} 461}
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index f50b9b5..0f76ece 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -1,90 +1,91 @@
1#ifndef PK_ITEM_H 1#ifndef PK_ITEM_H
2#define PK_ITEM_H 2#define PK_ITEM_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qpainter.h> 6#include <qpainter.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qdict.h> 8#include <qdict.h>
9#include <qobject.h> 9#include <qobject.h>
10 10
11#include "pksettings.h" 11#include "pksettings.h"
12 12
13class Package : public QObject 13class Package : public QObject
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16 public: 16 public:
17 Package(QObject *parent=0, const char *name=0); 17 Package(QObject *parent=0, const char *name=0);
18 Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0); 18 Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0);
19 ~Package(); 19 ~Package();
20 Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); 20 Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
21 Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); 21 Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
22 Package( Package*s, QObject *parent=0, const char *name=0 ); 22 Package( Package*s, QObject *parent=0, const char *name=0 );
23 23
24 void setValue( QString, QString ); 24 void setValue( QString, QString );
25 void copyValues( Package* ); 25 void copyValues( Package* );
26 26
27 QString name(); 27 QString name();
28 QString installName(); 28 QString installName();
29 QString packageName();
29 bool installed(); 30 bool installed();
30 bool otherInstalled(); 31 bool otherInstalled();
31 32
32 void setDesc( QString ); 33 void setDesc( QString );
33 QString shortDesc(); 34 QString shortDesc();
34 QString desc(); 35 QString desc();
35 QString size(); 36 QString size();
36 QString sizeUnits(); 37 QString sizeUnits();
37 QString version(); 38 QString version();
38 void setSection( QString ); 39 void setSection( QString );
39 QString section(); 40 QString section();
40 QString subSection(); 41 QString subSection();
41 QString details(); 42 QString details();
42 bool toProcess(); 43 bool toProcess();
43 bool toInstall(); 44 bool toInstall();
44 bool toRemove(); 45 bool toRemove();
45 void processed(); 46 void processed();
46 QString dest(); 47 QString dest();
47 void setDest( QString d ); 48 void setDest( QString d );
48 void setOn(); 49 void setOn();
49 bool link(); 50 bool link();
50 void setLink(bool); 51 void setLink(bool);
51 bool isOld(); 52 bool isOld();
52 bool hasVersions(); 53 bool hasVersions();
53 void parseIpkgFile( QString ); 54 void parseIpkgFile( QString );
54 void instalFromFile(bool iff=true); 55 void instalFromFile(bool iff=true);
55 void setName(QString); 56 void setName(QString);
56 QDict<QString>* getFields(); 57 QDict<QString>* getFields();
57 QString status(); 58 QString status();
58 59
59 QDict<Package>* getOtherVersions(); 60 QDict<Package>* getOtherVersions();
60 void setOtherVersions(QDict<Package>*); 61 void setOtherVersions(QDict<Package>*);
61 62
62public slots: 63public slots:
63 void toggleProcess(); 64 void toggleProcess();
64 65
65private: 66private:
66 PackageManagerSettings *settings; 67 PackageManagerSettings *settings;
67 QString _displayName; 68 QString _displayName;
68 QString _name; 69 QString _name;
69 QString _fileName; 70 QString _fileName;
70 bool _old; 71 bool _old;
71 bool _hasVersions; 72 bool _hasVersions;
72 bool _toProcess; 73 bool _toProcess;
73 bool _link; 74 bool _link;
74 QString _status; 75 QString _status;
75 QString _size; 76 QString _size;
76 QString _section; 77 QString _section;
77 QString _subsection; 78 QString _subsection;
78 QString _shortDesc; 79 QString _shortDesc;
79 QString _desc; 80 QString _desc;
80 QString _version; 81 QString _version;
81 QString _dest; 82 QString _dest;
82 QDict<QString> _values; 83 QDict<QString> _values;
83 QDict<Package> *_versions; 84 QDict<Package> *_versions;
84 bool _useFileName; 85 bool _useFileName;
85 void parsePackage( QStringList ); 86 void parsePackage( QStringList );
86 void init(PackageManagerSettings *); 87 void init(PackageManagerSettings *);
87}; 88};
88 89
89 90
90#endif 91#endif
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 7d0e246..89309a2 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,479 +1,480 @@
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 <opie/oprocess.h> 6#include <opie/oprocess.h>
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 <qpe/qpeapplication.h>
11#include <qdir.h> 11#include <qdir.h>
12#include <qfile.h> 12#include <qfile.h>
13#include <qgroupbox.h> 13#include <qgroupbox.h>
14#include <qmultilineedit.h> 14#include <qmultilineedit.h>
15#include <qstring.h> 15#include <qstring.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qtextstream.h> 17#include <qtextstream.h>
18#include <qtextview.h> 18#include <qtextview.h>
19 19
20#include <qprogressbar.h> 20#include <qprogressbar.h>
21#include <qpushbutton.h> 21#include <qpushbutton.h>
22#include <qlayout.h> 22#include <qlayout.h>
23 23
24#include <stdlib.h> 24#include <stdlib.h>
25#include <unistd.h> 25#include <unistd.h>
26 26
27#include "mainwindow.h" 27#include "mainwindow.h"
28 28
29 29
30//#define OPROCESS 30//#define OPROCESS
31 31
32PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) 32PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
33 : QObject ( p ) 33 : QObject ( p )
34{ 34{
35 settings = s; 35 settings = s;
36 runwindow = new RunWindow( p, name, true, f ); 36 runwindow = new RunWindow( p, name, true, f );
37#ifdef OPROCESS 37#ifdef OPROCESS
38 ipkgProcess = new OProcess(); 38 ipkgProcess = new OProcess();
39 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 39 connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
40 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 40 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
41 41
42 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), 42 connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)),
43 this, SLOT(getIpkgOutput(OProcess*,char*,int))); 43 this, SLOT(getIpkgOutput(OProcess*,char*,int)));
44 installDialog = 0; 44 installDialog = 0;
45#endif 45#endif
46} 46}
47 47
48PmIpkg::~PmIpkg() 48PmIpkg::~PmIpkg()
49{ 49{
50#ifdef OPROCESS 50#ifdef OPROCESS
51 delete ipkgProcess; 51 delete ipkgProcess;
52#endif 52#endif
53} 53}
54 54
55bool PmIpkg::runIpkg(const QString& args, const QString& dest ) 55bool PmIpkg::runIpkg(const QString& args, const QString& dest )
56{ 56{
57 bool ret=false; 57 bool ret=false;
58 QDir::setCurrent("/tmp"); 58 QDir::setCurrent("/tmp");
59 QString cmd = "/usr/bin/ipkg "; 59 QString cmd = "/usr/bin/ipkg ";
60#ifdef OPROCESS 60#ifdef OPROCESS
61 ipkgProcess->clearArguments(); 61 ipkgProcess->clearArguments();
62 *ipkgProcess << "/usr/bin/ipkg "; 62 *ipkgProcess << "/usr/bin/ipkg ";
63 QString cmd = ""; 63 cmd = "";
64#endif 64#endif
65 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); 65 pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
66 if ( dest == "" ) 66 if ( dest == "" )
67 cmd += " -dest "+settings->getDestinationName(); 67 cmd += " -dest "+settings->getDestinationName();
68 else 68 else
69 cmd += " -dest "+ dest; 69 cmd += " -dest "+ dest;
70 70
71 cmd += " -force-defaults "; 71 cmd += " -force-defaults ";
72 72
73 if (installDialog && installDialog->_force_depends) 73 if (installDialog && installDialog->_force_depends)
74 { 74 {
75 if (installDialog->_force_depends->isChecked()) 75 if (installDialog->_force_depends->isChecked())
76 cmd += " -force-depends "; 76 cmd += " -force-depends ";
77 if (installDialog->_force_reinstall->isChecked()) 77 if (installDialog->_force_reinstall->isChecked())
78 cmd += " -force-reinstall "; 78 cmd += " -force-reinstall ";
79 if (installDialog->_force_remove->isChecked()) 79 if (installDialog->_force_remove->isChecked())
80 cmd += " -force-removal-of-essential-packages "; 80 cmd += " -force-removal-of-essential-packages ";
81 } 81 }
82 82
83 out( "Starting to "+ args+"\n"); 83 out( "Starting to "+ args+"\n");
84 cmd += args; 84 cmd += args;
85 out( "running:\n"+cmd+"\n" ); 85 out( "running:\n"+cmd+"\n" );
86 pvDebug(2,"running:"+cmd); 86 pvDebug(2,"running:"+cmd);
87#ifdef OPROCESS 87#ifdef OPROCESS
88 *ipkgProcess << args; 88 *ipkgProcess << args;
89 out( "running:\n" + cmd); 89 out( "running:\n" + cmd);
90 *ipkgProcess << cmd; 90 *ipkgProcess << cmd;
91 91
92//debug 92//debug
93 ipkgProcess->clearArguments(); 93 ipkgProcess->clearArguments();
94 *ipkgProcess << "/bin/ls "; 94 *ipkgProcess << "/bin/ls ";
95//debug 95//debug
96 QValueList<QCString> a = ipkgProcess->args(); 96 QValueList<QCString> a = ipkgProcess->args();
97 QValueList<QCString>::Iterator it; 97 QValueList<QCString>::Iterator it;
98 for( it = a.begin(); it != a.end(); ++it ) 98 for( it = a.begin(); it != a.end(); ++it )
99 { 99 {
100 out( *it ); 100 out( *it );
101 cmd += *it; 101 cmd += *it;
102 } 102 }
103 103
104 pvDebug(2,"running:"+cmd); 104 pvDebug(2,"running:"+cmd);
105 qApp->processEvents(); 105 qApp->processEvents();
106// sleep(1); 106// sleep(1);
107 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 107 ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
108 if ( !ret ) { 108 if ( !ret ) {
109 pvDebug(2,"Could not execute '" + cmd); 109 pvDebug(2,"Could not execute '" + cmd);
110 out("\nError while executing "+ cmd+"\n\n"); 110 out("\nError while executing "+ cmd+"\n\n");
111 out("\nError while executing\n\n"); 111 out("\nError while executing\n\n");
112 // return false; 112 // return false;
113 } 113 }
114 114
115 while ( ipkgProcess->isRunning() ) 115 while ( ipkgProcess->isRunning() )
116 { 116 {
117 out("."); 117 out(".");
118 pvDebug(7,"wait for oprocess to terminate"); 118 pvDebug(7,"wait for oprocess to terminate");
119 qApp->processEvents(); 119 qApp->processEvents();
120 }; 120 };
121#else 121#else
122 qApp->processEvents(); 122 qApp->processEvents();
123 FILE *fp; 123 FILE *fp;
124 char line[130]; 124 char line[130];
125 QString lineStr, lineStrOld; 125 QString lineStr, lineStrOld;
126 sleep(1); 126 sleep(1);
127 cmd +=" 2>&1"; 127 cmd +=" 2>&1";
128 fp = popen( (const char *) cmd, "r"); 128 fp = popen( (const char *) cmd, "r");
129 if ( fp == NULL ) { 129 if ( fp == NULL ) {
130 qDebug("Could not execute '" + cmd + "'! err=%d", fp); 130 qDebug("Could not execute '" + cmd + "'! err=%d", fp);
131 out("\nError while executing "+ cmd+"\n\n"); 131 out("\nError while executing "+ cmd+"\n\n");
132 ret = false; 132 ret = false;
133 } else { 133 } else {
134 while ( fgets( line, sizeof line, fp) != NULL) 134 while ( fgets( line, sizeof line, fp) != NULL)
135 { 135 {
136 lineStr = line; 136 lineStr = line;
137 lineStr=lineStr.left(lineStr.length()-1); 137 lineStr=lineStr.left(lineStr.length()-1);
138 //Configuring opie-oipkg...Done 138 //Configuring opie-oipkg...Done
139 if (lineStr.contains("Done")) ret = true; 139 if (lineStr.contains("Done")) ret = true;
140 if (lineStr!=lineStrOld) 140 if (lineStr!=lineStrOld)
141 out(lineStr); 141 out(lineStr);
142 lineStrOld = lineStr; 142 lineStrOld = lineStr;
143 qApp->processEvents(); 143 qApp->processEvents();
144 } 144 }
145 } 145 }
146 pclose(fp); 146 pclose(fp);
147#endif 147#endif
148 //out( "Finished!"); 148 //out( "Finished!");
149 pvDebug(2,QString(ret?"success\n":"failure\n")); 149 pvDebug(2,QString(ret?"success\n":"failure\n"));
150 return ret; 150 return ret;
151} 151}
152 152
153void PmIpkg::makeLinks(Package *pack) 153void PmIpkg::makeLinks(Package *pack)
154{ 154{
155 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); 155 pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
156 linkPackage( pack->name(), pack->dest() ); 156 QString pn = pack->name();
157 linkPackage( pack->packageName(), pack->dest() );
157} 158}
158 159
159QStringList* PmIpkg::getList( QString packFileName, QString d ) 160QStringList* PmIpkg::getList( QString packFileName, QString d )
160{ 161{
161 QString dest = settings->getDestinationUrlByName( d ); 162 QString dest = settings->getDestinationUrlByName( d );
162 dest = dest==""?d:dest; 163 dest = dest==""?d:dest;
163 if (dest == "/" ) return 0; 164 if (dest == "/" ) return 0;
164 { 165 {
165 Config cfg( "oipkg", Config::User ); 166 Config cfg( "oipkg", Config::User );
166 cfg.setGroup( "Common" ); 167 cfg.setGroup( "Common" );
167 QString statusDir = cfg.readEntry( "statusDir", "" ); 168 QString statusDir = cfg.readEntry( "statusDir", "" );
168 } 169 }
169 packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list"; 170 packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list";
170 QFile f( packFileName ); 171 QFile f( packFileName );
171 if ( ! f.open(IO_ReadOnly) ) 172 if ( ! f.open(IO_ReadOnly) )
172 { 173 {
173 pvDebug(1," Panik! Could not open"); 174 pvDebug(1," Panik! Could not open");
174 out( "Panik!\n Could not open:\n"+packFileName ); 175 out( "Panik!\n Could not open:\n"+packFileName );
175 return (QStringList*)0; 176 return (QStringList*)0;
176 } 177 }
177 QStringList *fileList = new QStringList(); 178 QStringList *fileList = new QStringList();
178 QTextStream t( &f ); 179 QTextStream t( &f );
179 while ( !t.eof() ) 180 while ( !t.eof() )
180 { 181 {
181 *fileList += t.readLine(); 182 *fileList += t.readLine();
182 } 183 }
183 return fileList; 184 return fileList;
184} 185}
185 186
186void PmIpkg::linkPackage( QString packFileName, QString dest ) 187void PmIpkg::linkPackage( QString packFileName, QString dest )
187{ 188{
188 QStringList *fileList = getList( packFileName, dest ); 189 QStringList *fileList = getList( packFileName, dest );
189 processFileList( fileList, dest ); 190 processFileList( fileList, dest );
190 delete fileList; 191 delete fileList;
191} 192}
192 193
193void PmIpkg::processFileList( QStringList *fileList, QString d ) 194void PmIpkg::processFileList( QStringList *fileList, QString d )
194{ 195{
195 if (!fileList) return; 196 if (!fileList) return;
196 for (uint i=0; i < fileList->count(); i++) 197 for (uint i=0; i < fileList->count(); i++)
197 { 198 {
198 QString dest = settings->getDestinationUrlByName( d ); 199 QString dest = settings->getDestinationUrlByName( d );
199 dest = dest==""?d:dest; 200 dest = dest==""?d:dest;
200 processLinkDir( (*fileList)[i], dest ); 201 processLinkDir( (*fileList)[i], dest );
201 } 202 }
202} 203}
203 204
204 205
205void PmIpkg::processLinkDir( QString file, QString dest ) 206void PmIpkg::processLinkDir( QString file, QString dest )
206{ 207{
207 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); 208 pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
208 if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); 209 if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
209 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); 210 if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
210 if ( dest == "???" || dest == "" ) return; 211 if ( dest == "???" || dest == "" ) return;
211 QString destFile = file; 212 QString destFile = file;
212 file = dest+"/"+file; 213 file = dest+"/"+file;
213 if (file == dest) return; 214 if (file == dest) return;
214// if (linkOpp==createLink) out( "\ncreating links\n" ); 215// if (linkOpp==createLink) out( "\ncreating links\n" );
215 // if (linkOpp==removeLink) out( "\nremoving links\n" ); 216 // if (linkOpp==removeLink) out( "\nremoving links\n" );
216 QFileInfo fileInfo( file ); 217 QFileInfo fileInfo( file );
217 if ( fileInfo.isDir() ) 218 if ( fileInfo.isDir() )
218 { 219 {
219 pvDebug(4, "process dir "+file); 220 pvDebug(4, "process dir "+file);
220 QDir destDir( destFile ); 221 QDir destDir( destFile );
221 if (linkOpp==createLink) destDir.mkdir( destFile, true ); 222 if (linkOpp==createLink) destDir.mkdir( destFile, true );
222 QDir d( file ); 223 QDir d( file );
223// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 224// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
224 const QFileInfoList *list = d.entryInfoList(); 225 const QFileInfoList *list = d.entryInfoList();
225 QFileInfoListIterator it( *list ); 226 QFileInfoListIterator it( *list );
226 QFileInfo *fi; 227 QFileInfo *fi;
227 while ( (fi=it.current()) ) 228 while ( (fi=it.current()) )
228 { 229 {
229 pvDebug(4, "processLinkDir "+fi->absFilePath()); 230 pvDebug(4, "processLinkDir "+fi->absFilePath());
230 processLinkDir( fi->absFilePath(), dest ); 231 processLinkDir( fi->absFilePath(), dest );
231 ++it; 232 ++it;
232 } 233 }
233 } else 234 } else
234 if ( fileInfo.isFile() ) 235 if ( fileInfo.isFile() )
235 { 236 {
236 const char *instFile = strdup( (file).latin1() ); 237 const char *instFile = strdup( (file).latin1() );
237 const char *linkFile = strdup( (destFile).latin1()); 238 const char *linkFile = strdup( (destFile).latin1());
238 if( linkOpp==createLink ) 239 if( linkOpp==createLink )
239 { 240 {
240 pvDebug(4, "linking: "+file+" -> "+destFile ); 241 pvDebug(4, "linking: "+file+" -> "+destFile );
241 symlink( instFile, linkFile ); 242 symlink( instFile, linkFile );
242 } 243 }
243 } else { 244 } else {
244 const char *linkFile = strdup( (destFile).latin1()); 245 const char *linkFile = strdup( (destFile).latin1());
245 if( linkOpp==removeLink ) 246 if( linkOpp==removeLink )
246 { 247 {
247 QFileInfo toRemoveLink( destFile ); 248 QFileInfo toRemoveLink( destFile );
248 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 249 if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
249 { 250 {
250 pvDebug(4,"removing "+destFile+" no "+file); 251 pvDebug(4,"removing "+destFile+" no "+file);
251 unlink( linkFile ); 252 unlink( linkFile );
252 } 253 }
253 } 254 }
254 } 255 }
255} 256}
256 257
257void PmIpkg::loadList( PackageList *pl ) 258void PmIpkg::loadList( PackageList *pl )
258 { 259 {
259 for( Package *pack = pl->first();pack ; (pack = pl->next()) ) 260 for( Package *pack = pl->first();pack ; (pack = pl->next()) )
260 { 261 {
261 if ( pack && (pack->name() != "") && pack) 262 if ( pack && (pack->name() != "") && pack)
262 { 263 {
263 if ( pack->toInstall() ) 264 if ( pack->toInstall() )
264 to_install.append( pack ); 265 to_install.append( pack );
265 if ( pack->toRemove() ) 266 if ( pack->toRemove() )
266 to_remove.append( pack ); 267 to_remove.append( pack );
267 } 268 }
268 } 269 }
269} 270}
270 271
271void PmIpkg::commit() 272void PmIpkg::commit()
272 { 273 {
273 int sizecount = 0; 274 int sizecount = 0;
274 installDialog = new InstallDialog(settings,0,0,true); 275 installDialog = new InstallDialog(settings,0,0,true);
275 installDialog->toRemoveItem->setOpen( true ); 276 installDialog->toRemoveItem->setOpen( true );
276 installDialog->toInstallItem->setOpen( true ); 277 installDialog->toInstallItem->setOpen( true );
277 for (uint i=0; i < to_remove.count(); i++) 278 for (uint i=0; i < to_remove.count(); i++)
278 { 279 {
279 sizecount += 1; 280 sizecount += 1;
280 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); 281 installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
281 } 282 }
282 for (uint i=0; i < to_install.count(); i++) 283 for (uint i=0; i < to_install.count(); i++)
283 { 284 {
284 sizecount += to_install.at(i)->size().toInt(); 285 sizecount += to_install.at(i)->size().toInt();
285 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); 286 installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
286 } 287 }
287 runwindow->progress->setTotalSteps(sizecount); 288 runwindow->progress->setTotalSteps(sizecount);
288 qDebug("Install size %i",sizecount); 289 qDebug("Install size %i",sizecount);
289 installDialog->showMaximized(); 290 installDialog->showMaximized();
290 installDialog->show(); 291 installDialog->show();
291 if ( installDialog->exec() ) 292 if ( installDialog->exec() )
292 { 293 {
293 doIt(); 294 doIt();
294 runwindow->showMaximized(); 295 runwindow->showMaximized();
295 runwindow->show(); 296 runwindow->show();
296 } 297 }
297 installDialog->close(); 298 installDialog->close();
298 delete installDialog; 299 delete installDialog;
299 installDialog = 0; 300 installDialog = 0;
300 out(tr("\nAll done.")); 301 out(tr("\nAll done."));
301} 302}
302 303
303void PmIpkg::doIt() 304void PmIpkg::doIt()
304{ 305{
305 runwindow->progress->setProgress(0); 306 runwindow->progress->setProgress(0);
306 show(); 307 show();
307 remove(); 308 remove();
308 install(); 309 install();
309} 310}
310 311
311 312
312void PmIpkg::remove() 313void PmIpkg::remove()
313{ 314{
314 if ( to_remove.count() == 0 ) return; 315 if ( to_remove.count() == 0 ) return;
315 316
316 out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); 317 out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
317 318
318 QStringList *fileList; 319 QStringList *fileList;
319 for (uint i=0; i < to_remove.count(); i++) 320 for (uint i=0; i < to_remove.count(); i++)
320 { 321 {
321 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); 322 if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
322 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) 323 if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() ))
323 { 324 {
324 runwindow->progress->setProgress( 1 ); 325 runwindow->progress->setProgress( 1 );
325 linkOpp = removeLink; 326 linkOpp = removeLink;
326 to_remove.at(i)->processed(); 327 to_remove.at(i)->processed();
327 pvDebug(3,"link "+QString::number(i)); 328 pvDebug(3,"link "+QString::number(i));
328 if ( to_remove.at(i)->link() ) 329 if ( to_remove.at(i)->link() )
329 processFileList( fileList, to_remove.at(i)->dest() ); 330 processFileList( fileList, to_remove.at(i)->dest() );
330 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); 331 //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count()));
331 //if ( to_remove.at(i) ) to_remove.take( i ); 332 //if ( to_remove.at(i) ) to_remove.take( i );
332 333
333 out("\n"); 334 out("\n");
334 }else{ 335 }else{
335 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); 336 out(tr("Error while removing ")+to_remove.at(i)->name()+"\n");
336 if ( to_remove.at(i)->link() ) 337 if ( to_remove.at(i)->link() )
337 processFileList( fileList, to_remove.at(i)->dest() ); 338 processFileList( fileList, to_remove.at(i)->dest() );
338 } 339 }
339 if ( to_remove.at(i)->link() ) 340 if ( to_remove.at(i)->link() )
340 processFileList( fileList, to_remove.at(i)->dest() ); 341 processFileList( fileList, to_remove.at(i)->dest() );
341 if ( to_remove.at(i)->link() )delete fileList; 342 if ( to_remove.at(i)->link() )delete fileList;
342 } 343 }
343 to_remove.clear(); 344 to_remove.clear();
344 out("\n"); 345 out("\n");
345} 346}
346 347
347 348
348void PmIpkg::install() 349void PmIpkg::install()
349{ 350{
350 if ( to_install.count() == 0 ) return; 351 if ( to_install.count() == 0 ) return;
351 out(tr("Installing")+"\n"+tr("please wait")+"\n"); 352 out(tr("Installing")+"\n"+tr("please wait")+"\n");
352 for (uint i=0; i < to_install.count(); i++) 353 for (uint i=0; i < to_install.count(); i++)
353 { 354 {
354 qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug 355 qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug
355 if (to_install.at(i)->link()) 356 if (to_install.at(i)->link())
356 { 357 {
357 // hack to have package.list 358 // hack to have package.list
358 // in "dest"/usr/lib/ipkg/info/ 359 // in "dest"/usr/lib/ipkg/info/
359 QString rds = settings->getDestinationUrlByName("root"); 360 QString rds = settings->getDestinationUrlByName("root");
360 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); 361 QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest());
361 QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; 362 QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list";
362 rds += listFile; 363 rds += listFile;
363 lds += listFile; 364 lds += listFile;
364 const char *rd = rds.latin1(); 365 const char *rd = rds.latin1();
365 const char *ld = lds.latin1(); 366 const char *ld = lds.latin1();
366 pvDebug(4, "linking: "+rds+" -> "+lds ); 367 pvDebug(4, "linking: "+rds+" -> "+lds );
367 symlink( rd, ld ); 368 symlink( rd, ld );
368 } 369 }
369 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) 370 if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
370 { 371 {
371 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); 372 runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
372 to_install.at(i)->processed(); 373 to_install.at(i)->processed();
373 linkOpp = createLink; 374 linkOpp = createLink;
374 if ( to_install.at(i)->link() ) 375 if ( to_install.at(i)->link() )
375 makeLinks( to_install.at(i) ); 376 makeLinks( to_install.at(i) );
376 // to_install.take( i ); 377 // to_install.take( i );
377 out("\n"); 378 out("\n");
378 }else{ 379 }else{
379 out(tr("Error while installing")+to_install.at(i)->name()+"\n"); 380 out(tr("Error while installing")+to_install.at(i)->name()+"\n");
380 linkOpp = createLink; 381 linkOpp = createLink;
381 if ( to_install.at(i)->link() ) 382 if ( to_install.at(i)->link() )
382 makeLinks( to_install.at(i) ); 383 makeLinks( to_install.at(i) );
383 } 384 }
384 } 385 }
385 out("\n"); 386 out("\n");
386 to_install.clear(); 387 to_install.clear();
387} 388}
388 389
389void PmIpkg::createLinks( const QString &dest ) 390void PmIpkg::createLinks( const QString &dest )
390{ 391{
391 pvDebug(2,"PmIpkg::createLinks "+dest); 392 pvDebug(2,"PmIpkg::createLinks "+dest);
392 linkOpp=createLink; 393 linkOpp=createLink;
393 QString url = settings->getDestinationUrlByName( dest ); 394 QString url = settings->getDestinationUrlByName( dest );
394 url = url==""?dest:url; 395 url = url==""?dest:url;
395 processLinkDir( "/opt", url ); 396 processLinkDir( "/opt", url );
396 processLinkDir( "/usr", url ); 397 processLinkDir( "/usr", url );
397} 398}
398 399
399void PmIpkg::removeLinks( const QString &dest ) 400void PmIpkg::removeLinks( const QString &dest )
400{ 401{
401 pvDebug(2,"PmIpkg::removeLinks "+dest); 402 pvDebug(2,"PmIpkg::removeLinks "+dest);
402 linkOpp=removeLink; 403 linkOpp=removeLink;
403 QString url = settings->getDestinationUrlByName( dest ); 404 QString url = settings->getDestinationUrlByName( dest );
404 url = url==""?dest:url; 405 url = url==""?dest:url;
405 processLinkDir( "/opt", url ); 406 processLinkDir( "/opt", url );
406 processLinkDir( "/usr", url ); 407 processLinkDir( "/usr", url );
407} 408}
408 409
409void PmIpkg::update() 410void PmIpkg::update()
410{ 411{
411 show(); 412 show();
412 if ( runIpkg( "update" ) ) 413 if ( runIpkg( "update" ) )
413 runwindow->close(); 414 runwindow->close();
414 else out("An error occurred!\nPlease check the log."); 415 else out("An error occurred!\nPlease check the log.");
415} 416}
416 417
417void PmIpkg::out( QString o ) 418void PmIpkg::out( QString o )
418{ 419{
419 runwindow->outPut->append(o); 420 runwindow->outPut->append(o);
420 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); 421 runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
421} 422}
422 423
423 424
424 425
425 426
426void PmIpkg::show() 427void PmIpkg::show()
427{ 428{
428 if (!runwindow->isVisible()) 429 if (!runwindow->isVisible())
429 { 430 {
430 runwindow->showMaximized(); 431 runwindow->showMaximized();
431 runwindow->show(); 432 runwindow->show();
432 } 433 }
433 runwindow->outPut->setText(""); 434 runwindow->outPut->setText("");
434} 435}
435 436
436void PmIpkg::installFile(const QString &fileName, const QString &dest) 437void PmIpkg::installFile(const QString &fileName, const QString &dest)
437{ 438{
438 439
439 to_install.clear(); 440 to_install.clear();
440 to_remove.clear(); 441 to_remove.clear();
441 pvDebug( 2,"PmIpkg::installFile "+ fileName); 442 pvDebug( 2,"PmIpkg::installFile "+ fileName);
442 Package *p = new Package(fileName,settings); 443 Package *p = new Package(fileName,settings);
443 if ( dest!="") p->setDest( dest ); 444 if ( dest!="") p->setDest( dest );
444 to_install.append( p ); 445 to_install.append( p );
445 commit(); 446 commit();
446 delete p; 447 delete p;
447} 448}
448 449
449void PmIpkg::removeFile(const QString &fileName, const QString &dest) 450void PmIpkg::removeFile(const QString &fileName, const QString &dest)
450{ 451{
451 452
452 to_install.clear(); 453 to_install.clear();
453 to_remove.clear(); 454 to_remove.clear();
454 pvDebug( 2,"PmIpkg::removeFile "+ fileName); 455 pvDebug( 2,"PmIpkg::removeFile "+ fileName);
455 Package *p = new Package(fileName,settings); 456 Package *p = new Package(fileName,settings);
456 if ( dest!="") p->setDest( dest ); 457 if ( dest!="") p->setDest( dest );
457 to_remove.append( p ); 458 to_remove.append( p );
458 commit(); 459 commit();
459 delete p; 460 delete p;
460} 461}
461 462
462 463
463void PmIpkg::clearLists() 464void PmIpkg::clearLists()
464{ 465{
465 to_remove.clear(); 466 to_remove.clear();
466 to_install.clear(); 467 to_install.clear();
467} 468}
468 469
469 470
470void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) 471void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen)
471{ 472{
472 QString lineStr, lineStrOld; 473 QString lineStr, lineStrOld;
473 lineStr = buffer; 474 lineStr = buffer;
474 lineStr=lineStr.left(buflen); 475 lineStr=lineStr.left(buflen);
475 //Configuring opie-oipkg...Done 476 //Configuring opie-oipkg...Done
476 if (lineStr!=lineStrOld) 477 if (lineStr!=lineStrOld)
477 out(lineStr); 478 out(lineStr);
478 lineStrOld = lineStr; 479 lineStrOld = lineStr;
479} 480}