From 53cf08baf8e3dc1a4d7ebd5504dfa4f7b7f921f1 Mon Sep 17 00:00:00 2001 From: djcb Date: Thu, 13 Sep 2012 21:10:27 +0300 Subject: [PATCH] * mu4e/crypto: support mu4e-decryption-policy --- mu4e/mu4e-headers.el | 8 +++++++- mu4e/mu4e-proc.el | 8 ++++---- mu4e/mu4e-vars.el | 10 +++++----- mu4e/mu4e-view.el | 9 ++++++--- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index df346997..8aa43946 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -1107,12 +1107,18 @@ current window. " (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (let* ((docid (or (mu4e~headers-docid-at-point) (mu4e-warn "No message at point"))) + ;; decrypt (or not), based on `mu4e-decryption-policy'. + (decrypt + (and (member 'encrypted (mu4e-field-at-point :flags)) + (if (eq mu4e-decryption-policy 'ask) + (yes-or-no-p (mu4e-format "Decrypt message?")) + mu4e-decryption-policy))) (viewwin (mu4e~headers-redraw-get-view-window))) (unless (window-live-p viewwin) (mu4e-error "Cannot get a message view")) (select-window viewwin) (switch-to-buffer (mu4e~headers-get-loading-buf)) - (mu4e~proc-view docid mu4e-show-images))) + (mu4e~proc-view docid mu4e-show-images decrypt))) (defun mu4e-headers-rerun-search () "Rerun the search for the last search expression." diff --git a/mu4e/mu4e-proc.el b/mu4e/mu4e-proc.el index 167d95c7..47b086e2 100644 --- a/mu4e/mu4e-proc.el +++ b/mu4e/mu4e-proc.el @@ -456,17 +456,17 @@ seen AFTER (the time_t value)." (if personal "true" "false") (or after 0))) -(defun mu4e~proc-view (docid-or-msgid &optional images) +(defun mu4e~proc-view (docid-or-msgid &optional images decrypt) "Get one particular message based on its DOCID-OR-MSGID (keyword argument). Optionally, if IMAGES is non-nil, backend will any images attached to the message, and return them as temp files. The result will be delivered to the function registered as `mu4e-message-func'." (mu4e~proc-send-command - "view %s extract-images:%s extract-encrypted:true" + "view %s extract-images:%s extract-encrypted:%s" (mu4e--docid-msgid-param docid-or-msgid) - (if images "true" "false"))) + (if images "true" "false") + (if decrypt "true" "false"))) (provide 'mu4e-proc) - ;; End of mu4e-proc.el diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index e2d04e18..30b7bf7e 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -157,14 +157,14 @@ view buffer." :type 'boolean :group 'mu4e-crypto) -(defcustom mu4e-decryption-policy 'auto +(defcustom mu4e-decryption-policy t "Policy for dealing with encrypted parts. The setting is a symbol: - * `auto': try to decrypt automatically + * t: try to decrypt automatically * `ask': ask before decrypting anything - * `no': don't try to decrypt anything." - :type '(choice (const :tag "Try to decrypt automatically" auto) + * nil: don't try to decrypt anything." + :type '(choice (const :tag "Try to decrypt automatically" t) (const :tag "Ask before decrypting anything" ask) - (const :tag "Don't try to decrypt anything" no)) + (const :tag "Don't try to decrypt anything" nil)) :group 'mu4e-crypto) ;; completion; we put them here rather than in mu4e-compose, as mu4e-utils needs diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 118b54f1..d492908d 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -138,12 +138,15 @@ The first letter of NAME is used as a shortcut character.") "A mapping of user-visible attachment number to the actual part index.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - (defun mu4e-view-message-with-msgid (msgid) "View message with MSGID. This is meant for external programs wanting to show specific messages - for example, `mu4e-org'." - (mu4e~proc-view msgid mu4e-show-images)) + ;; note: hackish; if mu4e-decryption-policy is non-nil (ie., t or 'ask), we + ;; decrpt the message. Since here we don't know if message is encrypted or + ;; not, when the policy is 'ask'. we simply assume the user said yes... the + ;; alternative would be to ask for each message, encrypted or not. maybe we + ;; need an extra policy... + (mu4e~proc-view msgid mu4e-show-images mu4e-decryption-policy)) (defun mu4e-view-message-text (msg) "Return the message to display (as a string), based on the MSG