From 513a4c9f4f5a1bdc66aa0da908246fee7f6289a4 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sat, 2 Jul 2005 18:33:51 +0000 Subject: [PATCH] Gajim now asks reason for ban/kick (thanks liorithiel!) --- src/common/connection.py | 8 ++++++-- src/groupchat_window.py | 21 ++++++++++++++++++--- src/gtkgui.glade | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index c01a53181..c65d71d2e 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1109,7 +1109,7 @@ class Connection: self.to_be_sent.insert(0, common.xmpp.Presence(to = '%s/%s' % (jid, nick), typ = ptype, show = show, status = status)) - def gc_set_role(self, room_jid, nick, role): + def gc_set_role(self, room_jid, nick, role, reason = ''): if not self.connection: return iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\ @@ -1117,9 +1117,11 @@ class Connection: item = iq.getTag('query').setTag('item') item.setAttr('nick', nick) item.setAttr('role', role) + if reason: + item.addChild(name = 'reason', payload = reason) self.to_be_sent.insert(0, iq) - def gc_set_affiliation(self, room_jid, jid, affiliation): + def gc_set_affiliation(self, room_jid, jid, affiliation, reason = ''): if not self.connection: return iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\ @@ -1127,6 +1129,8 @@ class Connection: item = iq.getTag('query').setTag('item') item.setAttr('jid', jid) item.setAttr('affiliation', affiliation) + if reason: + item.addChild(name = 'reason', payload = reason) self.to_be_sent.insert(0, iq) def send_gc_config(self, room_jid, config): diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 1c69cbe52..4492d5963 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -583,7 +583,15 @@ class GroupchatWindow(chat.Chat): def kick(self, widget, room_jid, nick): """kick a user""" - gajim.connections[self.account].gc_set_role(room_jid, nick, 'none') + # ask for reason + instance = dialogs.InputDialog(_('Kicking %s') % nick, + _('Please specify a reason below:')) + response = instance.get_response() + if response == gtk.RESPONSE_OK: + reason = instance.input_entry.get_text() + else: + return # stop kicking procedure + gajim.connections[self.account].gc_set_role(room_jid, nick, 'none', reason) def grant_voice(self, widget, room_jid, nick): """grant voice privilege to a user""" @@ -603,8 +611,15 @@ class GroupchatWindow(chat.Chat): def ban(self, widget, room_jid, jid): """ban a user""" - gajim.connections[self.account].gc_set_affiliation(room_jid, jid, - 'outcast') + # ask for reason + instance = dialogs.InputDialog(_('Banning %s') % nick, + _('Please specify a reason below:')) + response = instance.get_response() + if response == gtk.RESPONSE_OK: + reason = instance.input_entry.get_text() + else: + return # stop banning procedure + gajim.connections[self.account].gc_set_affiliation(room_jid, jid, 'outcast', reason) def grant_membership(self, widget, room_jid, jid): """grant membership privilege to a user""" diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 855bc32af..21ded5608 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -11863,7 +11863,7 @@ JID: whatever@jabber.org - 12 + 6 True GTK_WINDOW_TOPLEVEL