;;; -*-Scheme-*-
;;;
-;;; $Id: imail-core.scm,v 1.119 2001/05/07 18:02:52 cph Exp $
+;;; $Id: imail-core.scm,v 1.120 2001/05/09 17:38:17 cph Exp $
;;;
;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
;;;
;; Return #T if URL represents an existing folder.
(define-generic url-exists? (url))
+;; Return #T if URL both exists and can be opened.
+(define-generic url-selectable? (url))
+
;; Return a string that uniquely identifies the server and account for
;; URL. E.g. for IMAP this could be the URL string without the
;; mailbox information. This string will be included in the
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-file.scm,v 1.61 2001/03/19 22:51:48 cph Exp $
+;;; $Id: imail-file.scm,v 1.62 2001/05/09 17:38:22 cph Exp $
;;;
;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
;;;
(define-method url-exists? ((url <file-url>))
(file-exists? (file-url-pathname url)))
+(define-method url-selectable? ((url <file-url>))
+ (file-regular? (file-url-pathname url)))
+
(define (pathname->url-body pathname)
(string-append (let ((device (pathname-device pathname)))
(if (string? device)
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-imap.scm,v 1.148 2001/05/07 18:01:05 cph Exp $
+;;; $Id: imail-imap.scm,v 1.149 2001/05/09 17:38:33 cph Exp $
;;;
;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
;;;
(= (imap-url-port url1) (imap-url-port url2))))
\f
(define-method url-exists? ((url <imap-url>))
+ (and (imap-url-info url) #t))
+
+(define-method url-selectable? ((url <imap-url>))
+ (let ((response (imap-url-info url)))
+ (and response
+ (not (memq '\NOSELECT (imap:response:list-flags response))))))
+
+(define (imap-url-info url)
(let ((responses
(with-open-imap-connection url
(lambda (connection)
(imap-url-server-mailbox url))))))
(and (pair? responses)
(null? (cdr responses))
- (not (memq '\NOSELECT (imap:response:list-flags (car responses)))))))
+ (car responses))))
(define-method url-pass-phrase-key ((url <imap-url>))
(make-url-string (url-protocol url) (make-imap-url-string url #f)))