From 6a6c0ff50985cac09495d119e87ca460cd076475 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Tue, 15 Jan 2008 20:02:20 -0800 Subject: [PATCH] add mime-view hook for viewing mime attachments Add a hook for handling the spawning of external programs for viewing MIME attachments. --- lib/sup/message-chunks.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb index 08dcf27..8e5def9 100644 --- a/lib/sup/message-chunks.rb +++ b/lib/sup/message-chunks.rb @@ -53,6 +53,16 @@ Variables: Return value: The decoded text of the attachment, or nil if not decoded. EOS + + HookManager.register "mime-view", < /dev/null 2> /dev/null" $? == 0 end + def view! + path = write_to_disk + ret = HookManager.run "mime-view", :content_type => @content_type, + :filename => path + view_default! path unless ret + end + def write_to_disk file = Tempfile.new(@filename || "sup-attachment") file.print @raw_content -- 2.45.2