(nnir-add-result): New helper macro.
[gnus] / contrib / gpg.el
index 3afa1ed..80c5d8a 100644 (file)
@@ -7,13 +7,11 @@
 ;; Keywords: crypto
 ;; Created: 2000-04-15
 
 ;; Keywords: crypto
 ;; Created: 2000-04-15
 
-;; $Id: gpg.el,v 1.14 2001/07/30 23:04:20 zsh Exp $
-
 ;; This file is NOT (yet?) part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; This file is NOT (yet?) part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -23,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
 
 ;; 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:
 
 
 ;;; Commentary:
 
@@ -41,8 +39,8 @@
 ;; * Customization for all flavors of PGP is possible.
 ;; * The main operations (verify, decrypt, sign, encrypt, sign &
 ;;   encrypt) are implemented.
 ;; * Customization for all flavors of PGP is possible.
 ;; * The main operations (verify, decrypt, sign, encrypt, sign &
 ;;   encrypt) are implemented.
-;; * Gero Treuner's gpg-2comp script is supported, and data which is is
-;;   compatible with PGP 2.6.3 is generated.
+;; * Optionally, Gero Treuner's gpg-2comp script is supported, 
+;;   to generate data which is compatible with PGP 2.6.3.
 
 ;; Customizing external programs 
 ;; =============================
 
 ;; Customizing external programs 
 ;; =============================
 \f
 ;;; Code:
 
 \f
 ;;; Code:
 
