Syndication

itemrdfimpl.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
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 
29 namespace Syndication
30 {
31 ItemRDFImpl::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 {
58  QList<PersonPtr> list;
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 
97 {
98  // return empty list
100 }
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 
135 Syndication::SpecificItemPtr ItemRDFImpl::specificItem() const
136 {
137  return Syndication::SpecificItemPtr(new Syndication::RDF::Item(m_item));
138 }
139 
141 {
143 }
144 
145 } // namespace Syndication
void append(const T &value)
QList< CategoryPtr > categories() const override
returns a list of categories this item is filed in.
Definition: feed.h:20
int commentsCount() const override
The number of comments posted for this item.
a property is node type that represents properties of things, like "name" is a property of a person,...
Definition: property.h:31
QString commentApiNamespace()
wellformedweb.org's RSS namespace for comment functionality "http://wellformedweb....
Definition: constants.cpp:39
QList< EnclosurePtr > enclosures() const override
returns a list of enclosures describing files available on the net.
Definition: itemrdfimpl.cpp:96
QString commentsFeed() const override
URL of feed syndicating comments belonging to this item.
QString language() const override
returns the language used in the item's content
Definition: itemrdfimpl.cpp:72
time_t dateUpdated() const override
returns the date when the item was modified the last time.
Definition: itemrdfimpl.cpp:91
QList< PersonPtr > authors() const override
returns a list of persons who created the item content.
Definition: itemrdfimpl.cpp:56
QString commentsLink() const override
Link to an HTML site which contains the comments belonging to this item.
QString title() const override
The title of the item.
Definition: itemrdfimpl.cpp:36
QString link() const override
returns a link to the (web) resource described by this item.
Definition: itemrdfimpl.cpp:41
QString id() const override
returns an identifier that identifies the item within its feed.
Definition: itemrdfimpl.cpp:77
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of item metadata not covered by this class.
QString content() const override
returns the content of the item.
Definition: itemrdfimpl.cpp:51
QString slashNamespace()
"slash" namespace http://purl.org/rss/1.0/modules/slash/
Definition: constants.cpp:44
int toInt(bool *ok, int base) const const
QString commentPostUri() const override
URI that can be used to post comments via an HTTP POST request using the Comment API.
SpecificItemPtr specificItem() const override
returns the format-specific item this object abstracts from.
QString description() const override
returns the description of the item.
Definition: itemrdfimpl.cpp:46
time_t datePublished() const override
returns the date when the item was initially published.
Definition: itemrdfimpl.cpp:86
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Nov 30 2023 03:51:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.