Add nnir-1.68.
[elisp/gnus.git-] / lisp / mm-view.el
index 9ff7036..82f116c 100644 (file)
@@ -34,7 +34,8 @@
   (autoload 'vcard-parse-string "vcard")
   (autoload 'vcard-format-string "vcard")
   (autoload 'fill-flowed "flow-fill")
-  (autoload 'diff-mode "diff-mode"))
+  (unless (fboundp 'diff-mode)
+    (autoload 'diff-mode "diff-mode" "" t nil)))
 
 ;;;
 ;;; Functions for displaying various formats inline
       (mm-insert-inline
        handle
        (concat "\n-- \n"
-              (if (fboundp 'vcard-pretty-print)
-                  (vcard-pretty-print (mm-get-part handle))
-                (vcard-format-string
-                 (vcard-parse-string (mm-get-part handle)
-                                     'vcard-standard-filter))))))
+              (ignore-errors
+                (if (fboundp 'vcard-pretty-print)
+                    (vcard-pretty-print (mm-get-part handle))
+                  (vcard-format-string
+                   (vcard-parse-string (mm-get-part handle)
+                                       'vcard-standard-filter)))))))
      (t
       (let ((b (point))
            (charset (mail-content-type-get
   (mm-string-as-unibyte
    (apply 'concat
          (mapcar 'char-to-string
-                 (list ?\x30 ?\x82 ?\x01 ?\x91 ?\x06 ?\x09 ?\x2a ?\x86 ?\x48
+                 (list ?\x30 ?\x5c ?\x28 ?\x80 ?\x5c ?\x7c ?\x81 ?\x2e ?\x5c
+                       ?\x7c ?\x82 ?\x2e ?\x2e ?\x5c ?\x7c ?\x83 ?\x2e ?\x2e
+                       ?\x2e ?\x5c ?\x29 ?\x06 ?\x09 ?\x5c ?\x2a ?\x86 ?\x48
                        ?\x86 ?\xf7 ?\x0d ?\x01 ?\x07 ?\x02)))))
 
 ;;      id-envelopedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
   (mm-string-as-unibyte
    (apply 'concat
          (mapcar 'char-to-string
-                 (list ?\x30 ?\x82 ?\x01 ?\x91 ?\x06 ?\x09 ?\x2a ?\x86 ?\x48
+                 (list ?\x30 ?\x5c ?\x28 ?\x80 ?\x5c ?\x7c ?\x81 ?\x2e ?\x5c
+                       ?\x7c ?\x82 ?\x2e ?\x2e ?\x5c ?\x7c ?\x83 ?\x2e ?\x2e
+                       ?\x2e ?\x5c ?\x29 ?\x06 ?\x09 ?\x5c ?\x2a ?\x86 ?\x48
                        ?\x86 ?\xf7 ?\x0d ?\x01 ?\x07 ?\x03)))))
 
 (defun mm-view-pkcs7-get-type (handle)
-  (with-temp-buffer
-    (mm-insert-part handle)
-    (cond ((looking-at (regexp-quote mm-pkcs7-enveloped-magic))
-          'enveloped)
-         ((looking-at (regexp-quote mm-pkcs7-signed-magic))
-          'signed)
-         (t
-          (error "Could not identify PKCS#7 type")))))
+  (mm-with-unibyte-buffer
+   (mm-insert-part handle)
+   (cond ((looking-at mm-pkcs7-enveloped-magic)
+         'enveloped)
+        ((looking-at mm-pkcs7-signed-magic)
+         'signed)
+        (t
+         (error "Could not identify PKCS#7 type")))))
 
 (defun mm-view-pkcs7 (handle)
   (case (mm-view-pkcs7-get-type handle)
     (otherwise (error "Unknown or unimplemented PKCS#7 type"))))
 
 (defun mm-view-pkcs7-decrypt (handle)
-  (if (cond
-       ((eq mm-decrypt-option 'never) nil)
-       ((eq mm-decrypt-option 'always) t)
-       ((eq mm-decrypt-option 'known) t)
-       (t (y-or-n-p
-          (format "Decrypt (S/MIME) part? "))))
-      (let (res)
-       (with-temp-buffer
-         (insert-buffer (mm-handle-buffer handle))
-         (goto-char (point-min))
-         (insert "MIME-Version: 1.0\n")
-         (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
-         (smime-decrypt-region
-          (point-min) (point-max)
-          (if (= (length smime-keys) 1)
-              (cadar smime-keys)
-            (smime-get-key-by-email
-             (completing-read "Decrypt this part with which key? "
-                              smime-keys nil nil
-                              (and (listp (car-safe smime-keys))
-                                   (caar smime-keys))))))
-         (setq res (buffer-string)))
-       (mm-insert-inline handle res))))
+  (insert-buffer (mm-handle-buffer handle))
+  (goto-char (point-min))
+  (insert "MIME-Version: 1.0\n")
+  (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
+  (smime-decrypt-region
+   (point-min) (point-max)
+   (if (= (length smime-keys) 1)
+       (cadar smime-keys)
+     (smime-get-key-by-email
+      (completing-read "Decrypt this part with which key? "
+                      smime-keys nil nil
+                      (and (listp (car-safe smime-keys))
+                           (caar smime-keys)))))))
 
 (provide 'mm-view)