-(require 'timer)
+(if (featurep 'xemacs)
+    (require 'timer-funcs)
+  (require 'timer))
 (eval-when-compile (require 'cl))
 
 (eval-and-compile 
 (eval-when-compile (require 'cl))
 
 (eval-and-compile 
        'point-at-eol
       'line-end-position)))
 
        'point-at-eol
       'line-end-position)))
 
+;; itimer/timer compatibility
+(eval-and-compile
+  (if (featurep 'xemacs)
+      (progn
+       (defalias 'gpg-cancel-timer 'delete-itimer)
+       (defalias 'gpg-timer-activate 'activate-itimer)
+       (defalias 'gpg-timer-create 'make-itimer)
+       (defalias 'gpg-timer-set-function 'set-itimer-function)
+       (defalias 'gpg-timer-set-time 'set-itimer-value))
+    (defalias 'gpg-cancel-timer 'cancel-timer)
+    (defalias 'gpg-timer-activate 'timer-activate)
+    (defalias 'gpg-timer-create 'timer-create)
+    (defalias 'gpg-timer-set-function 'timer-set-function)
+    (defalias 'gpg-timer-set-time 'timer-set-time)))
+
 ;;;; Customization:
 
 ;;; Customization: Groups:
 ;;;; Customization:
 
 ;;; Customization: Groups:
@@ -227,12 +242,12 @@ If you are running Emacs 20, this directory must have mode 0700."
 
 (defcustom gpg-command-default-alist 
   '((gpg . "gpg")
 
 (defcustom gpg-command-default-alist 
   '((gpg . "gpg")
-    (gpg-2comp . "gpg-2comp"))
+    (gpg-2comp . "gpg"))
   "Default paths for some GnuPG-related programs.
 Modify this variable if you have to change the paths to the
   "Default paths for some GnuPG-related programs.
 Modify this variable if you have to change the paths to the
-executables required by the GnuPG interface.  You can enter \"gpg\"
-for `gpg-2comp' if you don't have this script, but you'll lose PGP
-2.6.x compatibility."
+executables required by the GnuPG interface.  You can enter \"gpg-2comp\"
+for `gpg-2comp' if you have obtained this script, in order to gain
+PGP 2.6.x compatibility."
   :tag "GnuPG programs"
   :type 'gpg-command-alist
   :group 'gpg-options)
   :tag "GnuPG programs"
   :type 'gpg-command-alist
   :group 'gpg-options)
@@ -342,7 +357,7 @@ endings; the input data shall be treated as binary."
   :group 'gpg-commands)
 
 (defcustom gpg-command-decrypt
   :group 'gpg-commands)
 
 (defcustom gpg-command-decrypt
-  '(gpg . ("--decrypt" "--batch" "--passphrase-fd=0"))
+  '(gpg . ("--status-fd" "2" "--decrypt" "--batch" "--passphrase-fd=0"))
   "Command to decrypt a message.
 The invoked program has to read the passphrase from standard
 input, followed by the encrypted message.  It writes the decrypted
   "Command to decrypt a message.
 The invoked program has to read the passphrase from standard
 input, followed by the encrypted message.  It writes the decrypted
@@ -364,7 +379,7 @@ standard error."
   '(gpg-2comp . ("--batch" "--passphrase-fd=0" "--output=-"
                 armor textmode  "--clearsign"
                 sign-with-key))
   '(gpg-2comp . ("--batch" "--passphrase-fd=0" "--output=-"
                 armor textmode  "--clearsign"
                 sign-with-key))
-  "Command to create a create a \"clearsign\" text file.  
+  "Command to create a \"clearsign\" text file.  
 The invoked program has to read the passphrase from standard input,
 followed by the message to sign.  It should write the ASCII-amored
 signed text message to standard output, and diagnostic messages to
 The invoked program has to read the passphrase from standard input,
 followed by the message to sign.  It should write the ASCII-amored
 signed text message to standard output, and diagnostic messages to
@@ -377,7 +392,7 @@ standard error."
   '(gpg-2comp . ("--batch" "--passphrase-fd=0" "--output=-"
                 armor textmode "--detach-sign" 
                 sign-with-key))
   '(gpg-2comp . ("--batch" "--passphrase-fd=0" "--output=-"
                 armor textmode "--detach-sign" 
                 sign-with-key))
-  "Command to create a create a detached signature. 
+  "Command to create a detached signature. 
 The invoked program has to read the passphrase from standard input,
 followed by the message to sign.  It should write the ASCII-amored
 detached signature to standard output, and diagnostic messages to
 The invoked program has to read the passphrase from standard input,
 followed by the message to sign.  It should write the ASCII-amored
 detached signature to standard output, and diagnostic messages to
@@ -781,7 +796,7 @@ evaluates BODY, like `progn'.  If BODY evaluates to `nil' (or
 ;;; Passphrase handling:
 
 (defvar gpg-passphrase-timer
 ;;; Passphrase handling:
 
 (defvar gpg-passphrase-timer
-  (timer-create)
+  (gpg-timer-create)
   "This timer will clear the passphrase cache periodically.")
 
 (defvar gpg-passphrase
   "This timer will clear the passphrase cache periodically.")
 
 (defvar gpg-passphrase
@@ -800,24 +815,25 @@ evaluates BODY, like `progn'.  If BODY evaluates to `nil' (or
 (defun gpg-passphrase-forget ()
   "Forget stored passphrase."
   (interactive)
 (defun gpg-passphrase-forget ()
   "Forget stored passphrase."
   (interactive)
-  (cancel-timer gpg-passphrase-timer)
-  (setq gpg-passphrase-timer nil)
-  (gpg-passphrase-clear-string gpg-passphrase)
-  (setq gpg-passphrase nil))
+  (when gpg-passphrase
+    (gpg-cancel-timer gpg-passphrase-timer)
+    (setq gpg-passphrase-timer nil)
+    (gpg-passphrase-clear-string gpg-passphrase)
+    (setq gpg-passphrase nil)))
 
 (defun gpg-passphrase-store (passphrase)
   "Store PASSPHRASE in cache.
 Updates the timeout for clearing the cache to `gpg-passphrase-timeout'."
   (unless (equal gpg-passphrase-timeout 0)
     (if (null gpg-passphrase-timer)
 
 (defun gpg-passphrase-store (passphrase)
   "Store PASSPHRASE in cache.
 Updates the timeout for clearing the cache to `gpg-passphrase-timeout'."
   (unless (equal gpg-passphrase-timeout 0)
     (if (null gpg-passphrase-timer)
-       (setq gpg-passphrase-timer (timer-create)))
-    (timer-set-time gpg-passphrase-timer 
-                   (timer-relative-time (current-time) 
-                                        gpg-passphrase-timeout))
-    (timer-set-function gpg-passphrase-timer 'gpg-passphrase-forget)
+       (setq gpg-passphrase-timer (gpg-timer-create)))
+    (gpg-timer-set-time gpg-passphrase-timer 
+                       (timer-relative-time (current-time) 
+                                            gpg-passphrase-timeout))
+    (gpg-timer-set-function gpg-passphrase-timer 'gpg-passphrase-forget)
     (unless (and (fboundp 'itimer-live-p)
                 (itimer-live-p gpg-passphrase-timer))
     (unless (and (fboundp 'itimer-live-p)
                 (itimer-live-p gpg-passphrase-timer))
-      (timer-activate gpg-passphrase-timer))
+      (gpg-timer-activate gpg-passphrase-timer))
     (setq gpg-passphrase passphrase))
   passphrase)
 
     (setq gpg-passphrase passphrase))
   passphrase)
 
@@ -1320,4 +1336,5 @@ before point.")
 
 (provide 'gpg)
 
 
 (provide 'gpg)
 
+;;; arch-tag: c972455d-9bc5-4de1-9dc7-4f494d63053b
 ;;; gpg.el ends here
 ;;; gpg.el ends here