aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.cpp51
-rw-r--r--src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.h2
2 files changed, 51 insertions, 2 deletions
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.cpp
index cd29d5f0..dab8e596 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.cpp
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.cpp
@@ -116,18 +116,26 @@ RSSchannel RSSReader::readRSS(QByteArray bytes){
RSSchannel rssinfo;
//qDebug() << "Can Read XML Stream:" << !xml.hasError();
if(xml.readNextStartElement()){
- //qDebug() << " - RSS Element:" << xml.name();
- if(xml.name() == "rss" && (xml.attributes().value("version") =="2.0" || xml.attributes().value("version") =="0.91") ){
+ qDebug() << " - RSS Element:" << xml.name();
+ if(xml.name() == "rss" && (xml.attributes().value("version") =="2.0" || xml.attributes().value("version") =="0.91")) {
while(xml.readNextStartElement()){
//qDebug() << " - RSS Element:" << xml.name();
if(xml.name()=="channel"){ rssinfo = readRSSChannel(&xml); }
else{ xml.skipCurrentElement(); }
}
+ }else if(xml.name() == "feed") {
+ qDebug() << "starting feed";
+ while(xml.readNextStartElement()){
+ qDebug() << " - ATOM Element:" << xml.name();
+ if(xml.name()=="entry"){ rssinfo = readRSSChannel(&xml); }
+ else{ xml.skipCurrentElement(); }
+ }
}
}
if(xml.hasError()){ qDebug() << " - XML Read Error:" << xml.errorString() << "\n" << bytes; }
return rssinfo;
}
+
RSSchannel RSSReader::readRSSChannel(QXmlStreamReader *rss){
RSSchannel info;
info.timetolive = -1;
@@ -151,6 +159,45 @@ RSSchannel RSSReader::readRSSChannel(QXmlStreamReader *rss){
return info;
}
+RSSchannel RSSReader::readRSSChannelAtom(QXmlStreamReader *rss){
+ RSSchannel info;
+ info.timetolive = -1;
+ while(rss->readNextStartElement()){
+ qDebug() << " - RSS Element (channel):" <<rss->name();
+ if(rss->name()=="entry"){ info.items << readRSSItemAtom(rss); }
+ else if(rss->name()=="title"){ info.title = rss->readElementText(); }
+ else if(rss->name()=="link"){
+ QString txt = rss->readElementText();
+ if(!txt.isEmpty()){ info.link = txt; }
+ }
+ else if(rss->name()=="subtitle"){ info.description = rss->readElementText(); }
+ else if(rss->name()=="updated"){ info.lastBuildDate = RSSDateTime(rss->readElementText()); }
+ else{ rss->skipCurrentElement(); }
+ }
+ return info;
+}
+
+RSSitem RSSReader::readRSSItemAtom(QXmlStreamReader *rss){
+ RSSitem item;
+ while(rss->readNextStartElement()){
+ qDebug() << " - RSS Element (Item):" << rss->name();
+ if(rss->name()=="title"){ item.title = rss->readElementText(); }
+ else if(rss->name()=="link"){ item.link = rss->readElementText(); }
+ else if(rss->name()=="summary"){ item.description = rss->readElementText(); }
+ else if(rss->name()=="comments"){ item.comments_url = rss->readElementText(); }
+ else if(rss->name()=="author"){
+ //Special handling - this field can contain both email and name
+ rss->skipCurrentElement();
+ item.author = rss->readElementText();
+ qDebug() << item.author;
+ rss->skipCurrentElement();
+ }
+ else if(rss->name()=="updated"){ item.pubdate = RSSDateTime(rss->readElementText()); }
+ else{ rss->skipCurrentElement(); }
+ }
+ return item;
+}
+
RSSitem RSSReader::readRSSItem(QXmlStreamReader *rss){
RSSitem item;
while(rss->readNextStartElement()){
diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.h b/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.h
index 3069bf8d..eb37dab3 100644
--- a/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.h
+++ b/src-qt5/core/lumina-desktop/desktop-plugins/rssreader/RSSObjects.h
@@ -88,7 +88,9 @@ private:
//RSS parsing functions
RSSchannel readRSS(QByteArray bytes);
RSSchannel readRSSChannel(QXmlStreamReader *rss);
+ RSSchannel readRSSChannelAtom(QXmlStreamReader *rss);
RSSitem readRSSItem(QXmlStreamReader *rss);
+ RSSitem readRSSItemAtom(QXmlStreamReader *rss);
void readRSSImage(RSSchannel *item, QXmlStreamReader *rss);
QDateTime RSSDateTime(QString datetime);
bgstack15