Make history window work even if we don't have roster.

This commit is contained in:
Jean-Marie Traissard 2008-03-13 02:12:25 +00:00
parent 67f69fe688
commit 49dcc089a7
1 changed files with 25 additions and 15 deletions

View File

@ -326,6 +326,7 @@ class HistoryWindow:
tag_name = 'incoming' tag_name = 'incoming'
elif kind in (constants.KIND_SINGLE_MSG_RECV, elif kind in (constants.KIND_SINGLE_MSG_RECV,
constants.KIND_CHAT_MSG_RECV): constants.KIND_CHAT_MSG_RECV):
if self.account:
contact = gajim.contacts.get_first_contact_from_jid(self.account, contact = gajim.contacts.get_first_contact_from_jid(self.account,
self.jid) self.jid)
if contact: if contact:
@ -334,17 +335,26 @@ class HistoryWindow:
else: else:
room_jid, nick = gajim.get_room_and_nick_from_fjid(self.jid) room_jid, nick = gajim.get_room_and_nick_from_fjid(self.jid)
# do we have him as gc_contact? # do we have him as gc_contact?
gc_contact = gajim.contacts.get_gc_contact(self.account, room_jid, gc_contact = gajim.contacts.get_gc_contact(self.account,
nick) room_jid, nick)
if gc_contact: if gc_contact:
# so yes, it's pm! # so yes, it's pm!
contact_name = nick contact_name = nick
else: else:
contact_name = self.jid.split('@')[0] contact_name = self.jid.split('@')[0]
else:
# we don't have roster
contact_name = self.jid.split('@')[0]
tag_name = 'incoming' tag_name = 'incoming'
elif kind in (constants.KIND_SINGLE_MSG_SENT, elif kind in (constants.KIND_SINGLE_MSG_SENT,
constants.KIND_CHAT_MSG_SENT): constants.KIND_CHAT_MSG_SENT):
if self.account:
contact_name = gajim.nicks[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' tag_name = 'outgoing'
elif kind == constants.KIND_GCSTATUS: elif kind == constants.KIND_GCSTATUS:
# message here (if not None) is status message # message here (if not None) is status message