| 1 | /* |
| 2 | This file is part of the syndication library |
| 3 | SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #include "enclosure.h" |
| 9 | |
| 10 | namespace Syndication |
| 11 | { |
| 12 | namespace RSS2 |
| 13 | { |
| 14 | Enclosure::() |
| 15 | : ElementWrapper() |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | Enclosure::(const QDomElement &element) |
| 20 | : ElementWrapper(element) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | QString Enclosure::() const |
| 25 | { |
| 26 | return attribute(QStringLiteral("url" )); |
| 27 | } |
| 28 | |
| 29 | int Enclosure::() const |
| 30 | { |
| 31 | int length = 0; |
| 32 | |
| 33 | if (hasAttribute(QStringLiteral("length" ))) { |
| 34 | bool ok; |
| 35 | int c = attribute(QStringLiteral("length" )).toInt(ok: &ok); |
| 36 | length = ok ? c : 0; |
| 37 | } |
| 38 | return length; |
| 39 | } |
| 40 | |
| 41 | QString Enclosure::() const |
| 42 | { |
| 43 | return attribute(QStringLiteral("type" )); |
| 44 | } |
| 45 | |
| 46 | QString Enclosure::() const |
| 47 | { |
| 48 | QString info = QLatin1String("### Enclosure: ###################\n" ); |
| 49 | if (!url().isNull()) { |
| 50 | info += QLatin1String("url: #" ) + url() + QLatin1String("#\n" ); |
| 51 | } |
| 52 | if (!type().isNull()) { |
| 53 | info += QLatin1String("type: #" ) + type() + QLatin1String("#\n" ); |
| 54 | } |
| 55 | if (length() != -1) { |
| 56 | info += QLatin1String("length: #" ) + QString::number(length()) + QLatin1String("#\n" ); |
| 57 | } |
| 58 | info += QLatin1String("### Enclosure end ################\n" ); |
| 59 | return info; |
| 60 | } |
| 61 | |
| 62 | } // namespace RSS2 |
| 63 | } // namespace Syndication |
| 64 | |