diff options
| author | Katsumi Yamaoka | 2009-09-28 12:09:13 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2009-09-28 12:09:13 +0000 |
| commit | ffa894dbde4c72055a21b18501c0c3e1e6c13ae1 (patch) | |
| tree | a640daf1abb4ad34e86f41776595006448b1595f | |
| parent | 54c72c310894099a143af23937997d60ec58ebbe (diff) | |
| download | emacs-ffa894dbde4c72055a21b18501c0c3e1e6c13ae1.tar.gz emacs-ffa894dbde4c72055a21b18501c0c3e1e6c13ae1.zip | |
Synch with Gnus trunk.
2009-09-10 Teodor Zlatanov <tzz@lifelogs.com>
* net/imap.el (imap-interactive-login): Better messages.
(imap-open): Fix bug with renamed buffer on reconnect.
(imap-authenticate): Add buffer-local imap-last-authenticator variable
for easier debugging and cleaner code. On successful (guessed based on
server capabilities) secondary authentication, set imap-state
correctly.
(imap-last-authenticator): Define imap-last-authenticator as a variable
to avoid warnings.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/net/imap.el | 35 |
2 files changed, 35 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 777ebae3da8..bea9900d56d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1108,6 +1108,17 @@ | |||
| 1108 | * loadup.el (define-key-rebound-commands): Don't bother fiddling with | 1108 | * loadup.el (define-key-rebound-commands): Don't bother fiddling with |
| 1109 | define-key-rebound-commands and precompute-menubar-bindings. | 1109 | define-key-rebound-commands and precompute-menubar-bindings. |
| 1110 | 1110 | ||
| 1111 | 2009-09-10 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 1112 | |||
| 1113 | * net/imap.el (imap-interactive-login): Better messages. | ||
| 1114 | (imap-open): Fix bug with renamed buffer on reconnect. | ||
| 1115 | (imap-authenticate): Add buffer-local imap-last-authenticator variable | ||
| 1116 | for easier debugging and cleaner code. On successful (guessed based on | ||
| 1117 | server capabilities) secondary authentication, set imap-state | ||
| 1118 | correctly. | ||
| 1119 | (imap-last-authenticator): Define imap-last-authenticator as a variable | ||
| 1120 | to avoid warnings. | ||
| 1121 | |||
| 1111 | 2009-09-10 Glenn Morris <rgm@gnu.org> | 1122 | 2009-09-10 Glenn Morris <rgm@gnu.org> |
| 1112 | 1123 | ||
| 1113 | * pcvs.el (cvs-mode-find-file): Use forward-line rather than goto-line. | 1124 | * pcvs.el (cvs-mode-find-file): Use forward-line rather than goto-line. |
diff --git a/lisp/net/imap.el b/lisp/net/imap.el index 6393e8a5c90..ea1c8870bac 100644 --- a/lisp/net/imap.el +++ b/lisp/net/imap.el | |||
| @@ -380,6 +380,7 @@ basis.") | |||
| 380 | (defvar imap-port nil) | 380 | (defvar imap-port nil) |
| 381 | (defvar imap-username nil) | 381 | (defvar imap-username nil) |
| 382 | (defvar imap-password nil) | 382 | (defvar imap-password nil) |
| 383 | (defvar imap-last-authenticator nil) | ||
| 383 | (defvar imap-calculate-literal-size-first nil) | 384 | (defvar imap-calculate-literal-size-first nil) |
| 384 | (defvar imap-state 'closed | 385 | (defvar imap-state 'closed |
| 385 | "IMAP state. | 386 | "IMAP state. |
| @@ -872,25 +873,26 @@ Returns t if login was successful, nil otherwise." | |||
| 872 | (while (or (not user) (not passwd)) | 873 | (while (or (not user) (not passwd)) |
| 873 | (setq user (or imap-username | 874 | (setq user (or imap-username |
| 874 | (read-from-minibuffer | 875 | (read-from-minibuffer |
| 875 | (concat "IMAP username for " imap-server | 876 | (concat "imap: username for " imap-server |
| 876 | " (using stream `" (symbol-name imap-stream) | 877 | " (using stream `" (symbol-name imap-stream) |
| 877 | "'): ") | 878 | "'): ") |
| 878 | (or user imap-default-user)))) | 879 | (or user imap-default-user)))) |
| 879 | (setq passwd (or imap-password | 880 | (setq passwd (or imap-password |
| 880 | (read-passwd | 881 | (read-passwd |
| 881 | (concat "IMAP password for " user "@" | 882 | (concat "imap: password for " user "@" |
| 882 | imap-server " (using authenticator `" | 883 | imap-server " (using authenticator `" |
| 883 | (symbol-name imap-auth) "'): ")))) | 884 | (symbol-name imap-auth) "'): ")))) |
| 884 | (when (and user passwd) | 885 | (when (and user passwd) |
| 885 | (if (funcall loginfunc user passwd) | 886 | (if (funcall loginfunc user passwd) |
| 886 | (progn | 887 | (progn |
| 888 | (message "imap: Login successful...") | ||
| 887 | (setq ret t | 889 | (setq ret t |
| 888 | imap-username user) | 890 | imap-username user) |
| 889 | (when (and (not imap-password) | 891 | (when (and (not imap-password) |
| 890 | (or imap-store-password | 892 | (or imap-store-password |
| 891 | (y-or-n-p "Store password for this session? "))) | 893 | (y-or-n-p "imap: Store password for this IMAP session? "))) |
| 892 | (setq imap-password passwd))) | 894 | (setq imap-password passwd))) |
| 893 | (message "Login failed...") | 895 | (message "imap: Login failed...") |
| 894 | (setq passwd nil) | 896 | (setq passwd nil) |
| 895 | (setq imap-password nil) | 897 | (setq imap-password nil) |
| 896 | (sit-for 1)))) | 898 | (sit-for 1)))) |
| @@ -1160,7 +1162,10 @@ necessary. If nil, the buffer name is generated." | |||
| 1160 | buffer | 1162 | buffer |
| 1161 | (buffer-name buffer)))) | 1163 | (buffer-name buffer)))) |
| 1162 | (kill-buffer buffer) | 1164 | (kill-buffer buffer) |
| 1163 | (rename-buffer name)) | 1165 | (rename-buffer name) |
| 1166 | ;; set the passed buffer to the current one, | ||
| 1167 | ;; so that (imap-opened buffer) later will work | ||
| 1168 | (setq buffer (current-buffer))) | ||
| 1164 | (message "imap: Reconnecting with stream `%s'...done" | 1169 | (message "imap: Reconnecting with stream `%s'...done" |
| 1165 | stream) | 1170 | stream) |
| 1166 | (setq imap-stream stream) | 1171 | (setq imap-stream stream) |
| @@ -1173,6 +1178,7 @@ necessary. If nil, the buffer name is generated." | |||
| 1173 | (setq streams nil)))))) | 1178 | (setq streams nil)))))) |
| 1174 | (when (imap-opened buffer) | 1179 | (when (imap-opened buffer) |
| 1175 | (setq imap-mailbox-data (make-vector imap-mailbox-prime 0))) | 1180 | (setq imap-mailbox-data (make-vector imap-mailbox-prime 0))) |
| 1181 | ;; (debug "opened+state+auth+buffer" (imap-opened buffer) imap-state imap-auth buffer) | ||
| 1176 | (when imap-stream | 1182 | (when imap-stream |
| 1177 | buffer)))) | 1183 | buffer)))) |
| 1178 | 1184 | ||
| @@ -1217,25 +1223,32 @@ password is remembered in the buffer." | |||
| 1217 | (eq imap-state 'examine)) | 1223 | (eq imap-state 'examine)) |
| 1218 | (make-local-variable 'imap-username) | 1224 | (make-local-variable 'imap-username) |
| 1219 | (make-local-variable 'imap-password) | 1225 | (make-local-variable 'imap-password) |
| 1220 | (if user (setq imap-username user)) | 1226 | (make-local-variable 'imap-last-authenticator) |
| 1221 | (if passwd (setq imap-password passwd)) | 1227 | (when user (setq imap-username user)) |
| 1228 | (when passwd (setq imap-password passwd)) | ||
| 1222 | (if imap-auth | 1229 | (if imap-auth |
| 1223 | (and (funcall (nth 2 (assq imap-auth | 1230 | (and (setq imap-last-authenticator |
| 1224 | imap-authenticator-alist)) (current-buffer)) | 1231 | (assq imap-auth imap-authenticator-alist)) |
| 1232 | (funcall (nth 2 imap-last-authenticator) (current-buffer)) | ||
| 1225 | (setq imap-state 'auth)) | 1233 | (setq imap-state 'auth)) |
| 1226 | ;; Choose authenticator. | 1234 | ;; Choose authenticator. |
| 1227 | (let ((auths imap-authenticators) | 1235 | (let ((auths imap-authenticators) |
| 1228 | auth) | 1236 | auth) |
| 1229 | (while (setq auth (pop auths)) | 1237 | (while (setq auth (pop auths)) |
| 1230 | ;; OK to use authenticator? | 1238 | ;; OK to use authenticator? |
| 1231 | (when (funcall (nth 1 (assq auth imap-authenticator-alist)) (current-buffer)) | 1239 | (setq imap-last-authenticator |
| 1240 | (assq auth imap-authenticator-alist)) | ||
| 1241 | (when (funcall (nth 1 imap-last-authenticator) (current-buffer)) | ||
| 1232 | (message "imap: Authenticating to `%s' using `%s'..." | 1242 | (message "imap: Authenticating to `%s' using `%s'..." |
| 1233 | imap-server auth) | 1243 | imap-server auth) |
| 1234 | (setq imap-auth auth) | 1244 | (setq imap-auth auth) |
| 1235 | (if (funcall (nth 2 (assq auth imap-authenticator-alist)) (current-buffer)) | 1245 | (if (funcall (nth 2 imap-last-authenticator) (current-buffer)) |
| 1236 | (progn | 1246 | (progn |
| 1237 | (message "imap: Authenticating to `%s' using `%s'...done" | 1247 | (message "imap: Authenticating to `%s' using `%s'...done" |
| 1238 | imap-server auth) | 1248 | imap-server auth) |
| 1249 | ;; set imap-state correctly on successful auth attempt | ||
| 1250 | (setq imap-state 'auth) | ||
| 1251 | ;; stop iterating through the authenticator list | ||
| 1239 | (setq auths nil)) | 1252 | (setq auths nil)) |
| 1240 | (message "imap: Authenticating to `%s' using `%s'...failed" | 1253 | (message "imap: Authenticating to `%s' using `%s'...failed" |
| 1241 | imap-server auth))))) | 1254 | imap-server auth))))) |