diff options
| author | Linus Jahn <lnj@kaidan.im> | 2019-11-16 23:14:46 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2019-12-06 22:26:12 +0100 |
| commit | 46e148fb2d3396ca33bba1aa400e55651c7a9c61 (patch) | |
| tree | bcec9b21b6b360f016135bee542902efcab0c973 /src/base/QXmppMessage.cpp | |
| parent | 0ef3588af37a7eb28af1dd33c9c3ad06b29f80d7 (diff) | |
| download | qxmpp-46e148fb2d3396ca33bba1aa400e55651c7a9c61.tar.gz | |
Implement XEP-0231: Bits of Binary: message extension
This adds support for XEP-0231: Bits of Binary attachments in messages.
Diffstat (limited to 'src/base/QXmppMessage.cpp')
| -rw-r--r-- | src/base/QXmppMessage.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
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 <QTextStream> #include <QXmlStreamWriter> +#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 <private> 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; |
