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

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

#include "qtlibs/config.h"

akiraohgaki's avatar
akiraohgaki committed
namespace qtlibs {
class NetworkResource;
akiraohgaki's avatar
akiraohgaki committed
}

akiraohgaki's avatar
akiraohgaki committed
namespace handlers {
akiraohgaki's avatar
akiraohgaki committed

class XdgUrl : public QObject
{
    Q_OBJECT

public:
    explicit XdgUrl(const QString &xdgUrl, const qtlibs::Config &config, QObject *parent = 0);
akiraohgaki's avatar
akiraohgaki committed

akiraohgaki's avatar
akiraohgaki committed
signals:
    void started();
akiraohgaki's avatar
akiraohgaki committed
    void finishedWithSuccess(QJsonObject result);
    void finishedWithError(QJsonObject result);
    void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
akiraohgaki's avatar
akiraohgaki committed

public slots:
akiraohgaki's avatar
akiraohgaki committed
    QString xdgUrl() const;
    QJsonObject metadata() const;

akiraohgaki's avatar
akiraohgaki committed
    void process();
akiraohgaki's avatar
akiraohgaki committed
    bool isValid();
akiraohgaki's avatar
akiraohgaki committed
    void openDestination();
akiraohgaki's avatar
akiraohgaki committed

private slots:
akiraohgaki's avatar
akiraohgaki committed
    void networkResourceFinished(qtlibs::NetworkResource *resource);
akiraohgaki's avatar
akiraohgaki committed

akiraohgaki's avatar
akiraohgaki committed
private:
akiraohgaki's avatar
akiraohgaki committed
    void parse();
    void loadDestinations();
    QString convertPathString(const QString &path);
akiraohgaki's avatar
akiraohgaki committed
    void saveDownloadedFile(qtlibs::NetworkResource *resource);
    void installDownloadedFile(qtlibs::NetworkResource *resource);
akiraohgaki's avatar
akiraohgaki committed

    QString xdgUrl_;
    qtlibs::Config config_;
akiraohgaki's avatar
akiraohgaki committed
    QJsonObject metadata_;
    QJsonObject destinations_;
    QString destination_;
akiraohgaki's avatar
akiraohgaki committed
};

akiraohgaki's avatar
akiraohgaki committed
} // namespace handlers