;;; -*-Scheme-*-
;;;
-;;; $Id: imail-core.scm,v 1.59 2000/05/15 19:20:40 cph Exp $
+;;; $Id: imail-core.scm,v 1.60 2000/05/16 04:14:33 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(if (not (message? message))
(error:wrong-type-argument message "IMAIL message" procedure)))
-(define (make-detached-message headers body)
- (call-with-values (lambda () (parse-imail-header-fields headers))
- (lambda (headers flags)
- (make-message headers body flags))))
-
-(define (parse-imail-header-fields headers)
- (let loop ((headers headers) (headers* '()) (flags '()))
- (cond ((not (pair? headers))
- (values (reverse! headers*)
- (remove-duplicates! (reverse! flags) string-ci=?)))
- ((header-field->message-flags (car headers))
- => (lambda (flags*)
- (loop (cdr headers)
- headers*
- (append! (reverse! (cdr flags*)) flags))))
- (else
- (loop (cdr headers)
- (cons (car headers) headers*)
- flags)))))
-\f
(define (copy-message message)
(make-message (map copy-header-field (message-header-fields message))
(message-body message)
(let ((folder (message-folder message)))
(if folder
(folder-modified! folder))))))
+
+(define-generic message-internal-time (message))
+
+(define-method message-internal-time ((message <message>))
+ (let loop ((headers (get-all-header-fields headers "received")) (winner #f))
+ (if (pair? headers)
+ (call-with-values
+ (lambda ()
+ (rfc822:received-header-components
+ (header-field-value (car headers))))
+ (lambda (from by via with id for time)
+ from by via with id for ;ignored
+ (loop (cdr headers)
+ (if (or (not winner) (< time winner)) time winner))))
+ (or winner
+ (let ((date (get-first-header-field-value headers "date" #f)))
+ (and date
+ (string->universal-time date)))))))
\f
;;;; Message Navigation
(cons #f (burst-string (header-field-value header) char-set:lwsp #t))))
(define message-flags:name "X-IMAIL-FLAGS")
+
+(define (parse-imail-header-fields headers)
+ (let loop ((headers headers) (headers* '()) (flags '()))
+ (cond ((not (pair? headers))
+ (values (reverse! headers*)
+ (remove-duplicates! (reverse! flags) string-ci=?)))
+ ((header-field->message-flags (car headers))
+ => (lambda (flags*)
+ (loop (cdr headers)
+ headers*
+ (append! (reverse! (cdr flags*)) flags))))
+ (else
+ (loop (cdr headers)
+ (cons (car headers) headers*)
+ flags)))))
\f
(define (message-deleted? msg) (message-flagged? msg "deleted"))
(define (message-undeleted? msg) (not (message-flagged? msg "deleted")))
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-imap.scm,v 1.42 2000/05/16 03:36:17 cph Exp $
+;;; $Id: imail-imap.scm,v 1.43 2000/05/16 04:14:37 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
((string-ci=? flag "deleted") '\DELETED)
((string-ci=? flag "seen") '\SEEN)
(else (intern flag))))
+
+(define-method message-internal-time ((message <imap-message>))
+ (imap:response:fetch-attribute
+ (imap:command:fetch (imap-message-connection message)
+ (message-index message)
+ '(INTERNALDATE))
+ 'INTERNALDATE))
\f
;;; These reflectors are needed to guarantee that we read the
;;; appropriate information from the server. Normally most message
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-umail.scm,v 1.23 2000/05/15 19:20:58 cph Exp $
+;;; $Id: imail-umail.scm,v 1.24 2000/05/16 04:14:42 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
"unknown")
" "
(universal-time->local-ctime-string (get-universal-time))))
+
+(define-method message-internal-time ((message <umail-message>))
+ (or (extract-umail-from-time (umail-message-from-line message))
+ (call-next-method message)))
\f
;;;; Read unix mail file