diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-01-25 08:13:41 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-25 08:26:31 -0800 |
commit | a8376bf4371778d0904843f1dc3e16f14d91aba7 (patch) | |
tree | 41464ec870a7c6e5384f8fadc76e82335dce8a75 /qt-ui/updatemanager.cpp | |
parent | 656d23fa930b7d9781cea1e7ac5437729df6689c (diff) | |
download | subsurface-a8376bf4371778d0904843f1dc3e16f14d91aba7.tar.gz |
Clean up the update checking logic
If update checking is allowed we want to do so but we want to be careful,
which messages we show - specifically we don't want to show "your version
is newer" unless it's a manual check.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/updatemanager.cpp')
-rw-r--r-- | qt-ui/updatemanager.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/qt-ui/updatemanager.cpp b/qt-ui/updatemanager.cpp index 865a54127..b920a8ebb 100644 --- a/qt-ui/updatemanager.cpp +++ b/qt-ui/updatemanager.cpp @@ -19,13 +19,13 @@ UpdateManager::UpdateManager(QObject *parent) : QObject(parent) // we have just updated - wait two weeks before you check again settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING)); settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate)); - return; + } else { + // is it time to check again? + QString nextCheckString = settings.value("NextCheck").toString(); + QDateTime nextCheck = QDateTime::fromString(nextCheckString, Qt::ISODate); + if (nextCheck > QDateTime::currentDateTime()) + return; } - // is it time to check again? - QString nextCheckString = settings.value("NextCheck").toString(); - QDateTime nextCheck = QDateTime::fromString(nextCheckString, Qt::ISODate); - if (nextCheck > QDateTime::currentDateTime()) - return; } settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING)); settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate)); @@ -45,7 +45,6 @@ void UpdateManager::checkForUpdates(bool automatic) #else os = "unknown"; #endif - qDebug() << "checking for update"; isAutomaticCheck = automatic; QString version = CANONICAL_VERSION_STRING; QString url = QString("http://subsurface-divelog.org/updatecheck.html?os=%1&version=%2").arg(os, version); @@ -54,7 +53,7 @@ void UpdateManager::checkForUpdates(bool automatic) request.setRawHeader("Accept", "text/xml"); QString userAgent = UserSurvey::getUserAgent(); request.setRawHeader("User-Agent", userAgent.toUtf8()); - connect(SubsurfaceWebServices::manager()->get(request), SIGNAL(finished()), this, SLOT(requestReceived())); + connect(SubsurfaceWebServices::manager()->get(request), SIGNAL(finished()), this, SLOT(requestReceived()), Qt::UniqueConnection); } void UpdateManager::requestReceived() @@ -98,7 +97,8 @@ void UpdateManager::requestReceived() } else { // the webservice backend doesn't localize - but it's easy enough to just replace the // strings that it is likely to send back - haveNewVersion = true; + if (!responseBody.contains("newer")) + haveNewVersion = true; if (responseBody.contains("Newest release version is ")) responseBody.replace("Newest release version is ", tr("Newest release version is ")); msgText = tr("The server returned the following information:").append("<br/><br/>").append(responseBody); |