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

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