summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/rbutilqt.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-06-11 19:18:13 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-06-11 19:18:13 +0000
commit13d8649a3445717b8527dfb2ef3c301bdc2e0188 (patch)
tree30b44b00a24ccb5c5d4f609d51864540c99ef9c9 /rbutil/rbutilqt/rbutilqt.cpp
parentdb54033a15dc3235693431463ae868f3b239d868 (diff)
downloadrockbox-13d8649a3445717b8527dfb2ef3c301bdc2e0188.tar.gz
rockbox-13d8649a3445717b8527dfb2ef3c301bdc2e0188.zip
Rework Rockbox Utility update version number check.
The version check failed on subrelease versions (as the 1.2.5-1 rebuild done for Mac) and detected an updated version that is in fact an outdated one. Rework the comparison completely, move it to the Utils class and display some more information in the status bar upon update check. Especially keep a notice in the status bar if an updated version was found. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26788 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/rbutilqt.cpp')
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp62
1 files changed, 8 insertions, 54 deletions
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 274efb46af..98c1024f60 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -1269,6 +1269,7 @@ void RbUtilQt::checkUpdate(void)
if(RbSettings::value(RbSettings::CacheOffline).toBool())
update->setCache(true);
+ ui.statusbar->showMessage(tr("Checking for update ..."));
update->getFile(QUrl(url));
}
@@ -1290,7 +1291,7 @@ void RbUtilQt::downloadUpdateDone(bool error)
}
qDebug() << "[Checkupdate] " << rbutilList;
- QString newVersion ="";
+ QString newVersion = "";
//check if there is a binary with higher version in this list
for(int i=0; i < rbutilList.size(); i++)
{
@@ -1306,9 +1307,9 @@ void RbUtilQt::downloadUpdateDone(bool error)
#endif
#endif
//check if it is newer, and remember newest
- if(newerVersion(VERSION,rbutilList.at(i)))
+ if(Utils::compareVersionStrings(VERSION, rbutilList.at(i)) == 1)
{
- if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i)))
+ if(Utils::compareVersionStrings(newVersion, rbutilList.at(i)) == 1)
{
newVersion = rbutilList.at(i);
}
@@ -1331,58 +1332,11 @@ void RbUtilQt::downloadUpdateDone(bool error)
QMessageBox::information(this,tr("RockboxUtility Update available"),
tr("<b>New RockboxUtility Version available.</b> <br><br>"
"Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) );
+ ui.statusbar->showMessage(tr("New version of Rockbox Utility available."));
+ }
+ else {
+ ui.statusbar->showMessage(tr("Rockbox Utility is up to date."), 5000);
}
}
}
-bool RbUtilQt::newerVersion(QString versionOld,QString versionNew)
-{
- QRegExp chars("\\d*(\\D)");
-
- //strip non-number from beginning
- versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d")));
- versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d")));
-
- // split versions by "."
- QStringList versionListOld = versionOld.split(".");
- QStringList versionListNew = versionNew.split(".");
-
- QStringListIterator iteratorOld(versionListOld);
- QStringListIterator iteratorNew(versionListNew);
-
- //check every section
- while(iteratorOld.hasNext() && iteratorNew.hasNext())
- {
- QString newPart = iteratorNew.next();
- QString oldPart = iteratorOld.next();
- QString newPartChar = "", oldPartChar = "";
- int newPartInt = 0, oldPartInt =0;
-
- //convert to int, if it contains chars, put into seperated variable
- if(newPart.contains(chars))
- {
- newPartChar = chars.cap(1);
- newPart = newPart.remove(newPartChar);
- }
- newPartInt = newPart.toInt();
- //convert to int, if it contains chars, put into seperated variable
- if(oldPart.contains(chars))
- {
- oldPartChar = chars.cap(1);
- oldPart = oldPart.remove(oldPartChar);
- }
- oldPartInt = oldPart.toInt();
-
- if(newPartInt > oldPartInt) // this section int is higher -> true
- return true;
- else if(newPartInt < oldPartInt) //this section int is lower -> false
- return false;
- else if(newPartChar > oldPartChar) //ints are the same, chars is higher -> true
- return true;
- else if(newPartChar < oldPartChar) //ints are the same, chars is lower -> false
- return false;
- //all the same, next section
- }
- // all the same -> false
- return false;
-}