• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

syndication/atom

  • sources
  • kde-4.14
  • kdepimlibs
  • syndication
  • atom
source.cpp
1 /*
2  * This file is part of the syndication library
3  *
4  * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "source.h"
24 #include "category.h"
25 #include "constants.h"
26 #include "generator.h"
27 #include "link.h"
28 #include "person.h"
29 #include "atomtools.h"
30 
31 #include <tools.h>
32 
33 #include <QtXml/QDomElement>
34 #include <QtCore/QList>
35 #include <QtCore/QString>
36 
37 namespace Syndication {
38 namespace Atom {
39 
40 Source::Source() : ElementWrapper()
41 {
42 }
43 
44 Source::Source(const QDomElement& element) : ElementWrapper(element)
45 {
46 }
47 
48 QList<Person> Source::authors() const
49 {
50  QList<QDomElement> a =
51  elementsByTagNameNS(atom1Namespace(),
52  QLatin1String("author"));
53  QList<Person> list;
54 
55  QList<QDomElement>::ConstIterator it = a.constBegin();
56  QList<QDomElement>::ConstIterator end = a.constEnd();
57 
58 
59  for ( ; it != end; ++it)
60  {
61  list.append(Person(*it));
62  }
63 
64  return list;
65 }
66 
67 QList<Person> Source::contributors() const
68 {
69  QList<QDomElement> a =
70  elementsByTagNameNS(atom1Namespace(),
71  QLatin1String("contributor"));
72  QList<Person> list;
73 
74  QList<QDomElement>::ConstIterator it = a.constBegin();
75  QList<QDomElement>::ConstIterator end = a.constEnd();
76 
77 
78  for ( ; it != end; ++it)
79  {
80  list.append(Person(*it));
81  }
82 
83  return list;
84 }
85 
86 QList<Category> Source::categories() const
87 {
88  QList<QDomElement> a =
89  elementsByTagNameNS(atom1Namespace(),
90  QLatin1String("category"));
91  QList<Category> list;
92 
93  QList<QDomElement>::ConstIterator it = a.constBegin();
94  QList<QDomElement>::ConstIterator end = a.constEnd();
95 
96 
97  for ( ; it != end; ++it)
98  {
99  list.append(Category(*it));
100  }
101 
102  return list;
103 }
104 
105 Generator Source::generator() const
106 {
107  return Generator(firstElementByTagNameNS(atom1Namespace(),
108  QLatin1String("generator")));
109 }
110 
111 QString Source::icon() const
112 {
113  return extractElementTextNS(atom1Namespace(),
114  QLatin1String("icon"));
115 }
116 
117 QString Source::id() const
118 {
119  return extractElementTextNS(atom1Namespace(),
120  QLatin1String("id"));
121 }
122 
123 QList<Link> Source::links() const
124 {
125  QList<QDomElement> a =
126  elementsByTagNameNS(atom1Namespace(),
127  QLatin1String("link"));
128  QList<Link> list;
129 
130  QList<QDomElement>::ConstIterator it = a.constBegin();
131  QList<QDomElement>::ConstIterator end = a.constEnd();
132 
133 
134  for ( ; it != end; ++it)
135  {
136  list.append(Link(*it));
137  }
138 
139  return list;
140 }
141 
142 QString Source::logo() const
143 {
144  return extractElementTextNS(atom1Namespace(),
145  QLatin1String("logo"));
146 }
147 
148 QString Source::rights() const
149 {
150  return extractAtomText(*this, QLatin1String("rights"));
151 }
152 
153 QString Source::subtitle() const
154 {
155  return extractAtomText(*this, QLatin1String("subtitle"));
156 }
157 
158 QString Source::title() const
159 {
160  return extractAtomText(*this, QLatin1String("title"));
161 }
162 
163 time_t Source::updated() const
164 {
165  QString upd = extractElementTextNS(atom1Namespace(),
166  QLatin1String("updated"));
167  return parseDate(upd, ISODate);
168 }
169 
170 QString Source::debugInfo() const
171 {
172  QString info;
173  info += QLatin1String("### Source: ###################\n");
174  if (!title().isEmpty())
175  info += QLatin1String("title: #") + title() + QLatin1String("#\n");
176  if (!subtitle().isEmpty())
177  info += QLatin1String("subtitle: #") + subtitle() + QLatin1String("#\n");
178  if (!id().isEmpty())
179  info += QLatin1String("id: #") + id() + QLatin1String("#\n");
180 
181  if (!rights().isEmpty())
182  info += QLatin1String("rights: #") + rights() + QLatin1String("#\n");
183  if (!icon().isEmpty())
184  info += QLatin1String("icon: #") + icon() + QLatin1String("#\n");
185  if (!logo().isEmpty())
186  info += QLatin1String("logo: #") + logo() + QLatin1String("#\n");
187  if (!generator().isNull())
188  info += generator().debugInfo();
189 
190 
191  QString dupdated = dateTimeToString(updated());
192  if (!dupdated.isNull())
193  info += QLatin1String("updated: #") + dupdated + QLatin1String("#\n");
194 
195  QList<Link> dlinks = links();
196  QList<Link>::ConstIterator endlinks = dlinks.constEnd();
197  for (QList<Link>::ConstIterator it = dlinks.constBegin(); it != endlinks; ++it)
198  info += (*it).debugInfo();
199 
200  QList<Category> dcats = categories();
201  QList<Category>::ConstIterator endcats = dcats.constEnd();
202  for (QList<Category>::ConstIterator it = dcats.constBegin(); it != endcats; ++it)
203  info += (*it).debugInfo();
204 
205  info += QLatin1String("### Authors: ###################\n");
206 
207  QList<Person> dauthors = authors();
208  QList<Person>::ConstIterator endauthors = dauthors.constEnd();
209  for (QList<Person>::ConstIterator it = dauthors.constBegin(); it != endauthors; ++it)
210  info += (*it).debugInfo();
211 
212  info += QLatin1String("### Contributors: ###################\n");
213 
214  QList<Person> dcontri = contributors();
215  QList<Person>::ConstIterator endcontri = dcontri.constEnd();
216  for (QList<Person>::ConstIterator it = dcontri.constBegin(); it != endcontri; ++it)
217  info += (*it).debugInfo();
218 
219  info += QLatin1String("### Source end ################\n");
220 
221  return info;
222 }
223 
224 } // namespace Atom
225 } //namespace Syndication
Syndication::Atom::Category
A category for categorizing items or whole feeds.
Definition: category.h:45
Syndication::Atom::Link
A link, pointing to webpages, media files on the web ("podcast"), related content, etc.
Definition: link.h:39
Syndication::Atom::Generator
Description of the agent used to generate the feed.
Definition: generator.h:39
Syndication::Atom::Source::updated
time_t updated() const
The datetime of the last modification of the source feed content.
Definition: source.cpp:163
Syndication::Atom::Source::links
QList< Link > links() const
a list of links.
Definition: source.cpp:123
Syndication::Atom::Source::contributors
QList< Person > contributors() const
contributors to the original content (optional)
Definition: source.cpp:67
Syndication::Atom::Source::subtitle
QString subtitle() const
description or subtitle of the source feed (optional).
Definition: source.cpp:153
Syndication::Atom::Generator::debugInfo
QString debugInfo() const
a description of this generator for debugging purposes.
Definition: generator.cpp:54
Syndication::Atom::Source::logo
QString logo() const
URL of an image, the logo of the source feed (optional)
Definition: source.cpp:142
Syndication::Atom::Source::icon
QString icon() const
URL of an image serving as a feed icon (optional)
Definition: source.cpp:111
Syndication::Atom::Source::id
QString id() const
a string that unambigously identifies the source feed (optional)
Definition: source.cpp:117
Syndication::Atom::Source::title
QString title() const
source feed title (optional).
Definition: source.cpp:158
QString::isNull
bool isNull() const
Syndication::Atom::atom1Namespace
QString atom1Namespace()
namespace used by Atom 1.0 elements
Definition: constants.cpp:30
QList::append
void append(const T &value)
Syndication::Atom::Source::generator
Generator generator() const
description of the software which generated the source feed (optional)
Definition: source.cpp:105
QString
QList
Definition: document.h:31
Syndication::Atom::Source::categories
QList< Category > categories() const
categories the source feed is assigned to (optional)
Definition: source.cpp:86
Syndication::Atom::extractAtomText
QString extractAtomText(const Syndication::ElementWrapper &parent, const QString &tagname)
extracts the content of an atomTextConstruct.
Definition: atomtools.cpp:35
Syndication::Atom::Source::Source
Source()
creates a null source object
Definition: source.cpp:40
QLatin1String
Syndication::Atom::Source::authors
QList< Person > authors() const
authors of the original content (optional)
Definition: source.cpp:48
Syndication::Atom::Person
describes a person, with name and optional URI and e-mail address.
Definition: person.h:40
Syndication::Atom::Source::debugInfo
QString debugInfo() const
description of this source object for debugging purposes
Definition: source.cpp:170
QList::constEnd
const_iterator constEnd() const
QList::constBegin
const_iterator constBegin() const
QDomElement
Syndication::Atom::Source::rights
QString rights() const
copyright information (optional)
Definition: source.cpp:148
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:35 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

syndication/atom

Skip menu "syndication/atom"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal