aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppMessage.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-04-27 21:37:31 +0100
committerLNJ <lnj@kaidan.im>2019-09-06 18:04:40 +0200
commit8ab56c2cf1ff490b78def3f9799d4b8a99965d47 (patch)
tree3b363feee85fd10a59b684c3e9067f1f1cde3eb4 /src/base/QXmppMessage.cpp
parent499b6567a9b3f9838a0d0f082d8baabd05414ff9 (diff)
downloadqxmpp-8ab56c2cf1ff490b78def3f9799d4b8a99965d47.tar.gz
Implement XEP-0367: Message Attaching
This adds parsing and serialization for XEP-0367: Message Attaching in version 0.3.0.
Diffstat (limited to 'src/base/QXmppMessage.cpp')
-rw-r--r--src/base/QXmppMessage.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp
index dae2308b..af4b2a6f 100644
--- a/src/base/QXmppMessage.cpp
+++ b/src/base/QXmppMessage.cpp
@@ -103,6 +103,9 @@ public:
// XEP-0308: Last Message Correction
QString replaceId;
+ // XEP-0367: Message Attaching
+ QString attachId;
+
// XEP-0369: Mediated Information eXchange (MIX)
QString mixUserJid;
QString mixUserNick;
@@ -521,6 +524,25 @@ void QXmppMessage::setReplaceId(const QString &replaceId)
d->replaceId = replaceId;
}
+/// Returns the message id this message is linked/attached to. See XEP-0367:
+/// Message Attaching for details.
+
+QString QXmppMessage::attachId() const
+{
+ return d->attachId;
+}
+
+/// Sets the id of the attached message as in XEP-0367: Message Attaching. This
+/// can be used for a "reply to" or "reaction" function.
+///
+/// The used message id depends on the message context, see the Business rules
+/// section of the XEP for details about when to use which id.
+
+void QXmppMessage::setAttachId(const QString &attachId)
+{
+ d->attachId = attachId;
+}
+
/// Returns the actual JID of a MIX channel participant.
QString QXmppMessage::mixUserJid() const
@@ -736,6 +758,9 @@ void QXmppMessage::parse(const QDomElement &element)
else {
extensions << QXmppElement(xElement);
}
+ // XEP-0367: Message Attaching
+ } else if (xElement.tagName() == "attach-to" && xElement.namespaceURI() == ns_message_attaching) {
+ d->attachId = xElement.attribute("id");
// XEP-0369: Mediated Information eXchange (MIX)
} else if (xElement.tagName() == "mix" && xElement.namespaceURI() == ns_mix) {
d->mixUserJid = xElement.firstChildElement("jid").text();
@@ -881,6 +906,14 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const
xmlWriter->writeEndElement();
}
+ // XEP-0367: Message Attaching
+ if (!d->attachId.isEmpty()) {
+ xmlWriter->writeStartElement("attach-to");
+ xmlWriter->writeAttribute("xmlns", ns_message_attaching);
+ xmlWriter->writeAttribute("id", d->attachId);
+ xmlWriter->writeEndElement();
+ }
+
// XEP-0369: Mediated Information eXchange (MIX)
if (!d->mixUserJid.isEmpty() || !d->mixUserNick.isEmpty()) {
xmlWriter->writeStartElement("mix");