>>>>> In <[email protected]> 
>>>>>   Ted Zlatanov <[email protected]> wrote:
> - EPG asks for the passphrase.  It should try tramp-imap-passphrase as a
>   string first (I'll add the alist and function call support later).  As
>   an extra courtesy to the user, if the passphrase is nil, we should ask
>   interactively if encryption is wanted, and if yes, read the
>   passphrase.  Would you be willing to make that addition?

Yes, here is a patch to do that.

--- tramp-imap.el~	2009-04-24 08:59:11.000000000 +0900
+++ tramp-imap.el	2009-04-24 09:01:16.000000000 +0900
@@ -738,12 +738,17 @@
 	(error "Could not find the body separator in the encoded message!")))
       (current-buffer)))
 
+(defun tramp-imap-passphrase-callback-function (context key-id handback)
+  (or tramp-imap-passphrase
+      (epa-passphrase-callback-function context key-id handback)))
+
 (defun tramp-imap-encode-buffer ()
   (let ((context (epg-make-context 'OpenPGP))
 	cipher)
     (epg-context-set-armor context t)
-    (epg-context-set-passphrase-callback context
-					 #'epa-passphrase-callback-function)
+    (epg-context-set-passphrase-callback
+     context
+     #'tramp-imap-passphrase-callback-function)
     (epg-context-set-progress-callback context
 				       (cons #'epa-progress-callback-function
 					     "Encrypting..."))
@@ -758,8 +763,9 @@
 (defun tramp-imap-decode-buffer ()
   (let ((context (epg-make-context 'OpenPGP))
 	plain)
-    (epg-context-set-passphrase-callback context
-					 #'epa-passphrase-callback-function)
+    (epg-context-set-passphrase-callback
+     context
+     #'tramp-imap-passphrase-callback-function)
     (epg-context-set-progress-callback context
 				       (cons #'epa-progress-callback-function
 					     "Decrypting..."))
> - I had to clean ^M characters from the buffer before; EPG seems to
>   handle them automatically so I removed this code

>       ;; TODO: do this better, removes all ^M in the buffer
>       (goto-char (point-min))
>        (while (re-search-forward "^M" nil t) ;; this was the literal ^M
>       (replace-match "" nil nil))

>   from tramp-imap-get-file.  Is that OK?

I think so - if data do not roundtrip before/after encryption, it seems
a bug...

Regards,
-- 
Daiki Ueno
_______________________________________________
Tramp-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to