From 49dcc089a73c355edf7169308113e73cfdea96da Mon Sep 17 00:00:00 2001 From: Jean-Marie Traissard Date: Thu, 13 Mar 2008 02:12:25 +0000 Subject: [PATCH] Make history window work even if we don't have roster. --- src/history_window.py | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/history_window.py b/src/history_window.py index 9366b7df2..aaed11c1b 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -326,25 +326,35 @@ class HistoryWindow: tag_name = 'incoming' elif kind in (constants.KIND_SINGLE_MSG_RECV, constants.KIND_CHAT_MSG_RECV): - contact = gajim.contacts.get_first_contact_from_jid(self.account, - self.jid) - if contact: - # he is in our roster, use the name - contact_name = contact.get_shown_name() - else: - room_jid, nick = gajim.get_room_and_nick_from_fjid(self.jid) - # do we have him as gc_contact? - gc_contact = gajim.contacts.get_gc_contact(self.account, room_jid, - nick) - if gc_contact: - # so yes, it's pm! - contact_name = nick + if self.account: + contact = gajim.contacts.get_first_contact_from_jid(self.account, + self.jid) + if contact: + # he is in our roster, use the name + contact_name = contact.get_shown_name() else: - contact_name = self.jid.split('@')[0] + room_jid, nick = gajim.get_room_and_nick_from_fjid(self.jid) + # do we have him as gc_contact? + gc_contact = gajim.contacts.get_gc_contact(self.account, + room_jid, nick) + if gc_contact: + # so yes, it's pm! + contact_name = nick + else: + contact_name = self.jid.split('@')[0] + else: + # we don't have roster + contact_name = self.jid.split('@')[0] tag_name = 'incoming' elif kind in (constants.KIND_SINGLE_MSG_SENT, constants.KIND_CHAT_MSG_SENT): - contact_name = gajim.nicks[self.account] + if self.account: + contact_name = gajim.nicks[self.account] + else: + # we don't have roster, we don't know our own nick, use first + # account one (urk!) + account = gajim.contacts.get_accounts()[0] + contact_name = gajim.nicks[account] tag_name = 'outgoing' elif kind == constants.KIND_GCSTATUS: # message here (if not None) is status message