We can now see affiliation list (ban, admin, ...), edit it will come (beginning of #530)

This commit is contained in:
Yann Leboulanger 2006-01-16 11:16:06 +00:00
parent ded0b38723
commit 864b82e9e4
4 changed files with 19124 additions and 18985 deletions

View File

@ -1313,6 +1313,18 @@ class Connection:
dic = self.parse_data_form(node)
self.dispatch('GC_CONFIG', (self.get_full_jid(iq_obj), dic))
def _MucAdminCB(self, con, iq_obj):
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'):
affiliation = item.getAttr('affiliation')
list.append(item.getAttr('jid'))
self.dispatch('GC_AFFILIATION', (self.get_full_jid(iq_obj), affiliation, list))
def _MucErrorCB(self, con, iq_obj):
gajim.log.debug('MucErrorCB')
jid = self.get_full_jid(iq_obj)
@ -1740,6 +1752,8 @@ class Connection:
common.xmpp.NS_VERSION)
con.RegisterHandler('iq', self._MucOwnerCB, 'result',
common.xmpp.NS_MUC_OWNER)
con.RegisterHandler('iq', self._MucAdminCB, 'result',
common.xmpp.NS_MUC_ADMIN)
con.RegisterHandler('iq', self._getRosterCB, 'result',
common.xmpp.NS_ROSTER)
con.RegisterHandler('iq', self._PrivateCB, 'result',
@ -2333,6 +2347,25 @@ class Connection:
item.addChild(name = 'reason', payload = reason)
self.to_be_sent.append(iq)
def send_gc_affiliation_list(self, room_jid, affiliation, 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})
self.to_be_sent.append(iq)
def get_affiliation_list(self, room_jid, affiliation):
if not self.connection:
return
iq = common.xmpp.Iq(typ = 'get', to = room_jid, queryNS = \
common.xmpp.NS_MUC_ADMIN)
item = iq.getTag('query').setTag('item')
item.setAttr('affiliation', affiliation)
self.to_be_sent.append(iq)
def build_data_from_dict(self, query, config):
x = query.setTag(common.xmpp.NS_DATA + ' x', attrs = {'type': 'submit'})
i = 0

View File

