summaryrefslogtreecommitdiff
path: root/lisp/epg.el
diff options
context:
space:
mode:
authorAdam Sjøgren <asjo@koldfront.dk>2012-12-25 23:49:35 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2012-12-25 23:49:35 +0100
commit23dab7dca6ee4dbe4fb55f89f7291abb5cf932e7 (patch)
treeb15b5b49e61e2d7aa25b48d2e85becbb3b78f731 /lisp/epg.el
parentecfb998c179b004f515b0c4d8e98d53811a3b12a (diff)
downloademacs-23dab7dca6ee4dbe4fb55f89f7291abb5cf932e7.tar.gz
Display images from gpg signatures
* epg.el (epg-signature-to-string): Use new functions epg-key-image, epg-key-image-to-string to find and display image from key.
Diffstat (limited to 'lisp/epg.el')
-rw-r--r--lisp/epg.el28
1 files changed, 26 insertions, 2 deletions
diff --git a/lisp/epg.el b/lisp/epg.el
index 833a68d6e7e..b79c5df4165 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -967,11 +967,34 @@ This function is for internal use only."
(setcdr entry value)
(epg-context-set-result context (cons (cons name value) result)))))
+(defun epg-key-image (key-id)
+ "Return the image of a key, if any"
+ (let ((filename
+ (replace-regexp-in-string
+ "\n" ""
+ (shell-command-to-string
+ (concat "/usr/bin/gpg --photo-viewer 'echo %I >&2' --list-keys "
+ key-id " > /dev/null")))))
+ (when (and (not (string-equal filename ""))
+ (file-exists-p filename))
+ (create-image filename))))
+
+(defun epg-key-image-to-string (key-id)
+ "Return a string with the image of a key, if any"
+ (let* ((result "")
+ (key-image (epg-key-image key-id)))
+ (when key-image
+ (setq result " ")
+ (put-text-property 1 2 'display key-image result))
+ result))
+
(defun epg-signature-to-string (signature)
"Convert SIGNATURE to a human readable string."
(let* ((user-id (cdr (assoc (epg-signature-key-id signature)
epg-user-id-alist)))
- (pubkey-algorithm (epg-signature-pubkey-algorithm signature)))
+ (pubkey-algorithm (epg-signature-pubkey-algorithm signature))
+ (key-id (epg-signature-key-id signature))
+ (key-image (epg-key-image-to-string key-id)))
(concat
(cond ((eq (epg-signature-status signature) 'good)
"Good signature from ")
@@ -985,7 +1008,8 @@ This function is for internal use only."
"Signature made by revoked key ")
((eq (epg-signature-status signature) 'no-pubkey)
"No public key for "))
- (epg-signature-key-id signature)
+ key-id
+ key-image
(if user-id
(concat " "
(if (stringp user-id)