diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-02-10 16:44:55 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-02-10 20:29:19 +0100 |
| commit | bfd26369d1ef032837fbd2b52ea0ed4cc04abe91 (patch) | |
| tree | 64aa6d70c44eada4c891c6c5272dd6b5af3ba5bd /src/base | |
| parent | 964e7458191f615abe2ee4eb0b27c7680c7be2f3 (diff) | |
| download | qxmpp-bfd26369d1ef032837fbd2b52ea0ed4cc04abe91.tar.gz | |
Implement XEP-0428: Fallback Indication
This adds support of XEP-0428: Fallback Indication in version 0.1.0.
https://xmpp.org/extensions/xep-0428.html
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 | 44 | ||||
| -rw-r--r-- | src/base/QXmppMessage.h | 4 |
4 files changed, 51 insertions, 1 deletions
diff --git a/src/base/QXmppConstants.cpp b/src/base/QXmppConstants.cpp index a9d5612d..794ce14c 100644 --- a/src/base/QXmppConstants.cpp +++ b/src/base/QXmppConstants.cpp @@ -166,3 +166,5 @@ const char* ns_omemo = "eu.siacs.conversations.axolotl"; const char* ns_mix_pam = "urn:xmpp:mix:pam:1"; const char* ns_mix_roster = "urn:xmpp:mix:roster:0"; const char* ns_mix_presence = "urn:xmpp:presence:0"; +// XEP-0428: Fallback Indication +const char* ns_fallback_indication = "urn:xmpp:fallback:0"; diff --git a/src/base/QXmppConstants_p.h b/src/base/QXmppConstants_p.h index 28ad6da8..c7811811 100644 --- a/src/base/QXmppConstants_p.h +++ b/src/base/QXmppConstants_p.h @@ -178,5 +178,7 @@ extern const char* ns_omemo; extern const char* ns_mix_pam; extern const char* ns_mix_roster; extern const char* ns_mix_presence; +// XEP-0428: Fallback Indication +extern const char* ns_fallback_indication; #endif // QXMPPCONSTANTS_H diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index 3544c55b..e877e5c1 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -155,6 +155,9 @@ public: // XEP-0382: Spoiler messages bool isSpoiler; QString spoilerHint; + + // XEP-0428: Fallback Indication + bool isFallback; }; QXmppMessagePrivate::QXmppMessagePrivate() @@ -167,7 +170,8 @@ QXmppMessagePrivate::QXmppMessagePrivate() marker(QXmppMessage::NoMarker), privatemsg(false), hints(0), - isSpoiler(false) + isSpoiler(false), + isFallback(false) { } @@ -796,6 +800,34 @@ void QXmppMessage::setSpoilerHint(const QString &spoilerHint) d->isSpoiler = true; } +/// +/// Sets whether this message is only a fallback according to \xep{0428}: +/// Fallback Indication. +/// +/// This is useful for clients not supporting end-to-end encryption to indicate +/// that the message body does not contain the intended text of the author. +/// +/// \since QXmpp 1.3 +/// +bool QXmppMessage::isFallback() const +{ + return d->isFallback; +} + +/// +/// Sets whether this message is only a fallback according to \xep{0428}: +/// Fallback Indication. +/// +/// This is useful for clients not supporting end-to-end encryption to indicate +/// that the message body does not contain the intended text of the author. +/// +/// \since QXmpp 1.3 +/// +void QXmppMessage::setIsFallback(bool isFallback) +{ + d->isFallback = isFallback; +} + /// \cond void QXmppMessage::parse(const QDomElement &element) { @@ -999,6 +1031,13 @@ void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const xmlWriter->writeEndElement(); } + // XEP-0428: Fallback Indication + if (d->isFallback) { + xmlWriter->writeStartElement(QStringLiteral("fallback")); + xmlWriter->writeDefaultNamespace(ns_fallback_indication); + xmlWriter->writeEndElement(); + } + // other extensions QXmppStanza::extensionsToXml(xmlWriter); @@ -1093,6 +1132,9 @@ void QXmppMessage::parseExtension(const QDomElement &element, QXmppElementList & } else if (checkElement(element, QStringLiteral("spoiler"), ns_spoiler)) { d->isSpoiler = true; d->spoilerHint = element.text(); + } else if (checkElement(element, QStringLiteral("fallback"), ns_fallback_indication)) { + // XEP-0428: Fallback Indication + d->isFallback = true; } else { // other extensions unknownExtensions << QXmppElement(element); diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h index 970395aa..cd24c25a 100644 --- a/src/base/QXmppMessage.h +++ b/src/base/QXmppMessage.h @@ -205,6 +205,10 @@ public: QString spoilerHint() const; void setSpoilerHint(const QString &); + // XEP-0428: Fallback Indication + bool isFallback() const; + void setIsFallback(bool isFallback); + /// \cond void parse(const QDomElement &element) override; void toXml(QXmlStreamWriter *writer) const override; |
