-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 @@ + * Released version 0.3.0 * Fix handling of filtering options in View menu + * Do proper version string comparison + * Fix string alignment code in PromptDlg to eliminate QT warning messages 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 @@ -#include <stdio.h> #include <stdlib.h> @@ -71,3 +70,2 @@ int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_ { -printf( "*****List*****\n%s\n", desc ); 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 @@ +#include <ctype.h> + #include <qpe/qpeapplication.h> @@ -295,11 +297,24 @@ OPackage *OPackageManager::findPackage( const QString &name ) -int OPackageManager::compareVersions( const QString &version1, const QString &version2 ) +int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) { - // TODO - do proper compare! - if ( version1 < version2 ) - return -1; - else if ( version1 > version2 ) + // TODO - should this be in OIpkg??? + + int epoch1, epoch2; + QString version1, revision1; + QString version2, revision2; + + parseVersion( ver1, &epoch1, &version1, &revision1 ); + parseVersion( ver2, &epoch2, &version2, &revision2 ); + + if ( epoch1 > epoch2 ) return 1; + else if ( epoch1 < epoch2 ) + return -1; - return 0; + int r = verrevcmp( version1.latin1(), version2.latin1() ); + if (r) + return r; + + r = verrevcmp( revision1.latin1(), revision2.latin1() ); + return r; } @@ -323 +338,75 @@ bool OPackageManager::executeCommand( OPackage::Command command, QStringList *pa } + +void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, + QString *revision ) +{ + *epoch = 0; + *revision = QString::null; + + // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision + + // Get epoch + int colonpos = verstr.find( ':' ); + if ( colonpos > -1 ) + { + *epoch = verstr.left( colonpos ).toInt(); + } + + // Get version and revision + int hyphenpos = verstr.find( '-', colonpos + 1 ); + int verlen = verstr.length(); + if ( hyphenpos > -1 ) + { + *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); + *revision = verstr.right( verlen - hyphenpos - 1 ); + } + else + { + *version = verstr.right( verlen - colonpos ); + } +} + +/* + * libdpkg - Debian packaging suite library routines + * vercmp.c - comparison of version numbers + * + * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> + */ +int OPackageManager::verrevcmp( const char *val, const char *ref ) +{ + int vc, rc; + long vl, rl; + const char *vp, *rp; + const char *vsep, *rsep; + + if (!val) val= ""; + if (!ref) ref= ""; + for (;;) { + vp= val; while (*vp && !isdigit(*vp)) vp++; + rp= ref; while (*rp && !isdigit(*rp)) rp++; + for (;;) { + vc= (val == vp) ? 0 : *val++; + rc= (ref == rp) ? 0 : *ref++; + if (!rc && !vc) break; + if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ + if (rc && !isalpha(rc)) rc += 256; + if (vc != rc) return vc - rc; + } + val= vp; + ref= rp; + vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); + rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); + if (vl != rl) return vl - rl; + + vc = *val; + rc = *ref; + vsep = strchr(".-", vc); + rsep = strchr(".-", rc); + if (vsep && !rsep) return -1; + if (!vsep && rsep) return +1; + + if (!*val && !*ref) return 0; + if (!*val) return -1; + if (!*ref) return +1; + } +} 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: + void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); + int verrevcmp( const char *val, const char *ref ); + 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) Description: Opie package management client -Version: 0.2.0 +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 QLabel *label = new QLabel( text, this ); - label->setAlignment( AlignCenter | AlignTop | WordBreak ); + label->setAlignment( AlignCenter | WordBreak ); layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |