X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fmodes%2Fedit-message-mode.rb;h=3449503bf1d297e9ebd0bf2a03a6f780ec7bceff;hb=refs%2Fheads%2Fnext;hp=d7bd41c692f55a7fe7f23f0ebb608e506f938f06;hpb=fa0b5a25587356684bd45b82b172fedc729038d5;p=sup diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb index d7bd41c..3449503 100644 --- a/lib/sup/modes/edit-message-mode.rb +++ b/lib/sup/modes/edit-message-mode.rb @@ -2,7 +2,10 @@ require 'tempfile' require 'socket' # just for gethostname! require 'pathname' require 'rmail' -require 'jcode' # for RE_UTF8 + +# from jcode.rb, not included in ruby 1.9 +PATTERN_UTF8 = '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]' +RE_UTF8 = Regexp.new(PATTERN_UTF8, 0, 'n') module Redwood @@ -70,7 +73,14 @@ EOS @attachment_names = [] end - @message_id = "<#{Time.now.to_i}-sup-#{rand 10000}@#{Socket.gethostname}>" + begin + hostname = File.open("/etc/mailname", "r").gets.chomp + rescue + nil + end + hostname = Socket.gethostname if hostname.nil? or hostname.empty? + + @message_id = "<#{Time.now.to_i}-sup-#{rand 10000}@#{hostname}>" @edited = false @selectors = [] @selector_label_width = 0 @@ -79,7 +89,12 @@ EOS if CryptoManager.have_crypto? HorizontalSelector.new "Crypto:", [:none] + CryptoManager::OUTGOING_MESSAGE_OPERATIONS.keys, ["None"] + CryptoManager::OUTGOING_MESSAGE_OPERATIONS.values end - add_selector @crypto_selector if @crypto_selector + if @crypto_selector + if !$config[:crypto_default].nil? + @crypto_selector.set_to $config[:crypto_default] + end + add_selector @crypto_selector + end HookManager.run "before-edit", :header => @header, :body => @body @@ -181,7 +196,7 @@ protected end def mime_encode_subject string - return string unless string.match(String::RE_UTF8) + return string unless string.match(RE_UTF8) mime_encode string end @@ -190,7 +205,7 @@ protected # Encode "bælammet mitt " into # "=?utf-8?q?b=C3=A6lammet_mitt?= def mime_encode_address string - return string unless string.match(String::RE_UTF8) + return string unless string.match(RE_UTF8) string.sub(RE_ADDRESS) { |match| mime_encode($1) + $2 } end @@ -315,7 +330,7 @@ protected BufferManager.flash "Message sent!" true rescue SystemCallError, SendmailCommandFailed, CryptoManager::Error => e - Redwood::log "Problem sending mail: #{e.message}" + warn "Problem sending mail: #{e.message}" BufferManager.flash "Problem sending mail: #{e.message}" false end