diff options
| author | Linus Jahn <lnj@kaidan.im> | 2018-12-04 19:22:02 +0100 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2018-12-19 09:06:22 +0100 |
| commit | fc389736df1107245ca91ecbe0bca0526a42288a (patch) | |
| tree | 162f5b422fcdfb28ce926fe3190960039886fc9c /src/base/QXmppMessage.cpp | |
| parent | 5b0b6472aa5932844f87ee939e0bf11b8eadb2cd (diff) | |
Add partial support of XEP-0066: Out of Band Data
Today this is most important for attaching URLs generated by XEP-0363:
HTTP File Upload for a very basic form of media/file sharing.
Diffstat (limited to 'src/base/QXmppMessage.cpp')
| -rw-r--r-- | src/base/QXmppMessage.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index df6e6bd1..3c62bd42 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -96,6 +96,9 @@ public: // XEP-0280: Message Carbons bool privatemsg; + + // XEP-0066: Out of Band Data + QString outOfBandUrl; }; /// Constructs a QXmppMessage. @@ -475,6 +478,20 @@ bool QXmppMessage::isXmppStanza() const return true; } +/// Returns a possibly attached URL from XEP-0066: Out of Band Data + +QString QXmppMessage::outOfBandUrl() const +{ + return d->outOfBandUrl; +} + +/// Sets the attached URL for XEP-0066: Out of Band Data + +void QXmppMessage::setOutOfBandUrl(const QString &url) +{ + d->outOfBandUrl = url; +} + /// \cond void QXmppMessage::parse(const QDomElement &element) { @@ -604,6 +621,9 @@ void QXmppMessage::parse(const QDomElement &element) d->mucInvitationJid = xElement.attribute("jid"); d->mucInvitationPassword = xElement.attribute("password"); d->mucInvitationReason = xElement.attribute("reason"); + } else if (xElement.namespaceURI() == ns_oob) { + // XEP-0066: Out of Band Data + d->outOfBandUrl = xElement.firstChildElement("url").text(); } else { extensions << QXmppElement(xElement); @@ -729,6 +749,14 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const xmlWriter->writeEndElement(); } + // XEP-0066: Out of Band Data + if (!d->outOfBandUrl.isEmpty()) { + xmlWriter->writeStartElement("x"); + xmlWriter->writeAttribute("xmlns", ns_oob); + xmlWriter->writeTextElement("url", d->outOfBandUrl); + xmlWriter->writeEndElement(); + } + // other extensions QXmppStanza::extensionsToXml(xmlWriter); |
