(mime-acting-condition): Use `mime-method-to-save' instead of external
[elisp/semi.git] / mime-play.el
index d2eb479..65b9fcf 100644 (file)
@@ -1,14 +1,13 @@
-;;; mime-play.el --- decoder for mime-view.el
+;;; mime-play.el --- Playback processing module for mime-view.el
 
-;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1994,1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1995/9/26 (separated from tm-view.el)
 ;;     Renamed: 1997/2/21 from tm-play.el
-;; Version: $Id: mime-play.el,v 0.48 1997-09-05 08:14:47 morioka Exp $
 ;; Keywords: MIME, multimedia, mail, news
 
-;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
+;; This file is part of SEMI (Secretariat of Emacs MIME Interfaces).
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -53,7 +52,7 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
              )
          (setq mime-preview/after-decoded-position (point))
          (set-buffer raw-buffer)
-         (mime-display-content cinfo mode)
+         (mime-playback-entity cinfo mode)
          (if (eq (current-buffer) raw-buffer)
              (progn
                (set-buffer the-buf)
@@ -61,12 +60,12 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
                ))
          ))))
 
-(defun mime-display-content (cinfo &optional mode)
+(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::content-info/type cinfo) "text/plain"))
-       (params (mime::content-info/parameters cinfo))
-       (encoding (mime::content-info/encoding cinfo))
+       (ctype (or (mime-entity-info-type/subtype cinfo) "text/plain"))
+       (params (mime-entity-info-parameters cinfo))
+       (encoding (mime-entity-info-encoding cinfo))
        )
     ;; Check for VM
     (if (< beg (point-min))
@@ -90,7 +89,7 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
             (funcall method beg end ret)
             )
            ((and (listp method)(stringp (car method)))
-            (mime-article/start-external-method-region beg end ret)
+            (mime-activate-external-method beg end ret)
             )
            (t
             (mime-show-echo-buffer
@@ -111,7 +110,7 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
 ;;; @ external decoder
 ;;;
 
-(defun mime-article/start-external-method-region (beg end cal)
+(defun mime-activate-external-method (beg end cal)
   (save-excursion
     (save-restriction
       (narrow-to-region beg end)
@@ -141,15 +140,15 @@ If MODE is specified, play as it.  Default MODE is \"play\"."
                          (list (car method)
                                mime-echo-buffer-name (car method)
                                )
-                         (mime-article/make-method-args cal
-                                                        (cdr (cdr method)))
+                         (mime-make-external-method-args
+                          cal (cdr (cdr method)))
                          ))
              (apply (function start-process) args)
              (mime-show-echo-buffer)
              ))
        ))))
 
-(defun mime-article/make-method-args (cal format)
+(defun mime-make-external-method-args (cal format)
   (mapcar (function
           (lambda (arg)
             (if (stringp arg)
@@ -249,6 +248,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
 ;;;
 
@@ -264,7 +296,7 @@ It is registered to variable `mime-view-quitting-method-alist'."
     (pop-to-buffer mother)
     ))
 
-(defun mime-display-message/rfc822 (beg end cal)
+(defun mime-method-to-display-message/rfc822 (beg end cal)
   (let* ((cnum (mime-article/point-content-number beg))
         (new-name (format "%s-%s" (buffer-name) cnum))
         (mother mime-view-buffer)
@@ -303,7 +335,7 @@ It is registered to variable `mime-view-quitting-method-alist'."
     (write-region start end file)
     ))
 
-(defun mime-display-message/partial (beg end cal)
+(defun mime-method-to-store-message/partial (beg end cal)
   (goto-char beg)
   (let* ((root-dir
          (expand-file-name
@@ -344,7 +376,7 @@ It is registered to variable `mime-view-quitting-method-alist'."
       (re-search-forward "^$")
       (goto-char (1+ (match-end 0)))
       (setq file (concat root-dir "/" number))
-      (mime-article::write-region (point) (point-max) file)
+      (mime-article::write-region (point) end file)
       (let ((total-file (concat root-dir "/CT")))
        (setq total
              (if total
@@ -355,7 +387,7 @@ It is registered to variable `mime-view-quitting-method-alist'."
                           (get-buffer-create mime-temp-buffer-name))
                          (erase-buffer)
                          (insert total)
-                         (write-file total-file)
+                         (write-region (point-min)(point-max) total-file)
                          (kill-buffer (current-buffer))
                          ))
                    (string-to-number total)
@@ -388,7 +420,9 @@ It is registered to variable `mime-view-quitting-method-alist'."
                    (goto-char (point-max))
                    (setq i (1+ i))
                    ))
-               (as-binary-output-file (write-file (concat root-dir "/FULL")))
+               (as-binary-output-file
+                 (write-region (point-min)(point-max)
+                               (expand-file-name "FULL" root-dir)))
                (let ((i 1))
                  (while (<= i total)
                    (let ((file (format "%s/%d" root-dir i)))
@@ -433,7 +467,7 @@ It is registered to variable `mime-view-quitting-method-alist'."
     (dired dir)
     ))
 
-(defun mime-display-message/external-ftp (beg end cal)
+(defun mime-method-to-display-message/external-ftp (beg end cal)
   (let* ((site (cdr (assoc "site" cal)))
         (directory (cdr (assoc "directory" cal)))
         (name (cdr (assoc "name" cal)))
@@ -450,7 +484,7 @@ It is registered to variable `mime-view-quitting-method-alist'."
 ;;; @ rot13-47
 ;;;
 
-(defun mime-display-caesar (start end cal)
+(defun mime-method-to-display-caesar (start end cal)
   "Internal method for mime-view to display ROT13-47-48 message."
   (let* ((cnum (mime-article/point-content-number start))
         (new-name (format "%s-%s" (buffer-name) cnum))