Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [patch] Add crypto_selector variable to before-edit
@ 2010-01-18 14:32 Daniel Schoepe
  2010-01-23 12:53 ` William Morgan
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Schoepe @ 2010-01-18 14:32 UTC (permalink / raw)
  To: sup-talk


[-- Attachment #1.1.1: Type: text/plain, Size: 391 bytes --]

This patch adds crypto_selector to the variables available to the
before-edit hook, so one can set default crypto-options or
sign/encrypt a mail depending on e.g the message or header content.

Users should beware that the variable can be nil, since the same hook
is also run from reply_mode which doesn't have access to the
crypto_selector element or crypto-support can be absent entirely.

[-- Attachment #1.1.2: add_crypto_selector.patch --]
[-- Type: application/octet-stream, Size: 2056 bytes --]

From 1a8e906a7e49226021d088073f40f8cc0c4d75c6 Mon Sep 17 00:00:00 2001
From: Daniel Schoepe <daniel.schoepe@googlemail.com>
Date: Mon, 18 Jan 2010 15:16:25 +0100
Subject: [PATCH] Added crypto_selector to before-edit hook

---
 lib/sup/modes/edit-message-mode.rb |    9 +++++----
 lib/sup/modes/reply-mode.rb        |    2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 8849271..b991d73 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -34,8 +34,10 @@ EOS
 Modifies message body and headers before editing a new message. Variables
 should be modified in place.
 Variables:
-	header: a hash of headers. See 'signature' hook for documentation.
-	body: an array of lines of body text.
+  header: a hash of headers. See 'signature' hook for documentation.
+  body: an array of lines of body text.
+  crypto_selector: the UI element for cryptography settings; useful for
+                   default settings. (Can be nil)
 Return value:
 	none
 EOS
@@ -90,8 +92,7 @@ EOS
         HorizontalSelector.new "Crypto:", [:none] + CryptoManager::OUTGOING_MESSAGE_OPERATIONS.keys, ["None"] + CryptoManager::OUTGOING_MESSAGE_OPERATIONS.values
       end
     add_selector @crypto_selector if @crypto_selector
-    
-    HookManager.run "before-edit", :header => @header, :body => @body
+    HookManager.run "before-edit", :header => @header, :body => @body, :crypto_selector => @crypto_selector
 
     super opts
     regen_text
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index 3d39a8a..1453393 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -151,7 +151,7 @@ EOS
       end)
 
     @headers.each do |k, v|
-      HookManager.run "before-edit", :header => v, :body => body
+      HookManager.run "before-edit", :header => v, :body => body, :crypto_selector => nil
     end
 
     super :header => @headers[@type_selector.val], :body => body, :twiddles => false
-- 
1.6.6


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-01-18 14:32 [sup-talk] [patch] Add crypto_selector variable to before-edit Daniel Schoepe
@ 2010-01-23 12:53 ` William Morgan
  2010-01-24 11:10   ` Carlos Garcia Campos
  2010-01-26 15:55   ` Daniel Schoepe
  0 siblings, 2 replies; 9+ messages in thread
From: William Morgan @ 2010-01-23 12:53 UTC (permalink / raw)
  To: sup-talk

Hi Daniel,

