process))
(defun nnimap-open-connection (buffer)
- (with-current-buffer (nnimap-buffer)
+ (with-current-buffer (nnimap-make-process-buffer buffer)
(let* ((coding-system-for-read 'binary)
(coding-system-for-write 'binary)
(credentials
(if (netrc-find-service-number "imap")
"imap"
"143")))
- (netrc-credentials nnimap-address "imap"))
+ (auth-source-user-or-password
+ '("login" "password") nnimap-address "imap" nil t))
((eq nnimap-stream 'stream)
(nnimap-open-shell-stream
"*nnimap*" (current-buffer) nnimap-address
(or nnimap-server-port "imap"))
- (netrc-credentials nnimap-address "imap"))
+ (auth-source-user-or-password
+ '("login" "password") nnimap-address "imap" nil t))
((eq nnimap-stream 'ssl)
(open-tls-stream "*nnimap*" (current-buffer) nnimap-address
(or nnimap-server-port
(if (netrc-find-service-number "imaps")
"imaps"
"993")))
- (netrc-credentials nnimap-address "imaps" "imap")))))
+ (or
+ (auth-source-user-or-password
+ '("login" "password") nnimap-address "imap")
+ (auth-source-user-or-password
+ '("login" "password") nnimap-address "imaps" nil t))))))
(setf (nnimap-process nnimap-object)
(get-buffer-process (current-buffer)))
(unless credentials
- (delete-process (nnimap-process nnimap-object))
- (error "Can't find user name/password for %s" nnimap-address))
+ (delete-process (nnimap-process nnimap-object)))
(when (and (nnimap-process nnimap-object)
(memq (process-status (nnimap-process nnimap-object))
'(open run)))
(gnus-set-process-query-on-exit-flag (nnimap-process nnimap-object) nil)
(let ((result (nnimap-command "LOGIN %S %S"
(car credentials) (cadr credentials))))
- (unless (car result)
- (delete-process (nnimap-process nnimap-object))
- (error "Unable to login to the server: %s"
- (mapconcat #'identity (cadr result) " ")))
- (setf (nnimap-capabilities nnimap-object)
- (mapcar
- #'upcase
- (or (nnimap-find-parameter "CAPABILITY" (cdr result))
- (nnimap-find-parameter
- "CAPABILITY" (cdr (nnimap-command "CAPABILITY"))))))
- (when (member "QRESYNC" (nnimap-capabilities nnimap-object))
- (nnimap-command "ENABLE QRESYNC"))
- t)))))
+ (if (not (car result))
+ (progn
+ (delete-process (nnimap-process nnimap-object))
+ nil)
+ (setf (nnimap-capabilities nnimap-object)
+ (mapcar
+ #'upcase
+ (or (nnimap-find-parameter "CAPABILITY" (cdr result))
+ (nnimap-find-parameter
+ "CAPABILITY" (cdr (nnimap-command "CAPABILITY"))))))
+ (when (member "QRESYNC" (nnimap-capabilities nnimap-object))
+ (nnimap-command "ENABLE QRESYNC"))
+ t))))))
(defun nnimap-find-parameter (parameter elems)
(let (result)
sequences))))
(defun nnimap-finish-retrieve-group-infos (server infos sequences)
- (when (nnimap-possibly-change-group nil server)
+ (when (and sequences
+ (nnimap-possibly-change-group nil server))
(with-current-buffer (nnimap-buffer)
;; Wait for the final data to trickle in.
(nnimap-wait-for-response (cadar sequences))
nil)
(defun nnimap-possibly-change-group (group server)
- (when (and server
- (not (nnimap-server-opened server)))
- (nnimap-open-server server))
- (if (not group)
- t
- (with-current-buffer (nnimap-buffer)
- (if (equal group (nnimap-group nnimap-object))
- t
- (let ((result (nnimap-command "SELECT %S" (utf7-encode group t))))
- (when (car result)
- (setf (nnimap-group nnimap-object) group)
- result))))))
+ (let ((open-result t))
+ (when (and server
+ (not (nnimap-server-opened server)))
+ (setq open-result (nnimap-open-server server)))
+ (cond
+ ((not open-result)
+ nil)
+ ((not group)
+ t)
+ (t
+ (with-current-buffer (nnimap-buffer)
+ (if (equal group (nnimap-group nnimap-object))
+ t
+ (let ((result (nnimap-command "SELECT %S" (utf7-encode group t))))
+ (when (car result)
+ (setf (nnimap-group nnimap-object) group)
+ result))))))))
(defun nnimap-find-connection (buffer)
"Find the connection delivering to BUFFER."