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  QStringList people = m_item.dc().creators();
61  people += m_item.dc().contributors();
63  QStringList::ConstIterator end = people.constEnd();
64 
65  for (; it != end; ++it) {
66  PersonPtr ptr = personFromString(*it);
67  if (!ptr->isNull()) {
68  list.append(ptr);
69  }
70  }
71 
72  return list;
73 }
74 
76 {
77  return m_item.dc().language();
78 }
79 
81 {
82  if (!m_item.resource()->isAnon()) {
83  return m_item.resource()->uri();
84  } else {
85  return QLatin1String("hash:") + calcMD5Sum(title() + description() + link() + content());
86  }
87 }
88 
90 {
91  return m_item.dc().date();
92 }
93 
95 {
96  return m_item.dc().date();
97 }
98 
100 {
101  // return empty list
103 }
104 
106 {
107  // return empty list
109 }
110 
112 {
113  PropertyPtr prop(new Property(slashNamespace() + QLatin1String("comments")));
114  QString cstr = m_item.resource()->property(prop)->asString();
115  bool ok = false;
116  int comments = cstr.toInt(&ok);
117  return ok ? comments : -1;
118  return -1;
119 }
120 
122 {
123  return QString();
124 }
125 
127 {
128  PropertyPtr prop(new Property(commentApiNamespace() + QLatin1String("commentRss")));
129  return m_item.resource()->property(prop)->asString();
130 }
131 
133 {
134  PropertyPtr prop(new Property(commentApiNamespace() + QLatin1String("comment")));
135  return m_item.resource()->property(prop)->asString();
136 }
137 
138 Syndication::SpecificItemPtr ItemRDFImpl::specificItem() const
139 {
140  return Syndication::SpecificItemPtr(new Syndication::RDF::Item(m_item));
141 }
142 
144 {
146 }
147 
148 } // namespace Syndication
QString link() const override
returns a link to the (web) resource described by this item.
a property is node type that represents properties of things, like "name" is a property of a person...
Definition: property.h:31
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of item metadata not covered by this class.
int commentsCount() const override
The number of comments posted for this item.
QString description() const override
returns the description of the item.
Definition: itemrdfimpl.cpp:46
QString link() const override
returns a link to the (web) resource described by this item.
Definition: itemrdfimpl.cpp:41
QString title() const override
The title of the item.
Definition: itemrdfimpl.cpp:36
void append(const T &value)
QString slashNamespace()
"slash" namespace http://purl.org/rss/1.0/modules/slash/
Definition: constants.cpp:44
QList< EnclosurePtr > enclosures() const override
returns a list of enclosures describing files available on the net.
Definition: itemrdfimpl.cpp:99
int toInt(bool *ok, int base) const const
QList< CategoryPtr > categories() const override
returns a list of categories this item is filed in.
SpecificItemPtr specificItem() const override
returns the format-specific item this object abstracts from.
QString content() const override
returns the content of the item.
Definition: itemrdfimpl.cpp:51
QString title() const override
The title of the item.
QString commentsFeed() const override
URL of feed syndicating comments belonging to this item.
QList< PersonPtr > authors() const override
returns a list of persons who created the item content.
Definition: itemrdfimpl.cpp:56
QString description() const override
returns the description of the item.
QString id() const override
returns an identifier that identifies the item within its feed.
Definition: itemrdfimpl.cpp:80
QString content() const override
returns the content of the item.
QString commentApiNamespace()
wellformedweb.org&#39;s RSS namespace for comment functionality "http://wellformedweb.org/CommentAPI/"
Definition: constants.cpp:39
QString commentPostUri() const override
URI that can be used to post comments via an HTTP POST request using the Comment API.
typedef ConstIterator
An RSS 1.0 item.
Definition: rdf/item.h:34
QList::const_iterator constEnd() const const
Definition: feed.h:20
QList::const_iterator constBegin() const const
time_t dateUpdated() const override
returns the date when the item was modified the last time.
Definition: itemrdfimpl.cpp:94
QString language() const override
returns the language used in the item&#39;s content
Definition: itemrdfimpl.cpp:75
time_t datePublished() const override
returns the date when the item was initially published.
Definition: itemrdfimpl.cpp:89
QString commentsLink() const override
Link to an HTML site which contains the comments belonging to this item.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:54:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.