From ab868df50eb6f9f3958bdc0a7ab9199dcdf46b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 11 Mar 2017 01:39:45 +0100 Subject: NOISSUE Wonko is the new Meta And then Wonko was the Meta. --- api/logic/meta/BaseEntity.h | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 api/logic/meta/BaseEntity.h (limited to 'api/logic/meta/BaseEntity.h') diff --git a/api/logic/meta/BaseEntity.h b/api/logic/meta/BaseEntity.h new file mode 100644 index 00000000..b7a241c6 --- /dev/null +++ b/api/logic/meta/BaseEntity.h @@ -0,0 +1,53 @@ +/* Copyright 2015-2017 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 +#include + +#include "multimc_logic_export.h" + +class Task; +namespace Meta +{ +class MULTIMC_LOGIC_EXPORT BaseEntity +{ +public: + virtual ~BaseEntity(); + + using Ptr = std::shared_ptr; + + virtual std::unique_ptr remoteUpdateTask() = 0; + virtual std::unique_ptr localUpdateTask() = 0; + virtual void merge(const std::shared_ptr &other) = 0; + + void store() const; + virtual QString localFilename() const = 0; + virtual QJsonObject serialized() const = 0; + + bool isComplete() const { return m_localLoaded || m_remoteLoaded; } + + bool isLocalLoaded() const { return m_localLoaded; } + bool isRemoteLoaded() const { return m_remoteLoaded; } + + void notifyLocalLoadComplete(); + void notifyRemoteLoadComplete(); + +private: + bool m_localLoaded = false; + bool m_remoteLoaded = false; +}; +} -- cgit v1.2.3 From 0060b506257b906d40ef53d1e23404dba76afcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 17 Mar 2017 01:48:54 +0100 Subject: NOISSUE simplify. --- api/logic/meta/BaseEntity.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'api/logic/meta/BaseEntity.h') diff --git a/api/logic/meta/BaseEntity.h b/api/logic/meta/BaseEntity.h index b7a241c6..7064e9d2 100644 --- a/api/logic/meta/BaseEntity.h +++ b/api/logic/meta/BaseEntity.h @@ -17,6 +17,7 @@ #include #include +#include #include "multimc_logic_export.h" @@ -33,10 +34,10 @@ public: virtual std::unique_ptr remoteUpdateTask() = 0; virtual std::unique_ptr localUpdateTask() = 0; virtual void merge(const std::shared_ptr &other) = 0; + virtual void parse(const QJsonObject &obj) = 0; - void store() const; virtual QString localFilename() const = 0; - virtual QJsonObject serialized() const = 0; + virtual QUrl url() const; bool isComplete() const { return m_localLoaded || m_remoteLoaded; } -- cgit v1.2.3 From e46aba9da584338db8d8a1a8a487bdcc6cf84343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 18 Mar 2017 02:22:36 +0100 Subject: NOISSUE sanitize loading and downloading of metadata files --- api/logic/meta/BaseEntity.h | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'api/logic/meta/BaseEntity.h') diff --git a/api/logic/meta/BaseEntity.h b/api/logic/meta/BaseEntity.h index 7064e9d2..92a39272 100644 --- a/api/logic/meta/BaseEntity.h +++ b/api/logic/meta/BaseEntity.h @@ -15,9 +15,9 @@ #pragma once -#include -#include #include +#include +#include "QObjectPtr.h" #include "multimc_logic_export.h" @@ -26,29 +26,48 @@ namespace Meta { class MULTIMC_LOGIC_EXPORT BaseEntity { +public: /* types */ + using Ptr = std::shared_ptr; + enum class LoadStatus + { + NotLoaded, + Local, + Remote + }; + enum class UpdateStatus + { + NotDone, + InProgress, + Failed, + Succeeded + }; + public: virtual ~BaseEntity(); - using Ptr = std::shared_ptr; - - virtual std::unique_ptr remoteUpdateTask() = 0; - virtual std::unique_ptr localUpdateTask() = 0; virtual void merge(const std::shared_ptr &other) = 0; virtual void parse(const QJsonObject &obj) = 0; virtual QString localFilename() const = 0; virtual QUrl url() const; - bool isComplete() const { return m_localLoaded || m_remoteLoaded; } + bool isLoaded() const + { + return m_loadStatus > LoadStatus::NotLoaded; + } + bool shouldStartRemoteUpdate() const + { + return m_updateStatus == UpdateStatus::NotDone; + } - bool isLocalLoaded() const { return m_localLoaded; } - bool isRemoteLoaded() const { return m_remoteLoaded; } + void load(); - void notifyLocalLoadComplete(); - void notifyRemoteLoadComplete(); +protected: /* methods */ + bool loadLocalFile(); private: - bool m_localLoaded = false; - bool m_remoteLoaded = false; + LoadStatus m_loadStatus = LoadStatus::NotLoaded; + UpdateStatus m_updateStatus = UpdateStatus::NotDone; + shared_qobject_ptr m_updateTask; }; } -- cgit v1.2.3 From 2660418d58efb33cd3a0ab8ed9d48c359c076905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 19 Mar 2017 02:13:49 +0100 Subject: NOISSUE hack it together enough to get launching back Meta index will now always return valid objects. They just might never load if they don't exist on the server. --- api/logic/meta/BaseEntity.h | 1 + 1 file changed, 1 insertion(+) (limited to 'api/logic/meta/BaseEntity.h') diff --git a/api/logic/meta/BaseEntity.h b/api/logic/meta/BaseEntity.h index 92a39272..85051d97 100644 --- a/api/logic/meta/BaseEntity.h +++ b/api/logic/meta/BaseEntity.h @@ -61,6 +61,7 @@ public: } void load(); + shared_qobject_ptr getCurrentTask(); protected: /* methods */ bool loadLocalFile(); -- cgit v1.2.3