43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/sup/modes/forward_mode.rb', line 43
def self.spawn_nicely opts={}
to = opts[:to] || (BufferManager.ask_for_contacts(:people, "To: ") or return if ($config[:ask_for_to] != false))
cc = opts[:cc] || (BufferManager.ask_for_contacts(:people, "Cc: ") or return if $config[:ask_for_cc])
bcc = opts[:bcc] || (BufferManager.ask_for_contacts(:people, "Bcc: ") or return if $config[:ask_for_bcc])
attachment_hash = {}
attachments = opts[:attachments] || []
if(m = opts[:message])
m.load_from_source!
attachments += m.chunks.select { |c| c.is_a?(Chunk::Attachment) && !c.quotable? }
end
attachments.each do |c|
mime_type = MIME::Types[c.content_type].first || MIME::Types["application/octet-stream"].first
attachment_hash[c.filename] = RMail::Message.make_attachment c.raw_content, mime_type.content_type, mime_type.encoding, c.filename
end
mode = ForwardMode.new :message => opts[:message], :to => to, :cc => cc, :bcc => bcc, :attachments => attachment_hash
title = "Forwarding " +
if opts[:message]
opts[:message].subj
elsif attachments
attachment_hash.keys.join(", ")
else
"something"
end
BufferManager.spawn title, mode
mode.default_edit_message
end
|