From ac4fab231c1582216d0fd43bd824ce563d0c2bde Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Tue, 28 Nov 2006 16:41:31 +0000 Subject: [PATCH] remove gc contact avatar when he removes his avatar. see #2718 --- src/common/connection_handlers.py | 6 +++++- src/gajim.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 050884558e..2dfd97f1e5 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1621,7 +1621,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, # we know real jid, save it in db st += ' (%s)' % jid gajim.logger.write('gcstatus', who, st, show) - if avatar_sha: + if avatar_sha or avatar_sha == '': + if avatar_sha == '': + # contact has no avatar + puny_nick = helpers.sanitize_filename(resource) + gajim.interface.remove_avatar_files(jid_stripped, puny_nick) if self.vcard_shas.has_key(who): if avatar_sha != self.vcard_shas[who]: # avatar has been updated diff --git a/src/gajim.py b/src/gajim.py index cdc8af0a50..48aba65d70 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1196,10 +1196,12 @@ class Interface: path_to_bw_file = path_to_file + '_notif_size_bw.png' bwbuf.save(path_to_bw_file, 'png') - def remove_avatar_files(self, jid): + def remove_avatar_files(self, jid, puny_nick = None): '''remove avatar files of a jid''' puny_jid = helpers.sanitize_filename(jid) path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + if puny_nick: + path_to_file = os.path.join(path_to_file, puny_nick) for ext in ('.jpeg', '.png', '_notif_size_colored.png', '_notif_size_bw.png'): path_to_original_file = path_to_file + ext -- GitLab