2017-01-08 09:28:05 +05:30
|
|
|
/* Copyright 2015-2017 MultiMC Contributors
|
2016-04-07 02:39:30 +05:30
|
|
|
*
|
|
|
|
* 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 "tasks/Task.h"
|
|
|
|
#include <memory>
|
|
|
|
|
2016-05-28 23:24:17 +05:30
|
|
|
namespace Net
|
|
|
|
{
|
2017-03-11 06:09:45 +05:30
|
|
|
class Download;
|
2016-05-28 23:24:17 +05:30
|
|
|
}
|
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
namespace Meta
|
|
|
|
{
|
|
|
|
class BaseEntity;
|
|
|
|
class Index;
|
|
|
|
class VersionList;
|
|
|
|
class Version;
|
2016-04-07 02:39:30 +05:30
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
class RemoteLoadTask : public Task
|
2016-04-07 02:39:30 +05:30
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-03-11 06:09:45 +05:30
|
|
|
explicit RemoteLoadTask(BaseEntity *entity, QObject *parent = nullptr);
|
2016-04-07 02:39:30 +05:30
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual QUrl url() const = 0;
|
|
|
|
virtual QString name() const = 0;
|
|
|
|
virtual void parse(const QJsonObject &obj) const = 0;
|
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
BaseEntity *entity() const { return m_entity; }
|
2016-04-07 02:39:30 +05:30
|
|
|
|
|
|
|
private slots:
|
|
|
|
void networkFinished();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void executeTask() override;
|
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
BaseEntity *m_entity;
|
2016-05-28 23:24:17 +05:30
|
|
|
std::shared_ptr<Net::Download> m_dl;
|
2016-04-07 02:39:30 +05:30
|
|
|
};
|
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
class IndexRemoteLoadTask : public RemoteLoadTask
|
2016-04-07 02:39:30 +05:30
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-03-11 06:09:45 +05:30
|
|
|
explicit IndexRemoteLoadTask(Index *index, QObject *parent = nullptr);
|
2016-04-07 02:39:30 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
QUrl url() const override;
|
|
|
|
QString name() const override;
|
|
|
|
void parse(const QJsonObject &obj) const override;
|
|
|
|
};
|
2017-03-11 06:09:45 +05:30
|
|
|
|
|
|
|
class VersionListRemoteLoadTask : public RemoteLoadTask
|
2016-04-07 02:39:30 +05:30
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-03-11 06:09:45 +05:30
|
|
|
explicit VersionListRemoteLoadTask(VersionList *list, QObject *parent = nullptr);
|
2016-04-07 02:39:30 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
QUrl url() const override;
|
|
|
|
QString name() const override;
|
|
|
|
void parse(const QJsonObject &obj) const override;
|
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
VersionList *list() const;
|
2016-04-07 02:39:30 +05:30
|
|
|
};
|
2017-03-11 06:09:45 +05:30
|
|
|
|
|
|
|
class VersionRemoteLoadTask : public RemoteLoadTask
|
2016-04-07 02:39:30 +05:30
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-03-11 06:09:45 +05:30
|
|
|
explicit VersionRemoteLoadTask(Version *version, QObject *parent = nullptr);
|
2016-04-07 02:39:30 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
QUrl url() const override;
|
|
|
|
QString name() const override;
|
|
|
|
void parse(const QJsonObject &obj) const override;
|
|
|
|
|
2017-03-11 06:09:45 +05:30
|
|
|
Version *version() const;
|
2016-04-07 02:39:30 +05:30
|
|
|
};
|
2017-03-11 06:09:45 +05:30
|
|
|
}
|