From aa58d06d998fdd4217a79016bd876faac95166fe Mon Sep 17 00:00:00 2001 From: ueno Date: Sun, 11 Nov 2007 01:22:45 +0000 Subject: [PATCH] (epg-make-context): New slot "operation-data". (epg--process-filter): Pick up status handler from "operation-data". (epg-start-edit-key): New function. (epg-edit-key): New function. --- ChangeLog | 7 +++++++ epg.el | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d13601..e0f5bde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-11 Daiki Ueno + + * epg.el (epg-make-context): New slot "operation-data". + (epg--process-filter): Pick up status handler from "operation-data". + (epg-start-edit-key): New function. + (epg-edit-key): New function. + 2007-09-05 Daiki Ueno * EasyPG: Version 0.0.15 released. diff --git a/epg.el b/epg.el index ea0d4a1..a7e85da 100644 --- a/epg.el +++ b/epg.el @@ -190,7 +190,7 @@ cipher-algorithm digest-algorithm compress-algorithm #'epg-passphrase-callback-function nil - nil nil nil nil nil nil))) + nil nil nil nil nil nil nil))) (defun epg-context-protocol (context) "Return the protocol used within CONTEXT." @@ -285,6 +285,12 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-context-p context))) (aref (cdr context) 14)) +(defun epg-context-operation-data (context) + "Return the obarray of the current cryptographic operation." + (unless (eq (car-safe context) 'epg-context) + (signal 'wrong-type-argument (list 'epg-context-p context))) + (aref (cdr context) 15)) + (defun epg-context-set-protocol (context protocol) "Set the protocol used within CONTEXT." (unless (eq (car-safe context) 'epg-context) @@ -385,6 +391,12 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-context-p context))) (aset (cdr context) 14 operation)) +(defun epg-context-set-operation-data (context operation-data) + "Set the name of the current cryptographic operation." + (unless (eq (car-safe context) 'epg-context) + (signal 'wrong-type-argument (list 'epg-context-p context))) + (aset (cdr context) 15 operation-data)) + (defun epg-make-signature (status &optional key-id) "Return a signature object." (cons 'epg-signature (vector status key-id nil nil nil nil nil nil nil nil @@ -1145,8 +1157,14 @@ This function is for internal use only." (if (looking-at "\\[GNUPG:] \\([A-Z_]+\\) ?\\(.*\\)") (let* ((status (match-string 1)) (string (match-string 2)) - (symbol (intern-soft (concat "epg--status-" - status)))) + (handler-name (concat "epg--status-" status)) + (symbol (or (if (epg-context-operation-data + epg-context) + (intern-soft + handler-name + (epg-context-operation-data + epg-context))) + (intern-soft handler-name)))) (if (member status epg-pending-status-list) (setq epg-pending-status-list nil)) (if (and symbol @@ -2476,6 +2494,32 @@ If you are unsure, use synchronous version of this function (epg-reset context))) ;;;###autoload +(defun epg-start-edit-key (context key) + "Initiate an edit key operation. + +If you use this function, you will need to wait for the completion of +`epg-gpg-program' by using `epg-wait-for-completion' and call +`epg-reset' to clear a temporaly output file. +If you are unsure, use synchronous version of this function +`epg-edit-key' instead." + (epg-context-set-operation context 'edit-key) + (epg-context-set-result context nil) + (epg--start context (list "--with-colons" "--edit-key" "--" + (epg-sub-key-id (car (epg-key-sub-key-list key)))))) + +;;;###autoload +(defun epg-edit-key (context key) + "Edit KEY in the key ring." + (unwind-protect + (progn + (epg-start-edit-key context key) + (epg-wait-for-completion context) + (if (epg-context-result-for context 'error) + (error "Edit key failed: %S" + (epg-context-result-for context 'error)))) + (epg-reset context))) + +;;;###autoload (defun epg-start-sign-keys (context keys &optional local) "Initiate a sign keys operation. -- 1.7.10.4