Update FSF's address in GPL notices.
[elisp/flim.git] / mmcooked.el
1 ;;; mmcooked.el --- MIME entity implementation for binary buffer
2
3 ;; Copyright (C) 1998,1999 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., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, 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-buffer-entity-buffer-internal entity))
36     (let ((encoding (or (mime-entity-encoding entity) "7bit")))
37       (if (member encoding '("7bit" "8bit" "binary"))
38           (write-region (mime-buffer-entity-body-start-internal entity)
39                         (mime-buffer-entity-body-end-internal entity) filename)
40         (mime-write-decoded-region
41          (mime-buffer-entity-body-start-internal entity)
42          (mime-buffer-entity-body-end-internal entity)
43          filename encoding)
44         ))))
45
46 (mm-define-method write-entity ((entity cooked) filename)
47   (save-excursion
48     (set-buffer (mime-buffer-entity-buffer-internal entity))
49     (write-region (mime-buffer-entity-header-start-internal entity)
50                   (mime-buffer-entity-body-end-internal entity)
51                   filename)
52     ))
53
54 (mm-define-method write-entity-body ((entity cooked) filename)
55   (save-excursion
56     (set-buffer (mime-buffer-entity-buffer-internal entity))
57     (write-region (mime-buffer-entity-body-start-internal entity)
58                   (mime-buffer-entity-body-end-internal entity)
59                   filename)
60     ))
61
62 (luna-define-method mime-insert-header ((entity mime-cooked-entity)
63                                         &optional invisible-fields
64                                         visible-fields)
65   (let (default-mime-charset)
66     (funcall (car (luna-class-find-functions
67                    (luna-find-class 'mime-buffer-entity)
68                    'mime-insert-header))
69              entity invisible-fields visible-fields)
70     ))
71
72 (mm-define-method insert-text-content ((entity cooked))
73   (let ((str (mime-entity-content entity)))
74     (insert
75      (if (member (mime-entity-encoding entity)
76                  '(nil "7bit" "8bit" "binary"))
77          str
78        (decode-mime-charset-string str
79                                    (or (mime-content-type-parameter
80                                         (mime-entity-content-type entity)
81                                         "charset")
82                                        default-mime-charset)
83                                    'CRLF)
84        ))))
85
86
87 ;;; @ end
88 ;;;
89
90 (provide 'mmcooked)
91
92 ;;; mmcooked.el ends here