@ -1842,6 +1842,78 @@ class ServiceRegistrationWindow(DataFormWindow):
self.xml.signal_autoconnect(self)
self.window.show_all()
class GroupchatConfigWindow(DataFormWindow):
'''GroupchatConfigWindow class'''
def __init__(self, account, room_jid, config):
DataFormWindow.__init__(self, account, config)
self.room_jid = room_jid
# Draw the edit affiliation list things
add_on_vbox = self.xml.get_widget('add_on_vbox')
hbox = gtk.HBox(spacing = 5)
add_on_vbox.pack_start(hbox, False)
label = gtk.Label('Edit affiliation list:')
hbox.pack_start(label, False)
liststore = gtk.ListStore(str, str)
self.affiliation_combobox = gtk.ComboBox(liststore)
cell = gtk.CellRendererText()
self.affiliation_combobox.pack_start(cell, True)
self.affiliation_combobox.add_attribute(cell, 'text', 0)
liststore.append(('', ''))
liststore.append((_('Ban List'), 'outcast'))
liststore.append((_('Member List'), 'member'))
liststore.append((_('Owner List'), 'owner'))
liststore.append((_('Admin List'), 'admin'))
self.affiliation_combobox.connect('changed', self.on_affiliation_combobox_changed)
hbox.pack_start(self.affiliation_combobox, False)
liststore = gtk.ListStore(str)
self.affiliation_treeview = gtk.TreeView(liststore)
self.affiliation_treeview.set_header_visible(False)
renderer = gtk.CellRendererText()
col = gtk.TreeViewColumn(_('JID'), renderer)
col.add_attribute(renderer, 'text', 0)
self.affiliation_treeview.append_column(col)
sc = gtk.ScrolledWindow()
sc.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
sc.add(self.affiliation_treeview)
add_on_vbox.pack_start(sc)
add_on_vbox.show_all()
def get_active_affiliation(self):
model = self.affiliation_combobox.get_model()
active_iter = self.affiliation_combobox.get_active()
if active_iter < 0:
return None
return model[active_iter][1]
def on_affiliation_combobox_changed(self, combobox):
tv = self.affiliation_treeview
tv.get_model().clear()
affiliation = self.get_active_affiliation()
if affiliation:
gajim.connections[self.account].get_affiliation_list(self.room_jid,
affiliation)
def affiliation_list_received(self, affiliation, list):
'''Fill the affiliation treeview'''
if affiliation != self.get_active_affiliation():
return
tv = self.affiliation_treeview
model = tv.get_model()
for jid in list:
model.append((jid,))
def on_data_form_window_destroy(self, widget):
del gajim.interface.instances[self.account]['gc_config'][self.room_jid]
def on_apply_button_clicked(self, widget):
gajim.connections[self.account].send_gc_config(self.room_jid, self.config)
self.window.destroy()
#---------- ManageEmoticonsWindow class -------------#
class ManageEmoticonsWindow:
@ -2035,19 +2107,6 @@ class ManageEmoticonsWindow:
if event.keyval == gtk.keysyms.Delete:
self.on_button_remove_emoticon_clicked(widget)
class GroupchatConfigWindow(DataFormWindow):
'''GroupchatConfigWindow class'''
def __init__(self, account, room_jid, config):
DataFormWindow.__init__(self, account, config)
self.room_jid = room_jid
def on_data_form_window_destroy(self, widget):
del gajim.interface.instances[self.account]['gc_config'][self.room_jid]
def on_apply_button_clicked(self, widget):
gajim.connections[self.account].send_gc_config(self.room_jid, self.config)
self.window.destroy()
#---------- RemoveAccountWindow class -------------#
class RemoveAccountWindow:
'''ask for removing from gajim only or from gajim and server too

View File

@ -786,6 +786,13 @@ class Interface:
self.instances[account]['gc_config'][jid] = \
config.GroupchatConfigWindow(account, jid, array[1])
def handle_event_gc_affiliation(self, account, array):
#('GC_AFFILIATION', account, (room_jid, affiliation, 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])
def handle_event_gc_invitation(self, account, array):
#('GC_INVITATION', (room_jid, jid_from, reason, password))
dialogs.InvitationReceivedDialog(account, array[0], array[1],
@ -1245,6 +1252,7 @@ class Interface:
'GC_SUBJECT': self.handle_event_gc_subject,
'GC_CONFIG': self.handle_event_gc_config,
'GC_INVITATION': self.handle_event_gc_invitation,
'GC_AFFILIATION': self.handle_event_gc_affiliation,
'BAD_PASSPHRASE': self.handle_event_bad_passphrase,
'ROSTER_INFO': self.handle_event_roster_info,
'BOOKMARKS': self.handle_event_bookmarks,

View File

@ -11101,7 +11101,13 @@ Static</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkVBox" id="vbox110">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkTable" id="config_table">
@ -11155,6 +11161,42 @@ Static</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator14">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="add_on_vbox">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
@ -16953,7 +16995,6 @@ Maybe I'll refactor later</property>
<accessibility>
<atkproperty name="AtkObject::accessible_name" translatable="yes">Remove file transfer from the list.</atkproperty>
<atkproperty name="AtkObject::accessible_description" translatable="yes">This action removes single file transfer from the list. If the transfer is active, it is first stopped and then removed</atkproperty>
<atkaction action_name="click" description="Removing selected file transfer"/>
</accessibility>
<signal name="clicked" handler="on_cleanup_button_clicked" last_modification_time="Sat, 03 Sep 2005 14:03:13 GMT"/>
@ -17113,7 +17154,6 @@ Maybe I'll refactor later</property>
<accessibility>
<atkproperty name="AtkObject::accessible_name" translatable="yes">Cancel file transfer</atkproperty>
<atkproperty name="AtkObject::accessible_description" translatable="yes">Cancels the selected file transfer</atkproperty>
<atkaction action_name="click" description="Stoping selected file transfer"/>
</accessibility>
<signal name="clicked" handler="on_cancel_button_clicked" last_modification_time="Tue, 09 Aug 2005 17:07:31 GMT"/>
</widget>
@ -17155,7 +17195,6 @@ Maybe I'll refactor later</property>
<property name="draw_indicator">True</property>
<accessibility>
<atkproperty name="AtkObject::accessible_description" translatable="yes">When a file transfer is complete show a popup notification</atkproperty>
<atkaction action_name="press" description="Activate/Disable notification for when a file transfer is complete"/>
</accessibility>
<signal name="toggled" handler="on_notify_ft_complete_checkbox_toggled" last_modification_time="Wed, 31 Aug 2005 22:52:01 GMT"/>
</widget>