From 2197c188f21d563a192be711d13db7d0d1600681 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 31 Mar 2020 22:26:44 +0200 Subject: QXmppStanza::Error: Add 'by' attribute from RFC6120 This adds parsing and serialization and unit tests for the by attribute for QXmppStanza::Errors. The protocol is defined in RFC6120. --- src/base/QXmppStanza.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/base/QXmppStanza.cpp') diff --git a/src/base/QXmppStanza.cpp b/src/base/QXmppStanza.cpp index c4fae8de..2c2af1d5 100644 --- a/src/base/QXmppStanza.cpp +++ b/src/base/QXmppStanza.cpp @@ -165,6 +165,7 @@ public: QXmppStanza::Error::Type type; QXmppStanza::Error::Condition condition; QString text; + QString by; QString redirectionUri; // XEP-0363: HTTP File Upload @@ -283,6 +284,32 @@ QXmppStanza::Error::Type QXmppStanza::Error::type() const return d->type; } +/// +/// Returns the optional JID of the creator of the error. +/// +/// This is useful to ditinguish between errors generated by the local server +/// and by the remote server for example. However, the value is optional. +/// +/// \since QXmpp 1.3 +/// +QString QXmppStanza::Error::by() const +{ + return d->by; +} + +/// +/// Sets the optional JID of the creator of the error. +/// +/// This is useful to ditinguish between errors generated by the local server +/// and by the remote server for example. However, the value is optional. +/// +/// \since QXmpp 1.3 +/// +void QXmppStanza::Error::setBy(const QString &by) +{ + d->by = by; +} + /// /// Sets the type of the error. /// @@ -424,6 +451,7 @@ void QXmppStanza::Error::parse(const QDomElement &errorElement) { setCode(errorElement.attribute(QStringLiteral("code")).toInt()); setTypeFromStr(errorElement.attribute(QStringLiteral("type"))); + setBy(errorElement.attribute(QStringLiteral("by"))); QDomElement element = errorElement.firstChildElement(); while (!element.isNull()) { @@ -469,6 +497,7 @@ void QXmppStanza::Error::toXml(QXmlStreamWriter *writer) const return; writer->writeStartElement(QStringLiteral("error")); + helperToXmlAddAttribute(writer, QStringLiteral("by"), d->by); helperToXmlAddAttribute(writer, QStringLiteral("type"), type); if (d->code > 0) -- cgit v1.2.3