aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppPresence.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-01-05 13:18:45 +0100
committerJeremy Lainé <jeremy.laine@m4x.org>2019-05-01 10:24:51 +0200
commitc0412e29545c109e3473b38dbeba4e17514a7b05 (patch)
tree9c6d10d44198a6e06312899fffe42d3f7a183251 /src/base/QXmppPresence.cpp
parentf8fc440ef424dec4e465eb6a57eadb734f43da59 (diff)
downloadqxmpp-c0412e29545c109e3473b38dbeba4e17514a7b05.tar.gz
Implement MIX-PAM XEP-0405: Presence extension
This implements the new presence extension defined by XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements in version 0.4.0. https://xmpp.org/extensions/xep-0405.html#usecase-user-presence-receive
Diffstat (limited to 'src/base/QXmppPresence.cpp')
-rw-r--r--src/base/QXmppPresence.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/base/QXmppPresence.cpp b/src/base/QXmppPresence.cpp
index f8a27f43..ad0b1c60 100644
--- a/src/base/QXmppPresence.cpp
+++ b/src/base/QXmppPresence.cpp
@@ -80,6 +80,10 @@ public:
// XEP-0319: Last User Interaction in Presence
QDateTime lastUserInteraction;
+
+ // XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements
+ QString mixUserJid;
+ QString mixUserNick;
};
/// Constructs a QXmppPresence.
@@ -265,6 +269,11 @@ void QXmppPresence::parse(const QDomElement &element)
d->lastUserInteraction = QXmppUtils::datetimeFromString(since);
}
}
+ // XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements
+ else if (xElement.tagName() == "mix" && xElement.namespaceURI() == ns_mix_presence) {
+ d->mixUserJid = xElement.firstChildElement("jid").text();
+ d->mixUserNick = xElement.firstChildElement("nick").text();
+ }
else if (xElement.tagName() != "addresses" && xElement.tagName() != "error"
&& xElement.tagName() != "show" && xElement.tagName() != "status"
&& xElement.tagName() != "priority")
@@ -361,6 +370,17 @@ void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
xmlWriter->writeEndElement();
}
+ // XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements
+ if (!d->mixUserJid.isEmpty() || !d->mixUserNick.isEmpty()) {
+ xmlWriter->writeStartElement("mix");
+ xmlWriter->writeAttribute("xmlns", ns_mix_presence);
+ if (!d->mixUserJid.isEmpty())
+ xmlWriter->writeTextElement("jid", d->mixUserJid);
+ if (!d->mixUserNick.isEmpty())
+ xmlWriter->writeTextElement("nick", d->mixUserNick);
+ xmlWriter->writeEndElement();
+ }
+
// other extensions
QXmppStanza::extensionsToXml(xmlWriter);
@@ -522,7 +542,35 @@ void QXmppPresence::setLastUserInteraction(const QDateTime& lastUserInteraction)
d->lastUserInteraction = lastUserInteraction;
}
-/// Indicates if the QXmppStanza is a stanza in the XMPP sense (i. e. a message,
+/// Returns the actual (full) JID of the MIX channel participant.
+
+QString QXmppPresence::mixUserJid() const
+{
+ return d->mixUserJid;
+}
+
+/// Sets the actual (full) JID of the MIX channel participant.
+
+void QXmppPresence::setMixUserJid(const QString& mixUserJid)
+{
+ d->mixUserJid = mixUserJid;
+}
+
+/// Returns the MIX participant's nickname.
+
+QString QXmppPresence::mixUserNick() const
+{
+ return d->mixUserNick;
+}
+
+/// Sets the MIX participant's nickname.
+
+void QXmppPresence::setMixUserNick(const QString& mixUserNick)
+{
+ d->mixUserNick = mixUserNick;
+}
+
+/// Indicates if the QXmppStanza is a stanza in the XMPP sence (i. e. a message,
/// iq or presence)
bool QXmppPresence::isXmppStanza() const