1 ;;; gnus-picon.el --- displaying pretty icons in Gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Wes Hardaker <hardaker@ece.ucdavis.edu>
5 ;; Keywords: news xpm annotation glyph faces
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
30 (require 'annotations)
38 "Show pictures of people, domains, and newsgroups (XEmacs).
39 For this to work, you must switch on the `gnus-treat-display-picons'
43 (defcustom gnus-picons-display-where 'picons
44 "Where to display the group and article icons.
45 Valid values are `article' and `picons'."
46 :type '(choice symbol string)
49 (defcustom gnus-picons-has-modeline-p t
50 "*Whether the picons window should have a modeline.
51 This is only useful if `gnus-picons-display-where' is `picons'."
55 (defcustom gnus-picons-database "/usr/local/faces"
56 "*Defines the location of the faces database.
57 For information on obtaining this database of pretty pictures, please
58 see http://www.cs.indiana.edu/picons/ftp/index.html"
62 (defcustom gnus-picons-news-directories '("news")
63 "*List of directories to search for newsgroups faces."
64 :type '(repeat string)
66 (define-obsolete-variable-alias 'gnus-picons-news-directory
67 'gnus-picons-news-directories)
69 (defcustom gnus-picons-user-directories '("local" "users" "usenix" "misc")
70 "*List of directories to search for user faces."
71 :type '(repeat string)
74 (defcustom gnus-picons-domain-directories '("domains")
75 "*List of directories to search for domain faces.
76 Some people may want to add \"unknown\" to this list."
77 :type '(repeat string)
80 (defcustom gnus-picons-refresh-before-display nil
81 "*If non-nil, display the article buffer before computing the picons."
85 (defcustom gnus-picons-group-excluded-groups nil
86 "*If this regexp matches the group name, group picons will be disabled."
90 (defcustom gnus-picons-display-as-address t
91 "*If t display textual email addresses along with pictures."
95 (defcustom gnus-picons-file-suffixes
97 (let ((types (list "xbm")))
100 (when (featurep 'xpm)
103 "*List of suffixes on picon file names to try."
104 :type '(repeat string)
107 (defcustom gnus-picons-display-article-move-p nil
108 "*Whether to move point to first empty line when displaying picons.
109 This has only an effect if `gnus-picons-display-where' has value `article'."
113 (defcustom gnus-picons-clear-cache-on-shutdown t
114 "*Whether to clear the picons cache when exiting gnus.
115 Gnus caches every picons it finds while it is running. This saves
116 some time in the search process but eats some memory. If this
117 variable is set to nil, Gnus will never clear the cache itself; you
118 will have to manually call `gnus-picons-clear-cache' to clear it.
119 Otherwise the cache will be cleared every time you exit Gnus."
123 (defcustom gnus-picons-piconsearch-url nil
124 "*The url to query for picons. Setting this to nil will disable it.
125 The only publicly available address currently known is
126 http://www.cs.indiana.edu:800/piconsearch. If you know of any other,
127 please tell me so that we can list it."
128 :type '(choice (const :tag "Disable" :value nil)
129 (const :tag "www.cs.indiana.edu"
130 :value "http://www.cs.indiana.edu:800/piconsearch")
134 (defface gnus-picons-xbm-face '((t (:foreground "black" :background "white")))
135 "Face to show xbm picons in."
138 (defface gnus-picons-face '((t (:foreground "black" :background "white")))
139 "Face to show picons in."
142 (defcustom gnus-picons-setup-hook nil
143 "Hook run in Picons buffers."
147 ;;; Internal variables:
149 (defvar gnus-picons-setup-p nil)
150 (defvar gnus-picons-processes-alist nil
151 "Picons processes currently running and their environment.")
152 (defvar gnus-picons-glyph-alist nil
153 "Picons glyphs cache.
154 List of pairs (KEY . GLYPH) where KEY is either a filename or an URL.")
155 (defvar gnus-picons-url-alist nil
156 "Picons file names cache.
157 List of pairs (KEY . NAME) where KEY is (USER HOST DBS) and NAME is an URL.")
159 (defvar gnus-picons-jobs-alist nil
160 "List of jobs that still need be done.
161 This is a list of (SYM-ANN TAG ARGS...) where SYM-ANN three annotations list,
162 TAG is one of `picon' or `search' indicating that the job should query a
163 picon or do a search for picons file names, and ARGS is some additionnal
164 arguments necessary for the job.")
166 (defvar gnus-picons-job-already-running nil
167 "Lock to ensure only one stream of http requests is running.")
171 (defun gnus-picons-remove-all ()
172 "Removes all picons from the Gnus display(s)."
174 (map-extents (function (lambda (ext unused) (delete-annotation ext) nil))
175 nil nil nil nil nil 'gnus-picon)
176 (setq gnus-picons-jobs-alist '())
177 ;; notify running job that it may have been preempted
178 (if (and (listp gnus-picons-job-already-running)
179 gnus-picons-job-already-running)
180 (setq gnus-picons-job-already-running t)))
182 (defun gnus-get-buffer-name (variable)
183 "Returns the buffer name associated with the contents of a variable."
184 (let ((buf (gnus-get-buffer-create
185 (gnus-window-to-buffer-helper
186 (cdr (assq variable gnus-window-to-buffer))))))
190 (defun gnus-picons-buffer-name ()
191 (cond ((or (stringp gnus-picons-display-where)
192 (bufferp gnus-picons-display-where))
193 gnus-picons-display-where)
194 ((eq gnus-picons-display-where 'picons)
195 (if gnus-single-article-buffer
197 (concat "*Picons " gnus-newsgroup-name "*")))
199 (gnus-get-buffer-name gnus-picons-display-where))))
201 (defun gnus-picons-kill-buffer ()
202 (let ((buf (get-buffer (gnus-picons-buffer-name))))
203 (when (and (buffer-live-p buf)
204 (string-match "Picons" (buffer-name buf)))
207 (defun gnus-picons-setup-buffer ()
208 (let ((name (gnus-picons-buffer-name)))
210 (if (and (get-buffer name)
211 (with-current-buffer name
212 gnus-picons-setup-p))
214 (set-buffer (gnus-get-buffer-create name))
215 (buffer-disable-undo)
216 (setq buffer-read-only t)
217 (run-hooks 'gnus-picons-setup-hook)
218 (set (make-local-variable 'gnus-picons-setup-p) t)
219 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-picons-kill-buffer))
222 (defun gnus-picons-set-buffer ()
223 (set-buffer (gnus-picons-setup-buffer))
224 (goto-char (point-min))
225 (if (and (eq gnus-picons-display-where 'article)
226 gnus-picons-display-article-move-p)
227 (if (search-forward "\n\n" nil t)
229 (goto-char (point-max)))
230 (setq buffer-read-only t)
231 (unless gnus-picons-has-modeline-p
232 (set-specifier has-modeline-p
233 (list (list (current-buffer)
234 (cons nil gnus-picons-has-modeline-p)))))))
236 (defun gnus-picons-prepare-for-annotations ()
237 "Prepare picons buffer for putting annotations."
238 ;; let drawing catch up
239 (when gnus-picons-refresh-before-display
241 (gnus-picons-set-buffer)
242 (gnus-picons-remove-all))
244 (defun gnus-picons-make-annotation (&rest args)
245 (let ((annot (apply 'make-annotation args)))
246 (set-extent-property annot 'gnus-picon t)
247 (set-extent-property annot 'duplicable t)
250 (defun gnus-article-display-picons ()
251 "Display faces for an author and her domain in gnus-picons-display-where."
254 (when (and (featurep 'xpm)
255 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
256 (setq from (mail-fetch-field "from"))
257 (setq from (downcase (or (cadr (mail-extract-address-components
260 (or (setq at-idx (string-match "@" from))
261 (setq at-idx (length from))))
263 (let ((username (downcase (substring from 0 at-idx)))
264 (addrs (if (eq at-idx (length from))
265 (if gnus-local-domain
266 (message-tokenize-header gnus-local-domain "."))
267 (message-tokenize-header (substring from (1+ at-idx))
269 (gnus-picons-prepare-for-annotations)
270 (gnus-group-display-picons)
271 (unless gnus-picons-display-article-move-p
272 (let ((buffer-read-only nil)
273 (case-fold-search t))
274 (when (re-search-forward "^From *: *" nil t)
275 (when (search-forward from (gnus-point-at-eol) t)
276 (gnus-put-text-property
277 (match-beginning 0) (match-end 0)
279 (if (null gnus-picons-piconsearch-url)
281 (gnus-picons-display-pairs (gnus-picons-lookup-pairs
283 gnus-picons-domain-directories)
284 gnus-picons-display-as-address
286 (if (and gnus-picons-display-as-address addrs)
287 (gnus-picons-make-annotation
288 [string :data "@"] nil 'text nil nil nil t))
289 (gnus-picons-display-picon-or-name
290 (gnus-picons-lookup-user username addrs)
292 (push (list 'gnus-article-annotations 'search username addrs
293 gnus-picons-domain-directories t (point-marker))
294 gnus-picons-jobs-alist)
295 (gnus-picons-next-job)))))))
297 (defun gnus-group-display-picons ()
298 "Display icons for the group in the `gnus-picons-display-where' buffer."
300 (when (and (featurep 'xpm)
301 (or (not (fboundp 'device-type)) (equal (device-type) 'x))
302 (or (null gnus-picons-group-excluded-groups)
303 (not (string-match gnus-picons-group-excluded-groups
304 gnus-newsgroup-name))))
305 (let* ((newsgroups (mail-fetch-field "newsgroups"))
307 (if (or gnus-picons-display-article-move-p
309 (list (gnus-group-real-name gnus-newsgroup-name))
310 (split-string newsgroups ",")))
313 (gnus-picons-prepare-for-annotations)
314 (while (setq group (pop groups))
315 (unless gnus-picons-display-article-move-p
316 (let ((buffer-read-only nil)
317 (case-fold-search t))
318 (goto-char (point-min))
319 (if (and (re-search-forward "^Newsgroups *: *" nil t)
320 (search-forward group (gnus-point-at-eol) t))
321 (gnus-put-text-property
322 (match-beginning 0) (match-end 0)
324 (let ((article-goto-body-goes-to-point-min-p nil))
327 (backward-char 1)))))
328 (if (null gnus-picons-piconsearch-url)
329 (gnus-picons-display-pairs
330 (gnus-picons-lookup-pairs
331 (reverse (split-string group "\\."))
332 gnus-picons-news-directories)
334 (push (list 'gnus-group-annotations 'search nil
335 (split-string group "\\.")
336 (if (listp gnus-picons-news-directories)
337 gnus-picons-news-directories
338 (list gnus-picons-news-directories))
340 gnus-picons-jobs-alist)
341 (gnus-picons-next-job))
343 (add-hook 'gnus-summary-exit-hook 'gnus-picons-remove-all))))))
345 (defun gnus-picons-lookup-internal (addrs dir)
346 (setq dir (expand-file-name dir gnus-picons-database))
347 (gnus-picons-try-face (dolist (part (reverse addrs) dir)
348 (setq dir (expand-file-name part dir)))))
350 (defun gnus-picons-lookup (addrs dirs)
351 "Lookup the picon for ADDRS in databases DIRS.
352 Returns the picon filename or NIL if none found."
354 (while (and dirs (null result))
355 (setq result (gnus-picons-lookup-internal addrs (pop dirs))))
358 (defun gnus-picons-lookup-user-internal (user domains)
359 (let ((dirs gnus-picons-user-directories)
360 domains-tmp dir picon)
361 (while (and dirs (null picon))
362 (setq domains-tmp domains
364 (while (and domains-tmp
365 (null (setq picon (gnus-picons-lookup-internal
366 (cons user domains-tmp) dir))))
368 ;; Also make a try in MISC subdir
370 (setq picon (gnus-picons-lookup-internal (list user "MISC") dir))))
373 (defun gnus-picons-lookup-user (user domains)
374 "Lookup the picon for USER at DOMAINS.
375 USER is a string containing a name.
376 DOMAINS is a list of strings from the fully qualified domain name."
377 (or (gnus-picons-lookup-user-internal user domains)
378 (gnus-picons-lookup-user-internal "unknown" domains)))
380 (defun gnus-picons-lookup-pairs (domains directories)
381 "Lookup picons for DOMAINS and all its parents in DIRECTORIES.
382 Returns a list of PAIRS whose CAR is the picon filename or NIL if
383 none, and whose CDR is the corresponding element of DOMAINS."
385 (setq directories (if (listp directories)
389 (push (list (gnus-picons-lookup (cons "unknown" domains) directories)
394 (defun gnus-picons-display-picon-or-name (picon name &optional right-p)
395 (cond (picon (gnus-picons-display-glyph picon name right-p))
396 (gnus-picons-display-as-address (list (gnus-picons-make-annotation
397 (vector 'string :data name)
399 nil nil nil right-p)))))
401 (defun gnus-picons-display-pairs (pairs &optional bar-p dot-p right-p)
402 "Display picons in list PAIRS."
403 (let ((domain-p (and gnus-picons-display-as-address dot-p))
405 (when (and bar-p domain-p right-p
406 gnus-picons-display-article-move-p)
407 (setq picons (gnus-picons-display-glyph
408 (let ((gnus-picons-file-suffixes '("xbm")))
409 (gnus-picons-try-face
410 gnus-xmas-glyph-directory "bar."))
412 (while (setq pair (pop pairs))
413 (setq picons (nconc picons
414 (gnus-picons-display-picon-or-name
415 (car pair) (cadr pair) right-p)
416 (if (and domain-p pairs)
417 (list (gnus-picons-make-annotation
418 (vector 'string :data dot-p)
419 nil 'text nil nil nil right-p))))))
422 (defun gnus-picons-try-face (dir &optional filebase)
423 (let* ((dir (file-name-as-directory dir))
424 (filebase (or filebase "face."))
425 (key (concat dir filebase))
426 (glyph (cdr (assoc key gnus-picons-glyph-alist)))
427 (suffixes gnus-picons-file-suffixes)
429 (while (setq suf (pop suffixes))
430 (when (file-exists-p (setq f (expand-file-name
431 (concat filebase suf)
434 glyph (make-glyph f))
435 (if (equal suf "xbm")
436 (set-glyph-face glyph 'gnus-picons-xbm-face)
437 (set-glyph-face glyph 'gnus-picons-face))
438 (push (cons key glyph) gnus-picons-glyph-alist)))
441 (defun gnus-picons-display-glyph (glyph &optional part rightp)
442 (set-glyph-baseline glyph 70)
443 (let ((new (gnus-picons-make-annotation
444 glyph (point) 'text nil nil nil rightp)))
445 (when (and part gnus-picons-display-as-address)
447 new (cons new (make-glyph (vector 'string :data part))))
448 (set-annotation-action new 'gnus-picons-action-toggle))
451 (if (and (eq major-mode 'gnus-article-mode)
452 (not gnus-picons-display-as-address)
454 (list (gnus-picons-make-annotation [string :data " "] (point)
455 'text nil nil nil rightp))))))
457 (defun gnus-picons-action-toggle (data)
460 (let* ((annot (car data))
461 (glyph (annotation-glyph annot)))
462 (set-annotation-glyph annot (cdr data))
463 (set-annotation-data annot (cons annot glyph))))
465 (defun gnus-picons-clear-cache ()
466 "Clear the picons cache."
468 (setq gnus-picons-glyph-alist nil
469 gnus-picons-url-alist nil))
471 (gnus-add-shutdown 'gnus-picons-close 'gnus)
473 (defun gnus-picons-close ()
474 "Shut down the picons."
475 (if gnus-picons-clear-cache-on-shutdown
476 (gnus-picons-clear-cache)))
478 ;;; Query a remote DB. This requires some stuff from w3 !
483 (require 'w3-forms)))
485 (defun gnus-picons-url-retrieve (url fn arg)
486 (let ((old-asynch (default-value 'url-be-asynchronous))
487 (url-working-buffer (generate-new-buffer " *picons*"))
488 (url-package-name "Gnus")
489 (url-package-version gnus-version-number)
491 (setq-default url-be-asynchronous t)
493 (set-buffer url-working-buffer)
494 (setq url-be-asynchronous t
495 url-current-callback-data arg
496 url-current-callback-func fn)
497 (url-retrieve url t))
498 (setq-default url-be-asynchronous old-asynch)))
500 (defun gnus-picons-make-glyph (type)
501 "Make a TYPE glyph using current buffer as data. Handles xbm nicely."
502 (cond ((null type) nil)
503 ((eq type 'xbm) (let ((fname (make-temp-name "/tmp/picon")))
504 (write-region (point-min) (point-max) fname
506 (prog1 (make-glyph (vector 'xbm :file fname))
507 (delete-file fname))))
508 (t (make-glyph (vector type :data (buffer-string))))))
510 ;;; Parsing of piconsearch result page.
513 ;; 1 - each value field has the form: "<strong>key</strong> = <kbd>value</kbd>"
514 ;; 2 - a "<p>" separates the keywords from the results
515 ;; 3 - every results begins by the path within the database at the beginning
516 ;; of the line in raw text.
517 ;; 3b - and the href following it is the preferred image type.
519 ;; if 1 or 2 is not met, it will probably cause an error. The other
520 ;; will go undetected
522 (defun gnus-picons-parse-value (name)
523 (goto-char (point-min))
524 (if (re-search-forward (concat "<strong>"
526 "</strong> *= *<kbd> *\\([^ <][^<]*\\) *</kbd>")
528 (buffer-substring (match-beginning 1) (match-end 1))))
530 (defun gnus-picons-parse-filenames ()
531 ;; returns an alist of ((USER ADDRS DB) . URL)
532 (let ((case-fold-search t)
533 (user (gnus-picons-parse-value "user"))
534 (host (gnus-picons-parse-value "host"))
535 (dbs (message-tokenize-header (gnus-picons-parse-value "db") " "))
536 start-re cur-db cur-host cur-user types res)
537 ;; now point will be somewhere in the header. Find beginning of
539 (when (and user host dbs)
543 "^\\(" (mapconcat 'regexp-quote dbs "\\|") "\\)/"
545 "\\(\\(" (mapconcat 'regexp-quote
546 (message-tokenize-header host ".") "/\\|")
549 "\\(" (regexp-quote user) "\\|unknown\\)/"
551 (re-search-forward "<p>[ \t\n]*")
552 (while (re-search-forward start-re nil t)
553 (setq cur-db (buffer-substring (match-beginning 1) (match-end 1))
554 cur-host (buffer-substring (match-beginning 2) (match-end 2))
555 cur-user (buffer-substring (match-beginning 4) (match-end 4))
556 cur-host (nreverse (message-tokenize-header cur-host "/")))
557 ;; XXX - KLUDGE: there is a blank picon in news/MISC/unknown
558 (unless (and (string-equal cur-db "news")
559 (string-equal cur-user "unknown")
560 (equal cur-host '("MISC")))
561 ;; ok now we have found an entry (USER HOST DB), find the
562 ;; corresponding picon URL
564 ;; restrict region to this entry
565 (narrow-to-region (point) (search-forward "<br>"))
566 (goto-char (point-min))
567 (setq types gnus-picons-file-suffixes)
569 (not (re-search-forward
570 (concat "<a[ \t\n]+href=\"\\([^\"]*\\."
571 (regexp-quote (car types)) "\\)\"")
574 (push (cons (list cur-user cur-host cur-db)
575 (buffer-substring (match-beginning 1) (match-end 1)))
579 ;;; picon network display functions :
581 (defun gnus-picons-network-display-internal (sym-ann glyph part right-p marker)
582 (let ((buf (marker-buffer marker))
583 (pos (marker-position marker)))
588 (gnus-picons-display-picon-or-name glyph part right-p))))
589 (gnus-picons-next-job-internal))
591 (defun gnus-picons-network-display-callback (url part sym-ann right-p marker)
592 (let ((glyph (gnus-picons-make-glyph (cdr (assoc url-current-mime-type
593 w3-image-mappings)))))
594 (kill-buffer (current-buffer))
595 (push (cons url glyph) gnus-picons-glyph-alist)
596 ;; only do the job if it has not been preempted.
597 (if (equal gnus-picons-job-already-running
598 (list sym-ann 'picon url part right-p marker))
599 (gnus-picons-network-display-internal
600 sym-ann glyph part right-p marker)
601 (gnus-picons-next-job-internal))))
603 (defun gnus-picons-network-display (url part sym-ann right-p marker)
604 (let ((cache (assoc url gnus-picons-glyph-alist)))
605 (if (or cache (null url))
606 (gnus-picons-network-display-internal
607 sym-ann (cdr cache) part right-p marker)
608 (gnus-picons-url-retrieve url 'gnus-picons-network-display-callback
609 (list url part sym-ann right-p marker)))))
611 ;;; search job functions
613 (defun gnus-picons-display-bar-p ()
614 (if (eq gnus-picons-display-where 'article)
615 gnus-picons-display-article-move-p
616 gnus-picons-display-as-address))
618 (defun gnus-picons-network-search-internal (user addrs dbs sym-ann right-p
619 marker &optional fnames)
620 (let (curkey dom pfx url dbs-tmp cache new-jobs)
621 ;; First do the domain search
622 (dolist (part (if right-p
625 (setq pfx (nconc (list part) pfx)
626 dom (cond ((and dom right-p) (concat part "." dom))
627 (dom (concat dom "." part))
629 curkey (list "unknown" dom dbs))
630 (when (null (setq cache (assoc curkey gnus-picons-url-alist)))
631 ;; This one is not yet in the cache, create a new entry
632 ;; Search for an entry
635 (while (and dbs-tmp (null url))
636 (setq url (or (cdr (assoc (list "unknown" pfx (car dbs-tmp)) fnames))
638 ;; This is the first component. Try the
639 ;; catch-all MISC component
640 (cdr (assoc (list "unknown"
645 (push (setq cache (cons curkey url)) gnus-picons-url-alist))
646 ;; Put this glyph in the job list
647 (if (and (not (eq dom part)) gnus-picons-display-as-address)
648 (push (list sym-ann "." right-p marker) new-jobs))
649 (push (list sym-ann 'picon (cdr cache) part right-p marker) new-jobs))
650 ;; next, the user search
652 (setq curkey (list user dom gnus-picons-user-directories))
653 (if (null (setq cache (assoc curkey gnus-picons-url-alist)))
654 (let ((users (list user "unknown"))
655 dirs usr domains-tmp dir picon)
656 (while (and users (null picon))
657 (setq dirs gnus-picons-user-directories
659 (while (and dirs (null picon))
660 (setq domains-tmp addrs
662 (while (and domains-tmp
663 (null (setq picon (assoc (list usr domains-tmp dir)
667 (setq picon (assoc (list usr '("MISC") dir) fnames)))))
668 (push (setq cache (cons curkey (cdr picon)))
669 gnus-picons-url-alist)))
670 (if (and gnus-picons-display-as-address new-jobs)
671 (push (list sym-ann "@" right-p marker) new-jobs))
672 (push (list sym-ann 'picon (cdr cache) user right-p marker) new-jobs))
673 (if (and (gnus-picons-display-bar-p) (not right-p))
674 (push (list sym-ann 'bar right-p marker) new-jobs))
675 ;; only put the jobs in the queue if this job has not been preempted.
676 (if (equal gnus-picons-job-already-running
677 (list sym-ann 'search user addrs dbs right-p marker))
678 (setq gnus-picons-jobs-alist
679 (nconc (if (and (gnus-picons-display-bar-p) right-p)
680 (list (list sym-ann 'bar right-p marker)))
682 gnus-picons-jobs-alist)))
683 (gnus-picons-next-job-internal)))
685 (defun gnus-picons-network-search-callback (user addrs dbs sym-ann right-p
687 (gnus-picons-network-search-internal
688 user addrs dbs sym-ann right-p marker
690 (gnus-picons-parse-filenames)
691 (kill-buffer (current-buffer)))))
693 ;; Initiate a query on the picon database
694 (defun gnus-picons-network-search (user addrs dbs sym-ann right-p marker)
695 (let* ((host (mapconcat 'identity addrs "."))
696 (key (list (or user "unknown") host (if user
697 gnus-picons-user-directories
699 (cache (assoc key gnus-picons-url-alist)))
701 (gnus-picons-url-retrieve
702 (concat gnus-picons-piconsearch-url
703 "?user=" (w3-form-encode-xwfu (or user "unknown"))
704 "&host=" (w3-form-encode-xwfu host)
705 "&db=" (mapconcat 'w3-form-encode-xwfu
708 gnus-picons-user-directories)
711 'gnus-picons-network-search-callback
712 (list user addrs dbs sym-ann right-p marker))
713 (gnus-picons-network-search-internal
714 user addrs dbs sym-ann right-p marker))))
716 ;;; Main jobs dispatcher function
718 (defun gnus-picons-next-job-internal ()
719 (when (setq gnus-picons-job-already-running (pop gnus-picons-jobs-alist))
720 (let* ((job gnus-picons-job-already-running)
725 ((stringp tag);; (SYM-ANN "..." RIGHT-P MARKER)
726 (gnus-picons-network-display-internal
727 sym-ann nil tag (pop job) (pop job)))
728 ((eq 'bar tag);; (SYM-ANN 'bar RIGHT-P MARKER)
729 (gnus-picons-network-display-internal
731 (let ((gnus-picons-file-suffixes '("xbm")))
732 (gnus-picons-try-face
733 gnus-xmas-glyph-directory "bar."))
734 nil (pop job) (pop job)))
735 ((eq 'search tag);; (SYM-ANN 'search USER ADDRS DBS RIGHT-P MARKER)
736 (gnus-picons-network-search
737 (pop job) (pop job) (pop job) sym-ann (pop job) (pop job)))
738 ((eq 'picon tag);; (SYM-ANN 'picon URL PART RIGHT-P MARKER)
739 (gnus-picons-network-display
740 (pop job) (pop job) sym-ann (pop job) (pop job)))
742 (setq gnus-picons-job-already-running nil)
743 (error "Unknown picon job tag %s" tag)))))))
745 (defun gnus-picons-next-job ()
746 "Start processing the job queue if it is not in progress."
747 (unless gnus-picons-job-already-running
748 (gnus-picons-next-job-internal)))
750 (provide 'gnus-picon)
752 ;;; gnus-picon.el ends here