summaryrefslogtreecommitdiffstats
path: root/libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-04-10 15:53:05 +0200
committerPetr Mrázek <peterix@gmail.com>2016-05-01 00:00:14 +0200
commitb6d455a02bd338e9dc0faa09d4d8177ecd8d569a (patch)
tree41982bca1ede50049f2f8c7109dd18edeefde6d0 /libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
parent47e37635f50c09b4f9a9ee7699e3120bab3e4088 (diff)
downloadMultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.gz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.lz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.xz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.zip
NOISSUE reorganize and document libraries
Diffstat (limited to 'libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp')
-rw-r--r--libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp126
1 files changed, 0 insertions, 126 deletions
diff --git a/libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp b/libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
deleted file mode 100644
index 727ec89d..00000000
--- a/libraries/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright 2015 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 "BaseWonkoEntityRemoteLoadTask.h"
-
-#include "net/CacheDownload.h"
-#include "net/HttpMetaCache.h"
-#include "net/NetJob.h"
-#include "wonko/format/WonkoFormat.h"
-#include "wonko/WonkoUtil.h"
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersion.h"
-#include "wonko/WonkoVersionList.h"
-#include "Env.h"
-#include "Json.h"
-
-BaseWonkoEntityRemoteLoadTask::BaseWonkoEntityRemoteLoadTask(BaseWonkoEntity *entity, QObject *parent)
- : Task(parent), m_entity(entity)
-{
-}
-
-void BaseWonkoEntityRemoteLoadTask::executeTask()
-{
- NetJob *job = new NetJob(name());
-
- auto entry = ENV.metacache()->resolveEntry("wonko", url().toString());
- entry->setStale(true);
- m_dl = CacheDownload::make(url(), entry);
- job->addNetAction(m_dl);
- connect(job, &NetJob::failed, this, &BaseWonkoEntityRemoteLoadTask::emitFailed);
- connect(job, &NetJob::succeeded, this, &BaseWonkoEntityRemoteLoadTask::networkFinished);
- connect(job, &NetJob::status, this, &BaseWonkoEntityRemoteLoadTask::setStatus);
- connect(job, &NetJob::progress, this, &BaseWonkoEntityRemoteLoadTask::setProgress);
- job->start();
-}
-
-void BaseWonkoEntityRemoteLoadTask::networkFinished()
-{
- setStatus(tr("Parsing..."));
- setProgress(0, 0);
-
- try
- {
- parse(Json::requireObject(Json::requireDocument(m_dl->getTargetFilepath(), name()), name()));
- m_entity->notifyRemoteLoadComplete();
- emitSucceeded();
- }
- catch (Exception &e)
- {
- emitFailed(tr("Unable to parse response: %1").arg(e.cause()));
- }
-}
-
-// WONKO INDEX //
-WonkoIndexRemoteLoadTask::WonkoIndexRemoteLoadTask(WonkoIndex *index, QObject *parent)
- : BaseWonkoEntityRemoteLoadTask(index, parent)
-{
-}
-QUrl WonkoIndexRemoteLoadTask::url() const
-{
- return Wonko::indexUrl();
-}
-QString WonkoIndexRemoteLoadTask::name() const
-{
- return tr("Wonko Index");
-}
-void WonkoIndexRemoteLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseIndex(obj, dynamic_cast<WonkoIndex *>(entity()));
-}
-
-// WONKO VERSION LIST //
-WonkoVersionListRemoteLoadTask::WonkoVersionListRemoteLoadTask(WonkoVersionList *list, QObject *parent)
- : BaseWonkoEntityRemoteLoadTask(list, parent)
-{
-}
-QUrl WonkoVersionListRemoteLoadTask::url() const
-{
- return Wonko::versionListUrl(list()->uid());
-}
-QString WonkoVersionListRemoteLoadTask::name() const
-{
- return tr("Wonko Version List for %1").arg(list()->humanReadable());
-}
-void WonkoVersionListRemoteLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseVersionList(obj, list());
-}
-WonkoVersionList *WonkoVersionListRemoteLoadTask::list() const
-{
- return dynamic_cast<WonkoVersionList *>(entity());
-}
-
-// WONKO VERSION //
-WonkoVersionRemoteLoadTask::WonkoVersionRemoteLoadTask(WonkoVersion *version, QObject *parent)
- : BaseWonkoEntityRemoteLoadTask(version, parent)
-{
-}
-QUrl WonkoVersionRemoteLoadTask::url() const
-{
- return Wonko::versionUrl(version()->uid(), version()->version());
-}
-QString WonkoVersionRemoteLoadTask::name() const
-{
- return tr("Wonko Version for %1").arg(version()->name());
-}
-void WonkoVersionRemoteLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseVersion(obj, version());
-}
-WonkoVersion *WonkoVersionRemoteLoadTask::version() const
-{
- return dynamic_cast<WonkoVersion *>(entity());
-}