]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/edit-message-mode.rb
Add new :crypto_default configuration option.
[sup] / lib / sup / modes / edit-message-mode.rb
index f956d6587948cb3cc01f0579faa98f548850c1d6..3449503bf1d297e9ebd0bf2a03a6f780ec7bceff 100644 (file)
@@ -73,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
@@ -82,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
 
@@ -318,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