diff options
author | Andrew <forkk@forkk.net> | 2013-12-04 12:34:12 -0600 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-12-04 12:34:12 -0600 |
commit | bf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f (patch) | |
tree | c5da1162598f91853555c580bdba6b778dfc1ac0 /logic/GoUpdate.cpp | |
parent | 6aa9bd0f77dcb5128167fae62e32aa5252fe85c6 (diff) | |
download | MultiMC-bf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f.tar MultiMC-bf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f.tar.gz MultiMC-bf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f.tar.lz MultiMC-bf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f.tar.xz MultiMC-bf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f.zip |
Rework the update checking system
Diffstat (limited to 'logic/GoUpdate.cpp')
-rw-r--r-- | logic/GoUpdate.cpp | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/logic/GoUpdate.cpp b/logic/GoUpdate.cpp deleted file mode 100644 index 6ac53d19..00000000 --- a/logic/GoUpdate.cpp +++ /dev/null @@ -1,99 +0,0 @@ - -#include "GoUpdate.h" - -#include "config.h" -#include "logger/QsLog.h" - -GoUpdate::GoUpdate() -{ - currentBuildIndex = VERSION_BUILD; - builderName = VERSION_BUILD_TYPE; - repoUrlBase = VERSION_REPO; -} - -void GoUpdate::updateCheckFailed() -{ - // TODO: log errors better - QLOG_ERROR() << "Update check failed for reasons unknown."; -} - -void GoUpdate::updateCheckFinished() -{ - QJsonParseError jsonError; - QByteArray data; - { - ByteArrayDownloadPtr dl = - std::dynamic_pointer_cast<ByteArrayDownload>(index_job->first()); - data = dl->m_data; - index_job.reset(); - } - - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); - if (jsonError.error != QJsonParseError::NoError || !jsonDoc.isObject()) - { - return; - } - - QVariant doc = jsonDoc.toVariant(); - auto stuff = doc.toMap(); - - // check api version (or later, branch?) - int ApiVersion = stuff["ApiVersion"].toInt(); - if (ApiVersion != 0) - return; - - // parse and store the channel list - auto parsedChannels = stuff["Channels"].toList(); - for (auto channel : parsedChannels) - { - auto chanMap = channel.toMap(); - channels.append({chanMap["Id"].toString(), chanMap["Name"].toString(), - chanMap["CurrentVersion"].toInt()}); - } - - // parse and store the version list - auto parsedVersions = stuff["Versions"].toList(); - for (auto version : parsedVersions) - { - auto verMap = version.toMap(); - int versionId = verMap["Id"].toInt(); - versions.append({versionId, verMap["Name"].toString()}); - if (currentBuildIndex < versionId) - { - newBuildIndex = versionId; - } - } - - if (newBuildIndex != -1) - { - QLOG_INFO() << "Update is available."; - emit updateAvailable(); - } - else - { - QLOG_INFO() << "Update check finished."; - } -} - -void GoUpdate::checkForUpdate() -{ - if (repoUrlBase == "invalid") - { - return; - } - - auto job = new NetJob("Assets index"); - job->addNetAction( - ByteArrayDownload::make(QUrl(repoUrlBase + "/" + VERSION_BRANCH + "/index.json"))); - connect(job, SIGNAL(succeeded()), SLOT(updateCheckFinished())); - connect(job, SIGNAL(failed()), SLOT(updateCheckFailed())); - index_job.reset(job); - job->start(); -} - -/* -<Forkk> files.multimc.org/lin64/ -<manmaed> Hi Forkkie -<Forkk> files.multimc.org/win32/ -<Forkk> files.multimc.org/lin32/ -*/ |