summaryrefslogtreecommitdiffstats
path: root/logic/updater/DownloadTask.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-02-08 17:56:14 +0100
committerPetr Mrázek <peterix@gmail.com>2015-04-12 20:57:17 +0200
commit4730f54df7edf4775dfddf45f77c60edd86c32d9 (patch)
tree22fe05326976cbdadf150c1cfe0710f375e34edf /logic/updater/DownloadTask.h
parent7a71ecd8af0454e405b25080a4b266fc99306269 (diff)
downloadMultiMC-4730f54df7edf4775dfddf45f77c60edd86c32d9.tar
MultiMC-4730f54df7edf4775dfddf45f77c60edd86c32d9.tar.gz
MultiMC-4730f54df7edf4775dfddf45f77c60edd86c32d9.tar.lz
MultiMC-4730f54df7edf4775dfddf45f77c60edd86c32d9.tar.xz
MultiMC-4730f54df7edf4775dfddf45f77c60edd86c32d9.zip
SCRATCH separate the generic updater logic from the application
Diffstat (limited to 'logic/updater/DownloadTask.h')
-rw-r--r--logic/updater/DownloadTask.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/logic/updater/DownloadTask.h b/logic/updater/DownloadTask.h
new file mode 100644
index 00000000..2b8c6299
--- /dev/null
+++ b/logic/updater/DownloadTask.h
@@ -0,0 +1,85 @@
+/* Copyright 2013-2014 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/tasks/Task.h"
+#include "logic/net/NetJob.h"
+#include "GoUpdate.h"
+
+namespace GoUpdate
+{
+/*!
+ * The DownloadTask is a task that takes a given version ID and repository URL,
+ * downloads that version's files from the repository, and prepares to install them.
+ */
+class DownloadTask : public Task
+{
+ Q_OBJECT
+
+public:
+ explicit DownloadTask(Status status, QObject* parent = 0);
+
+ /// Get the directory that will contain the update files.
+ QString updateFilesDir();
+
+ /// set updater download behavior
+ void setUseLocalUpdater(bool useLocal);
+
+protected:
+ //! Entry point for tasks.
+ virtual void executeTask() override;
+
+ /*!
+ * Downloads the version info files from the repository.
+ * The files for both the current build, and the build that we're updating to need to be downloaded.
+ * If the current version's info file can't be found, MultiMC will not delete files that
+ * were removed between versions. It will still replace files that have changed, however.
+ * Note that although the repository URL for the current version is not given to the update task,
+ * the task will attempt to look it up in the UpdateChecker's channel list.
+ * If an error occurs here, the function will call emitFailed and return false.
+ */
+ void loadVersionInfo();
+
+ NetJobPtr m_vinfoNetJob;
+ ByteArrayDownloadPtr m_currentVersionFileListDownload;
+ ByteArrayDownloadPtr m_newVersionFileListDownload;
+
+ NetJobPtr m_filesNetJob;
+
+ Status m_status;
+
+ bool m_keepLocalUpdater;
+
+ /*!
+ * Temporary directory to store update files in.
+ * This will be set to not auto delete. Task will fail if this fails to be created.
+ */
+ QTemporaryDir m_updateFilesDir;
+
+protected slots:
+ /*!
+ * This function is called when version information is finished downloading
+ * and at least the new file list download succeeded
+ */
+ void processDownloadedVersionInfo();
+ void vinfoDownloadFailed();
+
+ void fileDownloadFinished();
+ void fileDownloadFailed();
+ void fileDownloadProgressChanged(qint64 current, qint64 total);
+};
+
+} \ No newline at end of file