3 class ForwardMode < EditMessageMode
4 ## TODO: share some of this with reply-mode
7 "From" => AccountManager.default_account.full_address,
12 "Fwd: " + opts[:message].subj
13 elsif opts[:attachments]
14 "Fwd: " + opts[:attachments].keys.join(", ")
17 header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
18 header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc]
19 header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc]
23 forward_body_lines(opts[:message])
24 elsif opts[:attachments]
25 ["Note: #{opts[:attachments].size.pluralize 'attachment'}."]
28 super :header => header, :body => body, :attachments => opts[:attachments]
31 def self.spawn_nicely opts={}
32 to = opts[:to] || BufferManager.ask_for_contacts(:people, "To: ") or return
33 cc = opts[:cc] || BufferManager.ask_for_contacts(:people, "Cc: ") or return if $config[:ask_for_cc]
34 bcc = opts[:bcc] || BufferManager.ask_for_contacts(:people, "Bcc: ") or return if $config[:ask_for_bcc]
37 attachments = opts[:attachments] || []
39 if(m = opts[:message])
40 m.load_from_source! # read the full message in. you know, maybe i should just make Message#chunks do this....
41 attachments += m.chunks.select { |c| c.is_a?(Chunk::Attachment) && !c.quotable? }
44 attachments.each do |c|
45 mime_type = MIME::Types[c.content_type].first || MIME::Types["application/octet-stream"]
46 attachment_hash[c.filename] = RMail::Message.make_attachment c.raw_content, mime_type.content_type, mime_type.encoding, c.filename
49 mode = ForwardMode.new :message => opts[:message], :to => to, :cc => cc, :bcc => bcc, :attachments => attachment_hash
51 title = "Forwarding " +
55 attachment_hash.keys.join(", ")
60 BufferManager.spawn title, mode
66 def forward_body_lines m
67 ["--- Begin forwarded message from #{m.from.mediumname} ---"] +
68 m.quotable_header_lines + [""] + m.quotable_body_lines +
69 ["--- End forwarded message ---"]