2006-04-30 Andreas Seltenreich <uwi7@rz.uni-karlsruhe.de>
[gnus] / lisp / mml2015.el
index b682d89..a35e206 100644 (file)
@@ -1,5 +1,7 @@
 ;;; mml2015.el --- MIME Security with Pretty Good Privacy (PGP)
-;; Copyright (C) 2000 Free Software Foundation, Inc.
+
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: PGP MIME MML
 
 ;; 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.
 
 ;;; Commentary:
 
+;; RFC 2015 is updated by RFC 3156, this file should be compatible
+;; with both.
+
 ;;; Code:
 
 (eval-when-compile (require 'cl))
 (require 'mm-decode)
+(require 'mm-util)
+(require 'mml)
+
+(defvar mc-pgp-always-sign)
 
-(defvar mml2015-use (or 
+(defvar mml2015-use (or
+                    (progn
+                      (ignore-errors
+                       ;; Avoid the "Recursive load suspected" error
+                       ;; in Emacs 21.1.
+                       (let ((recursive-load-depth-limit 100))
+                         (require 'pgg)))
+                      (and (fboundp 'pgg-sign-region)
+                           'pgg))
                     (progn
                       (ignore-errors
                         (require 'gpg))
@@ -40,7 +57,8 @@
                                 (fboundp 'mc-sign-generic)
                                 (fboundp 'mc-cleanup-recipient-headers)
                                 'mailcrypt)))
-  "The package used for PGP/MIME.")
+  "The package used for PGP/MIME.
+Valid packages include `pgg', `gpg' and `mailcrypt'.")
 
 ;; Something is not RFC2015.
 (defvar mml2015-function-alist
               mml2015-mailcrypt-verify
               mml2015-mailcrypt-decrypt
               mml2015-mailcrypt-clear-verify
-              mml2015-mailcrypt-clear-decrypt) 
+              mml2015-mailcrypt-clear-decrypt)
     (gpg mml2015-gpg-sign
         mml2015-gpg-encrypt
         mml2015-gpg-verify
         mml2015-gpg-decrypt
         mml2015-gpg-clear-verify
-        mml2015-gpg-clear-decrypt))
+        mml2015-gpg-clear-decrypt)
+  (pgg mml2015-pgg-sign
+       mml2015-pgg-encrypt
+       mml2015-pgg-verify
+       mml2015-pgg-decrypt
+       mml2015-pgg-clear-verify
+       mml2015-pgg-clear-decrypt))
   "Alist of PGP/MIME functions.")
 
 (defvar mml2015-result-buffer nil)
 
+(defcustom mml2015-unabbrev-trust-alist
+  '(("TRUST_UNDEFINED" . nil)
+    ("TRUST_NEVER"     . nil)
+    ("TRUST_MARGINAL"  . t)
+    ("TRUST_FULLY"     . t)
+    ("TRUST_ULTIMATE"  . t))
+  "Map GnuPG trust output values to a boolean saying if you trust the key."
+  :version "22.1"
+  :group 'mime-security
+  :type '(repeat (cons (regexp :tag "GnuPG output regexp")
+                      (boolean :tag "Trust key"))))
+
 ;;; mailcrypt wrapper
 
 (eval-and-compile
 (defvar mml2015-decrypt-function 'mailcrypt-decrypt)
 (defvar mml2015-verify-function 'mailcrypt-verify)
 
+(defun mml2015-format-error (err)
+  (if (stringp (cadr err))
+      (cadr err)
+    (format "%S" (cdr err))))
+
 (defun mml2015-mailcrypt-decrypt (handle ctl)
   (catch 'error
     (let (child handles result)
-      (unless (setq child (mm-find-part-by-type 
-                          (cdr handle) 
+      (unless (setq child (mm-find-part-by-type
+                          (cdr handle)
        &nbs