aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppPresence.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-12 14:33:43 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-12 14:33:43 +0200
commitef8fce0bb434c5fdc22630a0890a3c0fa4c7cc1f (patch)
treee0d64902da2332747cb4f5d6ce5edb6a2f4df169 /src/base/QXmppPresence.cpp
parentcd5287ba3fe64fd2782c10066a43c31b4c7694de (diff)
downloadqxmpp-ef8fce0bb434c5fdc22630a0890a3c0fa4c7cc1f.tar.gz
Add XEP-0045: Multi-User Chat attributes to QXmppPresence.
Diffstat (limited to 'src/base/QXmppPresence.cpp')
-rw-r--r--src/base/QXmppPresence.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/base/QXmppPresence.cpp b/src/base/QXmppPresence.cpp
index 5cd81739..a720a0e4 100644
--- a/src/base/QXmppPresence.cpp
+++ b/src/base/QXmppPresence.cpp
@@ -72,7 +72,9 @@ public:
// XEP-0045: Multi-User Chat
QXmppMucItem mucItem;
+ QString mucPassword;
QList<int> mucStatusCodes;
+ bool mucSupported;
};
/// Constructs a QXmppPresence.
@@ -83,6 +85,7 @@ QXmppPresence::QXmppPresence(QXmppPresence::Type type)
: d(new QXmppPresencePrivate)
{
d->type = type;
+ d->mucSupported = false;
d->vCardUpdateType = VCardUpdateNone;
}
@@ -198,7 +201,11 @@ void QXmppPresence::parse(const QDomElement &element)
while(!xElement.isNull())
{
// XEP-0045: Multi-User Chat
- if(xElement.namespaceURI() == ns_muc_user)
+ if(xElement.namespaceURI() == ns_muc) {
+ d->mucSupported = true;
+ d->mucPassword = xElement.firstChildElement("password").text();
+ }
+ else if(xElement.namespaceURI() == ns_muc_user)
{
QDomElement itemElement = xElement.firstChildElement("item");
d->mucItem.parse(itemElement);
@@ -273,6 +280,14 @@ void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
error().toXml(xmlWriter);
// XEP-0045: Multi-User Chat
+ if(d->mucSupported) {
+ xmlWriter->writeStartElement("x");
+ xmlWriter->writeAttribute("xmlns", ns_muc);
+ if (!d->mucPassword.isEmpty())
+ xmlWriter->writeTextElement("password", d->mucPassword);
+ xmlWriter->writeEndElement();
+ }
+
if(!d->mucItem.isNull() || !d->mucStatusCodes.isEmpty())
{
xmlWriter->writeStartElement("x");
@@ -420,6 +435,20 @@ void QXmppPresence::setMucItem(const QXmppMucItem &item)
d->mucItem = item;
}
+/// Returns the password used to join a MUC room.
+
+QString QXmppPresence::mucPassword() const
+{
+ return d->mucPassword;
+}
+
+/// Sets the password used to join a MUC room.
+
+void QXmppPresence::setMucPassword(const QString &password)
+{
+ d->mucPassword = password;
+}
+
/// Returns the MUC status codes.
QList<int> QXmppPresence::mucStatusCodes() const
@@ -436,6 +465,20 @@ void QXmppPresence::setMucStatusCodes(const QList<int> &codes)
d->mucStatusCodes = codes;
}
+/// Returns true if the sender has indicated MUC support.
+
+bool QXmppPresence::isMucSupported() const
+{
+ return d->mucSupported;
+}
+
+/// Sets whether MUC is \a supported.
+
+void QXmppPresence::setMucSupported(bool supported)
+{
+ d->mucSupported = supported;
+}
+
/// \cond
const QXmppPresence::Status& QXmppPresence::status() const
{