aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppPresence.cpp
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2022-09-25 14:12:51 +0200
committerGitHub <noreply@github.com>2022-09-25 14:12:51 +0200
commit524a02debffd9552f0928b5804d7b51b045aa9d2 (patch)
treea8832b961839c27511193ec58e608ea552ff5362 /src/base/QXmppPresence.cpp
parent48bc0775e68cb6d7647287e90c3e69fde387003a (diff)
downloadqxmpp-524a02debffd9552f0928b5804d7b51b045aa9d2.tar.gz
Implement XEP-0272: Multiparty Jingle (Muji) stanza extensions (#457)
Adds the presence extension and the extension of the Jingle IQ. https://xmpp.org/extensions/xep-0272.html
Diffstat (limited to 'src/base/QXmppPresence.cpp')
-rw-r--r--src/base/QXmppPresence.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/base/QXmppPresence.cpp b/src/base/QXmppPresence.cpp
index 54e44fb4..059bd642 100644
--- a/src/base/QXmppPresence.cpp
+++ b/src/base/QXmppPresence.cpp
@@ -1,10 +1,12 @@
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
+// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#include "QXmppPresence.h"
#include "QXmppConstants_p.h"
+#include "QXmppJingleIq.h"
#include "QXmppUtils.h"
#include <QDateTime>
@@ -59,6 +61,10 @@ public:
QByteArray photoHash;
QXmppPresence::VCardUpdateType vCardUpdateType;
+ // XEP-0272: Multiparty Jingle (Muji)
+ bool isPreparingMujiSession = false;
+ QVector<QXmppJingleIq::Content> mujiContents;
+
// XEP-0319: Last User Interaction in Presence
QDateTime lastUserInteraction;
@@ -253,6 +259,54 @@ QStringList QXmppPresence::capabilityExt() const
return d->capabilityExt;
}
+///
+/// Returns whether a \xep{0272, Multiparty Jingle (Muji)} session is being prepared.
+///
+/// \return whether a Muji session is being prepared
+///
+/// \since QXmpp 1.5
+///
+bool QXmppPresence::isPreparingMujiSession() const
+{
+ return d->isPreparingMujiSession;
+}
+
+///
+/// Sets whether a \xep{0272, Multiparty Jingle (Muji)} session is being prepared.
+///
+/// \param isPreparingMujiSession whether a Muji session is being prepared
+///
+/// \since QXmpp 1.5
+///
+void QXmppPresence::setIsPreparingMujiSession(bool isPreparingMujiSession)
+{
+ d->isPreparingMujiSession = isPreparingMujiSession;
+}
+
+///
+/// Returns \xep{0272, Multiparty Jingle (Muji)} contents.
+///
+/// \return Muji contents
+///
+/// \since QXmpp 1.5
+///
+QVector<QXmppJingleIq::Content> QXmppPresence::mujiContents() const
+{
+ return d->mujiContents;
+}
+
+///
+/// Sets \xep{0272, Multiparty Jingle (Muji)} contents.
+///
+/// \param mujiContents Muji contents
+///
+/// \since QXmpp 1.5
+///
+void QXmppPresence::setMujiContents(const QVector<QXmppJingleIq::Content> &mujiContents)
+{
+ d->mujiContents = mujiContents;
+}
+
/// Returns the MUC item.
QXmppMucItem QXmppPresence::mucItem() const
@@ -447,6 +501,19 @@ void QXmppPresence::parseExtension(const QDomElement &element, QXmppElementList
d->vCardUpdateType = VCardUpdateValidPhoto;
}
}
+ // XEP-0272: Multiparty Jingle (Muji)
+ } else if (element.tagName() == QStringLiteral("muji") && element.namespaceURI() == ns_muji) {
+ if (!element.firstChildElement(QStringLiteral("preparing")).isNull()) {
+ d->isPreparingMujiSession = true;
+ }
+
+ for (auto contentElement = element.firstChildElement(QStringLiteral("content"));
+ !contentElement.isNull();
+ contentElement = contentElement.nextSiblingElement(QStringLiteral("content"))) {
+ QXmppJingleIq::Content content;
+ content.parse(contentElement);
+ d->mujiContents.append(content);
+ }
// XEP-0319: Last User Interaction in Presence
} else if (element.tagName() == QStringLiteral("idle") && element.namespaceURI() == ns_idle) {
if (element.hasAttribute(QStringLiteral("since"))) {
@@ -537,6 +604,22 @@ void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
xmlWriter->writeEndElement();
}
+ // XEP-0272: Multiparty Jingle (Muji)
+ if (d->isPreparingMujiSession || !d->mujiContents.isEmpty()) {
+ xmlWriter->writeStartElement(QStringLiteral("muji"));
+ xmlWriter->writeDefaultNamespace(ns_muji);
+
+ if (d->isPreparingMujiSession) {
+ xmlWriter->writeEmptyElement(QStringLiteral("preparing"));
+ }
+
+ for (const auto &mujiContent : d->mujiContents) {
+ mujiContent.toXml(xmlWriter);
+ }
+
+ xmlWriter->writeEndElement();
+ }
+
// XEP-0319: Last User Interaction in Presence
if (!d->lastUserInteraction.isNull() && d->lastUserInteraction.isValid()) {
xmlWriter->writeStartElement(QStringLiteral("idle"));