diff options
author | Ken Moore <moorekou@gmail.com> | 2016-05-31 15:49:42 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-05-31 15:49:42 -0400 |
commit | 0e378ef4f087a04e4cc3643eb533f2e59e1a9061 (patch) | |
tree | 5d25faa30ee9b4aadd37c6d0dea67880c68d035d /src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.h | |
parent | Add a note to the OS-detect.pri file that the OS and LINUX_DISTRO variables s... (diff) | |
download | lumina-0e378ef4f087a04e4cc3643eb533f2e59e1a9061.tar.gz lumina-0e378ef4f087a04e4cc3643eb533f2e59e1a9061.tar.bz2 lumina-0e378ef4f087a04e4cc3643eb533f2e59e1a9061.zip |
Add the beginnings of a new desktop plugin: rssreader
This is a simple RSS reader for the desktop. (Not finished yet - but getting close).
Diffstat (limited to 'src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.h')
-rw-r--r-- | src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.h b/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.h new file mode 100644 index 00000000..a1cffc3f --- /dev/null +++ b/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.h @@ -0,0 +1,86 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_RSS_READER_PLUGIN_OBJECT_H +#define _LUMINA_DESKTOP_RSS_READER_PLUGIN_OBJECT_H + +#include <QNetworkAccessManager> +#include <QNetworkReply> +#include <QString> +#include <QDateTime> +#include <QList> +#include <QIcon> + +struct RSSitem{ + //Required Fields + QString title, link, description; + + //Optional Fields + QString comments_url, author_email, author, guid; + QDateTime pubdate; //when the item was published + //IGNORED INFO from RSS2 spec: "category", "source", "enclosure" +}; + +struct RSSchannel{ + //Required fields + QString title, link, description; + + //Optional Fields + QDateTime lastBuildDate, lastPubDate; //last build/publish dates + // - channel refresh information + int timetolive; //in minutes - time until next sync should be performed + //QList<int> skiphours; + //QStringList skipdays; + // - icon info + QIcon icon; + QString iconurl, icontitle, iconlink; + QSize iconsize; + //All items within this channel + QList<RSSitem> items; + + //Optional RSS2 elements ignored: + // "cloud", "textInput", "rating", "language", "copyright", "managingEditor", "webMaster", + // "category", "generator", "docs" +}; + +class RSSReader : public QObject{ + Q_OBJECT +public: + RSSReader(QObject *parent); + ~RSSReader(); + + //Information retrieval + QStringList channels(); //returns all ID's + Rsschannel dataForID(QString ID); + + //Initial setup + void addUrls(); + void removeUrl(QString ID); + +public slots: + void syncNow(); //not generally needed + +private: + QHash<QString, RSSchannel> data; // ID/data + //Network request functions + QNetworkAccessManager *NMAN; + void requestRSS(QString url); + + //RSS parsing functions + RSSchannel readRSS(QByteArray rss); + RSSchannel readRSSChannel(QXmlStreamReader *rss) + RSSitem readRSSItem(QXmlStreamReader *rss); + QDateTime RSSDateTime(QString datetime); + +private slots: + void replyFinished(QNetworkReply *reply); + +signals: + void rssChanged(QString); //ID + void newChannelsAvailable(); +}; + +#endif |