summaryrefslogtreecommitdiff
authortille <tille>2002-05-31 12:11:02 (UTC)
committer tille <tille>2002-05-31 12:11:02 (UTC)
commit40eac37ff82dd4499a95adb786eb063fd0b81584 (patch) (unidiff)
treedbcfe08a966ed02575897a722ddaa05b2450d7c6
parentb0c81bac3828ed8b5a5f03e1e3910c4722c6689a (diff)
downloadopie-40eac37ff82dd4499a95adb786eb063fd0b81584.zip
opie-40eac37ff82dd4499a95adb786eb063fd0b81584.tar.gz
opie-40eac37ff82dd4499a95adb786eb063fd0b81584.tar.bz2
parses "not-installed" from /usr/lib/ipkg/list
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO3
-rw-r--r--noncore/unsupported/oipkg/package.cpp10
2 files changed, 11 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index b92cbb0..e7b017c 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,12 +1,13 @@
1* check for networt before installing from network
1* Settings Class 2* Settings Class
2* parse "to install" and "to remove" from status 3* parse "to install" and "to remove" from status
3* install local file dialog 4* install local file dialog
4* qcop 5* qcop
5* error handling 6* error handling
6* manage links 7* manage links
7* dependency checking 8* dependency checking
8* create dest if it does not exist 9* create dest if it does not exist
9* allow reinstalling 10* allow reinstalling
10* different types of filters and searches 11* different types of filters and searches
11 i.e. name, desc, files etc 12 i.e. name, desc, files etc
12* display new list after update \ No newline at end of file 13* display new list after update
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index bfb48b3..4a09b40 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,436 +1,444 @@
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
12//Package::~Package() 12//Package::~Package()
13//{ 13//{
14//} 14//}
15 15
16Package::Package( PackageManagerSettings *s ) 16Package::Package( PackageManagerSettings *s )
17{ 17{
18 init(s); 18 init(s);
19} 19}
20 20
21void Package::init( PackageManagerSettings *s ) 21void Package::init( PackageManagerSettings *s )
22{ 22{
23 settings = s; 23 settings = s;
24 _size = ""; 24 _size = "";
25 _section = ""; 25 _section = "";
26 _subsection = ""; 26 _subsection = "";
27 _shortDesc = ""; 27 _shortDesc = "";
28 _desc = ""; 28 _desc = "";
29 _name = ""; 29 _name = "";
30 _toProcess = false; 30 _toProcess = false;
31 _useFileName = false; 31 _useFileName = false;
32 _old = false; 32 _old = false;
33 _status = ""; 33 _status = "";
34 _dest = settings->getDestinationName(); 34 _dest = settings->getDestinationName();
35 _link = settings->createLinks(); 35 _link = settings->createLinks();
36 _versions=0; 36 _versions=0;
37 _version=""; 37 _version="";
38} 38}
39 39
40Package::Package( QStringList pack, PackageManagerSettings *s ) 40Package::Package( QStringList pack, PackageManagerSettings *s )
41 { 41 {
42 init(s); 42 init(s);
43 parsePackage( pack ); 43 parsePackage( pack );
44} 44}
45 45
46Package::Package( QString n, PackageManagerSettings *s ) 46Package::Package( QString n, PackageManagerSettings *s )
47 { 47 {
48 init(s); 48 init(s);
49 if ( !QFile::exists( n ) ) 49 if ( !QFile::exists( n ) )
50 { 50 {
51 _name = QString( n ); 51 _name = QString( n );
52 }else{ 52 }else{
53 pvDebug(4,"remote file: "+n); 53 pvDebug(4,"remote file: "+n);
54 parseIpkgFile( n ); 54 parseIpkgFile( n );
55 _useFileName = true; 55 _useFileName = true;
56 _fileName = QString( n ); 56 _fileName = QString( n );
57 } 57 }
58} 58}
59 59
60Package::Package( Package *pi ) 60Package::Package( Package *pi )
61{ 61{
62 init(pi->settings); 62 init(pi->settings);
63 copyValues( pi ); 63 copyValues( pi );
64} 64}
65 65
66 66
67void Package::setValue( QString n, QString t ) 67void Package::setValue( QString n, QString t )
68{ 68{
69 if ( n == "Package" ) 69 if ( n == "Package" )
70 { 70 {
71 _name = QString( t ); 71 _name = QString( t );
72 }else if ( n == "Installed-Size" ) 72 }else if ( n == "Installed-Size" )
73 { 73 {
74 _size = t; 74 _size = t;
75// }else if ( n == "Priority") 75// }else if ( n == "Priority")
76// { 76// {
77 77
78 }else if ( n == "Section") 78 }else if ( n == "Section")
79 { 79 {
80 setSection( t ); 80 setSection( t );
81// }else if ( n == "Maintainer") 81// }else if ( n == "Maintainer")
82// { 82// {
83// 83//
84// }else if ( n == "Architecture") 84// }else if ( n == "Architecture")
85// { 85// {
86 86
87 }else if ( n == "Version") 87 }else if ( n == "Version")
88 { 88 {
89 _version = t; 89 _version = t;
90// }else if ( n == "Pre-Depends") 90// }else if ( n == "Pre-Depends")
91// { 91// {
92// 92//
93// }else if ( n == "Depends") 93// }else if ( n == "Depends")
94// { 94// {
95 95
96 }else if ( n == "Filename") 96 }else if ( n == "Filename")
97 { 97 {
98 _fileName = t; 98 _fileName = t;
99// }else if ( n == "Size") 99// }else if ( n == "Size")
100 // { 100 // {
101 // 101 //
102 //}else if ( n == "MD5Sum") 102 //}else if ( n == "MD5Sum")
103 //{ 103 //{
104 104
105 }else if ( n == "Description") 105 }else if ( n == "Description")
106 { 106 {
107 setDesc( t ); 107 setDesc( t );
108 }else if ( n == "Status") 108 }else if ( n == "Status")
109 { 109 {
110 if ( installed() ) return; 110 if ( installed() ) return;
111 _status = t; 111 _status = t;
112// }else if ( n == "Essential") 112// }else if ( n == "Essential")
113// { 113// {
114 114
115 }else{ 115 }else{
116 _values.insert(n,new QString(t)); 116 _values.insert(n,new QString(t));
117 } 117 }
118} 118}
119 119
120QString Package::name() 120QString Package::name()
121{ 121{
122 if (_displayName.isEmpty() ) return _name; 122 if (_displayName.isEmpty() ) return _name;
123 else return _displayName; 123 else return _displayName;
124} 124}
125 125
126 126
127QString Package::installName() 127QString Package::installName()
128{ 128{
129 if (_useFileName) return _fileName; 129 if (_useFileName) return _fileName;
130 else return _name; 130 else return _name;
131} 131}
132 132
133bool Package::installed() 133bool Package::installed()
134{ 134{
135 if (_status.contains("installed")) return true; 135 if (_status.contains("installed"))
136 {
137 if (_status.contains("not-installed"))
138 {
139 _toProcess = true;
140 return false;
141 }
142 else return true;
143 }
136 else 144 else
137 if (_versions) 145 if (_versions)
138 { 146 {
139 QDictIterator<Package> other( *_versions ); 147 QDictIterator<Package> other( *_versions );
140 while ( other.current() ) 148 while ( other.current() )
141 { 149 {
142 if (other.current()->status().contains("installed") 150 if (other.current()->status().contains("installed")
143 && other.current()->version() == version()) 151 && other.current()->version() == version())
144 return true; 152 return true;
145 ++other; 153 ++other;
146 } 154 }
147 } 155 }
148 return false; 156 return false;
149} 157}
150 158
151bool Package::otherInstalled() 159bool Package::otherInstalled()
152{ 160{
153 if (_versions) 161 if (_versions)
154 { 162 {
155 QDictIterator<Package> other( *_versions ); 163 QDictIterator<Package> other( *_versions );
156 while ( other.current() ) 164 while ( other.current() )
157 { 165 {
158 if (other.current()->installed()) return true; 166 if (other.current()->installed()) return true;
159 ++other; 167 ++other;
160 } 168 }
161 } 169 }
162 return false; 170 return false;
163} 171}
164 172
165void Package::setDesc( QString s ) 173void Package::setDesc( QString s )
166{ 174{
167 _desc = s; 175 _desc = s;
168 _shortDesc = s.left( s.find("\n") ); 176 _shortDesc = s.left( s.find("\n") );
169} 177}
170 178
171QString Package::desc() 179QString Package::desc()
172{ 180{
173 return _desc; 181 return _desc;
174} 182}
175 183
176QString Package::shortDesc() 184QString Package::shortDesc()
177{ 185{
178 return _shortDesc; 186 return _shortDesc;
179} 187}
180 188
181QString Package::size() 189QString Package::size()
182{ 190{
183 return _size; 191 return _size;
184} 192}
185 193
186 194
187QString Package::version() 195QString Package::version()
188{ 196{
189 return _version; 197 return _version;
190} 198}
191 199
192QString Package::sizeUnits() 200QString Package::sizeUnits()
193{ 201{
194 int i = _size.toInt(); 202 int i = _size.toInt();
195 int c = 0; 203 int c = 0;
196 QString ret; 204 QString ret;
197 QStringList unit; 205 QStringList unit;
198 unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) 206 unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;)
199 while (i > 1) 207 while (i > 1)
200 { 208 {
201 ret=QString::number(i)+" "+unit[c]; 209 ret=QString::number(i)+" "+unit[c];
202 c++; 210 c++;
203 i /= 1024; 211 i /= 1024;
204 } 212 }
205 return ret; 213 return ret;
206} 214}
207 215
208bool Package::toProcess() 216bool Package::toProcess()
209{ 217{
210 return _toProcess; 218 return _toProcess;
211} 219}
212 220
213bool Package::toRemove() 221bool Package::toRemove()
214{ 222{
215 if ( _toProcess && installed() ) return true; 223 if ( _toProcess && installed() ) return true;
216 else return false; 224 else return false;
217} 225}
218 226
219bool Package::toInstall() 227bool Package::toInstall()
220{ 228{
221 if ( _toProcess && !installed() ) return true; 229 if ( _toProcess && !installed() ) return true;
222 else return false; 230 else return false;
223} 231}
224 232
225void Package::toggleProcess() 233void Package::toggleProcess()
226{ 234{
227 _toProcess = ! _toProcess; 235 _toProcess = ! _toProcess;
228} 236}
229 237
230 238
231 239
232void Package::copyValues( Package* pack ) 240void Package::copyValues( Package* pack )
233{ 241{
234 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); 242 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size );
235 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); 243 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section );
236 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); 244 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection );
237 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); 245 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc );
238 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); 246 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc );
239 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); 247 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name );
240 if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); 248 if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest );
241 if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); 249 if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName );
242 if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); 250 if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName );
243 if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); 251 if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version );
244 if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); 252 if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values );
245 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); 253 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status );
246} 254}
247 255
248QString Package::section() 256QString Package::section()
249{ 257{
250 return _section; 258 return _section;
251} 259}
252 260
253void Package::setSection( QString s) 261void Package::setSection( QString s)
254{ 262{
255 int i = s.find("/"); 263 int i = s.find("/");
256 if ( i > 0 ) 264 if ( i > 0 )
257 { 265 {
258 _section = s.left(i); 266 _section = s.left(i);
259 _subsection = s.mid(i+1); 267 _subsection = s.mid(i+1);
260 }else{ 268 }else{
261 _section = s; 269 _section = s;
262 _subsection = ""; 270 _subsection = "";
263 } 271 }
264} 272}
265 273
266QString Package::subSection() 274QString Package::subSection()
267{ 275{
268 return _subsection; 276 return _subsection;
269} 277}
270 278
271void Package::parsePackage( QStringList pack ) 279void Package::parsePackage( QStringList pack )
272{ 280{
273 if ( pack.isEmpty() ) return; 281 if ( pack.isEmpty() ) return;
274 int count = pack.count(); 282 int count = pack.count();
275 for( int i = 0; i < count; i++ ) 283 for( int i = 0; i < count; i++ )
276 { 284 {
277 QString line = pack[i]; 285 QString line = pack[i];
278 int sep = line.find( QRegExp(":[\t ]+") ); 286 int sep = line.find( QRegExp(":[\t ]+") );
279 if ( sep >= 0 ) 287 if ( sep >= 0 )
280 { 288 {
281 QString tag = line.left(sep); 289 QString tag = line.left(sep);
282 QString value = line.mid(sep+2).simplifyWhiteSpace(); 290 QString value = line.mid(sep+2).simplifyWhiteSpace();
283 setValue( tag, value ); 291 setValue( tag, value );
284 }else{ 292 }else{
285 } 293 }
286 } 294 }
287 return; 295 return;
288} 296}
289 297
290QString Package::details() 298QString Package::details()
291{ 299{
292 QString status; 300 QString status;
293 Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); 301 Process ipkg_status(QStringList() << "ipkg" << "info" << name() );
294 QString description; 302 QString description;
295 if ( ipkg_status.exec("",status) ) 303 if ( ipkg_status.exec("",status) )
296 { 304 {
297 QStringList lines = QStringList::split('\n',status,TRUE); 305 QStringList lines = QStringList::split('\n',status,TRUE);
298 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { 306 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
299 QString line = *it; 307 QString line = *it;
300 if ( line == " ." ) 308 if ( line == " ." )
301 { 309 {
302 description.append("<p>"); 310 description.append("<p>");
303 } else 311 } else
304 if ( line[0] == ' ' || line[0] == '\t' ) 312 if ( line[0] == ' ' || line[0] == '\t' )
305 { 313 {
306 // continuation 314 // continuation
307 description.append(" "); 315 description.append(" ");
308 description.append(Qtopia::escapeString(line)); 316 description.append(Qtopia::escapeString(line));
309 } else { 317 } else {
310 int sep = line.find(QRegExp(":[\t ]+")); 318 int sep = line.find(QRegExp(":[\t ]+"));
311 if ( sep >= 0 ) 319 if ( sep >= 0 )
312 { 320 {
313 QString tag = line.left(sep); 321 QString tag = line.left(sep);
314 description.append("<br>"); 322 description.append("<br>");
315 description.append("<b>"); 323 description.append("<b>");
316 description.append(Qtopia::escapeString(tag)); 324 description.append(Qtopia::escapeString(tag));
317 description.append(":</b> "); 325 description.append(":</b> ");
318 description.append(Qtopia::escapeString(line.mid(sep+2))); 326 description.append(Qtopia::escapeString(line.mid(sep+2)));
319 } else { 327 } else {
320 description.append(" "); 328 description.append(" ");
321 description.append(Qtopia::escapeString(line)); 329 description.append(Qtopia::escapeString(line));
322 } 330 }
323 } 331 }
324 } 332 }
325 } 333 }
326 return description; 334 return description;
327} 335}
328 336
329void Package::processed() 337void Package::processed()
330{ 338{
331 _toProcess = false; 339 _toProcess = false;
332 //hack, but we're not writing status anyway... 340 //hack, but we're not writing status anyway...
333 if ( installed() ) _status = "install"; 341 if ( installed() ) _status = "install";
334 else _status = "installed"; 342 else _status = "installed";
335} 343}
336 344
337QString Package::dest() 345QString Package::dest()
338{ 346{
339 if ( installed()||(!installed() && _toProcess) ) 347 if ( installed()||(!installed() && _toProcess) )
340 return _dest!=""?_dest:settings->getDestinationName(); 348 return _dest!=""?_dest:settings->getDestinationName();
341 else return ""; 349 else return "";
342} 350}
343 351
344void Package::setDest( QString d ) 352void Package::setDest( QString d )
345{ 353{
346 if ( d == "remote") _useFileName = true; 354 if ( d == "remote") _useFileName = true;
347 else _dest = d; 355 else _dest = d;
348} 356}
349 357
350void Package::setOn() 358void Package::setOn()
351{ 359{
352 _toProcess = true; 360 _toProcess = true;
353} 361}
354 362
355bool Package::link() 363bool Package::link()
356{ 364{
357 if ( _dest == "root" || (!installed() && !_toProcess) ) return false; 365 if ( _dest == "root" || (!installed() && !_toProcess) ) return false;
358 return _link; 366 return _link;
359} 367}
360 368
361void Package::setLink(bool b) 369void Package::setLink(bool b)
362{ 370{
363 _link = b; 371 _link = b;
364} 372}
365 373
366void Package::parseIpkgFile( QString file) 374void Package::parseIpkgFile( QString file)
367{ 375{
368 system("tar xzf "+file+" -C /tmp"); 376 system("tar xzf "+file+" -C /tmp");
369 system("tar xzf /tmp/control.tar.gz -C /tmp"); 377 system("tar xzf /tmp/control.tar.gz -C /tmp");
370 QFile f("/tmp/control"); 378 QFile f("/tmp/control");
371 if ( f.open(IO_ReadOnly) ) 379 if ( f.open(IO_ReadOnly) )
372 { 380 {
373 QTextStream t( &f ); 381 QTextStream t( &f );
374 QStringList pack; 382 QStringList pack;
375 while ( !t.eof() ) 383 while ( !t.eof() )
376 { 384 {
377 pack << t.readLine(); 385 pack << t.readLine();
378 } 386 }
379 f.close(); 387 f.close();
380 parsePackage( pack ); 388 parsePackage( pack );
381 } 389 }
382 390
383} 391}
384 392
385//QString Package::getPackageName() 393//QString Package::getPackageName()
386//{ 394//{
387 //if ( _packageName.isEmpty() ) return _name; 395 //if ( _packageName.isEmpty() ) return _name;
388 //else return _packageName; 396 //else return _packageName;
389//} 397//}
390 398
391void Package::instalFromFile(bool iff) 399void Package::instalFromFile(bool iff)
392{ 400{
393 _useFileName = iff; 401 _useFileName = iff;
394} 402}
395 403
396void Package::setName(QString n) 404void Package::setName(QString n)
397{ 405{
398 _displayName = n; 406 _displayName = n;
399} 407}
400 408
401QDict<QString>* Package::getFields() 409QDict<QString>* Package::getFields()
402{ 410{
403 return &_values; 411 return &_values;
404} 412}
405 413
406QString Package::status() 414QString Package::status()
407{ 415{
408 return _status; 416 return _status;
409} 417}
410 418
411bool Package::isOld() 419bool Package::isOld()
412{ 420{
413 if (!_versions) return false; 421 if (!_versions) return false;
414 QDictIterator<Package> other( *_versions ); 422 QDictIterator<Package> other( *_versions );
415 while ( other.current() ) { 423 while ( other.current() ) {
416 if (other.current()->version() > version() ) return true; 424 if (other.current()->version() > version() ) return true;
417 ++other; 425 ++other;
418 } 426 }
419 return false; 427 return false;
420} 428}
421 429
422bool Package::hasVersions() 430bool Package::hasVersions()
423{ 431{
424 if (!_versions) return false; 432 if (!_versions) return false;
425 else return true; 433 else return true;
426} 434}
427 435
428QDict<Package>* Package::getOtherVersions() 436QDict<Package>* Package::getOtherVersions()
429{ 437{
430 return _versions; 438 return _versions;
431} 439}
432 440
433void Package::setOtherVersions(QDict<Package> *v) 441void Package::setOtherVersions(QDict<Package> *v)
434{ 442{
435 _versions=v; 443 _versions=v;
436} 444}