Rename `mime-raw-content-info' -> `mime-raw-entity-info'.
[elisp/semi.git] / mime-play.el
index a6a03de..435aa46 100644 (file)
@@ -63,10 +63,14 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
 (defun mime-playback-entity (cinfo &optional mode)
   (let ((beg (mime-entity-info-point-min cinfo))
        (end (mime-entity-info-point-max cinfo))
-       (ctype (or (mime-entity-info-type/subtype cinfo) "text/plain"))
+       (c-type (mime-entity-info-media-type cinfo))
+       (c-subtype (mime-entity-info-media-subtype cinfo))
        (params (mime-entity-info-parameters cinfo))
        (encoding (mime-entity-info-encoding cinfo))
        )
+    (or c-type
+       (setq c-type 'text
+             c-subtype 'plain))
     ;; Check for VM
     (if (< beg (point-min))
        (setq beg (point-min))
@@ -75,7 +79,8 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
        (setq end (point-max))
       )
     (let (method cal ret)
-      (setq cal (list* (cons 'type ctype)
+      (setq cal (list* (cons 'type c-type)
+                      (cons 'subtype c-subtype)
                       (cons 'encoding encoding)
                       (cons 'major-mode major-mode)
                       params))
@@ -248,6 +253,39 @@ window.")
   )
 
 
+;;; @ file extraction
+;;;
+
+(defun mime-method-to-save (beg end cal)
+  (goto-char beg)
+  (let* ((name
+         (save-restriction
+           (narrow-to-region beg end)
+           (mime-article/get-filename cal)
+           ))
+        (encoding (cdr (assq 'encoding cal)))
+        (filename
+          (if (and name (not (string-equal name "")))
+             (expand-file-name name
+                               (call-interactively
+                                (function
+                                 (lambda (dir)
+                                   (interactive "DDirectory: ")
+                                   dir))))
+           (call-interactively
+            (function
+             (lambda (file)
+               (interactive "FFilename: ")
+               (expand-file-name file))))))
+        )
+    (if (file-exists-p filename)
+        (or (yes-or-no-p (format "File %s exists. Save anyway? " filename))
+            (error "")))
+    (re-search-forward "\n\n")
+    (mime-write-decoded-region (match-end 0)(point-max) filename encoding)
+    ))
+
+
 ;;; @ mail/news message
 ;;;