diff options
| author | Linus Jahn <lnj@kaidan.im> | 2018-12-29 23:54:06 +0100 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2018-12-30 13:50:27 +0100 |
| commit | 1d838fb55fc7f4be8c96f8a02dfa9d1a82af2c05 (patch) | |
| tree | c7ee7fb6957a724728d4db8b2aa601da32ce743e /src/base | |
| parent | fc389736df1107245ca91ecbe0bca0526a42288a (diff) | |
Implement XEP-0308: Last Message Correction
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 | 34 | ||||
| -rw-r--r-- | src/base/QXmppMessage.h | 4 |
4 files changed, 42 insertions, 0 deletions
diff --git a/src/base/QXmppConstants.cpp b/src/base/QXmppConstants.cpp index 03260018..3254dd61 100644 --- a/src/base/QXmppConstants.cpp +++ b/src/base/QXmppConstants.cpp @@ -122,6 +122,8 @@ const char* ns_conference = "jabber:x:conference"; const char* ns_carbons = "urn:xmpp:carbons:2"; // XEP-0297: Stanza Forwarding const char* ns_forwarding = "urn:xmpp:forward:0"; +// XEP-0308: Last Message Correction +const char* ns_message_correct = "urn:xmpp:message-correct:0"; // XEP-0313: Message Archive Management const char* ns_mam = "urn:xmpp:mam:1"; // XEP-0333: Chat Markers diff --git a/src/base/QXmppConstants_p.h b/src/base/QXmppConstants_p.h index 8846145c..17495b33 100644 --- a/src/base/QXmppConstants_p.h +++ b/src/base/QXmppConstants_p.h @@ -134,6 +134,8 @@ extern const char* ns_conference; extern const char* ns_carbons; // XEP-0297: Stanza Forwarding extern const char* ns_forwarding; +// XEP-0308: Last Message Correction +extern const char* ns_message_correct; // XEP-0313: Message Archive Management extern const char* ns_mam; // XEP-0333: Char Markers diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index 3c62bd42..24a5d4eb 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -99,6 +99,9 @@ public: // XEP-0066: Out of Band Data QString outOfBandUrl; + + // XEP-0308: Last Message Correction + QString replaceId; }; /// Constructs a QXmppMessage. @@ -377,6 +380,7 @@ namespace << qMakePair(QString("thread"), QString()) << qMakePair(QString("html"), QString()) << qMakePair(QString("received"), QString(ns_message_receipts)) + << qMakePair(QString("replace"), QString(ns_message_correct)) << qMakePair(QString("request"), QString()) << qMakePair(QString("delay"), QString()) << qMakePair(QString("attention"), QString()) @@ -492,6 +496,23 @@ void QXmppMessage::setOutOfBandUrl(const QString &url) d->outOfBandUrl = url; } +/// Returns the message id to replace with this message as used in XEP-0308: +/// Last Message Correction. If the returned string is empty, this message is +/// not replacing another. + +QString QXmppMessage::replaceId() const +{ + return d->replaceId; +} + +/// Sets the message id to replace with this message as in XEP-0308: Last +/// Message Correction. + +void QXmppMessage::setReplaceId(const QString &replaceId) +{ + d->replaceId = replaceId; +} + /// \cond void QXmppMessage::parse(const QDomElement &element) { @@ -597,6 +618,11 @@ void QXmppMessage::parse(const QDomElement &element) if (!privateElement.isNull()) d->privatemsg = true; + // XEP-0308: Last Message Correction + QDomElement replaceElement = element.firstChildElement("replace"); + if (!replaceElement.isNull() && replaceElement.namespaceURI() == ns_message_correct) + d->replaceId = replaceElement.attribute("id"); + const QList<QPair<QString, QString> > &knownElems = knownMessageSubelems(); QXmppElementList extensions; @@ -757,6 +783,14 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const xmlWriter->writeEndElement(); } + // XEP-0308: Last Message Correction + if (!d->replaceId.isEmpty()) { + xmlWriter->writeStartElement("replace"); + xmlWriter->writeAttribute("xmlns", ns_message_correct); + xmlWriter->writeAttribute("id", d->replaceId); + xmlWriter->writeEndElement(); + } + // other extensions QXmppStanza::extensionsToXml(xmlWriter); diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h index 4ecd0d19..be5d2885 100644 --- a/src/base/QXmppMessage.h +++ b/src/base/QXmppMessage.h @@ -139,6 +139,10 @@ public: QString outOfBandUrl() const; void setOutOfBandUrl(const QString&); + // XEP-0308: Last Message Correction + QString replaceId() const; + void setReplaceId(const QString&); + /// \cond void parse(const QDomElement &element); void toXml(QXmlStreamWriter *writer) const; |
