diff options
| author | Linus Jahn <lnj@kaidan.im> | 2019-04-27 21:37:31 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2019-09-06 18:04:40 +0200 |
| commit | 8ab56c2cf1ff490b78def3f9799d4b8a99965d47 (patch) | |
| tree | 3b363feee85fd10a59b684c3e9067f1f1cde3eb4 /src/base | |
| parent | 499b6567a9b3f9838a0d0f082d8baabd05414ff9 (diff) | |
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')
| -rw-r--r-- | src/base/QXmppConstants.cpp | 2 | ||||
| -rw-r--r-- | src/base/QXmppConstants_p.h | 2 | ||||
| -rw-r--r-- | src/base/QXmppMessage.cpp | 33 | ||||
| -rw-r--r-- | src/base/QXmppMessage.h | 15 |
4 files changed, 45 insertions, 7 deletions
diff --git a/src/base/QXmppConstants.cpp b/src/base/QXmppConstants.cpp index 8c3295d5..05d29f55 100644 --- a/src/base/QXmppConstants.cpp +++ b/src/base/QXmppConstants.cpp @@ -134,6 +134,8 @@ const char* ns_chat_markers = "urn:xmpp:chat-markers:0"; const char* ns_csi = "urn:xmpp:csi:0"; // XEP-0363: HTTP File Upload const char* ns_http_upload = "urn:xmpp:http:upload:0"; +// XEP-0367: Message Attaching +const char* ns_message_attaching = "urn:xmpp:message-attaching:1"; // XEP-0369: Mediated Information eXchange (MIX) const char* ns_mix = "urn:xmpp:mix:core:1"; const char* ns_mix_create_channel = "urn:xmpp:mix:core:1#create-channel"; diff --git a/src/base/QXmppConstants_p.h b/src/base/QXmppConstants_p.h index 35d92247..4f6eca53 100644 --- a/src/base/QXmppConstants_p.h +++ b/src/base/QXmppConstants_p.h @@ -146,6 +146,8 @@ extern const char* ns_chat_markers; extern const char* ns_csi; // XEP-0363: HTTP File Upload extern const char* ns_http_upload; +// XEP-0367: Message Attaching +extern const char* ns_message_attaching; // XEP-0369: Mediated Information eXchange (MIX) extern const char* ns_mix; extern const char* ns_mix_create_channel; 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"); diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h index 0101e211..330c70fe 100644 --- a/src/base/QXmppMessage.h +++ b/src/base/QXmppMessage.h @@ -21,7 +21,6 @@ * */ - #ifndef QXMPPMESSAGE_H #define QXMPPMESSAGE_H @@ -33,7 +32,6 @@ class QXmppMessagePrivate; /// \brief The QXmppMessage class represents an XMPP message. /// /// \ingroup Stanzas -/// class QXMPP_EXPORT QXmppMessage : public QXmppStanza { @@ -48,8 +46,8 @@ public: Headline }; - /// This enum describes a chat state as defined by - /// XEP-0085 : Chat State Notifications. + /// This enum describes a chat state as defined by XEP-0085: Chat State + /// Notifications. enum State { None = 0, ///< The message does not contain any chat state information. @@ -60,8 +58,7 @@ public: Paused ///< User had been composing but now has stopped. }; - /// This enum describes a chat marker as defined by - /// XEP-0333 : Char Markers + /// This enum describes a chat marker as defined by XEP-0333: Chat Markers. enum Marker { NoMarker = 0, Received, @@ -116,7 +113,7 @@ public: QString xhtml() const; void setXhtml(const QString &xhtml); - // XEP-0333 + // XEP-0333: Chat Markers bool isMarkable() const; void setMarkable(const bool); @@ -143,6 +140,10 @@ public: QString replaceId() const; void setReplaceId(const QString&); + // XEP-0367: Message Attaching + QString attachId() const; + void setAttachId(const QString&); + // XEP-0369: Mediated Information eXchange (MIX) QString mixUserJid() const; void setMixUserJid(const QString&); |
