move function to get real_jid to gajim.py
This commit is contained in:
parent
433af985b1
commit
2720f1ce7c
|
@ -126,6 +126,18 @@ def get_room_and_nick_from_fjid(jid):
|
||||||
l.append('')
|
l.append('')
|
||||||
return l
|
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):
|
def get_room_from_fjid(jid):
|
||||||
return get_room_and_nick_from_fjid(jid)[0]
|
return get_room_and_nick_from_fjid(jid)[0]
|
||||||
|
|
||||||
|
|
|
@ -132,14 +132,8 @@ class TabbedChatWindow(chat.Chat):
|
||||||
'''we enter the eventbox area so we under conditions add a timeout
|
'''we enter the eventbox area so we under conditions add a timeout
|
||||||
to show a bigger avatar after 0.5 sec'''
|
to show a bigger avatar after 0.5 sec'''
|
||||||
jid = self.get_active_jid()
|
jid = self.get_active_jid()
|
||||||
real_jid = jid
|
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
|
||||||
# Is it a pm ? if it is we get the real jid
|
if not real_jid: # this can happend if we're in a moderate room
|
||||||
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:
|
|
||||||
return
|
return
|
||||||
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
|
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
|
||||||
avatar_w = avatar_pixbuf.get_width()
|
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
|
'''resizes the avatar, if needed, so it has at max half the screen size
|
||||||
and shows it'''
|
and shows it'''
|
||||||
jid = self.get_active_jid()
|
jid = self.get_active_jid()
|
||||||
real_jid = jid
|
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
|
||||||
# Is it a pm ? if it is we get the real jid
|
if not real_jid: # this can happend if we're in a moderate room
|
||||||
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:
|
|
||||||
return
|
return
|
||||||
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
|
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
|
||||||
screen_w = gtk.gdk.screen_width()
|
screen_w = gtk.gdk.screen_width()
|
||||||
|
@ -315,19 +303,12 @@ class TabbedChatWindow(chat.Chat):
|
||||||
# we assume contact has no avatar
|
# we assume contact has no avatar
|
||||||
scaled_buf = None
|
scaled_buf = None
|
||||||
|
|
||||||
real_jid = jid
|
real_jid = gajim.get_real_jid_from_fjid(self.account, 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
|
|
||||||
|
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
if real_jid:
|
if real_jid:
|
||||||
pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(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)
|
gajim.connections[self.account].request_vcard(jid_with_resource)
|
||||||
return
|
return
|
||||||
if pixbuf is not None:
|
if pixbuf is not None:
|
||||||
|
|
Loading…
Reference in New Issue