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:
Jean-Marie Traissard 2008-05-05 00:38:52 +00:00
parent f217ae91f5
commit 5689daf66b
3 changed files with 17 additions and 15 deletions

View File

@ -2094,7 +2094,6 @@ returns the session that we last sent a message to.'''
gajim.log.debug('MucAdminCB')
items = iq_obj.getTag('query', namespace = common.xmpp.NS_MUC_ADMIN).getTags('item')
list = {}
affiliation = ''
for item in items:
if item.has_attr('jid') and item.has_attr('affiliation'):
jid = item.getAttr('jid')
@ -2109,7 +2108,7 @@ returns the session that we last sent a message to.'''
list[jid]['reason'] = reason
self.dispatch('GC_AFFILIATION', (helpers.get_full_jid_from_iq(iq_obj),
affiliation, list))
list))
def _MucErrorCB(self, con, iq_obj):
gajim.log.debug('MucErrorCB')

View File

@ -2362,7 +2362,7 @@ class GroupchatConfigWindow:
self.remove_button = {}
self.affiliation_treeview = {}
self.list_init = {} # list at the beginning
ui_list = {'outcast': _('Ban List'),
self.affiliation_labels = {'outcast': _('Ban List'),
'member': _('Member List'),
'owner': _('Owner List'),
'admin':_('Administrator List')}
@ -2386,12 +2386,12 @@ class GroupchatConfigWindow:
# Draw the edit affiliation list things
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] = {}
hbox = gtk.HBox(spacing = 5)
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)
bb = gtk.HButtonBox()
@ -2501,14 +2501,17 @@ class GroupchatConfigWindow:
def on_affiliation_treeview_cursor_changed(self, widget, affiliation):
self.remove_button[affiliation].set_sensitive(True)
def affiliation_list_received(self, affiliation, list):
def affiliation_list_received(self, list):
'''Fill the affiliation treeview'''
self.list_init[affiliation] = list
if not affiliation:
return
tv = self.affiliation_treeview[affiliation]
model = tv.get_model()
for jid in list:
if list[jid].has_key('affiliation'):
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]
model = tv.get_model()
reason = ''
if list[jid].has_key('reason'):
reason = list[jid]['reason']
@ -2518,7 +2521,7 @@ class GroupchatConfigWindow:
role = ''
if list[jid].has_key('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):
del gajim.interface.instances[self.account]['gc_config'][self.room_jid]
@ -2527,7 +2530,7 @@ class GroupchatConfigWindow:
if self.form:
form = self.data_form_widget.data_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 = {}
actual_jid_list = []
model = self.affiliation_treeview[affiliation].get_model()

View File

@ -1373,11 +1373,11 @@ class Interface:
gc_control.print_conversation(change)
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]
if self.instances[account]['gc_config'].has_key(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):
#('GC_PASSWORD_REQUIRED', account, (room_jid, nick))