From 46e148fb2d3396ca33bba1aa400e55651c7a9c61 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 16 Nov 2019 23:14:46 +0100 Subject: Implement XEP-0231: Bits of Binary: message extension This adds support for XEP-0231: Bits of Binary attachments in messages. --- src/base/QXmppMessage.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/base/QXmppMessage.cpp') diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index 47f9bed9..6ef292ef 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -28,6 +28,7 @@ #include #include +#include "QXmppBitsOfBinaryDataList.h" #include "QXmppConstants_p.h" #include "QXmppMessage.h" #include "QXmppUtils.h" @@ -125,6 +126,9 @@ public: QString markedId; QString markedThread; + // XEP-0231: Bits of Binary + QXmppBitsOfBinaryDataList bitsOfBinaryData; + // XEP-0280: Message Carbons bool privatemsg; @@ -481,6 +485,37 @@ void QXmppMessage::setMarker(const Marker marker) d->marker = marker; } +/// Returns a list of data packages attached using XEP-0231: Bits of Binary. +/// +/// This could be used to resolve \c cid: URIs found in the X-HTML body. +/// +/// \since QXmpp 1.2 + +QXmppBitsOfBinaryDataList QXmppMessage::bitsOfBinaryData() const +{ + return d->bitsOfBinaryData; +} + +/// Returns a list of data attached using XEP-0231: Bits of Binary. +/// +/// This could be used to resolve \c cid: URIs found in the X-HTML body. +/// +/// \since QXmpp 1.2 + +QXmppBitsOfBinaryDataList &QXmppMessage::bitsOfBinaryData() +{ + return d->bitsOfBinaryData; +} + +/// Sets a list of XEP-0231: Bits of Binary attachments to be included. +/// +/// \since QXmpp 1.2 + +void QXmppMessage::setBitsOfBinaryData(const QXmppBitsOfBinaryDataList &bitsOfBinaryData) +{ + d->bitsOfBinaryData = bitsOfBinaryData; +} + /// Returns if the message is marked with a tag, /// in which case it will not be forwarded to other resources /// according to XEP-0280: Message Carbons. @@ -896,6 +931,10 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const xmlWriter->writeEndElement(); } + // XEP-0231: Bits of Binary + for (const auto &data : qAsConst(d->bitsOfBinaryData)) + data.toXmlElementFromChild(xmlWriter); + // XEP-0280: Message Carbons if (d->privatemsg) { xmlWriter->writeStartElement(QStringLiteral("private")); @@ -1016,6 +1055,11 @@ void QXmppMessage::parseExtension(const QDomElement &element, QXmppElementList & // XEP-0224: Attention } else if (checkElement(element, QStringLiteral("attention"), ns_attention)) { d->attentionRequested = true; + // XEP-0231: Bits of Binary + } else if (QXmppBitsOfBinaryData::isBitsOfBinaryData(element)) { + QXmppBitsOfBinaryData data; + data.parseElementFromChild(element); + d->bitsOfBinaryData << data; // XEP-0280: Message Carbons } else if (checkElement(element, QStringLiteral("private"), ns_carbons)) { d->privatemsg = true; -- cgit v1.2.3