mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-17 20:36:15 +00:00
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>
This commit is contained in:
parent
656d23fa93
commit
a8376bf437
1 changed files with 9 additions and 9 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue