diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-03 23:58:39 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-03 23:58:39 +0200 |
commit | 4f73091bb5bdbdb91329b9a4ef647fc8286d423c (patch) | |
tree | 6bc63a2d9ca2265cd7ee6dcf683219b73e25a24e /backend/tasks | |
parent | 13b1b98f7cf8a3b3b2c15dd42f96537b02c00711 (diff) | |
download | MultiMC-4f73091bb5bdbdb91329b9a4ef647fc8286d423c.tar MultiMC-4f73091bb5bdbdb91329b9a4ef647fc8286d423c.tar.gz MultiMC-4f73091bb5bdbdb91329b9a4ef647fc8286d423c.tar.lz MultiMC-4f73091bb5bdbdb91329b9a4ef647fc8286d423c.tar.xz MultiMC-4f73091bb5bdbdb91329b9a4ef647fc8286d423c.zip |
Errr... I forgot.
Diffstat (limited to 'backend/tasks')
-rw-r--r-- | backend/tasks/GameUpdateTask.cpp | 90 | ||||
-rw-r--r-- | backend/tasks/GameUpdateTask.h | 81 | ||||
-rw-r--r-- | backend/tasks/LoginResponse.cpp | 69 | ||||
-rw-r--r-- | backend/tasks/LoginResponse.h | 94 | ||||
-rw-r--r-- | backend/tasks/LoginTask.cpp | 2 | ||||
-rw-r--r-- | backend/tasks/LoginTask.h | 9 |
6 files changed, 18 insertions, 327 deletions
diff --git a/backend/tasks/GameUpdateTask.cpp b/backend/tasks/GameUpdateTask.cpp index 2b1acf26..f49b551c 100644 --- a/backend/tasks/GameUpdateTask.cpp +++ b/backend/tasks/GameUpdateTask.cpp @@ -24,6 +24,7 @@ #include <QDebug> +#include "BaseInstance.h" #include "lists/MinecraftVersionList.h" #include "VersionFactory.h" #include "OneSixVersion.h" @@ -31,34 +32,23 @@ #include "pathutils.h" -GameUpdateTask::GameUpdateTask(const LoginResponse &response, BaseInstance *inst, QObject *parent) : - Task(parent), m_response(response) +GameUpdateTask::GameUpdateTask(BaseInstance *inst, QObject *parent) : + Task(parent) { m_inst = inst; - m_updateState = StateInit; } void GameUpdateTask::executeTask() { - updateStatus(); - // Get a pointer to the version object that corresponds to the instance's version. - //FIXME: HACKERY - // targetVersion = (MinecraftVersion *)MinecraftVersionList::getMainList().findVersion(m_inst->intendedVersion()); + targetVersion = (MinecraftVersion *)MinecraftVersionList::getMainList().findVersion(m_inst->intendedVersionId()); if(targetVersion == NULL) { - //Q_ASSERT_X(targetVersion != NULL, "game update", "instance's intended version is not an actual version"); - setState(StateFinished); - emit gameUpdateComplete(m_response); + emit gameUpdateComplete(); return; } - ///////////////////////// - // BUILD DOWNLOAD LIST // - ///////////////////////// - // Build a list of URLs that will need to be downloaded. - - setState(StateDetermineURLs); + setStatus("Getting the version files from Mojang."); QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/"); urlstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json"; @@ -121,10 +111,6 @@ void GameUpdateTask::versionFileFinished() void GameUpdateTask::jarlibFinished() { - //FIXME: HACKERY - // m_inst->setCurrentVersion(targetVersion->descriptor()); - // m_inst->setShouldUpdate(false); - // m_inst->setIsForNewLauncher(true); exit(1); } @@ -140,70 +126,6 @@ void GameUpdateTask::versionFileFailed() exit(0); } - -int GameUpdateTask::state() const -{ - return m_updateState; -} - -void GameUpdateTask::setState(int state, bool resetSubStatus) -{ - m_updateState = state; - if (resetSubStatus) - setSubStatus(""); - else // We only need to update if we're not resetting substatus becasue setSubStatus updates status for us. - updateStatus(); -} - -QString GameUpdateTask::subStatus() const -{ - return m_subStatusMsg; -} - -void GameUpdateTask::setSubStatus(const QString &msg) -{ - m_subStatusMsg = msg; - updateStatus(); -} - -QString GameUpdateTask::getStateMessage(int state) -{ - switch (state) - { - case StateInit: - return "Initializing"; - - case StateDetermineURLs: - return "Determining files to download"; - - case StateDownloadFiles: - return "Downloading files"; - - case StateInstall: - return "Installing"; - - case StateFinished: - return "Finished"; - - default: - return "Downloading instance files"; - } -} - -void GameUpdateTask::updateStatus() -{ - QString newStatus; - - newStatus = getStateMessage(state()); - if (!subStatus().isEmpty()) - newStatus += ": " + subStatus(); - else - newStatus += "..."; - - setStatus(newStatus); -} - - void GameUpdateTask::error(const QString &msg) { emit gameUpdateError(msg); diff --git a/backend/tasks/GameUpdateTask.h b/backend/tasks/GameUpdateTask.h index ea0cf658..f13f42d1 100644 --- a/backend/tasks/GameUpdateTask.h +++ b/backend/tasks/GameUpdateTask.h @@ -24,12 +24,10 @@ #include "dlqueue.h" #include "Task.h" -#include "tasks/LoginResponse.h" -#include "BaseInstance.h" - #include "libmmc_config.h" class MinecraftVersion; +class BaseInstance; /*! * The game update task is the task that handles downloading instances' files. @@ -37,58 +35,14 @@ class MinecraftVersion; class LIBMULTIMC_EXPORT GameUpdateTask : public Task { Q_OBJECT - - /*! - * The task's state. - * A certain state message will be shown depending on what this is set to. - */ - Q_PROPERTY(int state READ state WRITE setState) - - /*! - * The substatus message. - * This will be next to the the state message in the task's status. - */ - Q_PROPERTY(QString subStatus READ subStatus WRITE setSubStatus) public: - explicit GameUpdateTask(const LoginResponse &response, BaseInstance *inst, QObject *parent = 0); - - - ///////////////////////// - // EXECUTION FUNCTIONS // - ///////////////////////// + explicit GameUpdateTask(BaseInstance *inst, QObject *parent = 0); virtual void executeTask(); - ////////////////////// - // STATE AND STATUS // - ////////////////////// - - virtual int state() const; - virtual void setState(int state, bool resetSubStatus = true); - - virtual QString subStatus() const; - virtual void setSubStatus(const QString &msg); - - /*! - * Gets the message that will be displated for the given state. - */ - virtual QString getStateMessage(int state); - -private: - void getLegacyJar(); - void determineNewVersion(); - public slots: - - /*! - * Updates the status message based on the state and substatus message. - */ - virtual void updateStatus(); - - virtual void error(const QString &msg); - private slots: void updateDownloadProgress(qint64 current, qint64 total); @@ -103,7 +57,7 @@ signals: * \brief Signal emitted when the game update is complete. * \param response The login response received from login task. */ - void gameUpdateComplete(const LoginResponse &response); + void gameUpdateComplete(); /*! * \brief Signal emitted if an error occurrs during the update. @@ -112,37 +66,10 @@ signals: void gameUpdateError(const QString &errorMsg); private: - /////////// - // STUFF // - /////////// - BaseInstance *m_inst; - LoginResponse m_response; - - //////////////////////////// - // STATE AND STATUS STUFF // - //////////////////////////// - - int m_updateState; + QString m_subStatusMsg; - enum UpdateState - { - // Initializing - StateInit = 0, - - // Determining files to download - StateDetermineURLs, - - // Downloading files - StateDownloadFiles, - - // Installing files - StateInstall, - - // Finished - StateFinished - }; JobListPtr legacyDownloadJob; JobListPtr specificVersionDownloadJob; JobListPtr jarlibDownloadJob; diff --git a/backend/tasks/LoginResponse.cpp b/backend/tasks/LoginResponse.cpp deleted file mode 100644 index 218f51c1..00000000 --- a/backend/tasks/LoginResponse.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* 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. - */ - -#include "tasks/LoginResponse.h" - -LoginResponse::LoginResponse(const QString& username, const QString& sessionID, - qint64 latestVersion, QObject *parent) : - QObject(parent) -{ - this->m_username = username; - this->m_sessionID = sessionID; - this->m_latestVersion = latestVersion; -} - -LoginResponse::LoginResponse() -{ - this->m_username = ""; - this->m_sessionID = ""; - this->m_latestVersion = 0; -} - -LoginResponse::LoginResponse(const LoginResponse &other) -{ - this->m_username = other.username(); - this->m_sessionID = other.sessionID(); - this->m_latestVersion = other.latestVersion(); -} - -QString LoginResponse::username() const -{ - return m_username; -} - -void LoginResponse::setUsername(const QString& username) -{ - this->m_username = username; -} - -QString LoginResponse::sessionID() const -{ - return m_sessionID; -} - -void LoginResponse::setSessionID(const QString& sessionID) -{ - this->m_sessionID = sessionID; -} - -qint64 LoginResponse::latestVersion() const -{ - return m_latestVersion; -} - -void LoginResponse::setLatestVersion(qint64 v) -{ - this->m_latestVersion = v; -} diff --git a/backend/tasks/LoginResponse.h b/backend/tasks/LoginResponse.h deleted file mode 100644 index 60875619..00000000 --- a/backend/tasks/LoginResponse.h +++ /dev/null @@ -1,94 +0,0 @@ -/* 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 <QObject> - -#include "libmmc_config.h" - -/*! - * \brief The LoginResponse class represents a response received from Minecraft's login servers. - */ -class LIBMULTIMC_EXPORT LoginResponse : public QObject -{ - Q_OBJECT -public: - /*! - * \brief Creates a new instance of the LoginResponse class. - * \param username The user's username. - * \param sessionID The user's session ID. - * \param latestVersion The latest version of Minecraft. - * \param parent The parent object. - */ - explicit LoginResponse(const QString &username, const QString &sessionID, - qint64 latestVersion, QObject *parent = 0); - LoginResponse(); - LoginResponse(const LoginResponse& other); - - /*! - * \brief Gets the username. - * This one should go without saying. - * \return The username. - * \sa setUsername() - */ - QString username() const; - - /*! - * \brief setUsername Sets the username. - * \param username The new username. - * \sa username() - */ - void setUsername(const QString& username); - - - /*! - * \brief Gets the session ID. - * \return The session ID. - * \sa setSessionID() - */ - QString sessionID() const; - - /*! - * \brief Sets the session ID. - * \param sessionID The new session ID. - * \sa sessionID() - */ - void setSessionID(const QString& sessionID); - - - /*! - * \brief Gets the latest version. - * This is a value returned by the login servers when a user logs in. - * \return The latest version. - * \sa setLatestVersion() - */ - qint64 latestVersion() const; - - /*! - * \brief Sets the latest version. - * \param v The new latest version. - * \sa latestVersion() - */ - void setLatestVersion(qint64 v); - -private: - QString m_username; - QString m_sessionID; - qint64 m_latestVersion; -}; - -Q_DECLARE_METATYPE(LoginResponse) - diff --git a/backend/tasks/LoginTask.cpp b/backend/tasks/LoginTask.cpp index 11f58f28..999a718e 100644 --- a/backend/tasks/LoginTask.cpp +++ b/backend/tasks/LoginTask.cpp @@ -77,7 +77,7 @@ void LoginTask::processNetReply(QNetworkReply *reply) QString username = strings[2]; QString sessionID = strings[3]; - LoginResponse response(username, sessionID, latestVersion); + LoginResponse response{username, sessionID, latestVersion}; emit loginComplete(response); } else diff --git a/backend/tasks/LoginTask.h b/backend/tasks/LoginTask.h index e23ea9e9..cb606204 100644 --- a/backend/tasks/LoginTask.h +++ b/backend/tasks/LoginTask.h @@ -19,10 +19,15 @@ #include "Task.h" #include "UserInfo.h" -#include "tasks/LoginResponse.h" - #include "libmmc_config.h" +struct LoginResponse +{ + QString username; + QString sessionID; + qint64 latestVersion; +}; + //class QNetworkAccessManager; class QNetworkReply; |