remove gc contact avatar when he removes his avatar. see #2718

This commit is contained in:
Yann Leboulanger 2006-11-28 16:41:31 +00:00
parent e9db205110
commit ac4fab231c
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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