diff --git a/syndication/mapper/itemrdfimpl.cpp b/syndication/mapper/itemrdfimpl.cpp index ab2fb98e6..793c2cb39 100644 --- a/syndication/mapper/itemrdfimpl.cpp +++ b/syndication/mapper/itemrdfimpl.cpp @@ -1,165 +1,165 @@ /* * This file is part of the syndication library * * Copyright (C) 2006 Frank Osterfeld * * This library is free software you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation either * version 2 of the License, or (at your option) any later version. * * This library 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. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "itemrdfimpl.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using Syndication::RDF::Property; using Syndication::RDF::PropertyPtr; namespace Syndication { ItemRDFImpl::ItemRDFImpl(const Syndication::RDF::Item& item) : m_item(item) { } QString ItemRDFImpl::title() const { return m_item.title(); } QString ItemRDFImpl::link() const { return m_item.link(); } QString ItemRDFImpl::description() const { return m_item.description(); } QString ItemRDFImpl::content() const { return m_item.encodedContent(); } QList ItemRDFImpl::authors() const { QList list; - + QStringList people = m_item.dc().creators(); people += m_item.dc().contributors(); QStringList::ConstIterator it = people.constBegin(); QStringList::ConstIterator end = people.constEnd(); - + for ( ; it != end; ++it) { PersonPtr ptr = personFromString(*it); if (!ptr->isNull()) { list.append(ptr); } } return list; } QString ItemRDFImpl::language() const { return m_item.dc().language(); } QString ItemRDFImpl::id() const { if (!m_item.resource()->isAnon()) return m_item.resource()->uri(); else - return "hash:" + calcMD5Sum(title() + description() + content()); + return "hash:" + calcMD5Sum(title() + description() + link() + content()); } -time_t ItemRDFImpl::datePublished() const +time_t ItemRDFImpl::datePublished() const { return m_item.dc().date(); } -time_t ItemRDFImpl::dateUpdated() const +time_t ItemRDFImpl::dateUpdated() const { return m_item.dc().date(); } QList ItemRDFImpl::enclosures() const { // return empty list return QList(); } QList ItemRDFImpl::categories() const { // return empty list return QList(); } int ItemRDFImpl::commentsCount() const { PropertyPtr prop(new Property(slashNamespace() + QString::fromUtf8("comments"))); QString cstr = m_item.resource()->property(prop)->asString(); bool ok = false; int comments = cstr.toInt(&ok); return ok ? comments : -1; return -1; } QString ItemRDFImpl::commentsLink() const { return QString(); } QString ItemRDFImpl::commentsFeed() const { PropertyPtr prop(new Property(commentApiNamespace() + QString::fromUtf8("commentRss"))); return m_item.resource()->property(prop)->asString(); } QString ItemRDFImpl::commentPostUri() const { PropertyPtr prop(new Property(commentApiNamespace() + QString::fromUtf8("comment"))); return m_item.resource()->property(prop)->asString(); } Syndication::SpecificItemPtr ItemRDFImpl::specificItem() const { return Syndication::SpecificItemPtr(new Syndication::RDF::Item(m_item)); } QMultiMap ItemRDFImpl::additionalProperties() const { return QMultiMap(); } } // namespace Syndication diff --git a/syndication/mapper/itemrss2impl.cpp b/syndication/mapper/itemrss2impl.cpp index 889e6d2c5..e2e760c4b 100644 --- a/syndication/mapper/itemrss2impl.cpp +++ b/syndication/mapper/itemrss2impl.cpp @@ -1,187 +1,187 @@ /* * This file is part of the syndication library * * Copyright (C) 2006 Frank Osterfeld * * This library is free software you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation either * version 2 of the License, or (at your option) any later version. * * This library 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. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "itemrss2impl.h" #include "categoryrss2impl.h" #include "enclosurerss2impl.h" #include #include #include #include #include #include #include #include #include namespace Syndication { ItemRSS2Impl::ItemRSS2Impl(const Syndication::RSS2::Item& item) : m_item(item) { } QString ItemRSS2Impl::title() const { return m_item.title(); } QString ItemRSS2Impl::link() const { QString link = m_item.link(); if (!link.isEmpty()) return link; QString guid = m_item.guid(); if (m_item.guidIsPermaLink()) return guid; return QString(); } QString ItemRSS2Impl::description() const { return m_item.description(); } QString ItemRSS2Impl::content() const { return m_item.content(); } QList ItemRSS2Impl::authors() const { QList list; - + PersonPtr ptr = personFromString(m_item.author()); - + if (!ptr->isNull()) { list.append(ptr); } - + return list; } QString ItemRSS2Impl::language() const { return QString(); } QString ItemRSS2Impl::id() const { QString guid = m_item.guid(); if (!guid.isEmpty()) return guid; - - return QString("hash:%1").arg(calcMD5Sum(title() - + description() + content())); + + return QString("hash:%1").arg(calcMD5Sum(title() + + description() + link() + content())); } time_t ItemRSS2Impl::datePublished() const { return m_item.pubDate(); } time_t ItemRSS2Impl::dateUpdated() const { return datePublished(); } QList ItemRSS2Impl::enclosures() const { QList list; - + QList encs = m_item.enclosures(); - + for (QList::ConstIterator it = encs.constBegin(); it != encs.constEnd(); ++it) { EnclosureRSS2ImplPtr impl(new EnclosureRSS2Impl(m_item, *it)); list.append(impl); } - + return list; } QList ItemRSS2Impl::categories() const { QList list; - + QList cats = m_item.categories(); QList::ConstIterator it = cats.constBegin(); QList::ConstIterator end = cats.constEnd(); - + for ( ; it != end; ++it) { CategoryRSS2ImplPtr impl(new CategoryRSS2Impl(*it)); list.append(impl); } - + return list; } int ItemRSS2Impl::commentsCount() const { QString cstr = m_item.extractElementTextNS(slashNamespace(), QString::fromUtf8("comments")); bool ok = false; int comments = cstr.toInt(&ok); return ok ? comments : -1; } QString ItemRSS2Impl::commentsLink() const { return m_item.comments(); } QString ItemRSS2Impl::commentsFeed() const { QString t = m_item.extractElementTextNS(commentApiNamespace(), QString::fromUtf8("commentRss")); if (t.isNull()) t = m_item.extractElementTextNS(commentApiNamespace(), QString::fromUtf8("commentRSS")); return t; } QString ItemRSS2Impl::commentPostUri() const { return m_item.extractElementTextNS(commentApiNamespace(), QString::fromUtf8("comment")); } Syndication::SpecificItemPtr ItemRSS2Impl::specificItem() const { return Syndication::SpecificItemPtr(new Syndication::RSS2::Item(m_item)); } QMultiMap ItemRSS2Impl::additionalProperties() const { QMultiMap ret; - + foreach (const QDomElement &i, m_item.unhandledElements()) { - ret.insert(i.namespaceURI() + i.localName(), i); + ret.insert(i.namespaceURI() + i.localName(), i); } - + return ret; } } // namespace Syndication