(signal 'wrong-type-argument (list 'epg-context-p context)))
(aset (cdr context) 6 compress-algorithm))
-(defun epg-context-set-passphrase-callback (context
- passphrase-callback)
- "Set the function used to query passphrase."
+(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."
(unless (eq (car-safe context) 'epg-context)
(signal 'wrong-type-argument (list 'epg-context-p context)))
- (aset (cdr context) 7 passphrase-callback))
-
-(defun epg-context-set-progress-callback (context progress-callback)
- "Set the function which handles progress update."
+ (aset (cdr context) 7 (if handback
+ (cons passphrase-callback handback)
+ passphrase-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."
(unless (eq (car-safe context) 'epg-context)
(signal 'wrong-type-argument (list 'epg-context-p context)))
- (aset (cdr context) 8 progress-callback))
+ (aset (cdr context) 8 (if handback
+ (cons progress-callback handback)
+ progress-callback)))
(defun epg-context-set-signers (context signers)
"Set the list of key-id for singning."
(let* ((args (append (list "--no-tty"
"--status-fd" "1"
"--yes")
- (if (epg-context-progress-callback context)
- (list "--enable-progress-filter"))
+ (if (string-match ":" (or (getenv "GPG_AGENT_INFO") ""))
+ '("--use-agent"))
+ (if (and (not (eq (epg-context-protocol context) 'CMS))
+ (epg-context-progress-callback context))
+ '("--enable-progress-filter"))
(if epg-gpg-home-directory
(list "--homedir" epg-gpg-home-directory))
(unless (eq (epg-context-protocol context) 'CMS)
- (list "--command-fd" "0"))
+ '("--command-fd" "0"))
(if (epg-context-armor context) '("--armor"))
(if (epg-context-textmode context) '("--textmode"))
(if (epg-context-output-file context)
(if epg-passphrase-coding-system
(progn
(setq encoded-passphrase-with-new-line
- (encode-coding-string
+ (epg--encode-coding-string
passphrase-with-new-line
- epg-passphrase-coding-system))
+ (coding-system-change-eol-conversion
+ epg-passphrase-coding-system 'unix)))
(epg--clear-string passphrase-with-new-line)
(setq passphrase-with-new-line nil))
(setq encoded-passphrase-with-new-line
(epg-sig-notations signature))))))
(defun epg--status-PROGRESS (context string)
- (if (string-match "\\`\\([^ ]+\\) \\([^ ]\\) \\([0-9]+\\) \\([0-9]+\\)"
- string)
+ (if (and (epg-context-progress-callback context)
+ (string-match "\\`\\([^ ]+\\) \\([^ ]\\) \\([0-9]+\\) \\([0-9]+\\)"
+ string))
(funcall (if (consp (epg-context-progress-callback context))
(car (epg-context-progress-callback context))
(epg-context-progress-callback context))
(defun epg--clear-string (string)
(fillarray string 0)))
+(if (fboundp 'encode-coding-string)
+ (defalias 'epg--encode-coding-string 'encode-coding-string)
+ (defalias 'epg--encode-coding-string 'identity))
+
(defun epg--args-from-sig-notations (notations)
(apply #'nconc
(mapcar
(unless (eq (epg-context-protocol context) 'CMS)
(epg-wait-for-status context '("BEGIN_DECRYPTION"))))
-(defun epg--check-decrypt (context)
+(defun epg--check-error-for-decrypt (context)
(if (epg-context-result-for context 'decryption-failed)
(signal 'epg-error (list "Decryption failed")))
(if (epg-context-result-for context 'no-secret-key)
(epg--make-temp-file "epg-output")))
(epg-start-decrypt context (epg-make-data-from-file cipher))
(epg-wait-for-completion context)
- (epg--check-decrypt context)
+ (epg--check-error-for-decrypt context)
(unless plain
(epg-read-output context)))
(unless plain
(epg--make-temp-file "epg-output"))
(epg-start-decrypt context (epg-make-data-from-file input-file))
(epg-wait-for-completion context)
- (epg--check-decrypt context)
+ (epg--check-error-for-decrypt context)
(epg-read-output context))
(epg-delete-output-file context)
(if (file-exists-p input-file)
(if entry
(if (setq entry (assq (cdr entry)
epg-delete-problem-reason-alist))
- (error "Delete keys failed: %s" (cdr entry)))
- (error "Delete keys failed" (cdr entry)))))
+ (error "Delete keys failed: %s" (cdr entry))
+ (error "Delete keys failed")))))
(epg-reset context)))
;;;###autoload