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 | |
| parent | 5b0b6472aa5932844f87ee939e0bf11b8eadb2cd (diff) | |
| download | qxmpp-fc389736df1107245ca91ecbe0bca0526a42288a.tar.gz | |
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')
| -rw-r--r-- | src/base/QXmppConstants.cpp | 2 | ||||
| -rw-r--r-- | src/base/QXmppConstants_p.h | 2 | ||||
| -rw-r--r-- | src/base/QXmppMessage.cpp | 28 | ||||
| -rw-r--r-- | src/base/QXmppMessage.h | 4 |
4 files changed, 36 insertions, 0 deletions
diff --git a/src/base/QXmppConstants.cpp b/src/base/QXmppConstants.cpp index 1ab2c70d..03260018 100644 --- a/src/base/QXmppConstants.cpp +++ b/src/base/QXmppConstants.cpp @@ -57,6 +57,8 @@ const char* ns_vcard = "vcard-temp"; const char* ns_rsm = "http://jabber.org/protocol/rsm"; // XEP-0065: SOCKS5 Bytestreams const char* ns_bytestreams = "http://jabber.org/protocol/bytestreams"; +// XEP-0066: Out of Band Data +const char* ns_oob = "jabber:x:oob"; // XEP-0071: XHTML-IM const char *ns_xhtml_im = "http://jabber.org/protocol/xhtml-im"; // XEP-0077: In-Band Registration diff --git a/src/base/QXmppConstants_p.h b/src/base/QXmppConstants_p.h index cc113e3d..8846145c 100644 --- a/src/base/QXmppConstants_p.h +++ b/src/base/QXmppConstants_p.h @@ -69,6 +69,8 @@ extern const char* ns_vcard; extern const char* ns_rsm; // XEP-0065: SOCKS5 Bytestreams extern const char* ns_bytestreams; +// XEP-0066: Out of Band Data +extern const char* ns_oob; // XEP-0071: XHTML-IM extern const char *ns_xhtml_im; // XEP-0077: In-Band Registration 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); diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h index fbed97e0..4ecd0d19 100644 --- a/src/base/QXmppMessage.h +++ b/src/base/QXmppMessage.h @@ -135,6 +135,10 @@ public: bool isXmppStanza() const; + // XEP-0066: Out of Band Data + QString outOfBandUrl() const; + void setOutOfBandUrl(const QString&); + /// \cond void parse(const QDomElement &element); void toXml(QXmlStreamWriter *writer) const; |
