From ee5583251d92d47f96b03c3b447c115bab901c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 7 Jul 2013 23:51:26 +0200 Subject: Legacy versions downloaded from the new location are treated as legacy versions! --- libmultimc/include/gameupdatetask.h | 72 ++++++++++--------------------------- 1 file changed, 19 insertions(+), 53 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/gameupdatetask.h b/libmultimc/include/gameupdatetask.h index c3f84356..f607db6b 100644 --- a/libmultimc/include/gameupdatetask.h +++ b/libmultimc/include/gameupdatetask.h @@ -22,47 +22,15 @@ #include #include +#include "dlqueue.h" #include "task.h" #include "loginresponse.h" #include "instance.h" #include "libmmc_config.h" -class FileToDownload; -typedef QSharedPointer FileToDownloadPtr; - -class FileToDownload : public QObject -{ - Q_OBJECT - - /*! - * The URL to download the file from. - */ - Q_PROPERTY(QUrl url READ url WRITE setURL) - - /*! - * The path to download to. - * This path is relative to the instance's root directory. - */ - Q_PROPERTY(QString path READ path WRITE setPath) - -private: - FileToDownload(const QUrl &url, const QString &path, QObject *parent = 0); -public: - static FileToDownloadPtr Create(const QUrl &url, const QString &path, QObject *parent = 0); - - virtual QUrl url() const { return m_dlURL; } - virtual void setURL(const QUrl &url) { m_dlURL = url; } - - virtual QString path() const { return m_dlPath; } - virtual void setPath(const QString &path) { m_dlPath = path; } - -private: - QUrl m_dlURL; - QString m_dlPath; -}; - +class MinecraftVersion; /*! * The game update task is the task that handles downloading instances' files. @@ -92,9 +60,6 @@ public: virtual void executeTask(); - virtual bool downloadFile(const FileToDownloadPtr file); - - ////////////////////// // STATE AND STATUS // ////////////////////// @@ -110,6 +75,10 @@ public: */ virtual QString getStateMessage(int state); +private: + void getLegacyJar(); + void determineNewVersion(); + public slots: /*! @@ -122,7 +91,12 @@ public slots: private slots: - virtual void updateDownloadProgress(qint64 current, qint64 total); + void updateDownloadProgress(qint64 current, qint64 total); + void legacyJarFinished(); + void legacyJarFailed(); + + void versionFileFinished(); + void versionFileFailed(); signals: /*! @@ -143,23 +117,8 @@ private: /////////// Instance *m_inst; - LoginResponse m_response; - QNetworkAccessManager *netMgr; - - - - //////////////////////// - // FILE DOWNLOAD LIST // - //////////////////////// - - // List of URLs that the game updater will need to download. - QList m_downloadList; - int m_currentDownload; - - - //////////////////////////// // STATE AND STATUS STUFF // //////////////////////////// @@ -184,6 +143,13 @@ private: // Finished StateFinished }; + JobListPtr legacyDownloadJob; + JobListPtr specificVersionDownloadJob; + JobListPtr jarlibDownloadJob; + JobListQueue download_queue; + + // target version, determined during this task + MinecraftVersion *targetVersion; }; -- cgit v1.2.3 From c96ac2460522b9567a10831bcd1d8a6bc9f36d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 9 Jul 2013 22:46:33 +0200 Subject: Replace one line. Get downloading of 1.6 jars working. Yay. --- libmultimc/include/gameupdatetask.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libmultimc/include') diff --git a/libmultimc/include/gameupdatetask.h b/libmultimc/include/gameupdatetask.h index f607db6b..b56c448b 100644 --- a/libmultimc/include/gameupdatetask.h +++ b/libmultimc/include/gameupdatetask.h @@ -98,6 +98,9 @@ private slots: void versionFileFinished(); void versionFileFailed(); + void jarlibFinished(); + void jarlibFailed(); + signals: /*! * \brief Signal emitted when the game update is complete. -- cgit v1.2.3 From 33b9b25da7d3d29f949c9418295de257d437c9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 14 Jul 2013 18:33:31 +0200 Subject: More work on the downloader and 1.6 instance creation --- libmultimc/include/instance.h | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index 717f8816..526025be 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -80,16 +80,7 @@ class LIBMULTIMC_EXPORT Instance : public QObject * This returns true if shouldForceUpdate game is true or if the intended and * current versions don't match. */ - Q_PROPERTY(bool shouldUpdateGame READ shouldUpdateGame STORED false) - - /*! - * Whether or not the game will be forced to update on the next launch. - * If this is set to true, shouldUpdateGame will be true, regardless of whether or not - * the current and intended versions match. - * It should be noted that this is set to false automatically when game updates are run. - */ - Q_PROPERTY(bool shouldForceUpdateGame READ shouldForceUpdateGame WRITE setShouldForceUpdateGame) - + Q_PROPERTY(bool shouldUpdate READ shouldUpdate WRITE setShouldUpdate) /*! * The instance's current version. @@ -236,14 +227,17 @@ public: virtual QString intendedVersion() const { return settings().get("IntendedJarVersion").toString(); } virtual void setIntendedVersion(QString val) { settings().set("IntendedJarVersion", val); } - virtual bool shouldUpdateGame() const - { return shouldForceUpdateGame() || intendedVersion() != currentVersion(); } - - virtual bool shouldForceUpdateGame() const { return settings().get("ShouldForceUpdate").toBool(); } - virtual void setShouldForceUpdateGame(bool val) { settings().set("ShouldForceUpdate", val); } - - - + virtual bool shouldUpdate() const + { + QVariant var = settings().get("ShouldUpdate"); + if(!var.isValid() || var.toBool() == false) + { + return intendedVersion() != currentVersion(); + } + return true; + } + virtual void setShouldUpdate(bool val) { settings().set("ShouldUpdate", val); } + //// Timestamps //// virtual qint64 lastLaunch() const { return settings().get("lastLaunchTime").value(); } -- cgit v1.2.3 From 18853ca3fa185f5fe5288a1d0c8ed6cf8c678007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 22 Jul 2013 02:01:56 +0200 Subject: Parsing the version files, part I --- libmultimc/include/fullversion.h | 68 +++++++++++++++++++++++++++++++++ libmultimc/include/fullversionfactory.h | 23 +++++++++++ libmultimc/include/library.h | 18 +++++++++ 3 files changed, 109 insertions(+) create mode 100644 libmultimc/include/fullversion.h create mode 100644 libmultimc/include/fullversionfactory.h create mode 100644 libmultimc/include/library.h (limited to 'libmultimc/include') diff --git a/libmultimc/include/fullversion.h b/libmultimc/include/fullversion.h new file mode 100644 index 00000000..b1de02a3 --- /dev/null +++ b/libmultimc/include/fullversion.h @@ -0,0 +1,68 @@ +#pragma once +#include +#include + +class FullVersion +{ +public: + FullVersion() + { + minimumLauncherVersion = 0xDEADBEEF; + isLegacy = false; + } + // the ID - determines which jar to use! ACTUALLY IMPORTANT! + QString id; + // do we actually care about parsing this? + QString time; + // I don't think we do. + QString releaseTime; + // eh, not caring - "release" or "snapshot" + QString type; + /* + * DEPRECATED: Old versions of the new vanilla launcher used this + * ex: "username_session_version" + */ + QString processArguments; + /* + * arguments that should be used for launching minecraft + * + * ex: "--username ${auth_player_name} --session ${auth_session} + * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}" + */ + QString minecraftArguments; + /* + * the minimum launcher version required by this version ... current is 4 (at point of writing) + */ + int minimumLauncherVersion; + /* + * The main class to load first + */ + QString mainClass; + + // the list of libs. just the names for now. expand to full-blown strutures! + QStringList libraries; + + // is this actually a legacy version? if so, none of the other stuff here will be ever used. + // added by FullVersionFactory + bool isLegacy; + +/* +FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. + + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx", + "version": "^10\\.5\\.\\d$" + } + } + ], + "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!" +} +*/ + // QList rules; +}; \ No newline at end of file diff --git a/libmultimc/include/fullversionfactory.h b/libmultimc/include/fullversionfactory.h new file mode 100644 index 00000000..673a6a72 --- /dev/null +++ b/libmultimc/include/fullversionfactory.h @@ -0,0 +1,23 @@ +#pragma once +#include + +struct FullVersion; + +class FullVersionFactory +{ +public: + enum Error + { + AllOK, // all parsed OK + ParseError, // the file was corrupted somehow + UnsupportedVersion // the file was meant for a launcher version we don't support (yet) + } m_error; + QString error_string; + +public: + FullVersionFactory(); + QSharedPointer parse(QByteArray data); +private: + QSharedPointer parse4(QJsonObject root, QSharedPointer product); + QStringList legacyWhitelist; +}; \ No newline at end of file diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h new file mode 100644 index 00000000..10ecb9f3 --- /dev/null +++ b/libmultimc/include/library.h @@ -0,0 +1,18 @@ +/* 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 + + -- cgit v1.2.3 From 97cf08f964ceebf4cb98b46f473bf952007a8a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 24 Jul 2013 23:44:00 +0200 Subject: Parsing the version files, part II --- libmultimc/include/fullversion.h | 5 +- libmultimc/include/library.h | 117 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 2 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/fullversion.h b/libmultimc/include/fullversion.h index b1de02a3..523ac87c 100644 --- a/libmultimc/include/fullversion.h +++ b/libmultimc/include/fullversion.h @@ -1,6 +1,7 @@ #pragma once #include -#include + +class Library; class FullVersion { @@ -40,7 +41,7 @@ public: QString mainClass; // the list of libs. just the names for now. expand to full-blown strutures! - QStringList libraries; + QList > libraries; // is this actually a legacy version? if so, none of the other stuff here will be ever used. // added by FullVersionFactory diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h index 10ecb9f3..30270bc1 100644 --- a/libmultimc/include/library.h +++ b/libmultimc/include/library.h @@ -15,4 +15,121 @@ #pragma once +#include +class Library; + +enum RuleAction +{ + Allow, + Disallow, + Defer +}; + +RuleAction RuleAction_fromString(QString); + +class Rule +{ +protected: + RuleAction m_result; + virtual bool applies(Library * parent) = 0; +public: + Rule(RuleAction result) + :m_result(result) {} + virtual ~Rule(){}; + RuleAction apply(Library * parent) + { + if(applies(parent)) + return m_result; + else + return Defer; + }; +}; + +enum OpSys +{ + Os_Windows, + Os_Linux, + Os_OSX, + Os_Other +}; + +OpSys OpSys_fromString(QString); + +#ifdef Q_OS_MAC + #define currentSystem Os_OSX +#endif + +#ifdef Q_OS_LINUX + #define currentSystem Os_Linux +#endif + +#ifdef Q_OS_WIN32 + #define currentSystem Os_Windows +#endif + +#ifndef currentSystem + #define currentSystem Os_Other +#endif + + +class OsRule : public Rule +{ +private: + // the OS + OpSys m_system; + // the OS version regexp + QString m_version_regexp; +protected: + virtual bool applies ( Library* ) + { + return (m_system == currentSystem); + } +public: + OsRule(RuleAction result, OpSys system, QString version_regexp) + : Rule(result), m_system(system), m_version_regexp(version_regexp) {} +}; + +class ImplicitRule : public Rule +{ +protected: + virtual bool applies ( Library* ) + { + return true; + } +public: + ImplicitRule(RuleAction result) + : Rule(result) {} +}; + +class Library +{ +public: + QString base_url; + QString name; + QList > rules; + QMap natives; + QStringList extract_excludes; + + void AddRule(RuleAction result) + { + rules.append(QSharedPointer(new ImplicitRule(result))); + } + void AddRule(RuleAction result, OpSys system, QString version_regexp) + { + rules.append(QSharedPointer(new OsRule(result, system, version_regexp))); + } + bool applies() + { + if(rules.empty()) + return true; + RuleAction result = Disallow; + for(auto rule: rules) + { + RuleAction temp = rule->apply( this ); + if(temp != Defer) + result = temp; + } + return result == Allow; + } +}; -- cgit v1.2.3 From a7a84d4dbb58565f108cb0886da6cb786e34d10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 27 Jul 2013 11:41:45 +0200 Subject: Parsing the version files, part III --- libmultimc/include/fullversionfactory.h | 2 + libmultimc/include/instance.h | 16 ++- libmultimc/include/library.h | 178 +++++++++++++++++++++++--------- 3 files changed, 147 insertions(+), 49 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/fullversionfactory.h b/libmultimc/include/fullversionfactory.h index 673a6a72..60e5c983 100644 --- a/libmultimc/include/fullversionfactory.h +++ b/libmultimc/include/fullversionfactory.h @@ -2,6 +2,7 @@ #include struct FullVersion; +class Rule; class FullVersionFactory { @@ -19,5 +20,6 @@ public: QSharedPointer parse(QByteArray data); private: QSharedPointer parse4(QJsonObject root, QSharedPointer product); + QList > parse4rules(QJsonObject & baseObj); QStringList legacyWhitelist; }; \ No newline at end of file diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index 526025be..f6857cd8 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -116,8 +116,11 @@ class LIBMULTIMC_EXPORT Instance : public QObject */ Q_PROPERTY(qint64 lastCurrentVersionUpdate READ lastCurrentVersionUpdate WRITE setLastCurrentVersionUpdate) - - + /*! + * Is the instance a new launcher instance? Get/Set + */ + Q_PROPERTY(bool isForNewLauncher READ isForNewLauncher WRITE setIsForNewLauncher) + // Dirs //! Path to the instance's .minecraft folder. Q_PROPERTY(QString minecraftDir READ minecraftDir STORED false) @@ -250,6 +253,15 @@ public: virtual qint64 lastCurrentVersionUpdate() const { return settings().get("lastVersionUpdate").value(); } virtual void setLastCurrentVersionUpdate(qint64 val) { settings().set("lastVersionUpdate", val); } + virtual bool isForNewLauncher() + { + return settings().get("IsForNewLauncher").value(); + } + + virtual void setIsForNewLauncher(bool value = true) + { + settings().set("IsForNewLauncher", value); + } ////// Directories ////// QString minecraftDir() const; diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h index 30270bc1..8d97b4a6 100644 --- a/libmultimc/include/library.h +++ b/libmultimc/include/library.h @@ -19,33 +19,6 @@ class Library; -enum RuleAction -{ - Allow, - Disallow, - Defer -}; - -RuleAction RuleAction_fromString(QString); - -class Rule -{ -protected: - RuleAction m_result; - virtual bool applies(Library * parent) = 0; -public: - Rule(RuleAction result) - :m_result(result) {} - virtual ~Rule(){}; - RuleAction apply(Library * parent) - { - if(applies(parent)) - return m_result; - else - return Defer; - }; -}; - enum OpSys { Os_Windows, @@ -73,6 +46,33 @@ OpSys OpSys_fromString(QString); #endif +enum RuleAction +{ + Allow, + Disallow, + Defer +}; + +RuleAction RuleAction_fromString(QString); + +class Rule +{ +protected: + RuleAction m_result; + virtual bool applies(Library * parent) = 0; +public: + Rule(RuleAction result) + :m_result(result) {} + virtual ~Rule(){}; + RuleAction apply(Library * parent) + { + if(applies(parent)) + return m_result; + else + return Defer; + }; +}; + class OsRule : public Rule { private: @@ -85,9 +85,13 @@ protected: { return (m_system == currentSystem); } -public: OsRule(RuleAction result, OpSys system, QString version_regexp) : Rule(result), m_system(system), m_version_regexp(version_regexp) {} +public: + static QSharedPointer create(RuleAction result, OpSys system, QString version_regexp) + { + return QSharedPointer (new OsRule(result, system, version_regexp)); + } }; class ImplicitRule : public Rule @@ -97,39 +101,119 @@ protected: { return true; } -public: ImplicitRule(RuleAction result) : Rule(result) {} +public: + static QSharedPointer create(RuleAction result) + { + return QSharedPointer (new ImplicitRule(result)); + } }; class Library { +private: + // basic values used internally (so far) + QString m_name; + QString m_base_url; + QList > m_rules; + + // derived values used for real things + /// where to store the lib locally + QString m_storage_path; + /// where to download the lib from + QString m_download_path; + /// is this lib actuall active on the current OS? + bool m_is_active; + + // native lib? + bool m_is_native; + QMap m_native_suffixes; public: - QString base_url; - QString name; - QList > rules; - QMap natives; QStringList extract_excludes; - void AddRule(RuleAction result) +public: + /// finalize the library, processing the input values into derived values and state + void finalize() { - rules.append(QSharedPointer(new ImplicitRule(result))); + QStringList parts = m_name.split(':'); + QString relative = parts[0]; + relative.replace('.','/'); + relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2]; + if(!m_is_native) + relative += ".jar"; + else + { + if(m_native_suffixes.contains(currentSystem)) + { + relative += "-" + m_native_suffixes[currentSystem] + ".jar"; + } + else + { + // really, bad. + relative += ".jar"; + } + } + m_storage_path = relative; + m_download_path = m_base_url + relative; + + if(m_rules.empty()) + { + m_is_active = true; + } + else + { + RuleAction result = Disallow; + for(auto rule: m_rules) + { + RuleAction temp = rule->apply( this ); + if(temp != Defer) + result = temp; + } + m_is_active = (result == Allow); + } + if(m_is_native) + { + m_is_active = m_is_active && m_native_suffixes.contains(currentSystem); + } + }; + + Library(QString name) + { + m_is_native = false; + m_is_native = false; + m_name = name; + m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/"; + } + + void setName(QString name) + { + m_name = name; } - void AddRule(RuleAction result, OpSys system, QString version_regexp) + + void setBaseUrl(QString base_url) { - rules.append(QSharedPointer(new OsRule(result, system, version_regexp))); + m_base_url = base_url; } + + void setIsNative() + { + m_is_native = true; + } + + void addNative(OpSys os, QString suffix) + { + m_is_native = true; + m_native_suffixes[os] = suffix; + } + + void setRules(QList > rules) + { + m_rules = rules; + } + bool applies() { - if(rules.empty()) - return true; - RuleAction result = Disallow; - for(auto rule: rules) - { - RuleAction temp = rule->apply( this ); - if(temp != Defer) - result = temp; - } - return result == Allow; + return m_is_active; } }; -- cgit v1.2.3