Author: asterix Date: 2006-11-28 16:40:08 +0100 (Tue, 28 Nov 2006) New Revision: 7557
Modified: trunk/src/common/connection_handlers.py trunk/src/gajim.py Log: remove avatar files when we publish a vcard without an avatar. see #2718
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2006-11-28 14:41:14 UTC (rev 7556) +++ trunk/src/common/connection_handlers.py 2006-11-28 15:40:08 UTC (rev 7557) @@ -940,15 +940,17 @@ iq.setID(id) self.connection.send(iq)
+ our_jid = gajim.get_jid_from_account(self.name) # Add the sha of the avatar if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \ vcard['PHOTO'].has_key('BINVAL'): photo = vcard['PHOTO']['BINVAL'] photo_decoded = base64.decodestring(photo) - our_jid = gajim.get_jid_from_account(self.name) gajim.interface.save_avatar_files(our_jid, photo_decoded) avatar_sha = sha.sha(photo_decoded).hexdigest() iq2.getTag('PHOTO').setTagData('SHA', avatar_sha) + else: + gajim.interface.remove_avatar_files(our_jid)
self.awaiting_answers[id] = (VCARD_PUBLISHED, iq2)
Modified: trunk/src/gajim.py =================================================================== --- trunk/src/gajim.py 2006-11-28 14:41:14 UTC (rev 7556) +++ trunk/src/gajim.py 2006-11-28 15:40:08 UTC (rev 7557) @@ -1196,6 +1196,16 @@ path_to_bw_file = path_to_file + '_notif_size_bw.png' bwbuf.save(path_to_bw_file, 'png')
+ def remove_avatar_files(self, jid): + '''remove avatar files of a jid''' + puny_jid = helpers.sanitize_filename(jid) + path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + for ext in ('.jpeg', '.png', '_notif_size_colored.png', + '_notif_size_bw.png'): + path_to_original_file = path_to_file + ext + if os.path.isfile(path_to_original_file): + os.remove(path_to_original_file) + def add_event(self, account, jid, type_, event_args): '''add an event to the gajim.events var''' # We add it to the gajim.events queue