]> git.cworth.org Git - sup/blobdiff - lib/sup/message-chunks.rb
Merge branch 'index-locking' into next
[sup] / lib / sup / message-chunks.rb
index 08dcf27e06c1847ca888569645c78e7be9c744b0..cc895f3e480e591d077a18a83a84b85ca7d0cf5a 100644 (file)
@@ -53,6 +53,16 @@ Variables:
 Return value:
   The decoded text of the attachment, or nil if not decoded.
 EOS
+
+    HookManager.register "mime-view", <<EOS
+Executes when viewing a MIME attachment, i.e., launching a separate
+viewer program.
+Variables:
+   content_type: the content-type of the attachment
+       filename: the filename of the attachment as saved to disk
+Return value:
+  True if the viewing was successful, false otherwise.
+EOS
 #' stupid ruby-mode
 
     ## raw_content is the post-MIME-decode content. this is used for
@@ -105,10 +115,18 @@ EOS
     def expandable?; !viewable? end
     def initial_state; :open end
     def viewable?; @lines.nil? end
+    def view_default! path
+      cmd = "/usr/bin/run-mailcap --action=view '#{@content_type}:#{path}' 2>/dev/null"
+      Redwood::log "running: #{cmd.inspect}"
+      system cmd
+      $? == 0
+    end
+
     def view!
       path = write_to_disk
-      system "/usr/bin/run-mailcap --action=view #{@content_type}:#{path} > /dev/null 2> /dev/null"
-      $? == 0
+      ret = HookManager.run "mime-view", :content_type => @content_type,
+                                         :filename => path
+      ret || view_default!(path)
     end
 
     def write_to_disk
@@ -188,7 +206,7 @@ EOS
     def inlineable?; false end
     def quotable?; false end
     def expandable?; true end
-    def initial_state; :open end
+    def initial_state; :closed end
     def viewable?; false end
 
     def patina_color; :generic_notice_patina_color end