diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-02-08 17:56:14 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-12 20:57:17 +0200 |
commit | 4730f54df7edf4775dfddf45f77c60edd86c32d9 (patch) | |
tree | 22fe05326976cbdadf150c1cfe0710f375e34edf /logic/updater/UpdateChecker.cpp | |
parent | 7a71ecd8af0454e405b25080a4b266fc99306269 (diff) | |
download | PrismLauncher-4730f54df7edf4775dfddf45f77c60edd86c32d9.tar.gz PrismLauncher-4730f54df7edf4775dfddf45f77c60edd86c32d9.tar.bz2 PrismLauncher-4730f54df7edf4775dfddf45f77c60edd86c32d9.zip |
SCRATCH separate the generic updater logic from the application
Diffstat (limited to 'logic/updater/UpdateChecker.cpp')
-rw-r--r-- | logic/updater/UpdateChecker.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp index 8ac84bf1..7d214ed4 100644 --- a/logic/updater/UpdateChecker.cpp +++ b/logic/updater/UpdateChecker.cpp @@ -23,10 +23,12 @@ #define API_VERSION 0 #define CHANLIST_FORMAT 0 -UpdateChecker::UpdateChecker(QString channelListUrl, int currentBuild) +UpdateChecker::UpdateChecker(QString channelListUrl, QString currentChannel, int currentBuild) { m_channelListUrl = channelListUrl; + m_currentChannel = currentChannel; m_currentBuild = currentBuild; + m_updateChecking = false; m_chanListLoading = false; m_checkUpdateWaiting = false; @@ -69,24 +71,26 @@ void UpdateChecker::checkForUpdate(QString updateChannel, bool notifyNoUpdate) // Find the desired channel within the channel list and get its repo URL. If if cannot be // found, error. - m_repoUrl = ""; + m_newRepoUrl = ""; for (ChannelListEntry entry : m_channels) { if (entry.id == updateChannel) - m_repoUrl = entry.url; + m_newRepoUrl = entry.url; + if (entry.id == m_currentChannel) + m_currentRepoUrl = entry.url; } - qDebug() << "m_repoUrl = " << m_repoUrl; + qDebug() << "m_repoUrl = " << m_newRepoUrl; // If we didn't find our channel, error. - if (m_repoUrl.isEmpty()) + if (m_newRepoUrl.isEmpty()) { qCritical() << "m_repoUrl is empty!"; emit updateCheckFailed(); return; } - QUrl indexUrl = QUrl(m_repoUrl).resolved(QUrl("index.json")); + QUrl indexUrl = QUrl(m_newRepoUrl).resolved(QUrl("index.json")); auto job = new NetJob("GoUpdate Repository Index"); job->addNetAction(ByteArrayDownload::make(indexUrl)); @@ -149,8 +153,13 @@ void UpdateChecker::updateCheckFinished(bool notifyNoUpdate) { qDebug() << "Found newer version with ID" << newBuildNumber; // Update! - emit updateAvailable(m_repoUrl, newestVersion.value("Name").toVariant().toString(), - newBuildNumber); + GoUpdate::Status updateStatus; + updateStatus.updateAvailable = true; + updateStatus.currentVersionId = m_currentBuild; + updateStatus.currentRepoUrl = m_currentRepoUrl; + updateStatus.newVersionId = newBuildNumber; + updateStatus.newRepoUrl = m_newRepoUrl; + emit updateAvailable(updateStatus); } else if (notifyNoUpdate) { |