summaryrefslogtreecommitdiffstats
path: root/plugins/rssfeed/rss/tools_p.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
commit9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0 (patch)
treed088b5210e77d9fa91d954d8550e00e372b47378 /plugins/rssfeed/rss/tools_p.cpp
downloadktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.tar.gz
ktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.zip
Updated to final KDE3 ktorrent release (2.2.6)
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktorrent@1077377 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugins/rssfeed/rss/tools_p.cpp')
-rw-r--r--plugins/rssfeed/rss/tools_p.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/rssfeed/rss/tools_p.cpp b/plugins/rssfeed/rss/tools_p.cpp
new file mode 100644
index 0000000..c1ebbc9
--- /dev/null
+++ b/plugins/rssfeed/rss/tools_p.cpp
@@ -0,0 +1,51 @@
+/*
+ * tools_p.cpp
+ *
+ * Copyright (c) 2001, 2002, 2003 Frerich Raabe <raabe@kde.org>
+ *
+ * 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. For licensing and distribution details, check the
+ * accompanying file 'COPYING'.
+ */
+#include "tools_p.h"
+
+#include <krfcdate.h>
+#include <qdom.h>
+
+time_t RSS::parseISO8601Date(const QString &s)
+{
+ // do some sanity check: 26-12-2004T00:00+00:00 is parsed to epoch+1 in the KRFCDate, which is wrong. So let's check if the date begins with YYYY -fo
+ if (s.stripWhiteSpace().left(4).toInt() < 1000)
+ return 0; // error
+
+ // FIXME: imho this is done in KRFCDate::parseDateISO8601() automatically, so we could omit it? -fo
+ if (s.find('T') != -1)
+ return KRFCDate::parseDateISO8601(s);
+ else
+ return KRFCDate::parseDateISO8601(s + "T12:00:00");
+}
+
+
+QString RSS::extractNode(const QDomNode &parent, const QString &elemName, bool isInlined)
+{
+ QDomNode node = parent.namedItem(elemName);
+ if (node.isNull())
+ return QString::null;
+
+ QString result = node.toElement().text();
+
+ bool hasPre = result.contains("<pre>",false);
+ bool hasHtml = hasPre || result.contains("<"); // FIXME: test if we have html, should be more clever -> regexp
+ if(!isInlined && !hasHtml) // perform nl2br if not a inline elt and it has no html elts
+ result = result = result.replace(QChar('\n'), "<br />");
+ if(!hasPre) // strip white spaces if no <pre>
+ result = result.simplifyWhiteSpace();
+
+ if (result.isEmpty())
+ return QString::null;
+
+ return result;
+}
+
+// vim:noet:ts=4