Add auto update check to Steam Link

This commit is contained in:
Cameron Gutman 2019-12-13 20:15:52 -08:00
parent 4832d8007b
commit 5d872e8b5b
3 changed files with 19 additions and 4 deletions

View file

@ -28,7 +28,7 @@ AutoUpdateChecker::AutoUpdateChecker(QObject *parent) :
void AutoUpdateChecker::start() void AutoUpdateChecker::start()
{ {
#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) // Only run update checker on platforms without auto-update #if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) || defined(STEAM_LINK) // Only run update checker on platforms without auto-update
// We'll get a callback when this is finished // We'll get a callback when this is finished
QUrl url("https://moonlight-stream.org/updates/qt.json"); QUrl url("https://moonlight-stream.org/updates/qt.json");
m_Nam.get(QNetworkRequest(url)); m_Nam.get(QNetworkRequest(url));
@ -43,6 +43,15 @@ void AutoUpdateChecker::parseStringToVersionQuad(QString& string, QVector<int>&
} }
} }
QString AutoUpdateChecker::getPlatform()
{
#ifdef STEAM_LINK
return QStringLiteral("steamlink");
#else
return QSysInfo::productType();
#endif
}
void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply) void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
{ {
Q_ASSERT(reply->isFinished()); Q_ASSERT(reply->isFinished());
@ -88,7 +97,7 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
} }
if (updateObj["arch"] == QSysInfo::buildCpuArchitecture() && if (updateObj["arch"] == QSysInfo::buildCpuArchitecture() &&
updateObj["platform"] == QSysInfo::productType()) { updateObj["platform"] == getPlatform()) {
qDebug() << "Found update manifest match for current platform"; qDebug() << "Found update manifest match for current platform";
QString latestVersion = updateObj["version"].toString(); QString latestVersion = updateObj["version"].toString();
@ -137,7 +146,7 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
} }
qWarning() << "No entry in update manifest found for current platform: " qWarning() << "No entry in update manifest found for current platform: "
<< QSysInfo::buildCpuArchitecture() << QSysInfo::productType(); << QSysInfo::buildCpuArchitecture() << getPlatform();
} }
else { else {
qWarning() << "Update checking failed with error: " << reply->error(); qWarning() << "Update checking failed with error: " << reply->error();

View file

@ -20,6 +20,8 @@ private slots:
private: private:
void parseStringToVersionQuad(QString& string, QVector<int>& version); void parseStringToVersionQuad(QString& string, QVector<int>& version);
QString getPlatform();
QVector<int> m_CurrentVersionQuad; QVector<int> m_CurrentVersionQuad;
QNetworkAccessManager m_Nam; QNetworkAccessManager m_Nam;
}; };

View file

@ -245,7 +245,11 @@ ApplicationWindow {
// an update is available // an update is available
visible: false visible: false
onClicked: Qt.openUrlExternally(browserUrl); onClicked: {
if (SystemProperties.hasBrowser) {
Qt.openUrlExternally(browserUrl);
}
}
function updateAvailable(version, url) function updateAvailable(version, url)
{ {