* elmo-nmz.el (elmo-nmz-content-type-alist): New variable.
authorhmurata <hmurata>
Sat, 29 Sep 2001 13:41:40 +0000 (13:41 +0000)
committerhmurata <hmurata>
Sat, 29 Sep 2001 13:41:40 +0000 (13:41 +0000)
(elmo-map-message-fetch): Add `Content-Type' field if contents is
not a message.

elmo/ChangeLog
elmo/elmo-nmz.el

index 06c4c5f..1b2caa7 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-29  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * elmo-nmz.el (elmo-nmz-content-type-alist): New variable.
+       (elmo-map-message-fetch): Add `Content-Type' field if contents is
+       not a message.
+
 2001-09-20  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * elmo.el (elmo-folder-writable-p): Changed default value to nil.
index c768d26..0fc85ef 100644 (file)
@@ -51,6 +51,9 @@
   :type '(repeat string)
   :group 'elmo)
 
+(defvar elmo-nmz-content-type-alist '(("\.html?\\'" . "text/html"))
+  "*An alist of (REGEXP . Content-Type) related filename.")
+
 ;;; "namazu search"
 (eval-and-compile
   (luna-define-class elmo-nmz-folder
@@ -82,7 +85,7 @@
    (elmo-replace-string-as-filename
     (elmo-folder-name-internal folder))
    (expand-file-name "nmz" elmo-msgdb-dir)))
-                    
+
 (defun elmo-nmz-msgdb-create-entity (folder number)
   "Create msgdb entity for the message in the FOLDER with NUMBER."
   (elmo-msgdb-create-overview-entity-from-file
                                            location strategy
                                            &optional section unseen)
   (when (file-exists-p location)
-    (insert-file-contents-as-binary location)))
+    (insert-file-contents-as-binary location)
+    (unless (or (std11-field-body "To")
+               (std11-field-body "Resent-To")
+               (std11-field-body "Cc")
+               (std11-field-body "Bcc")
+               (std11-field-body "Newsgroups"))
+      (erase-buffer)
+      (set-buffer-multibyte t)
+      (insert-file-contents location)
+      (goto-char (point-min))
+      (insert "Content-Type: "
+             (or (cdr (elmo-string-matched-assoc
+                       location
+                       elmo-nmz-content-type-alist))
+                 "text/plain")
+             "; charset=ISO-2022-JP\nMIME-Version: 1.0\n\n")
+      (encode-coding-region (point-min) (point-max)
+                           (mime-charset-to-coding-system "ISO-2022-JP"))
+      (set-buffer-multibyte nil))))
 
 (luna-define-method elmo-map-folder-list-message-locations
   ((folder elmo-nmz-folder))