When reading entire body of MIME message, use MESSAGE-BODY.
authorChris Hanson <org/chris-hanson/cph>
Mon, 5 Jun 2000 18:20:38 +0000 (18:20 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 5 Jun 2000 18:20:38 +0000 (18:20 +0000)
v7/src/imail/imail-imap.scm

index 9b9052d10e41e1441a8af9679c07cb4654628d2c..6d3020fe5f04a8ed304c08dca6de57c00925a6c4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.108 2000/06/05 17:50:45 cph Exp $
+;;; $Id: imail-imap.scm,v 1.109 2000/06/05 18:20:38 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
 
 (define-method message-mime-body-part
     ((message <imap-message>) selector cache?)
-  (let ((section
-        (map (lambda (x)
-               (if (exact-nonnegative-integer? x)
-                   (+ x 1)
-                   x))
-             selector)))
-    (let ((entry
-          (list-search-positive (imap-message-body-parts message)
-            (lambda (entry)
-              (equal? (car entry) section)))))
-      (if entry
-         (cdr entry)
-         (let ((part
-                (imap:response:fetch-body-part
-                 (let ((suffix 
-                        (string-append
-                         " body part for message "
-                         (number->string (+ (message-index message) 1)))))
-                   ((imail-message-wrapper "Reading" suffix)
-                    (lambda ()
-                      (imap:read-literal-progress-hook imail-progress-meter
-                        (lambda ()
-                          (imap:command:uid-fetch
-                           (imap-folder-connection (message-folder message))
-                           (imap-message-uid message)
-                           `(',(string-append
-                                "body["
-                                (decorated-string-append
-                                 "" "." ""
-                                 (map (lambda (x)
-                                        (if (exact-nonnegative-integer? x)
-                                            (number->string x)
-                                            (symbol->string x)))
-                                      section))
-                                "]"))))))))
-                 section
-                 #f)))
-           (if (and cache?
-                    (or (eq? cache? #t)
-                        (< (string-length part) cache?)))
-               (set-imap-message-body-parts!
-                message
-                (cons (cons section part)
-                      (imap-message-body-parts message))))
-           part)))))
+  (if (equal? selector '(TEXT))
+      (message-body message)
+      (let ((section
+            (map (lambda (x)
+                   (if (exact-nonnegative-integer? x)
+                       (+ x 1)
+                       x))
+                 selector)))
+       (let ((entry
+              (list-search-positive (imap-message-body-parts message)
+                (lambda (entry)
+                  (equal? (car entry) section)))))
+         (if entry
+             (cdr entry)
+             (let ((part (%imap-message-body-part message section)))
+               (if (and cache?
+                        (or (eq? cache? #t)
+                            (< (string-length part) cache?)))
+                   (set-imap-message-body-parts!
+                    message
+                    (cons (cons section part)
+                          (imap-message-body-parts message))))
+               part))))))
+
+(define (%imap-message-body-part message section)
+  (imap:response:fetch-body-part
+   (let ((suffix 
+         (string-append " body part for message "
+                        (number->string (+ (message-index message) 1)))))
+     ((imail-message-wrapper "Reading" suffix)
+      (lambda ()
+       (imap:read-literal-progress-hook imail-progress-meter
+         (lambda ()
+           (imap:command:uid-fetch
+            (imap-folder-connection (message-folder message))
+            (imap-message-uid message)
+            `(',(string-append "body["
+                               (decorated-string-append
+                                "" "." ""
+                                (map (lambda (x)
+                                       (if (exact-nonnegative-integer? x)
+                                           (number->string x)
+                                           (symbol->string x)))
+                                     section))
+                               "]"))))))))
+   section
+   #f))
 \f
 (define (parse-mime-body body)
   (cond ((not (and (pair? body) (list? body))) (parse-mime-body:lose body))