Gajim now asks reason for ban/kick (thanks liorithiel!)
This commit is contained in:
parent
7c8bd6ac38
commit
513a4c9f4f
|
@ -1109,7 +1109,7 @@ class Connection:
|
||||||
self.to_be_sent.insert(0, common.xmpp.Presence(to = '%s/%s' % (jid, nick),
|
self.to_be_sent.insert(0, common.xmpp.Presence(to = '%s/%s' % (jid, nick),
|
||||||
typ = ptype, show = show, status = status))
|
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:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
||||||
|
@ -1117,9 +1117,11 @@ class Connection:
|
||||||
item = iq.getTag('query').setTag('item')
|
item = iq.getTag('query').setTag('item')
|
||||||
item.setAttr('nick', nick)
|
item.setAttr('nick', nick)
|
||||||
item.setAttr('role', role)
|
item.setAttr('role', role)
|
||||||
|
if reason:
|
||||||
|
item.addChild(name = 'reason', payload = reason)
|
||||||
self.to_be_sent.insert(0, iq)
|
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:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
||||||
|
@ -1127,6 +1129,8 @@ class Connection:
|
||||||
item = iq.getTag('query').setTag('item')
|
item = iq.getTag('query').setTag('item')
|
||||||
item.setAttr('jid', jid)
|
item.setAttr('jid', jid)
|
||||||
item.setAttr('affiliation', affiliation)
|
item.setAttr('affiliation', affiliation)
|
||||||
|
if reason:
|
||||||
|
item.addChild(name = 'reason', payload = reason)
|
||||||
self.to_be_sent.insert(0, iq)
|
self.to_be_sent.insert(0, iq)
|
||||||
|
|
||||||
def send_gc_config(self, room_jid, config):
|
def send_gc_config(self, room_jid, config):
|
||||||
|
|
|
@ -583,7 +583,15 @@ class GroupchatWindow(chat.Chat):
|
||||||
|
|
||||||
def kick(self, widget, room_jid, nick):
|
def kick(self, widget, room_jid, nick):
|
||||||
"""kick a user"""
|
"""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):
|
def grant_voice(self, widget, room_jid, nick):
|
||||||
"""grant voice privilege to a user"""
|
"""grant voice privilege to a user"""
|
||||||
|
@ -603,8 +611,15 @@ class GroupchatWindow(chat.Chat):
|
||||||
|
|
||||||
def ban(self, widget, room_jid, jid):
|
def ban(self, widget, room_jid, jid):
|
||||||
"""ban a user"""
|
"""ban a user"""
|
||||||
gajim.connections[self.account].gc_set_affiliation(room_jid, jid,
|
# ask for reason
|
||||||
'outcast')
|
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):
|
def grant_membership(self, widget, room_jid, jid):
|
||||||
"""grant membership privilege to a user"""
|
"""grant membership privilege to a user"""
|
||||||
|
|
|
@ -11863,7 +11863,7 @@ JID: whatever@jabber.org</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="input_dialog">
|
<widget class="GtkDialog" id="input_dialog">
|
||||||
<property name="border_width">12</property>
|
<property name="border_width">6</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="title" translatable="yes"></property>
|
<property name="title" translatable="yes"></property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
|
|
Loading…
Reference in New Issue