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

syndication/rdf

  • sources
  • kde-4.14
  • kdepimlibs
  • syndication
  • rdf
syndicationinfo.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 "syndicationinfo.h"
24 #include "property.h"
25 #include "statement.h"
26 #include "syndicationvocab.h"
27 
28 #include <tools.h>
29 
30 #include <QtCore/QString>
31 
32 namespace Syndication {
33 namespace RDF {
34 
35  SyndicationInfo::SyndicationInfo(ResourcePtr resource) : ResourceWrapper(resource)
36 {
37 }
38 
39 SyndicationInfo::~SyndicationInfo()
40 {
41 }
42 
43 SyndicationInfo::Period SyndicationInfo::updatePeriod() const
44 {
45  return stringToPeriod(resource()->property(SyndicationVocab::self()->updatePeriod())->asString());
46 }
47 
48 int SyndicationInfo::updateFrequency() const
49 {
50  QString freqStr = resource()->property(SyndicationVocab::self()->updateFrequency())->asString();
51 
52  if (freqStr.isEmpty())
53  return 1; // 1 is default
54 
55  bool ok = false;
56  int freq = freqStr.toInt(&ok);
57 
58  if (ok)
59  return freq;
60  else
61  return 1; // 1 is default
62 }
63 
64 time_t SyndicationInfo::updateBase() const
65 {
66  QString str = resource()->property(SyndicationVocab::self()->updateBase())->asString();
67 
68  return parseDate(str, ISODate);
69 }
70 
71 QString SyndicationInfo::debugInfo() const
72 {
73  QString info;
74  if (updatePeriod() != Daily)
75  info += QString::fromLatin1("syn:updatePeriod: #%1#\n").arg(periodToString(updatePeriod()));
76  info += QString::fromLatin1("syn:updateFrequency: #%1#\n").arg(QString::number(updateFrequency()));
77 
78  QString dbase = dateTimeToString(updateBase());
79  if (!dbase.isNull())
80  info += QString::fromLatin1("syn:updateBase: #%1#\n").arg(dbase);
81 
82  return info;
83 }
84 
85 QString SyndicationInfo::periodToString(Period period)
86 {
87  switch (period)
88  {
89  case Daily:
90  return QLatin1String("daily");
91  case Hourly:
92  return QLatin1String("hourly");
93  case Monthly:
94  return QLatin1String("monthly");
95  case Weekly:
96  return QLatin1String("weekly");
97  case Yearly:
98  return QLatin1String("yearly");
99  default: // should never happen
100  return QString();
101  }
102 }
103 
104 SyndicationInfo::Period SyndicationInfo::stringToPeriod(const QString& str)
105 {
106  if (str.isEmpty())
107  return Daily; // default is "daily"
108 
109  if (str == QLatin1String("hourly"))
110  return Hourly;
111  if (str == QLatin1String("monthly"))
112  return Monthly;
113  if (str == QLatin1String("weekly"))
114  return Weekly;
115  if (str == QLatin1String("yearly"))
116  return Yearly;
117 
118  return Daily; // default is "daily"
119 }
120 
121 } // namespace RDF
122 } // namespace Syndication
Syndication::RDF::SyndicationInfo::Period
Period
update period enum as used by updatePeriod().
Definition: syndicationinfo.h:51
Syndication::RDF::SyndicationInfo::Yearly
the feed is updated yearly
Definition: syndicationinfo.h:57
Syndication::RDF::SyndicationInfo::updateFrequency
int updateFrequency() const
Used to describe the frequency of updates in relation to the update period.
Definition: syndicationinfo.cpp:48
Syndication::RDF::SyndicationInfo::debugInfo
QString debugInfo() const
description of the syndication information for debugging purposes
Definition: syndicationinfo.cpp:71
Syndication::RDF::SyndicationInfo::periodToString
static QString periodToString(Period period)
returns Period value as string.
Definition: syndicationinfo.cpp:85
Syndication::RDF::SyndicationInfo::Weekly
the feed is updated weekly
Definition: syndicationinfo.h:55
Syndication::RDF::SyndicationInfo::stringToPeriod
static Period stringToPeriod(const QString &str)
parses a Period value from a string.
Definition: syndicationinfo.cpp:104
Syndication::RDF::SyndicationInfo::Daily
the feed is updated daily
Definition: syndicationinfo.h:54
QString::isNull
bool isNull() const
Syndication::RDF::SyndicationInfo::~SyndicationInfo
virtual ~SyndicationInfo()
virtual destructor
Definition: syndicationinfo.cpp:39
QString::number
QString number(int n, int base)
Syndication::RDF::SyndicationInfo::Monthly
the feed is updated monthly
Definition: syndicationinfo.h:56
QString::toInt
int toInt(bool *ok, int base) const
QString::isEmpty
bool isEmpty() const
Syndication::RDF::SyndicationInfo::Hourly
the feed is updated hourly
Definition: syndicationinfo.h:53
QString
Syndication::RDF::SyndicationInfo::updateBase
time_t updateBase() const
Defines a base date to be used in concert with updatePeriod and updateFrequency to calculate the publ...
Definition: syndicationinfo.cpp:64
Syndication::RDF::SyndicationInfo::SyndicationInfo
SyndicationInfo()
creates a wrapper wrapping a null resource.
QLatin1String
Syndication::RDF::SyndicationInfo::updatePeriod
Period updatePeriod() const
Describes the period over which the channel format is updated.
Definition: syndicationinfo.cpp:43
Syndication::RDF::ResourceWrapper::resource
ResourcePtr resource() const
returns the wrapped resource.
Definition: resourcewrapper.cpp:75
Syndication::RDF::SyndicationVocab::self
static SyndicationVocab * self()
returns the singleton instance
Definition: syndicationvocab.cpp:67
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Syndication::RDF::ResourceWrapper
A wrapper for RDF resources.
Definition: resourcewrapper.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

syndication/rdf

Skip menu "syndication/rdf"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • 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