In configure room, works even if we receive an affiliation list with more than one affiliation inside.
More logical, more secure and example 90 in xep-0045 says it can happen. Deal also with affiliation 'none' (don't show it)
This commit is contained in:
parent
f217ae91f5
commit
5689daf66b
|
@ -2094,7 +2094,6 @@ returns the session that we last sent a message to.'''
|
||||||
gajim.log.debug('MucAdminCB')
|
gajim.log.debug('MucAdminCB')
|
||||||
items = iq_obj.getTag('query', namespace = common.xmpp.NS_MUC_ADMIN).getTags('item')
|
items = iq_obj.getTag('query', namespace = common.xmpp.NS_MUC_ADMIN).getTags('item')
|
||||||
list = {}
|
list = {}
|
||||||
affiliation = ''
|
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.has_attr('jid') and item.has_attr('affiliation'):
|
if item.has_attr('jid') and item.has_attr('affiliation'):
|
||||||
jid = item.getAttr('jid')
|
jid = item.getAttr('jid')
|
||||||
|
@ -2109,7 +2108,7 @@ returns the session that we last sent a message to.'''
|
||||||
list[jid]['reason'] = reason
|
list[jid]['reason'] = reason
|
||||||
|
|
||||||
self.dispatch('GC_AFFILIATION', (helpers.get_full_jid_from_iq(iq_obj),
|
self.dispatch('GC_AFFILIATION', (helpers.get_full_jid_from_iq(iq_obj),
|
||||||
affiliation, list))
|
list))
|
||||||
|
|
||||||
def _MucErrorCB(self, con, iq_obj):
|
def _MucErrorCB(self, con, iq_obj):
|
||||||
gajim.log.debug('MucErrorCB')
|
gajim.log.debug('MucErrorCB')
|
||||||
|
|
|
@ -2362,7 +2362,7 @@ class GroupchatConfigWindow:
|
||||||
self.remove_button = {}
|
self.remove_button = {}
|
||||||
self.affiliation_treeview = {}
|
self.affiliation_treeview = {}
|
||||||
self.list_init = {} # list at the beginning
|
self.list_init = {} # list at the beginning
|
||||||
ui_list = {'outcast': _('Ban List'),
|
self.affiliation_labels = {'outcast': _('Ban List'),
|
||||||
'member': _('Member List'),
|
'member': _('Member List'),
|
||||||
'owner': _('Owner List'),
|
'owner': _('Owner List'),
|
||||||
'admin':_('Administrator List')}
|
'admin':_('Administrator List')}
|
||||||
|
@ -2386,12 +2386,12 @@ class GroupchatConfigWindow:
|
||||||
# Draw the edit affiliation list things
|
# Draw the edit affiliation list things
|
||||||
add_on_vbox = self.xml.get_widget('add_on_vbox')
|
add_on_vbox = self.xml.get_widget('add_on_vbox')
|
||||||
|
|
||||||
for affiliation in ('outcast', 'member', 'owner', 'admin'):
|
for affiliation in self.affiliation_labels.keys():
|
||||||
self.list_init[affiliation] = {}
|
self.list_init[affiliation] = {}
|
||||||
hbox = gtk.HBox(spacing = 5)
|
hbox = gtk.HBox(spacing = 5)
|
||||||
add_on_vbox.pack_start(hbox, False)
|
add_on_vbox.pack_start(hbox, False)
|
||||||
|
|
||||||
label = gtk.Label(ui_list[affiliation])
|
label = gtk.Label(self.affiliation_labels[affiliation])
|
||||||
hbox.pack_start(label, False)
|
hbox.pack_start(label, False)
|
||||||
|
|
||||||
bb = gtk.HButtonBox()
|
bb = gtk.HButtonBox()
|
||||||
|
@ -2501,14 +2501,17 @@ class GroupchatConfigWindow:
|
||||||
def on_affiliation_treeview_cursor_changed(self, widget, affiliation):
|
def on_affiliation_treeview_cursor_changed(self, widget, affiliation):
|
||||||
self.remove_button[affiliation].set_sensitive(True)
|
self.remove_button[affiliation].set_sensitive(True)
|
||||||
|
|
||||||
def affiliation_list_received(self, affiliation, list):
|
def affiliation_list_received(self, list):
|
||||||
'''Fill the affiliation treeview'''
|
'''Fill the affiliation treeview'''
|
||||||
self.list_init[affiliation] = list
|
for jid in list:
|
||||||
if not affiliation:
|
if list[jid].has_key('affiliation'):
|
||||||
return
|
affiliation = list[jid]['affiliation']
|
||||||
|
if affiliation not in self.affiliation_labels.keys():
|
||||||
|
# Unknown affiliation or 'none' affiliation, do not show it
|
||||||
|
continue
|
||||||
|
self.list_init[affiliation][jid] = list[jid]
|
||||||
tv = self.affiliation_treeview[affiliation]
|
tv = self.affiliation_treeview[affiliation]
|
||||||
model = tv.get_model()
|
model = tv.get_model()
|
||||||
for jid in list:
|
|
||||||
reason = ''
|
reason = ''
|
||||||
if list[jid].has_key('reason'):
|
if list[jid].has_key('reason'):
|
||||||
reason = list[jid]['reason']
|
reason = list[jid]['reason']
|
||||||
|
@ -2518,7 +2521,7 @@ class GroupchatConfigWindow:
|
||||||
role = ''
|
role = ''
|
||||||
if list[jid].has_key('role'):
|
if list[jid].has_key('role'):
|
||||||
role = list[jid]['role']
|
role = list[jid]['role']
|
||||||
model.append((jid,reason, nick, role))
|
model.append((jid, reason, nick, role))
|
||||||
|
|
||||||
def on_data_form_window_destroy(self, widget):
|
def on_data_form_window_destroy(self, widget):
|
||||||
del gajim.interface.instances[self.account]['gc_config'][self.room_jid]
|
del gajim.interface.instances[self.account]['gc_config'][self.room_jid]
|
||||||
|
@ -2527,7 +2530,7 @@ class GroupchatConfigWindow:
|
||||||
if self.form:
|
if self.form:
|
||||||
form = self.data_form_widget.data_form
|
form = self.data_form_widget.data_form
|
||||||
gajim.connections[self.account].send_gc_config(self.room_jid, form)
|
gajim.connections[self.account].send_gc_config(self.room_jid, form)
|
||||||
for affiliation in ('outcast', 'member', 'owner', 'admin'):
|
for affiliation in self.affiliation_labels.keys():
|
||||||
list = {}
|
list = {}
|
||||||
actual_jid_list = []
|
actual_jid_list = []
|
||||||
model = self.affiliation_treeview[affiliation].get_model()
|
model = self.affiliation_treeview[affiliation].get_model()
|
||||||
|
|
|
@ -1373,11 +1373,11 @@ class Interface:
|
||||||
gc_control.print_conversation(change)
|
gc_control.print_conversation(change)
|
||||||
|
|
||||||
def handle_event_gc_affiliation(self, account, array):
|
def handle_event_gc_affiliation(self, account, array):
|
||||||
#('GC_AFFILIATION', account, (room_jid, affiliation, list)) list is list
|
#('GC_AFFILIATION', account, (room_jid, list)) list is list
|
||||||
room_jid = array[0]
|
room_jid = array[0]
|
||||||
if self.instances[account]['gc_config'].has_key(room_jid):
|
if self.instances[account]['gc_config'].has_key(room_jid):
|
||||||
self.instances[account]['gc_config'][room_jid].\
|
self.instances[account]['gc_config'][room_jid].\
|
||||||
affiliation_list_received(array[1], array[2])
|
affiliation_list_received(array[1])
|
||||||
|
|
||||||
def handle_event_gc_password_required(self, account, array):
|
def handle_event_gc_password_required(self, account, array):
|
||||||
#('GC_PASSWORD_REQUIRED', account, (room_jid, nick))
|
#('GC_PASSWORD_REQUIRED', account, (room_jid, nick))
|
||||||
|
|
Loading…
Reference in New Issue