aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppStanza.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2020-03-31 22:26:44 +0200
committerLNJ <lnj@kaidan.im>2020-04-04 23:39:10 +0200
commit2197c188f21d563a192be711d13db7d0d1600681 (patch)
treec47c515a5f7865d2647f993889de755d41a938b7 /src/base/QXmppStanza.cpp
parent318f2a88a31c675dd7c4e2ffccbd28582bc2a0c3 (diff)
downloadqxmpp-2197c188f21d563a192be711d13db7d0d1600681.tar.gz
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.
Diffstat (limited to 'src/base/QXmppStanza.cpp')
-rw-r--r--src/base/QXmppStanza.cpp29
1 files changed, 29 insertions, 0 deletions
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
@@ -284,6 +285,32 @@ QXmppStanza::Error::Type QXmppStanza::Error::type() const
}
///
+/// 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.
///
void QXmppStanza::Error::setType(QXmppStanza::Error::Type type)
@@ -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)