From 97430552cbdfcca4a472a41a95e76714b62f87f9 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 30 May 2006 11:41:58 +0000 Subject: [PATCH] rename vcard / avatar files when a gc contact changes his nick. Fixes #1914 --- src/groupchat_control.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 587d9973a..e6329e797 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -823,6 +823,22 @@ class GroupchatControl(ChatControlBase): # after that, but that doesn't hurt self.add_contact_to_roster(new_nick, show, role, affiliation, status, jid) + # rename vcard / avatar + puny_jid = helpers.sanitize_filename(self.room_jid) + puny_nick = helpers.sanitize_filename(nick) + puny_new_nick = helpers.sanitize_filename(new_nick) + old_path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) + new_path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_new_nick) + files = {old_path: new_path} + path = os.path.join(gajim.AVATAR_PATH, puny_jid) + # possible extensions + for ext in ('.png', '.jpeg', '_notif_size_bw.png', + '_notif_size_colored.png'): + files[os.path.join(path, puny_nick + ext)] = \ + os.path.join(path, puny_new_nick + ext) + for old_file in files: + if os.path.exists(old_file): + os.rename(old_file, files[old_file]) self.print_conversation(s, 'info') if not gajim.awaiting_events[self.account].has_key(self.room_jid + '/' + nick):