diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/QXmppMucManager.cpp | 35 | ||||
| -rw-r--r-- | src/client/QXmppMucManager.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/client/QXmppMucManager.cpp b/src/client/QXmppMucManager.cpp index 222d14de..5b006af2 100644 --- a/src/client/QXmppMucManager.cpp +++ b/src/client/QXmppMucManager.cpp @@ -226,6 +226,41 @@ QXmppMucRoom::Actions QXmppMucRoom::allowedActions() const return d->allowedActions; } +/// Bans the specified user from the chat room. +/// +/// The specified \a jid can be either an "anonymized" room participant JID +/// such of the form theroom@conference.example.com/nickname or a real JID. +/// +/// \return true if the request was sent, false otherwise + +bool QXmppMucRoom::ban(const QString &jid, const QString &reason) +{ + QString realJid; + if (QXmppUtils::jidToBareJid(jid) == d->jid) { + // an "anonymized" JID was specified, look up the real JID + if (d->participants.contains(jid)) + realJid = d->participants.value(jid).mucItem().jid(); + if (realJid.isEmpty()) { + qWarning("Coud not determine real JID for %s", qPrintable(jid)); + return false; + } + } else { + realJid = jid; + } + + QXmppMucItem item; + item.setAffiliation(QXmppMucItem::OutcastAffiliation); + item.setJid(realJid); + item.setReason(reason); + + QXmppMucAdminIq iq; + iq.setType(QXmppIq::Set); + iq.setTo(d->jid); + iq.setItems(QList<QXmppMucItem>() << item); + + return d->client->sendPacket(iq); +} + /// Returns true if you are currently in the room. bool QXmppMucRoom::isJoined() const diff --git a/src/client/QXmppMucManager.h b/src/client/QXmppMucManager.h index 9d103c12..77760b1f 100644 --- a/src/client/QXmppMucManager.h +++ b/src/client/QXmppMucManager.h @@ -188,6 +188,7 @@ signals: void subjectChanged(const QString &subject); public slots: + bool ban(const QString &jid, const QString &reason); bool join(); bool kick(const QString &jid, const QString &reason); bool leave(const QString &message = QString()); |
