author | drw <drw> | 2004-02-13 18:56:44 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-13 18:56:44 (UTC) |
commit | ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98 (patch) (unidiff) | |
tree | 446720b4302433a7ef6df33336605c03dc79de8d /noncore/settings/packagemanager | |
parent | f3cf623e76060c8f4ee7c2eef241de02d63a2614 (diff) | |
download | opie-ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98.zip opie-ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98.tar.gz opie-ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98.tar.bz2 |
Do proper version string comparison and fix string alignment code in PromptDlg to eliminate QT warning messages
Diffstat (limited to 'noncore/settings/packagemanager') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/ChangeLog | 3 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.cpp | 101 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.h | 3 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opie-packagemanager.control | 2 | ||||
-rw-r--r-- | noncore/settings/packagemanager/promptdlg.cpp | 2 |
6 files changed, 103 insertions, 10 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog index 6ad724f..d53a2b3 100644 --- a/noncore/settings/packagemanager/ChangeLog +++ b/noncore/settings/packagemanager/ChangeLog | |||
@@ -2,3 +2,6 @@ | |||
2 | 2 | ||
3 | * Released version 0.3.0 | ||
3 | * Fix handling of filtering options in View menu | 4 | * Fix handling of filtering options in View menu |
5 | * Do proper version string comparison | ||
6 | * Fix string alignment code in PromptDlg to eliminate QT warning messages | ||
4 | 7 | ||
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index eb07a61..086e91b 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -33,3 +33,2 @@ | |||
33 | 33 | ||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | 34 | #include <stdlib.h> |
@@ -71,3 +70,2 @@ int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_ | |||
71 | { | 70 | { |
72 | printf( "*****List*****\n%s\n", desc ); | ||
73 | oipkg->ipkgList( desc ); | 71 | oipkg->ipkgList( desc ); |
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp index ad2fe02..3633e05 100644 --- a/noncore/settings/packagemanager/opackagemanager.cpp +++ b/noncore/settings/packagemanager/opackagemanager.cpp | |||
@@ -31,2 +31,4 @@ | |||
31 | 31 | ||
32 | #include <ctype.h> | ||
33 | |||
32 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
@@ -295,11 +297,24 @@ OPackage *OPackageManager::findPackage( const QString &name ) | |||
295 | 297 | ||
296 | int OPackageManager::compareVersions( const QString &version1, const QString &version2 ) | 298 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) |
297 | { | 299 | { |
298 | // TODO - do proper compare! | 300 | // TODO - should this be in OIpkg??? |
299 | if ( version1 < version2 ) | 301 | |
300 | return -1; | 302 | int epoch1, epoch2; |
301 | else if ( version1 > version2 ) | 303 | QString version1, revision1; |
304 | QString version2, revision2; | ||
305 | |||
306 | parseVersion( ver1, &epoch1, &version1, &revision1 ); | ||
307 | parseVersion( ver2, &epoch2, &version2, &revision2 ); | ||
308 | |||
309 | if ( epoch1 > epoch2 ) | ||
302 | return 1; | 310 | return 1; |
311 | else if ( epoch1 < epoch2 ) | ||
312 | return -1; | ||
313 | |||
314 | int r = verrevcmp( version1.latin1(), version2.latin1() ); | ||
315 | if (r) | ||
316 | return r; | ||
303 | 317 | ||
304 | return 0; | 318 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); |
319 | return r; | ||
305 | } | 320 | } |
@@ -323 +338,75 @@ bool OPackageManager::executeCommand( OPackage::Command command, QStringList *pa | |||
323 | } | 338 | } |
339 | |||
340 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, | ||
341 | QString *revision ) | ||
342 | { | ||
343 | *epoch = 0; | ||
344 | *revision = QString::null; | ||
345 | |||
346 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision | ||
347 | |||
348 | // Get epoch | ||
349 | int colonpos = verstr.find( ':' ); | ||
350 | if ( colonpos > -1 ) | ||
351 | { | ||
352 | *epoch = verstr.left( colonpos ).toInt(); | ||
353 | } | ||
354 | |||
355 | // Get version and revision | ||
356 | int hyphenpos = verstr.find( '-', colonpos + 1 ); | ||
357 | int verlen = verstr.length(); | ||
358 | if ( hyphenpos > -1 ) | ||
359 | { | ||
360 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); | ||
361 | *revision = verstr.right( verlen - hyphenpos - 1 ); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | *version = verstr.right( verlen - colonpos ); | ||
366 | } | ||
367 | } | ||
368 | |||
369 | /* | ||
370 | * libdpkg - Debian packaging suite library routines | ||
371 | * vercmp.c - comparison of version numbers | ||
372 | * | ||
373 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> | ||
374 | */ | ||
375 | int OPackageManager::verrevcmp( const char *val, const char *ref ) | ||
376 | { | ||
377 | int vc, rc; | ||
378 | long vl, rl; | ||
379 | const char *vp, *rp; | ||
380 | const char *vsep, *rsep; | ||
381 | |||
382 | if (!val) val= ""; | ||
383 | if (!ref) ref= ""; | ||
384 | for (;;) { | ||
385 | vp= val; while (*vp && !isdigit(*vp)) vp++; | ||
386 | rp= ref; while (*rp && !isdigit(*rp)) rp++; | ||
387 | for (;;) { | ||
388 | vc= (val == vp) ? 0 : *val++; | ||
389 | rc= (ref == rp) ? 0 : *ref++; | ||
390 | if (!rc && !vc) break; | ||
391 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ | ||
392 | if (rc && !isalpha(rc)) rc += 256; | ||
393 | if (vc != rc) return vc - rc; | ||
394 | } | ||
395 | val= vp; | ||
396 | ref= rp; | ||
397 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); | ||
398 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); | ||
399 | if (vl != rl) return vl - rl; | ||
400 | |||
401 | vc = *val; | ||
402 | rc = *ref; | ||
403 | vsep = strchr(".-", vc); | ||
404 | rsep = strchr(".-", rc); | ||
405 | if (vsep && !rsep) return -1; | ||
406 | if (!vsep && rsep) return +1; | ||
407 | |||
408 | if (!*val && !*ref) return 0; | ||
409 | if (!*val) return -1; | ||
410 | if (!*ref) return +1; | ||
411 | } | ||
412 | } | ||
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h index 871af0c..b710a51 100644 --- a/noncore/settings/packagemanager/opackagemanager.h +++ b/noncore/settings/packagemanager/opackagemanager.h | |||
@@ -82,2 +82,5 @@ private: | |||
82 | 82 | ||
83 | void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); | ||
84 | int verrevcmp( const char *val, const char *ref ); | ||
85 | |||
83 | signals: | 86 | signals: |
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control index 095e3be..5a3908e 100644 --- a/noncore/settings/packagemanager/opie-packagemanager.control +++ b/noncore/settings/packagemanager/opie-packagemanager.control | |||
@@ -9,2 +9,2 @@ Maintainer: Dan Williams (drw@handhelds.org) | |||
9 | Description: Opie package management client | 9 | Description: Opie package management client |
10 | Version: 0.2.0 | 10 | Version: 0.3.0 |
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp index 128e88e..4e82ba9 100644 --- a/noncore/settings/packagemanager/promptdlg.cpp +++ b/noncore/settings/packagemanager/promptdlg.cpp | |||
@@ -47,3 +47,3 @@ PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString | |||
47 | QLabel *label = new QLabel( text, this ); | 47 | QLabel *label = new QLabel( text, this ); |
48 | label->setAlignment( AlignCenter | AlignTop | WordBreak ); | 48 | label->setAlignment( AlignCenter | WordBreak ); |
49 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 49 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |