annotate lisp/gnus/gravatar.el @ 112278:ef719132ddfa

Nuke arch-tags.
author Glenn Morris <rgm@gnu.org>
date Sat, 15 Jan 2011 15:16:57 -0800
parents b1eac6d41a93
children 98ad7c9e56a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
1 ;;; gravatar.el --- Get Gravatars
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
2
112235
b1eac6d41a93 [Gnus] Update copyright years.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111994
diff changeset
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
4
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
5 ;; Author: Julien Danjou <julien@danjou.info>
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
6 ;; Keywords: news
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
7
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
9
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
13 ;; (at your option) any later version.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
14
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
19
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
22
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
23 ;;; Commentary:
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
24
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
25 ;;; Code:
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
26
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
27 (require 'url)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
28 (require 'url-cache)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
29
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
30 (defgroup gravatar nil
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
31 "Gravatar."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
32 :group 'comm)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
33
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
34 (defcustom gravatar-automatic-caching t
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
35 "Whether cache retrieved gravatar."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
36 :group 'gravatar)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
37
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
38 (defcustom gravatar-cache-ttl (days-to-time 30)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
39 "Time to live for gravatar cache entries."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
40 :group 'gravatar)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
41
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
42 (defcustom gravatar-rating "g"
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
43 "Default rating for gravatar."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
44 :group 'gravatar)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
45
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
46 (defcustom gravatar-size 32
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
47 "Default size in pixels for gravatars."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
48 :group 'gravatar)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
49
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
50 (defconst gravatar-base-url
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
51 "http://www.gravatar.com/avatar"
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
52 "Base URL for getting gravatars.")
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
53
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
54 (defun gravatar-hash (mail-address)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
55 "Create an hash from MAIL-ADDRESS."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
56 (md5 (downcase mail-address)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
57
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
58 (defun gravatar-build-url (mail-address)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
59 "Return an URL to retrieve MAIL-ADDRESS gravatar."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
60 (format "%s/%s?d=404&r=%s&s=%d"
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
61 gravatar-base-url
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
62 (gravatar-hash mail-address)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
63 gravatar-rating
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
64 gravatar-size))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
65
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
66 (defun gravatar-cache-expired (url)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
67 "Check if URL is cached for more than `gravatar-cache-ttl'."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
68 (cond (url-standalone-mode
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
69 (not (file-exists-p (url-cache-create-filename url))))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
70 (t (let ((cache-time (url-is-cached url)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
71 (if cache-time
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
72 (time-less-p
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
73 (time-add
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
74 cache-time
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
75 gravatar-cache-ttl)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
76 (current-time))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
77 t)))))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
78
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
79 (defun gravatar-get-data ()
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
80 "Get data from current buffer."
111994
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
81 (save-excursion
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
82 (goto-char (point-min))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
83 (when (re-search-forward "^HTTP/.+ 200 OK$" nil (line-end-position))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
84 (when (search-forward "\n\n" nil t)
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
85 (buffer-substring (point) (point-max))))))
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
86
110670
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
87 (eval-and-compile
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
88 (cond ((featurep 'xemacs)
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
89 (require 'gnus-xmas)
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
90 (defalias 'gravatar-create-image 'gnus-xmas-create-image))
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
91 ((featurep 'gnus-ems)
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
92 (defalias 'gravatar-create-image 'gnus-create-image))
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
93 (t
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
94 (require 'image)
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
95 (defalias 'gravatar-create-image 'create-image))))
bd7b628a1f67 gravatar.el (gravatar-create-image): New function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110555
diff changeset
96
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
97 (defun gravatar-data->image ()
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
98 "Get data of current buffer and return an image.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
99 If no image available, return 'error."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
100 (let ((data (gravatar-get-data)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
101 (if data
111994
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
102 (gravatar-create-image data nil t)
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
103 'error)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
104
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
105 ;;;###autoload
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
106 (defun gravatar-retrieve (mail-address cb &optional cbargs)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
107 "Retrieve MAIL-ADDRESS gravatar and call CB on retrieval.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
108 You can provide a list of argument to pass to CB in CBARGS."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
109 (let ((url (gravatar-build-url mail-address)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
110 (if (gravatar-cache-expired url)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
111 (url-retrieve url
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
112 'gravatar-retrieved
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
113 (list cb (when cbargs cbargs)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
114 (apply cb
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
115 (with-temp-buffer
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
116 (mm-disable-multibyte)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
117 (url-cache-extract (url-cache-create-filename url))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
118 (gravatar-data->image))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
119 cbargs))))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
120
111994
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
121 ;;;###autoload
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
122 (defun gravatar-retrieve-synchronously (mail-address)
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
123 "Retrieve MAIL-ADDRESS gravatar and returns it."
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
124 (let ((url (gravatar-build-url mail-address)))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
125 (if (gravatar-cache-expired url)
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
126 (with-current-buffer (url-retrieve-synchronously url)
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
127 (when gravatar-automatic-caching
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
128 (url-store-in-cache (current-buffer)))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
129 (let ((data (gravatar-data->image)))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
130 (kill-buffer (current-buffer))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
131 data))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
132 (with-temp-buffer
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
133 (mm-disable-multibyte)
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
134 (url-cache-extract (url-cache-create-filename url))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
135 (gravatar-data->image)))))
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
136
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
137
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
138 (defun gravatar-retrieved (status cb &optional cbargs)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
139 "Callback function used by `gravatar-retrieve'."
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
140 ;; Store gravatar?
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
141 (when gravatar-automatic-caching
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
142 (url-store-in-cache (current-buffer)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
143 (if (plist-get status :error)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
144 ;; Error happened.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
145 (apply cb 'error cbargs)
110763
0fe64d68a522 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110670
diff changeset
146 (apply cb (gravatar-data->image) cbargs))
0fe64d68a522 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110670
diff changeset
147 (kill-buffer (current-buffer)))
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
148
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
149 (provide 'gravatar)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
150
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
151 ;;; gravatar.el ends here