Send STATUS folder event when IMAP folder opened. Guarantee that
authorChris Hanson <org/chris-hanson/cph>
Tue, 23 May 2000 04:35:48 +0000 (04:35 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 23 May 2000 04:35:48 +0000 (04:35 +0000)
connection's folder is reset if the user aborts the SELECT.

v7/src/imail/imail-imap.scm

index 20d5a97e1e8f0797c22e42b94498a3fa7454ed59..7c00eb7e9edf6ac6c48ceca5b4c4e742a68e859c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.81 2000/05/23 04:23:05 cph Exp $
+;;; $Id: imail-imap.scm,v 1.82 2000/05/23 04:35:48 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
      (set-imap-folder-n-messages! folder 0)
      (set-imap-folder-messages! folder (initial-messages)))))
 
+(define (guarantee-imap-folder-open folder)
+  (let ((connection (imap-folder-connection folder)))
+    (if (or (guarantee-imap-connection-open connection)
+           (not (eq? folder (imap-connection-folder connection))))
+       (begin
+         (set-imap-folder-messages-synchronized?! folder #f)
+         (set-imap-connection-folder! connection folder)
+         (let ((selected? #f))
+           (dynamic-wind
+            (lambda () unspecific)
+            (lambda ()
+              (set! selected?
+                    (imap:command:select
+                     connection
+                     (imap-url-mailbox (folder-url folder))))
+              unspecific)
+            (lambda ()
+              (if (not selected?)
+                  (set-imap-connection-folder! connection #f)))))
+         (folder-modified! folder 'STATUS)
+         #t))))
+\f
 (define (new-imap-folder-uidvalidity! folder uidvalidity)
   (without-interrupts
    (lambda ()
     (guarantee-imap-folder-open folder)
     folder))
 
-(define (guarantee-imap-folder-open folder)
-  (let ((connection (imap-folder-connection folder)))
-    (if (or (guarantee-imap-connection-open connection)
-           (not (eq? folder (imap-connection-folder connection))))
-       (begin
-         (set-imap-folder-messages-synchronized?! folder #f)
-         (set-imap-connection-folder! connection folder)
-         (if (not
-              (imap:command:select connection
-                                   (imap-url-mailbox (folder-url folder))))
-             (set-imap-connection-folder! connection #f))
-         #t))))
-
 (define-method %close-folder ((folder <imap-folder>))
   (let ((connection (imap-folder-connection folder)))
     (maybe-close-imap-connection connection)