-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XEP 0283: Moved - Add support in QXmppPresence
This allow to track if the request is being issued as part of a moved user.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 Melvin Keskin <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Filipe Azevedo <[email protected]> | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
|
@@ -76,6 +77,9 @@ class QXmppPresencePrivate : public QSharedData | |
// XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements | ||
QString mixUserJid; | ||
QString mixUserNick; | ||
|
||
// XEP-0283: Moved | ||
QString oldJid; | ||
}; | ||
|
||
QXmppPresencePrivate::QXmppPresencePrivate() | ||
|
@@ -348,6 +352,26 @@ void QXmppPresence::setMucSupported(bool supported) | |
d->mucSupported = supported; | ||
} | ||
|
||
/// | ||
/// Returns the \xep{0283, Moved} user's old jid. | ||
/// | ||
/// \since QXmpp 1.9 | ||
/// | ||
QString QXmppPresence::oldJid() const | ||
{ | ||
return d->oldJid; | ||
} | ||
|
||
/// | ||
/// Sets the \xep{0283, Moved} user's old jid. | ||
/// | ||
/// \since QXmpp 1.9 | ||
/// | ||
void QXmppPresence::setOldJid(const QString &oldJid) | ||
{ | ||
d->oldJid = oldJid; | ||
} | ||
|
||
/// | ||
/// Returns when the last user interaction with the client took place. See | ||
/// \xep{0319}: Last User Interaction in Presence for details. | ||
|
@@ -483,6 +507,9 @@ void QXmppPresence::parseExtension(const QDomElement &element, QXmppElementList | |
content.parse(contentElement); | ||
d->mujiContents.append(content); | ||
} | ||
// XEP-0283: Moved | ||
} else if (element.tagName() == u"moved" && element.namespaceURI() == ns_moved) { | ||
d->oldJid = element.firstChildElement(u"old-jid"_s).text(); | ||
// XEP-0319: Last User Interaction in Presence | ||
} else if (element.tagName() == u"idle" && element.namespaceURI() == ns_idle) { | ||
if (element.hasAttribute(u"since"_s)) { | ||
|
@@ -584,6 +611,14 @@ void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const | |
xmlWriter->writeEndElement(); | ||
} | ||
|
||
// XEP-0283: Moved | ||
if (!d->oldJid.isEmpty()) { | ||
xmlWriter->writeStartElement(QSL65("moved")); | ||
xmlWriter->writeDefaultNamespace(ns_moved.toString()); | ||
writeXmlTextElement(xmlWriter, u"old-jid", d->oldJid); | ||
xmlWriter->writeEndElement(); | ||
} | ||
|
||
// XEP-0319: Last User Interaction in Presence | ||
if (!d->lastUserInteraction.isNull() && d->lastUserInteraction.isValid()) { | ||
xmlWriter->writeStartElement(QSL65("idle")); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 Melvin Keskin <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Filipe Azevedo <[email protected]> | ||
// | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
|
@@ -115,6 +116,10 @@ class QXMPP_EXPORT QXmppPresence : public QXmppStanza | |
QVector<QXmppJingleIq::Content> mujiContents() const; | ||
void setMujiContents(const QVector<QXmppJingleIq::Content> &mujiContents); | ||
|
||
// XEP-0283: Moved | ||
QString oldJid() const; | ||
void setOldJid(const QString &oldJid); | ||
|
||
// XEP-0319: Last User Interaction in Presence | ||
QDateTime lastUserInteraction() const; | ||
void setLastUserInteraction(const QDateTime &); | ||
|