From a2ed9b31bf45f3b1673d1b90591bc40e106a6ae1 Mon Sep 17 00:00:00 2001 From: ueno Date: Wed, 12 Apr 2006 02:14:24 +0000 Subject: [PATCH] (epg-decrypt-file): New function. --- epg.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/epg.el b/epg.el index c3317af..0299480 100644 --- a/epg.el +++ b/epg.el @@ -488,6 +488,8 @@ This function is for internal use only." (setq alist (cdr alist))) (nreverse result))) +(defalias 'epg-make-temp-file 'make-temp-file) + ;;;###autoload (defun epg-decrypt-start (context input-file) "Initiate a decrypt operation on INPUT-FILE. @@ -503,6 +505,19 @@ If you are unsure, use synchronous version of this function (epg-wait-for-status context '("BEGIN_DECRYPTION"))) ;;;###autoload +(defun epg-decrypt-file (context input-file) + "Decrypt INPUT-FILE and return the plain text." + (unwind-protect + (progn + (epg-decrypt-start context input-file) + (epg-wait-for-completion context) + (unless (epg-context-result-for context 'decrypt) + (epg-read-output context))) + (epg-reset context) + (if (file-exists-p input-file) + (delete-file input-file)))) + +;;;###autoload (defun epg-decrypt-string (context string) "Decrypt STRING and return the plain text." (let ((input-file (epg-make-temp-file "epg-input")) @@ -510,11 +525,7 @@ If you are unsure, use synchronous version of this function (unwind-protect (progn (write-region string nil input-file) - (epg-decrypt-start context input-file) - (epg-wait-for-completion context) - (unless (epg-context-result-for context 'decrypt) - (epg-read-output context))) - (epg-reset context) + (epg-decrypt-file context input-file)) (if (file-exists-p input-file) (delete-file input-file))))) @@ -630,7 +641,9 @@ If you are unsure, use synchronous version of this function (list "-r" recipient)) recipients)))) (if sign - (epg-wait-for-status context '("BEGIN_SIGNING"))) + (epg-wait-for-status context '("BEGIN_SIGNING")) + (if (null recipients) + (epg-wait-for-status context '("BEGIN_ENCRYPTION")))) (if (eq (process-status (epg-context-process context)) 'run) (process-send-string (epg-context-process context) string))) -- 1.7.10.4