diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 70aa573..89fcff2 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -54,10 +54,17 @@ If nnimap-stream is `ssl', this will default to `imaps'. If not, it will default to `imap'.") -(defvoo nnimap-stream 'ssl +(defvoo nnimap-stream '((ssl . "") + (network . "") + (shell . (if (boundp 'imap-shell-program) + (if (listp imap-shell-program) + (car imap-shell-program) + imap-shell-program) + "ssh %s imapd"))) "How nnimap will talk to the IMAP server. Values are `ssl', `network', `starttls' or `shell'.") +;; FIXME: remove this in favor of nnimap-stream parameters (defvoo nnimap-shell-program (if (boundp 'imap-shell-program) (if (listp imap-shell-program) (car imap-shell-program) @@ -245,12 +252,12 @@ textual parts.") (push (current-buffer) nnimap-process-buffers) (current-buffer))) -(defun nnimap-open-shell-stream (name buffer host port) +(defun nnimap-open-shell-stream (name buffer host port program) (let ((process-connection-type nil)) (start-process name buffer shell-file-name shell-command-switch (format-spec - nnimap-shell-program + program (format-spec-make ?s host ?p port))))) @@ -293,9 +300,13 @@ textual parts.") (let* ((coding-system-for-read 'binary) (coding-system-for-write 'binary) (port nil) + ;; FIXME: this should cycle through the streams and if one fails, offer to customize them + (stream-struct (or (car-safe nnimap-stream) '(starttls . ""))) + (stream (car stream-struct)) + (stream-helper (cdr stream-struct)) (ports (cond - ((eq nnimap-stream 'network) + ((eq stream 'network) (open-network-stream "*nnimap*" (current-buffer) nnimap-address (setq port @@ -304,19 +315,20 @@ textual parts.") "imap" "143")))) '("143" "imap")) - ((eq nnimap-stream 'shell) + ((eq stream 'shell) (nnimap-open-shell-stream "*nnimap*" (current-buffer) nnimap-address - (setq port (or nnimap-server-port "imap"))) + (setq port (or nnimap-server-port "imap")) + stream-helper) '("imap")) - ((eq nnimap-stream 'starttls) + ((eq stream 'starttls) (let ((tls-program (nnimap-extend-tls-programs))) (open-tls-stream "*nnimap*" (current-buffer) nnimap-address (setq port (or nnimap-server-port "imap")) 'starttls)) '("imap")) - ((eq nnimap-stream 'ssl) + ((eq stream 'ssl) (open-tls-stream "*nnimap*" (current-buffer) nnimap-address (setq port @@ -332,7 +344,7 @@ textual parts.") (memq (process-status (nnimap-process nnimap-object)) '(open run)))) (nnheader-report 'nnimap "Unable to contact %s:%s via %s" - nnimap-address port nnimap-stream) + nnimap-address port stream) (gnus-set-process-query-on-exit-flag (nnimap-process nnimap-object) nil) (if (not (setq connection-result (nnimap-wait-for-connection))) (nnheader-report 'nnimap @@ -352,9 +364,9 @@ textual parts.") (push (format "%s" nnimap-server-port) ports)) ;; If this is a STARTTLS-capable server, then sever the ;; connection and start a STARTTLS connection instead. - (when (and (eq nnimap-stream 'network) + (when (and (eq stream 'network) (member "STARTTLS" (nnimap-capabilities nnimap-object))) - (let ((nnimap-stream 'starttls)) + (let ((nnimap-stream '(starttls))) ; FIXME, should be handled with the right nnimap-stream to begin with (let ((tls-process (nnimap-open-connection buffer))) ;; If the STARTTLS connection was successful, we