move function to get real_jid to gajim.py

This commit is contained in:
Yann Leboulanger 2005-11-02 08:12:54 +00:00
parent 433af985b1
commit 2720f1ce7c
2 changed files with 20 additions and 27 deletions

View File

@ -125,7 +125,19 @@ def get_room_and_nick_from_fjid(jid):
if len(l) == 1: # No nick
l.append('')
return l
def get_real_jid_from_fjid(account, fjid):
room_jid, nick = get_room_and_nick_from_fjid(fjid)
if not nick: # It's not a fake_jid, so it's not pm
return fjid
real_jid = fjid
gcs = interface.windows[account]['gc']
if gcs.has_key(room_jid):
# It's a pm, so if we have real jid it's in contact.jid
contact = gc_contacts[account][room_jid][nick]
real_jid = contact.jid
return real_jid
def get_room_from_fjid(jid):
return get_room_and_nick_from_fjid(jid)[0]

View File

@ -132,14 +132,8 @@ class TabbedChatWindow(chat.Chat):
'''we enter the eventbox area so we under conditions add a timeout
to show a bigger avatar after 0.5 sec'''
jid = self.get_active_jid()
real_jid = jid
# Is it a pm ? if it is we get the real jid
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
gcs = gajim.interface.windows[self.account]['gc']
if gcs.has_key(room_jid):
contact = gajim.gc_contacts[self.account][room_jid][nick]
real_jid = contact.jid
if not real_jid:
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
if not real_jid: # this can happend if we're in a moderate room
return
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
avatar_w = avatar_pixbuf.get_width()
@ -165,14 +159,8 @@ class TabbedChatWindow(chat.Chat):
'''resizes the avatar, if needed, so it has at max half the screen size
and shows it'''
jid = self.get_active_jid()
real_jid = jid
# Is it a pm ? if it is we get the real jid
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
gcs = gajim.interface.windows[self.account]['gc']
if gcs.has_key(room_jid):
contact = gajim.gc_contacts[self.account][room_jid][nick]
real_jid = contact.jid
if not real_jid:
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
if not real_jid: # this can happend if we're in a moderate room
return
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
screen_w = gtk.gdk.screen_width()
@ -315,19 +303,12 @@ class TabbedChatWindow(chat.Chat):
# we assume contact has no avatar
scaled_buf = None
real_jid = jid
# Is it a pm ? if it is we get the real jid
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
if nick:
gcs = gajim.interface.windows[self.account]['gc']
if gcs.has_key(room_jid):
contact = gajim.gc_contacts[self.account][room_jid][nick]
real_jid = contact.jid
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
pixbuf = None
if real_jid:
pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
if not real_jid or pixbuf == 'ask': # we don't have the vcard or it's too old
if not real_jid or pixbuf == 'ask':
# we don't have the vcard or it's pm and we don't have the real jid
gajim.connections[self.account].request_vcard(jid_with_resource)
return
if pixbuf is not None: