aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppMucManager.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-05 16:11:48 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-05 16:11:48 +0200
commit1cd1192af7f660baf9b86524abf0b6c7204341c2 (patch)
tree5f6c6fc3baa5b25506b92edfb3fe07cd0dc5cbf0 /src/client/QXmppMucManager.cpp
parent9168d631d5c266ee79c3112840423d4fca0c96dd (diff)
downloadqxmpp-1cd1192af7f660baf9b86524abf0b6c7204341c2.tar.gz
Add QXmppMucRoom::ban() slot to ban users.
Diffstat (limited to 'src/client/QXmppMucManager.cpp')
-rw-r--r--src/client/QXmppMucManager.cpp35
1 files changed, 35 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