show blocked contacts name striked and add [blocked] in tooltip. fixes #3129

This commit is contained in:
Yann Leboulanger 2007-04-25 17:09:07 +00:00
parent 550785233f
commit 1f7d9a39ed
2 changed files with 55 additions and 31 deletions

View File

@ -560,6 +560,8 @@ 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())
if jid in gajim.connections[account].blocked_contacts:
name = '<span strikethrough="true">%s</span>' % name
nb_connected_contact = 0 nb_connected_contact = 0
for c in contact_instances: for c in contact_instances:
@ -1315,6 +1317,7 @@ class RosterWindow:
if not connected_contacts: if not connected_contacts:
# no connected contacts, show the ofline one # no connected contacts, show the ofline one
connected_contacts = contacts connected_contacts = contacts
self.tooltip.account = account
self.tooltip.timeout = gobject.timeout_add(500, self.tooltip.timeout = gobject.timeout_add(500,
self.show_tooltip, connected_contacts) self.show_tooltip, connected_contacts)
elif model[iter][C_TYPE] == 'account': elif model[iter][C_TYPE] == 'account':
@ -1323,6 +1326,7 @@ class RosterWindow:
if account == 'all': if account == 'all':
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row self.tooltip.id = row
self.tooltip.account = None
self.tooltip.timeout = gobject.timeout_add(500, self.tooltip.timeout = gobject.timeout_add(500,
self.show_tooltip, []) self.show_tooltip, [])
return return
@ -1364,6 +1368,7 @@ class RosterWindow:
contacts.append(contact) contacts.append(contact)
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row self.tooltip.id = row
self.tooltip.account = None
self.tooltip.timeout = gobject.timeout_add(500, self.tooltip.timeout = gobject.timeout_add(500,
self.show_tooltip, contacts) self.show_tooltip, contacts)
@ -1437,44 +1442,47 @@ class RosterWindow:
new_rule = {'order': u'1', 'type': u'jid', 'action': u'deny', new_rule = {'order': u'1', 'type': u'jid', 'action': u'deny',
'value' : jid, 'child': [u'message', u'iq', u'presence-out']} 'value' : jid, '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_contact:
gajim.connections[account].blocked_contacts.append(jid)
self.draw_contact(jid, account)
else: else:
msg = self.get_status_message('offline') msg = self.get_status_message('offline')
if iter == None: if iter == None:
for (contact, account) in blockedlist: for (contact, account) in blockedlist:
if account not in accounts: if account not in accounts:
if gajim.connections[account].privacy_rules_supported: if not gajim.connections[account].privacy_rules_supported:
accounts.append(account) continue
self.send_status(account, 'offline', msg, to = contact.jid) accounts.append(account)
new_rule = {'order': u'1', 'type': u'jid', self.send_status(account, 'offline', msg, to = contact.jid)
'action': u'deny', 'value' : contact.jid, new_rule = {'order': u'1', 'type': u'jid',
'child': [u'message', u'iq', u'presence-out']} 'action': u'deny', 'value' : contact.jid,
gajim.connections[account].blocked_list.append(new_rule) 'child': [u'message', u'iq', u'presence-out']}
else: gajim.connections[account].blocked_list.append(new_rule)
self.send_status(account, 'offline', msg, to = contact.jid) # needed for draw_contact:
new_rule = {'order': u'1', 'type': u'jid', gajim.connections[account].blocked_contacts.append(contact.jid)
'action': u'deny', 'value' : contact.jid, self.draw_contact(contact.jid, account)
'child': [u'message', u'iq', u'presence-out']}
gajim.connections[account].blocked_list.append(new_rule)
else: else:
group = model[iter][C_JID].decode('utf-8') group = model[iter][C_JID].decode('utf-8')
msg = self.get_status_message('offline') msg = self.get_status_message('offline')
for (contact, account) in blockedlist: for (contact, account) in blockedlist:
if account not in accounts: if account not in accounts:
if gajim.connections[account].privacy_rules_supported: if not gajim.connections[account].privacy_rules_supported:
accounts.append(account) continue
self.send_status(account, 'offline', msg, to = contact.jid) accounts.append(account)
else: self.send_status(account, 'offline', msg, to = contact.jid)
self.send_status(account, 'offline', msg, to = contact.jid) # needed for draw_contact:
gajim.connections[account].blocked_contacts.append(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)
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)
if len(gajim.connections[account].blocked_list) == 1: if len(gajim.connections[account].blocked_list) == 1:
gajim.connections[account].set_active_list('block') gajim.connections[account].set_active_list('block')
gajim.connections[account].set_default_list('block') gajim.connections[account].set_default_list('block')
gajim.connections[account].get_privacy_list('block') gajim.connections[account].get_privacy_list('block')
def on_unblock(self, widget, iter, group_list): def on_unblock(self, widget, iter, group_list):
''' When clicked on the 'unblock' button in context menu. ''' ''' When clicked on the 'unblock' button in context menu. '''
@ -1487,8 +1495,12 @@ class RosterWindow:
gajim.connections[jid_account].new_blocked_list = [] gajim.connections[jid_account].new_blocked_list = []
for rule in gajim.connections[jid_account].blocked_list: for rule in gajim.connections[jid_account].blocked_list:
if rule['action'] != 'deny' or rule['type'] != 'jid' \ if rule['action'] != 'deny' or rule['type'] != 'jid' \
or rule['value'] != jid: or rule['value'] != jid:
gajim.connections[jid_account].new_blocked_list.append(rule) gajim.connections[jid_account].new_blocked_list.append(rule)
# needed for draw_contact:
if jid in gajim.connections[jid_account].blocked_contacts:
gajim.connections[jid_account].blocked_contacts.remove(jid)
self.draw_contact(jid, jid_account)
else: else:
if iter == None: if iter == None:
for (contact, account) in group_list: for (contact, account) in group_list:
@ -1500,6 +1512,11 @@ class RosterWindow:
gajim.connections[account].to_unblock.append(contact.jid) gajim.connections[account].to_unblock.append(contact.jid)
else: else:
gajim.connections[account].to_unblock.append(contact.jid) gajim.connections[account].to_unblock.append(contact.jid)
# needed for draw_contact:
if contact.jid in gajim.connections[account].blocked_contacts:
gajim.connections[account].blocked_contacts.remove(
contact.jid)
self.draw_contact(contact.jid, account)
for account in accounts: for account in accounts:
for rule in gajim.connections[account].blocked_list: for rule in gajim.connections[account].blocked_list:
if rule['action'] != 'deny' or rule['type'] != 'jid' \ if rule['action'] != 'deny' or rule['type'] != 'jid' \
@ -1514,8 +1531,14 @@ class RosterWindow:
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(rule) gajim.connections[account].new_blocked_list.append(
rule)
# needed for draw_contact:
if contact.jid in gajim.connections[account].blocked_contacts:
gajim.connections[account].blocked_contacts.remove(
contact.jid)
self.draw_contact(contact.jid, 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)
@ -1553,8 +1576,6 @@ class RosterWindow:
self.send_status(account, show, self.send_status(account, show,
gajim.connections[account].status, to = contact.jid) gajim.connections[account].status, to = contact.jid)
def on_rename(self, widget, iter, path): def on_rename(self, widget, iter, path):
# this function is called either by F2 or by Rename menuitem # this function is called either by F2 or by Rename menuitem
if gajim.interface.instances.has_key('rename'): if gajim.interface.instances.has_key('rename'):

View File

@ -409,6 +409,9 @@ class RosterTooltip(NotificationAreaTooltip):
name_markup = u'<span weight="bold">' + \ name_markup = u'<span weight="bold">' + \
gobject.markup_escape_text(prim_contact.get_shown_name())\ gobject.markup_escape_text(prim_contact.get_shown_name())\
+ '</span>' + '</span>'
if self.account and prim_contact.jid in gajim.connections[
self.account].blocked_contacts:
name_markup += u' [blocked]'
properties.append((name_markup, None)) properties.append((name_markup, None))
num_resources = 0 num_resources = 0