summaryrefslogtreecommitdiffstats
path: root/logic/updater
diff options
context:
space:
mode:
Diffstat (limited to 'logic/updater')
-rw-r--r--logic/updater/NotificationChecker.cpp13
-rw-r--r--logic/updater/NotificationChecker.h2
-rw-r--r--logic/updater/UpdateChecker.cpp4
3 files changed, 10 insertions, 9 deletions
diff --git a/logic/updater/NotificationChecker.cpp b/logic/updater/NotificationChecker.cpp
index 40367eac..191e90a3 100644
--- a/logic/updater/NotificationChecker.cpp
+++ b/logic/updater/NotificationChecker.cpp
@@ -5,8 +5,8 @@
#include <QJsonArray>
#include "MultiMC.h"
+#include "MultiMCVersion.h"
#include "logic/net/CacheDownload.h"
-#include "config.h"
NotificationChecker::NotificationChecker(QObject *parent)
: QObject(parent), m_notificationsUrl(QUrl(NOTIFICATION_URL))
@@ -55,7 +55,7 @@ void NotificationChecker::downloadSucceeded(int)
{
m_entries.clear();
- QFile file(m_download->m_output_file.fileName());
+ QFile file(m_download->getTargetFilepath());
if (file.open(QFile::ReadOnly))
{
QJsonArray root = QJsonDocument::fromJson(file.readAll()).array();
@@ -66,7 +66,7 @@ void NotificationChecker::downloadSucceeded(int)
entry.id = obj.value("id").toDouble();
entry.message = obj.value("message").toString();
entry.channel = obj.value("channel").toString();
- entry.buildtype = obj.value("buildtype").toString();
+ entry.platform = obj.value("platform").toString();
entry.from = obj.value("from").toString();
entry.to = obj.value("to").toString();
const QString type = obj.value("type").toString("critical");
@@ -93,13 +93,14 @@ void NotificationChecker::downloadSucceeded(int)
bool NotificationChecker::NotificationEntry::applies() const
{
- bool channelApplies = channel.isEmpty() || channel == VERSION_CHANNEL;
- bool buildtypeApplies = buildtype.isEmpty() || buildtype == VERSION_BUILD_TYPE;
+ MultiMCVersion version = MMC->version();
+ bool channelApplies = channel.isEmpty() || channel == version.channel;
+ bool platformApplies = platform.isEmpty() || platform == version.platform;
bool fromApplies =
from.isEmpty() || from == FULL_VERSION_STR || !versionLessThan(FULL_VERSION_STR, from);
bool toApplies =
to.isEmpty() || to == FULL_VERSION_STR || !versionLessThan(to, FULL_VERSION_STR);
- return channelApplies && buildtypeApplies && fromApplies && toApplies;
+ return channelApplies && platformApplies && fromApplies && toApplies;
}
bool NotificationChecker::NotificationEntry::versionLessThan(const QString &v1,
diff --git a/logic/updater/NotificationChecker.h b/logic/updater/NotificationChecker.h
index 20541757..915ee54d 100644
--- a/logic/updater/NotificationChecker.h
+++ b/logic/updater/NotificationChecker.h
@@ -26,7 +26,7 @@ public:
Information
} type;
QString channel;
- QString buildtype;
+ QString platform;
QString from;
QString to;
bool applies() const;
diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp
index 68d97db5..8e2aa8b3 100644
--- a/logic/updater/UpdateChecker.cpp
+++ b/logic/updater/UpdateChecker.cpp
@@ -141,8 +141,6 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
if (newestVersion.value("Id").toVariant().toInt() <
version.value("Id").toVariant().toInt())
{
- QLOG_DEBUG() << "Found newer version with ID"
- << version.value("Id").toVariant().toInt();
newestVersion = version;
}
}
@@ -152,6 +150,7 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate)
int newBuildNumber = newestVersion.value("Id").toVariant().toInt();
if (newBuildNumber != MMC->version().build)
{
+ QLOG_DEBUG() << "Found newer version with ID" << newBuildNumber;
// Update!
emit updateAvailable(m_repoUrl, newestVersion.value("Name").toVariant().toString(),
newBuildNumber);
@@ -261,3 +260,4 @@ void UpdateChecker::chanListDownloadFailed()
QLOG_ERROR() << "Failed to download channel list.";
emit channelListLoaded();
}
+