support XEP-0016 (privacy lists) "block all" feature. Fixes #4552

This commit is contained in:
Yann Leboulanger 2009-10-16 15:58:21 +02:00
parent 43f87899f8
commit 2472a9556d
2 changed files with 70 additions and 31 deletions

View File

@ -165,6 +165,7 @@
<property name="visible">True</property> <property name="visible">True</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property>
<property name="padding">5</property> <property name="padding">5</property>
</packing> </packing>
</child> </child>
@ -422,6 +423,19 @@ to</property>
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkCheckButton" id="edit_all_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">All (including subscription)</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_edit_all_checkbutton_toggled"/>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="position">2</property> <property name="position">2</property>

View File

@ -3066,20 +3066,20 @@ class PrivacyListWindow:
# Add Widgets # Add Widgets
for widget_to_add in ('title_hbox', 'privacy_lists_title_label', for widget_to_add in ('title_hbox', 'privacy_lists_title_label',
'list_of_rules_label', 'add_edit_rule_label', 'delete_open_buttons_hbox', 'list_of_rules_label', 'add_edit_rule_label', 'delete_open_buttons_hbox',
'privacy_list_active_checkbutton', 'privacy_list_default_checkbutton', 'privacy_list_active_checkbutton', 'privacy_list_default_checkbutton',
'list_of_rules_combobox', 'delete_open_buttons_hbox', 'list_of_rules_combobox', 'delete_open_buttons_hbox',
'delete_rule_button', 'open_rule_button', 'edit_allow_radiobutton', 'delete_rule_button', 'open_rule_button', 'edit_allow_radiobutton',
'edit_deny_radiobutton', 'edit_type_jabberid_radiobutton', 'edit_deny_radiobutton', 'edit_type_jabberid_radiobutton',
'edit_type_jabberid_entry', 'edit_type_group_radiobutton', 'edit_type_jabberid_entry', 'edit_type_group_radiobutton',
'edit_type_group_combobox', 'edit_type_subscription_radiobutton', 'edit_type_group_combobox', 'edit_type_subscription_radiobutton',
'edit_type_subscription_combobox', 'edit_type_select_all_radiobutton', 'edit_type_subscription_combobox', 'edit_type_select_all_radiobutton',
'edit_queries_send_checkbutton', 'edit_send_messages_checkbutton', 'edit_queries_send_checkbutton', 'edit_send_messages_checkbutton',
'edit_view_status_checkbutton', 'edit_order_spinbutton', 'edit_view_status_checkbutton', 'edit_all_checkbutton',
'new_rule_button', 'save_rule_button', 'privacy_list_refresh_button', 'edit_order_spinbutton', 'new_rule_button', 'save_rule_button',
'privacy_list_close_button', 'edit_send_status_checkbutton', 'privacy_list_refresh_button', 'privacy_list_close_button',
'add_edit_vbox', 'privacy_list_active_checkbutton', 'edit_send_status_checkbutton', 'add_edit_vbox',
'privacy_list_default_checkbutton'): 'privacy_list_active_checkbutton', 'privacy_list_default_checkbutton'):
self.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add) self.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add)
self.privacy_lists_title_label.set_label( self.privacy_lists_title_label.set_label(
@ -3144,12 +3144,12 @@ class PrivacyListWindow:
for rule in rules: for rule in rules:
if 'type' in rule: if 'type' in rule:
text_item = _('Order: %(order)s, action: %(action)s, type: %(type)s' text_item = _('Order: %(order)s, action: %(action)s, type: %(type)s'
', value: %(value)s') % {'order': rule['order'], ', value: %(value)s') % {'order': rule['order'],
'action': rule['action'], 'type': rule['type'], 'action': rule['action'], 'type': rule['type'],
'value': rule['value']} 'value': rule['value']}
else: else:
text_item = _('Order: %(order)s, action: %(action)s') % \ text_item = _('Order: %(order)s, action: %(action)s') % \
{'order': rule['order'], 'action': rule['action']} {'order': rule['order'], 'action': rule['action']}
self.global_rules[text_item] = rule self.global_rules[text_item] = rule
self.list_of_rules_combobox.append_text(text_item) self.list_of_rules_combobox.append_text(text_item)
if len(rules) == 0: if len(rules) == 0:
@ -3230,14 +3230,17 @@ class PrivacyListWindow:
self.edit_queries_send_checkbutton.set_active(False) self.edit_queries_send_checkbutton.set_active(False)
self.edit_view_status_checkbutton.set_active(False) self.edit_view_status_checkbutton.set_active(False)
self.edit_send_status_checkbutton.set_active(False) self.edit_send_status_checkbutton.set_active(False)
for child in rule_info['child']: self.edit_all_checkbutton.set_active(False)
if child == 'presence-out': if not rule_info['child']:
self.edit_all_checkbutton.set_active(True)
else:
if 'presence-out' in rule_info['child']:
self.edit_send_status_checkbutton.set_active(True) self.edit_send_status_checkbutton.set_active(True)
elif child == 'presence-in': if 'presence-in' in rule_info['child']:
self.edit_view_status_checkbutton.set_active(True) self.edit_view_status_checkbutton.set_active(True)
elif child == 'iq': if 'iq' in rule_info['child']:
self.edit_queries_send_checkbutton.set_active(True) self.edit_queries_send_checkbutton.set_active(True)
elif child == 'message': if 'message' in rule_info['child']:
self.edit_send_messages_checkbutton.set_active(True) self.edit_send_messages_checkbutton.set_active(True)
if rule_info['action'] == 'allow': if rule_info['action'] == 'allow':
@ -3246,6 +3249,26 @@ class PrivacyListWindow:
self.edit_deny_radiobutton.set_active(True) self.edit_deny_radiobutton.set_active(True)
self.add_edit_vbox.show() self.add_edit_vbox.show()
def on_edit_all_checkbutton_toggled(self, widget):
if widget.get_active():
self.edit_send_messages_checkbutton.set_active(True)
self.edit_queries_send_checkbutton.set_active(True)
self.edit_view_status_checkbutton.set_active(True)
self.edit_send_status_checkbutton.set_active(True)
self.edit_send_messages_checkbutton.set_sensitive(False)
self.edit_queries_send_checkbutton.set_sensitive(False)
self.edit_view_status_checkbutton.set_sensitive(False)
self.edit_send_status_checkbutton.set_sensitive(False)
else:
self.edit_send_messages_checkbutton.set_active(False)
self.edit_queries_send_checkbutton.set_active(False)
self.edit_view_status_checkbutton.set_active(False)
self.edit_send_status_checkbutton.set_active(False)
self.edit_send_messages_checkbutton.set_sensitive(True)
self.edit_queries_send_checkbutton.set_sensitive(True)
self.edit_view_status_checkbutton.set_sensitive(True)
self.edit_send_status_checkbutton.set_sensitive(True)
def on_privacy_list_active_checkbutton_toggled(self, widget): def on_privacy_list_active_checkbutton_toggled(self, widget):
if widget.get_active(): if widget.get_active():
gajim.connections[self.account].set_active_list( gajim.connections[self.account].set_active_list(
@ -3273,6 +3296,7 @@ class PrivacyListWindow:
self.edit_queries_send_checkbutton.set_active(False) self.edit_queries_send_checkbutton.set_active(False)
self.edit_view_status_checkbutton.set_active(False) self.edit_view_status_checkbutton.set_active(False)
self.edit_send_status_checkbutton.set_active(False) self.edit_send_status_checkbutton.set_active(False)
self.edit_all_checkbutton.set_active(False)
self.edit_order_spinbutton.set_value(1) self.edit_order_spinbutton.set_value(1)
self.edit_type_group_combobox.set_active(0) self.edit_type_group_combobox.set_active(0)
self.edit_type_subscription_combobox.set_active(0) self.edit_type_subscription_combobox.set_active(0)
@ -3299,14 +3323,15 @@ class PrivacyListWindow:
else: else:
edit_deny = 'deny' edit_deny = 'deny'
child = [] child = []
if self.edit_send_messages_checkbutton.get_active(): if not self.edit_all_checkbutton.get_active():
child.append('message') if self.edit_send_messages_checkbutton.get_active():
if self.edit_queries_send_checkbutton.get_active(): child.append('message')
child.append('iq') if self.edit_queries_send_checkbutton.get_active():
if self.edit_send_status_checkbutton.get_active(): child.append('iq')
child.append('presence-out') if self.edit_send_status_checkbutton.get_active():
if self.edit_view_status_checkbutton.get_active(): child.append('presence-out')
child.append('presence-in') if self.edit_view_status_checkbutton.get_active():
child.append('presence-in')
if edit_type != '': if edit_type != '':
return {'order': edit_order, 'action': edit_deny, return {'order': edit_order, 'action': edit_deny,
'type': edit_type, 'value': edit_value, 'child': child} 'type': edit_type, 'value': edit_value, 'child': child}