Diffstat (limited to 'noncore/unsupported/oipkg/package.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 3effb73..e020601 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -18,24 +18,23 @@ | |||
18 | 18 | ||
19 | #include "debug.h" | 19 | #include "debug.h" |
20 | 20 | ||
21 | Package::Package( QObject *parent, const char *name ) | 21 | OipkgPackage::OipkgPackage( QObject *parent, const char *name ) |
22 | : QObject(parent,name) | 22 | : QObject(parent,name) |
23 | { | 23 | { |
24 | 24 | ||
25 | } | 25 | } |
26 | 26 | ||
27 | Package::~Package() | 27 | OipkgPackage::~OipkgPackage() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | Package::Package( PackageManagerSettings *s, QObject *parent, const char *name ) | 31 | OipkgPackage::OipkgPackage( PackageManagerSettings *s, QObject *parent, const char *name ) |
32 | : QObject(parent,name) | 32 | : QObject(parent,name) |
33 | { | 33 | { |
34 | Package(parent,name); | ||
35 | init(s); | 34 | init(s); |
36 | } | 35 | } |
37 | 36 | ||
38 | void Package::init( PackageManagerSettings *s ) | 37 | void OipkgPackage::init( PackageManagerSettings *s ) |
39 | { | 38 | { |
40 | settings = s; | 39 | settings = s; |
41 | _size = ""; | 40 | _size = ""; |
@@ -54,14 +53,14 @@ void Package::init( PackageManagerSettings *s ) | |||
54 | _version=""; | 53 | _version=""; |
55 | } | 54 | } |
56 | 55 | ||
57 | Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) | 56 | OipkgPackage::OipkgPackage( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) |
58 | : QObject(parent,name) | 57 | : QObject(parent,name) |
59 | { | 58 | { |
60 | init(s); | 59 | init(s); |
61 | parsePackage( pack ); | 60 | parsePackage( pack ); |
62 | } | 61 | } |
63 | 62 | ||
64 | Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) | 63 | OipkgPackage::OipkgPackage( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) |
65 | : QObject(parent,name) | 64 | : QObject(parent,name) |
66 | { | 65 | { |
67 | init(s); | 66 | init(s); |
@@ -76,7 +75,7 @@ Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const c | |||
76 | } | 75 | } |
77 | } | 76 | } |
78 | 77 | ||
79 | Package::Package( Package *pi, QObject *parent, const char *name ) | 78 | OipkgPackage::OipkgPackage( OipkgPackage *pi, QObject *parent, const char *name ) |
80 | : QObject(parent,name) | 79 | : QObject(parent,name) |
81 | { | 80 | { |
82 | init(pi->settings); | 81 | init(pi->settings); |
@@ -84,7 +83,7 @@ Package::Package( Package *pi, QObject *parent, const char *name ) | |||
84 | } | 83 | } |
85 | 84 | ||
86 | 85 | ||
87 | void Package::setValue( QString n, QString t ) | 86 | void OipkgPackage::setValue( QString n, QString t ) |
88 | { | 87 | { |
89 | if ( n == "Package" ) | 88 | if ( n == "Package" ) |
90 | { | 89 | { |
@@ -137,20 +136,20 @@ void Package::setValue( QString n, QString t ) | |||
137 | } | 136 | } |
138 | } | 137 | } |
139 | 138 | ||
140 | QString Package::name() | 139 | QString OipkgPackage::name() |
141 | { | 140 | { |
142 | if (_displayName.isEmpty() ) return _name; | 141 | if (_displayName.isEmpty() ) return _name; |
143 | else return _displayName; | 142 | else return _displayName; |
144 | } | 143 | } |
145 | 144 | ||
146 | 145 | ||
147 | QString Package::installName() | 146 | QString OipkgPackage::installName() |
148 | { | 147 | { |
149 | if (_useFileName) return _fileName; | 148 | if (_useFileName) return _fileName; |
150 | else return _name; | 149 | else return _name; |
151 | } | 150 | } |
152 | 151 | ||
153 | QString Package::packageName() | 152 | QString OipkgPackage::packageName() |
154 | { | 153 | { |
155 | QString pn = installName(); | 154 | QString pn = installName(); |
156 | pn = pn.right(pn.length()-pn.findRev("/")); | 155 | pn = pn.right(pn.length()-pn.findRev("/")); |
@@ -158,7 +157,7 @@ QString Package::packageName() | |||
158 | return pn; | 157 | return pn; |
159 | } | 158 | } |
160 | 159 | ||
161 | bool Package::installed() | 160 | bool OipkgPackage::installed() |
162 | { | 161 | { |
163 | if (_status.contains("installed")) | 162 | if (_status.contains("installed")) |
164 | { | 163 | { |
@@ -172,7 +171,7 @@ bool Package::installed() | |||
172 | else | 171 | else |
173 | if (_versions) | 172 | if (_versions) |
174 | { | 173 | { |
175 | QDictIterator<Package> other( *_versions ); | 174 | QDictIterator<OipkgPackage> other( *_versions ); |
176 | while ( other.current() ) | 175 | while ( other.current() ) |
177 | { | 176 | { |
178 | if (other.current()->status().contains("installed") | 177 | if (other.current()->status().contains("installed") |
@@ -184,11 +183,11 @@ bool Package::installed() | |||
184 | return false; | 183 | return false; |
185 | } | 184 | } |
186 | 185 | ||
187 | bool Package::otherInstalled() | 186 | bool OipkgPackage::otherInstalled() |
188 | { | 187 | { |
189 | if (_versions) | 188 | if (_versions) |
190 | { | 189 | { |
191 | QDictIterator<Package> other( *_versions ); | 190 | QDictIterator<OipkgPackage> other( *_versions ); |
192 | while ( other.current() ) | 191 | while ( other.current() ) |
193 | { | 192 | { |
194 | if (other.current()->installed()) return true; | 193 | if (other.current()->installed()) return true; |
@@ -198,34 +197,34 @@ bool Package::otherInstalled() | |||
198 | return false; | 197 | return false; |
199 | } | 198 | } |
200 | 199 | ||
201 | void Package::setDesc( QString s ) | 200 | void OipkgPackage::setDesc( QString s ) |
202 | { | 201 | { |
203 | _desc = s; | 202 | _desc = s; |
204 | _shortDesc = s.left( s.find("\n") ); | 203 | _shortDesc = s.left( s.find("\n") ); |
205 | } | 204 | } |
206 | 205 | ||
207 | QString Package::desc() | 206 | QString OipkgPackage::desc() |
208 | { | 207 | { |
209 | return _desc; | 208 | return _desc; |
210 | } | 209 | } |
211 | 210 | ||
212 | QString Package::shortDesc() | 211 | QString OipkgPackage::shortDesc() |
213 | { | 212 | { |
214 | return _shortDesc; | 213 | return _shortDesc; |
215 | } | 214 | } |
216 | 215 | ||
217 | QString Package::size() | 216 | QString OipkgPackage::size() |
218 | { | 217 | { |
219 | return _size; | 218 | return _size; |
220 | } | 219 | } |
221 | 220 | ||
222 | 221 | ||
223 | QString Package::version() | 222 | QString OipkgPackage::version() |
224 | { | 223 | { |
225 | return _version; | 224 | return _version; |
226 | } | 225 | } |
227 | 226 | ||
228 | QString Package::sizeUnits() | 227 | QString OipkgPackage::sizeUnits() |
229 | { | 228 | { |
230 | int i = _size.toInt(); | 229 | int i = _size.toInt(); |
231 | int c = 0; | 230 | int c = 0; |
@@ -241,31 +240,30 @@ QString Package::sizeUnits() | |||
241 | return ret; | 240 | return ret; |
242 | } | 241 | } |
243 | 242 | ||
244 | bool Package::toProcess() | 243 | bool OipkgPackage::toProcess() |
245 | { | 244 | { |
246 | return _toProcess; | 245 | return _toProcess; |
247 | } | 246 | } |
248 | 247 | ||
249 | bool Package::toRemove() | 248 | bool OipkgPackage::toRemove() |
250 | { | 249 | { |
251 | if ( _toProcess && installed() ) return true; | 250 | if ( _toProcess && installed() ) return true; |
252 | else return false; | 251 | else return false; |
253 | } | 252 | } |
254 | 253 | ||
255 | bool Package::toInstall() | 254 | bool OipkgPackage::toInstall() |
256 | { | 255 | { |
257 | if ( _toProcess && !installed() ) return true; | 256 | if ( _toProcess && !installed() ) return true; |
258 | else return false; | 257 | else return false; |
259 | } | 258 | } |
260 | 259 | ||
261 | void Package::toggleProcess() | 260 | void OipkgPackage::toggleProcess() |
262 | { | 261 | { |
263 | _toProcess = ! _toProcess; | 262 | _toProcess = ! _toProcess; |
264 | } | 263 | } |
265 | 264 | ||
266 | 265 | ||
267 | 266 | void OipkgPackage::copyValues( OipkgPackage* pack ) | |
268 | void Package::copyValues( Package* pack ) | ||
269 | { | 267 | { |
270 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); | 268 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); |
271 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); | 269 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); |
@@ -281,12 +279,12 @@ void Package::copyValues( Package* pack ) | |||
281 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); | 279 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); |
282 | } | 280 | } |
283 | 281 | ||
284 | QString Package::section() | 282 | QString OipkgPackage::section() |
285 | { | 283 | { |
286 | return _section; | 284 | return _section; |
287 | } | 285 | } |
288 | 286 | ||
289 | void Package::setSection( QString s) | 287 | void OipkgPackage::setSection( QString s) |
290 | { | 288 | { |
291 | int i = s.find("/"); | 289 | int i = s.find("/"); |
292 | if ( i > 0 ) | 290 | if ( i > 0 ) |
@@ -299,12 +297,12 @@ void Package::setSection( QString s) | |||
299 | } | 297 | } |
300 | } | 298 | } |
301 | 299 | ||
302 | QString Package::subSection() | 300 | QString OipkgPackage::subSection() |
303 | { | 301 | { |
304 | return _subsection; | 302 | return _subsection; |
305 | } | 303 | } |
306 | 304 | ||
307 | void Package::parsePackage( QStringList pack ) | 305 | void OipkgPackage::parsePackage( QStringList pack ) |
308 | { | 306 | { |
309 | if ( pack.isEmpty() ) return; | 307 | if ( pack.isEmpty() ) return; |
310 | int count = pack.count(); | 308 | int count = pack.count(); |
@@ -323,7 +321,7 @@ void Package::parsePackage( QStringList pack ) | |||
323 | return; | 321 | return; |
324 | } | 322 | } |
325 | 323 | ||
326 | QString Package::details() | 324 | QString OipkgPackage::details() |
327 | { | 325 | { |
328 | QString status; | 326 | QString status; |
329 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); | 327 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); |
@@ -362,7 +360,7 @@ QString Package::details() | |||
362 | return description; | 360 | return description; |
363 | } | 361 | } |
364 | 362 | ||
365 | void Package::processed() | 363 | void OipkgPackage::processed() |
366 | { | 364 | { |
367 | _toProcess = false; | 365 | _toProcess = false; |
368 | //hack, but we're not writing status anyway... | 366 | //hack, but we're not writing status anyway... |
@@ -370,36 +368,36 @@ void Package::processed() | |||
370 | else _status = "installed"; | 368 | else _status = "installed"; |
371 | } | 369 | } |
372 | 370 | ||
373 | QString Package::dest() | 371 | QString OipkgPackage::dest() |
374 | { | 372 | { |
375 | if ( installed()||(!installed() && _toProcess) ) | 373 | if ( installed()||(!installed() && _toProcess) ) |
376 | return _dest!=""?_dest:settings->getDestinationName(); | 374 | return _dest!=""?_dest:settings->getDestinationName(); |
377 | else return ""; | 375 | else return ""; |
378 | } | 376 | } |
379 | 377 | ||
380 | void Package::setDest( QString d ) | 378 | void OipkgPackage::setDest( QString d ) |
381 | { | 379 | { |
382 | if ( d == "remote") _useFileName = true; | 380 | if ( d == "remote") _useFileName = true; |
383 | else _dest = d; | 381 | else _dest = d; |
384 | } | 382 | } |
385 | 383 | ||
386 | void Package::setOn() | 384 | void OipkgPackage::setOn() |
387 | { | 385 | { |
388 | _toProcess = true; | 386 | _toProcess = true; |
389 | } | 387 | } |
390 | 388 | ||
391 | bool Package::link() | 389 | bool OipkgPackage::link() |
392 | { | 390 | { |
393 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; | 391 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; |
394 | return _link; | 392 | return _link; |
395 | } | 393 | } |
396 | 394 | ||
397 | void Package::setLink(bool b) | 395 | void OipkgPackage::setLink(bool b) |
398 | { | 396 | { |
399 | _link = b; | 397 | _link = b; |
400 | } | 398 | } |
401 | 399 | ||
402 | void Package::parseIpkgFile( QString file) | 400 | void OipkgPackage::parseIpkgFile( QString file) |
403 | { | 401 | { |
404 | // 20020830 | 402 | // 20020830 |
405 | // a quick hack to make oipkg understand the new ipk format | 403 | // a quick hack to make oipkg understand the new ipk format |
@@ -425,36 +423,36 @@ void Package::parseIpkgFile( QString file) | |||
425 | 423 | ||
426 | } | 424 | } |
427 | 425 | ||
428 | //QString Package::getPackageName() | 426 | //QString OipkgPackage::getPackageName() |
429 | //{ | 427 | //{ |
430 | //if ( _packageName.isEmpty() ) return _name; | 428 | //if ( _packageName.isEmpty() ) return _name; |
431 | //else return _packageName; | 429 | //else return _packageName; |
432 | //} | 430 | //} |
433 | 431 | ||
434 | void Package::instalFromFile(bool iff) | 432 | void OipkgPackage::instalFromFile(bool iff) |
435 | { | 433 | { |
436 | _useFileName = iff; | 434 | _useFileName = iff; |
437 | } | 435 | } |
438 | 436 | ||
439 | void Package::setName(QString n) | 437 | void OipkgPackage::setName(QString n) |
440 | { | 438 | { |
441 | _displayName = n; | 439 | _displayName = n; |
442 | } | 440 | } |
443 | 441 | ||
444 | QDict<QString>* Package::getFields() | 442 | QDict<QString>* OipkgPackage::getFields() |
445 | { | 443 | { |
446 | return &_values; | 444 | return &_values; |
447 | } | 445 | } |
448 | 446 | ||
449 | QString Package::status() | 447 | QString OipkgPackage::status() |
450 | { | 448 | { |
451 | return _status; | 449 | return _status; |
452 | } | 450 | } |
453 | 451 | ||
454 | bool Package::isOld() | 452 | bool OipkgPackage::isOld() |
455 | { | 453 | { |
456 | if (!_versions) return false; | 454 | if (!_versions) return false; |
457 | QDictIterator<Package> other( *_versions ); | 455 | QDictIterator<OipkgPackage> other( *_versions ); |
458 | while ( other.current() ) { | 456 | while ( other.current() ) { |
459 | if (other.current()->version() > version() ) return true; | 457 | if (other.current()->version() > version() ) return true; |
460 | ++other; | 458 | ++other; |
@@ -462,18 +460,18 @@ bool Package::isOld() | |||
462 | return false; | 460 | return false; |
463 | } | 461 | } |
464 | 462 | ||
465 | bool Package::hasVersions() | 463 | bool OipkgPackage::hasVersions() |
466 | { | 464 | { |
467 | if (!_versions) return false; | 465 | if (!_versions) return false; |
468 | else return true; | 466 | else return true; |
469 | } | 467 | } |
470 | 468 | ||
471 | QDict<Package>* Package::getOtherVersions() | 469 | QDict<OipkgPackage>* OipkgPackage::getOtherVersions() |
472 | { | 470 | { |
473 | return _versions; | 471 | return _versions; |
474 | } | 472 | } |
475 | 473 | ||
476 | void Package::setOtherVersions(QDict<Package> *v) | 474 | void OipkgPackage::setOtherVersions(QDict<OipkgPackage> *v) |
477 | { | 475 | { |
478 | _versions=v; | 476 | _versions=v; |
479 | } | 477 | } |