Verify avatars'sha on hdd in muc too, don't send sha when disconnecting from muc

This commit is contained in:
Jean-Marie Traissard 2007-01-29 22:04:22 +00:00
parent b971afec24
commit f4d43979ed
2 changed files with 15 additions and 5 deletions

View File

@ -1170,10 +1170,10 @@ class Connection(ConnectionHandlers):
ptype = None
if show == 'offline':
ptype = 'unavailable'
show = helpers.get_xmpp_show(show)
xmpp_show = helpers.get_xmpp_show(show)
p = common.xmpp.Presence(to = '%s/%s' % (jid, nick), typ = ptype,
show = show, status = status)
if gajim.config.get('send_sha_in_gc_presence'):
show = xmpp_show, status = status)
if gajim.config.get('send_sha_in_gc_presence') and show != 'offline':
p = self.add_sha(p, ptype != 'unavailable')
# send instantly so when we go offline, status is sent to gc before we
# disconnect from jabber server

View File

@ -1669,12 +1669,22 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
# 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 self.vcard_shas.has_key(who): # Verify sha cached in mem
if avatar_sha != self.vcard_shas[who]:
# avatar has been updated
self.request_vcard(who, True)
else:
else: # Verify sha cached in hdd
self.vcard_shas[who] = avatar_sha
cached_vcard = self.get_cached_vcard(who, True)
if cached_vcard and cached_vcard.has_key('PHOTO') and \
cached_vcard['PHOTO'].has_key('SHA'):
cached_sha = cached_vcard['PHOTO']['SHA']
else:
cached_sha = ''
if cached_sha != self.vcard_shas[who]:
# avatar has been updated
self.request_vcard(who)
self.vcard_shas[who] = avatar_sha
self.dispatch('GC_NOTIFY', (jid_stripped, show, status, resource,
prs.getRole(), prs.getAffiliation(), prs.getJid(),
prs.getReason(), prs.getActor(), prs.getStatusCode(),