diff options
author | mathieui <mathieui@mathieui.net> | 2015-06-18 21:02:13 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-06-18 21:02:13 +0200 |
commit | 43ef5fd949b0c6632b0a4277a0d379a1e3b8f88c (patch) | |
tree | 1161e36d492e2e2d822df5940d1b5330f0e7f536 | |
parent | 5ae74e4c9321fc0a5474df790d931d5d794da563 (diff) | |
download | poezio-43ef5fd949b0c6632b0a4277a0d379a1e3b8f88c.tar.gz poezio-43ef5fd949b0c6632b0a4277a0d379a1e3b8f88c.tar.bz2 poezio-43ef5fd949b0c6632b0a4277a0d379a1e3b8f88c.tar.xz poezio-43ef5fd949b0c6632b0a4277a0d379a1e3b8f88c.zip |
Fix #3080 (show roster names instead of JIDs)
-rw-r--r-- | src/core/handlers.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/handlers.py b/src/core/handlers.py index 288de782..61be8467 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -862,10 +862,12 @@ def on_got_offline(self, presence): self.information('Unable to write in the log file', 'Error') # If a resource got offline, display the message in the conversation with this # precise resource. + contact = roster[jid.bare] + name = contact.name if contact and contact.name else jid.bare if jid.resource: - self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x191}offline' % (jid.full)) - self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x191}offline' % (jid.bare)) - self.information('\x193}%s \x195}is \x191}offline' % (jid.bare), 'Roster') + self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x191}offline' % name) + self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x191}offline' % name) + self.information('\x193}%s \x195}is \x191}offline' % name, 'Roster') roster.modified() if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() @@ -890,14 +892,15 @@ def on_got_online(self, presence): 'show': presence['show'], }) self.events.trigger('normal_presence', presence, resource) - self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x194}online' % (jid.full)) + name = contact.name if contact.name else jid.bare + self.add_information_message_to_conversation_tab(jid.full, '\x195}%s is \x194}online' % name) if time.time() - self.connection_time > 10: # We do not display messages if we recently logged in if presence['status']: - self.information("\x193}%s \x195}is \x194}online\x195} (\x19o%s\x195})" % (safeJID(resource.jid).bare, presence['status']), "Roster") + self.information("\x193}%s \x195}is \x194}online\x195} (\x19o%s\x195})" % (name, presence['status']), "Roster") else: - self.information("\x193}%s \x195}is \x194}online\x195}" % safeJID(resource.jid).bare, "Roster") - self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x194}online' % (jid.bare)) + self.information("\x193}%s \x195}is \x194}online\x195}" % name, "Roster") + self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x194}online' % name) if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() |