kasts/src/fetcher.h

57 lines
1.9 KiB
C
Raw Normal View History

2020-02-28 23:25:08 +01:00
/**
* Copyright 2020 Tobias Fella <fella@posteo.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#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-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-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);
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
QNetworkAccessManager *manager;
2020-02-28 23:25:08 +01:00
Q_SIGNALS:
2020-05-26 16:32:07 +02:00
void feedUpdated(QString url);
void feedDetailsUpdated(QString url, QString name, QString image, QString link, QString description);
2020-02-28 23:25:08 +01:00
};