;;; -*-Scheme-*-
;;;
-;;; $Id: imail-core.scm,v 1.53 2000/05/12 17:56:18 cph Exp $
+;;; $Id: imail-core.scm,v 1.54 2000/05/12 18:22:46 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(define-generic %copy-folder (url new-url))
(define-method %copy-folder ((url <url>) (new-url <url>))
- (let ((from (open-folder url))
- (to (new-folder new-url)))
- (let ((n (folder-length from)))
+ (let ((folder (open-folder url)))
+ (let ((n (folder-length folder)))
(do ((i 0 (+ i 1)))
((= i n))
- (append-message to (get-message from i))))
- (save-folder to)))
+ (%append-message (get-message folder i) new-url)))))
+
+;; -------------------------------------------------------------------
+;; Insert a copy of MESSAGE in FOLDER at the end of the existing
+;; messages. Unspecified result.
+
+(define (append-message message url)
+ (%append-message message (->url url)))
+
+(define-generic %append-message (message url))
\f
;; -------------------------------------------------------------------
;; Return a list of URLs for folders that match URL-PATTERN.
(%get-message folder index))
(define-generic %get-message (folder index))
-\f
-;; -------------------------------------------------------------------
-;; Insert a copy of MESSAGE in FOLDER at the end of the existing
-;; messages. Unspecified result.
-
-(define-generic append-message (folder message))
;; -------------------------------------------------------------------
;; Remove all messages in FOLDER that are marked for deletion.
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-file.scm,v 1.21 2000/05/12 17:56:22 cph Exp $
+;;; $Id: imail-file.scm,v 1.22 2000/05/12 18:22:50 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(define-method %get-message ((folder <file-folder>) index)
(list-ref (file-folder-messages folder) index))
-(define-method append-message ((folder <file-folder>) (message <message>))
- (let ((message (copy-message message)))
- (without-interrupts
- (lambda ()
- (set-file-folder-messages!
- folder
- (let ((messages (file-folder-messages folder)))
- (if (pair? messages)
- (begin
- (let loop ((prev messages) (this (cdr messages)) (index 1))
- (if (pair? this)
- (loop this (cdr this) (fix:+ index 1))
- (begin
- (attach-message! message folder index)
- (set-cdr! prev (list message)))))
- messages)
- (begin
- (attach-message! message folder 0)
- (list message)))))))))
+(define-method %append-message ((message <message>) (url <file-url>))
+ (let ((folder (get-memoized-folder url)))
+ (if folder
+ (let ((message (copy-message message)))
+ (without-interrupts
+ (lambda ()
+ (set-file-folder-messages!
+ folder
+ (let ((messages (file-folder-messages folder)))
+ (if (pair? messages)
+ (begin
+ (let loop
+ ((prev messages)
+ (this (cdr messages))
+ (index 1))
+ (if (pair? this)
+ (loop this (cdr this) (fix:+ index 1))
+ (begin
+ (attach-message! message folder index)
+ (set-cdr! prev (list message)))))
+ messages)
+ (begin
+ (attach-message! message folder 0)
+ (list message))))))))
+ (append-message-to-file message url))))
+
+(define-generic append-message-to-file (message url))
\f
(define-method expunge-deleted-messages ((folder <file-folder>))
(without-interrupts
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-imap.scm,v 1.32 2000/05/12 18:00:52 cph Exp $
+;;; $Id: imail-imap.scm,v 1.33 2000/05/12 18:22:52 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(define-method %copy-folder ((url <imap-url>) (new-url <imap-url>))
???)
+(define-method %append-message ((message <message>) (url <imap-url>))
+ ???)
+
(define-method available-folder-names ((url <imap-url>))
???)
\f
(or (imap-folder-unseen folder) 0))
|#
-(define-method append-message ((folder <imap-folder>) (message <message>))
- (guarantee-imap-folder-open folder)
- ???)
-
(define-method expunge-deleted-messages ((folder <imap-folder>))
(guarantee-imap-folder-open folder)
(imap:command:expunge (imap-folder-connection folder)))
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-rmail.scm,v 1.24 2000/05/10 17:03:27 cph Exp $
+;;; $Id: imail-rmail.scm,v 1.25 2000/05/12 18:22:56 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(synchronize-file-folder-write folder write-rmail-file))
(define (compute-rmail-folder-header-fields folder)
+ (make-rmail-folder-header-fields (folder-flags folder)))
+
+(define (make-rmail-folder-header-fields flags)
(list (make-header-field "Version" " 5")
(make-header-field "Labels"
(decorated-string-append
"" "," ""
- (flags->rmail-labels (folder-flags folder))))
+ (flags->rmail-labels flags)))
(make-header-field "Note" " This is the header of an rmail file.")
(make-header-field "Note" " If you are seeing it in rmail,")
(make-header-field "Note"
(let ((message (read-rmail-message port)))
(if message
(begin
- (append-message folder message)
+ (append-message message (folder-url folder))
(loop))))))))))
(define (read-rmail-prolog port)
;; **** Do backup of file here.
(call-with-binary-output-file pathname
(lambda (port)
- (write-string "BABYL OPTIONS: -*- rmail -*-" port)
- (newline port)
- (write-header-fields (rmail-folder-header-fields folder) port)
- (write-char rmail-message:end-char port)
+ (write-rmail-file-header (rmail-folder-header-fields folder))
(for-each (lambda (message) (write-rmail-message message port))
(file-folder-messages folder)))))
+(define-method append-message-to-file ((message <message>) (url <rmail-url>))
+ (let ((pathname (file-url-pathname url)))
+ (if (file-exists? pathname)
+ (let ((port (open-binary-output-file pathname #t)))
+ (write-rmail-message message port)
+ (close-port port))
+ (call-with-binary-output-file pathname
+ (lambda (port)
+ (write-rmail-file-header (make-rmail-folder-header-fields '()))
+ (write-rmail-message message port))))))
+
+(define (write-rmail-file-header header-fields)
+ (write-string "BABYL OPTIONS: -*- rmail -*-" port)
+ (newline port)
+ (write-header-fields header-fields port)
+ (write-char rmail-message:end-char port))
+
(define (write-rmail-message message port)
(write-char rmail-message:start-char port)
(newline port)
(let ((n (folder-length inbox)))
(do ((index 0 (+ index 1)))
((= index n))
- (append-message folder
- (get-message inbox index))))
+ (append-message (get-message inbox index)
+ (folder-url folder))))
inbox))
pathnames)))
(save-folder folder)
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-top.scm,v 1.42 2000/05/12 18:00:56 cph Exp $
+;;; $Id: imail-top.scm,v 1.43 2000/05/12 18:22:59 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
"Append messages to this folder from a specified folder."
"sInput from folder"
(lambda (url-string)
- (let ((folder (selected-folder))
- (message (selected-message))
- (folder* (open-folder url-string)))
- (let ((n (folder-length folder*)))
+ (let ((message (selected-message))
+ (folder (open-folder url-string))
+ (url (folder-url (selected-folder))))
+ (let ((n (folder-length folder)))
(do ((index 0 (+ index 1)))
((= index n))
- (append-message folder (get-message folder* index))))
+ (append-message (get-message folder index) url)))
(if (not message)
(select-message folder (first-unseen-message folder))))))
"Append this message to a specified folder."
"sOutput to folder"
(lambda (url-string)
- (let ((folder (open-folder url-string))
- (message (selected-message)))
- (append-message folder message)
+ (let ((message (selected-message)))
+ (append-message message url-string)
(message-filed message)
(if (ref-variable imail-delete-after-output)
((ref-command imail-delete-forward) #f))
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-umail.scm,v 1.18 2000/05/10 17:03:30 cph Exp $
+;;; $Id: imail-umail.scm,v 1.19 2000/05/12 18:23:03 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(for-each (lambda (message) (write-umail-message message port))
(file-folder-messages folder)))))
+(define-method append-message-to-file ((message <message>) (url <umail-url>))
+ (let ((port (open-binary-output-file (file-url-pathname url) #t)))
+ (write-umail-message message port)
+ (close-port port)))
+
(define (write-umail-message message port)
(let ((from-line (get-message-property message "umail-from-line" #f)))
(if from-line
IMAIL To-Do List
-$Id: todo.txt,v 1.5 2000/05/12 17:56:46 cph Exp $
+$Id: todo.txt,v 1.6 2000/05/12 18:23:05 cph Exp $
Bug fixes
---------
Binary search can be used which should produce excellent results on
large folders. UID FETCH command should be useful for this.
-* Change APPEND-MESSAGE to accept arguments (MESSAGE URL) rather than
- (FOLDER MESSAGE) as currently. There's no need to have the folder
- open to append a message to it, and this requirement causes problems
- for the IMAP back end.
-
* Try to leverage IMAP MIME parser by building compatible
interface for file-based folders.