[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenetwork/librss
From:       Frerich Raabe <raabe () kde ! org>
Date:       2004-04-09 22:06:36
Message-ID: 20040409220636.7933F9A3E () office ! kde ! org
[Download RAW message or body]

CVS commit by raabe: 

- Initial, incomplete, RSS 2.0 support (based on patch by berkus)


  M +43 -2     article.cpp   1.10
  M +19 -0     article.h   1.11


--- kdenetwork/librss/article.h  #1.10:1.11
@@ -12,4 +12,5 @@
 #define LIBRSS_ARTICLE_H
 
+class QDateTime;
 class QDomNode;
 template <class>
@@ -106,4 +107,22 @@ namespace RSS
 
                         /**
+                         * RSS 2.0 and upwards
+                         * @return An article GUID (globally unique identifier).
+                         */
+                        QString guid() const;
+
+                        /**
+                         * RSS 2.0 and upwards
+                         * @return If this article GUID is permalink. Has no meaning \
when guid() is QString::null. +                         */
+                        bool guidIsPermaLink() const;
+
+                        /**
+                         * RSS 2.0 and upwards
+                         * @return The date when the article was published.
+                         */
+                        const QDateTime &pubDate() const;
+
+                        /**
                          * @param parent The parent widget for the KURLLabel.
                          * @param name A name for the widget which will be used \
internally.

--- kdenetwork/librss/article.cpp  #1.9:1.10
@@ -12,7 +12,9 @@
 #include "tools_p.h"
 
+#include <krfcdate.h>
 #include <kurl.h>
 #include <kurllabel.h>
 
+#include <qdatetime.h>
 #include <qdom.h>
 
@@ -24,4 +26,7 @@ struct Article::Private : public Shared
         KURL link;
         QString description;
+        QDateTime pubDate;
+        QString guid;
+        bool guidIsPermaLink;
 };
 
@@ -45,4 +50,21 @@ Article::Article(const QDomNode &node) :
         if (!(elemText = extractNode(node, \
QString::fromLatin1("description"))).isNull())  d->description = elemText;
+        if (!(elemText = extractNode(node, \
QString::fromLatin1("pubDate"))).isNull()) { +                time_t _time = \
KRFCDate::parseDate(elemText); +                /* \bug This isn't really the right \
way since it will set the date to +                 * Jan 1 1970, 1:00:00 if the \
passed date was invalid; this means that +                 * we cannot distinguish \
between that date, and invalid values. :-/ +                 */
+                d->pubDate.setTime_t(_time);
+        }
+
+        QDomNode n = node.namedItem(QString::fromLatin1("guid"));
+        if (!n.isNull()) {
+                d->guidIsPermaLink = true;
+                if (n.toElement().attribute(QString::fromLatin1("isPermaLink"), \
"true") == "false") d->guidIsPermaLink = false; +
+                if (!(elemText = extractNode(node, \
QString::fromLatin1("guid"))).isNull()) +                        d->guid = elemText;
+        }
 }
 
@@ -68,4 +90,19 @@ QString Article::description() const
 }
 
+QString Article::guid() const
+{
+        return d->guid;
+}
+
+bool Article::guidIsPermaLink() const
+{
+        return d->guidIsPermaLink;
+}
+
+const QDateTime &Article::pubDate() const
+{
+        return d->pubDate;
+}
+
 KURLLabel *Article::widget(QWidget *parent, const char *name) const
 {
@@ -92,6 +129,10 @@ bool Article::operator==(const Article &
 {
         return d->title == other.title() &&
+                d->link == other.link() &&
                d->description == other.description() &&
-                   d->link == other.link();
+                d->pubDate == other.pubDate() &&
+                d->guid == other.guid() &&
+                d->guidIsPermaLink == other.guidIsPermaLink();
 }
+
 // vim:noet:ts=4


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic