(gnus-dribble-read-file): Use make-local-variable rather than
[gnus] / lisp / pgg-gpg.el
index c6efe28..6ba017c 100644 (file)
@@ -1,6 +1,7 @@
 ;;; pgg-gpg.el --- GnuPG support for PGG.
 
-;; Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Created: 1999/10/28
@@ -20,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Code:
 
@@ -30,7 +31,7 @@
   (require 'pgg))
 
 (defgroup pgg-gpg ()
-  "GnuPG interface"
+  "GnuPG interface."
   :group 'pgg)
 
 (defcustom pgg-gpg-program "gpg"
   :group 'pgg-gpg
   :type '(repeat (string :tag "Argument")))
 
+(defcustom pgg-gpg-recipient-argument "--recipient"
+  "GnuPG option to specify recipient."
+  :group 'pgg-gpg
+  :type '(choice (const :tag "New `--recipient' option" "--recipient")
+                (const :tag "Old `--remote-user' option" "--remote-user")))
+
 (defvar pgg-gpg-user-id nil
   "GnuPG ID of your default identity.")
 
   (if (and pgg-cache-passphrase
           (progn
             (goto-char (point-min))
-            (re-search-forward "^\\[GNUPG:] GOOD_PASSPHRASE\\>" nil t)))
+            (re-search-forward "^\\[GNUPG:] \\(GOOD_PASSPHRASE\\>\\)\\|\\(SIG_CREATED\\)" nil t)))
       (pgg-add-passphrase-cache
        (or key
           (progn
             (goto-char (point-min))
             (if (re-search-forward
-                 "^\\[GNUPG:] NEED_PASSPHRASE \\w+ ?\\w*" nil t)
+                 "^\\[GNUPG:] NEED_PASSPHRASE\\(_PIN\\)? \\w+ ?\\w*" nil t)
                 (substring (match-string 0) -8))))
        passphrase)))
 
       (with-temp-buffer
        (apply #'call-process pgg-gpg-program nil t nil args)
        (goto-char (point-min))
-       (while (re-search-forward "^\\(sec\\|pub\\):"  nil t)
-         (push (substring
-                (nth 3 (split-string
-                        (buffer-substring (match-end 0)
-                                          (progn (end-of-line) (point)))
-                        ":")) 8)
+       (while (re-search-forward
+               "^\\(sec\\|pub\\):[^:]*:[^:]*:[^:]*:\\([^:]*\\)" nil t)
+         (push (substring (match-string 2) 8)
                pgg-gpg-all-secret-keys)))))
   pgg-gpg-all-secret-keys)
 
     (with-temp-buffer
       (apply #'call-process pgg-gpg-program nil t nil args)
       (goto-char (point-min))
-      (if (re-search-forward "^\\(sec\\|pub\\):"  nil t)
-         (substring
-          (nth 3 (split-string
-                  (buffer-substring (match-end 0)
-                                    (progn (end-of-line)(point)))
-                  ":")) 8)))))
+      (if (re-search-forward "^\\(sec\\|pub\\):[^:]*:[^:]*:[^:]*:\\([^:]*\\)"
+                            nil t)
+         (substring (match-string 2) 8)))))
 
 (defun pgg-gpg-encrypt-region (start end recipients &optional sign)
   "Encrypt the current region between START and END.
@@ -154,7 +155,7 @@ If optional argument SIGN is non-nil, do a combined sign and encrypt."
           (if recipients
               (apply #'nconc
                      (mapcar (lambda (rcpt)
-                               (list "--remote-user" rcpt))
+                               (list pgg-gpg-recipient-argument rcpt))
                              (append recipients
                                      (if pgg-encrypt-for-me
                                          (list pgg-gpg-user-id)))))))))
@@ -252,7 +253,7 @@ If optional argument SIGN is non-nil, do a combined sign and encrypt."
     (when (re-search-forward "^\\[GNUPG:] IMPORT_RES\\>" nil t)
       (setq status (buffer-substring (match-end 0)
                                     (progn (end-of-line)(point)))
-           status (vconcat (mapcar #'string-to-int (split-string status))))
+           status (vconcat (mapcar #'string-to-number (split-string status))))
       (erase-buffer)
       (insert (format "Imported %d key(s).
 \tArmor contains %d key(s) [%d bad, %d old].\n"
@@ -270,4 +271,5 @@ If optional argument SIGN is non-nil, do a combined sign and encrypt."
 
 (provide 'pgg-gpg)
 
+;;; arch-tag: 2aa5d5d8-93a0-4865-9312-33e29830e000
 ;;; pgg-gpg.el ends here