diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-02-11 10:56:00 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-02-11 16:20:08 +0100 |
| commit | 776f028d9f3f51e9dbba834a01d1decd737c4a27 (patch) | |
| tree | 6ea444c840812d001ea2f259ae50c0aa38c50fdd /src/base/QXmppMessage.cpp | |
| parent | f583f1a71459f413f9f869b8f1616722054dbea8 (diff) | |
Implement XEP-0359: Unique and Stable Stanza IDs
This adds support of XEP-0359: Unique and Stable Stanza IDs in version
0.6.0.
Diffstat (limited to 'src/base/QXmppMessage.cpp')
| -rw-r--r-- | src/base/QXmppMessage.cpp | 96 |
1 files changed, 95 insertions, 1 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index e877e5c1..9084d957 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -141,6 +141,11 @@ public: // XEP-0334: Message Processing Hints quint8 hints; + // XEP-0359: Unique and Stable Stanza IDs + QString stanzaId; + QString stanzaIdBy; + QString originId; + // XEP-0367: Message Attaching QString attachId; @@ -607,6 +612,72 @@ void QXmppMessage::removeAllHints() d->hints = 0; } +/// +/// Returns the stanza ID of the message according to \xep{0359}: Unique and +/// Stable Stanza IDs. +/// +/// \since QXmpp 1.3 +/// +QString QXmppMessage::stanzaId() const +{ + return d->stanzaId; +} + +/// +/// Sets the stanza ID of the message according to \xep{0359}: Unique and +/// Stable Stanza IDs. +/// +/// \since QXmpp 1.3 +/// +void QXmppMessage::setStanzaId(const QString& id) +{ + d->stanzaId = id; +} + +/// +/// Returns the creator of the stanza ID according to \xep{0359}: Unique and +/// Stable Stanza IDs. +/// +/// \since QXmpp 1.3 +/// +QString QXmppMessage::stanzaIdBy() const +{ + return d->stanzaIdBy; +} + +/// +/// Sets the creator of the stanza ID according to \xep{0359}: Unique and +/// Stable Stanza IDs. +/// +/// \since QXmpp 1.3 +/// +void QXmppMessage::setStanzaIdBy(const QString &by) +{ + d->stanzaIdBy = by; +} + +/// +/// Returns the origin ID of the message according to \xep{0359}: Unique and +/// Stable Stanza IDs. +/// +/// \since QXmpp 1.3 +/// +QString QXmppMessage::originId() const +{ + return d->originId; +} + +/// +/// Sets the origin ID of the message according to \xep{0359}: Unique and +/// Stable Stanza IDs. +/// +/// \since QXmpp 1.3 +/// +void QXmppMessage::setOriginId(const QString &id) +{ + d->originId = id; +} + /// Returns the message id this message is linked/attached to. See XEP-0367: /// Message Attaching for details. /// @@ -997,6 +1068,23 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const } } + // XEP-0359: Unique and Stable Stanza IDs + if (!d->stanzaId.isNull()) { + xmlWriter->writeStartElement(QStringLiteral("stanza-id")); + xmlWriter->writeDefaultNamespace(ns_sid); + xmlWriter->writeAttribute(QStringLiteral("id"), d->stanzaId); + if (!d->stanzaIdBy.isNull()) + xmlWriter->writeAttribute(QStringLiteral("by"), d->stanzaIdBy); + xmlWriter->writeEndElement(); + } + + if (!d->originId.isNull()) { + xmlWriter->writeStartElement(QStringLiteral("origin-id")); + xmlWriter->writeDefaultNamespace(ns_sid); + xmlWriter->writeAttribute(QStringLiteral("id"), d->originId); + xmlWriter->writeEndElement(); + } + // XEP-0367: Message Attaching if (!d->attachId.isEmpty()) { xmlWriter->writeStartElement(QStringLiteral("attach-to")); @@ -1117,8 +1205,14 @@ void QXmppMessage::parseExtension(const QDomElement &element, QXmppElementList & } else if (element.namespaceURI() == ns_message_processing_hints && HINT_TYPES.contains(element.tagName())) { addHint(Hint(1 << HINT_TYPES.indexOf(element.tagName()))); - // XEP-0367: Message Attaching + } else if (checkElement(element, QStringLiteral("stanza-id"), ns_sid)) { + // XEP-0359: Unique and Stable Stanza IDs + d->stanzaId = element.attribute(QStringLiteral("id")); + d->stanzaIdBy = element.attribute(QStringLiteral("by")); + } else if (checkElement(element, QStringLiteral("origin-id"), ns_sid)) { + d->originId = element.attribute(QStringLiteral("id")); } else if (checkElement(element, QStringLiteral("attach-to"), ns_message_attaching)) { + // XEP-0367: Message Attaching d->attachId = element.attribute(QStringLiteral("id")); // XEP-0369: Mediated Information eXchange (MIX) } else if (checkElement(element, QStringLiteral("mix"), ns_mix)) { |
