kasts/src/fetcher.h

50 lines
1.6 KiB
C
Raw Normal View History

2020-02-28 23:25:08 +01:00
/**
2020-08-14 20:56:04 +02:00
* SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>
2020-02-28 23:25:08 +01:00
*
2020-08-14 20:56:04 +02:00
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
2020-02-28 23:25:08 +01:00
*/
#pragma once
2020-04-26 23:40:09 +02:00
#include <QNetworkAccessManager>
2020-02-28 23:25:08 +01:00
#include <QObject>
#include <QUrl>
2020-05-18 16:47:12 +02:00
#include <Syndication/Syndication>
2020-02-28 23:25:08 +01:00
class Fetcher : public QObject
{
Q_OBJECT
public:
static Fetcher &instance()
{
static Fetcher _instance;
return _instance;
}
2020-11-01 13:18:11 +01:00
Q_INVOKABLE void fetch(const QString &url);
Q_INVOKABLE void fetchAll();
2020-11-01 13:18:11 +01:00
Q_INVOKABLE QString image(const QString &url);
void removeImage(const QString &url);
2021-02-21 19:54:10 +01:00
Q_INVOKABLE QNetworkReply *download(QString url);
2020-07-02 19:14:07 +02:00
QNetworkReply *get(QNetworkRequest &request);
2021-02-21 19:54:10 +01:00
QString filePath(const QString &url);
2020-02-28 23:25:08 +01:00
private:
Fetcher();
2020-11-01 13:18:11 +01:00
void processFeed(Syndication::FeedPtr feed, const QString &url);
void processEntry(Syndication::ItemPtr entry, const QString &url);
void processAuthor(Syndication::PersonPtr author, const QString &entryId, const QString &url);
void processEnclosure(Syndication::EnclosurePtr enclosure, Syndication::ItemPtr entry, const QString &feedUrl);
2020-04-26 23:40:09 +02:00
2021-02-21 19:54:10 +01:00
QNetworkAccessManager *manager;
2020-02-28 23:25:08 +01:00
Q_SIGNALS:
2020-11-01 13:18:11 +01:00
void startedFetchingFeed(const QString &url);
void feedUpdated(const QString &url);
void feedDetailsUpdated(const QString &url, const QString &name, const QString &image, const QString &link, const QString &description, const QDateTime &lastUpdated);
void error(const QString &url, int errorId, const QString &errorString);
void entryAdded(const QString &feedurl, const QString &id);
2021-02-21 19:54:10 +01:00
void downloadFinished(QString url);
2020-02-28 23:25:08 +01:00
};