]> git.cworth.org Git - sup/commitdiff
message/rfc822 mime-type handling
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 27 Oct 2007 17:40:00 +0000 (17:40 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 27 Oct 2007 17:40:00 +0000 (17:40 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@621 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup
lib/sup/message-chunks.rb
lib/sup/message.rb
lib/sup/modes/thread-view-mode.rb

diff --git a/bin/sup b/bin/sup
index e2b331a90d390a5d85c209382e7d23b356a47607..be455fa6789bc5e50851f31834148d24127cca9f 100644 (file)
--- a/bin/sup
+++ b/bin/sup
@@ -130,6 +130,7 @@ begin
     c.add :cryptosig_valid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK, Ncurses::A_BOLD
     c.add :cryptosig_unknown_color, Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK
     c.add :cryptosig_invalid_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_RED, Ncurses::A_BOLD
+    c.add :generic_notice_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
     c.add :quote_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
     c.add :sig_patina_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
     c.add :quote_color, Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK
index de7d4b5701fb2b958f80d79afcde694d492e76d2..e96dab408240ebf331c263e829e6fd24dfaebd3b 100644 (file)
 ## inlineable, #color and #lines are called and the output is treated
 ## as part of the message text. This is how Text and one-line Quotes
 ## and Signatures work.
-
-## If it's expandable, #patina_color and #patina_text are called to
-## generate a "patina" (a one-line widget, basically), and the user
-## can press enter to toggle the display of the chunk content, which
-## is generated from #color and #lines). This is how Quote, Signature,
-## and most widgets work.
-
-## If it's viewable, a patina is displayed using #patina_color and
-## #patina_text, but no toggling is allowed. Instead, if #view! is
-## defined, pressing enter on the widget calls view! and (if that
-## returns false) #to_s. Otherwise enter does nothing. This is how
-## non-inlineable attachments work.
+##
+## If it's not inlineable but is expandable, #patina_color and
+## #patina_text are called to generate a "patina" (a one-line widget,
+## basically), and the user can press enter to toggle the display of
+## the chunk content, which is generated from #color and #lines as
+## above. This is how Quote, Signature, and most widgets work.
+##
+## If it's not expandable but is viewable, a patina is displayed using
+## #patina_color and #patina_text, but no toggling is allowed. Instead,
+## if #view! is defined, pressing enter on the widget calls view! and
+## (if that returns false) #to_s. Otherwise, enter does nothing. This
+## is how non-inlineable attachments work.
 
 module Redwood
 module Chunk
@@ -137,14 +137,19 @@ EOS
   end
 
   class EnclosedMessageNotice
-    attr_reader :from
-    def initialize from
+    attr_reader :from, :lines
+    def initialize from, body
       @from = from
+      @lines = body.split "\n"
     end
 
-    def to_s
-      "Begin enclosed message from #{@from.longname}"
-    end
+    def inlineable?; false end
+    def expandable?; true end
+
+    def patina_color; :generic_notice_patina_color end
+    def patina_text; "Begin enclosed message from #{@from.longname} (#{@lines.length} lines)" end
+
+    def color; :quote_color end
   end
 
   class CryptoNotice
index 6eb47d8b863a0485fa08efb1f64966415b1af96c..0d4a780dbca979f698e27dea3f6e5e319dda9baf 100644 (file)
@@ -323,6 +323,9 @@ private
       end
 
       chunks
+    elsif m.header.content_type == "message/rfc822"
+      payload = RMail::Parser.read(m.body)
+      [Chunk::EnclosedMessageNotice.new(PersonManager.person_for(payload.header.from.first.format), payload.to_s)]
     else
       filename =
         ## first, paw through the headers looking for a filename
index d9c3f8c07d669e8dd3a7f524c08615517f6eb8bb..2f25b2551b7f1837bb07785bf852b441f027a03f 100644 (file)
@@ -478,6 +478,7 @@ private
         (chunk.is_draft? ? [[[:draft_notification_color, prefix + " >>> This message is a draft. To edit, hit 'e'. <<<"]]] : [])
 
     else
+      raise "Bad chunk: #{chunk.inspect}" unless chunk.respond_to?(:inlineable?) ## debugging
       if chunk.inlineable?
         chunk.lines.map { |line| [[chunk.color, "#{prefix}#{line}"]] }
       elsif chunk.expandable?