summaryrefslogtreecommitdiff
path: root/lisp/gnus/nnimap.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/gnus/nnimap.el')
-rw-r--r--lisp/gnus/nnimap.el59
1 files changed, 43 insertions, 16 deletions
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index f4f4ef89a9e..8a48cd87dba 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -95,7 +95,7 @@ Uses the same syntax as `nnmail-split-methods'.")
"Articles with the flags in the list will not be considered when splitting.")
(make-obsolete-variable 'nnimap-split-rule "see `nnimap-split-methods'."
- "Emacs 24.1")
+ "24.1")
(defvoo nnimap-authenticator nil
"How nnimap authenticate itself to the server.
@@ -136,6 +136,16 @@ will fetch all parts that have types that match that string. A
likely value would be \"text/\" to automatically fetch all
textual parts.")
+(defvoo nnimap-keepalive-intervals (cons (* 60 15)
+ (* 60 5))
+ "Configuration for the nnimap keepalive timer.
+The value is a cons of two integers (each representing a number
+of seconds): the first is how often to run the keepalive
+function, the second is the seconds of inactivity required to
+send the actual keepalive command.
+
+Set to nil to disable keepalive commands altogether.")
+
(defgroup nnimap nil
"IMAP for Gnus."
:group 'gnus)
@@ -405,20 +415,22 @@ during splitting, which may be slow."
nil)))
(defun nnimap-keepalive ()
- (let ((now (current-time)))
+ (let ((now (current-time))
+ ;; Set this so we don't wait for a response.
+ (nnimap-streaming t))
(dolist (buffer nnimap-process-buffers)
(when (buffer-live-p buffer)
(with-current-buffer buffer
(when (and nnimap-object
(nnimap-last-command-time nnimap-object)
(time-less-p
- ;; More than five minutes since the last command.
- (* 5 60)
+ (cdr nnimap-keepalive-intervals)
(time-subtract
now
(nnimap-last-command-time nnimap-object))))
- (ignore-errors ;E.g. "buffer foo has no process".
- (nnimap-send-command "NOOP"))))))))
+ (with-local-quit
+ (ignore-errors ;E.g. "buffer foo has no process".
+ (nnimap-send-command "NOOP")))))))))
(defun nnimap-open-connection (buffer)
;; Be backwards-compatible -- the earlier value of nnimap-stream was
@@ -440,6 +452,7 @@ during splitting, which may be slow."
;; This is only needed for Windows XP or earlier
(defun nnimap-map-port (port)
+ (declare-function x-server-version "xfns.c" (&optional terminal))
(if (and (eq system-type 'windows-nt)
(<= (car (x-server-version)) 5)
(equal port "imaps"))
@@ -447,9 +460,12 @@ during splitting, which may be slow."
port))
(defun nnimap-open-connection-1 (buffer)
- (unless nnimap-keepalive-timer
- (setq nnimap-keepalive-timer (run-at-time (* 60 15) (* 60 15)
- #'nnimap-keepalive)))
+ (unless (or nnimap-keepalive-timer
+ (null nnimap-keepalive-intervals))
+ (setq nnimap-keepalive-timer (run-at-time
+ (car nnimap-keepalive-intervals)
+ (car nnimap-keepalive-intervals)
+ #'nnimap-keepalive)))
(with-current-buffer (nnimap-make-process-buffer buffer)
(let* ((coding-system-for-read 'binary)
(coding-system-for-write 'binary)
@@ -583,6 +599,13 @@ during splitting, which may be slow."
(eq nnimap-authenticator 'anonymous)
(eq nnimap-authenticator 'login)))
(nnimap-command "LOGIN %S %S" user password))
+ ((and (nnimap-capability "AUTH=XOAUTH2")
+ (eq nnimap-authenticator 'xoauth2))
+ (nnimap-command "AUTHENTICATE XOAUTH2 %s"
+ (base64-encode-string
+ (format "user=%s\001auth=Bearer %s\001\001"
+ (nnimap-quote-specials user)
+ (nnimap-quote-specials password)))))
((and (nnimap-capability "AUTH=CRAM-MD5")
(or (null nnimap-authenticator)
(eq nnimap-authenticator 'cram-md5)))
@@ -1061,7 +1084,9 @@ during splitting, which may be slow."
"UID COPY %s %S")
(nnimap-article-ranges (gnus-compress-sequence articles))
(nnimap-group-to-imap (gnus-group-real-name nnmail-expiry-target)))
- (set (if can-move 'deleted-articles 'articles-to-delete) articles))))
+ (if can-move
+ (setq deleted-articles articles)
+ (setq articles-to-delete articles)))))
t)
(t
(dolist (article articles)
@@ -1274,7 +1299,7 @@ If LIMIT, first try to limit the search to the N last articles."
(when (and (nnimap-greeting nnimap-object)
(string-match greeting-match (nnimap-greeting nnimap-object))
(eq type 'append)
- (string-match "\000" data))
+ (string-search "\000" data))
(let ((choice (gnus-multiple-choice
"Message contains NUL characters. Delete, continue, abort? "
'((?d "Delete NUL characters")
@@ -1613,13 +1638,15 @@ If LIMIT, first try to limit the search to the N last articles."
(setq start-article 1))
(let* ((unread
(gnus-compress-sequence
- (gnus-set-difference
- (gnus-set-difference
+ (seq-difference
+ (seq-difference
existing
(gnus-sorted-union
(cdr (assoc '%Seen flags))
- (cdr (assoc '%Deleted flags))))
- (cdr (assoc '%Flagged flags)))))
+ (cdr (assoc '%Deleted flags)))
+ #'eq)
+ (cdr (assoc '%Flagged flags))
+ #'eq)))
(read (gnus-range-difference
(cons start-article high) unread)))
(when (> start-article 1)
@@ -1734,7 +1761,7 @@ If LIMIT, first try to limit the search to the N last articles."
(let ((result nil))
(dolist (elem (split-string irange ","))
(push
- (if (string-match ":" elem)
+ (if (string-search ":" elem)
(let ((numbers (split-string elem ":")))
(cons (string-to-number (car numbers))
(string-to-number (cadr numbers))))