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-05-26 16:32:07 +02:00
|
|
|
Q_INVOKABLE void fetch(QString url);
|
2020-05-31 18:17:25 +02:00
|
|
|
Q_INVOKABLE void fetchAll();
|
2020-05-19 20:37:51 +02:00
|
|
|
Q_INVOKABLE QString image(QString);
|
2020-04-26 23:40:09 +02:00
|
|
|
void removeImage(QString);
|
2020-05-19 20:37:51 +02:00
|
|
|
Q_INVOKABLE void download(QString url);
|
2020-07-02 19:14:07 +02:00
|
|
|
QNetworkReply *get(QNetworkRequest &request);
|
2020-02-28 23:25:08 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Fetcher();
|
|
|
|
|
2020-05-18 21:00:05 +02:00
|
|
|
QString filePath(QString);
|
2020-05-26 16:32:07 +02:00
|
|
|
void processFeed(Syndication::FeedPtr feed, QString url);
|
|
|
|
void processEntry(Syndication::ItemPtr entry, QString url);
|
2020-05-30 17:33:08 +02:00
|
|
|
void processAuthor(Syndication::PersonPtr author, QString entryId, QString url);
|
2020-05-26 16:32:07 +02:00
|
|
|
void processEnclosure(Syndication::EnclosurePtr enclosure, Syndication::ItemPtr entry, QString feedUrl);
|
2020-04-26 23:40:09 +02:00
|
|
|
|
2020-04-25 22:16:19 +02:00
|
|
|
QNetworkAccessManager *manager;
|
|
|
|
|
2020-02-28 23:25:08 +01:00
|
|
|
Q_SIGNALS:
|
2020-05-31 18:17:25 +02:00
|
|
|
void startedFetchingFeed(QString url);
|
2020-05-26 16:32:07 +02:00
|
|
|
void feedUpdated(QString url);
|
2020-06-06 00:05:32 +02:00
|
|
|
void feedDetailsUpdated(QString url, QString name, QString image, QString link, QString description, QDateTime lastUpdated);
|
2020-07-02 21:57:09 +02:00
|
|
|
void error(QString url, int errorId, QString errorString);
|
2020-07-04 23:29:46 +02:00
|
|
|
void imageDownloadFinished(QString url);
|
2020-02-28 23:25:08 +01:00
|
|
|
};
|