From cea64c05df699c49e2db57db1312bfaca1753240 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 17 Jan 2006 08:05:02 +0000 Subject: [PATCH] we can now remove jid from affiliation lists (#530) --- src/common/connection.py | 4 ++-- src/config.py | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 0c8c4554f..878135688 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -2347,14 +2347,14 @@ class Connection: item.addChild(name = 'reason', payload = reason) self.to_be_sent.append(iq) - def send_gc_affiliation_list(self, room_jid, affiliation, list): + def send_gc_affiliation_list(self, room_jid, list): if not self.connection: return iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS = \ common.xmpp.NS_MUC_ADMIN) item = iq.getTag('query') for jid in list: - item.addChild('item', {'jid': jid, 'affiliation': affiliation}) + item.addChild('item', {'jid': jid, 'affiliation': list[jid]}) self.to_be_sent.append(iq) def get_affiliation_list(self, room_jid, affiliation): diff --git a/src/config.py b/src/config.py index 2f2de75a4..cbba0279d 100644 --- a/src/config.py +++ b/src/config.py @@ -1847,6 +1847,7 @@ class GroupchatConfigWindow(DataFormWindow): def __init__(self, account, room_jid, config): DataFormWindow.__init__(self, account, config) self.room_jid = room_jid + self.removed_jid = [] # Draw the edit affiliation list things add_on_vbox = self.xml.get_widget('add_on_vbox') @@ -1932,26 +1933,32 @@ class GroupchatConfigWindow(DataFormWindow): return model = self.affiliation_treeview.get_model() model.append((jid,)) + if jid in self.removed_jid: + self.removed_jid.remove(jid) def on_remove_button_clicked(self, widget): model, iter = self.affiliation_treeview.get_selection().get_selected() if not iter: return + jid = model[iter][0] model.remove(iter) + self.removed_jid.append(jid) self.remove_button.set_sensitive(False) - def on_save_button_clicked(self, widget): + def on_save_button_clicked(self, widget): affiliation = self.get_active_affiliation() if not affiliation: return - list = [] + list = {} model = self.affiliation_treeview.get_model() iter = model.get_iter_first() while iter: - list.append(model[iter][0]) + list[model[iter][0]] = affiliation iter = model.iter_next(iter) + for jid in self.removed_jid: + list[jid] = 'none' gajim.connections[self.account].send_gc_affiliation_list(self.room_jid, - affiliation, list) + list) def on_affiliation_treeview_cursor_changed(self, widget): self.remove_button.set_sensitive(True) @@ -1961,6 +1968,7 @@ class GroupchatConfigWindow(DataFormWindow): tv.get_model().clear() self.add_button.set_sensitive(False) self.remove_button.set_sensitive(False) + self.removed_jid = [] affiliation = self.get_active_affiliation() if affiliation: