From a57ee5fc78a50b205236e7633abfdcee31c29167 Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 18 Sep 2007 02:09:22 +0000 Subject: [PATCH] (epg-make-context): New slot "edit-key-callback". (epg-start-edit-key): New function. (epg-edit-key): New function. --- ChangeLog | 6 ++++++ epg.el | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d13601..7b3f7c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-09-18 Daiki Ueno + + * epg.el (epg-make-context): New slot "edit-key-callback". + (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 29a8ee5..1081984 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,13 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-context-p context))) (aref (cdr context) 14)) +(defun epg-context-edit-key-callback (context) + "Return the function which handles input/output from the edit-key operation. +This function is for internal use only." + (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) @@ -330,7 +337,7 @@ This function is for internal use only." (defun epg-context-set-passphrase-callback (context passphrase-callback &optional handback) "Set the function used to query passphrase. -If optional argument HANDBACK is specified, it is passed to CALLBACK." +If optional argument HANDBACK is specified, it is passed to PASSPHRASE-CALLBACK." (unless (eq (car-safe context) 'epg-context) (signal 'wrong-type-argument (list 'epg-context-p context))) (aset (cdr context) 7 (if handback @@ -340,7 +347,7 @@ If optional argument HANDBACK is specified, it is passed to CALLBACK." (defun epg-context-set-progress-callback (context progress-callback &optional handback) "Set the function which handles progress update. -If optional argument HANDBACK is specified, it is passed to CALLBACK." +If optional argument HANDBACK is specified, it is passed to PROGRESS-CALLBACK." (unless (eq (car-safe context) 'epg-context) (signal 'wrong-type-argument (list 'epg-context-p context))) (aset (cdr context) 8 (if handback @@ -385,6 +392,16 @@ 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-edit-key-callback (context callback &optional handback) + "Set the function which handles input/output from the edit-key operation. +If optional argument HANDBACK is specified, it is passed to CALLBACK. +This function is for internal use only." + (unless (eq (car-safe context) 'epg-context) + (signal 'wrong-type-argument (list 'epg-context-p context))) + (aset (cdr context) 15 (if handback + (cons callback handback) + callback))) + (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 @@ -2476,8 +2493,38 @@ If you are unsure, use synchronous version of this function (epg-reset context))) ;;;###autoload +(defun epg-start-edit-key (context key &optional callback handback output) + "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-sign-keys' instead." + (epg-context-set-operation context 'edit-key) + (epg-context-set-result context nil) + (epg-context-set-edit-key-callback context callback (cons handback output)) + (epg--start context (list "--edit-key" + (epg-sub-key-id (car epg-key-sub-key-list key))))) + +;;;###autoload +(defun epg-edit-key (context key &optional callback handback output) + "Process the KEY interactively, using the edit CALLBACK with the HANDBACK. +The CALLBACK is invoked for every status and command request from +the crypto engine. The output of the crypto engine is written to +the data object OUTPUT." + (unwind-protect + (progn + (epg-start-edit-key context key callback handback output) + (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 an sign keys operation. + "Initiate a sign keys 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 -- 1.7.10.4