Merge flim-1_11_0.
[elisp/flim.git] / mmcooked.el
1 ;;; mmcooked.el --- MIME entity implementation for binary buffer
2
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: MIME, multimedia, mail, news
7
8 ;; This file is part of FLIM (Faithful Library about Internet Message).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'mmbuffer)
28
29 (mm-define-backend cooked (buffer))
30
31 (mm-define-method entity-cooked-p ((entity cooked)) t)
32
33 (mm-define-method write-entity-content ((entity cooked) filename)
34   (save-excursion
35     (set-buffer (mime-entity-buffer-internal entity))
36     (let ((encoding (or (mime-entity-encoding entity) "7bit")))
37       (if (member encoding '("7bit" "8bit" "binary"))
38           (write-region (mime-entity-body-start-internal entity)
39                         (mime-entity-body-end-internal entity) filename)
40         (mime-write-decoded-region (mime-entity-body-start-internal entity)
41                                    (mime-entity-body-end-internal entity)
42                                    filename encoding)
43         ))))
44
45 (mm-define-method write-entity ((entity cooked) filename)
46   (save-excursion
47     (set-buffer (mime-entity-buffer-internal entity))
48     (write-region (mime-entity-header-start-internal entity)
49                   (mime-entity-body-end-internal entity)
50                   filename)
51     ))
52
53 (mm-define-method write-entity-body ((entity cooked) filename)
54   (save-excursion
55     (set-buffer (mime-entity-buffer-internal entity))
56     (write-region (mime-entity-body-start-internal entity)
57                   (mime-entity-body-end-internal entity)
58                   filename)
59     ))
60
61 (mm-define-method insert-header ((entity cooked)
62                                  &optional invisible-fields visible-fields)
63   (let (default-mime-charset)
64     (funcall (mime-find-function 'insert-decoded-header 'buffer)
65              entity invisible-fields visible-fields)
66     ))
67
68 (mm-define-method insert-text-content ((entity cooked))
69   (let ((str (mime-entity-content entity)))
70     (insert
71      (if (member (mime-entity-encoding entity)
72                  '(nil "7bit" "8bit" "binary"))
73          str
74        (decode-mime-charset-string str
75                                    (or (mime-content-type-parameter
76                                         (mime-entity-content-type entity)
77                                         "charset")
78                                        default-mime-charset)
79                                    'CRLF)
80        ))))
81
82
83 ;;; @ end
84 ;;;
85
86 (provide 'mmcooked)
87
88 ;;; mmcooked.el ends here