Skip to content
Snippets Groups Projects
itemhandler.h 1.41 KiB
Newer Older
akiraohgaki's avatar
akiraohgaki committed
#pragma once

#include <QObject>
#include <QJsonObject>

namespace qtlib {
class NetworkResource;
}

class ConfigHandler;

class ItemHandler : public QObject
{
    Q_OBJECT

public:
    explicit ItemHandler(ConfigHandler *configHandler, QObject *parent = 0);

signals:
    void metadataSetChanged();
    void downloadStarted(QJsonObject result);
    void downloadFinished(QJsonObject result);
    void downloadProgress(QString id, qint64 bytesReceived, qint64 bytesTotal);
akiraohgaki's avatar
akiraohgaki committed
    void saveStarted(QJsonObject result);
    void saveFinished(QJsonObject result);
akiraohgaki's avatar
akiraohgaki committed
    void installStarted(QJsonObject result);
    void installFinished(QJsonObject result);
    void uninstallStarted(QJsonObject result);
    void uninstallFinished(QJsonObject result);

public slots:
    QJsonObject metadataSet() const;

akiraohgaki's avatar
akiraohgaki committed
    void getItem(const QString &command, const QString &url, const QString &installType, const QString &filename = "",
                 const QString &providerKey = "", const QString &contentId = "");
    void getItemByOcsUrl(const QString &ocsUrl);
akiraohgaki's avatar
akiraohgaki committed
    void uninstall(const QString &itemKey);

private slots:
    void networkResourceFinished(qtlib::NetworkResource *resource);

private:
    void setMetadataSet(const QJsonObject &metadataSet);

akiraohgaki's avatar
akiraohgaki committed
    void saveDownloadedFile(qtlib::NetworkResource *resource);
    void installDownloadedFile(qtlib::NetworkResource *resource);
akiraohgaki's avatar
akiraohgaki committed

    ConfigHandler *configHandler_;
    QJsonObject metadataSet_;
};