Update of /cvsroot/emacs-jabber/emacs-jabber
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv12421
Modified Files:
jabber-vcard-avatars.el
Log Message:
Revision: ma...@fr...--2005/emacs-jabber--cvs-head--0--patch-510
Creator: Magnus Henoch <ma...@fr...>
Don't fetch avatar from disk if it hasn't changed
Index: jabber-vcard-avatars.el
===================================================================
RCS file: /cvsroot/emacs-jabber/emacs-jabber/jabber-vcard-avatars.el,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- jabber-vcard-avatars.el 8 Aug 2007 11:59:01 -0000 1.10
+++ jabber-vcard-avatars.el 27 May 2008 01:12:21 -0000 1.11
@@ -1,6 +1,6 @@
;;; jabber-vcard-avatars.el --- Avatars by JEP-0153
-;; Copyright (C) 2006, 2007 Magnus Henoch
+;; Copyright (C) 2006, 2007, 2008 Magnus Henoch
;; Author: Magnus Henoch <ma...@fr...>
@@ -52,14 +52,19 @@
(let* ((from (jabber-jid-user (jabber-xml-get-attribute xml-data 'from)))
(photo (jabber-xml-path xml-data '(("vcard-temp:x:update" . "x") photo)))
(sha1-hash (car (jabber-xml-node-children photo))))
- (if (null sha1-hash)
- ;; User has removed avatar
- (jabber-avatar-set from nil)
- (if (jabber-avatar-find-cached sha1-hash)
- ;; Avatar is cached
- (jabber-avatar-set from sha1-hash)
- ;; Avatar is not cached; retrieve it
- (jabber-vcard-avatars-fetch jc from sha1-hash))))))
+ (cond
+ ((null sha1-hash)
+ ;; User has removed avatar
+ (jabber-avatar-set from nil))
+ ((string= sha1-hash (get (jabber-jid-symbol from) 'avatar-hash))
+ ;; Same avatar as before; do nothing
+ )
+ ((jabber-avatar-find-cached sha1-hash)
+ ;; Avatar is cached
+ (jabber-avatar-set from sha1-hash))
+ (t
+ ;; Avatar is not cached; retrieve it
+ (jabber-vcard-avatars-fetch jc from sha1-hash))))))
(defun jabber-vcard-avatars-fetch (jc who sha1-hash)
"Fetch WHO's vCard, and extract avatar."
|