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
27using Syndication::RDF::PropertyPtr;
28
29namespace Syndication
30{
31ItemRDFImpl::ItemRDFImpl(const Syndication::RDF::Item &item)
32 : m_item(item)
33{
34}
35
37{
38 return m_item.title();
39}
40
42{
43 return m_item.link();
44}
45
47{
48 return m_item.description();
49}
50
52{
53 return m_item.encodedContent();
54}
55
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
73{
74 return m_item.dc().language();
75}
76
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
87{
88 return m_item.dc().date();
89}
90
92{
93 return m_item.dc().date();
94}
95
101
103{
104 // return empty list
106}
107
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
119{
120 return QString();
121}
122
124{
125 PropertyPtr prop(new Property(commentApiNamespace() + QLatin1String("commentRss")));
126 return m_item.resource()->property(prop)->asString();
127}
128
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
144
145} // namespace Syndication
QString commentsLink() const override
Link to an HTML site which contains the comments belonging to this item.
QList< PersonPtr > authors() const override
returns a list of persons who created the item content.
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of item metadata not covered by this class.
time_t dateUpdated() const override
returns the date when the item was modified the last time.
QString commentsFeed() const override
URL of feed syndicating comments belonging to this item.
SpecificItemPtr specificItem() const override
returns the format-specific item this object abstracts from.
int commentsCount() const override
The number of comments posted for this item.
QString commentPostUri() const override
URI that can be used to post comments via an HTTP POST request using the Comment API.
QString language() const override
returns the language used in the item's content
QString description() const override
returns the description of the item.
time_t datePublished() const override
returns the date when the item was initially published.
QList< CategoryPtr > categories() const override
returns a list of categories this item is filed in.
QString link() const override
returns a link to the (web) resource described by this item.
QList< EnclosurePtr > enclosures() const override
returns a list of enclosures describing files available on the net.
QString title() const override
The title of the item.
QString id() const override
returns an identifier that identifies the item within its feed.
QString content() const override
returns the content of the item.
An RSS 1.0 item.
Definition rdf/item.h:37
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-2025 The KDE developers.
Generated on Thu Jan 23 2025 19:01:16 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.