>>>>> In <[email protected]> 
>>>>>   Daiki Ueno <[email protected]> wrote:
> >>>>> In <[email protected]> 
> >>>>> Ted Zlatanov <[email protected]> wrote:
> > If you trust your 3 servers, that's great.  The vast majority of IMAP
> > users, as I said, have no expectation of privacy on their IMAP server
> > (consider GMail, for instance).  This is not a filesystem on a remote
> > server where you can trust user permissions to be managed correctly.

> I agree with the facts.  But in that case, you cannot even trust your
> ISP which delivers original e-mails, can you?

Ah, I see my confusion about e-mail systems and IMAP as a file system.
That makes sense.  I apologize to you for that.

But still, I'm against the use of PGG (which is on the way to
obsolescence) in the new package.  Here is a patch to use EPG instead.

--- tramp-imap.el~	2009-04-23 23:13:51.000000000 +0900
+++ tramp-imap.el	2009-04-23 23:25:46.000000000 +0900
@@ -247,7 +247,7 @@
 (require 'tramp-cache)
 (require 'tramp-compat)
 (require 'imap)
-(require 'pgg)
+(require 'epa)
 (autoload 'auth-source-user-or-password "auth-source")
 
 ;; Define Tramp IMAP method ...
@@ -627,8 +627,7 @@
       (goto-char (point-min))
       (while (re-search-forward "
" nil t)
 	(replace-match "" nil nil))
-      ;; TODO: catch errors from PGG here
-      (tramp-imap-pgg-decode-buffer))))
+      (tramp-imap-decode-buffer))))
 
 ;;; (tramp-imap-collapse-name "a b c / where ; strange ! characters $ abound") 
 ;;; => "abcwherestrangecharactersabound"
@@ -655,29 +654,40 @@
 		(with-current-buffer filename-or-buffer
 		  (buffer-string)))
 	     (insert-file-contents filename-or-buffer))
-	   (tramp-imap-pgg-encode-buffer))))
+	   (tramp-imap-encode-buffer))))
       (current-buffer)))
 
-(defun tramp-imap-pgg-encode-buffer ()
-  (tramp-imap-pgg-process-buffer t))
-
-(defun tramp-imap-pgg-decode-buffer ()
-  (tramp-imap-pgg-process-buffer))
-
-(defun tramp-imap-pgg-process-buffer (&optional encode)
-  "Use PGG to encode or decode the current buffer."
-  (let ((pfft (if encode 'pgg-encrypt-symmetric 'pgg-decrypt))
-	(default-enable-multibyte-characters nil)
-	(input (buffer-substring-no-properties (point-min) (point-max)))
-	exit-data)
-    (with-temp-buffer
-      (insert input)
-      ;; note that we call pfft before pgg-display-output-buffer
-      (pgg-display-output-buffer (point-min) (point-max) (funcall pfft (point-min) (point-max) tramp-imap-passphrase))
-      (setq exit-data
-	    (buffer-substring-no-properties (point-min) (point-max))))
-;    (debug exit-data)
-    exit-data))
+(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-progress-callback context
+				       (cons #'epa-progress-callback-function
+					     "Encrypting..."))
+    (message "Encrypting...")
+    (setq cipher (epg-encrypt-string
+		  context
+		  (encode-coding-string (buffer-string) 'utf-8)
+		  nil))
+    (message "Encrypting...done")
+    cipher))
+
+(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-progress-callback context
+				       (cons #'epa-progress-callback-function
+					     "Decrypting..."))
+    (message "Decrypting...")
+    (setq plain (decode-coding-string
+		 (epg-decrypt-string context (buffer-string))
+		 'utf-8))
+    (message "Decrypting...done")
+    plain))
 
 (provide 'tramp-imap)
 ;;; tramp-imap.el ends here
Regards,
-- 
Daiki Ueno
_______________________________________________
Tramp-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to