draw contacts under a blocked group as striked

This commit is contained in:
Yann Leboulanger 2007-04-26 20:33:52 +00:00
parent 3176f6e1f5
commit 7cbd1e3a0c
2 changed files with 27 additions and 11 deletions

View File

@ -2365,16 +2365,17 @@ class BlockedContactsWindow:
gajim.interface.roster.draw_contact(jid, self.account) gajim.interface.roster.draw_contact(jid, self.account)
else: else:
group = deleted_rule['value'] group = deleted_rule['value']
# needed for draw_group:
if group in gajim.connections[self.account].blocked_groups:
gajim.connections[self.account].blocked_groups.remove(group)
gajim.interface.roster.draw_group(group, self.account)
for jid in gajim.contacts.get_jid_list(self.account): for jid in gajim.contacts.get_jid_list(self.account):
contact = gajim.contacts.get_contact_with_highest_priority( contact = gajim.contacts.get_contact_with_highest_priority(
self.account, jid) self.account, jid)
if group in contact.groups: if group in contact.groups:
gajim.connections[self.account].send_custom_status(show, msg, gajim.connections[self.account].send_custom_status(show, msg,
contact.jid) contact.jid)
# needed for draw_group: gajim.interface.roster.draw_contact(contact.jid, self.account)
if group in gajim.connections[self.account].blocked_groups:
gajim.connections[self.account].blocked_groups.remove(group)
gajim.interface.roster.draw_group(group, self.account)
def privacy_list_received(self, rules): def privacy_list_received(self, rules):
self.store.clear() self.store.clear()

View File

@ -562,7 +562,20 @@ class RosterWindow:
if not contact: if not contact:
return return
name = gobject.markup_escape_text(contact.get_shown_name()) name = gobject.markup_escape_text(contact.get_shown_name())
strike = False
if jid in gajim.connections[account].blocked_contacts: if jid in gajim.connections[account].blocked_contacts:
strike = True
else:
groups = contact.groups
if contact.is_observer():
groups = [_('Observers')]
elif not groups:
groups = [_('General')]
for group in groups:
if group in gajim.connections[account].blocked_groups:
strike = True
break
if strike:
name = '<span strikethrough="true">%s</span>' % name name = '<span strikethrough="true">%s</span>' % name
nb_connected_contact = 0 nb_connected_contact = 0
@ -1469,13 +1482,14 @@ class RosterWindow:
if not gajim.connections[account].privacy_rules_supported: if not gajim.connections[account].privacy_rules_supported:
continue continue
accounts.append(account) accounts.append(account)
# needed for draw_group:
gajim.connections[account].blocked_groups.append(group)
self.draw_group(group, account)
self.send_status(account, 'offline', msg, to=contact.jid) self.send_status(account, 'offline', msg, to=contact.jid)
self.draw_contact(contact.jid, account)
new_rule = {'order': u'1', 'type': u'group', 'action': u'deny', new_rule = {'order': u'1', 'type': u'group', 'action': u'deny',
'value' : group, 'child': [u'message', u'iq', u'presence-out']} 'value' : group, 'child': [u'message', u'iq', u'presence-out']}
gajim.connections[account].blocked_list.append(new_rule) gajim.connections[account].blocked_list.append(new_rule)
# needed for draw_group:
gajim.connections[account].blocked_groups.append(group)
self.draw_group(group, account)
for account in accounts: for account in accounts:
gajim.connections[account].set_privacy_list( gajim.connections[account].set_privacy_list(
'block', gajim.connections[account].blocked_list) 'block', gajim.connections[account].blocked_list)
@ -1528,16 +1542,17 @@ class RosterWindow:
if account not in accounts: if account not in accounts:
if gajim.connections[account].privacy_rules_supported: if gajim.connections[account].privacy_rules_supported:
accounts.append(account) accounts.append(account)
# needed for draw_group:
if group in gajim.connections[account].blocked_groups:
gajim.connections[account].blocked_groups.remove(group)
self.draw_group(group, account)
gajim.connections[account].new_blocked_list = [] gajim.connections[account].new_blocked_list = []
for rule in gajim.connections[account].blocked_list: for rule in gajim.connections[account].blocked_list:
if rule['action'] != 'deny' or rule['type'] != 'group' \ if rule['action'] != 'deny' or rule['type'] != 'group' \
or rule['value'] != group: or rule['value'] != group:
gajim.connections[account].new_blocked_list.append( gajim.connections[account].new_blocked_list.append(
rule) rule)
# needed for draw_group: self.draw_contact(contact.jid, account)
if group in gajim.connections[account].blocked_groups:
gajim.connections[account].blocked_groups.remove(group)
self.draw_group(group, account)
for account in accounts: for account in accounts:
gajim.connections[account].set_privacy_list( gajim.connections[account].set_privacy_list(
'block', gajim.connections[account].new_blocked_list) 'block', gajim.connections[account].new_blocked_list)