• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

syndication/rdf

syndicationinfo.cpp
00001 /*
00002  * This file is part of the syndication library
00003  *
00004  * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "syndicationinfo.h"
00024 #include "property.h"
00025 #include "statement.h"
00026 #include "syndicationvocab.h"
00027 
00028 #include <tools.h>
00029 
00030 #include <QtCore/QString>
00031 
00032 namespace Syndication {
00033 namespace RDF {
00034     
00035     SyndicationInfo::SyndicationInfo(ResourcePtr resource) : ResourceWrapper(resource)
00036 {
00037 }
00038 
00039 SyndicationInfo::~SyndicationInfo()
00040 {
00041 }
00042 
00043 SyndicationInfo::Period SyndicationInfo::updatePeriod() const
00044 {
00045     return stringToPeriod(resource()->property(SyndicationVocab::self()->updatePeriod())->asString());
00046 }
00047 
00048 int SyndicationInfo::updateFrequency() const
00049 {
00050     QString freqStr =  resource()->property(SyndicationVocab::self()->updateFrequency())->asString();
00051     
00052     if (freqStr.isEmpty())
00053         return 1; // 1 is default
00054     
00055     bool ok = false;
00056     int freq = freqStr.toInt(&ok);
00057     
00058     if (ok)
00059         return freq;
00060     else
00061         return 1; // 1 is default
00062 }
00063 
00064 time_t SyndicationInfo::updateBase() const
00065 {
00066     QString str =  resource()->property(SyndicationVocab::self()->updateBase())->asString();
00067     
00068     return parseDate(str, ISODate);
00069 }
00070 
00071 QString SyndicationInfo::debugInfo() const
00072 {
00073     QString info;
00074     if (updatePeriod() != Daily)
00075         info += QString("syn:updatePeriod: #%1#\n").arg(periodToString(updatePeriod()));
00076     info += QString("syn:updateFrequency: #%1#\n").arg(QString::number(updateFrequency()));
00077     
00078     QString dbase = dateTimeToString(updateBase());
00079     if (!dbase.isNull())
00080         info += QString("syn:updateBase: #%1#\n").arg(dbase);
00081 
00082     return info;
00083 }
00084 
00085 QString SyndicationInfo::periodToString(Period period)
00086 {
00087     switch (period)
00088     {
00089         case Daily:
00090             return QString::fromUtf8("daily");
00091         case Hourly:
00092             return QString::fromUtf8("hourly");
00093         case Monthly:
00094             return QString::fromUtf8("monthly");
00095         case Weekly:
00096             return QString::fromUtf8("weekly");
00097         case Yearly:
00098             return QString::fromUtf8("yearly");
00099             default: // should never happen
00100             return QString();
00101     }
00102 }
00103 
00104 SyndicationInfo::Period SyndicationInfo::stringToPeriod(const QString& str)
00105 {
00106     if (str.isEmpty())
00107         return Daily; // default is "daily"
00108     
00109     if (str == QString::fromUtf8("hourly"))
00110         return Hourly;
00111     if (str == QString::fromUtf8("monthly"))
00112         return Monthly;
00113     if (str == QString::fromUtf8("weekly"))
00114         return Weekly;
00115     if (str == QString::fromUtf8("yearly"))
00116         return Yearly;
00117 
00118     return Daily;  // default is "daily"
00119 }
00120 
00121 } // namespace RDF
00122 } // namespace Syndication

syndication/rdf

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal