File indexing completed on 2023-12-03 07:51:58

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "enclosure.h"
0009 
0010 namespace Syndication
0011 {
0012 namespace RSS2
0013 {
0014 Enclosure::Enclosure()
0015     : ElementWrapper()
0016 {
0017 }
0018 
0019 Enclosure::Enclosure(const QDomElement &element)
0020     : ElementWrapper(element)
0021 {
0022 }
0023 
0024 QString Enclosure::url() const
0025 {
0026     return attribute(QStringLiteral("url"));
0027 }
0028 
0029 int Enclosure::length() const
0030 {
0031     int length = 0;
0032 
0033     if (hasAttribute(QStringLiteral("length"))) {
0034         bool ok;
0035         int c = attribute(QStringLiteral("length")).toInt(&ok);
0036         length = ok ? c : 0;
0037     }
0038     return length;
0039 }
0040 
0041 QString Enclosure::type() const
0042 {
0043     return attribute(QStringLiteral("type"));
0044 }
0045 
0046 QString Enclosure::debugInfo() const
0047 {
0048     QString info = QLatin1String("### Enclosure: ###################\n");
0049     if (!url().isNull()) {
0050         info += QLatin1String("url: #") + url() + QLatin1String("#\n");
0051     }
0052     if (!type().isNull()) {
0053         info += QLatin1String("type: #") + type() + QLatin1String("#\n");
0054     }
0055     if (length() != -1) {
0056         info += QLatin1String("length: #") + QString::number(length()) + QLatin1String("#\n");
0057     }
0058     info += QLatin1String("### Enclosure end ################\n");
0059     return info;
0060 }
0061 
0062 } // namespace RSS2
0063 } // namespace Syndication