(accept-process-output (epg-context-process context) 1))))
(defun epg-wait-for-completion (context)
- (process-send-eof (epg-context-process context))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-eof (epg-context-process context)))
(while (eq (process-status (epg-context-process context)) 'run)
;; We can't use accept-process-output instead of sit-for here
;; because it may cause an interrupt during the sentinel execution.
(epg-context-result-for epg-context 'verify)))))
(defun epg-status-TRUST_UNDEFINED (process string)
- (let ((signature (car (epg-context-result-for-for epg-context 'verify))))
+ (let ((signature (car (epg-context-result-for epg-context 'verify))))
(if (and signature
(eq (epg-signature-status signature) 'good))
(epg-signature-set-validity signature 'unknown))))
(eq (epg-signature-status signature) 'good))
(epg-signature-set-validity signature 'full))))
-(defun epg-status-DECRYPTION_FAILED (process string)
- (epg-context-set-result-for epg-context 'decrypt 'failed))
-
(defun epg-status-PROGRESS (process string)
(if (string-match "\\`\\([^ ]+\\) \\([^ ]\\) \\([0-9]+\\) \\([0-9]+\\)"
string)
(string-to-number (match-string 4 string))
(cdr (epg-context-progress-callback-info epg-context)))))
+(defun epg-status-DECRYPTION_FAILED (process string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons 'decryption-failed
+ (epg-context-result-for epg-context 'error))))
+
+(defun epg-status-NODATA (process string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons (cons 'no-data (string-to-number string))
+ (epg-context-result-for epg-context 'error))))
+
+(defun epg-status-UNEXPECTED (process string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons (cons 'unexpected (string-to-number string))
+ (epg-context-result-for epg-context 'error))))
+
+(defun epg-status-KEYEXPIRED (process string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons (cons 'key-expired string)
+ (epg-context-result-for epg-context 'error))))
+
+(defun epg-status-KEYREVOKED (process string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons 'key-revoked
+ (epg-context-result-for epg-context 'error))))
+
+(defun epg-status-BADARMOR (process string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons 'bad-armor
+ (epg-context-result-for epg-context 'error))))
+
(defun epg-passphrase-callback-function (key-id handback)
(read-passwd
(if (eq key-id 'SYM)
(progn
(epg-decrypt-start context input-file)
(epg-wait-for-completion context)
- (unless (epg-context-result-for context 'decrypt)
- (epg-read-output context)))
+ (if (epg-context-result-for context 'error)
+ (error "Decryption failed"))
+ (epg-read-output context))
(epg-reset context)
(if (file-exists-p input-file)
(delete-file input-file))))
`epg-sign-string' instead."
(epg-context-set-output-file context (epg-make-temp-file "epg-output"))
(epg-start context
- (append (list (if (eq 'clearsign)
+ (append (list (if (eq mode 'clearsign)
"--clearsign"
(if (or (eq mode t) (eq mode 'detached))
"--detach-sign"
(progn
(epg-sign-start context string mode)
(epg-wait-for-completion context)
+ (if (epg-context-result-for context 'error)
+ (error "Sign failed"))
(epg-read-output context))
(epg-reset context)))
(progn
(epg-encrypt-start context string recipients sign always-trust)
(epg-wait-for-completion context)
+ (if (epg-context-result-for context 'error)
+ (error "Encrypt failed"))
(epg-read-output context))
(epg-reset context)))