I like the idea, but would prefer a dedicated "crypto-mode" hook
analogous to how we have the "reply-to" hook for setting the default
reply-to mode.
-- 
William <wmorgan-sup@masanjin.net>
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-01-23 12:53 ` William Morgan
@ 2010-01-24 11:10   ` Carlos Garcia Campos
  2010-01-26 15:55   ` Daniel Schoepe
  1 sibling, 0 replies; 9+ messages in thread
From: Carlos Garcia Campos @ 2010-01-24 11:10 UTC (permalink / raw)
  To: sup-talk


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

Excerpts from William Morgan's message of sáb ene 23 13:53:04 +0100 2010:
> Hi Daniel,
> 
> I like the idea, but would prefer a dedicated "crypto-mode" hook
> analogous to how we have the "reply-to" hook for setting the default
> reply-to mode.

+1

I filed a bug report for that some time ago indeed:

http://masanjin.net/sup-bugs/issue13

-- 
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-01-23 12:53 ` William Morgan
  2010-01-24 11:10   ` Carlos Garcia Campos
@ 2010-01-26 15:55   ` Daniel Schoepe
  2010-01-26 18:19     ` Ben Walton
                       ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: Daniel Schoepe @ 2010-01-26 15:55 UTC (permalink / raw)
  To: sup-talk


[-- Attachment #1.1.1: Type: text/plain, Size: 274 bytes --]

Excerpts from William Morgan's message of Sat Jan 23 13:53:04 +0100 2010:
> Hi Daniel,
> 
> I like the idea, but would prefer a dedicated "crypto-mode" hook
> analogous to how we have the "reply-to" hook for setting the default
> reply-to mode.

Okay, here's the new patch:

[-- Attachment #1.1.2: 0001-Added-crypto-settings-hook.patch --]
[-- Type: application/octet-stream, Size: 1449 bytes --]

From 3226e89b09f166e55ed36721aa42ad59c6dddc09 Mon Sep 17 00:00:00 2001
From: Daniel Schoepe <daniel.schoepe@googlemail.com>
Date: Tue, 26 Jan 2010 16:45:16 +0100
Subject: [PATCH] Added crypto-settings hook

---
 lib/sup/modes/edit-message-mode.rb |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 8849271..88f3734 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -40,6 +40,18 @@ Return value:
 	none
 EOS
 
+  HookManager.register "crypto-mode", <<EOS
+Modifies cryptography settings based on header and message content, before
+editing a new message. This can be used to set, for example, default cryptography
+settings.
+Variables:
+    header: a hash of headers. See 'signature' hook for documentation.
+    body: an array of lines of body text.
+    crypto_selector: the UI element that controls the current cryptography setting.
+Return value:
+     none
+EOS
+
   attr_reader :status
   attr_accessor :body, :header
   bool_reader :edited
@@ -92,6 +104,9 @@ EOS
     add_selector @crypto_selector if @crypto_selector
     
     HookManager.run "before-edit", :header => @header, :body => @body
+    if @crypto_selector
+      HookManager.run "crypto-mode", :header => @header, :body => @body, :crypto_selector => @crypto_selector
+    end
 
     super opts
     regen_text
-- 
1.6.6


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-01-26 15:55   ` Daniel Schoepe
@ 2010-01-26 18:19     ` Ben Walton
  2010-02-27 18:17     ` Rich Lane
  2010-03-09 10:29     ` Gaute Hope
  2 siblings, 0 replies; 9+ messages in thread
From: Ben Walton @ 2010-01-26 18:19 UTC (permalink / raw)
  To: sup-talk


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

Excerpts from Daniel Schoepe's message of Tue Jan 26 10:55:55 -0500 2010:

> Okay, here's the new patch:

+1 for this.  Patch looks OK to my eye, fwiw.

-Ben
-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu
Contact me to arrange for a CAcert assurance meeting.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-01-26 15:55   ` Daniel Schoepe
  2010-01-26 18:19     ` Ben Walton
@ 2010-02-27 18:17     ` Rich Lane
  2010-03-09 10:29     ` Gaute Hope
  2 siblings, 0 replies; 9+ messages in thread
From: Rich Lane @ 2010-02-27 18:17 UTC (permalink / raw)
  To: Daniel Schoepe; +Cc: sup-talk

Applied to master.
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-01-26 15:55   ` Daniel Schoepe
  2010-01-26 18:19     ` Ben Walton
  2010-02-27 18:17     ` Rich Lane
@ 2010-03-09 10:29     ` Gaute Hope
  2010-03-12 22:03       ` Daniel Schoepe
  2 siblings, 1 reply; 9+ messages in thread
From: Gaute Hope @ 2010-03-09 10:29 UTC (permalink / raw)
  To: sup-talk

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

Excerpts from Daniel Schoepe's message of 2010-01-26 16:55:55 +0100:
> Excerpts from William Morgan's message of Sat Jan 23 13:53:04 +0100 2010:
> > Hi Daniel,
> > 
> > I like the idea, but would prefer a dedicated "crypto-mode" hook
> > analogous to how we have the "reply-to" hook for setting the default
> > reply-to mode.

Could someone be so kind and provide an example for setting it to i.e.
'Sign' by default, given a specific from address?

- gaute

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-03-09 10:29     ` Gaute Hope
@ 2010-03-12 22:03       ` Daniel Schoepe
  2010-03-12 22:34         ` Gaute Hope
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Schoepe @ 2010-03-12 22:03 UTC (permalink / raw)
  To: sup-talk


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

Excerpts from Gaute Hope's message of Tue Mar 09 11:29:13 +0100 2010:
> Could someone be so kind and provide an example for setting it to i.e.
> 'Sign' by default, given a specific from address?
> 
> - gaute

Something like this should work:

crypto_selector.set_to :sign if header["From"] == "foo@ba.r"

(You might need to use e.g. a regex if the header also contains the name,
as in "Foo Bar <mail>")

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

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

* Re: [sup-talk] [patch] Add crypto_selector variable to before-edit
  2010-03-12 22:03       ` Daniel Schoepe
@ 2010-03-12 22:34         ` Gaute Hope
  0 siblings, 0 replies; 9+ messages in thread
From: Gaute Hope @ 2010-03-12 22:34 UTC (permalink / raw)
  To: sup-talk

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

Excerpts from Daniel Schoepe's message of 2010-03-12 23:03:03 +0100:
> Excerpts from Gaute Hope's message of Tue Mar 09 11:29:13 +0100 2010:
> > Could someone be so kind and provide an example for setting it to i.e.
> > 'Sign' by default, given a specific from address?
> > 
> > - gaute
> 
> Something like this should work:
> 
> crypto_selector.set_to :sign if header["From"] == "foo@ba.r"
> 
> (You might need to use e.g. a regex if the header also contains the name,
> as in "Foo Bar <mail>")

Thanks, that did it!

- gaute

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2010-03-12 22:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-18 14:32 [sup-talk] [patch] Add crypto_selector variable to before-edit Daniel Schoepe
2010-01-23 12:53 ` William Morgan
2010-01-24 11:10   ` Carlos Garcia Campos
2010-01-26 15:55   ` Daniel Schoepe
2010-01-26 18:19     ` Ben Walton
2010-02-27 18:17     ` Rich Lane
2010-03-09 10:29     ` Gaute Hope
2010-03-12 22:03       ` Daniel Schoepe
2010-03-12 22:34         ` Gaute Hope

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox