aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2016-05-31 15:49:42 -0400
committerKen Moore <moorekou@gmail.com>2016-05-31 15:49:42 -0400
commit0e378ef4f087a04e4cc3643eb533f2e59e1a9061 (patch)
tree5d25faa30ee9b4aadd37c6d0dea67880c68d035d /src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.cpp
parentAdd a note to the OS-detect.pri file that the OS and LINUX_DISTRO variables s... (diff)
downloadlumina-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.cpp')
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.cpp
new file mode 100644
index 00000000..45a6bfeb
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSObjects.cpp
@@ -0,0 +1,101 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "RSSObjects.h"
+#include <QNetworkRequest>
+#include <QXmlStreamReader>
+
+//============
+// PUBLIC
+//============
+RSSReader::RSSReader(QObject *parent) : QObject(parent){
+ NMAN = new QNetworkAccessManager(this);
+}
+
+RSSReader::~RSSReader(){
+
+}
+
+//Information retrieval
+QStringList RSSReader::channels(){
+ return QStringList( data.keys() );
+}
+
+Rsschannel RSSReader::dataForID(QString ID){
+
+}
+
+//Initial setup
+void RSSReader::addUrls(){
+
+}
+
+void RSSReader::removeUrl(QString ID){
+
+}
+
+//=================
+// PUBLIC SLOTS
+//=================
+void RSSReader::syncNow(){
+
+}
+
+//=================
+// PRIVATE
+//=================
+void RSSchannel::requestRSS(QString url){
+ NMAN->get( QNetworkRequest( QUrl(url) ) );
+}
+
+//RSS parsing functions
+RSSchannel RSSReader::readRSS(QIODevice *device){
+ QXmlStreamReader xml(device);
+ RSSchannel rssinfo;
+ if(xml.readNextStartElement()){
+ if(xml.name() = "rss" && xml.attributes().value("version" =="2.0")){
+ while(xml.readNextStartElement()){
+ if(xml.name()=="channel"){ rssinfo = readRSSChannel(&xml); }
+ }
+ }
+ }
+ return rssinfo;
+}
+RSSchannel RSSReader::readRSSChannel(QXmlStreamReader *rss){
+ RSSchannel info;
+ while(rss.readNextStartElement()){
+ if(rss.name()=="item"){ info.items << readRSSItem(rss); }
+ else if(rss.name()=="title"){ info.title = rss.readElementText(); }
+ else if(rss.name()=="link"){ info.link = rss.readElementText(); }
+ else if(rss.name()=="description"){ info.description = rss.readElementText(); }
+ else if(rss.name()=="lastBuildDate"){ info.lastBuildDate = RSSDateTime(rss.readElementText()); }
+ else if(rss.name()=="pubDate"){ info.lastPubDate = RSSDateTime(rss.readElementText()); }
+ else if(rss.name()=="image"){ info.link = rss.readElementText(); }
+ else if(rss.name()=="guid"){ info.guid = rss.readElementText(); }
+ //else if(rss.name()=="skipHours"){ info.link = rss.readElementText(); }
+ //else if(rss.name()=="skipDays"){ info.link = rss.readElementText(); }
+ else if(rss.name()=="ttl"){ info.timetolive = rss.readElementText().toInt(); }
+ }
+ return info;
+}
+RSSitem RSSReader::readRSSItem(QXmlStreamReader *rss){
+
+}
+
+QDateTime RSSReader::RSSDateTime(QString datetime){
+
+}
+
+//=================
+// PRIVATE SLOTS
+//=================
+void RSSReader::replyFinished(QNetworkReply *reply){
+ RSSchannel info = ReadRSS(reply); //QNetworkReply can be used as QIODevice
+ reply->deleteLater(); //clean up
+ //Validate the info and announce any changes
+
+
+}
bgstack15