From: ueno Date: Mon, 1 May 2006 23:50:43 +0000 (+0000) Subject: * epg.el (epg-invalid-recipients-reason-alist): Renamed. X-Git-Tag: epg-0_0_2~50 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=9e9ecf0c5702a7a950b3bdb9875ece551f10a1e9;p=elisp%2Fepg.git * epg.el (epg-invalid-recipients-reason-alist): Renamed. (epg-delete-problem-reason-alist): Renamed. (epg-import-ok-reason-alist): New constant. (epg-import-problem-reason-alist): New constant. (epg-status-IMPORTED): New function. (epg-status-IMPORT_OK): New function. (epg-status-IMPORT_PROBLEM): New function. (epg-start-import-keys): Don't use a temporary output file. (epg-start-receive-keys): New function. (epg-import-keys-from-server): New function. (epg-receive-keys): Alias to epg-import-keys-from-server. --- diff --git a/ChangeLog b/ChangeLog index da7ba4f..bbcdb7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2006-05-01 Daiki Ueno + * epg.el (epg-invalid-recipients-reason-alist): Renamed. + (epg-delete-problem-reason-alist): Renamed. + (epg-import-ok-reason-alist): New constant. + (epg-import-problem-reason-alist): New constant. + (epg-status-IMPORTED): New function. + (epg-status-IMPORT_OK): New function. + (epg-status-IMPORT_PROBLEM): New function. + (epg-start-import-keys): Don't use a temporary output file. + (epg-start-receive-keys): New function. + (epg-import-keys-from-server): New function. + (epg-receive-keys): Alias to epg-import-keys-from-server. + +2006-05-01 Daiki Ueno + * epg.el (epg-start): Signal an error if the process of CONTEXT is already running for other operations. (epg-flush): Abolished. diff --git a/epg.el b/epg.el index 0e96c97..f83c600 100644 --- a/epg.el +++ b/epg.el @@ -91,7 +91,7 @@ (2 . "ZLIB") (3 . "BZIP2"))) -(defconst epg-invalid-recipients-alist +(defconst epg-invalid-recipients-reason-alist '((0 . "No specific reason given") (1 . "Not Found") (2 . "Ambigious specification") @@ -104,11 +104,26 @@ (9 . "Not a secret key") (10 . "Key not trusted"))) -(defconst epg-delete-problem-alist +(defconst epg-delete-problem-reason-alist '((1 . "No such key") (2 . "Must delete secret key first") (3 . "Ambigious specification"))) +(defconst epg-import-ok-reason-alist + '((0 . "Not actually changed") + (1 . "Entirely new key") + (2 . "New user IDs") + (4 . "New signatures") + (8 . "New subkeys") + (16 . "Contains private key"))) + +(defconst epg-import-problem-reason-alist + '((0 . "No specific reason given") + (1 . "Invalid Certificate") + (2 . "Issuer Certificate missing") + (3 . "Certificate Chain too long") + (4 . "Error storing certificate"))) + (defvar epg-key-validity-alist '((?o . unknown) (?i . invalid) @@ -1062,19 +1077,19 @@ This function is for internal use only." (defun epg-status-NODATA (process string) (epg-context-set-result-for epg-context 'error - (cons (cons 'no-data (string-to-number string)) + (cons (list 'no-data (cons 'reason (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)) + (cons (list 'unexpected (cons 'reason (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) + (cons (list 'key-expired (cons 'expiration-time string)) (epg-context-result-for epg-context 'error)))) (defun epg-status-KEYREVOKED (process string) @@ -1094,8 +1109,10 @@ This function is for internal use only." (epg-context-set-result-for epg-context 'error (cons (list 'invalid-recipient - (string-to-number (match-string 1 string)) - (match-string 2 string)) + (cons 'reason + (string-to-number (match-string 1 string))) + (cons 'requested-recipient + (match-string 2 string))) (epg-context-result-for epg-context 'error))))) (defun epg-status-NO_RECP (process string) @@ -1108,7 +1125,8 @@ This function is for internal use only." (if (string-match "\\`\\([0-9]+\\)" string) (epg-context-set-result-for epg-context 'error - (cons (cons 'delete-problem (string-to-number (match-string 1 string))) + (cons (list 'delete-problem + (cons 'reason (string-to-number (match-string 1 string)))) (epg-context-result-for epg-context 'error))))) (defun epg-status-SIG_CREATED (process string) @@ -1140,6 +1158,47 @@ This function is for internal use only." (cons '(key-not-created) (epg-context-result-for epg-context 'error)))) +(defun epg-status-IMPORTED (process string) + (if (string-match "\\`\\([^ ]+\\) \\(.*\\)" string) + (let* ((key-id (match-string 1 string)) + (user-id (match-string 2 string)) + (entry (assoc key-id epg-user-id-alist))) + (if entry + (setcdr entry user-id) + (setq epg-user-id-alist (cons (cons key-id user-id) + epg-user-id-alist))) + (epg-context-set-result-for + epg-context 'import + (cons (list (cons 'key-id key-id) + (cons 'user-id user-id)) + (epg-context-result-for epg-context 'import)))))) + +(defun epg-status-IMPORT_OK (process string) + (let ((result (epg-context-result-for epg-context 'import))) + (if (and result + (string-match "\\`\\([0-9]+\\)\\( \\(.+\\)\\)?" string)) + (setcar result + (append (list (cons 'reason + (string-to-number + (match-string 1 string)))) + (if (match-beginning 2) + (list (cons 'fingerprint + (match-string 3 string)))) + (car result)))))) + +(defun epg-status-IMPORT_PROBLEM (process string) + (if (string-match "\\`\\([0-9]+\\)\\( \\(.+\\)\\)?" string) + (epg-context-set-result-for + epg-context 'error + (cons (cons 'import-problem + (append (list (cons 'reason + (string-to-number + (match-string 1 string)))) + (if (match-beginning 2) + (list (cons 'fingerprint + (match-string 3 string))))) + (epg-context-result-for epg-context 'error)))))) + (defun epg-passphrase-callback-function (context key-id handback) (read-passwd (if (eq key-id 'SYM) @@ -1748,7 +1807,6 @@ If you use this function, you will need to wait for the completion of If you are unsure, use synchronous version of this function `epg-import-keys-from-file' or `epg-import-keys-from-string' instead." (epg-context-set-result context nil) - (epg-context-set-output-file context (epg-make-temp-file "epg-output")) (epg-start context (list "--import" (epg-data-file keys))) (when (epg-data-string keys) (if (eq (process-status (epg-context-process context)) 'run) @@ -1764,8 +1822,7 @@ If you are unsure, use synchronous version of this function (epg-wait-for-completion context) (if (epg-context-result-for context 'error) (error "Import keys failed: %S" - (epg-context-result-for context 'error))) - (epg-read-output context)) + (epg-context-result-for context 'error)))) (epg-reset context))) ;;;###autoload @@ -1779,6 +1836,35 @@ If you are unsure, use synchronous version of this function (epg-import-keys-1 context (epg-make-data-from-string keys))) ;;;###autoload +(defun epg-start-receive-keys (context key-id-list) + "Initiate a receive key operation. +KEY-ID-LIST is a list of key IDs. + +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-generate-key-from-file' or `epg-generate-key-from-string' instead." + (epg-context-set-result context nil) + (epg-start context (cons "--recv-keys" key-id-list))) + +;;;###autoload +(defun epg-import-keys-from-server (context keys) + "Add keys from server. +KEYS is a list of key IDs" + (unwind-protect + (progn + (epg-start-receive-keys context (epg-make-data-from-file parameters)) + (epg-wait-for-completion context) + (if (epg-context-result-for context 'error) + (error "Import keys failed: %S" + (epg-context-result-for context 'error)))) + (epg-reset context))) + +;;;###autoload +(defalias 'epg-receive-keys 'epg-import-keys-from-server) + +;;;###autoload (defun epg-start-delete-keys (context keys &optional allow-secret) "Initiate an delete keys operation.