summaryrefslogtreecommitdiffstats
path: root/logic/updater/UpdateChecker.h
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-12-04 12:34:12 -0600
committerAndrew <forkk@forkk.net>2013-12-04 12:34:12 -0600
commitbf94aaea7527a8f5b9f3b8c1ab6ff4e88cbd748f (patch)
treec5da1162598f91853555c580bdba6b778dfc1ac0 /logic/updater/UpdateChecker.h
parent6aa9bd0f77dcb5128167fae62e32aa5252fe85c6 (diff)
downloadMultiMC-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/updater/UpdateChecker.h')
-rw-r--r--logic/updater/UpdateChecker.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/logic/updater/UpdateChecker.h b/logic/updater/UpdateChecker.h
new file mode 100644
index 00000000..829f7303
--- /dev/null
+++ b/logic/updater/UpdateChecker.h
@@ -0,0 +1,93 @@
+/* Copyright 2013 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "logic/net/NetJob.h"
+
+#include <QUrl>
+
+class UpdateChecker : public QObject
+{
+ Q_OBJECT
+
+public:
+signals:
+ //! Signal emitted when an update is available. Passes the URL for the repo and the ID and name for the version.
+ void updateAvailable(QString repoUrl, QString versionName, int versionId);
+
+private slots:
+ void updateCheckFinished();
+ void updateCheckFailed();
+
+ void chanListDownloadFinished();
+ void chanListDownloadFailed();
+
+public:
+ UpdateChecker();
+ void checkForUpdate();
+
+ /*!
+ * Causes the update checker to download the channel list from the URL specified in config.h (generated by CMake).
+ * If this isn't called before checkForUpdate(), it will automatically be called.
+ */
+ void updateChanList();
+
+ /*!
+ * An entry in the channel list.
+ */
+ struct ChannelListEntry
+ {
+ QString id;
+ QString name;
+ QString description;
+ QString url;
+ };
+
+private:
+ NetJobPtr indexJob;
+ NetJobPtr chanListJob;
+
+ QString m_repoUrl;
+
+ QString m_channelListUrl;
+ QString m_currentChannel;
+
+ QList<ChannelListEntry> m_channels;
+
+ /*!
+ * True while the system is checking for updates.
+ * If checkForUpdate is called while this is true, it will be ignored.
+ */
+ bool m_updateChecking;
+
+ /*!
+ * True if the channel list has loaded.
+ * If this is false, trying to check for updates will call updateChanList first.
+ */
+ bool m_chanListLoaded;
+
+ /*!
+ * Set to true while the channel list is currently loading.
+ */
+ bool m_chanListLoading;
+
+ /*!
+ * Set to true when checkForUpdate is called while the channel list isn't loaded.
+ * When the channel list finishes loading, if this is true, the update checker will check for updates.
+ */
+ bool m_checkUpdateWaiting;
+};
+