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

View file

@ -99,6 +99,7 @@ import signal
import getopt import getopt
import time import time
import threading import threading
from encodings.punycode import punycode_encode
import gtkgui_helpers import gtkgui_helpers
import notify import notify
@ -964,7 +965,8 @@ class Interface:
def save_avatar_files(self, jid, photo_decoded): def save_avatar_files(self, jid, photo_decoded):
'''Save the decoded avatar to a separate file, and generate files for dbus notifications''' '''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 # remove old avatars
for typ in ('jpeg', 'png'): for typ in ('jpeg', 'png'):
path_to_original_file = path_to_file + '.' + typ 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, Returns full path to the avatar image if it exists,
otherwise returns full path to the image.''' otherwise returns full path to the image.'''
if jid: 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): if os.path.exists(path_to_file):
return path_to_file return path_to_file
return os.path.abspath(generic) return os.path.abspath(generic)

View file

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