2017-01-08 03:58:05 +00:00
|
|
|
/* Copyright 2013-2017 MultiMC Contributors
|
2013-11-04 01:53:05 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-09-08 00:15:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-29 00:24:00 +00:00
|
|
|
#include "tasks/Task.h"
|
|
|
|
|
2013-09-08 00:15:20 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QUrl>
|
2013-10-05 23:13:40 +00:00
|
|
|
#include <memory>
|
2013-09-08 00:15:20 +00:00
|
|
|
#include <QNetworkReply>
|
2015-02-09 00:51:14 +00:00
|
|
|
#include <QObjectPtr.h>
|
2013-09-08 00:15:20 +00:00
|
|
|
|
2015-09-05 17:10:03 +00:00
|
|
|
#include "multimc_logic_export.h"
|
|
|
|
|
2013-10-26 17:55:48 +00:00
|
|
|
typedef std::shared_ptr<class NetAction> NetActionPtr;
|
2017-04-29 00:24:00 +00:00
|
|
|
class MULTIMC_LOGIC_EXPORT NetAction : public Task
|
2013-09-08 00:15:20 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
protected:
|
2017-04-29 00:24:00 +00:00
|
|
|
explicit NetAction(QObject *parent = 0) : Task(parent) {};
|
2013-10-05 23:13:40 +00:00
|
|
|
|
2013-09-08 00:15:20 +00:00
|
|
|
public:
|
2013-10-26 17:55:48 +00:00
|
|
|
virtual ~NetAction() {};
|
2013-09-08 00:15:20 +00:00
|
|
|
|
2013-12-15 14:00:09 +00:00
|
|
|
public:
|
2015-10-20 15:18:53 +00:00
|
|
|
unique_qobject_ptr<QNetworkReply> m_reply;
|
2013-09-08 00:15:20 +00:00
|
|
|
QUrl m_url;
|
2017-04-29 19:34:36 +00:00
|
|
|
// FIXME: pull this up into Task
|
2017-04-29 00:24:00 +00:00
|
|
|
Status m_status = Status::NotStarted;
|
2013-09-08 00:15:20 +00:00
|
|
|
|
|
|
|
signals:
|
2017-04-29 00:24:00 +00:00
|
|
|
void failed();
|
|
|
|
void aborted();
|
2013-09-08 00:15:20 +00:00
|
|
|
|
2017-04-29 00:24:00 +00:00
|
|
|
protected slots:
|
2013-09-08 00:15:20 +00:00
|
|
|
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) = 0;
|
|
|
|
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
|
|
|
|
virtual void downloadFinished() = 0;
|
|
|
|
virtual void downloadReadyRead() = 0;
|
|
|
|
};
|