we can now remove jid from affiliation lists (#530)

This commit is contained in:
Yann Leboulanger 2006-01-17 08:05:02 +00:00
parent ade2619d7c
commit cea64c05df
2 changed files with 14 additions and 6 deletions

View file

@ -2347,14 +2347,14 @@ class Connection:
item.addChild(name = 'reason', payload = reason) item.addChild(name = 'reason', payload = reason)
self.to_be_sent.append(iq) 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: 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 = \
common.xmpp.NS_MUC_ADMIN) common.xmpp.NS_MUC_ADMIN)
item = iq.getTag('query') item = iq.getTag('query')
for jid in list: 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) self.to_be_sent.append(iq)
def get_affiliation_list(self, room_jid, affiliation): def get_affiliation_list(self, room_jid, affiliation):

View file

@ -1847,6 +1847,7 @@ class GroupchatConfigWindow(DataFormWindow):
def __init__(self, account, room_jid, config): def __init__(self, account, room_jid, config):
DataFormWindow.__init__(self, account, config) DataFormWindow.__init__(self, account, config)
self.room_jid = room_jid self.room_jid = room_jid
self.removed_jid = []
# 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')
@ -1932,26 +1933,32 @@ class GroupchatConfigWindow(DataFormWindow):
return return
model = self.affiliation_treeview.get_model() model = self.affiliation_treeview.get_model()
model.append((jid,)) model.append((jid,))
if jid in self.removed_jid:
self.removed_jid.remove(jid)
def on_remove_button_clicked(self, widget): def on_remove_button_clicked(self, widget):
model, iter = self.affiliation_treeview.get_selection().get_selected() model, iter = self.affiliation_treeview.get_selection().get_selected()
if not iter: if not iter:
return return
jid = model[iter][0]
model.remove(iter) model.remove(iter)
self.removed_jid.append(jid)
self.remove_button.set_sensitive(False) 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() affiliation = self.get_active_affiliation()
if not affiliation: if not affiliation:
return return
list = [] list = {}
model = self.affiliation_treeview.get_model() model = self.affiliation_treeview.get_model()
iter = model.get_iter_first() iter = model.get_iter_first()
while iter: while iter:
list.append(model[iter][0]) list[model[iter][0]] = affiliation
iter = model.iter_next(iter) 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, gajim.connections[self.account].send_gc_affiliation_list(self.room_jid,
affiliation, list) list)
def on_affiliation_treeview_cursor_changed(self, widget): def on_affiliation_treeview_cursor_changed(self, widget):
self.remove_button.set_sensitive(True) self.remove_button.set_sensitive(True)
@ -1961,6 +1968,7 @@ class GroupchatConfigWindow(DataFormWindow):
tv.get_model().clear() tv.get_model().clear()
self.add_button.set_sensitive(False) self.add_button.set_sensitive(False)
self.remove_button.set_sensitive(False) self.remove_button.set_sensitive(False)
self.removed_jid = []
affiliation = self.get_active_affiliation() affiliation = self.get_active_affiliation()
if affiliation: if affiliation: