Gnus development mailing list
 help / color / mirror / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: ding@gnus.org
Subject: Re: nnimap ports and protocols
Date: Fri, 01 Oct 2010 09:52:40 -0500	[thread overview]
Message-ID: <87wrq2x8w7.fsf@lifelogs.com> (raw)
In-Reply-To: <87k4m2yqnh.fsf@lifelogs.com>

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

On Fri, 01 Oct 2010 08:43:46 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> On Fri, 01 Oct 2010 11:00:13 +1000 Daniel Pittman <daniel@rimspace.net> wrote: 
DP> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>>> In the absence of user-specified ports and protocols, would it make sense
>>> just to try the likely ones?

DP> You wouldn't be the first person to do it, but watch out for firewalls that
DP> eat the SYN packet silently: having Gnus hang for a significant timeout on the
DP> first connection attempt would suck.  Doing that every time...

TZ> The nnimap stream parameter should be a list the user can customize,
TZ> attempted in order.  The default can be what Lars listed.

TZ> Then Gnus can ask the user if they want to customize the nnimap stream
TZ> parameter when a connection fails.

Attached is a patch that:

1) has FIXMEs all over

2) removes the dependency on nnimap-shell-program in favor of a more
structured nnimap-stream

3) makes nnimap-stream an alist of (stream . helper) where the helper is
currently only meaningful for the 'shell stream.  I plan to use it for
GnuTLS as well.

4) provides a default nnimap-stream that tries ssl, then network, then
shell

I'm sure this can be done better, but wanted to show how I thought
streams should work for nnimap.

Ted


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap-stream.patch --]
[-- Type: text/x-diff, Size: 3921 bytes --]

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

  reply	other threads:[~2010-10-01 14:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30 22:55 Lars Magne Ingebrigtsen
2010-10-01  1:00 ` Daniel Pittman
2010-10-01 13:43   ` Ted Zlatanov
2010-10-01 14:52     ` Ted Zlatanov [this message]
2010-10-01 15:19 ` Lars Magne Ingebrigtsen
2010-10-01 15:29   ` Frank Schmitt
2010-10-01 15:34     ` Lars Magne Ingebrigtsen
2010-10-01 15:46       ` Ted Zlatanov
2010-10-01 16:25         ` Lars Magne Ingebrigtsen
2010-10-01 16:45           ` Ted Zlatanov
2010-10-01 18:29             ` Lars Magne Ingebrigtsen
2010-10-01 18:41               ` Ted Zlatanov
2010-10-01 18:47                 ` Lars Magne Ingebrigtsen
2010-10-01 19:05                   ` Ted Zlatanov
2010-10-01 19:17                     ` Lars Magne Ingebrigtsen
2010-10-01 19:44                       ` Ted Zlatanov
2010-10-01 18:18           ` Sivaram Neelakantan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wrq2x8w7.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).