1 ;;; mmgnus.el --- MIME entity implementation for gnus-article
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;; Keiichi Suzuki <keiichi@nanp.org>
7 ;; Keywords: MIME, multimedia, mail, news
9 ;; This file is part of Nana-gnus.
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
29 (require 'eword-decode)
31 (luna-define-class mmgnus-entity (mime-entity)
33 header undisplayer content-description cache content-id))
35 (luna-define-internal-accessors 'mmgnus-entity)
37 (luna-define-method initialize-instance ((entity mmgnus-entity)
39 (apply (car (luna-class-find-functions
40 (luna-find-class 'standard-object)
41 'initialize-instance))
44 (defun mmgnus-visible-field-p (field-name visible-fields invisible-fields)
47 (let ((regexp (car visible-fields)))
48 (if (string-match regexp field-name)
51 (setq visible-fields (cdr visible-fields))
54 (while invisible-fields
55 (let ((regexp (car invisible-fields)))
56 (if (string-match regexp field-name)
59 (setq invisible-fields (cdr invisible-fields))
63 (defun mmgnus-insert-header-from-string (string
64 &optional invisible-fields
66 (let ((the-buf (current-buffer))
67 (mode-obj (mime-find-field-presentation-method 'wide))
69 f-b p f-e field-name len field field-body buffer)
71 (setq buffer (current-buffer))
73 (goto-char (point-min))
74 (while (re-search-forward std11-field-head-regexp nil t)
75 (setq f-b (match-beginning 0)
77 field-name (buffer-substring f-b p)
78 len (string-width field-name)
79 f-e (std11-field-end))
80 (when (mmgnus-visible-field-p field-name
81 visible-fields invisible-fields)
83 (capitalize (buffer-substring f-b (1- p))))
84 field-body (buffer-substring p f-e)
85 field-decoder (inline (mime-find-field-decoder-internal
87 (with-current-buffer the-buf
89 (insert (if field-decoder
90 (funcall field-decoder field-body len)
96 (luna-define-method mime-insert-header ((entity mmgnus-entity)
97 &optional invisible-fields
99 (mmgnus-insert-header-from-string
100 (mmgnus-entity-header-internal entity)
101 invisible-fields visible-fields))
103 (luna-define-method mime-entity-content ((entity mmgnus-entity))
106 ((bufferp (mmgnus-entity-body-internal entity))
107 (set-buffer (mmgnus-entity-body-internal entity))
108 (mime-decode-string (buffer-string) (mime-entity-encoding entity)))
110 (error "Invalid body object. %s"
111 (mmgnus-entity-body-internal entity))))))
113 (luna-define-class mime-gnus-entity (mmgnus-entity)
115 subject from date id references chars lines xref extra))
117 (luna-define-internal-accessors 'mime-gnus-entity)
119 (luna-define-method initialize-instance ((entity mime-gnus-entity)
121 (apply (car (luna-class-find-functions
122 (luna-find-class 'standard-object)
123 'initialize-instance))
126 (luna-define-method mime-insert-header :around ((entity mime-gnus-entity)
127 &optional invisible-fields
129 (luna-call-next-method))
131 (luna-define-method mime-entity-content :around ((entity mime-gnus-entity))
132 (luna-call-next-method))
139 ;;; mmgnus.el ends here