From: Magnus H. <leg...@us...> - 2007-08-08 10:59:25
|
Update of /cvsroot/emacs-jabber/emacs-jabber In directory sc8-pr-cvs17:/tmp/cvs-serv6480 Modified Files: jabber-vcard-avatars.el Log Message: Revision: ma...@fr...--2005/emacs-jabber--cvs-head--0--patch-378 Creator: Magnus Henoch <ma...@fr...> Display warning when we get the wrong avatar from a contact Index: jabber-vcard-avatars.el =================================================================== RCS file: /cvsroot/emacs-jabber/emacs-jabber/jabber-vcard-avatars.el,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- jabber-vcard-avatars.el 20 Feb 2007 14:13:40 -0000 1.8 +++ jabber-vcard-avatars.el 8 Aug 2007 10:58:51 -0000 1.9 @@ -1,6 +1,6 @@ ;;; jabber-vcard-avatars.el --- Avatars by JEP-0153 -;; Copyright (C) 2006 Magnus Henoch +;; Copyright (C) 2006, 2007 Magnus Henoch ;; Author: Magnus Henoch <ma...@fr...> @@ -59,26 +59,33 @@ ;; Avatar is cached (jabber-avatar-set from sha1-hash) ;; Avatar is not cached; retrieve it - (jabber-vcard-avatars-fetch jc from)))))) + (jabber-vcard-avatars-fetch jc from sha1-hash)))))) -(defun jabber-vcard-avatars-vcard (jc iq from) +(defun jabber-vcard-avatars-fetch (jc who sha1-hash) + "Fetch WHO's vCard, and extract avatar." + (interactive (list (jabber-read-account) + (jabber-read-jid-completing "Fetch whose vCard avatar: "))) + (jabber-send-iq jc who "get" '(vCard ((xmlns . "vcard-temp"))) + #'jabber-vcard-avatars-vcard (cons who sha1-hash) + #'ignore nil)) + +(defun jabber-vcard-avatars-vcard (jc iq closure) "Get the photo from the vCard, and set the avatar." - (let ((photo (assq 'PHOTO (jabber-vcard-parse (jabber-iq-query iq))))) + (let ((from (car closure)) + (sha1-hash (cdr closure)) + (photo (assq 'PHOTO (jabber-vcard-parse (jabber-iq-query iq))))) (if photo (let ((avatar (jabber-avatar-from-base64-string (nth 2 photo) (nth 1 photo)))) + (unless (string= sha1-hash (avatar-sha1-sum avatar)) + (message "%s's avatar should have SHA1 sum %s, but has %s" + (jabber-jid-displayname from) + sha1-hash + (avatar-sha1-sum avatar))) (jabber-avatar-cache avatar) (jabber-avatar-set from avatar)) (jabber-avatar-set from nil)))) -(defun jabber-vcard-avatars-fetch (jc who) - "Fetch WHO's vCard, and extract avatar." - (interactive (list (jabber-read-account) - (jabber-read-jid-completing "Fetch whose vCard avatar: "))) - (jabber-send-iq jc who "get" '(vCard ((xmlns . "vcard-temp"))) - #'jabber-vcard-avatars-vcard who - #'ignore nil)) - (add-hook 'jabber-post-connect-hooks 'jabber-vcard-avatars-find-current) (defun jabber-vcard-avatars-find-current (jc) "Request our own vCard, to find hash of avatar." |