jids are now punycoded before we store avatars on HD. Fixes #1030

This commit is contained in:
Yann Leboulanger 2006-03-10 18:58:28 +00:00
parent f9d0421d33
commit adb62eb628
4 changed files with 12 additions and 5 deletions

View File

@ -324,8 +324,10 @@ class Connection:
# Save it to file
self.save_vcard_to_hd(who, card)
# Save the decoded avatar to a separate file too, and generate files for dbus notifications
puny_jid = punycode_encode(frm)
if photo_decoded:
avatar_file = os.path.join(gajim.AVATAR_PATH, frm + '_notif_size_colored.png')
avatar_file = os.path.join(gajim.AVATAR_PATH,
puny_jid + '_notif_size_colored.png')
if frm == our_jid and avatar_sha != self.vcard_sha:
gajim.interface.save_avatar_files(frm, photo_decoded)
elif frm != our_jid and (not os.path.exists(avatar_file) or \
@ -335,7 +337,7 @@ class Connection:
else:
for ext in ('.jpeg', '.png', '_notif_size_bw.png',
'_notif_size_colored.png'):
path = os.path.join(gajim.AVATAR_PATH, frm + ext)
path = os.path.join(gajim.AVATAR_PATH, puny_jid + ext)
if os.path.isfile(path):
os.remove(path)

View File

@ -99,6 +99,7 @@ import signal
import getopt
import time
import threading
from encodings.punycode import punycode_encode
import gtkgui_helpers
import notify
@ -964,7 +965,8 @@ class Interface:
def save_avatar_files(self, jid, photo_decoded):
'''Save the decoded avatar to a separate file, and generate files for dbus notifications'''
path_to_file = os.path.join(gajim.AVATAR_PATH, jid)
puny_jid = punycode_encode(jid)
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid)
# remove old avatars
for typ in ('jpeg', 'png'):
path_to_original_file = path_to_file + '.' + typ

View File

@ -491,7 +491,8 @@ def get_path_to_generic_or_avatar(generic, jid = None, suffix = None):
Returns full path to the avatar image if it exists,
otherwise returns full path to the image.'''
if jid:
path_to_file = os.path.join(gajim.AVATAR_PATH, jid) + suffix
puny_jid = punycode_encode(jid)
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + suffix
if os.path.exists(path_to_file):
return path_to_file
return os.path.abspath(generic)

View File

@ -29,6 +29,7 @@ import gobject
import os
import time
import locale
from encodings.punycode import punycode_encode
import gtkgui_helpers
import message_control
@ -518,7 +519,8 @@ class RosterTooltip(NotificationAreaTooltip):
info += '\n<span style="italic">%s</span>' % text
for type_ in ('jpeg', 'png'):
file = os.path.join(gajim.AVATAR_PATH, prim_contact.jid + '.' + type_)
puny_jid = punycode_encode(prim_contact.jid)
file = os.path.join(gajim.AVATAR_PATH, puny_jid + '.' + type_)
if os.path.exists(file):
self.avatar_image.set_from_file(file)
pix = self.avatar_image.get_pixbuf()