File indexing completed on 2024-04-21 04:00:59

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef SYNDICATION_ATOM_LINK_H
0009 #define SYNDICATION_ATOM_LINK_H
0010 
0011 #include <syndication/elementwrapper.h>
0012 
0013 class QDomElement;
0014 class QString;
0015 
0016 namespace Syndication
0017 {
0018 namespace Atom
0019 {
0020 /**
0021  * A link, pointing to webpages, media files on the web ("podcast"),
0022  * related content, etc. See rel() for details.
0023  *
0024  * @author Frank Osterfeld
0025  */
0026 class SYNDICATION_EXPORT Link : public Syndication::ElementWrapper
0027 {
0028 public:
0029     /**
0030      * creates a null link object.
0031      */
0032     Link();
0033 
0034     /**
0035      * creates a Link object wrapping an atom:link element.
0036      * @param element a DOM element, should be a atom:link element
0037      * (although not enforced), otherwise this object will not parse
0038      * anything useful
0039      */
0040     explicit Link(const QDomElement &element);
0041 
0042     /**
0043      * URL of the referenced resource (required)
0044      */
0045     Q_REQUIRED_RESULT QString href() const;
0046 
0047     /**
0048      * the relation between the feed/entry and the linked resource.
0049      *
0050      * The value of rel() is usually one of the following:
0051      *
0052      * @c "alternate": The URL points to an alternate version of the
0053      * feed/entry. In practice, this is the article described in an entry,
0054      * or the homepage of the feed.
0055      *
0056      * @c "enclosure": The link describes an Enclosure. See
0057      * Syndication::Enclosure for more information.
0058      *
0059      * @c "related": links to web resources with related content. E.g., an
0060      * article discussing KDE might link to the KDE homepage.
0061      *
0062      * @c "self": "identifies a resource equivalent to the containing
0063      * element". This is usually the URL of the feed source itself.
0064      *
0065      * @c "via": The link points to the source of the information contained
0066      * in the feed/entry
0067      *
0068      * @return the rel value specified in the feed. Default value is
0069      * @c "alternate"
0070      */
0071     Q_REQUIRED_RESULT QString rel() const;
0072 
0073     /**
0074      * MIME type of the linked resource. (optional)
0075      *
0076      * @return MIME type following (e.g., "text/html", "audio/mpeg"),
0077      * or a null string if not set
0078      */
0079     Q_REQUIRED_RESULT QString type() const;
0080 
0081     /**
0082      * the language of the linked resource. (optional)
0083      * If used together with a rel() value of "alternate", it
0084      * implies a translated version of the entry.
0085      *
0086      * @return a language tag as defined in RFC 3066,
0087      * or a null string if not specified
0088      */
0089     Q_REQUIRED_RESULT QString hrefLanguage() const;
0090 
0091     /**
0092      * human-readable information about the link. (optional)
0093      *
0094      * @return the link title as plain text ("<", "&" are text, not
0095      * markup!), or a null string if not specified
0096      */
0097     Q_REQUIRED_RESULT QString title() const;
0098 
0099     /**
0100      * size of the linked resource in bytes. (optional)
0101      *
0102      * @return file size in bytes, or 0 if not specified
0103      */
0104     Q_REQUIRED_RESULT uint length() const;
0105 
0106     /**
0107      * description of the link object for debugging purposes
0108      *
0109      * @return debug string
0110      */
0111     Q_REQUIRED_RESULT QString debugInfo() const;
0112 };
0113 
0114 } // namespace Atom
0115 } // namespace Syndication
0116 
0117 #endif // SYNDICATION_ATOM_LINK_H