Get credentials for numerical equivalents of the port numbers.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 18 Sep 2010 15:54:20 +0000 (17:54 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 18 Sep 2010 15:54:20 +0000 (17:54 +0200)
* nnimap.el (nnimap-credentials): New function.
(nnimap-open-connection): Use the new function to look for credentials
also on the numeric equivalents of "imap" and "imaps".

lisp/ChangeLog
lisp/nnimap.el

index fce0692..ca54c8d 100644 (file)
@@ -1,5 +1,9 @@
 2010-09-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 2010-09-18  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nnimap.el (nnimap-credentials): New function.
+       (nnimap-open-connection): Use the new function to look for credentials
+       also on the numeric equivalents of "imap" and "imaps".
+
        * gnus-start.el (gnus-activate-group): Send the info to
        gnus-request-group.
 
        * gnus-start.el (gnus-activate-group): Send the info to
        gnus-request-group.
 
index d595192..4c3eaac 100644 (file)
@@ -202,6 +202,17 @@ not done by default on servers that doesn't support that command.")
                                  ?p port)))))
     process))
 
                                  ?p port)))))
     process))
 
+(defun nnimap-credentials (address &rest ports)
+  (let (port credentials)
+    ;; Request the credentials from all ports, but only query on the
+    ;; last port if all the previous ones have failed.
+    (while (and (null credentials)
+               (setq port (pop ports)))
+      (setq credentials
+           (auth-source-user-or-password
+            '("login" "password") address port nil (null ports))))
+    credentials))
+
 (defun nnimap-open-connection (buffer)
   (with-current-buffer (nnimap-make-process-buffer buffer)
     (let* ((coding-system-for-read 'binary)
 (defun nnimap-open-connection (buffer)
   (with-current-buffer (nnimap-make-process-buffer buffer)
     (let* ((coding-system-for-read 'binary)
@@ -214,25 +225,19 @@ not done by default on servers that doesn't support that command.")
                                       (if (netrc-find-service-number "imap")
                                           "imap"
                                         "143")))
                                       (if (netrc-find-service-number "imap")
                                           "imap"
                                         "143")))
-             (auth-source-user-or-password
-              '("login" "password") nnimap-address "imap" nil t))
+             (nnimap-credentials nnimap-address "143" "imap"))
             ((eq nnimap-stream 'stream)
              (nnimap-open-shell-stream
               "*nnimap*" (current-buffer) nnimap-address
               (or nnimap-server-port "imap"))
             ((eq nnimap-stream 'stream)
              (nnimap-open-shell-stream
               "*nnimap*" (current-buffer) nnimap-address
               (or nnimap-server-port "imap"))
-             (auth-source-user-or-password
-              '("login" "password") nnimap-address "imap" nil t))
+             (nnimap-credentials nnimap-address "imap"))
             ((eq nnimap-stream 'ssl)
              (open-tls-stream "*nnimap*" (current-buffer) nnimap-address
                               (or nnimap-server-port
                                   (if (netrc-find-service-number "imaps")
                                       "imaps"
                                     "993")))
             ((eq nnimap-stream 'ssl)
              (open-tls-stream "*nnimap*" (current-buffer) nnimap-address
                               (or nnimap-server-port
                                   (if (netrc-find-service-number "imaps")
                                       "imaps"
                                     "993")))
-             (or
-              (auth-source-user-or-password
-               '("login" "password") nnimap-address "imap")
-              (auth-source-user-or-password
-               '("login" "password") nnimap-address "imaps" nil t))))))
+             (nnimap-credentials nnimap-address "143" "993" "imap" "imaps")))))
       (setf (nnimap-process nnimap-object)
            (get-buffer-process (current-buffer)))
       (unless credentials
       (setf (nnimap-process nnimap-object)
            (get-buffer-process (current-buffer)))
       (unless credentials