From b15591f553cc515dec0229cb6287866b5a18a10f Mon Sep 17 00:00:00 2001 From: Ronan Waide Date: Fri, 18 Oct 2002 10:54:34 +0000 Subject: allows bbdb-pgp.el to be configured to use message.el MML tags to perform the signing and encryption, instead of only plain Mailcrypt which is not MIME-aware. (Michael Shields) --- bits/bbdb-pgp.el | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/bits/bbdb-pgp.el b/bits/bbdb-pgp.el index bbacb50..b1673e7 100644 --- a/bits/bbdb-pgp.el +++ b/bits/bbdb-pgp.el @@ -69,6 +69,11 @@ ;;; Change log: ;; $Log$ +;; Revision 1.2 2002/10/18 10:54:34 waider +;; allows bbdb-pgp.el to be configured to use message.el MML tags to perform +;; the signing and encryption, instead of only plain Mailcrypt which is not +;; MIME-aware. (Michael Shields) +;; ;; Revision 1.1 2001/01/24 21:19:08 waider ;; Add-ons that didn't make it to the current release. ;; @@ -105,6 +110,13 @@ Report bugs to: Kevin Davidson tkld@quadstone.com") If this field's value in a record is \"encrypt\" then messages are encrypted. If it is \"sign\" then messages are signed.") +(defvar bbdb/pgp-method 'mailcrypt + "*How to sign or encrypt messages. +'mailcrypt means use Mailcrypt. +'mml-pgp means add MML tags for Message to use old PGP format +'mml-pgpmime means add MML tags for Message to use PGP/MIME +'mml-smime means add MML tags for Message to use S/MIME") + (defvar bbdb/pgp-default-action nil "*Default action when sending a message and the recipient is not in BBDB. nil means do nothing. @@ -118,6 +130,36 @@ nil means do nothing. (bbdb-record-getprop record bbdb/pgp-field)))) pgp)) +(defun bbdb/pgp-sign () + "Sign a message. +bbdb/pgp-method controls the method used." + (cond + ((eq bbdb/pgp-method 'mailcrypt) + (mc-sign 0)) + ((eq bbdb/pgp-method 'mml-pgp) + (mml-secure-message-sign-pgp)) + ((eq bbdb/pgp-method 'mml-pgpmime) + (mml-secure-message-sign-pgpmime)) + ((eq bbdb/pgp-method 'mml-smime) + (mml-secure-message-sign-smime)) + (t + (error 'invalid-state "bbdb/pgp-method")))) + +(defun bbdb/pgp-encrypt () + "Encrypt and sign a message. +bbdb/pgp-method controls the method used." + (cond + ((eq bbdb/pgp-method 'mailcrypt) + (mc-encrypt 0)) + ((eq bbdb/pgp-method 'mml-pgp) + (mml-secure-message-encrypt-pgp)) + ((eq bbdb/pgp-method 'mml-pgpmime) + (mml-secure-message-encrypt-pgpmime)) + ((eq bbdb/pgp-method 'mml-smime) + (mml-secure-message-encrypt-smime)) + (t + (error 'invalid-state "bbdb/pgp-method")))) + (defun bbdb/pgp-hook-fun () "Function to be added to message-send-hook Uses PGP to encrypt messages to users marked in the BBDB with the @@ -137,19 +179,19 @@ The user is prompted before encryption or signing." (let ((pgp-p (bbdb/pgp-get-pgp (car address) (car (cdr address))))) (cond ((string= "encrypt" pgp-p) - (and (y-or-n-p "Encrypt message ? ") - (mc-encrypt 0))) + (and (y-or-n-p "Encrypt message? ") + (bbdb/pgp-encrypt))) ((string= "sign" pgp-p) - (and (y-or-n-p "Sign message ? ") - (mc-sign 0))) + (and (y-or-n-p "Sign message? ") + (bbdb/pgp-sign))) (t (cond ((eq bbdb/pgp-default-action 'encrypt) - (and (y-or-n-p "Encrypt message ? ") - (mc-encrypt 0))) + (and (y-or-n-p "Encrypt message? ") + (bbdb/pgp-encrypt))) ((eq bbdb/pgp-default-action 'sign) - (and (y-or-n-p "Sign message ? ") - (mc-sign 0))) + (and (y-or-n-p "Sign message? ") + (bbdb/pgp-sign))) (t nil)))))))))) -- cgit v1.2.3