mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16: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,14 +19,14 @@ UpdateManager::UpdateManager(QObject *parent) : QObject(parent)
|
||||||
// we have just updated - wait two weeks before you check again
|
// we have just updated - wait two weeks before you check again
|
||||||
settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING));
|
settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING));
|
||||||
settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate));
|
settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate));
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
// is it time to check again?
|
// is it time to check again?
|
||||||
QString nextCheckString = settings.value("NextCheck").toString();
|
QString nextCheckString = settings.value("NextCheck").toString();
|
||||||
QDateTime nextCheck = QDateTime::fromString(nextCheckString, Qt::ISODate);
|
QDateTime nextCheck = QDateTime::fromString(nextCheckString, Qt::ISODate);
|
||||||
if (nextCheck > QDateTime::currentDateTime())
|
if (nextCheck > QDateTime::currentDateTime())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING));
|
settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING));
|
||||||
settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate));
|
settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate));
|
||||||
checkForUpdates(true);
|
checkForUpdates(true);
|
||||||
|
@ -45,7 +45,6 @@ void UpdateManager::checkForUpdates(bool automatic)
|
||||||
#else
|
#else
|
||||||
os = "unknown";
|
os = "unknown";
|
||||||
#endif
|
#endif
|
||||||
qDebug() << "checking for update";
|
|
||||||
isAutomaticCheck = automatic;
|
isAutomaticCheck = automatic;
|
||||||
QString version = CANONICAL_VERSION_STRING;
|
QString version = CANONICAL_VERSION_STRING;
|
||||||
QString url = QString("http://subsurface-divelog.org/updatecheck.html?os=%1&version=%2").arg(os, version);
|
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");
|
request.setRawHeader("Accept", "text/xml");
|
||||||
QString userAgent = UserSurvey::getUserAgent();
|
QString userAgent = UserSurvey::getUserAgent();
|
||||||
request.setRawHeader("User-Agent", userAgent.toUtf8());
|
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()
|
void UpdateManager::requestReceived()
|
||||||
|
@ -98,6 +97,7 @@ void UpdateManager::requestReceived()
|
||||||
} else {
|
} else {
|
||||||
// the webservice backend doesn't localize - but it's easy enough to just replace the
|
// the webservice backend doesn't localize - but it's easy enough to just replace the
|
||||||
// strings that it is likely to send back
|
// strings that it is likely to send back
|
||||||
|
if (!responseBody.contains("newer"))
|
||||||
haveNewVersion = true;
|
haveNewVersion = true;
|
||||||
if (responseBody.contains("Newest release version is "))
|
if (responseBody.contains("Newest release version is "))
|
||||||
responseBody.replace("Newest release version is ", tr("Newest release version is "));
|
responseBody.replace("Newest release version is ", tr("Newest release version is "));
|
||||||
|
|
Loading…
Add table
Reference in a new issue