blob: d986ae11df6bc202184d1e58a80889c6e50acd67 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// SPDX-FileCopyrightText: 2022 Jonah Brüchert <jbb@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#include "QXmppOutOfBandUrl.h"
#include "QXmppConstants_p.h"
#include <QDomElement>
#include <QXmlStreamWriter>
class QXmppOutOfBandUrlPrivate : public QSharedData
{
public:
QString url;
std::optional<QString> description;
};
///
/// \class QXmppOutOfBandUrl
///
/// A URL and a description of its contents, from \xep{0066}: Out of Band Data
///
/// \since QXmpp 1.5
///
QXmppOutOfBandUrl::QXmppOutOfBandUrl()
: d(new QXmppOutOfBandUrlPrivate())
{
}
QXMPP_PRIVATE_DEFINE_RULE_OF_SIX(QXmppOutOfBandUrl);
///
/// Returns the attached URL
///
const QString &QXmppOutOfBandUrl::url() const
{
return d->url;
}
///
/// Sets the attached URL
///
void QXmppOutOfBandUrl::setUrl(const QString &url)
{
d->url = url;
}
///
/// Returns the description of the URL
///
const std::optional<QString> &QXmppOutOfBandUrl::description() const
{
return d->description;
}
///
/// Set the description of the URL
///
void QXmppOutOfBandUrl::setDescription(const std::optional<QString> &description)
{
d->description = description;
}
/// \cond
bool QXmppOutOfBandUrl::parse(const QDomElement &el)
{
d->url = el.firstChildElement(QStringLiteral("url")).text();
auto childEl = el.firstChildElement(QStringLiteral("desc"));
if (!childEl.isNull()) {
d->description = childEl.text();
}
return true;
}
void QXmppOutOfBandUrl::toXml(QXmlStreamWriter *writer) const
{
writer->writeStartElement(QStringLiteral("x"));
writer->writeDefaultNamespace(ns_oob);
writer->writeTextElement(QStringLiteral("url"), d->url);
if (d->description) {
writer->writeTextElement(QStringLiteral("desc"), *d->description);
}
writer->writeEndElement();
}
/// \endcond
|