1 ;;; mm-view.el --- Functions for viewing MIME objects
2 ;; Copyright (C) 1998,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
32 (autoload 'gnus-article-prepare-display "gnus-art")
33 (autoload 'vcard-parse-string "vcard")
34 (autoload 'vcard-format-string "vcard"))
37 ;;; Functions for displaying various formats inline
40 (defun mm-inline-image (handle)
41 (let ((annot (make-annotation (mm-get-image handle) nil 'text))
43 (mm-insert-inline handle "\n")
44 (set-extent-property annot 'mm t)
45 (set-extent-property annot 'duplicable t)))
47 (defvar mm-w3-setup nil)
55 (setq mm-w3-setup t)))
57 (defun mm-inline-text (handle)
58 (let ((type (cadr (split-string (car (mm-handle-type handle)) "/")))
59 text buffer-read-only)
63 (setq text (mm-get-part handle))
65 (url-standalone-mode t)
67 (url-generic-parse-url (format "cid:%s" (mm-handle-id handle))))
68 (width (window-width))
69 (charset (mail-content-type-get
70 (mm-handle-type handle) 'charset)))
74 (narrow-to-region b (point))
75 (goto-char (point-min))
76 (if (or (re-search-forward w3-meta-content-type-charset-regexp nil t)
77 (re-search-forward w3-meta-charset-content-type-regexp nil t))
78 (setq charset (w3-coding-system-for-mime-charset
79 (buffer-substring-no-properties
82 (mm-decode-body charset)
83 (save-window-excursion
84 (let ((w3-strict-width width)
85 (url-standalone-mode t))
86 (w3-region (point-min) (point-max)))))
87 (narrow-to-region (1+ (point-min)) (point-max))
88 (mm-handle-set-undisplayer
91 (let (buffer-read-only)
94 (face-property 'default prop) (current-buffer)))
95 '(background background-pixmap foreground))
96 (delete-region ,(point-min-marker)
97 ,(point-max-marker))))))))
98 ((or (equal type "enriched")
99 (equal type "richtext"))
101 (mm-with-unibyte-buffer
102 (mm-insert-part handle)
103 (save-window-excursion
104 (enriched-decode (point-min) (point-max))
105 (setq text (buffer-string)))))
106 (mm-insert-inline handle text))
107 ((equal type "x-vcard")
112 (vcard-parse-string (mm-get-part handle)
113 'vcard-standard-filter)))))
115 (setq text (mm-get-part handle))
117 (charset (mail-content-type-get
118 (mm-handle-type handle) 'charset)))
119 (insert (mm-decode-string text charset))
121 (narrow-to-region b (point))
122 (set-text-properties (point-min) (point-max) nil)
123 (mm-handle-set-undisplayer
126 (let (buffer-read-only)
127 (delete-region ,(point-min-marker)
128 ,(point-max-marker)))))))))))
130 (defun mm-insert-inline (handle text)
131 "Insert TEXT inline from HANDLE."
134 (mm-handle-set-undisplayer
137 (let (buffer-read-only)
138 (delete-region ,(set-marker (make-marker) b)
139 ,(set-marker (make-marker) (point))))))))
141 (defun mm-inline-audio (handle)
142 (message "Not implemented"))
144 (defun mm-view-sound-file ()
145 (message "Not implemented"))
147 (defun mm-w3-prepare-buffer ()
149 (let ((url-standalone-mode t))
150 (w3-prepare-buffer)))
152 (defun mm-view-message ()
153 (mm-enable-multibyte)
154 (gnus-article-prepare-display)
155 (run-hooks 'gnus-article-decode-hook)
157 (goto-char (point-min)))
159 (defun mm-inline-message (handle)
163 (narrow-to-region b b)
164 (mm-insert-part handle)
165 (run-hooks 'gnus-article-decode-hook)
166 (gnus-article-prepare-display)
167 (mm-handle-set-undisplayer
170 (let (buffer-read-only)
173 (face-property 'default prop) (current-buffer)))
174 '(background background-pixmap foreground))
175 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))
179 ;; mm-view.el ends here