| 1 | /* |
| 2 | This file is part of the syndication library |
| 3 | SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef SYNDICATION_RDF_SYNDICATIONINFO_H |
| 9 | #define SYNDICATION_RDF_SYNDICATIONINFO_H |
| 10 | |
| 11 | #include <syndication/rdf/resourcewrapper.h> |
| 12 | |
| 13 | #include <ctime> |
| 14 | |
| 15 | class QString; |
| 16 | |
| 17 | namespace Syndication |
| 18 | { |
| 19 | namespace RDF |
| 20 | { |
| 21 | /*! |
| 22 | * Wrapper to access syndication information for a feed. |
| 23 | * The RSS 1.0 syndication module provides syndication hints to |
| 24 | * aggregators regarding how often it is updated. |
| 25 | * |
| 26 | * The specification can be found at |
| 27 | * http://web.resource.org/rss/1.0/modules/syndication/ |
| 28 | * |
| 29 | * @author Frank Osterfeld |
| 30 | */ |
| 31 | class SyndicationInfo : public ResourceWrapper |
| 32 | { |
| 33 | public: |
| 34 | /*! |
| 35 | * update period enum as used by updatePeriod(). |
| 36 | */ |
| 37 | enum Period { |
| 38 | Hourly, /*!< the feed is updated hourly */ |
| 39 | Daily, /*!< the feed is updated daily */ |
| 40 | Weekly, /*!< the feed is updated weekly */ |
| 41 | Monthly, /*!< the feed is updated monthly */ |
| 42 | Yearly, /*!< the feed is updated yearly */ |
| 43 | }; |
| 44 | |
| 45 | /*! |
| 46 | * creates a wrapper wrapping a null resource. |
| 47 | * isNull() will be true. |
| 48 | */ |
| 49 | SyndicationInfo(); |
| 50 | |
| 51 | /*! |
| 52 | * creates a wrapper from a resource |
| 53 | * \a resource the feed resource to read syndication |
| 54 | * information from |
| 55 | */ |
| 56 | explicit SyndicationInfo(ResourcePtr resource); |
| 57 | |
| 58 | /*! |
| 59 | * virtual destructor |
| 60 | */ |
| 61 | ~SyndicationInfo() override; |
| 62 | |
| 63 | /*! |
| 64 | * Describes the period over which the channel format is updated. |
| 65 | * Acceptable values are: hourly, daily, weekly, monthly, yearly. |
| 66 | * If omitted, daily is assumed. |
| 67 | * |
| 68 | * @return update period, daily is default |
| 69 | */ |
| 70 | Period updatePeriod() const; |
| 71 | |
| 72 | /*! Used to describe the frequency of updates in relation to the |
| 73 | * update period. A positive integer indicates how many times in |
| 74 | * that period the channel is updated. For example, an |
| 75 | * updatePeriod of daily, and an updateFrequency of 2 indicates |
| 76 | * the channel format is updated twice daily. If omitted a value |
| 77 | * of 1 is assumed. |
| 78 | * |
| 79 | * @return update frequency, default is 1 |
| 80 | */ |
| 81 | int updateFrequency() const; |
| 82 | |
| 83 | /*! |
| 84 | * Defines a base date to be used in concert with updatePeriod |
| 85 | * and updateFrequency to calculate the publishing schedule. |
| 86 | * |
| 87 | * @return the base date in seconds since epoch. Default value is |
| 88 | * 0 (epoch). |
| 89 | */ |
| 90 | time_t updateBase() const; |
| 91 | |
| 92 | /*! |
| 93 | * description of the syndication information |
| 94 | * for debugging purposes |
| 95 | * |
| 96 | * @return debug string |
| 97 | */ |
| 98 | QString debugInfo() const; |
| 99 | |
| 100 | protected: |
| 101 | /*! |
| 102 | * returns Period value as string. |
| 103 | * \a period period enum to convert to a string |
| 104 | * @return the enum name in lower case, "daily", "hourly", etc. |
| 105 | */ |
| 106 | static QString periodToString(Period period); |
| 107 | |
| 108 | /*! |
| 109 | * parses a Period value from a string. |
| 110 | * |
| 111 | * \a str a period string as defined in the syndication module |
| 112 | * @return the parsed period, Daily (the default) if the parsed |
| 113 | * string is empty or invalid |
| 114 | */ |
| 115 | static Period stringToPeriod(const QString &str); |
| 116 | }; |
| 117 | |
| 118 | } // namespace RDF |
| 119 | } // namespace Syndication |
| 120 | |
| 121 | #endif // SYNDICATION_RDF_SYNDICATIONINFO_H |
| 122 | |