-;;; @ decoder
-;;;
-
-(defun mime/make-method-args (cal format)
- (mapcar (function
- (lambda (arg)
- (if (stringp arg)
- arg
- (let ((ret (cdr (assoc (eval arg) cal))))
- (if ret
- ret
- "")
- ))
- ))
- format))
-
-(defun mime/start-external-method-region (beg end cal)
- (save-excursion
- (save-restriction
- (narrow-to-region beg end)
- (goto-char beg)
- (let ((method (cdr (assoc 'method cal)))
- (name (mime-viewer/get-name cal))
- )
- (if method
- (let ((file (make-temp-name
- (expand-file-name "TM" mime/tmp-dir)))
- b args)
- (if (nth 1 method)
- (setq b beg)
- (setq b
- (if (re-search-forward "^$" nil t)
- (+ (match-end 0) 1)
- (point-min)
- ))
- )
- (goto-char b)
- (write-region b end file)
- (setq cal (put-alist
- 'name (replace-as-filename name) cal))
- (setq cal (put-alist 'file file cal))
- (setq args (nconc
- (list (car method)
- mime/output-buffer-name (car method)
- )
- (mime/make-method-args cal (cdr (cdr method)))
- ))
- (apply (function start-process) args)
- (mime/show-output-buffer)
- ))
- ))))
-
-(defun mime/decode-message/partial-region (beg end cal)
- (goto-char beg)
- (let* ((root-dir (expand-file-name
- (concat "m-prts-" (user-login-name)) mime/tmp-dir))
- (id (cdr (assoc "id" cal)))
- (number (cdr (assoc "number" cal)))
- (total (cdr (assoc "total" cal)))
- (the-buf (current-buffer))
- file
- (mother mime::article/preview-buffer))
- (if (not (file-exists-p root-dir))
- (make-directory root-dir)
- )
- (setq id (replace-as-filename id))
- (setq root-dir (concat root-dir "/" id))
- (if (not (file-exists-p root-dir))
- (make-directory root-dir)
- )
- (setq file (concat root-dir "/FULL"))
- (if (not (file-exists-p file))
- (progn
- (re-search-forward "^$")
- (goto-char (+ (match-end 0) 1))
- (setq file (concat root-dir "/" number))
- (write-region (point) (point-max) file)
- (if (get-buffer "*MIME-temp*")
- (kill-buffer "*MIME-temp*")
- )
- (switch-to-buffer "*MIME-temp*")
- (let ((i 1)
- (max (string-to-int total))
- )
- (catch 'tag
- (while (<= i max)
- (setq file (concat root-dir "/" (int-to-string i)))
- (if (not (file-exists-p file))
- (progn
- (switch-to-buffer the-buf)
- (throw 'tag nil)
- ))
- (insert-file-contents file)
- (goto-char (point-max))
- (setq i (+ i 1))
- )
- (delete-other-windows)
- (write-file (concat root-dir "/FULL"))
- (setq major-mode 'mime/show-message-mode)
- (mime/viewer-mode mother)
- (pop-to-buffer (current-buffer))
- ))
- )
- (progn
- (delete-other-windows)
- (find-file file)
- (setq major-mode 'mime/show-message-mode)
- (mime/viewer-mode mother)
- (pop-to-buffer (current-buffer))
- ))
- ))
-
-(defun mime/get-content-decoding-alist (al)
- (get-unified-alist mime/content-decoding-condition al)
- )
-
-(defun mime::article/decode-content-region (cinfo)
- (let ((beg (mime::content-info/point-min cinfo))
- (end (mime::content-info/point-max cinfo))
- (ctype (mime::content-info/type cinfo))
- (params (mime::content-info/parameters cinfo))
- (encoding (mime::content-info/encoding cinfo))
- )
- (if ctype
- (let (method cal ret)
- (setq cal (append (list (cons 'type ctype)
- (cons 'encoding encoding)
- (cons 'major-mode major-mode)
- )
- params))
- (if mime-viewer/decoding-mode
- (setq cal (cons
- (cons 'mode mime-viewer/decoding-mode)
- cal))
- )
- (setq ret (mime/get-content-decoding-alist cal))
- (setq method (cdr (assoc 'method ret)))
- (cond ((and (symbolp method)
- (fboundp method))
- (funcall method beg end ret)
- )
- ((and (listp method)(stringp (car method)))
- (mime/start-external-method-region beg end ret)
- )
- (t (mime/show-output-buffer
- "No method are specified for %s\n" ctype)
- ))
- ))
- ))
-
-(defun mime/show-output-buffer (&rest forms)
- (let ((the-buf (current-buffer)))
- (if (null (get-buffer-window mime/output-buffer-name))
- (split-window-vertically (/ (* (window-height) 3) 4))
- )
- (pop-to-buffer mime/output-buffer-name)
- (goto-char (point-max))
- (if forms
- (insert (apply (function format) forms))
- )
- (pop-to-buffer the-buf)
- ))
-
-