Reverted to 2006-07-04.
authorueno <ueno>
Fri, 29 Sep 2006 08:41:14 +0000 (08:41 +0000)
committerueno <ueno>
Fri, 29 Sep 2006 08:41:14 +0000 (08:41 +0000)
ChangeLog
mime-edit.el
mime-pgp.el

index 8db0c0d..3fc8ec3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,37 +1,3 @@
-2006-09-03  Daiki Ueno  <ueno@unixuser.org>
-
-       * mime-pgp.el (mime-pgp-use): New variable.
-       (mime-view-application/pgp-with-epg): Renamed from
-       mime-view-application/pgp.
-       (mime-view-application/pgp-with-pgg): Revived for backward
-       compatibility.
-       (mime-verify-application/*-signature-with-epg): Renamed from
-       mime-verify-application/*-signature.
-       (mime-verify-application/*-signature-with-pgg): Revived for
-       backward compatibility.
-       (mime-add-application/pgp-keys-with-epg): Renamed from
-       mime-add-application/pgp-keys.
-       (mime-add-application/pgp-keys-with-pgg): Revived for backward
-       compatibility.
-
-       * mime-edit.el (mime-edit-pgp-use): New variable.
-       (mime-edit-sign-pgp-mime-with-epg): Renamed from
-       mime-edit-sign-pgp-mime.
-       (mime-edit-sign-pgp-mime-with-pgg): Revived for backward
-       compatibility.
-       (mime-edit-encrypt-pgp-mime-with-epg): Renamed from
-       mime-edit-encrypt-pgp-mime.
-       (mime-edit-encrypt-pgp-mime-with-pgg): Revived for backward
-       compatibility.
-       (mime-edit-sign-pgp-kazu-with-epg): Renamed from
-       mime-edit-sign-pgp-kazu.
-       (mime-edit-sign-pgp-kazu-with-pgg): Revived for backward
-       compatibility.
-       (mime-edit-encrypt-pgp-kazu-with-epg): Renamed from
-       mime-edit-encrypt-pgp-kazu.
-       (mime-edit-encrypt-pgp-kazu-with-pgg): Revived for backward
-       compatibility.
-
 2006-07-04  Daiki Ueno  <ueno@unixuser.org>
 
        * mime-edit.el (mime-edit-sign-smime): Use
index f3b6638..15bc2c7 100644 (file)
 (require 'mime-view)
 (require 'signature)
 (require 'alist)
+(require 'epa)
 
-(defvar mime-edit-pgp-use
-  (condition-case nil
-      (progn
-       (require 'epg-config)
-       (epg-check-configuration (epg-configuration))
-       (autoload 'epg-make-context "epg")
-       'epg)
-    (error
-     (require 'pgg-def)
-     (require 'pgg-parse)
-     (autoload 'pgg-encrypt-region "pgg"
-       "PGP encryption of current region." t)
-     (autoload 'pgg-sign-region "pgg"
-       "PGP signature of current region." t)
-     (autoload 'pgg-insert-key "pgg"
-       "Insert PGP public key at point." t)
-     'pgg))
-  "Which PGG library to be used in MIME-Edit.")
 
 ;;; @ version
 ;;;
@@ -624,8 +607,7 @@ If it is not specified for a major-mode,
          ") "
          (if (fboundp 'apel-version)
              (concat (apel-version) " "))
-         (if (eq mime-edit-pgp-use 'epg)
-             (concat "EasyPG/" epg-version-number " "))
+         "EasyPG/" epg-version-number " "
          (if (featurep 'xemacs)
              (concat (cond ((and (featurep 'chise)
                                  (boundp 'xemacs-chise-version))
@@ -1624,21 +1606,13 @@ Parameter must be '(PROMPT CHOICE1 (CHOICE2...))."
          (cond ((string-equal type "quote")
                 (mime-edit-enquote-region bb eb))
                ((string-equal type "pgp-signed")
-                (if (eq mime-edit-pgp-use 'epg)
-                    (mime-edit-sign-pgp-mime-with-epg bb eb boundary)
-                  (mime-edit-sign-pgp-mime-with-pgg bb eb boundary)))
+                (mime-edit-sign-pgp-mime bb eb boundary))
                ((string-equal type "pgp-encrypted")
-                (if (eq mime-edit-pgp-use 'epg)
-                    (mime-edit-encrypt-pgp-mime-with-epg bb eb boundary)
-                  (mime-edit-encrypt-pgp-mime-with-pgg bb eb boundary)))
+                (mime-edit-encrypt-pgp-mime bb eb boundary))
                ((string-equal type "kazu-signed")
-                (if (eq mime-edit-pgp-use 'epg)
-                    (mime-edit-sign-pgp-kazu-with-epg bb eb boundary)
-                  (mime-edit-sign-pgp-kazu-with-pgg bb eb boundary)))
+                (mime-edit-sign-pgp-kazu bb eb boundary))
                ((string-equal type "kazu-encrypted")
-                (if (eq mime-edit-pgp-use 'epg)
-                    (mime-edit-encrypt-pgp-kazu-with-epg bb eb boundary)
-                  (mime-edit-encrypt-pgp-kazu-with-pgg bb eb boundary)))
+                (mime-edit-encrypt-pgp-kazu bb eb boundary))
                ((string-equal type "smime-signed")
                 (mime-edit-sign-smime bb eb boundary))
                ((string-equal type "smime-encrypted")
@@ -1682,7 +1656,7 @@ Parameter must be '(PROMPT CHOICE1 (CHOICE2...))."
       (while (re-search-forward "[ \t]+$" nil t)
        (delete-region (match-beginning 0) (match-end 0))))))
 
-(defun mime-edit-sign-pgp-mime-with-epg (beg end boundary)
+(defun mime-edit-sign-pgp-mime (beg end boundary)
   (save-excursion
     (save-restriction
       (let* ((from (std11-field-body "From" mail-header-separator))
@@ -1745,55 +1719,6 @@ Content-Description: OpenPGP Digital Signature
        (goto-char (point-max))
        (insert (format "\n--%s--\n" pgp-boundary))))))
 
-(defun mime-edit-sign-pgp-mime-with-pgg (beg end boundary)
-  (save-excursion
-    (save-restriction
-      (let* ((from (std11-field-body "From" mail-header-separator))
-            (ret (progn 
-                   (narrow-to-region beg end)
-                   (mime-edit-translate-region beg end boundary)))
-            (ctype    (car ret))
-            (encoding (nth 1 ret))
-            (pgp-boundary (concat "pgp-sign-" boundary))
-            micalg)
-       (mime-edit-delete-trailing-whitespace) ; RFC3156
-       (goto-char beg)
-       (insert (format "Content-Type: %s\n" ctype))
-       (if encoding
-           (insert (format "Content-Transfer-Encoding: %s\n" encoding)))
-       (insert "\n")
-       (or (let ((pgg-default-user-id 
-                  (or mime-edit-pgp-user-id
-                      (if from 
-                          (nth 1 (std11-extract-address-components from))
-                        pgg-default-user-id))))
-             (pgg-sign-region (point-min)(point-max)))
-           (throw 'mime-edit-error 'pgp-error))
-       (setq micalg
-             (cdr (assq 'hash-algorithm
-                        (cdar (with-current-buffer pgg-output-buffer
-                                (pgg-parse-armor-region 
-                                 (point-min)(point-max))))))
-             micalg 
-             (if micalg
-                 (concat "; micalg=pgp-" (downcase (symbol-name micalg)))
-               ""))
-       (goto-char beg)
-       (insert (format "--[[multipart/signed;
- boundary=\"%s\"%s;
- protocol=\"application/pgp-signature\"][7bit]]
---%s
-" pgp-boundary micalg pgp-boundary))
-       (goto-char (point-max))
-       (insert (format "\n--%s
-Content-Type: application/pgp-signature
-Content-Transfer-Encoding: 7bit
-
-" pgp-boundary))
-       (insert-buffer-substring pgg-output-buffer)
-       (goto-char (point-max))
-       (insert (format "\n--%s--\n" pgp-boundary))))))
-
 (defvar mime-edit-encrypt-recipient-fields-list '("To" "cc"))
 
 (defun mime-edit-make-encrypt-recipient-header ()
@@ -1823,7 +1748,7 @@ Content-Transfer-Encoding: 7bit
            values (cdr values)))
     (vector from recipients header)))
 
-(defun mime-edit-encrypt-pgp-mime-with-epg (beg end boundary)
+(defun mime-edit-encrypt-pgp-mime (beg end boundary)
   (save-excursion
     (save-restriction
       (let (recipients header)
@@ -1879,58 +1804,7 @@ Content-Transfer-Encoding: 7bit
          (goto-char (point-max))
          (insert (format "\n--%s--\n" pgp-boundary)))))))
 
-(defun mime-edit-encrypt-pgp-mime-with-pgg (beg end boundary)
-  (save-excursion
-    (save-restriction
-      (let (from recipients header)
-        (let ((ret (mime-edit-make-encrypt-recipient-header)))
-          (setq from (aref ret 0)
-                recipients (aref ret 1)
-                header (aref ret 2)))
-        (narrow-to-region beg end)
-        (let* ((ret
-                (mime-edit-translate-region beg end boundary))
-               (ctype    (car ret))
-               (encoding (nth 1 ret))
-               (pgp-boundary (concat "pgp-" boundary)))
-          (goto-char beg)
-          (insert header)
-          (insert (format "Content-Type: %s\n" ctype))
-          (if encoding
-              (insert (format "Content-Transfer-Encoding: %s\n" encoding)))
-          (insert "\n")
-         (mime-encode-header-in-buffer)
-         (or (let ((pgg-default-user-id 
-                    (or mime-edit-pgp-user-id
-                        (if from 
-                            (nth 1 (std11-extract-address-components from))
-                          pgg-default-user-id))))                   
-               (pgg-encrypt-region 
-                (point-min) (point-max) 
-                (mapcar (lambda (recipient)
-                          (nth 1 (std11-extract-address-components
-                                  recipient)))
-                        (split-string recipients 
-                                      "\\([ \t\n]*,[ \t\n]*\\)+"))))
-             (throw 'mime-edit-error 'pgp-error))
-         (delete-region (point-min)(point-max))
-         (goto-char beg)
-         (insert (format "--[[multipart/encrypted;
- boundary=\"%s\";
- protocol=\"application/pgp-encrypted\"][7bit]]
---%s
-Content-Type: application/pgp-encrypted
-
---%s
-Content-Type: application/octet-stream
-Content-Transfer-Encoding: 7bit
-
-" pgp-boundary pgp-boundary pgp-boundary))
-         (insert-buffer-substring pgg-output-buffer)
-         (goto-char (point-max))
-         (insert (format "\n--%s--\n" pgp-boundary)))))))
-
-(defun mime-edit-sign-pgp-kazu-with-epg (beg end boundary)
+(defun mime-edit-sign-pgp-kazu (beg end boundary)
   (save-excursion
     (save-restriction
       (narrow-to-region beg end)
@@ -1956,27 +1830,7 @@ Content-Transfer-Encoding: 7bit
         "--[[application/pgp; format=mime][7bit]]\n" signature)
        ))))
 
-(defun mime-edit-sign-pgp-kazu-with-pgg (beg end boundary)
-  (save-excursion
-    (save-restriction
-      (narrow-to-region beg end)
-      (let* ((ret
-             (mime-edit-translate-region beg end boundary))
-            (ctype    (car ret))
-            (encoding (nth 1 ret)))
-       (goto-char beg)
-       (insert (format "Content-Type: %s\n" ctype))
-       (if encoding
-           (insert (format "Content-Transfer-Encoding: %s\n" encoding)))
-       (insert "\n")
-       (or (pgg-sign-region beg (point-max) 'clearsign)
-           (throw 'mime-edit-error 'pgp-error))
-       (goto-char beg)
-       (insert
-        "--[[application/pgp; format=mime][7bit]]\n")
-       ))))
-
-(defun mime-edit-encrypt-pgp-kazu-with-epg (beg end boundary)
+(defun mime-edit-encrypt-pgp-kazu (beg end boundary)
   (save-excursion
     (let (recipients header)
       (let ((ret (mime-edit-make-encrypt-recipient-header)))
@@ -2018,31 +1872,6 @@ If no one is selected, symmetric encryption will be performed.  "
           "--[[application/pgp; format=mime][7bit]]\n" cipher)
          )))))
 
-(defun mime-edit-encrypt-pgp-kazu-with-pgg (beg end boundary)
-  (save-excursion
-    (let (recipients header)
-      (let ((ret (mime-edit-make-encrypt-recipient-header)))
-       (setq recipients (aref ret 1)
-             header (aref ret 2)))
-      (save-restriction
-       (narrow-to-region beg end)
-       (let* ((ret
-               (mime-edit-translate-region beg end boundary))
-              (ctype    (car ret))
-              (encoding (nth 1 ret)))
-         (goto-char beg)
-         (insert header)
-         (insert (format "Content-Type: %s\n" ctype))
-         (if encoding
-             (insert (format "Content-Transfer-Encoding: %s\n" encoding)))
-         (insert "\n")
-         (or (pgg-encrypt-region beg (point-max) recipients)
-             (throw 'mime-edit-error 'pgp-error))
-         (goto-char beg)
-         (insert
-          "--[[application/pgp; format=mime][7bit]]\n")
-         )))))
-
 (defun mime-edit-convert-lbt-string (string)
   (let ((index 0))
     (while (setq index (string-match "\n" string index))
index c607fa3..aafe5fd 100644 (file)
 ;;; Code:
 
 (require 'mime-play)
-
-(defvar mime-pgp-use
-  (condition-case nil
-      (progn
-       (require 'epg-config)
-       (epg-check-configuration (epg-configuration))
-       (autoload 'epg-make-context "epg")
-       'epg)
-    (error
-     (require 'pgg-def)
-     (autoload 'pgg-decrypt-region "pgg"
-       "PGP decryption of current region." t)
-     (autoload 'pgg-verify-region "pgg"
-       "PGP verification of current region." t)
-     (autoload 'pgg-snarf-keys-region "pgg"
-       "Snarf PGP public keys in current region." t)
-     'pgg))
-  "Which PGG library to be used.")
+(require 'epg)
+(require 'epa)
 
 ;;; @ Internal method for multipart/signed
 ;;;
@@ -86,7 +70,7 @@
 ;;;
 ;;; It is based on draft-kazu-pgp-mime-00.txt (PGP-kazu).
 
-(defun mime-view-application/pgp-with-epg (entity situation)
+(defun mime-view-application/pgp (entity situation)
   (let* ((p-win (or (get-buffer-window (current-buffer))
                    (get-largest-window)))
         (new-name
             (epg-context-result-for context 'verify))
        (epa-display-verify-result (epg-context-result-for context 'verify)))))
 
-(defun mime-view-application/pgp-with-pgg (entity situation)
-  (let* ((p-win (or (get-buffer-window (current-buffer))
-                   (get-largest-window)))
-        (new-name
-         (format "%s-%s" (buffer-name) (mime-entity-number entity)))
-        (mother (current-buffer))
-        (preview-buffer (concat "*Preview-" (buffer-name) "*"))
-        representation-type message-buf)
-    (set-buffer (setq message-buf (get-buffer-create new-name)))
-    (erase-buffer)
-    (mime-insert-entity entity)
-    (cond ((progn
-            (goto-char (point-min))
-            (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE-+$" nil t))
-          (pgg-verify-region (match-beginning 0)(point-max) nil 'fetch)
-          (goto-char (point-min))
-          (delete-region
-           (point-min)
-           (and
-            (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE-+\n\n")
-            (match-end 0)))
-          (delete-region
-           (and (re-search-forward "^-+BEGIN PGP SIGNATURE-+")
-                (match-beginning 0))
-           (point-max))
-          (goto-char (point-min))
-          (while (re-search-forward "^- -" nil t)
-            (replace-match "-"))
-          (setq representation-type (if (mime-entity-cooked-p entity)
-                                        'cooked)))
-         ((progn
-            (goto-char (point-min))
-            (re-search-forward "^-+BEGIN PGP MESSAGE-+$" nil t))
-          (pgg-decrypt-region (point-min)(point-max))
-          (delete-region (point-min)(point-max))
-          (insert-buffer pgg-output-buffer)
-          (setq representation-type 'binary)))
-    (setq major-mode 'mime-show-message-mode)
-    (save-window-excursion
-      (mime-view-buffer nil preview-buffer mother
-                       nil representation-type)
-      (make-local-variable 'mime-view-temp-message-buffer)
-      (setq mime-view-temp-message-buffer message-buf))
-    (set-window-buffer p-win preview-buffer)))
-
 
 (defun mime-verify-application/*-signature (entity situation)
-  (if (eq mime-pgp-use 'epg)
-      (mime-verify-application/*-signature-with-epg entity situation)
-    (mime-verify-application/*-signature-with-pgg entity situation)))
-
-(defun mime-verify-application/*-signature-with-epg (entity situation)
   (let* ((entity-node-id (mime-entity-node-id entity))
         (mother (mime-entity-parent entity))
         (knum (car entity-node-id))
     (if (epg-context-result-for context 'verify)
        (epa-display-verify-result (epg-context-result-for context 'verify)))))
 
-(defun mime-verify-application/*-signature-with-pgg (entity situation)
-  (let* ((entity-node-id (mime-entity-node-id entity))
-        (mother (mime-entity-parent entity))
-        (knum (car entity-node-id))
-        (onum (if (> knum 0)
-                  (1- knum)
-                (1+ knum)))
-        (orig-entity (nth onum (mime-entity-children mother)))
-        (protocol (cdr (assoc "protocol" (mime-entity-parameters mother))))
-        (sig-file (make-temp-file "tm" nil ".asc")))
-    (unless (equal protocol "application/pgp-signature")
-      (error "Not supported protocol: %s" protocol))
-    (save-excursion 
-      (mime-show-echo-buffer)
-      (set-buffer mime-echo-buffer-name)
-      (set-window-start 
-       (get-buffer-window mime-echo-buffer-name)
-       (point-max)))
-    (mime-write-entity-content entity sig-file)
-    (unwind-protect
-       (with-temp-buffer
-         (mime-insert-entity orig-entity)
-         (goto-char (point-min))
-         (while (progn (end-of-line) (not (eobp)))
-           (insert "\r")
-           (forward-line 1))
-         (pgg-verify-region (point-min)(point-max) 
-                            sig-file 'fetch)
-         (save-excursion 
-           (set-buffer mime-echo-buffer-name)
-           (insert-buffer-substring pgg-errors-buffer)))
-      (delete-file sig-file))))
-
 
 ;;; @ Internal method for application/pgp-encrypted
 ;;;
                   (1- knum)
                 (1+ knum)))
         (orig-entity (nth onum (mime-entity-children mother))))
-    (if (eq mime-pgp-use 'epg)
-       (mime-view-application/pgp-with-epg orig-entity situation)
-      (mime-view-application/pgp-with-pgg orig-entity situation))))
+    (mime-view-application/pgp orig-entity situation)))
 
 
 ;;; @ Internal method for application/pgp-keys
 ;;; draft-ietf-openpgp-mime-02.txt (OpenPGP/MIME).
 
 (defun mime-add-application/pgp-keys (entity situation)
-  (if (eq mime-pgp-use 'epg)
-      (mime-add-application/pgp-keys-with-epg entity situation)
-    (mime-add-application/pgp-keys-with-pgg entity situation)))
-
-(defun mime-add-application/pgp-keys-with-epg (entity situation)
   (epg-import-keys-from-string (epg-make-context)
                               (mime-entity-content entity)))
 
-(defun mime-add-application/pgp-keys-with-pgg (entity situation)
-  (save-excursion 
-    (mime-show-echo-buffer)
-    (set-buffer mime-echo-buffer-name)
-    (set-window-start 
-     (get-buffer-window mime-echo-buffer-name)
-     (point-max)))
-  (with-temp-buffer
-    (mime-insert-entity-content entity)
-    (mime-decode-region (point-min) (point-max)
-                        (cdr (assq 'encoding situation)))
-    (pgg-snarf-keys-region (point-min)(point-max))
-    (save-excursion 
-      (set-buffer mime-echo-buffer-name)
-      (insert-buffer-substring pgg-errors-buffer))))
 
 ;;; @ Internal method for application/pkcs7-mime
 ;;;