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

syndication/rdf

  • 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
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:26:28 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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
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