we can now remove jid from affiliation lists (#530)
This commit is contained in:
parent
ade2619d7c
commit
cea64c05df
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue