Gnus development mailing list
 help / color / mirror / Atom feed
* mml2015-epg-sign do not use from header
@ 2009-01-25 20:11 Daniel Dehennin
  2009-01-25 20:37 ` Reiner Steib
                   ` (3 more replies)
  0 siblings, 4 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-25 20:11 UTC (permalink / raw)
  To: ding


[-- Attachment #1.1: Type: text/plain, Size: 1251 bytes --]

Hello,

I'm using EasyPG backend to mml2015 and see that the from header is
not used for mail siging.

Looking at the code I see that the sender address is not used.

I create 3 new functions and use them to simplify/correct
mml2015-epg-sign and mml2015-epg-encrypt behavior.
 
Here is my changelog:

  * lisp/mml2015.el (mml2015-epg-split-addresses): Split a string of
    addresses delimited by "[ \f\t\n\r\v,]+".
    (mml2015-epg-prompt-select-key): Wrapper around epa-select-keys for
    prompting the keys to use.
    (mml2015-epg-choose-key): Choose keys for a certain usage for a list of
    names. Names are mail addresses used by epg to narrow selection.

  * lisp/mml2015.el (mml2015-epg-sign): Use sender for signing, get first
    address if From filed contains more that one.
    Change variable name to reflect the use of only one address for signin.
    Use mml2015-epg-choose-key.

  * lisp/mml2015.el (mml2015-epg-encrypt): Fetch one sender
    from (message-options-get 'message-sender).
    Fetch recipients from (message-options-get 'message-recipients).
    Use mml2015-epg-choose-key.


Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Use from header for signing with epg --]
[-- Type: text/x-diff, Size: 8230 bytes --]

=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-25 15:04:23 +0000
@@ -1025,6 +1025,82 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+"Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+	 (mapcar
+	  (lambda (address)
+	    (or (epg-expand-group config address)
+		(concat "<" address ">")))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+")))
+
+(defun mml2015-epg-prompt-select-key (context &optional name usage)
+"Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+			 ((memq usage '(t sign)) "default secret key is used")
+			 ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+			 (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     name key-type)))
+
+(defun mml2015-epg-choose-key (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(key-type-name (cond
+			((memq usage '(t sign)) "secret")
+			((memq usage '(nil encrypt)) "public")
+			(t "public")))
+	signer-key)
+    (if names
+	(delq nil
+	      (mapcar
+	       (lambda (name)
+		 (if (and
+		      ;; Fail to fetch a key
+		      (not (setq signer-key (or
+					     ;; Does sender has keys ?
+					     (and (epg-list-keys context name key-type)
+						  (or (and (not mml2015-verbose)
+							   (mml2015-epg-find-usable-key
+							    (epg-list-keys context name key-type)
+							    usage))
+						      (mml2015-epg-find-usable-key
+						       (mml2015-epg-prompt-select-key context name usage)
+						       usage)))
+					     ;; Ask for what ever secret key we have in keyring
+					     (mml2015-epg-find-usable-key
+					      (mml2015-epg-prompt-select-key context nil usage)
+					      usage))))
+		      ;; No key, ask for abortion
+		      (y-or-n-p
+		       (format
+			"No %s key selected for %s; abort? "
+			key-type name)))
+		     (error "No %s key for %s: aborted." key-type-name name))
+		 signer-key)
+	       names)))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1179,38 +1255,23 @@
       (mml2015-extract-cleartext-signature))))
 
 (defun mml2015-epg-sign (cont)
-  (let* ((inhibit-redisplay t)
+  (let ((inhibit-redisplay t)
 	 (context (epg-make-context))
+	 (config (epg-configuration))
 	 (boundary (mml-compute-boundary cont))
-	 signer-key
-	 (signers
-	  (or (message-options-get 'mml2015-epg-signers)
-	      (message-options-set
-	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
-	 signature micalg)
+	 sender signer signer-key signature micalg)
+    ;; Only one sender address
+    (setq sender (list (car (mml2015-epg-split-addresses 
+			     config 
+			     (message-options-get 'message-sender)))))
+    (setq signer (or 
+		  (message-options-get 'mml2015-epg-signers)
+		  (message-options-set
+		   'mml2015-epg-signers
+		   (mml2015-epg-choose-key context sender 'sign))))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-    (epg-context-set-signers context signers)
+    (epg-context-set-signers context signer)
     (if mml2015-cache-passphrase
 	(epg-context-set-passphrase-callback
 	 context
@@ -1249,75 +1310,35 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
-	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
 	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+	sender recipients signer cipher)
+    ;; Only one sender
+    (setq sender (list (car (mml2015-epg-split-addresses 
+			     config
+			     (message-options-get 'message-sender)))))
+    ;; All recipients
+    (setq recipients (mml2015-epg-split-addresses 
+		      config
+		      (message-options-get 'message-recipients)))
+    
+    (when mml2015-encrypt-to-self
+      (if (not sender)
+	  (error "Message sender not set"))
+      (setq recipients (nconc recipients sender)))
+    (setq recipients (or
+		      (message-options-get 'mml2015-epg-recipients)
+		      (message-options-set
+		       'mml2015-epg-recipients
+		       (mml2015-epg-choose-key context recipients 'encrypt))))
     (unless recipients
-      (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
-      (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
-      (message-options-set 'mml2015-epg-recipients recipients))
+      (error "No recipient specified"))
     (when sign
-      (setq signers
-	    (or (message-options-get 'mml2015-epg-signers)
-		(message-options-set
-		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
-      (epg-context-set-signers context signers))
+      (setq signer (or 
+		    (message-options-get 'mml2015-epg-signers)
+		    (message-options-set
+		     'mml2015-epg-signers
+		     (mml2015-epg-choose-key context sender 'sign)))))
+    (epg-context-set-signers context signer)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
     (if mml2015-cache-passphrase


[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-25 20:11 mml2015-epg-sign do not use from header Daniel Dehennin
@ 2009-01-25 20:37 ` Reiner Steib
  2009-01-25 20:43   ` Daniel Dehennin
  2009-01-26  1:34 ` Daiki Ueno
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 53+ messages in thread
From: Reiner Steib @ 2009-01-25 20:37 UTC (permalink / raw)
  To: Daniel Dehennin; +Cc: Daiki Ueno, ding

On Sun, Jan 25 2009, Daniel Dehennin wrote:

> I'm using EasyPG backend to mml2015 and see that the from header is
> not used for mail siging.
>
> Looking at the code I see that the sender address is not used.
>
> I create 3 new functions and use them to simplify/correct
> mml2015-epg-sign and mml2015-epg-encrypt behavior.

I'll leave comments on the code to others.  Cc-ed the author of
EasyPG.

In case we install your changes, we need a copyright assignment from
you.  I saw your name on the list for other GNU projects, so I guess I
won't be a problem for you.  I'm I right?

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-25 20:37 ` Reiner Steib
@ 2009-01-25 20:43   ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-25 20:43 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: ding

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

Le 5625 Septembre 1993, Reiner Steib a envoyé:
> I'll leave comments on the code to others.  Cc-ed the author of
> EasyPG.
>
> In case we install your changes, we need a copyright assignment from
> you.  I saw your name on the list for other GNU projects, so I guess I
> won't be a problem for you.  I'm I right?

Of course, I'm glad to help :-)
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-25 20:11 mml2015-epg-sign do not use from header Daniel Dehennin
  2009-01-25 20:37 ` Reiner Steib
@ 2009-01-26  1:34 ` Daiki Ueno
  2009-02-28 11:25   ` Reiner Steib
  2009-01-28 11:57 ` Daniel Dehennin
  2010-11-15 23:11 ` Daniel Dehennin
  3 siblings, 1 reply; 53+ messages in thread
From: Daiki Ueno @ 2009-01-26  1:34 UTC (permalink / raw)
  To: Daniel Dehennin; +Cc: ding

>>>>> In <87k58jqh6u.fsf@hati.baby-gnu.org> 
>>>>>	Daniel Dehennin <daniel.dehennin@baby-gnu.org> wrote:
> I'm using EasyPG backend to mml2015 and see that the from header is
> not used for mail siging.

> Looking at the code I see that the sender address is not used.

> I create 3 new functions and use them to simplify/correct
> mml2015-epg-sign and mml2015-epg-encrypt behavior.

Thanks for the patch.  The behavior change sounds reasonable.  However,
the patch looks too large since it contains two independent changes
(i.e. for feature enhancement and code cleanup).  Could you please
isolate these changes each other and post them in separate patches?

Regards,
-- 
Daiki Ueno



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-25 20:11 mml2015-epg-sign do not use from header Daniel Dehennin
  2009-01-25 20:37 ` Reiner Steib
  2009-01-26  1:34 ` Daiki Ueno
@ 2009-01-28 11:57 ` Daniel Dehennin
  2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
                     ` (10 more replies)
  2010-11-15 23:11 ` Daniel Dehennin
  3 siblings, 11 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 11:57 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

Hello,

After setting up a bzr repository to track my changes, I can provide
step by step modifications.

The 11 following patches permit to:
- use from header to sign message
- factorize some code
- ask the user about the key to use if more than one match

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] mml2015-epg-sign does not use from header.
  2009-01-28 11:57 ` Daniel Dehennin
@ 2009-01-28 11:59   ` Daniel Dehennin
  2009-03-01 17:13     ` Daiki Ueno
                       ` (2 more replies)
  2009-01-28 12:00   ` [PATCH] Factor spliting mail addresses Daniel Dehennin
                     ` (9 subsequent siblings)
  10 siblings, 3 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 11:59 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]



------------------------------------------------------------
revno: 113
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Tue 2009-01-27 19:44:28 +0100
message:
  mml2015-epg-sign does not use from header.
  
  * lisp/mml2015.el (mml2015-epg-sign): New variable 'sender'
    is (message-options-get 'message-sender). Use it in place of
    mml2015-signers.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus113.patch --]
[-- Type: text/x-patch, Size: 1319 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090127184428-\
#   g31ccthfaksykt29
# target_branch: ../../gnus.head
# testament_sha1: c1cf3a01375bb35cd7bde5fa3102662608096e6a
# timestamp: 2009-01-28 11:48:57 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-27 18:44:28 +0000
@@ -1182,6 +1182,7 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
@@ -1191,8 +1192,8 @@
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+				    sender t)
+		 (if sender
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1207,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (list sender))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Factor spliting mail addresses.
  2009-01-28 11:57 ` Daniel Dehennin
  2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
@ 2009-01-28 12:00   ` Daniel Dehennin
  2009-04-13 20:32     ` Daniel Dehennin
  2009-01-28 12:01   ` [PATCH] Cleanup selecting a key for sign and encryption Daniel Dehennin
                     ` (8 subsequent siblings)
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:00 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]



------------------------------------------------------------
revno: 115
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Tue 2009-01-27 20:40:52 +0100
message:
  Factor spliting mail addresses.
  
  * lisp/mml2015.el (mml2015-epg-split-addresses): Split a string of addresses.
    (mml2015-epg-encrypt): Use it to set recipients.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus115.patch --]
[-- Type: text/x-patch, Size: 3616 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090127194052-\
#   mnh8eg1sy9eldodg
# target_branch: ../../gnus.head
# testament_sha1: 09eb182f0e81f7faa1ebaa723bb27514223cb1a9
# timestamp: 2009-01-28 13:00:28 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-27 19:40:52 +0000
@@ -1025,6 +1025,18 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,6 +1194,7 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
@@ -1191,8 +1204,8 @@
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+				    sender t)
+		 (if sender
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1219,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (list sender))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,26 +1262,20 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients (list sender))))
       (if mml2015-verbose
 	  (setq recipients
 		(epa-select-keys context "\
@@ -1301,8 +1308,8 @@
 		     (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+				      sender t)
+		   (if sender
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1323,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (list sender))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Cleanup selecting a key for sign and encryption.
  2009-01-28 11:57 ` Daniel Dehennin
  2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
  2009-01-28 12:00   ` [PATCH] Factor spliting mail addresses Daniel Dehennin
@ 2009-01-28 12:01   ` Daniel Dehennin
  2009-04-13 20:32     ` Daniel Dehennin
  2009-01-28 12:02   ` [PATCH] Only one sender Daniel Dehennin
                     ` (7 subsequent siblings)
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:01 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]



------------------------------------------------------------
revno: 116
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Tue 2009-01-27 22:36:43 +0100
message:
  Cleanup selecting a key for sign and encryption.
  
  * lisp/mml2015.el (mml2015-epg-prompt-select-keys): New function.
    (mml2015-epg-sign): Use it.
    (mml2015-epg-encrypt): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus116.patch --]
[-- Type: text/x-patch, Size: 5007 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090127213643-\
#   wdsvibfo9rhmi3es
# target_branch: ../../gnus.head
# testament_sha1: f616e0abc7ccd21f7deb0f85564d74f5c0ff97ff
# timestamp: 2009-01-28 13:00:48 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-27 21:36:43 +0000
@@ -1025,6 +1025,43 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,17 +1219,15 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+		   (mml2015-epg-prompt-select-keys context sender 'sign)
+		 (if sender
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1241,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (list sender))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,32 +1284,23 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients (list sender))))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
 	      (delq nil
 		    (mapcar
@@ -1298,11 +1324,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+		     (mml2015-epg-prompt-select-keys context sender 'sign)
+		   (if sender
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1339,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (list sender))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Only one sender.
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (2 preceding siblings ...)
  2009-01-28 12:01   ` [PATCH] Cleanup selecting a key for sign and encryption Daniel Dehennin
@ 2009-01-28 12:02   ` Daniel Dehennin
  2009-04-13 20:32     ` Daniel Dehennin
  2009-01-28 12:02   ` Daniel Dehennin
                     ` (6 subsequent siblings)
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:02 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 363 bytes --]



------------------------------------------------------------
revno: 117
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Tue 2009-01-27 23:21:03 +0100
message:
  Only one sender.
  
  * lisp/mml2015.el (mml2015-epg-sign): From header should have only one
    sender address. Split it and fetch only the first one.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus117.patch --]
[-- Type: text/x-patch, Size: 5099 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090127222103-\
#   i0pdjq2zftwgg39f
# target_branch: ../../gnus.head
# testament_sha1: 10084be917ad726f471ded442fee6ba6ce9122fd
# timestamp: 2009-01-28 13:01:10 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-27 22:21:03 +0000
@@ -1025,6 +1025,43 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,17 +1219,19 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+		   (mml2015-epg-prompt-select-keys context sender 'sign)
+		 (if sender
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1245,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    sender)))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,32 +1288,23 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients (list sender))))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
 	      (delq nil
 		    (mapcar
@@ -1298,11 +1328,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+		     (mml2015-epg-prompt-select-keys context sender 'sign)
+		   (if sender
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1343,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (list sender))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Only one sender.
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (3 preceding siblings ...)
  2009-01-28 12:02   ` [PATCH] Only one sender Daniel Dehennin
@ 2009-01-28 12:02   ` Daniel Dehennin
  2009-04-13 20:32     ` Daniel Dehennin
  2009-01-28 12:02   ` [PATCH] Factorize choosing a key Daniel Dehennin
                     ` (5 subsequent siblings)
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:02 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]



------------------------------------------------------------
revno: 118
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Tue 2009-01-27 23:23:42 +0100
message:
  Only one sender.
  
  * lisp/mml2015.el (mml2015-epg-encrypt): From header should have only one
    sender address. Split it and fetch only the first one.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus118.patch --]
[-- Type: text/x-patch, Size: 5156 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090127222342-\
#   994z6t8g80vrzj9q
# target_branch: ../../gnus.head
# testament_sha1: 11829d0d11b87d6d050bbece843b2c5c4b5941e9
# timestamp: 2009-01-28 13:02:08 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-27 22:23:42 +0000
@@ -1025,6 +1025,43 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,17 +1219,19 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+		   (mml2015-epg-prompt-select-keys context sender 'sign)
+		 (if sender
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1245,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    sender)))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,32 +1288,26 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (list (car 
+		       (mml2015-epg-split-addresses 
+			config 
+			(message-options-get 'message-sender)))))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients sender)))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
 	      (delq nil
 		    (mapcar
@@ -1298,11 +1331,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+		     (mml2015-epg-prompt-select-keys context sender 'sign)
+		   (if sender
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1346,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      sender)))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Factorize choosing a key.
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (4 preceding siblings ...)
  2009-01-28 12:02   ` Daniel Dehennin
@ 2009-01-28 12:02   ` Daniel Dehennin
  2009-04-13 20:33     ` Daniel Dehennin
  2009-01-28 12:02   ` [PATCH] mml2015-epg-choose-keys handle the verbose selection of keys Daniel Dehennin
                     ` (4 subsequent siblings)
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:02 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]



------------------------------------------------------------
revno: 119
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Tue 2009-01-27 23:46:04 +0100
message:
  Factorize choosing a key.
  
  * lisp/mml2015.el (mml2015-epg-choose-keys): New function.
    (mml2015-epg-encrypt): Use it.
    (mml2015-epg-encrypt): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus119.patch --]
[-- Type: text/x-patch, Size: 7038 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090127224604-\
#   q8ho2n9lhg5bku2x
# target_branch: ../../gnus.head
# testament_sha1: 7968a974221474ca570e1db2a8d8fa64d78e3f5f
# timestamp: 2009-01-28 13:02:16 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-27 22:46:04 +0000
@@ -1025,6 +1025,70 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq nil
+	      (mapcar
+	       (lambda (name)
+		 (setq key (mml2015-epg-find-usable-key
+			    (epg-list-keys context name key-type)
+			    usage))
+		 (unless (or key
+			     (y-or-n-p
+			      (format
+			       "No %s key for %s; skip it? "
+			       key-type-name name)))
+		   (error "No %s key for %s" key-type-name name))
+		 key)
+	       names)))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,31 +1246,19 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+		   (mml2015-epg-prompt-select-keys context sender 'sign)
+		 (mml2015-epg-choose-keys context sender 'sign)))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,46 +1301,28 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (list (car 
+		       (mml2015-epg-split-addresses 
+			config 
+			(message-options-get 'message-sender)))))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients sender)))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
+	      (mml2015-epg-choose-keys context recipients 'encrypt))
 	(unless recipients
 	  (error "No recipient specified")))
       (message-options-set 'mml2015-epg-recipients recipients))
@@ -1298,25 +1332,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
+		     (mml2015-epg-prompt-select-keys context sender 'sign)
+		   (mml2015-epg-choose-keys context sender 'sign)))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] mml2015-epg-choose-keys handle the verbose selection of keys.
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (5 preceding siblings ...)
  2009-01-28 12:02   ` [PATCH] Factorize choosing a key Daniel Dehennin
@ 2009-01-28 12:02   ` Daniel Dehennin
  2009-04-13 20:33     ` Daniel Dehennin
  2009-01-28 12:02   ` [PATCH] Fix variable name, only one sender Daniel Dehennin
                     ` (3 subsequent siblings)
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:02 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]



------------------------------------------------------------
revno: 120
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Wed 2009-01-28 01:53:31 +0100
message:
  mml2015-epg-choose-keys handle the verbose selection of keys.
  
  * lisp/mml2015.el (mml2015-epg-choose-keys): Modify to handle mml2015-verbose.
    Fix y-or-n-p question, y mean abort sending mail.
    (mml2015-epg-sign): No need to check for mml2015-verbose.
    (mml2015-epg-encrypt): No need to check for mml2015-verbose.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus120.patch --]
[-- Type: text/x-patch, Size: 7481 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090128005331-\
#   8o7gdc2i1y196zef
# target_branch: ../../gnus.head
# testament_sha1: 383c8784df954f7dfc77bfa5c36f60ec1f874be0
# timestamp: 2009-01-28 13:02:26 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-28 00:53:31 +0000
@@ -1025,6 +1025,83 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,31 +1259,17 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       (mml2015-epg-choose-keys context sender 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,74 +1312,34 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (list (car 
+		       (mml2015-epg-split-addresses 
+			config 
+			(message-options-get 'message-sender)))))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients sender)))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
       (setq signers
 	    (or (message-options-get 'mml2015-epg-signers)
 		(message-options-set
 		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
+		   (mml2015-epg-choose-keys context sender 'sign))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Fix variable name, only one sender.
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (6 preceding siblings ...)
  2009-01-28 12:02   ` [PATCH] mml2015-epg-choose-keys handle the verbose selection of keys Daniel Dehennin
@ 2009-01-28 12:02   ` Daniel Dehennin
  2009-01-28 12:02   ` [PATCH] Remove useless variables Daniel Dehennin
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:02 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]



------------------------------------------------------------
revno: 121
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Wed 2009-01-28 01:57:05 +0100
message:
  Fix variable name, only one sender.
  
  * lisp/mml2015.el (mml2015-epg-sign): Replace signers with signer.
    (mml2015-epg-encrypt): Replace signers with signer.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus121.patch --]
[-- Type: text/x-patch, Size: 7943 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090128005705-\
#   bdb8zjv8jl3dkyx8
# target_branch: ../../gnus.head
# testament_sha1: 1859325a10218af10aeacbb25a5f32e8af2a9a3d
# timestamp: 2009-01-28 13:02:40 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-28 00:57:05 +0000
@@ -1025,6 +1025,83 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,35 +1259,21 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
 	 signer-key
-	 (signers
-	  (or (message-options-get 'mml2015-epg-signers)
+	 (signer
+	  (or (message-options-get 'mml2015-epg-signer)
 	      (message-options-set
-	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       'mml2015-epg-signer
+	       (mml2015-epg-choose-keys context sender 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-    (epg-context-set-signers context signers)
+    (epg-context-set-signers context signer)
     (if mml2015-cache-passphrase
 	(epg-context-set-passphrase-callback
 	 context
@@ -1249,75 +1312,35 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (list (car 
+		       (mml2015-epg-split-addresses 
+			config 
+			(message-options-get 'message-sender)))))
 	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
+	cipher signer
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients sender)))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
-      (setq signers
-	    (or (message-options-get 'mml2015-epg-signers)
+      (setq signer
+	    (or (message-options-get 'mml2015-epg-signer)
 		(message-options-set
-		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
-      (epg-context-set-signers context signers))
+		 'mml2015-epg-signer
+		   (mml2015-epg-choose-keys context sender 'sign))))
+      (epg-context-set-signers context signer))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
     (if mml2015-cache-passphrase


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Remove useless variables
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (7 preceding siblings ...)
  2009-01-28 12:02   ` [PATCH] Fix variable name, only one sender Daniel Dehennin
@ 2009-01-28 12:02   ` Daniel Dehennin
  2009-04-13 20:33     ` Daniel Dehennin
  2009-01-28 12:03   ` [PATCH] Permit to select a key if more than one match a mail address Daniel Dehennin
  2009-04-13 20:31   ` mml2015-epg-sign do not use from header Daniel Dehennin
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:02 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]



------------------------------------------------------------
revno: 122
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Wed 2009-01-28 01:58:55 +0100
message:
  Remove useless variables
  
  * lisp/mml2015.el (mml2015-epg-sign): Remove variable signer-key.
    (mml2015-epg-encrypt): Remove variables signer-key and recipient-key.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus122.patch --]
[-- Type: text/x-patch, Size: 7985 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090128005855-\
#   ztz9z6fz1fuf18x9
# target_branch: ../../gnus.head
# testament_sha1: 8c253d125ee3216224f3336db7039f0b889dbc74
# timestamp: 2009-01-28 13:02:48 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-28 00:58:55 +0000
@@ -1025,6 +1025,83 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,35 +1259,20 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
-	 signer-key
-	 (signers
-	  (or (message-options-get 'mml2015-epg-signers)
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
+	 (signer
+	  (or (message-options-get 'mml2015-epg-signer)
 	      (message-options-set
-	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       'mml2015-epg-signer
+	       (mml2015-epg-choose-keys context sender 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-    (epg-context-set-signers context signers)
+    (epg-context-set-signers context signer)
     (if mml2015-cache-passphrase
 	(epg-context-set-passphrase-callback
 	 context
@@ -1249,75 +1311,34 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (list (car 
+		       (mml2015-epg-split-addresses 
+			config 
+			(message-options-get 'message-sender)))))
 	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+	cipher signer
+	(boundary (mml-compute-boundary cont)))
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients sender)))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
-      (setq signers
-	    (or (message-options-get 'mml2015-epg-signers)
+      (setq signer
+	    (or (message-options-get 'mml2015-epg-signer)
 		(message-options-set
-		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
-      (epg-context-set-signers context signers))
+		 'mml2015-epg-signer
+		   (mml2015-epg-choose-keys context sender 'sign))))
+      (epg-context-set-signers context signer))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
     (if mml2015-cache-passphrase


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Permit to select a key if more than one match a mail address.
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (8 preceding siblings ...)
  2009-01-28 12:02   ` [PATCH] Remove useless variables Daniel Dehennin
@ 2009-01-28 12:03   ` Daniel Dehennin
  2009-04-13 20:33     ` Daniel Dehennin
  2009-04-13 20:31   ` mml2015-epg-sign do not use from header Daniel Dehennin
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-01-28 12:03 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]



------------------------------------------------------------
revno: 123
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: gnus.mml2015
timestamp: Wed 2009-01-28 02:09:27 +0100
message:
  Permit to select a key if more than one match a mail address.
  
  * lisp/mml2015.el (mml2015-epg-prompt-if-mutli-keys): New variable.
    (mml2015-epg-choose-keys): If a name has more than one key and if the
    user want it, prompt to select the one to use.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus123.patch --]
[-- Type: text/x-patch, Size: 8650 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090128010927-\
#   26t6dicbleuq378h
# target_branch: ../../gnus.head
# testament_sha1: 8f60d6ad2c8071a47704d48d5223b7dad88f9dcd
# timestamp: 2009-01-28 13:02:57 +0100
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090126152327-\
#   ccpvwbbxys1zto9f
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-01-28 01:09:27 +0000
@@ -990,6 +990,11 @@
 
 (defvar mml2015-epg-secret-key-id-list nil)
 
+(defvar mml2015-epg-prompt-if-mutli-keys t
+  "If t, the default, and there is more than one key to sign or encrypt a
+message, call mml2015-epg-prompt-select-key to select which one to choose.
+If nil, do not prompt for a key, usually, the first one will be used.")
+
 (defun mml2015-epg-passphrase-callback (context key-id ignore)
   (if (eq key-id 'SYM)
       (epg-passphrase-callback-function context key-id nil)
@@ -1025,6 +1030,87 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     ;; prompt if more than one key ?
+						     (or (= 1 
+							    (length (epg-list-keys context name key-type)))
+							 (not mml2015-epg-prompt-if-multi-keys))
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,35 +1268,20 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
-	 signer-key
-	 (signers
-	  (or (message-options-get 'mml2015-epg-signers)
+	 (config (epg-configuration))
+	 (sender (list (car 
+			(mml2015-epg-split-addresses 
+			 config 
+			 (message-options-get 'message-sender)))))
+	 (signer
+	  (or (message-options-get 'mml2015-epg-signer)
 	      (message-options-set
-	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       'mml2015-epg-signer
+	       (mml2015-epg-choose-keys context sender 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-    (epg-context-set-signers context signers)
+    (epg-context-set-signers context signer)
     (if mml2015-cache-passphrase
 	(epg-context-set-passphrase-callback
 	 context
@@ -1249,75 +1320,34 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (list (car 
+		       (mml2015-epg-split-addresses 
+			config 
+			(message-options-get 'message-sender)))))
 	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+	cipher signer
+	(boundary (mml-compute-boundary cont)))
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless sender
+	  (error "Message sender not set"))
+	(setq recipients (nconc recipients sender)))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
-      (setq signers
-	    (or (message-options-get 'mml2015-epg-signers)
+      (setq signer
+	    (or (message-options-get 'mml2015-epg-signer)
 		(message-options-set
-		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
-      (epg-context-set-signers context signers))
+		 'mml2015-epg-signer
+		   (mml2015-epg-choose-keys context sender 'sign))))
+      (epg-context-set-signers context signer))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
     (if mml2015-cache-passphrase


^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-26  1:34 ` Daiki Ueno
@ 2009-02-28 11:25   ` Reiner Steib
  2009-03-01  3:27     ` Daiki Ueno
  0 siblings, 1 reply; 53+ messages in thread
From: Reiner Steib @ 2009-02-28 11:25 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: Daniel Dehennin, ding

On Mon, Jan 26 2009, Daiki Ueno wrote:

>>>>>> In <87k58jqh6u.fsf@hati.baby-gnu.org> 
>>>>>>	Daniel Dehennin <daniel.dehennin@baby-gnu.org> wrote:
>> I'm using EasyPG backend to mml2015 and see that the from header is
>> not used for mail siging.
>
>> Looking at the code I see that the sender address is not used.
>
>> I create 3 new functions and use them to simplify/correct
>> mml2015-epg-sign and mml2015-epg-encrypt behavior.
>
> Thanks for the patch.  The behavior change sounds reasonable.  However,
> the patch looks too large since it contains two independent changes
> (i.e. for feature enhancement and code cleanup).  Could you please
> isolate these changes each other and post them in separate patches?

The paperwork for Daniel Dehennin is complete now.

Could you please review and install those changes that should be
installed for the upcoming Emacs 23 release, i.e. bug fixes,
corrections, etc?

[ Cf. http://thread.gmane.org/gmane.emacs.gnus.general/68204 ]

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-02-28 11:25   ` Reiner Steib
@ 2009-03-01  3:27     ` Daiki Ueno
  0 siblings, 0 replies; 53+ messages in thread
From: Daiki Ueno @ 2009-03-01  3:27 UTC (permalink / raw)
  To: Daniel Dehennin; +Cc: ding

>>>>> In <87d4d2by6k.fsf@marauder.physik.uni-ulm.de> 
>>>>>	Reiner Steib <reinersteib+gmane@imap.cc> wrote:
> The paperwork for Daniel Dehennin is complete now.

> Could you please review and install those changes that should be
> installed for the upcoming Emacs 23 release, i.e. bug fixes,
> corrections, etc?

> [ Cf. http://thread.gmane.org/gmane.emacs.gnus.general/68204 ]

Will review, but I see no urgent issue that needs to be done before
Emacs 23 release---those changes only contain feature enhancements and
large cosmetic changes.
-- 
Daiki Ueno



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH] mml2015-epg-sign does not use from header.
  2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
@ 2009-03-01 17:13     ` Daiki Ueno
  2009-03-03 18:59       ` Daniel Dehennin
  2009-04-13 20:31     ` Daniel Dehennin
  2009-04-13 20:32     ` [PATCH] mml2015-epg-encrypt do not use from header to sign Daniel Dehennin
  2 siblings, 1 reply; 53+ messages in thread
From: Daiki Ueno @ 2009-03-01 17:13 UTC (permalink / raw)
  To: Daniel Dehennin; +Cc: ding

>>>>> In <87wscf3al8.fsf@hati.baby-gnu.org> 
>>>>>	Daniel Dehennin <daniel.dehennin@baby-gnu.org> wrote:
>   * lisp/mml2015.el (mml2015-epg-sign): New variable 'sender'
>     is (message-options-get 'message-sender). Use it in place of
>     mml2015-signers.

Sorry for late response, and thanks for splitting your patch.

> --- lisp/mml2015.el	2009-01-22 07:02:15 +0000
> +++ lisp/mml2015.el	2009-01-27 18:44:28 +0000
> @@ -1182,6 +1182,7 @@
>    (let* ((inhibit-redisplay t)
>  	 (context (epg-make-context))
>  	 (boundary (mml-compute-boundary cont))
> +	 (sender (message-options-get 'message-sender))
>  	 signer-key
>  	 (signers
>  	  (or (message-options-get 'mml2015-epg-signers)
> @@ -1191,8 +1192,8 @@
>  		   (epa-select-keys context "\
>  Select keys for signing.
>  If no one is selected, default secret key is used.  "
> -				    mml2015-signers t)
> -		 (if mml2015-signers
> +				    sender t)
> +		 (if sender
>  		     (delq nil
>  			   (mapcar
>  			    (lambda (signer)
> @@ -1206,7 +1207,7 @@
>  					    signer)))
>  				(error "No secret key for %s" signer))
>  			      signer-key)
> -			    mml2015-signers)))))))
> +			    (list sender))))))))
>  	 signature micalg)
>      (epg-context-set-armor context t)
>      (epg-context-set-textmode context t)

Unfortunatelly, this patch looks unacceptable since it breaks the
compatibility of the user setting.  Although I agree with that the
typical user would expect his From: line be used as the keygrip of the
signing key, existing users (including I) may have a setting of
mml2015-signers.

Why not adjust mml2015-signers to include the From: address instead of
entirely overwriting it?  Like this:

(defun mml2015-epg-uniquify-keys (keys)
  (let (key-id key-ids)
    (delq nil (mapcar
	       (lambda (key)
		 (setq key-id (car (epg-key-sub-key-list key)))
		 (unless (member key-id key-ids)
		   (setq key-ids (cons key-id key-ids))
		   key))
	       keys))))

In mml2015-epg-sign:

- mml2015-signers)))))))
+ (append mml2015-signers (list sender)))))))))

...

+ (setq signers (mml2015-epg-uniquify-keys signers))

Regards,
-- 
Daiki Ueno



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH] mml2015-epg-sign does not use from header.
  2009-03-01 17:13     ` Daiki Ueno
@ 2009-03-03 18:59       ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-03-03 18:59 UTC (permalink / raw)
  To: ding

Le 5660 Septembre 1993, Daiki Ueno a envoyé:
> Unfortunatelly, this patch looks unacceptable since it breaks the
> compatibility of the user setting.  Although I agree with that the

[...]

> + (setq signers (mml2015-epg-uniquify-keys signers))

Ok, I'll post new patches soon, I'm quite busy for a couple of days.

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-28 11:57 ` Daniel Dehennin
                     ` (9 preceding siblings ...)
  2009-01-28 12:03   ` [PATCH] Permit to select a key if more than one match a mail address Daniel Dehennin
@ 2009-04-13 20:31   ` Daniel Dehennin
  2009-04-13 22:48     ` Daiki Ueno
  10 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:31 UTC (permalink / raw)
  To: ding

Le 5628 Septembre 1993, Daniel Dehennin a envoyé:
> Hello,
>
> After setting up a bzr repository to track my changes, I can provide
> step by step modifications.
>
> The 11 following patches permit to:
> - use from header to sign message
> - factorize some code
> - ask the user about the key to use if more than one match

I take a long time before coming back to this issue, following are a set
of new patch against HEAD which add support for mml2015-signers.

As I don't use mml2015-signers, let me know if it's ok.

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1



^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] mml2015-epg-sign does not use from header.
  2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
  2009-03-01 17:13     ` Daiki Ueno
@ 2009-04-13 20:31     ` Daniel Dehennin
  2009-04-13 20:32     ` [PATCH] mml2015-epg-encrypt do not use from header to sign Daniel Dehennin
  2 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:31 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]



------------------------------------------------------------
revno: 134
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:04:07 +0200
message:
  mml2015-epg-sign does not use from header.
  
  * lisp/mml2015.el (mml2015-epg-sign): New variable 'sender'
    is (message-options-get 'message-sender). Use it in addition to
    mml2015-signers.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-134.patch --]
[-- Type: text/x-patch, Size: 1379 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413180407-\
#   c8k3bhxwfy83520m
# target_branch: ../../gnus.head
# testament_sha1: a5b6834d5c550ff0991c0267d2ca24a941e55635
# timestamp: 2009-04-13 20:57:04 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:04:07 +0000
@@ -1182,6 +1182,7 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
@@ -1191,8 +1192,8 @@
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+				    (cons sender mml2015-signers) t)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1207,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] mml2015-epg-encrypt do not use from header to sign.
  2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
  2009-03-01 17:13     ` Daiki Ueno
  2009-04-13 20:31     ` Daniel Dehennin
@ 2009-04-13 20:32     ` Daniel Dehennin
  2 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:32 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 415 bytes --]



------------------------------------------------------------
revno: 135
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:06:53 +0200
message:
  mml2015-epg-encrypt do not use from header to sign.
  
  * lisp/mml2015.el (mml2015-epg-encrypt): New variable 'sender'
    is (message-options-get 'message-sender). Use it in addition to
    mml2015-signers.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-135.patch --]
[-- Type: text/x-patch, Size: 2819 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413180653-\
#   v67k5z5akqbiffsa
# target_branch: ../../gnus.head
# testament_sha1: 2297afa76761151c604ef7a0985fb033bdc209dc
# timestamp: 2009-04-13 20:57:26 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:06:53 +0000
@@ -1182,6 +1182,7 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
@@ -1191,8 +1192,8 @@
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+				    (cons sender mml2015-signers) t)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1207,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,6 +1250,7 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
@@ -1266,9 +1268,9 @@
 					      (read-string "Recipients: ")))
 		     "[ \f\t\n\r\v,]+"))))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if mml2015-verbose
 	  (setq recipients
 		(epa-select-keys context "\
@@ -1301,8 +1303,8 @@
 		     (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+				      (cons sender mml2015-signers) t)
+		   (if (or sender mml2015-signers)
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1318,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (cons sender mml2015-signers))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Factor spliting mail addresses.
  2009-01-28 12:00   ` [PATCH] Factor spliting mail addresses Daniel Dehennin
@ 2009-04-13 20:32     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:32 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]



------------------------------------------------------------
revno: 136
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:07:37 +0200
message:
  Factor spliting mail addresses.
  
  * lisp/mml2015.el (mml2015-epg-split-addresses): Split a string of addresses.
    (mml2015-epg-encrypt): Use it to set recipients.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-136.patch --]
[-- Type: text/x-patch, Size: 3793 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413180737-\
#   rj1gz47cn7iha9zu
# target_branch: ../../gnus.head
# testament_sha1: 951a8dc52109b188478c54a7a6afb0eae4c80017
# timestamp: 2009-04-13 20:58:52 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:07:37 +0000
@@ -1025,6 +1025,18 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,6 +1194,7 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
@@ -1191,8 +1204,8 @@
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+				    (cons sender mml2015-signers) t)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1219,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,26 +1262,20 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if mml2015-verbose
 	  (setq recipients
 		(epa-select-keys context "\
@@ -1301,8 +1308,8 @@
 		     (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+				      (cons sender mml2015-signers) t)
+		   (if (or sender mml2015-signers)
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1323,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (cons sender mml2015-signers))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Cleanup selecting a key for sign and encryption.
  2009-01-28 12:01   ` [PATCH] Cleanup selecting a key for sign and encryption Daniel Dehennin
@ 2009-04-13 20:32     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:32 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]



------------------------------------------------------------
revno: 137
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:17:09 +0200
message:
  Cleanup selecting a key for sign and encryption.
  
  * lisp/mml2015.el (mml2015-epg-prompt-select-keys): New function.
    (mml2015-epg-sign): Use it.
    (mml2015-epg-encrypt): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-137.patch --]
[-- Type: text/x-patch, Size: 5184 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413181709-\
#   6t1hgpg4585mapmw
# target_branch: ../../gnus.head
# testament_sha1: bd879ebf33dd7fbc8a6723fb4101951495e85b4a
# timestamp: 2009-04-13 20:59:19 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:17:09 +0000
@@ -1025,6 +1025,43 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,17 +1219,15 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+		   (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1241,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,32 +1284,23 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
 	      (delq nil
 		    (mapcar
@@ -1298,11 +1324,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+		     (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign)
+		   (if (or sender mml2015-signers)
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1339,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (cons sender mml2015-signers))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Only one sender.
  2009-01-28 12:02   ` [PATCH] Only one sender Daniel Dehennin
@ 2009-04-13 20:32     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:32 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]



------------------------------------------------------------
revno: 138
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:25:42 +0200
message:
  Only one sender.
  
  * lisp/mml2015.el (mml2015-epg-sign): From header should have only one
    sender address. Split it and fetch only the first one.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-138.patch --]
[-- Type: text/x-patch, Size: 5281 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413182542-\
#   i9jzkccgc9e1365g
# target_branch: ../../gnus.head
# testament_sha1: 8a13d89d874f9f0a56ce806e2856ec109d4ffa0c
# timestamp: 2009-04-13 21:00:07 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:25:42 +0000
@@ -1025,6 +1025,43 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,17 +1219,18 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+		   (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1244,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1249,32 +1287,23 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	(config (epg-configuration))
+	(sender (message-options-get 'message-sender))
 	(recipients (message-options-get 'mml2015-epg-recipients))
 	cipher signers
 	(boundary (mml-compute-boundary cont))
 	recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
 	      (delq nil
 		    (mapcar
@@ -1298,11 +1327,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+		     (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign)
+		   (if (or sender mml2015-signers)
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1342,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (cons sender mml2015-signers))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Only one sender.
  2009-01-28 12:02   ` Daniel Dehennin
@ 2009-04-13 20:32     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:32 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]



------------------------------------------------------------
revno: 139
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:36:52 +0200
message:
  Only one sender.
  
  * lisp/mml2015.el (mml2015-epg-encrypt): From header should have only one
    sender address. Split it and fetch only the first one.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-139.patch --]
[-- Type: text/x-patch, Size: 5677 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413183652-\
#   eknu6ads6ixw2rhq
# target_branch: ../../gnus.head
# testament_sha1: 0493d007a40fbce120796830b4d9c6c787c2f8f8
# timestamp: 2009-04-13 21:01:02 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:36:52 +0000
@@ -1025,6 +1025,43 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,17 +1219,18 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+		   (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -1206,7 +1244,7 @@
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1246,35 +1284,28 @@
     (goto-char (point-max))))
 
 (defun mml2015-epg-encrypt (cont &optional sign)
-  (let ((inhibit-redisplay t)
-	(context (epg-make-context))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+  (let* ((inhibit-redisplay t)
+	 (context (epg-make-context))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
+	 (recipients (message-options-get 'mml2015-epg-recipients))
+	 cipher signers
+	 (boundary (mml-compute-boundary cont))
+	 recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
 	      (delq nil
 		    (mapcar
@@ -1298,11 +1329,8 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
+		     (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign)
+		   (if (or sender mml2015-signers)
 		       (delq nil
 			     (mapcar
 			      (lambda (signer)
@@ -1316,7 +1344,7 @@
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      mml2015-signers)))))))
+			      (cons sender mml2015-signers))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Factorize choosing a key.
  2009-01-28 12:02   ` [PATCH] Factorize choosing a key Daniel Dehennin
@ 2009-04-13 20:33     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:33 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]



------------------------------------------------------------
revno: 140
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:38:15 +0200
message:
  Factorize choosing a key.
  
  * lisp/mml2015.el (mml2015-epg-choose-keys): New function.
    (mml2015-epg-encrypt): Use it.
    (mml2015-epg-encrypt): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-140.patch --]
[-- Type: text/x-patch, Size: 7349 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413183815-\
#   py6tj057jlml4f05
# target_branch: ../../gnus.head
# testament_sha1: 53d16ca70e4a4f5db511988154036c3775a1c060
# timestamp: 2009-04-13 21:04:19 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:38:15 +0000
@@ -1025,6 +1025,70 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq nil
+	      (mapcar
+	       (lambda (name)
+		 (setq key (mml2015-epg-find-usable-key
+			    (epg-list-keys context name key-type)
+			    usage))
+		 (unless (or key
+			     (y-or-n-p
+			      (format
+			       "No %s key for %s; skip it? "
+			       key-type-name name)))
+		   (error "No %s key for %s" key-type-name name))
+		 key)
+	       names)))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,31 +1246,17 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
 	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+		 (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign)))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1246,49 +1296,30 @@
     (goto-char (point-max))))
 
 (defun mml2015-epg-encrypt (cont &optional sign)
-  (let ((inhibit-redisplay t)
-	(context (epg-make-context))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+  (let* ((inhibit-redisplay t)
+	 (context (epg-make-context))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
+	 (recipients (message-options-get 'mml2015-epg-recipients))
+	 cipher signers
+	 (boundary (mml-compute-boundary cont))
+	 recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if mml2015-verbose
 	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
+		(mml2015-epg-prompt-select-keys context recipients 'encrypt))
 	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
+	      (mml2015-epg-choose-keys context recipients 'encrypt))
 	(unless recipients
 	  (error "No recipient specified")))
       (message-options-set 'mml2015-epg-recipients recipients))
@@ -1298,25 +1329,7 @@
 		(message-options-set
 		 'mml2015-epg-signers
 		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
+		   (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign)))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] mml2015-epg-choose-keys handle the verbose selection of keys.
  2009-01-28 12:02   ` [PATCH] mml2015-epg-choose-keys handle the verbose selection of keys Daniel Dehennin
@ 2009-04-13 20:33     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:33 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]



------------------------------------------------------------
revno: 141
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:46:39 +0200
message:
  mml2015-epg-choose-keys handle the verbose selection of keys.
  
  * lisp/mml2015.el (mml2015-epg-choose-keys): Modify to handle mml2015-verbose.
    Fix y-or-n-p question, y mean abort sending mail.
    (mml2015-epg-sign): No need to check for mml2015-verbose.
    (mml2015-epg-encrypt): No need to check for mml2015-verbose.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-141.patch --]
[-- Type: text/x-patch, Size: 7912 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413184639-\
#   0ej3g3ykoh0rpai7
# target_branch: ../../gnus.head
# testament_sha1: 60a9c5404d32ba705d74d2815da5cad517e3af6d
# timestamp: 2009-04-13 21:04:47 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:46:39 +0000
@@ -1025,6 +1025,83 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,31 +1259,16 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1246,77 +1308,36 @@
     (goto-char (point-max))))
 
 (defun mml2015-epg-encrypt (cont &optional sign)
-  (let ((inhibit-redisplay t)
-	(context (epg-make-context))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+  (let* ((inhibit-redisplay t)
+	 (context (epg-make-context))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
+	 (recipients (message-options-get 'mml2015-epg-recipients))
+	 cipher signers
+	 (boundary (mml-compute-boundary cont))
+	 recipient-key signer-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
       (setq signers
 	    (or (message-options-get 'mml2015-epg-signers)
 		(message-options-set
 		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
+		 (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Remove useless variables
  2009-01-28 12:02   ` [PATCH] Remove useless variables Daniel Dehennin
@ 2009-04-13 20:33     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:33 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]



------------------------------------------------------------
revno: 142
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:49:22 +0200
message:
  Remove useless variables
  
  * lisp/mml2015.el (mml2015-epg-sign): Remove variable signer-key.
    (mml2015-epg-encrypt): Remove variables signer-key and recipient-key.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-142.patch --]
[-- Type: text/x-patch, Size: 7884 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413184922-\
#   ctebq2id4u22jc1q
# target_branch: ../../gnus.head
# testament_sha1: 8e08acbed0400aaf7c3737f2f3f434ae19dd8345
# timestamp: 2009-04-13 21:05:47 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:49:22 +0000
@@ -1025,6 +1025,83 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,31 +1259,15 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
-	 signer-key
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1246,77 +1307,35 @@
     (goto-char (point-max))))
 
 (defun mml2015-epg-encrypt (cont &optional sign)
-  (let ((inhibit-redisplay t)
-	(context (epg-make-context))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+  (let* ((inhibit-redisplay t)
+	 (context (epg-make-context))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
+	 (recipients (message-options-get 'mml2015-epg-recipients))
+	 cipher signers
+	 (boundary (mml-compute-boundary cont)))
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
       (setq signers
 	    (or (message-options-get 'mml2015-epg-signers)
 		(message-options-set
 		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
+		 (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH] Permit to select a key if more than one match a mail address.
  2009-01-28 12:03   ` [PATCH] Permit to select a key if more than one match a mail address Daniel Dehennin
@ 2009-04-13 20:33     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2009-04-13 20:33 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]



------------------------------------------------------------
revno: 143
committer: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
branch nick: mml2015
timestamp: Mon 2009-04-13 20:50:33 +0200
message:
  Permit to select a key if more than one match a mail address.
  
  * lisp/mml2015.el (mml2015-epg-prompt-if-mutli-keys): New variable.
    (mml2015-epg-choose-keys): If a name has more than one key and if the
    user want it, prompt to select the one to use.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Gnus-mm2015-143.patch --]
[-- Type: text/x-patch, Size: 8549 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: daniel.dehennin@baby-gnu.org-20090413185033-\
#   h1lmms72gr14teu8
# target_branch: ../../gnus.head
# testament_sha1: 6b25a12c4b5fc431faafe4a2c181a59b13f2ec3b
# timestamp: 2009-04-13 21:06:10 +0200
# source_branch: .
# base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\
#   rhtvglq3r87nljez
# 
# Begin patch
=== modified file 'lisp/mml2015.el'
--- lisp/mml2015.el	2009-01-22 07:02:15 +0000
+++ lisp/mml2015.el	2009-04-13 18:50:33 +0000
@@ -990,6 +990,11 @@
 
 (defvar mml2015-epg-secret-key-id-list nil)
 
+(defvar mml2015-epg-prompt-if-mutli-keys t
+  "If t, the default, and there is more than one key to sign or encrypt a
+message, call mml2015-epg-prompt-select-key to select which one to choose.
+If nil, do not prompt for a key, usually, the first one will be used.")
+
 (defun mml2015-epg-passphrase-callback (context key-id ignore)
   (if (eq key-id 'SYM)
       (epg-passphrase-callback-function context key-id nil)
@@ -1025,6 +1030,87 @@
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+(defun mml2015-epg-split-addresses (config addresses)
+  "Split a string of addresses delimited by [ \f\t\n\r\v,]+."
+  (apply #'nconc
+	 (mapcar
+	  (lambda (recipient)
+	    (or (epg-expand-group config recipient)
+		(list (concat "<" recipient ">"))))
+	  (split-string
+	   (or addresses
+	       (read-string "Addresses: "))
+	   "[ \f\t\n\r\v,]+"))))
+
+(defun mml2015-epg-prompt-select-keys (context &optional names usage)
+  "Return a key matching NAME.
+USAGE is nil or encrypt to search private keyring.
+USAGE is t or sign to search secret keyring.
+Mostly a wrapper around epa-select-keys."
+  (let ((action (cond
+		 ((memq usage '(t sign)) "signing")
+		 ((memq usage '(nil encrypt)) "encryption")
+		 (t "encryption")))
+	(key-type (cond
+		   ((memq usage '(t sign)) 'secret)
+		   ((memq usage '(nil encrypt)) 'public)
+		   (t 'public)))
+	(no-selection (cond
+		       ((memq usage '(t sign)) "default secret key is used")
+		       ((memq usage '(nil encrypt)) "symmetric encryption will be performed")
+		       (t "symmetric encryption will be performed"))))
+    (epa-select-keys context
+		     (format "\
+Select a key for %s.
+If no one is selected, %s
+If more than one is select, first one is used.  "
+			     action no-selection)
+		     names key-type)))
+
+(defun mml2015-epg-choose-keys (context &optional names usage)
+"Return a list of keys for each NAMES matching USAGE."
+  (let ((key-type (cond
+                   ((memq usage '(t sign)) 'secret)
+                   ((memq usage '(nil encrypt)) 'public)
+                   (t 'public)))
+        (key-type-name (cond
+                        ((memq usage '(t sign)) "secret")
+                        ((memq usage '(nil encrypt)) "public")
+                        (t "public")))
+        key)
+    (if names
+	(delq t
+	      (delq nil
+		    (mapcar
+		     (lambda (name)
+		       (if (and
+			    ;; Fail to fetch a key
+			    (not (setq key
+				       ;; Does name have any key ?
+				       (and (epg-list-keys context name key-type)
+					    (or (and (not mml2015-verbose)
+						     ;; prompt if more than one key ?
+						     (or (= 1 
+							    (length (epg-list-keys context name key-type)))
+							 (not mml2015-epg-prompt-if-multi-keys))
+						     (mml2015-epg-find-usable-key
+						      (epg-list-keys context name key-type)
+						      usage))
+						(mml2015-epg-find-usable-key
+						 (mml2015-epg-prompt-select-keys context name usage)
+						 usage)
+						;; Avoid error if the user don't select a
+						;; key because epa-select-keys returns nil
+						t))))
+			    ;; No key, ask to abord
+			    (y-or-n-p
+			     (format
+			      "No %s key for %s; abort? "
+			      key-type-name name)))
+			   (error "No %s key for %s: aborted" key-type-name name))
+		       key)
+		     names))))))
+
 (defun mml2015-epg-decrypt (handle ctl)
   (catch 'error
     (let ((inhibit-redisplay t)
@@ -1182,31 +1268,15 @@
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
-	 signer-key
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
 	      (message-options-set
 	       'mml2015-epg-signers
-	       (if mml2015-verbose
-		   (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
-		     (delq nil
-			   (mapcar
-			    (lambda (signer)
-			      (setq signer-key (mml2015-epg-find-usable-key
-						(epg-list-keys context signer t)
-						'sign))
-			      (unless (or signer-key
-					  (y-or-n-p
-					   (format
-					    "No secret key for %s; skip it? "
-					    signer)))
-				(error "No secret key for %s" signer))
-			      signer-key)
-			    mml2015-signers)))))))
+	       (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1246,77 +1316,35 @@
     (goto-char (point-max))))
 
 (defun mml2015-epg-encrypt (cont &optional sign)
-  (let ((inhibit-redisplay t)
-	(context (epg-make-context))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml2015-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key signer-key)
+  (let* ((inhibit-redisplay t)
+	 (context (epg-make-context))
+	 (config (epg-configuration))
+	 (sender (car (mml2015-epg-split-addresses 
+		       config 
+		       (message-options-get 'message-sender))))
+	 (recipients (message-options-get 'mml2015-epg-recipients))
+	 cipher signers
+	 (boundary (mml-compute-boundary cont)))
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list (concat "<" recipient ">"))))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+	    (mml2015-epg-split-addresses
+	     config
+	     (message-options-get 'message-recipients)))
       (when mml2015-encrypt-to-self
-	(unless mml2015-signers
-	  (error "mml2015-signers not set"))
-	(setq recipients (nconc recipients mml2015-signers)))
-      (if mml2015-verbose
-	  (setq recipients
-		(epa-select-keys context "\
-Select recipients for encryption.
-If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (delq nil
-		    (mapcar
-		     (lambda (recipient)
-		       (setq recipient-key (mml2015-epg-find-usable-key
-					    (epg-list-keys context recipient)
-					    'encrypt))
-		       (unless (or recipient-key
-				   (y-or-n-p
-				    (format "No public key for %s; skip it? "
-					    recipient)))
-			 (error "No public key for %s" recipient))
-		       recipient-key)
-		     recipients)))
-	(unless recipients
-	  (error "No recipient specified")))
+	(unless (or sender mml2015-signers)
+	  (error "Message sender and mml2015-signers not set"))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
+      (setq recipients
+	    (mml2015-epg-choose-keys context recipients 'encrypt))
+      (unless recipients
+	(error "No recipient specified"))
       (message-options-set 'mml2015-epg-recipients recipients))
     (when sign
       (setq signers
 	    (or (message-options-get 'mml2015-epg-signers)
 		(message-options-set
 		 'mml2015-epg-signers
-		 (if mml2015-verbose
-		     (epa-select-keys context "\
-Select keys for signing.
-If no one is selected, default secret key is used.  "
-				      mml2015-signers t)
-		   (if mml2015-signers
-		       (delq nil
-			     (mapcar
-			      (lambda (signer)
-				(setq signer-key (mml2015-epg-find-usable-key
-						  (epg-list-keys context signer t)
-						  'sign))
-				(unless (or signer-key
-					    (y-or-n-p
-					     (format
-					      "No secret key for %s; skip it? "
-					      signer)))
-				  (error "No secret key for %s" signer))
-				signer-key)
-			      mml2015-signers)))))))
+		 (mml2015-epg-choose-keys context (cons sender mml2015-signers) 'sign))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)


^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-04-13 20:31   ` mml2015-epg-sign do not use from header Daniel Dehennin
@ 2009-04-13 22:48     ` Daiki Ueno
  0 siblings, 0 replies; 53+ messages in thread
From: Daiki Ueno @ 2009-04-13 22:48 UTC (permalink / raw)
  To: Daniel Dehennin; +Cc: ding

>>>>> In <87ljq4gury.fsf@hati.baby-gnu.org> 
>>>>>	Daniel Dehennin <daniel.dehennin@baby-gnu.org> wrote:
> I take a long time before coming back to this issue, following are a set
> of new patch against HEAD which add support for mml2015-signers.

Thanks, but I personally say that you have gone too far.

> As I don't use mml2015-signers, let me know if it's ok.

Please try it by yourself--I meant in the previous mail that if you
appended message-sender to mml2015-signers properly, the rest of your
patches would make little sense (from the user's perspective) because
there is already proper handling of mml2015-signers.

Summary:

* Gnus-mm2015-134.patch, Gnus-mm2015-135.patch:

Worth being installed with a little modification (to uniquify the
elements of mml2015-signers, to enclose the message-sender with angle
brackets to let GnuPG understand it is an emal address, etc.)

* Gnus-mm2015-137.patch, Gnus-mm2015-138.patch, Gnus-mm2015-140.patch,
Gnus-mm2015-141.patch:

We don't want them right now.

Regards,
-- 
Daiki Ueno



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2009-01-25 20:11 mml2015-epg-sign do not use from header Daniel Dehennin
                   ` (2 preceding siblings ...)
  2009-01-28 11:57 ` Daniel Dehennin
@ 2010-11-15 23:11 ` Daniel Dehennin
  2010-11-15 23:13   ` mml2015-epg-sign does not use From header Daniel Dehennin
  2010-11-16 18:21   ` mml2015-epg-sign do not use from header Lars Magne Ingebrigtsen
  3 siblings, 2 replies; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-15 23:11 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> I'm using EasyPG backend to mml2015 and see that the from header is
> not used for mail siging.
>
> Looking at the code I see that the sender address is not used.

Hello,

I'm recoding my patches to make mml2015 use the From header to sign.

The two first patches, coming soon, are very simple to show how to make
this works.

The from header is added to mml2015-signers when needed, if it's not
nil and mm-sign-option is not 'guided, the mails are signed by all the
ID of mml2015-signers _and_ the address in the from header.

Next, I will reduce code duplication.

You can fetch my git branch[1] to look and test easily, no need to
manually apply patches ;-)

Regards.

Footnotes: 
[1]  git checkout -b mml2015-use-from-to-sign master
     git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git dad/mml2015-use-from-to-sign
     
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* mml2015-epg-sign does not use From header.
  2010-11-15 23:11 ` Daniel Dehennin
@ 2010-11-15 23:13   ` Daniel Dehennin
  2010-11-15 23:23     ` Daniel Dehennin
  2010-11-16 18:21   ` mml2015-epg-sign do not use from header Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-15 23:13 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]

* lisp/mml2015.el (mml2015-epg-sign): New variable 'sender'
  is (message-options-get 'message-sender) and append it to
  mml2015-signers. If mm-sign-option is not 'guided, mml2015-signers
  and sender sign the mail.
---
 lisp/mml2015.el |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/mml2015.el b/lisp/mml2015.el
index 55ebf8c..71329f0 100644
--- a/lisp/mml2015.el
+++ b/lisp/mml2015.el
@@ -941,6 +941,7 @@ Whether the passphrase is cached at all is controlled by
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml2015-epg-signers)
@@ -950,8 +951,8 @@ Whether the passphrase is cached at all is controlled by
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    mml2015-signers t)
-		 (if mml2015-signers
+				    (append mml2015-signers (list sender)) t)
+		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
 			    (lambda (signer)
@@ -965,7 +966,7 @@ If no one is selected, default secret key is used.  "
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    mml2015-signers)))))))
+			    (append mml2015-signers (list sender)))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-- 
1.7.2.3

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign does not use From header.
  2010-11-15 23:13   ` mml2015-epg-sign does not use From header Daniel Dehennin
@ 2010-11-15 23:23     ` Daniel Dehennin
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-15 23:23 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 3390 bytes --]

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> @@ -950,8 +951,8 @@ Whether the passphrase is cached at all is controlled by
>  		   (epa-select-keys context "\
>  Select keys for signing.
>  If no one is selected, default secret key is used.  "
> -				    mml2015-signers t)
> -		 (if mml2015-signers
> +				    (append mml2015-signers (list sender)) t)
> +		 (if (or sender mml2015-signers)
>  		     (delq nil
>  			   (mapcar
>  			    (lambda (signer)
> @@ -965,7 +966,7 @@ If no one is selected, default secret key is used.  "
>  					    signer)))
>  				(error "No secret key for %s" signer))
>  			      signer-key)
> -			    mml2015-signers)))))))
> +			    (append mml2015-signers (list sender)))))))))
>  	 signature micalg)
>      (epg-context-set-armor context t)
>      (epg-context-set-textmode context t)
> -- 
> 1.7.2.3

I just see that the (append mml2015-signers (list sender)) can be
rewritten as (cons sender mml2015-signers), I thought about ordering at
first but it's just useless.

The same apply for the other patch.

---
 lisp/mml2015.el |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/mml2015.el b/lisp/mml2015.el
index 7697f8a..5a515fa 100644
--- a/lisp/mml2015.el
+++ b/lisp/mml2015.el
@@ -951,7 +951,7 @@ Whether the passphrase is cached at all is controlled by
 		   (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				    (append mml2015-signers (list sender)) t)
+				    (cons sender mml2015-signers) t)
 		 (if (or sender mml2015-signers)
 		     (delq nil
 			   (mapcar
@@ -966,7 +966,7 @@ If no one is selected, default secret key is used.  "
 					    signer)))
 				(error "No secret key for %s" signer))
 			      signer-key)
-			    (append mml2015-signers (list sender)))))))))
+			    (cons sender mml2015-signers))))))))
 	 signature micalg)
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
@@ -1029,7 +1029,7 @@ If no one is selected, default secret key is used.  "
       (when mml2015-encrypt-to-self
 	(unless (or sender mml2015-signers)
 	  (error "Message sender and mml2015-signers not set"))
-	(setq recipients (nconc recipients (append mml2015-signers (list sender)))))
+	(setq recipients (nconc recipients (cons sender mml2015-signers))))
       (if (eq mm-encrypt-option 'guided)
 	  (setq recipients
 		(epa-select-keys context "\
@@ -1062,7 +1062,7 @@ If no one is selected, symmetric encryption will be performed.  "
 		     (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				      (append mml2015-signers (list sender)) t)
+				      (cons mml2015-signers) t)
 		   (if (or sender mml2015-signers)
 		       (delq nil
 			     (mapcar
@@ -1077,7 +1077,7 @@ If no one is selected, default secret key is used.  "
 					      signer)))
 				  (error "No secret key for %s" signer))
 				signer-key)
-			      (append mml2015-signers (list sender)))))))))
+			      (cons mml2015-signers))))))))
       (epg-context-set-signers context signers))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-- 
1.7.2.3

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-15 23:11 ` Daniel Dehennin
  2010-11-15 23:13   ` mml2015-epg-sign does not use From header Daniel Dehennin
@ 2010-11-16 18:21   ` Lars Magne Ingebrigtsen
  2010-11-16 20:23     ` Daniel Dehennin
  1 sibling, 1 reply; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-16 18:21 UTC (permalink / raw)
  To: ding

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> The two first patches, coming soon, are very simple to show how to make
> this works.

Looks OK to me; just let me know which ones I should apply...

> You can fetch my git branch[1] to look and test easily, no need to
> manually apply patches ;-)

... or pull.    :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-16 18:21   ` mml2015-epg-sign do not use from header Lars Magne Ingebrigtsen
@ 2010-11-16 20:23     ` Daniel Dehennin
  2010-11-16 20:27       ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-16 20:23 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:
>
>> The two first patches, coming soon, are very simple to show how to make
>> this works.
>
> Looks OK to me; just let me know which ones I should apply...

I redone clean patches, you can pull both of them from the new branch[1]

>> You can fetch my git branch[1] to look and test easily, no need to
>> manually apply patches ;-)
>
> ... or pull.    :-)

I figure when testing how to use git to get those patches from my git
http repository that I must create a new branch first if I do not want
to pull in master, so I give the pull command in [1] and people handle
it as they want ;-)

Regards.

Footnotes: 
[1]  git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git dad/mml2015-epg-use-from-to-sign

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-16 20:23     ` Daniel Dehennin
@ 2010-11-16 20:27       ` Lars Magne Ingebrigtsen
  2010-11-16 20:45         ` Daniel Dehennin
  0 siblings, 1 reply; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-16 20:27 UTC (permalink / raw)
  To: ding

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> [1] git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git
> dad/mml2015-epg-use-from-to-sign

Hey!  It worked!

Pulled and pushed.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-16 20:27       ` Lars Magne Ingebrigtsen
@ 2010-11-16 20:45         ` Daniel Dehennin
  2010-11-17  7:34           ` Katsumi Yamaoka
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-16 20:45 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:
>
>> [1] git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git
>> dad/mml2015-epg-use-from-to-sign
>
> Hey!  It worked!
>
> Pulled and pushed.

One step to a full decentralised workflow ;-)
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-16 20:45         ` Daniel Dehennin
@ 2010-11-17  7:34           ` Katsumi Yamaoka
  2010-11-17 17:06             ` Daniel Dehennin
  0 siblings, 1 reply; 53+ messages in thread
From: Katsumi Yamaoka @ 2010-11-17  7:34 UTC (permalink / raw)
  To: ding

daniel.dehennin@baby-gnu.org wrote:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>> Hey!  It worked!
>> Pulled and pushed.

> One step to a full decentralised workflow ;-)

Well, shouldn't two (cons mml2015-signers) in mml2015-epg-encrypt
be (cons sender mml2015-signers) or something?

In mml2015-epg-encrypt:
mml2015.el:1065:40:Warning: cons called with 1 argument, but requires 2
mml2015.el:1080:32:Warning: `cons' called with 1 arg, but requires 2
mml2015.el:1098:33:Warning: cons called with 1 argument, but requires 2
mml2015.el:1098:33:Warning: `cons' called with 1 arg, but requires 2



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-17  7:34           ` Katsumi Yamaoka
@ 2010-11-17 17:06             ` Daniel Dehennin
  2010-11-17 17:13               ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-17 17:06 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> Well, shouldn't two (cons mml2015-signers) in mml2015-epg-encrypt
> be (cons sender mml2015-signers) or something?
>
> In mml2015-epg-encrypt:
> mml2015.el:1065:40:Warning: cons called with 1 argument, but requires 2
> mml2015.el:1080:32:Warning: `cons' called with 1 arg, but requires 2
> mml2015.el:1098:33:Warning: cons called with 1 argument, but requires 2
> mml2015.el:1098:33:Warning: `cons' called with 1 arg, but requires 2

Yes, I updated my branch[1], mea culpa.

Footnotes: 
[1]  git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git dad/mml2015-epg-use-from-to-sign

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-17 17:06             ` Daniel Dehennin
@ 2010-11-17 17:13               ` Lars Magne Ingebrigtsen
  2010-11-17 17:37                 ` Merging ChangeLogs (was: mml2015-epg-sign do not use from header) Sven Joachim
                                   ` (2 more replies)
  0 siblings, 3 replies; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-17 17:13 UTC (permalink / raw)
  To: ding

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> Footnotes: 
> [1] git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git dad/mml2015-e

Pulled and pushed.

But I'm still not understanding how this git thing is supposed to work.
Many times I pull something, I get a conflict in ChangeLog.  So I have
to fix that, and then say "git commit -a", and then I can push.

This seems really weird.  But, then again, the ChangeLog thing is really
weird, too.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Merging ChangeLogs (was: mml2015-epg-sign do not use from header)
  2010-11-17 17:13               ` Lars Magne Ingebrigtsen
@ 2010-11-17 17:37                 ` Sven Joachim
  2010-11-21  4:51                   ` Merging ChangeLogs Lars Magne Ingebrigtsen
  2010-11-17 18:07                 ` mml2015-epg-sign do not use from header Julien Danjou
  2010-11-17 23:08                 ` Daniel Dehennin
  2 siblings, 1 reply; 53+ messages in thread
From: Sven Joachim @ 2010-11-17 17:37 UTC (permalink / raw)
  To: ding

On 2010-11-17 18:13 +0100, Lars Magne Ingebrigtsen wrote:

> But I'm still not understanding how this git thing is supposed to work.
> Many times I pull something, I get a conflict in ChangeLog.  So I have
> to fix that, and then say "git commit -a", and then I can push.

The gnulib project has a special merge driver for ChangeLogs¹ that could
significantly improve this workflow.  I haven't tested it myself yet,
though.

> This seems really weird.  But, then again, the ChangeLog thing is really
> weird, too.

There's a reason why most projects have given up on writing ChangeLogs.

Cheers,
       Sven


¹ http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/git-merge-changelog.c;h=652b40a72d1cc87bf417484f7109632d2ae55f6e;hb=cc98e1ec101be0b8d260025b5e40bfec7f4b1ac5



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-17 17:13               ` Lars Magne Ingebrigtsen
  2010-11-17 17:37                 ` Merging ChangeLogs (was: mml2015-epg-sign do not use from header) Sven Joachim
@ 2010-11-17 18:07                 ` Julien Danjou
  2010-11-21  4:49                   ` Lars Magne Ingebrigtsen
  2010-11-17 23:08                 ` Daniel Dehennin
  2 siblings, 1 reply; 53+ messages in thread
From: Julien Danjou @ 2010-11-17 18:07 UTC (permalink / raw)
  To: ding

On Wed, Nov 17 2010, Lars Magne Ingebrigtsen wrote:

> But I'm still not understanding how this git thing is supposed to work.
> Many times I pull something, I get a conflict in ChangeLog.  So I have
> to fix that, and then say "git commit -a", and then I can push.

That's because both side have a different ChangeLog.

Could I suggest to stop writing ChangeLog, like org-mode did, and starts
using git log instead?

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-17 17:13               ` Lars Magne Ingebrigtsen
  2010-11-17 17:37                 ` Merging ChangeLogs (was: mml2015-epg-sign do not use from header) Sven Joachim
  2010-11-17 18:07                 ` mml2015-epg-sign do not use from header Julien Danjou
@ 2010-11-17 23:08                 ` Daniel Dehennin
  2010-11-21  4:47                   ` Lars Magne Ingebrigtsen
  2 siblings, 1 reply; 53+ messages in thread
From: Daniel Dehennin @ 2010-11-17 23:08 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:
>
>> Footnotes: 
>> [1] git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git dad/mml2015-e
>
> Pulled and pushed.
>
> But I'm still not understanding how this git thing is supposed to work.
> Many times I pull something, I get a conflict in ChangeLog.  So I have
> to fix that, and then say "git commit -a", and then I can push.

This may have things to do with fast-forward?

Personally, I always develop on a specific branch, and rebase this local
branch on upstream master to resolve such conflits locally, but you can
commit thing before pulling and then have troubles.

It seems there is the possibility to have a special changelog merge
driver[1].

Maybe another way is to have a specific workflow to only have
fast-forward merge?

> This seems really weird.  But, then again, the ChangeLog thing is really
> weird, too.

For people who need it (like package maintainer), there is the
possibility to generate them when needed[2] with the well suited pretty
format.

Regards.

Footnotes: 
[1]  like in http://raphaelhertzog.com/2009/10/08/3-way-merge-of-debian-changelog-files/

[2]  git log lisp >| lisp/ChangeLog

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-17 23:08                 ` Daniel Dehennin
@ 2010-11-21  4:47                   ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-21  4:47 UTC (permalink / raw)
  To: ding

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> It seems there is the possibility to have a special changelog merge
> driver[1].

Hm...  seemed somewhat Debian-specific, but I guess it could be
adapted... 

> Maybe another way is to have a specific workflow to only have
> fast-forward merge?

What commands would I use to have that workflow?  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: mml2015-epg-sign do not use from header
  2010-11-17 18:07                 ` mml2015-epg-sign do not use from header Julien Danjou
@ 2010-11-21  4:49                   ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-21  4:49 UTC (permalink / raw)
  To: ding

Julien Danjou <julien@danjou.info> writes:

> Could I suggest to stop writing ChangeLog, like org-mode did, and starts
> using git log instead?

I think the ChangeLog is nicer to read than the git/bzr log if I'm
looking for something.  But the merge conflicts are just so annoying.

If Emacs drops the ChangeLogs, then Gnus should, too.  But otherwise
probably not.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-17 17:37                 ` Merging ChangeLogs (was: mml2015-epg-sign do not use from header) Sven Joachim
@ 2010-11-21  4:51                   ` Lars Magne Ingebrigtsen
  2010-11-21  7:38                     ` Sven Joachim
  0 siblings, 1 reply; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-21  4:51 UTC (permalink / raw)
  To: ding

Sven Joachim <svenjoac@gmx.de> writes:

> The gnulib project has a special merge driver for ChangeLogs¹ that could
> significantly improve this workflow. 

That looks very nice.  But does this mean that everybody has to have the
merge driver installed?

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-21  4:51                   ` Merging ChangeLogs Lars Magne Ingebrigtsen
@ 2010-11-21  7:38                     ` Sven Joachim
  2010-11-21  7:43                       ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 53+ messages in thread
From: Sven Joachim @ 2010-11-21  7:38 UTC (permalink / raw)
  To: ding

On 2010-11-21 05:51 +0100, Lars Magne Ingebrigtsen wrote:

> Sven Joachim <svenjoac@gmx.de> writes:
>
>> The gnulib project has a special merge driver for ChangeLogs¹ that could
>> significantly improve this workflow. 
>
> That looks very nice.  But does this mean that everybody has to have the
> merge driver installed?

No, a custom merge driver is only tried if it is registered in
.git/config or ~/.gitconfig.  Otherwise, git uses the built-in merge
driver.

Sven



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-21  7:38                     ` Sven Joachim
@ 2010-11-21  7:43                       ` Lars Magne Ingebrigtsen
  2010-11-21  8:12                         ` Sven Joachim
  2010-11-22 19:42                         ` Ted Zlatanov
  0 siblings, 2 replies; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-21  7:43 UTC (permalink / raw)
  To: ding

Sven Joachim <svenjoac@gmx.de> writes:

>> That looks very nice.  But does this mean that everybody has to have the
>> merge driver installed?
>
> No, a custom merge driver is only tried if it is registered in
> .git/config or ~/.gitconfig.  Otherwise, git uses the built-in merge
> driver.

But if we put it in .git/config, then everybody has to have it, perhaps?
But I guess we could just put the merge driver into git Gnus as well?
Er...  would that work? 

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-21  7:43                       ` Lars Magne Ingebrigtsen
@ 2010-11-21  8:12                         ` Sven Joachim
  2010-11-21  8:19                           ` Sven Joachim
  2010-11-22 19:42                         ` Ted Zlatanov
  1 sibling, 1 reply; 53+ messages in thread
From: Sven Joachim @ 2010-11-21  8:12 UTC (permalink / raw)
  To: ding

On 2010-11-21 08:43 +0100, Lars Magne Ingebrigtsen wrote:

> Sven Joachim <svenjoac@gmx.de> writes:
>
>>> That looks very nice.  But does this mean that everybody has to have the
>>> merge driver installed?
>>
>> No, a custom merge driver is only tried if it is registered in
>> .git/config or ~/.gitconfig.  Otherwise, git uses the built-in merge
>> driver.
>
> But if we put it in .git/config, then everybody has to have it, perhaps?

No, .git/config is a private directory that is not shared between
repositories.  I.e. everyone has to enable the merge driver themselves,
but that is completely optional.

> But I guess we could just put the merge driver into git Gnus as well?
> Er...  would that work? 

Probably not unless you pull (large parts of) gnulib into Gnus.  This is
hardly desirable IMHO.

Sven



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-21  8:12                         ` Sven Joachim
@ 2010-11-21  8:19                           ` Sven Joachim
  0 siblings, 0 replies; 53+ messages in thread
From: Sven Joachim @ 2010-11-21  8:19 UTC (permalink / raw)
  To: ding

On 2010-11-21 09:12 +0100, Sven Joachim wrote:

> No, .git/config is a private directory that is not shared between
> repositories.

Err, s/directory/file/

Sven




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-21  7:43                       ` Lars Magne Ingebrigtsen
  2010-11-21  8:12                         ` Sven Joachim
@ 2010-11-22 19:42                         ` Ted Zlatanov
  2010-11-24 21:13                           ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 53+ messages in thread
From: Ted Zlatanov @ 2010-11-22 19:42 UTC (permalink / raw)
  To: ding

On Sun, 21 Nov 2010 08:43:18 +0100 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> Sven Joachim <svenjoac@gmx.de> writes:
>>> That looks very nice.  But does this mean that everybody has to have the
>>> merge driver installed?
>> 
>> No, a custom merge driver is only tried if it is registered in
>> .git/config or ~/.gitconfig.  Otherwise, git uses the built-in merge
>> driver.

LMI> But if we put it in .git/config, then everybody has to have it, perhaps?
LMI> But I guess we could just put the merge driver into git Gnus as well?
LMI> Er...  would that work? 

Just you, me, and whoever else may need to do this kind of merging.  I'd
guess it's very few of the Gnus comitters so it's probably not a big
hardship.

Ted




^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: Merging ChangeLogs
  2010-11-22 19:42                         ` Ted Zlatanov
@ 2010-11-24 21:13                           ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 53+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-11-24 21:13 UTC (permalink / raw)
  To: ding

Ted Zlatanov <tzz@lifelogs.com> writes:

> Just you, me, and whoever else may need to do this kind of merging. 

Right.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2010-11-24 21:13 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-25 20:11 mml2015-epg-sign do not use from header Daniel Dehennin
2009-01-25 20:37 ` Reiner Steib
2009-01-25 20:43   ` Daniel Dehennin
2009-01-26  1:34 ` Daiki Ueno
2009-02-28 11:25   ` Reiner Steib
2009-03-01  3:27     ` Daiki Ueno
2009-01-28 11:57 ` Daniel Dehennin
2009-01-28 11:59   ` [PATCH] mml2015-epg-sign does " Daniel Dehennin
2009-03-01 17:13     ` Daiki Ueno
2009-03-03 18:59       ` Daniel Dehennin
2009-04-13 20:31     ` Daniel Dehennin
2009-04-13 20:32     ` [PATCH] mml2015-epg-encrypt do not use from header to sign Daniel Dehennin
2009-01-28 12:00   ` [PATCH] Factor spliting mail addresses Daniel Dehennin
2009-04-13 20:32     ` Daniel Dehennin
2009-01-28 12:01   ` [PATCH] Cleanup selecting a key for sign and encryption Daniel Dehennin
2009-04-13 20:32     ` Daniel Dehennin
2009-01-28 12:02   ` [PATCH] Only one sender Daniel Dehennin
2009-04-13 20:32     ` Daniel Dehennin
2009-01-28 12:02   ` Daniel Dehennin
2009-04-13 20:32     ` Daniel Dehennin
2009-01-28 12:02   ` [PATCH] Factorize choosing a key Daniel Dehennin
2009-04-13 20:33     ` Daniel Dehennin
2009-01-28 12:02   ` [PATCH] mml2015-epg-choose-keys handle the verbose selection of keys Daniel Dehennin
2009-04-13 20:33     ` Daniel Dehennin
2009-01-28 12:02   ` [PATCH] Fix variable name, only one sender Daniel Dehennin
2009-01-28 12:02   ` [PATCH] Remove useless variables Daniel Dehennin
2009-04-13 20:33     ` Daniel Dehennin
2009-01-28 12:03   ` [PATCH] Permit to select a key if more than one match a mail address Daniel Dehennin
2009-04-13 20:33     ` Daniel Dehennin
2009-04-13 20:31   ` mml2015-epg-sign do not use from header Daniel Dehennin
2009-04-13 22:48     ` Daiki Ueno
2010-11-15 23:11 ` Daniel Dehennin
2010-11-15 23:13   ` mml2015-epg-sign does not use From header Daniel Dehennin
2010-11-15 23:23     ` Daniel Dehennin
2010-11-16 18:21   ` mml2015-epg-sign do not use from header Lars Magne Ingebrigtsen
2010-11-16 20:23     ` Daniel Dehennin
2010-11-16 20:27       ` Lars Magne Ingebrigtsen
2010-11-16 20:45         ` Daniel Dehennin
2010-11-17  7:34           ` Katsumi Yamaoka
2010-11-17 17:06             ` Daniel Dehennin
2010-11-17 17:13               ` Lars Magne Ingebrigtsen
2010-11-17 17:37                 ` Merging ChangeLogs (was: mml2015-epg-sign do not use from header) Sven Joachim
2010-11-21  4:51                   ` Merging ChangeLogs Lars Magne Ingebrigtsen
2010-11-21  7:38                     ` Sven Joachim
2010-11-21  7:43                       ` Lars Magne Ingebrigtsen
2010-11-21  8:12                         ` Sven Joachim
2010-11-21  8:19                           ` Sven Joachim
2010-11-22 19:42                         ` Ted Zlatanov
2010-11-24 21:13                           ` Lars Magne Ingebrigtsen
2010-11-17 18:07                 ` mml2015-epg-sign do not use from header Julien Danjou
2010-11-21  4:49                   ` Lars Magne Ingebrigtsen
2010-11-17 23:08                 ` Daniel Dehennin
2010-11-21  4:47                   ` Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).