print resource in chat window only if several resources. fixes #3175

This commit is contained in:
Yann Leboulanger 2007-07-26 16:54:13 +00:00
parent 52fdd458d7
commit 9a851c3b0d
1 changed files with 21 additions and 23 deletions

View File

@ -1286,10 +1286,15 @@ class RosterWindow:
contact_instances = gajim.contacts.get_contacts(account, contact.jid) contact_instances = gajim.contacts.get_contacts(account, contact.jid)
contact.show = show contact.show = show
contact.status = status contact.status = status
# name is to show in conversation window
name = contact.get_shown_name()
if show in ('offline', 'error') and \ if show in ('offline', 'error') and \
len(gajim.events.get_events(account, contact.get_full_jid())) == 0: len(gajim.events.get_events(account, contact.get_full_jid())) == 0:
if len(contact_instances) > 1: if len(contact_instances) > 1:
# if multiple resources # if multiple resources
if contact.resource != '':
name += '/' + contact.resource
jid_with_resource = contact.jid + '/' + contact.resource jid_with_resource = contact.jid + '/' + contact.resource
if gajim.interface.msg_win_mgr.has_window(jid_with_resource, if gajim.interface.msg_win_mgr.has_window(jid_with_resource,
account): account):
@ -1299,33 +1304,26 @@ class RosterWindow:
ctrl.update_ui() ctrl.update_ui()
win.redraw_tab(ctrl) win.redraw_tab(ctrl)
gajim.contacts.remove_contact(account, contact) gajim.contacts.remove_contact(account, contact)
elif len(contact_instances) > 1 and contact.resource != '':
name += '/' + contact.resource
self.remove_contact(contact, account) self.remove_contact(contact, account)
self.add_contact_to_roster(contact.jid, account) self.add_contact_to_roster(contact.jid, account)
# print status in chat window and update status/GPG image # print status in chat window and update status/GPG image
jid_list = [contact.jid] if gajim.interface.msg_win_mgr.has_window(contact.jid, account):
for jid in jid_list: win = gajim.interface.msg_win_mgr.get_window(contact.jid, account)
if gajim.interface.msg_win_mgr.has_window(jid, account): ctrl = win.get_control(contact.jid, account)
win = gajim.interface.msg_win_mgr.get_window(jid, account) ctrl.contact = gajim.contacts.get_contact_with_highest_priority(
ctrl = win.get_control(jid, account) account, contact.jid)
ctrl.contact = gajim.contacts.get_contact_with_highest_priority( ctrl.update_ui()
account, contact.jid) win.redraw_tab(ctrl)
ctrl.update_ui()
win.redraw_tab(ctrl)
name = contact.get_shown_name() uf_show = helpers.get_uf_show(show)
if status:
# if multiple resources (or second one disconnecting) ctrl.print_conversation(_('%s is now %s (%s)') % (name, uf_show,
if (len(contact_instances) > 1 or (len(contact_instances) == 1 and \ status), 'status')
show in ('offline', 'error'))) and contact.resource != '': else: # No status message
name += '/' + contact.resource ctrl.print_conversation(_('%s is now %s') % (name, uf_show),
'status')
uf_show = helpers.get_uf_show(show)
if status:
ctrl.print_conversation(_('%s is now %s (%s)') % (name, uf_show,
status), 'status')
else: # No status message
ctrl.print_conversation(_('%s is now %s') % (name, uf_show),
'status')
if not contact.groups: if not contact.groups:
self.draw_group(_('General'), account) self.draw_group(_('General'), account)