Syndication

itemrdfimpl.cpp
1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#include "itemrdfimpl.h"
9
10#include <category.h>
11#include <constants.h>
12#include <enclosure.h>
13#include <personimpl.h>
14#include <rdf/dublincore.h>
15#include <rdf/property.h>
16#include <rdf/resource.h>
17#include <rdf/resourcewrapper.h>
18#include <rdf/statement.h>
19#include <tools.h>
20
21#include <QDomElement>
22#include <QList>
23#include <QMultiMap>
24#include <QStringList>
25
28
29namespace Syndication
30{
31ItemRDFImpl::ItemRDFImpl(const Syndication::RDF::Item &item)
32 : m_item(item)
33{
34}
35
36QString ItemRDFImpl::title() const
37{
38 return m_item.title();
39}
40
41QString ItemRDFImpl::link() const
42{
43 return m_item.link();
44}
45
46QString ItemRDFImpl::description() const
47{
48 return m_item.description();
49}
50
51QString ItemRDFImpl::content() const
52{
53 return m_item.encodedContent();
54}
55
56QList<PersonPtr> ItemRDFImpl::authors() const
57{
59
60 const QStringList people = m_item.dc().creators() + m_item.dc().contributors();
61
62 for (const auto &person : people) {
63 PersonPtr ptr = personFromString(person);
64 if (!ptr->isNull()) {
65 list.append(ptr);
66 }
67 }
68
69 return list;
70}
71
72QString ItemRDFImpl::language() const
73{
74 return m_item.dc().language();
75}
76
77QString ItemRDFImpl::id() const
78{
79 if (!m_item.resource()->isAnon()) {
80 return m_item.resource()->uri();
81 } else {
82 return QLatin1String("hash:") + calcMD5Sum(title() + description() + link() + content());
83 }
84}
85
86time_t ItemRDFImpl::datePublished() const
87{
88 return m_item.dc().date();
89}
90
91time_t ItemRDFImpl::dateUpdated() const
92{
93 return m_item.dc().date();
94}
95
96QList<Syndication::EnclosurePtr> ItemRDFImpl::enclosures() const
97{
98 // return empty list
100}
101
102QList<Syndication::CategoryPtr> ItemRDFImpl::categories() const
103{
104 // return empty list
106}
107
108int ItemRDFImpl::commentsCount() const
109{
110 PropertyPtr prop(new Property(slashNamespace() + QLatin1String("comments")));
111 QString cstr = m_item.resource()->property(prop)->asString();
112 bool ok = false;
113 int comments = cstr.toInt(&ok);
114 return ok ? comments : -1;
115 return -1;
116}
117
118QString ItemRDFImpl::commentsLink() const
119{
120 return QString();
121}
122
123QString ItemRDFImpl::commentsFeed() const
124{
125 PropertyPtr prop(new Property(commentApiNamespace() + QLatin1String("commentRss")));
126 return m_item.resource()->property(prop)->asString();
127}
128
129QString ItemRDFImpl::commentPostUri() const
130{
131 PropertyPtr prop(new Property(commentApiNamespace() + QLatin1String("comment")));
132 return m_item.resource()->property(prop)->asString();
133}
134
135Syndication::SpecificItemPtr ItemRDFImpl::specificItem() const
136{
137 return Syndication::SpecificItemPtr(new Syndication::RDF::Item(m_item));
138}
139
140QMultiMap<QString, QDomElement> ItemRDFImpl::additionalProperties() const
141{
143}
144
145} // namespace Syndication
a property is node type that represents properties of things, like "name" is a property of a person,...
Definition property.h:32
QString slashNamespace()
"slash" namespace http://purl.org/rss/1.0/modules/slash/
Definition constants.cpp:44
QString commentApiNamespace()
wellformedweb.org's RSS namespace for comment functionality "http://wellformedweb....
Definition constants.cpp:39
void append(QList< T > &&value)
int toInt(bool *ok, int base) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Apr 27 2024 22:07:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.