Skip to content
Snippets Groups Projects
xdgurl.h 1.24 KiB
Newer Older
akiraohgaki's avatar
akiraohgaki committed
#ifndef HANDLERS_XDGURL_H
#define HANDLERS_XDGURL_H

#include <QObject>
akiraohgaki's avatar
akiraohgaki committed
#include <QJsonObject>
akiraohgaki's avatar
akiraohgaki committed

akiraohgaki's avatar
akiraohgaki committed
class QNetworkReply;
akiraohgaki's avatar
akiraohgaki committed

namespace Core {
class Config;
class Network;
}

namespace Handlers {

class XdgUrl : public QObject
{
    Q_OBJECT

private:
akiraohgaki's avatar
akiraohgaki committed
    QString _xdgUrl;
akiraohgaki's avatar
akiraohgaki committed
    Core::Config *_appConfig;
    Core::Config *_userConfig;
    Core::Network *_asyncNetwork;

akiraohgaki's avatar
akiraohgaki committed
    QJsonObject _metadata;
akiraohgaki's avatar
akiraohgaki committed
    QJsonObject _destinations;
    QJsonObject _archiveTypes;
akiraohgaki's avatar
akiraohgaki committed

akiraohgaki's avatar
akiraohgaki committed
public:
akiraohgaki's avatar
akiraohgaki committed
    explicit XdgUrl(const QString &xdgUrl, Core::Config *appConfig, Core::Config *userConfig, Core::Network *asyncNetwork, QObject *parent = 0);
akiraohgaki's avatar
akiraohgaki committed

private:
akiraohgaki's avatar
akiraohgaki committed
    QJsonObject _parse();
akiraohgaki's avatar
akiraohgaki committed
    QString _convertPathString(const QString &path);
akiraohgaki's avatar
akiraohgaki committed
    QJsonObject _loadDestinations();
    QJsonObject _loadArchiveTypes();
akiraohgaki's avatar
akiraohgaki committed
    bool _installPlasmapkg(const QString &path, const QString &type = "plasmoid");
    bool _uncompressArchive(const QString &path, const QString &targetDir);
akiraohgaki's avatar
akiraohgaki committed

private slots:
akiraohgaki's avatar
akiraohgaki committed
    void _saveDownloadedFile(QNetworkReply *reply);
    void _installDownloadedFile(QNetworkReply *reply);
akiraohgaki's avatar
akiraohgaki committed

public slots:
akiraohgaki's avatar
akiraohgaki committed
    QString getXdgUrl();
akiraohgaki's avatar
akiraohgaki committed
    QString getMetadata();
akiraohgaki's avatar
akiraohgaki committed
    bool isValid();
akiraohgaki's avatar
akiraohgaki committed
    void process();
akiraohgaki's avatar
akiraohgaki committed

signals:
akiraohgaki's avatar
akiraohgaki committed
    void finished(const QString &result);
akiraohgaki's avatar
akiraohgaki committed
};

} // namespace Handlers

#endif // HANDLERS_XDGURL_H