2010-09-18 10:02:19 +00:00
|
|
|
;;; nnimap.el --- IMAP interface for Gnus
|
2005-08-06 19:51:42 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Copyright (C) 2010 Free Software Foundation, Inc.
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
|
|
;; Simon Josefsson <simon@josefsson.org>
|
2000-09-19 13:40:08 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:56:49 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2000-09-19 13:40:08 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:56:49 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2000-09-19 13:40:08 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-05-06 03:56:49 +00:00
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2000-09-19 13:40:08 +00:00
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 03:56:49 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2000-09-19 13:40:08 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
;; nnimap interfaces Gnus with IMAP servers.
|
2000-09-19 13:40:08 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2010-10-11 23:29:33 +00:00
|
|
|
;; For Emacs <22.2 and XEmacs.
|
|
|
|
(eval-and-compile
|
|
|
|
(unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
|
|
|
|
|
Stop message.el from loading about 40 libraries it doesn't always need.
The general approach is to autoload rather than require, and to
require in the specific functions rather than the file. (Bug#5642)
* url/url.el: Move mailcap require earlier in the file.
* gnus/gmm-utils.el: Don't require wid-edit.
(widget-create-child-value, widget-convert, widget-default-get):
Autoload.
* gnus/gnus-util.el: Don't require time-date, netrc.
(message-fetch-field, gnus-group-name-decode): Declare rather than
autoloading.
(gnus-fetch-field): Require message.
(gnus-decode-newsgroups): Require gnus-group.
* gnus/ietf-drums.el: Don't require time-date.
* gnus/message.el: Don't require hashcash, canlock, ecomplete.
Do require mail-utils. Require nnheader only when compiling.
(smtpmail-default-smtp-server): Remove declaration.
(message-send-mail-function): Check smtpmail-default-smtp-server
is bound rather than requiring smtpmail.
(message-auto-save-directory, message-insert-signature): Use
expand-file-name rather than nnheader-concat.
(nnheader-insert-file-contents): Autoload.
(hashcash-wait-async): Declare.
(message-send-mail): Only call gnus-setup-posting-charset if
gnus-group-posting-charset-alist is bound. Require hashcash if needed.
(message-send-mail-with-sendmail): Require sendmail.
(canlock-password, canlock-password-for-verify): Declare.
(message-canlock-password): Require canlock.
(nnheader-get-report): Autoload.
(gnus-setup-posting-charset): Declare.
(message-send-news): Require gnus-msg.
(message-make-references, message-make-in-reply-to): Use mail-header-id
rather than the alias mail-header-message-id.
(ecomplete-add-item, ecomplete-save): Declare.
(message-put-addresses-in-ecomplete): Require ecomplete.
(ecomplete-display-matches): Autoload.
* gnus/mm-decode.el: Don't require mailcap, gnus-util.
(gnus-map-function, gnus-replace-in-string, gnus-read-shell-command)
(message-fetch-field, mailcap-parse-mailcaps, mailcap-mime-info):
Autoload.
(mailcap-mime-extensions): Declare.
* gnus/mm-encode.el: Don't require mailcap.
(mailcap-extension-to-mime): Autoload.
* gnus/mml-sec.el: Don't require password-cache.
* gnus/mml.el (gnus-setup-posting-charset): Declare rather than autoload.
(mailcap-parse-mimetypes, mailcap-mime-types): Declare.
(mml-minibuffer-read-type): Require mailcap.
(mml-preview): Require gnus-msg.
* gnus/mml1991.el: Require password-cache.
(password-cache-expiry): Remove declaration.
* gnus/mml2015.el: Require password-cache.
(password-cache-expiry): Remove declaration.
* gnus/nneething.el (mailcap): Require mailcap.
* gnus/nnheader.el: (declare-function): Add compatibility stub.
(message-remove-header): Declare rather than autoload.
(nnheader-replace-header): Require message.
* gnus/nnimap.el (declare-function): Add compatibility stub.
(netrc-parse, netrc-machine-user-or-password): Declare.
(nnimap-open-connection): Require netrc.
* gnus/nntp.el (declare-function): Add compatibility stub.
(netrc-parse, netrc-machine, netrc-get): Declare.
(nntp-send-authinfo): Require netrc.
* gnus/rfc2047.el: Don't require qp.
(quoted-printable-encode-region, quoted-printable-decode-string):
Autoload.
* gnus/sieve-mode.el: Don't require easymenu.
(easy-menu-add-item): Autoload it.
* gnus/spam-stat.el (time-to-number-of-days): Autoload it.
* password-cache.el (password-cache, password-cache-expiry):
Autoload.
2010-03-19 02:55:37 +00:00
|
|
|
(eval-and-compile
|
2010-09-18 10:02:19 +00:00
|
|
|
(require 'nnheader))
|
Stop message.el from loading about 40 libraries it doesn't always need.
The general approach is to autoload rather than require, and to
require in the specific functions rather than the file. (Bug#5642)
* url/url.el: Move mailcap require earlier in the file.
* gnus/gmm-utils.el: Don't require wid-edit.
(widget-create-child-value, widget-convert, widget-default-get):
Autoload.
* gnus/gnus-util.el: Don't require time-date, netrc.
(message-fetch-field, gnus-group-name-decode): Declare rather than
autoloading.
(gnus-fetch-field): Require message.
(gnus-decode-newsgroups): Require gnus-group.
* gnus/ietf-drums.el: Don't require time-date.
* gnus/message.el: Don't require hashcash, canlock, ecomplete.
Do require mail-utils. Require nnheader only when compiling.
(smtpmail-default-smtp-server): Remove declaration.
(message-send-mail-function): Check smtpmail-default-smtp-server
is bound rather than requiring smtpmail.
(message-auto-save-directory, message-insert-signature): Use
expand-file-name rather than nnheader-concat.
(nnheader-insert-file-contents): Autoload.
(hashcash-wait-async): Declare.
(message-send-mail): Only call gnus-setup-posting-charset if
gnus-group-posting-charset-alist is bound. Require hashcash if needed.
(message-send-mail-with-sendmail): Require sendmail.
(canlock-password, canlock-password-for-verify): Declare.
(message-canlock-password): Require canlock.
(nnheader-get-report): Autoload.
(gnus-setup-posting-charset): Declare.
(message-send-news): Require gnus-msg.
(message-make-references, message-make-in-reply-to): Use mail-header-id
rather than the alias mail-header-message-id.
(ecomplete-add-item, ecomplete-save): Declare.
(message-put-addresses-in-ecomplete): Require ecomplete.
(ecomplete-display-matches): Autoload.
* gnus/mm-decode.el: Don't require mailcap, gnus-util.
(gnus-map-function, gnus-replace-in-string, gnus-read-shell-command)
(message-fetch-field, mailcap-parse-mailcaps, mailcap-mime-info):
Autoload.
(mailcap-mime-extensions): Declare.
* gnus/mm-encode.el: Don't require mailcap.
(mailcap-extension-to-mime): Autoload.
* gnus/mml-sec.el: Don't require password-cache.
* gnus/mml.el (gnus-setup-posting-charset): Declare rather than autoload.
(mailcap-parse-mimetypes, mailcap-mime-types): Declare.
(mml-minibuffer-read-type): Require mailcap.
(mml-preview): Require gnus-msg.
* gnus/mml1991.el: Require password-cache.
(password-cache-expiry): Remove declaration.
* gnus/mml2015.el: Require password-cache.
(password-cache-expiry): Remove declaration.
* gnus/nneething.el (mailcap): Require mailcap.
* gnus/nnheader.el: (declare-function): Add compatibility stub.
(message-remove-header): Declare rather than autoload.
(nnheader-replace-header): Require message.
* gnus/nnimap.el (declare-function): Add compatibility stub.
(netrc-parse, netrc-machine-user-or-password): Declare.
(nnimap-open-connection): Require netrc.
* gnus/nntp.el (declare-function): Add compatibility stub.
(netrc-parse, netrc-machine, netrc-get): Declare.
(nntp-send-authinfo): Require netrc.
* gnus/rfc2047.el: Don't require qp.
(quoted-printable-encode-region, quoted-printable-decode-string):
Autoload.
* gnus/sieve-mode.el: Don't require easymenu.
(easy-menu-add-item): Autoload it.
* gnus/spam-stat.el (time-to-number-of-days): Autoload it.
* password-cache.el (password-cache, password-cache-expiry):
Autoload.
2010-03-19 02:55:37 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(eval-when-compile
|
|
|
|
(require 'cl))
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-18 20:27:52 +00:00
|
|
|
(require 'nnheader)
|
|
|
|
(require 'gnus-util)
|
|
|
|
(require 'gnus)
|
|
|
|
(require 'nnoo)
|
2010-09-18 10:02:19 +00:00
|
|
|
(require 'netrc)
|
2010-09-27 13:22:21 +00:00
|
|
|
(require 'utf7)
|
2010-10-01 00:25:50 +00:00
|
|
|
(require 'tls)
|
2010-09-21 23:13:46 +00:00
|
|
|
(require 'parse-time)
|
2010-11-01 02:07:01 +00:00
|
|
|
(require 'nnmail)
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
(require 'gnus-sum))
|
2008-05-10 05:34:55 +00:00
|
|
|
|
2010-09-28 05:12:21 +00:00
|
|
|
(autoload 'auth-source-forget-user-or-password "auth-source")
|
|
|
|
(autoload 'auth-source-user-or-password "auth-source")
|
|
|
|
|
2000-09-19 13:40:08 +00:00
|
|
|
(nnoo-declare nnimap)
|
|
|
|
|
|
|
|
(defvoo nnimap-address nil
|
2010-09-18 10:02:19 +00:00
|
|
|
"The address of the IMAP server.")
|
2000-09-19 13:40:08 +00:00
|
|
|
|
|
|
|
(defvoo nnimap-server-port nil
|
2010-09-18 10:02:19 +00:00
|
|
|
"The IMAP port used.
|
|
|
|
If nnimap-stream is `ssl', this will default to `imaps'. If not,
|
|
|
|
it will default to `imap'.")
|
|
|
|
|
|
|
|
(defvoo nnimap-stream 'ssl
|
|
|
|
"How nnimap will talk to the IMAP server.
|
2010-09-23 23:14:02 +00:00
|
|
|
Values are `ssl', `network', `starttls' or `shell'.")
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defvoo nnimap-shell-program (if (boundp 'imap-shell-program)
|
|
|
|
(if (listp imap-shell-program)
|
|
|
|
(car imap-shell-program)
|
|
|
|
imap-shell-program)
|
|
|
|
"ssh %s imapd"))
|
|
|
|
|
|
|
|
(defvoo nnimap-inbox nil
|
|
|
|
"The mail box where incoming mail arrives and should be split out of.")
|
|
|
|
|
2010-09-26 04:03:19 +00:00
|
|
|
(defvoo nnimap-split-methods nil
|
|
|
|
"How mail is split.
|
|
|
|
Uses the same syntax as nnmail-split-methods")
|
|
|
|
|
2010-10-01 00:25:50 +00:00
|
|
|
(defvoo nnimap-split-fancy nil
|
|
|
|
"Uses the same syntax as nnmail-split-fancy.")
|
|
|
|
|
2010-10-30 05:59:34 +00:00
|
|
|
(defvoo nnimap-unsplittable-articles '(%Deleted %Seen)
|
|
|
|
"Articles with the flags in the list will not be considered when splitting.")
|
|
|
|
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(make-obsolete-variable 'nnimap-split-rule "see `nnimap-split-methods'"
|
2010-10-01 00:25:50 +00:00
|
|
|
"Emacs 24.1")
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
|
2010-09-20 00:36:54 +00:00
|
|
|
(defvoo nnimap-authenticator nil
|
|
|
|
"How nnimap authenticate itself to the server.
|
|
|
|
Possible choices are nil (use default methods) or `anonymous'.")
|
|
|
|
|
2010-09-23 00:30:37 +00:00
|
|
|
(defvoo nnimap-expunge t
|
|
|
|
"If non-nil, expunge articles after deleting them.
|
|
|
|
This is always done if the server supports UID EXPUNGE, but it's
|
|
|
|
not done by default on servers that doesn't support that command.")
|
|
|
|
|
2010-09-26 04:03:19 +00:00
|
|
|
(defvoo nnimap-streaming t
|
|
|
|
"If non-nil, try to use streaming commands with IMAP servers.
|
|
|
|
Switching this off will make nnimap slower, but it helps with
|
|
|
|
some servers.")
|
2010-09-21 23:13:46 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defvoo nnimap-connection-alist nil)
|
2010-09-18 23:36:29 +00:00
|
|
|
|
|
|
|
(defvoo nnimap-current-infos nil)
|
|
|
|
|
2010-09-27 23:07:47 +00:00
|
|
|
(defvoo nnimap-fetch-partial-articles nil
|
|
|
|
"If non-nil, Gnus will fetch partial articles.
|
|
|
|
If t, nnimap will fetch only the first part. If a string, it
|
|
|
|
will fetch all parts that have types that match that string. A
|
|
|
|
likely value would be \"text/\" to automatically fetch all
|
|
|
|
textual parts.")
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defvar nnimap-process nil)
|
|
|
|
|
|
|
|
(defvar nnimap-status-string "")
|
2004-09-04 13:13:48 +00:00
|
|
|
|
|
|
|
(defvar nnimap-split-download-body-default nil
|
|
|
|
"Internal variable with default value for `nnimap-split-download-body'.")
|
|
|
|
|
2010-09-24 22:33:34 +00:00
|
|
|
(defvar nnimap-keepalive-timer nil)
|
|
|
|
(defvar nnimap-process-buffers nil)
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defstruct nnimap
|
2010-09-24 22:33:34 +00:00
|
|
|
group process commands capabilities select-result newlinep server
|
2010-11-21 07:11:35 +00:00
|
|
|
last-command-time greeting examined)
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defvar nnimap-object nil)
|
|
|
|
|
|
|
|
(defvar nnimap-mark-alist
|
2010-09-23 00:30:37 +00:00
|
|
|
'((read "\\Seen" %Seen)
|
|
|
|
(tick "\\Flagged" %Flagged)
|
|
|
|
(reply "\\Answered" %Answered)
|
2010-09-18 10:02:19 +00:00
|
|
|
(expire "gnus-expire")
|
|
|
|
(dormant "gnus-dormant")
|
|
|
|
(score "gnus-score")
|
|
|
|
(save "gnus-save")
|
|
|
|
(download "gnus-download")
|
|
|
|
(forward "gnus-forward")))
|
|
|
|
|
|
|
|
(defun nnimap-buffer ()
|
|
|
|
(nnimap-find-process-buffer nntp-server-buffer))
|
|
|
|
|
2010-10-24 22:32:38 +00:00
|
|
|
(defun nnimap-header-parameters ()
|
|
|
|
(format "(UID RFC822.SIZE BODYSTRUCTURE %s)"
|
|
|
|
(format
|
|
|
|
(if (nnimap-ver4-p)
|
|
|
|
"BODY.PEEK[HEADER.FIELDS %s]"
|
|
|
|
"RFC822.HEADER.LINES %s")
|
|
|
|
(append '(Subject From Date Message-Id
|
|
|
|
References In-Reply-To Xref)
|
|
|
|
nnmail-extra-headers))))
|
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-retrieve-headers (articles &optional group server fetch-old)
|
2000-09-19 13:40:08 +00:00
|
|
|
(with-current-buffer nntp-server-buffer
|
2010-09-18 10:02:19 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(when (nnimap-possibly-change-group group server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(erase-buffer)
|
|
|
|
(nnimap-wait-for-response
|
|
|
|
(nnimap-send-command
|
|
|
|
"UID FETCH %s %s"
|
|
|
|
(nnimap-article-ranges (gnus-compress-sequence articles))
|
2010-10-24 22:32:38 +00:00
|
|
|
(nnimap-header-parameters))
|
2010-09-18 10:02:19 +00:00
|
|
|
t)
|
|
|
|
(nnimap-transform-headers))
|
|
|
|
(insert-buffer-substring
|
|
|
|
(nnimap-find-process-buffer (current-buffer))))
|
2010-09-23 23:14:02 +00:00
|
|
|
'headers))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-transform-headers ()
|
|
|
|
(goto-char (point-min))
|
2010-09-23 23:14:02 +00:00
|
|
|
(let (article bytes lines size string)
|
2010-09-18 10:02:19 +00:00
|
|
|
(block nil
|
|
|
|
(while (not (eobp))
|
|
|
|
(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
|
|
|
|
(delete-region (point) (progn (forward-line 1) (point)))
|
|
|
|
(when (eobp)
|
|
|
|
(return)))
|
2010-09-23 23:14:02 +00:00
|
|
|
(setq article (match-string 1))
|
2010-11-25 23:43:16 +00:00
|
|
|
;; Unfold quoted {number} strings.
|
|
|
|
(while (re-search-forward "[^]][ (]{\\([0-9]+\\)}\r?\n"
|
|
|
|
(1+ (line-end-position)) t)
|
|
|
|
(setq size (string-to-number (match-string 1)))
|
|
|
|
(delete-region (+ (match-beginning 0) 2) (point))
|
|
|
|
(setq string (buffer-substring (point) (+ (point) size)))
|
|
|
|
(delete-region (point) (+ (point) size))
|
|
|
|
(insert (format "%S" string)))
|
2010-09-23 23:14:02 +00:00
|
|
|
(setq bytes (nnimap-get-length)
|
2010-09-18 10:02:19 +00:00
|
|
|
lines nil)
|
|
|
|
(beginning-of-line)
|
2010-09-20 23:08:33 +00:00
|
|
|
(setq size
|
|
|
|
(and (re-search-forward "RFC822.SIZE \\([0-9]+\\)"
|
|
|
|
(line-end-position)
|
|
|
|
t)
|
|
|
|
(match-string 1)))
|
|
|
|
(beginning-of-line)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when (search-forward "BODYSTRUCTURE" (line-end-position) t)
|
2010-09-23 23:14:02 +00:00
|
|
|
(let ((structure (ignore-errors
|
|
|
|
(read (current-buffer)))))
|
2010-09-18 10:02:19 +00:00
|
|
|
(while (and (consp structure)
|
|
|
|
(not (stringp (car structure))))
|
|
|
|
(setq structure (car structure)))
|
|
|
|
(setq lines (nth 7 structure))))
|
|
|
|
(delete-region (line-beginning-position) (line-end-position))
|
|
|
|
(insert (format "211 %s Article retrieved." article))
|
|
|
|
(forward-line 1)
|
2010-09-20 23:08:33 +00:00
|
|
|
(when size
|
|
|
|
(insert (format "Chars: %s\n" size)))
|
2010-09-18 10:02:19 +00:00
|
|
|
(when lines
|
|
|
|
(insert (format "Lines: %s\n" lines)))
|
2010-10-24 22:32:38 +00:00
|
|
|
(unless (re-search-forward "^\r$" nil t)
|
|
|
|
(goto-char (point-max)))
|
2010-09-18 10:02:19 +00:00
|
|
|
(delete-region (line-beginning-position) (line-end-position))
|
|
|
|
(insert ".")
|
|
|
|
(forward-line 1)))))
|
|
|
|
|
2010-11-25 23:05:10 +00:00
|
|
|
(defun nnimap-unfold-quoted-lines ()
|
|
|
|
;; Unfold quoted {number} strings.
|
2010-11-25 23:43:16 +00:00
|
|
|
(let (size string)
|
|
|
|
(while (re-search-forward " {\\([0-9]+\\)}\r?\n" nil t)
|
|
|
|
(setq size (string-to-number (match-string 1)))
|
|
|
|
(delete-region (1+ (match-beginning 0)) (point))
|
|
|
|
(setq string (buffer-substring (point) (+ (point) size)))
|
|
|
|
(delete-region (point) (+ (point) size))
|
|
|
|
(insert (format "%S" string)))))
|
2010-11-25 23:05:10 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-get-length ()
|
|
|
|
(and (re-search-forward "{\\([0-9]+\\)}" (line-end-position) t)
|
|
|
|
(string-to-number (match-string 1))))
|
|
|
|
|
|
|
|
(defun nnimap-article-ranges (ranges)
|
|
|
|
(let (result)
|
|
|
|
(cond
|
|
|
|
((numberp ranges)
|
|
|
|
(number-to-string ranges))
|
|
|
|
((numberp (cdr ranges))
|
|
|
|
(format "%d:%d" (car ranges) (cdr ranges)))
|
|
|
|
(t
|
|
|
|
(dolist (elem ranges)
|
|
|
|
(push
|
|
|
|
(if (consp elem)
|
|
|
|
(format "%d:%d" (car elem) (cdr elem))
|
|
|
|
(number-to-string elem))
|
|
|
|
result))
|
|
|
|
(mapconcat #'identity (nreverse result) ",")))))
|
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-open-server (server &optional defs)
|
2000-09-19 13:40:08 +00:00
|
|
|
(if (nnimap-server-opened server)
|
|
|
|
t
|
|
|
|
(unless (assq 'nnimap-address defs)
|
2010-09-18 10:02:19 +00:00
|
|
|
(setq defs (append defs (list (list 'nnimap-address server)))))
|
2000-09-19 13:40:08 +00:00
|
|
|
(nnoo-change-server 'nnimap server defs)
|
2010-09-18 10:02:19 +00:00
|
|
|
(or (nnimap-find-connection nntp-server-buffer)
|
|
|
|
(nnimap-open-connection nntp-server-buffer))))
|
|
|
|
|
|
|
|
(defun nnimap-make-process-buffer (buffer)
|
|
|
|
(with-current-buffer
|
|
|
|
(generate-new-buffer (format "*nnimap %s %s %s*"
|
|
|
|
nnimap-address nnimap-server-port
|
|
|
|
(gnus-buffer-exists-p buffer)))
|
|
|
|
(mm-disable-multibyte)
|
|
|
|
(buffer-disable-undo)
|
|
|
|
(gnus-add-buffer)
|
|
|
|
(set (make-local-variable 'after-change-functions) nil)
|
2010-09-23 00:30:37 +00:00
|
|
|
(set (make-local-variable 'nnimap-object)
|
|
|
|
(make-nnimap :server (nnoo-current-server 'nnimap)))
|
2010-09-18 10:02:19 +00:00
|
|
|
(push (list buffer (current-buffer)) nnimap-connection-alist)
|
2010-09-24 22:33:34 +00:00
|
|
|
(push (current-buffer) nnimap-process-buffers)
|
2010-09-18 10:02:19 +00:00
|
|
|
(current-buffer)))
|
|
|
|
|
|
|
|
(defun nnimap-open-shell-stream (name buffer host port)
|
2010-09-19 10:45:51 +00:00
|
|
|
(let ((process-connection-type nil))
|
|
|
|
(start-process name buffer shell-file-name
|
|
|
|
shell-command-switch
|
|
|
|
(format-spec
|
|
|
|
nnimap-shell-program
|
|
|
|
(format-spec-make
|
|
|
|
?s host
|
|
|
|
?p port)))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
2010-09-26 14:35:50 +00:00
|
|
|
(defun nnimap-credentials (address ports &optional inhibit-create)
|
2010-09-18 23:36:29 +00:00
|
|
|
(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
|
2010-09-26 14:35:50 +00:00
|
|
|
'("login" "password") address port nil
|
|
|
|
(if inhibit-create
|
|
|
|
nil
|
|
|
|
(null ports)))))
|
2010-09-18 23:36:29 +00:00
|
|
|
credentials))
|
|
|
|
|
2010-09-24 22:33:34 +00:00
|
|
|
(defun nnimap-keepalive ()
|
|
|
|
(let ((now (current-time)))
|
|
|
|
(dolist (buffer nnimap-process-buffers)
|
|
|
|
(when (buffer-name buffer)
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(when (and nnimap-object
|
|
|
|
(nnimap-last-command-time nnimap-object)
|
2010-11-01 02:07:01 +00:00
|
|
|
(> (gnus-float-time
|
2010-09-24 22:33:34 +00:00
|
|
|
(time-subtract
|
|
|
|
now
|
|
|
|
(nnimap-last-command-time nnimap-object)))
|
|
|
|
;; More than five minutes since the last command.
|
|
|
|
(* 5 60)))
|
|
|
|
(nnimap-send-command "NOOP")))))))
|
|
|
|
|
2010-11-01 06:13:43 +00:00
|
|
|
(declare-function gnutls-negotiate "gnutls"
|
|
|
|
(proc type &optional priority-string trustfiles keyfiles))
|
2010-10-11 23:29:33 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-open-connection (buffer)
|
2010-09-24 22:33:34 +00:00
|
|
|
(unless nnimap-keepalive-timer
|
|
|
|
(setq nnimap-keepalive-timer (run-at-time (* 60 15) (* 60 15)
|
|
|
|
'nnimap-keepalive)))
|
2010-09-27 23:07:47 +00:00
|
|
|
(block nil
|
|
|
|
(with-current-buffer (nnimap-make-process-buffer buffer)
|
|
|
|
(let* ((coding-system-for-read 'binary)
|
|
|
|
(coding-system-for-write 'binary)
|
|
|
|
(port nil)
|
|
|
|
(ports
|
|
|
|
(cond
|
2010-10-10 22:48:40 +00:00
|
|
|
((or (eq nnimap-stream 'network)
|
|
|
|
(and (eq nnimap-stream 'starttls)
|
|
|
|
(fboundp 'open-gnutls-stream)))
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "Opening connection to %s..."
|
|
|
|
nnimap-address)
|
2010-09-27 23:07:47 +00:00
|
|
|
(open-network-stream
|
|
|
|
"*nnimap*" (current-buffer) nnimap-address
|
|
|
|
(setq port
|
|
|
|
(or nnimap-server-port
|
|
|
|
(if (netrc-find-service-number "imap")
|
|
|
|
"imap"
|
|
|
|
"143"))))
|
|
|
|
'("143" "imap"))
|
|
|
|
((eq nnimap-stream 'shell)
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "Opening connection to %s via shell..."
|
|
|
|
nnimap-address)
|
2010-09-27 23:07:47 +00:00
|
|
|
(nnimap-open-shell-stream
|
|
|
|
"*nnimap*" (current-buffer) nnimap-address
|
|
|
|
(setq port (or nnimap-server-port "imap")))
|
|
|
|
'("imap"))
|
|
|
|
((eq nnimap-stream 'starttls)
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "Opening connection to %s via starttls..."
|
2010-10-14 22:39:54 +00:00
|
|
|
nnimap-address)
|
2010-10-14 10:16:59 +00:00
|
|
|
(let ((tls-program
|
2010-10-14 22:39:54 +00:00
|
|
|
'("openssl s_client -connect %h:%p -no_ssl2 -ign_eof -starttls imap")))
|
2010-10-01 00:25:50 +00:00
|
|
|
(open-tls-stream
|
|
|
|
"*nnimap*" (current-buffer) nnimap-address
|
2010-10-13 22:21:20 +00:00
|
|
|
(setq port (or nnimap-server-port "imap"))))
|
2010-09-27 23:07:47 +00:00
|
|
|
'("imap"))
|
2010-10-04 22:26:51 +00:00
|
|
|
((memq nnimap-stream '(ssl tls))
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "Opening connection to %s via tls..."
|
|
|
|
nnimap-address)
|
2010-10-10 00:15:21 +00:00
|
|
|
(funcall (if (fboundp 'open-gnutls-stream)
|
2010-10-06 12:38:45 +00:00
|
|
|
'open-gnutls-stream
|
|
|
|
'open-tls-stream)
|
|
|
|
"*nnimap*" (current-buffer) nnimap-address
|
|
|
|
(setq port
|
|
|
|
(or nnimap-server-port
|
|
|
|
(if (netrc-find-service-number "imaps")
|
|
|
|
"imaps"
|
|
|
|
"993"))))
|
2010-10-04 22:26:51 +00:00
|
|
|
'("143" "993" "imap" "imaps"))
|
|
|
|
(t
|
|
|
|
(error "Unknown stream type: %s" nnimap-stream))))
|
2010-09-27 23:07:47 +00:00
|
|
|
connection-result login-result credentials)
|
|
|
|
(setf (nnimap-process nnimap-object)
|
|
|
|
(get-buffer-process (current-buffer)))
|
|
|
|
(if (not (and (nnimap-process nnimap-object)
|
|
|
|
(memq (process-status (nnimap-process nnimap-object))
|
|
|
|
'(open run))))
|
|
|
|
(nnheader-report 'nnimap "Unable to contact %s:%s via %s"
|
|
|
|
nnimap-address port nnimap-stream)
|
2010-10-10 00:15:21 +00:00
|
|
|
(gnus-set-process-query-on-exit-flag
|
|
|
|
(nnimap-process nnimap-object) nil)
|
2010-09-27 23:07:47 +00:00
|
|
|
(if (not (setq connection-result (nnimap-wait-for-connection)))
|
|
|
|
(nnheader-report 'nnimap
|
|
|
|
"%s" (buffer-substring
|
|
|
|
(point) (line-end-position)))
|
|
|
|
;; Store the greeting (for debugging purposes).
|
|
|
|
(setf (nnimap-greeting nnimap-object)
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
(line-end-position)))
|
2010-11-21 22:46:16 +00:00
|
|
|
(nnimap-get-capabilities)
|
2010-09-27 23:07:47 +00:00
|
|
|
(when nnimap-server-port
|
|
|
|
(push (format "%s" nnimap-server-port) ports))
|
2010-10-01 00:25:50 +00:00
|
|
|
;; If this is a STARTTLS-capable server, then sever the
|
|
|
|
;; connection and start a STARTTLS connection instead.
|
2010-10-10 22:48:40 +00:00
|
|
|
(cond
|
|
|
|
((and (or (and (eq nnimap-stream 'network)
|
2010-10-31 22:31:24 +00:00
|
|
|
(nnimap-capability "STARTTLS"))
|
2010-10-10 22:48:40 +00:00
|
|
|
(eq nnimap-stream 'starttls))
|
|
|
|
(fboundp 'open-gnutls-stream))
|
|
|
|
(nnimap-command "STARTTLS")
|
2010-11-21 22:46:16 +00:00
|
|
|
(gnutls-negotiate (nnimap-process nnimap-object) nil)
|
|
|
|
;; Get the capabilities again -- they may have changed
|
|
|
|
;; after doing STARTTLS.
|
|
|
|
(nnimap-get-capabilities))
|
2010-10-10 22:48:40 +00:00
|
|
|
((and (eq nnimap-stream 'network)
|
2010-10-31 22:31:24 +00:00
|
|
|
(nnimap-capability "STARTTLS"))
|
2010-10-01 00:25:50 +00:00
|
|
|
(let ((nnimap-stream 'starttls))
|
|
|
|
(let ((tls-process
|
|
|
|
(nnimap-open-connection buffer)))
|
|
|
|
;; If the STARTTLS connection was successful, we
|
|
|
|
;; kill our first non-encrypted connection. If it
|
|
|
|
;; wasn't successful, we just use our unencrypted
|
|
|
|
;; connection.
|
|
|
|
(when (memq (process-status tls-process) '(open run))
|
|
|
|
(delete-process (nnimap-process nnimap-object))
|
|
|
|
(kill-buffer (current-buffer))
|
2010-10-10 22:48:40 +00:00
|
|
|
(return tls-process))))))
|
2010-09-27 23:07:47 +00:00
|
|
|
(unless (equal connection-result "PREAUTH")
|
|
|
|
(if (not (setq credentials
|
|
|
|
(if (eq nnimap-authenticator 'anonymous)
|
|
|
|
(list "anonymous"
|
|
|
|
(message-make-address))
|
|
|
|
(or
|
|
|
|
;; First look for the credentials based
|
|
|
|
;; on the virtual server name.
|
|
|
|
(nnimap-credentials
|
|
|
|
(nnoo-current-server 'nnimap) ports t)
|
|
|
|
;; Then look them up based on the
|
|
|
|
;; physical address.
|
|
|
|
(nnimap-credentials nnimap-address ports)))))
|
|
|
|
(setq nnimap-object nil)
|
2010-10-30 05:59:34 +00:00
|
|
|
(setq login-result
|
2010-10-31 22:31:24 +00:00
|
|
|
(if (and (nnimap-capability "AUTH=PLAIN")
|
|
|
|
(nnimap-capability "LOGINDISABLED"))
|
2010-10-30 05:59:34 +00:00
|
|
|
(nnimap-command
|
|
|
|
"AUTHENTICATE PLAIN %s"
|
|
|
|
(base64-encode-string
|
|
|
|
(format "\000%s\000%s"
|
|
|
|
(nnimap-quote-specials (car credentials))
|
|
|
|
(nnimap-quote-specials (cadr credentials)))))
|
|
|
|
(nnimap-command "LOGIN %S %S"
|
|
|
|
(car credentials)
|
|
|
|
(cadr credentials))))
|
2010-09-27 23:07:47 +00:00
|
|
|
(unless (car login-result)
|
|
|
|
;; If the login failed, then forget the credentials
|
|
|
|
;; that are now possibly cached.
|
|
|
|
(dolist (host (list (nnoo-current-server 'nnimap)
|
|
|
|
nnimap-address))
|
|
|
|
(dolist (port ports)
|
|
|
|
(dolist (element '("login" "password"))
|
|
|
|
(auth-source-forget-user-or-password
|
|
|
|
element host port))))
|
|
|
|
(delete-process (nnimap-process nnimap-object))
|
|
|
|
(setq nnimap-object nil))))
|
|
|
|
(when nnimap-object
|
2010-10-31 22:31:24 +00:00
|
|
|
(when (nnimap-capability "QRESYNC")
|
2010-09-27 23:07:47 +00:00
|
|
|
(nnimap-command "ENABLE QRESYNC"))
|
2010-10-01 00:25:50 +00:00
|
|
|
(nnimap-process nnimap-object))))))))
|
|
|
|
|
2010-11-21 22:46:16 +00:00
|
|
|
(defun nnimap-get-capabilities ()
|
|
|
|
(setf (nnimap-capabilities nnimap-object)
|
|
|
|
(mapcar
|
|
|
|
#'upcase
|
|
|
|
(nnimap-find-parameter
|
|
|
|
"CAPABILITY" (cdr (nnimap-command "CAPABILITY"))))))
|
|
|
|
|
2010-10-30 05:59:34 +00:00
|
|
|
(defun nnimap-quote-specials (string)
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert string)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "[\\\"]" nil t)
|
|
|
|
(forward-char -1)
|
|
|
|
(insert "\\")
|
|
|
|
(forward-char 1))
|
|
|
|
(buffer-string)))
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-find-parameter (parameter elems)
|
|
|
|
(let (result)
|
|
|
|
(dolist (elem elems)
|
|
|
|
(cond
|
|
|
|
((equal (car elem) parameter)
|
|
|
|
(setq result (cdr elem)))
|
|
|
|
((and (equal (car elem) "OK")
|
|
|
|
(consp (cadr elem))
|
|
|
|
(equal (caadr elem) parameter))
|
|
|
|
(setq result (cdr (cadr elem))))))
|
|
|
|
result))
|
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-close-server (&optional server)
|
2010-10-04 22:26:51 +00:00
|
|
|
(when (nnoo-change-server 'nnimap server nil)
|
|
|
|
(ignore-errors
|
|
|
|
(delete-process (get-buffer-process (nnimap-buffer))))
|
2010-10-13 23:12:47 +00:00
|
|
|
(nnoo-close-server 'nnimap server)
|
2010-10-04 22:26:51 +00:00
|
|
|
t))
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-request-close ()
|
2010-09-18 10:02:19 +00:00
|
|
|
t)
|
2004-09-04 13:13:48 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-server-opened (&optional server)
|
2010-09-18 10:02:19 +00:00
|
|
|
(and (nnoo-current-server-p 'nnimap server)
|
|
|
|
nntp-server-buffer
|
|
|
|
(gnus-buffer-live-p nntp-server-buffer)
|
|
|
|
(nnimap-find-connection nntp-server-buffer)))
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-status-message (&optional server)
|
2010-09-18 10:02:19 +00:00
|
|
|
nnimap-status-string)
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-request-article (article &optional group server to-buffer)
|
2000-09-19 13:40:08 +00:00
|
|
|
(with-current-buffer nntp-server-buffer
|
2010-09-20 00:36:54 +00:00
|
|
|
(let ((result (nnimap-possibly-change-group group server))
|
2010-09-26 04:03:19 +00:00
|
|
|
parts structure)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when (stringp article)
|
|
|
|
(setq article (nnimap-find-article-by-message-id group article)))
|
|
|
|
(when (and result
|
|
|
|
article)
|
|
|
|
(erase-buffer)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(erase-buffer)
|
2010-09-27 23:07:47 +00:00
|
|
|
(when nnimap-fetch-partial-articles
|
|
|
|
(nnimap-command "UID FETCH %d (BODYSTRUCTURE)" article)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(when (re-search-forward "FETCH.*BODYSTRUCTURE" nil t)
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(setq structure (ignore-errors
|
|
|
|
(let ((start (point)))
|
|
|
|
(forward-sexp 1)
|
|
|
|
(downcase-region start (point))
|
2010-10-20 10:34:58 +00:00
|
|
|
(goto-char start)
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(read (current-buffer))))
|
2010-09-27 23:07:47 +00:00
|
|
|
parts (nnimap-find-wanted-parts structure))))
|
2010-09-26 04:03:19 +00:00
|
|
|
(when (if parts
|
|
|
|
(nnimap-get-partial-article article parts structure)
|
|
|
|
(nnimap-get-whole-article article))
|
|
|
|
(let ((buffer (current-buffer)))
|
|
|
|
(with-current-buffer (or to-buffer nntp-server-buffer)
|
|
|
|
(erase-buffer)
|
|
|
|
(insert-buffer-substring buffer)
|
|
|
|
(nnheader-ms-strip-cr)
|
|
|
|
(cons group article)))))))))
|
|
|
|
|
2010-10-24 22:32:38 +00:00
|
|
|
(deffoo nnimap-request-head (article &optional group server to-buffer)
|
|
|
|
(when (nnimap-possibly-change-group group server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(when (stringp article)
|
|
|
|
(setq article (nnimap-find-article-by-message-id group article)))
|
|
|
|
(nnimap-get-whole-article
|
|
|
|
article (format "UID FETCH %%d %s"
|
|
|
|
(nnimap-header-parameters)))
|
|
|
|
(let ((buffer (current-buffer)))
|
|
|
|
(with-current-buffer (or to-buffer nntp-server-buffer)
|
|
|
|
(erase-buffer)
|
|
|
|
(insert-buffer-substring buffer)
|
|
|
|
(nnheader-ms-strip-cr)
|
|
|
|
(cons group article))))))
|
|
|
|
|
|
|
|
(defun nnimap-get-whole-article (article &optional command)
|
2010-09-26 04:03:19 +00:00
|
|
|
(let ((result
|
|
|
|
(nnimap-command
|
2010-10-24 22:32:38 +00:00
|
|
|
(or command
|
|
|
|
(if (nnimap-ver4-p)
|
|
|
|
"UID FETCH %d BODY.PEEK[]"
|
|
|
|
"UID FETCH %d RFC822.PEEK"))
|
2010-09-26 04:03:19 +00:00
|
|
|
article)))
|
|
|
|
;; Check that we really got an article.
|
|
|
|
(goto-char (point-min))
|
2010-09-26 23:01:31 +00:00
|
|
|
(unless (re-search-forward "\\* [0-9]+ FETCH" nil t)
|
2010-09-26 04:03:19 +00:00
|
|
|
(setq result nil))
|
|
|
|
(when result
|
2010-09-26 23:01:31 +00:00
|
|
|
;; Remove any data that may have arrived before the FETCH data.
|
|
|
|
(beginning-of-line)
|
|
|
|
(unless (bobp)
|
|
|
|
(delete-region (point-min) (point)))
|
2010-09-26 04:03:19 +00:00
|
|
|
(let ((bytes (nnimap-get-length)))
|
|
|
|
(delete-region (line-beginning-position)
|
|
|
|
(progn (forward-line 1) (point)))
|
|
|
|
(goto-char (+ (point) bytes))
|
|
|
|
(delete-region (point) (point-max)))
|
|
|
|
t)))
|
|
|
|
|
2010-10-31 22:31:24 +00:00
|
|
|
(defun nnimap-capability (capability)
|
|
|
|
(member capability (nnimap-capabilities nnimap-object)))
|
|
|
|
|
2010-09-26 04:03:19 +00:00
|
|
|
(defun nnimap-ver4-p ()
|
2010-10-31 22:31:24 +00:00
|
|
|
(nnimap-capability "IMAP4REV1"))
|
2010-09-26 04:03:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-get-partial-article (article parts structure)
|
|
|
|
(let ((result
|
|
|
|
(nnimap-command
|
|
|
|
"UID FETCH %d (%s %s)"
|
|
|
|
article
|
|
|
|
(if (nnimap-ver4-p)
|
|
|
|
"BODY.PEEK[HEADER]"
|
|
|
|
"RFC822.HEADER")
|
|
|
|
(if (nnimap-ver4-p)
|
|
|
|
(mapconcat (lambda (part)
|
|
|
|
(format "BODY.PEEK[%s]" part))
|
|
|
|
parts " ")
|
|
|
|
(mapconcat (lambda (part)
|
|
|
|
(format "RFC822.PEEK[%s]" part))
|
|
|
|
parts " ")))))
|
|
|
|
(when result
|
|
|
|
(nnimap-convert-partial-article structure))))
|
|
|
|
|
|
|
|
(defun nnimap-convert-partial-article (structure)
|
|
|
|
;; First just skip past the headers.
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let ((bytes (nnimap-get-length))
|
|
|
|
id parts)
|
|
|
|
;; Delete "FETCH" line.
|
|
|
|
(delete-region (line-beginning-position)
|
|
|
|
(progn (forward-line 1) (point)))
|
|
|
|
(goto-char (+ (point) bytes))
|
|
|
|
;; Collect all the body parts.
|
|
|
|
(while (looking-at ".*BODY\\[\\([.0-9]+\\)\\]")
|
|
|
|
(setq id (match-string 1)
|
|
|
|
bytes (nnimap-get-length))
|
|
|
|
(beginning-of-line)
|
|
|
|
(delete-region (point) (progn (forward-line 1) (point)))
|
|
|
|
(push (list id (buffer-substring (point) (+ (point) bytes)))
|
|
|
|
parts)
|
|
|
|
(delete-region (point) (+ (point) bytes)))
|
|
|
|
;; Delete trailing junk.
|
|
|
|
(delete-region (point) (point-max))
|
|
|
|
;; Now insert all the parts again where they fit in the structure.
|
|
|
|
(nnimap-insert-partial-structure structure parts)
|
|
|
|
t))
|
|
|
|
|
|
|
|
(defun nnimap-insert-partial-structure (structure parts &optional subp)
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(let (type boundary)
|
|
|
|
(let ((bstruc structure))
|
|
|
|
(while (consp (car bstruc))
|
|
|
|
(pop bstruc))
|
|
|
|
(setq type (car bstruc))
|
|
|
|
(setq bstruc (car (cdr bstruc)))
|
2010-10-20 22:29:38 +00:00
|
|
|
(let ((has-boundary (member "boundary" bstruc)))
|
|
|
|
(when has-boundary
|
|
|
|
(setq boundary (cadr has-boundary)))))
|
2010-09-26 04:03:19 +00:00
|
|
|
(when subp
|
|
|
|
(insert (format "Content-type: multipart/%s; boundary=%S\n\n"
|
|
|
|
(downcase type) boundary)))
|
|
|
|
(while (not (stringp (car structure)))
|
|
|
|
(insert "\n--" boundary "\n")
|
|
|
|
(if (consp (caar structure))
|
|
|
|
(nnimap-insert-partial-structure (pop structure) parts t)
|
|
|
|
(let ((bit (pop structure)))
|
|
|
|
(insert (format "Content-type: %s/%s"
|
|
|
|
(downcase (nth 0 bit))
|
|
|
|
(downcase (nth 1 bit))))
|
|
|
|
(if (member "CHARSET" (nth 2 bit))
|
|
|
|
(insert (format
|
|
|
|
"; charset=%S\n" (cadr (member "CHARSET" (nth 2 bit)))))
|
|
|
|
(insert "\n"))
|
|
|
|
(insert (format "Content-transfer-encoding: %s\n"
|
|
|
|
(nth 5 bit)))
|
|
|
|
(insert "\n")
|
|
|
|
(when (assoc (nth 9 bit) parts)
|
|
|
|
(insert (cadr (assoc (nth 9 bit) parts)))))))
|
|
|
|
(insert "\n--" boundary "--\n")))
|
2010-09-20 00:36:54 +00:00
|
|
|
|
|
|
|
(defun nnimap-find-wanted-parts (structure)
|
|
|
|
(message-flatten-list (nnimap-find-wanted-parts-1 structure "")))
|
|
|
|
|
|
|
|
(defun nnimap-find-wanted-parts-1 (structure prefix)
|
|
|
|
(let ((num 1)
|
|
|
|
parts)
|
|
|
|
(while (consp (car structure))
|
|
|
|
(let ((sub (pop structure)))
|
|
|
|
(if (consp (car sub))
|
|
|
|
(push (nnimap-find-wanted-parts-1
|
|
|
|
sub (if (string= prefix "")
|
|
|
|
(number-to-string num)
|
|
|
|
(format "%s.%s" prefix num)))
|
|
|
|
parts)
|
2010-09-26 04:03:19 +00:00
|
|
|
(let ((type (format "%s/%s" (nth 0 sub) (nth 1 sub)))
|
|
|
|
(id (if (string= prefix "")
|
2010-09-20 00:36:54 +00:00
|
|
|
(number-to-string num)
|
2010-09-26 04:03:19 +00:00
|
|
|
(format "%s.%s" prefix num))))
|
|
|
|
(setcar (nthcdr 9 sub) id)
|
2010-09-27 23:07:47 +00:00
|
|
|
(when (if (eq nnimap-fetch-partial-articles t)
|
|
|
|
(equal id "1")
|
|
|
|
(string-match nnimap-fetch-partial-articles type))
|
2010-09-26 04:03:19 +00:00
|
|
|
(push id parts))))
|
|
|
|
(incf num)))
|
2010-09-20 00:36:54 +00:00
|
|
|
(nreverse parts)))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-request-group (group &optional server dont-check info)
|
2010-10-18 22:09:28 +00:00
|
|
|
(let ((result (nnimap-possibly-change-group
|
|
|
|
;; Don't SELECT the group if we're going to select it
|
|
|
|
;; later, anyway.
|
2010-11-01 22:21:10 +00:00
|
|
|
(if (and dont-check
|
|
|
|
(assoc group nnimap-current-infos))
|
2010-10-18 22:09:28 +00:00
|
|
|
nil
|
|
|
|
group)
|
|
|
|
server))
|
2010-09-20 23:08:33 +00:00
|
|
|
articles active marks high low)
|
|
|
|
(with-current-buffer nntp-server-buffer
|
2010-09-18 10:02:19 +00:00
|
|
|
(when result
|
2010-09-18 23:36:29 +00:00
|
|
|
(if (and dont-check
|
|
|
|
(setq active (nth 2 (assoc group nnimap-current-infos))))
|
|
|
|
(insert (format "211 %d %d %d %S\n"
|
|
|
|
(- (cdr active) (car active))
|
|
|
|
(car active)
|
|
|
|
(cdr active)
|
|
|
|
group))
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(erase-buffer)
|
|
|
|
(let ((group-sequence
|
2010-09-21 23:13:46 +00:00
|
|
|
(nnimap-send-command "SELECT %S" (utf7-encode group t)))
|
2010-09-18 23:36:29 +00:00
|
|
|
(flag-sequence
|
|
|
|
(nnimap-send-command "UID FETCH 1:* FLAGS")))
|
2010-10-18 22:09:28 +00:00
|
|
|
(setf (nnimap-group nnimap-object) group)
|
2010-09-18 23:36:29 +00:00
|
|
|
(nnimap-wait-for-response flag-sequence)
|
|
|
|
(setq marks
|
|
|
|
(nnimap-flags-to-marks
|
|
|
|
(nnimap-parse-flags
|
2010-10-10 00:15:21 +00:00
|
|
|
(list (list group-sequence flag-sequence
|
|
|
|
1 group "SELECT")))))
|
|
|
|
(when (and info
|
|
|
|
marks)
|
2010-11-01 22:21:10 +00:00
|
|
|
(nnimap-update-infos marks (list info))
|
|
|
|
(nnimap-store-info info (gnus-active (gnus-info-group info))))
|
2010-09-18 23:36:29 +00:00
|
|
|
(goto-char (point-max))
|
2010-09-23 23:14:02 +00:00
|
|
|
(let ((uidnext (nth 5 (car marks))))
|
2010-10-01 23:08:25 +00:00
|
|
|
(setq high (or (if uidnext
|
|
|
|
(1- uidnext)
|
|
|
|
(nth 3 (car marks)))
|
|
|
|
0)
|
|
|
|
low (or (nth 4 (car marks)) uidnext 1)))))
|
2010-09-18 23:36:29 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(insert
|
|
|
|
(format
|
2010-09-21 23:13:46 +00:00
|
|
|
"211 %d %d %d %S\n" (1+ (- high low)) low high group)))
|
|
|
|
t))))
|
|
|
|
|
|
|
|
(deffoo nnimap-request-create-group (group &optional server args)
|
|
|
|
(when (nnimap-possibly-change-group nil server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(car (nnimap-command "CREATE %S" (utf7-encode group t))))))
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-09-20 23:08:33 +00:00
|
|
|
(deffoo nnimap-request-delete-group (group &optional force server)
|
|
|
|
(when (nnimap-possibly-change-group nil server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
2010-09-21 23:13:46 +00:00
|
|
|
(car (nnimap-command "DELETE %S" (utf7-encode group t))))))
|
|
|
|
|
2010-10-07 11:46:01 +00:00
|
|
|
(deffoo nnimap-request-rename-group (group new-name &optional server)
|
|
|
|
(when (nnimap-possibly-change-group nil server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
2010-11-21 07:11:35 +00:00
|
|
|
(nnimap-unselect-group)
|
2010-10-10 00:15:21 +00:00
|
|
|
(car (nnimap-command "RENAME %S %S"
|
|
|
|
(utf7-encode group t) (utf7-encode new-name t))))))
|
2010-10-07 11:46:01 +00:00
|
|
|
|
2010-11-21 07:11:35 +00:00
|
|
|
(defun nnimap-unselect-group ()
|
|
|
|
;; Make sure we don't have this group open read/write by asking
|
|
|
|
;; to examine a mailbox that doesn't exist. This seems to be
|
|
|
|
;; the only way that allows us to reliably go back to unselected
|
|
|
|
;; state on Courier.
|
|
|
|
(nnimap-command "EXAMINE DOES.NOT.EXIST"))
|
|
|
|
|
2010-09-21 23:13:46 +00:00
|
|
|
(deffoo nnimap-request-expunge-group (group &optional server)
|
|
|
|
(when (nnimap-possibly-change-group group server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(car (nnimap-command "EXPUNGE")))))
|
2010-09-20 23:08:33 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-get-flags (spec)
|
|
|
|
(let ((articles nil)
|
2010-10-10 00:15:21 +00:00
|
|
|
elems end)
|
2010-09-18 10:02:19 +00:00
|
|
|
(with-current-buffer (nnimap-buffer)
|
2000-09-19 13:40:08 +00:00
|
|
|
(erase-buffer)
|
2010-09-18 10:02:19 +00:00
|
|
|
(nnimap-wait-for-response (nnimap-send-command
|
|
|
|
"UID FETCH %s FLAGS" spec))
|
2010-10-10 00:15:21 +00:00
|
|
|
(setq end (point))
|
|
|
|
(subst-char-in-region (point-min) (point-max)
|
|
|
|
?\\ ?% t)
|
2010-09-18 10:02:19 +00:00
|
|
|
(goto-char (point-min))
|
2010-10-10 00:15:21 +00:00
|
|
|
(while (search-forward " FETCH " end t)
|
|
|
|
(setq elems (read (current-buffer)))
|
|
|
|
(push (cons (cadr (memq 'UID elems))
|
|
|
|
(cadr (memq 'FLAGS elems)))
|
2010-09-18 10:02:19 +00:00
|
|
|
articles)))
|
|
|
|
(nreverse articles)))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-close-group (group &optional server)
|
2010-09-18 10:02:19 +00:00
|
|
|
t)
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2007-10-28 09:18:39 +00:00
|
|
|
(deffoo nnimap-request-move-article (article group server accept-form
|
2010-09-18 10:02:19 +00:00
|
|
|
&optional last internal-move-group)
|
2010-09-21 23:13:46 +00:00
|
|
|
(with-temp-buffer
|
2010-10-19 00:13:27 +00:00
|
|
|
(mm-disable-multibyte)
|
2010-10-24 22:32:38 +00:00
|
|
|
(when (funcall (if internal-move-group
|
|
|
|
'nnimap-request-head
|
|
|
|
'nnimap-request-article)
|
|
|
|
article group server (current-buffer))
|
2010-09-21 23:13:46 +00:00
|
|
|
;; If the move is internal (on the same server), just do it the easy
|
|
|
|
;; way.
|
|
|
|
(let ((message-id (message-field-value "message-id")))
|
|
|
|
(if internal-move-group
|
|
|
|
(let ((result
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(nnimap-command "UID COPY %d %S"
|
|
|
|
article
|
|
|
|
(utf7-encode internal-move-group t)))))
|
|
|
|
(when (car result)
|
2010-09-20 23:08:33 +00:00
|
|
|
(nnimap-delete-article article)
|
2010-09-21 23:13:46 +00:00
|
|
|
(cons internal-move-group
|
2010-11-26 01:14:40 +00:00
|
|
|
(or (nnimap-find-uid-response "COPYUID" (cadr result))
|
|
|
|
(nnimap-find-article-by-message-id
|
|
|
|
internal-move-group message-id)))))
|
2010-09-21 23:13:46 +00:00
|
|
|
;; Move the article to a different method.
|
|
|
|
(let ((result (eval accept-form)))
|
|
|
|
(when result
|
|
|
|
(nnimap-delete-article article)
|
|
|
|
result)))))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(deffoo nnimap-request-expire-articles (articles group &optional server force)
|
|
|
|
(cond
|
2010-09-21 23:13:46 +00:00
|
|
|
((null articles)
|
|
|
|
nil)
|
2010-09-18 10:02:19 +00:00
|
|
|
((not (nnimap-possibly-change-group group server))
|
|
|
|
articles)
|
2010-09-21 23:13:46 +00:00
|
|
|
((and force
|
|
|
|
(eq nnmail-expiry-target 'delete))
|
2010-09-26 23:01:31 +00:00
|
|
|
(unless (nnimap-delete-article (gnus-compress-sequence articles))
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "Article marked for deletion, but not expunged."))
|
2010-09-18 10:02:19 +00:00
|
|
|
nil)
|
|
|
|
(t
|
2010-09-21 23:13:46 +00:00
|
|
|
(let ((deletable-articles
|
2010-09-23 00:30:37 +00:00
|
|
|
(if (or force
|
|
|
|
(eq nnmail-expiry-wait 'immediate))
|
2010-09-21 23:13:46 +00:00
|
|
|
articles
|
|
|
|
(gnus-sorted-intersection
|
|
|
|
articles
|
|
|
|
(nnimap-find-expired-articles group)))))
|
|
|
|
(if (null deletable-articles)
|
|
|
|
articles
|
|
|
|
(if (eq nnmail-expiry-target 'delete)
|
2010-09-26 23:01:31 +00:00
|
|
|
(nnimap-delete-article (gnus-compress-sequence deletable-articles))
|
2010-09-21 23:13:46 +00:00
|
|
|
(setq deletable-articles
|
|
|
|
(nnimap-process-expiry-targets
|
|
|
|
deletable-articles group server)))
|
|
|
|
;; Return the articles we didn't delete.
|
|
|
|
(gnus-sorted-complement articles deletable-articles))))))
|
|
|
|
|
|
|
|
(defun nnimap-process-expiry-targets (articles group server)
|
|
|
|
(let ((deleted-articles nil))
|
|
|
|
(dolist (article articles)
|
|
|
|
(let ((target nnmail-expiry-target))
|
|
|
|
(with-temp-buffer
|
2010-10-19 00:13:27 +00:00
|
|
|
(mm-disable-multibyte)
|
2010-09-21 23:13:46 +00:00
|
|
|
(when (nnimap-request-article article group server (current-buffer))
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "Expiring article %s:%d" group article)
|
2010-09-21 23:13:46 +00:00
|
|
|
(when (functionp target)
|
|
|
|
(setq target (funcall target group)))
|
|
|
|
(when (and target
|
|
|
|
(not (eq target 'delete)))
|
|
|
|
(if (or (gnus-request-group target t)
|
|
|
|
(gnus-request-create-group target))
|
|
|
|
(nnmail-expiry-target-group target group)
|
|
|
|
(setq target nil)))
|
|
|
|
(when target
|
|
|
|
(push article deleted-articles))))))
|
|
|
|
;; Change back to the current group again.
|
|
|
|
(nnimap-possibly-change-group group server)
|
|
|
|
(setq deleted-articles (nreverse deleted-articles))
|
2010-09-26 23:01:31 +00:00
|
|
|
(nnimap-delete-article (gnus-compress-sequence deleted-articles))
|
2010-09-21 23:13:46 +00:00
|
|
|
deleted-articles))
|
|
|
|
|
|
|
|
(defun nnimap-find-expired-articles (group)
|
|
|
|
(let ((cutoff (nnmail-expired-article-p group nil nil)))
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(let ((result
|
|
|
|
(nnimap-command
|
|
|
|
"UID SEARCH SENTBEFORE %s"
|
|
|
|
(format-time-string
|
|
|
|
(format "%%d-%s-%%Y"
|
|
|
|
(upcase
|
|
|
|
(car (rassoc (nth 4 (decode-time cutoff))
|
|
|
|
parse-time-months))))
|
|
|
|
cutoff))))
|
|
|
|
(and (car result)
|
|
|
|
(delete 0 (mapcar #'string-to-number
|
|
|
|
(cdr (assoc "SEARCH" (cdr result))))))))))
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-find-article-by-message-id (group message-id)
|
2010-10-01 00:25:50 +00:00
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(erase-buffer)
|
2010-11-04 22:18:09 +00:00
|
|
|
(unless (equal group (nnimap-group nnimap-object))
|
|
|
|
(setf (nnimap-group nnimap-object) nil)
|
2010-11-21 07:11:35 +00:00
|
|
|
(setf (nnimap-examined nnimap-object) group)
|
2010-11-04 22:18:09 +00:00
|
|
|
(nnimap-send-command "EXAMINE %S" (utf7-encode group t)))
|
2010-10-01 00:25:50 +00:00
|
|
|
(let ((sequence
|
|
|
|
(nnimap-send-command "UID SEARCH HEADER Message-Id %S" message-id))
|
|
|
|
article result)
|
|
|
|
(setq result (nnimap-wait-for-response sequence))
|
|
|
|
(when (and result
|
|
|
|
(car (setq result (nnimap-parse-response))))
|
|
|
|
;; Select the last instance of the message in the group.
|
|
|
|
(and (setq article
|
|
|
|
(car (last (assoc "SEARCH" (cdr result)))))
|
|
|
|
(string-to-number article))))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-delete-article (articles)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)"
|
|
|
|
(nnimap-article-ranges articles))
|
2010-09-21 23:13:46 +00:00
|
|
|
(cond
|
2010-10-31 22:31:24 +00:00
|
|
|
((nnimap-capability "UIDPLUS")
|
2010-09-21 23:13:46 +00:00
|
|
|
(nnimap-command "UID EXPUNGE %s"
|
|
|
|
(nnimap-article-ranges articles))
|
|
|
|
t)
|
|
|
|
(nnimap-expunge
|
|
|
|
(nnimap-command "EXPUNGE")
|
2010-09-22 13:34:37 +00:00
|
|
|
t)
|
|
|
|
(t (gnus-message 7 (concat "nnimap: nnimap-expunge is not set and the "
|
|
|
|
"server doesn't support UIDPLUS, so we won't "
|
|
|
|
"delete this article now"))))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(deffoo nnimap-request-scan (&optional group server)
|
|
|
|
(when (and (nnimap-possibly-change-group nil server)
|
|
|
|
nnimap-inbox
|
|
|
|
nnimap-split-methods)
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "nnimap %s splitting mail..." server)
|
2010-09-18 10:02:19 +00:00
|
|
|
(nnimap-split-incoming-mail)))
|
|
|
|
|
|
|
|
(defun nnimap-marks-to-flags (marks)
|
|
|
|
(let (flags flag)
|
|
|
|
(dolist (mark marks)
|
|
|
|
(when (setq flag (cadr (assq mark nnimap-mark-alist)))
|
|
|
|
(push flag flags)))
|
|
|
|
flags))
|
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-request-set-mark (group actions &optional server)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when (nnimap-possibly-change-group group server)
|
|
|
|
(let (sequence)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(erase-buffer)
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Just send all the STORE commands without waiting for
|
|
|
|
;; response. If they're successful, they're successful.
|
|
|
|
(dolist (action actions)
|
|
|
|
(destructuring-bind (range action marks) action
|
|
|
|
(let ((flags (nnimap-marks-to-flags marks)))
|
|
|
|
(when flags
|
|
|
|
(setq sequence (nnimap-send-command
|
|
|
|
"UID STORE %s %sFLAGS.SILENT (%s)"
|
|
|
|
(nnimap-article-ranges range)
|
2010-11-26 02:11:40 +00:00
|
|
|
(cond
|
|
|
|
((eq action 'del) "-")
|
|
|
|
((eq action 'add) "-")
|
|
|
|
((eq action 'set) ""))
|
2010-09-18 10:02:19 +00:00
|
|
|
(mapconcat #'identity flags " ")))))))
|
|
|
|
;; Wait for the last command to complete to avoid later
|
|
|
|
;; syncronisation problems with the stream.
|
2010-09-20 23:08:33 +00:00
|
|
|
(when sequence
|
|
|
|
(nnimap-wait-for-response sequence))))))
|
2003-02-04 13:24:35 +00:00
|
|
|
|
2000-09-19 13:40:08 +00:00
|
|
|
(deffoo nnimap-request-accept-article (group &optional server last)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when (nnimap-possibly-change-group nil server)
|
|
|
|
(nnmail-check-syntax)
|
2010-10-01 00:25:50 +00:00
|
|
|
(let ((message-id (message-field-value "message-id"))
|
|
|
|
sequence message)
|
|
|
|
(nnimap-add-cr)
|
2010-10-21 01:23:34 +00:00
|
|
|
(setq message (buffer-substring-no-properties (point-min) (point-max)))
|
2010-09-18 10:02:19 +00:00
|
|
|
(with-current-buffer (nnimap-buffer)
|
2010-11-21 07:11:35 +00:00
|
|
|
;; If we have this group open read-only, then unselect it
|
|
|
|
;; before appending to it.
|
|
|
|
(when (equal (nnimap-examined nnimap-object) group)
|
|
|
|
(nnimap-unselect-group))
|
2010-10-31 22:31:24 +00:00
|
|
|
(erase-buffer)
|
2010-09-18 10:02:19 +00:00
|
|
|
(setq sequence (nnimap-send-command
|
|
|
|
"APPEND %S {%d}" (utf7-encode group t)
|
|
|
|
(length message)))
|
2010-10-31 22:31:24 +00:00
|
|
|
(unless nnimap-streaming
|
|
|
|
(nnimap-wait-for-connection "^[+]"))
|
2010-09-18 10:02:19 +00:00
|
|
|
(process-send-string (get-buffer-process (current-buffer)) message)
|
2010-09-18 23:36:29 +00:00
|
|
|
(process-send-string (get-buffer-process (current-buffer))
|
|
|
|
(if (nnimap-newlinep nnimap-object)
|
|
|
|
"\n"
|
|
|
|
"\r\n"))
|
2010-09-18 10:02:19 +00:00
|
|
|
(let ((result (nnimap-get-response sequence)))
|
2010-09-27 12:22:22 +00:00
|
|
|
(if (not (car result))
|
|
|
|
(progn
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "%s" (nnheader-get-report-string 'nnimap))
|
2010-09-27 12:22:22 +00:00
|
|
|
nil)
|
2010-09-18 10:02:19 +00:00
|
|
|
(cons group
|
2010-11-26 01:14:40 +00:00
|
|
|
(or (nnimap-find-uid-response "APPENDUID" (car result))
|
|
|
|
(nnimap-find-article-by-message-id
|
|
|
|
group message-id)))))))))
|
|
|
|
|
|
|
|
(defun nnimap-find-uid-response (name list)
|
2010-11-26 01:27:37 +00:00
|
|
|
(let ((result (car (last (nnimap-find-response-element name list)))))
|
2010-11-26 01:14:40 +00:00
|
|
|
(and result
|
|
|
|
(string-to-number result))))
|
|
|
|
|
|
|
|
(defun nnimap-find-response-element (name list)
|
|
|
|
(let (result)
|
|
|
|
(dolist (elem list)
|
|
|
|
(when (and (consp elem)
|
|
|
|
(equal name (car elem)))
|
|
|
|
(setq result elem)))
|
|
|
|
result))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
2010-10-21 01:23:34 +00:00
|
|
|
(deffoo nnimap-request-replace-article (article group buffer)
|
|
|
|
(let (group-art)
|
|
|
|
(when (and (nnimap-possibly-change-group group nil)
|
|
|
|
;; Put the article into the group.
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(setq group-art
|
|
|
|
(nnimap-request-accept-article group nil t))))
|
|
|
|
(nnimap-delete-article (list article))
|
|
|
|
;; Return the new article number.
|
|
|
|
(cdr group-art))))
|
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-add-cr ()
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "\r?\n" nil t)
|
|
|
|
(replace-match "\r\n" t t)))
|
|
|
|
|
|
|
|
(defun nnimap-get-groups ()
|
2010-11-26 01:14:40 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(let ((sequence (nnimap-send-command "LIST \"\" \"*\""))
|
2010-09-18 10:02:19 +00:00
|
|
|
groups)
|
2010-11-26 01:14:40 +00:00
|
|
|
(nnimap-wait-for-response sequence)
|
|
|
|
(subst-char-in-region (point-min) (point-max)
|
|
|
|
?\\ ?% t)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(nnimap-unfold-quoted-lines)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (search-forward "* LIST " nil t)
|
|
|
|
(let ((flags (read (current-buffer)))
|
|
|
|
(separator (read (current-buffer)))
|
|
|
|
(group (read (current-buffer))))
|
|
|
|
(unless (member '%NoSelect flags)
|
|
|
|
(push group groups))))
|
|
|
|
(nreverse groups)))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-request-list (&optional server)
|
2010-09-18 10:02:19 +00:00
|
|
|
(nnimap-possibly-change-group nil server)
|
|
|
|
(with-current-buffer nntp-server-buffer
|
|
|
|
(erase-buffer)
|
|
|
|
(let ((groups
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(nnimap-get-groups)))
|
|
|
|
sequences responses)
|
|
|
|
(when groups
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
2010-09-23 00:30:37 +00:00
|
|
|
(setf (nnimap-group nnimap-object) nil)
|
2010-09-18 10:02:19 +00:00
|
|
|
(dolist (group groups)
|
2010-11-21 07:11:35 +00:00
|
|
|
(setf (nnimap-examined nnimap-object) group)
|
2010-09-18 10:02:19 +00:00
|
|
|
(push (list (nnimap-send-command "EXAMINE %S" (utf7-encode group t))
|
|
|
|
group)
|
|
|
|
sequences))
|
|
|
|
(nnimap-wait-for-response (caar sequences))
|
|
|
|
(setq responses
|
|
|
|
(nnimap-get-responses (mapcar #'car sequences))))
|
|
|
|
(dolist (response responses)
|
|
|
|
(let* ((sequence (car response))
|
|
|
|
(response (cadr response))
|
|
|
|
(group (cadr (assoc sequence sequences))))
|
|
|
|
(when (and group
|
|
|
|
(equal (caar response) "OK"))
|
|
|
|
(let ((uidnext (nnimap-find-parameter "UIDNEXT" response))
|
|
|
|
highest exists)
|
|
|
|
(dolist (elem response)
|
|
|
|
(when (equal (cadr elem) "EXISTS")
|
|
|
|
(setq exists (string-to-number (car elem)))))
|
|
|
|
(when uidnext
|
|
|
|
(setq highest (1- (string-to-number (car uidnext)))))
|
|
|
|
(cond
|
|
|
|
((null highest)
|
|
|
|
(insert (format "%S 0 1 y\n" (utf7-decode group t))))
|
|
|
|
((zerop exists)
|
|
|
|
;; Empty group.
|
|
|
|
(insert (format "%S %d %d y\n"
|
|
|
|
(utf7-decode group t) highest (1+ highest))))
|
|
|
|
(t
|
|
|
|
;; Return the widest possible range.
|
|
|
|
(insert (format "%S %d 1 y\n" (utf7-decode group t)
|
|
|
|
(or highest exists)))))))))
|
2000-09-19 13:40:08 +00:00
|
|
|
t))))
|
|
|
|
|
2010-10-01 23:08:25 +00:00
|
|
|
(deffoo nnimap-request-newgroups (date &optional server)
|
|
|
|
(nnimap-possibly-change-group nil server)
|
|
|
|
(with-current-buffer nntp-server-buffer
|
|
|
|
(erase-buffer)
|
|
|
|
(dolist (group (with-current-buffer (nnimap-buffer)
|
|
|
|
(nnimap-get-groups)))
|
|
|
|
(unless (assoc group nnimap-current-infos)
|
|
|
|
;; Insert dummy numbers here -- they don't matter.
|
2010-10-05 22:43:06 +00:00
|
|
|
(insert (format "%S 0 1 y\n" group))))
|
|
|
|
t))
|
2010-10-01 23:08:25 +00:00
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-retrieve-group-data-early (server infos)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when (nnimap-possibly-change-group nil server)
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
2010-10-10 00:15:21 +00:00
|
|
|
(erase-buffer)
|
|
|
|
(setf (nnimap-group nnimap-object) nil)
|
2010-10-31 22:31:24 +00:00
|
|
|
(let ((qresyncp (nnimap-capability "QRESYNC"))
|
2010-10-10 00:15:21 +00:00
|
|
|
params groups sequences active uidvalidity modseq group)
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Go through the infos and gather the data needed to know
|
|
|
|
;; what and how to request the data.
|
|
|
|
(dolist (info infos)
|
2010-10-10 00:15:21 +00:00
|
|
|
(setq params (gnus-info-params info)
|
|
|
|
group (gnus-group-real-name (gnus-info-group info))
|
|
|
|
active (cdr (assq 'active params))
|
|
|
|
uidvalidity (cdr (assq 'uidvalidity params))
|
|
|
|
modseq (cdr (assq 'modseq params)))
|
2010-11-21 07:11:35 +00:00
|
|
|
(setf (nnimap-examined nnimap-object) group)
|
2010-09-18 10:02:19 +00:00
|
|
|
(if (and qresyncp
|
2010-10-10 00:15:21 +00:00
|
|
|
uidvalidity
|
|
|
|
modseq)
|
2010-09-18 10:02:19 +00:00
|
|
|
(push
|
2010-10-10 00:15:21 +00:00
|
|
|
(list (nnimap-send-command "EXAMINE %S (QRESYNC (%s %s))"
|
2010-10-10 22:48:40 +00:00
|
|
|
(utf7-encode group t)
|
|
|
|
uidvalidity modseq)
|
2010-10-10 00:15:21 +00:00
|
|
|
'qresync
|
|
|
|
nil group 'qresync)
|
2010-09-18 10:02:19 +00:00
|
|
|
sequences)
|
|
|
|
(let ((start
|
2010-10-10 00:15:21 +00:00
|
|
|
(if (and active uidvalidity)
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Fetch the last 100 flags.
|
2010-10-10 00:15:21 +00:00
|
|
|
(max 1 (- (cdr active) 100))
|
|
|
|
1))
|
|
|
|
(command
|
|
|
|
(if uidvalidity
|
|
|
|
"EXAMINE"
|
|
|
|
;; If we don't have a UIDVALIDITY, then this is
|
|
|
|
;; the first time we've seen the group, so we
|
|
|
|
;; have to do a SELECT (which is slower than an
|
|
|
|
;; examine), but will tell us whether the group
|
|
|
|
;; is read-only or not.
|
|
|
|
"SELECT")))
|
2010-10-10 22:48:40 +00:00
|
|
|
(push (list (nnimap-send-command "%s %S" command
|
|
|
|
(utf7-encode group t))
|
2010-09-18 10:02:19 +00:00
|
|
|
(nnimap-send-command "UID FETCH %d:* FLAGS" start)
|
2010-10-10 00:15:21 +00:00
|
|
|
start group command)
|
2010-10-24 22:32:38 +00:00
|
|
|
sequences))))
|
2010-09-18 10:02:19 +00:00
|
|
|
sequences))))
|
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-finish-retrieve-group-infos (server infos sequences)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when (and sequences
|
|
|
|
(nnimap-possibly-change-group nil server))
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
;; Wait for the final data to trickle in.
|
2010-10-10 00:15:21 +00:00
|
|
|
(when (nnimap-wait-for-response (if (eq (cadar sequences) 'qresync)
|
|
|
|
(caar sequences)
|
|
|
|
(cadar sequences))
|
|
|
|
t)
|
|
|
|
;; Now we should have most of the data we need, no matter
|
|
|
|
;; whether we're QRESYNCING, fetching all the flags from
|
|
|
|
;; scratch, or just fetching the last 100 flags per group.
|
2010-09-26 04:03:19 +00:00
|
|
|
(nnimap-update-infos (nnimap-flags-to-marks
|
|
|
|
(nnimap-parse-flags
|
|
|
|
(nreverse sequences)))
|
|
|
|
infos)
|
|
|
|
;; Finally, just return something resembling an active file in
|
|
|
|
;; the nntp buffer, so that the agent can save the info, too.
|
|
|
|
(with-current-buffer nntp-server-buffer
|
|
|
|
(erase-buffer)
|
|
|
|
(dolist (info infos)
|
|
|
|
(let* ((group (gnus-info-group info))
|
|
|
|
(active (gnus-active group)))
|
|
|
|
(when active
|
|
|
|
(insert (format "%S %d %d y\n"
|
|
|
|
(gnus-group-real-name group)
|
|
|
|
(cdr active)
|
|
|
|
(car active)))))))))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-update-infos (flags infos)
|
|
|
|
(dolist (info infos)
|
2010-10-10 00:15:21 +00:00
|
|
|
(let* ((group (gnus-group-real-name (gnus-info-group info)))
|
|
|
|
(marks (cdr (assoc group flags))))
|
|
|
|
(when marks
|
|
|
|
(nnimap-update-info info marks)))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-update-info (info marks)
|
2010-10-10 00:15:21 +00:00
|
|
|
(destructuring-bind (existing flags high low uidnext start-article
|
|
|
|
permanent-flags uidvalidity
|
|
|
|
vanished highestmodseq) marks
|
|
|
|
(cond
|
|
|
|
;; Ignore groups with no UIDNEXT/marks. This happens for
|
|
|
|
;; completely empty groups.
|
|
|
|
((and (not existing)
|
|
|
|
(not uidnext))
|
2010-10-10 22:48:40 +00:00
|
|
|
(let ((active (cdr (assq 'active (gnus-info-params info)))))
|
|
|
|
(when active
|
|
|
|
(gnus-set-active (gnus-info-group info) active))))
|
2010-10-10 00:15:21 +00:00
|
|
|
;; We have a mismatch between the old and new UIDVALIDITY
|
|
|
|
;; identifiers, so we have to re-request the group info (the next
|
|
|
|
;; time). This virtually never happens.
|
|
|
|
((let ((old-uidvalidity
|
|
|
|
(cdr (assq 'uidvalidity (gnus-info-params info)))))
|
|
|
|
(and old-uidvalidity
|
|
|
|
(not (equal old-uidvalidity uidvalidity))
|
|
|
|
(> start-article 1)))
|
|
|
|
(gnus-group-remove-parameter info 'uidvalidity)
|
|
|
|
(gnus-group-remove-parameter info 'modseq))
|
|
|
|
;; We have the data needed to update.
|
|
|
|
(t
|
2010-10-10 22:48:40 +00:00
|
|
|
(let* ((group (gnus-info-group info))
|
|
|
|
(completep (and start-article
|
|
|
|
(= start-article 1)))
|
|
|
|
(active (or (gnus-active group)
|
|
|
|
(cdr (assq 'active (gnus-info-params info))))))
|
2010-09-23 23:14:02 +00:00
|
|
|
(when uidnext
|
|
|
|
(setq high (1- uidnext)))
|
2010-09-18 10:02:19 +00:00
|
|
|
;; First set the active ranges based on high/low.
|
|
|
|
(if (or completep
|
|
|
|
(not (gnus-active group)))
|
|
|
|
(gnus-set-active group
|
2010-09-24 22:33:34 +00:00
|
|
|
(cond
|
2010-11-10 23:16:01 +00:00
|
|
|
(active
|
|
|
|
(cons (min (or low (car active))
|
|
|
|
(car active))
|
|
|
|
(max (or high (cdr active))
|
|
|
|
(cdr active))))
|
2010-09-24 22:33:34 +00:00
|
|
|
((and low high)
|
|
|
|
(cons low high))
|
|
|
|
(uidnext
|
2010-09-18 10:02:19 +00:00
|
|
|
;; No articles in this group.
|
2010-09-24 22:33:34 +00:00
|
|
|
(cons uidnext (1- uidnext)))
|
|
|
|
(start-article
|
|
|
|
(cons start-article (1- start-article)))
|
|
|
|
(t
|
|
|
|
;; No articles and no uidnext.
|
|
|
|
nil)))
|
2010-09-27 23:07:47 +00:00
|
|
|
(gnus-set-active
|
|
|
|
group
|
2010-10-10 22:48:40 +00:00
|
|
|
(cons (car active)
|
2010-09-27 23:07:47 +00:00
|
|
|
(or high (1- uidnext)))))
|
2010-10-10 00:15:21 +00:00
|
|
|
;; See whether this is a read-only group.
|
|
|
|
(unless (eq permanent-flags 'not-scanned)
|
|
|
|
(gnus-group-set-parameter
|
|
|
|
info 'permanent-flags
|
2010-10-18 22:09:28 +00:00
|
|
|
(and (or (memq '%* permanent-flags)
|
|
|
|
(memq '%Seen permanent-flags))
|
|
|
|
permanent-flags)))
|
2010-10-10 00:15:21 +00:00
|
|
|
;; Update marks and read articles if this isn't a
|
|
|
|
;; read-only IMAP group.
|
2010-10-18 22:09:28 +00:00
|
|
|
(when (setq permanent-flags
|
|
|
|
(cdr (assq 'permanent-flags (gnus-info-params info))))
|
2010-10-10 00:15:21 +00:00
|
|
|
(if (and highestmodseq
|
|
|
|
(not start-article))
|
|
|
|
;; We've gotten the data by QRESYNCing.
|
|
|
|
(nnimap-update-qresync-info
|
2010-10-10 22:48:40 +00:00
|
|
|
info existing (nnimap-imap-ranges-to-gnus-ranges vanished) flags)
|
2010-10-10 00:15:21 +00:00
|
|
|
;; Do normal non-QRESYNC flag updates.
|
|
|
|
;; Update the list of read articles.
|
|
|
|
(let* ((unread
|
|
|
|
(gnus-compress-sequence
|
|
|
|
(gnus-set-difference
|
|
|
|
(gnus-set-difference
|
|
|
|
existing
|
|
|
|
(cdr (assoc '%Seen flags)))
|
|
|
|
(cdr (assoc '%Flagged flags)))))
|
|
|
|
(read (gnus-range-difference
|
|
|
|
(cons start-article high) unread)))
|
|
|
|
(when (> start-article 1)
|
|
|
|
(setq read
|
|
|
|
(gnus-range-nconcat
|
|
|
|
(if (> start-article 1)
|
|
|
|
(gnus-sorted-range-intersection
|
|
|
|
(cons 1 (1- start-article))
|
|
|
|
(gnus-info-read info))
|
|
|
|
(gnus-info-read info))
|
|
|
|
read)))
|
2010-10-18 22:09:28 +00:00
|
|
|
(when (or (not (listp permanent-flags))
|
|
|
|
(memq '%Seen permanent-flags))
|
|
|
|
(gnus-info-set-read info read))
|
2010-10-10 00:15:21 +00:00
|
|
|
;; Update the marks.
|
|
|
|
(setq marks (gnus-info-marks info))
|
|
|
|
(dolist (type (cdr nnimap-mark-alist))
|
2010-10-18 22:09:28 +00:00
|
|
|
(when (or (not (listp permanent-flags))
|
2010-10-30 12:54:28 +00:00
|
|
|
(memq (car (assoc (caddr type) flags))
|
|
|
|
permanent-flags)
|
2010-10-18 22:09:28 +00:00
|
|
|
(memq '%* permanent-flags))
|
|
|
|
(let ((old-marks (assoc (car type) marks))
|
|
|
|
(new-marks
|
|
|
|
(gnus-compress-sequence
|
|
|
|
(cdr (or (assoc (caddr type) flags) ; %Flagged
|
|
|
|
(assoc (intern (cadr type) obarray) flags)
|
|
|
|
(assoc (cadr type) flags)))))) ; "\Flagged"
|
|
|
|
(setq marks (delq old-marks marks))
|
|
|
|
(pop old-marks)
|
|
|
|
(when (and old-marks
|
|
|
|
(> start-article 1))
|
|
|
|
(setq old-marks (gnus-range-difference
|
|
|
|
old-marks
|
|
|
|
(cons start-article high)))
|
|
|
|
(setq new-marks (gnus-range-nconcat old-marks new-marks)))
|
|
|
|
(when new-marks
|
|
|
|
(push (cons (car type) new-marks) marks)))))
|
|
|
|
(gnus-info-set-marks info marks t))))
|
2010-10-10 00:15:21 +00:00
|
|
|
;; Note the active level for the next run-through.
|
|
|
|
(gnus-group-set-parameter info 'active (gnus-active group))
|
|
|
|
(gnus-group-set-parameter info 'uidvalidity uidvalidity)
|
|
|
|
(gnus-group-set-parameter info 'modseq highestmodseq)
|
|
|
|
(nnimap-store-info info (gnus-active group)))))))
|
|
|
|
|
2010-10-10 22:48:40 +00:00
|
|
|
(defun nnimap-update-qresync-info (info existing vanished flags)
|
2010-10-10 00:15:21 +00:00
|
|
|
;; Add all the vanished articles to the list of read articles.
|
|
|
|
(gnus-info-set-read
|
|
|
|
info
|
2010-10-10 22:48:40 +00:00
|
|
|
(gnus-add-to-range
|
|
|
|
(gnus-add-to-range
|
|
|
|
(gnus-range-add (gnus-info-read info)
|
|
|
|
vanished)
|
|
|
|
(cdr (assq '%Flagged flags)))
|
|
|
|
(cdr (assq '%Seen flags))))
|
|
|
|
(let ((marks (gnus-info-marks info)))
|
|
|
|
(dolist (type (cdr nnimap-mark-alist))
|
|
|
|
(let ((ticks (assoc (car type) marks))
|
|
|
|
(new-marks
|
|
|
|
(cdr (or (assoc (caddr type) flags) ; %Flagged
|
|
|
|
(assoc (intern (cadr type) obarray) flags)
|
|
|
|
(assoc (cadr type) flags))))) ; "\Flagged"
|
|
|
|
(setq marks (delq ticks marks))
|
|
|
|
(pop ticks)
|
|
|
|
;; Add the new marks we got.
|
|
|
|
(setq ticks (gnus-add-to-range ticks new-marks))
|
|
|
|
;; Remove the marks from messages that don't have them.
|
|
|
|
(setq ticks (gnus-remove-from-range
|
|
|
|
ticks
|
|
|
|
(gnus-compress-sequence
|
|
|
|
(gnus-sorted-complement existing new-marks))))
|
|
|
|
(when ticks
|
|
|
|
(push (cons (car type) ticks) marks)))
|
|
|
|
(gnus-info-set-marks info marks t))))
|
2010-10-10 00:15:21 +00:00
|
|
|
|
|
|
|
(defun nnimap-imap-ranges-to-gnus-ranges (irange)
|
|
|
|
(if (zerop (length irange))
|
|
|
|
nil
|
|
|
|
(let ((result nil))
|
|
|
|
(dolist (elem (split-string irange ","))
|
|
|
|
(push
|
|
|
|
(if (string-match ":" elem)
|
|
|
|
(let ((numbers (split-string elem ":")))
|
|
|
|
(cons (string-to-number (car numbers))
|
|
|
|
(string-to-number (cadr numbers))))
|
|
|
|
(string-to-number elem))
|
|
|
|
result))
|
|
|
|
(nreverse result))))
|
2010-09-18 23:36:29 +00:00
|
|
|
|
|
|
|
(defun nnimap-store-info (info active)
|
|
|
|
(let* ((group (gnus-group-real-name (gnus-info-group info)))
|
|
|
|
(entry (assoc group nnimap-current-infos)))
|
|
|
|
(if entry
|
|
|
|
(setcdr entry (list info active))
|
|
|
|
(push (list group info active) nnimap-current-infos))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-flags-to-marks (groups)
|
2010-10-10 00:15:21 +00:00
|
|
|
(let (data group totalp uidnext articles start-article mark permanent-flags
|
|
|
|
uidvalidity vanished highestmodseq)
|
2010-09-18 10:02:19 +00:00
|
|
|
(dolist (elem groups)
|
|
|
|
(setq group (car elem)
|
2010-09-23 00:30:37 +00:00
|
|
|
uidnext (nth 1 elem)
|
|
|
|
start-article (nth 2 elem)
|
|
|
|
permanent-flags (nth 3 elem)
|
2010-10-10 00:15:21 +00:00
|
|
|
uidvalidity (nth 4 elem)
|
|
|
|
vanished (nth 5 elem)
|
|
|
|
highestmodseq (nth 6 elem)
|
|
|
|
articles (nthcdr 7 elem))
|
2010-09-18 10:02:19 +00:00
|
|
|
(let ((high (caar articles))
|
|
|
|
marks low existing)
|
|
|
|
(dolist (article articles)
|
|
|
|
(setq low (car article))
|
|
|
|
(push (car article) existing)
|
|
|
|
(dolist (flag (cdr article))
|
|
|
|
(setq mark (assoc flag marks))
|
|
|
|
(if (not mark)
|
|
|
|
(push (list flag (car article)) marks)
|
2010-09-23 00:30:37 +00:00
|
|
|
(setcdr mark (cons (car article) (cdr mark))))))
|
|
|
|
(push (list group existing marks high low uidnext start-article
|
2010-10-10 00:15:21 +00:00
|
|
|
permanent-flags uidvalidity vanished highestmodseq)
|
2010-09-23 00:30:37 +00:00
|
|
|
data)))
|
2010-09-18 10:02:19 +00:00
|
|
|
data))
|
|
|
|
|
|
|
|
(defun nnimap-parse-flags (sequences)
|
|
|
|
(goto-char (point-min))
|
2010-09-23 00:30:37 +00:00
|
|
|
;; Change \Delete etc to %Delete, so that the reader can read it.
|
|
|
|
(subst-char-in-region (point-min) (point-max)
|
|
|
|
?\\ ?% t)
|
2010-10-10 00:15:21 +00:00
|
|
|
(let (start end articles groups uidnext elems permanent-flags
|
|
|
|
uidvalidity vanished highestmodseq)
|
2010-09-18 10:02:19 +00:00
|
|
|
(dolist (elem sequences)
|
2010-10-10 00:15:21 +00:00
|
|
|
(destructuring-bind (group-sequence flag-sequence totalp group command)
|
|
|
|
elem
|
2010-09-23 00:30:37 +00:00
|
|
|
(setq start (point))
|
2010-10-10 00:15:21 +00:00
|
|
|
(when (and
|
|
|
|
;; The EXAMINE was successful.
|
|
|
|
(search-forward (format "\n%d OK " group-sequence) nil t)
|
|
|
|
(progn
|
|
|
|
(forward-line 1)
|
|
|
|
(setq end (point))
|
|
|
|
(goto-char start)
|
|
|
|
(setq permanent-flags
|
|
|
|
(if (equal command "SELECT")
|
2010-09-23 00:30:37 +00:00
|
|
|
(and (search-forward "PERMANENTFLAGS "
|
2010-10-10 00:15:21 +00:00
|
|
|
(or end (point-min)) t)
|
|
|
|
(read (current-buffer)))
|
|
|
|
'not-scanned))
|
|
|
|
(goto-char start)
|
|
|
|
(setq uidnext
|
|
|
|
(and (search-forward "UIDNEXT "
|
|
|
|
(or end (point-min)) t)
|
|
|
|
(read (current-buffer))))
|
|
|
|
(goto-char start)
|
|
|
|
(setq uidvalidity
|
|
|
|
(and (re-search-forward "UIDVALIDITY \\([0-9]+\\)"
|
|
|
|
(or end (point-min)) t)
|
|
|
|
;; Store UIDVALIDITY as a string, as it's
|
|
|
|
;; too big for 32-bit Emacsen, usually.
|
|
|
|
(match-string 1)))
|
|
|
|
(goto-char start)
|
|
|
|
(setq vanished
|
|
|
|
(and (eq flag-sequence 'qresync)
|
|
|
|
(re-search-forward "VANISHED.* \\([0-9:,]+\\)"
|
|
|
|
(or end (point-min)) t)
|
|
|
|
(match-string 1)))
|
|
|
|
(goto-char start)
|
|
|
|
(setq highestmodseq
|
|
|
|
(and (search-forward "HIGHESTMODSEQ "
|
|
|
|
(or end (point-min)) t)
|
|
|
|
(read (current-buffer))))
|
|
|
|
(goto-char end)
|
|
|
|
(forward-line -1))
|
|
|
|
;; The UID FETCH FLAGS was successful.
|
|
|
|
(or (eq flag-sequence 'qresync)
|
|
|
|
(search-forward (format "\n%d OK " flag-sequence) nil t)))
|
|
|
|
(if (eq flag-sequence 'qresync)
|
|
|
|
(progn
|
|
|
|
(goto-char start)
|
|
|
|
(setq start end))
|
|
|
|
(setq start (point))
|
|
|
|
(goto-char end))
|
2010-10-13 22:21:20 +00:00
|
|
|
(while (re-search-forward "^\\* [0-9]+ FETCH " start t)
|
2010-09-23 00:30:37 +00:00
|
|
|
(setq elems (read (current-buffer)))
|
|
|
|
(push (cons (cadr (memq 'UID elems))
|
|
|
|
(cadr (memq 'FLAGS elems)))
|
2010-09-18 10:02:19 +00:00
|
|
|
articles))
|
2010-10-10 00:15:21 +00:00
|
|
|
(push (nconc (list group uidnext totalp permanent-flags uidvalidity
|
|
|
|
vanished highestmodseq)
|
|
|
|
articles)
|
2010-09-23 00:30:37 +00:00
|
|
|
groups)
|
2010-10-10 00:15:21 +00:00
|
|
|
(goto-char end)
|
2010-09-18 10:02:19 +00:00
|
|
|
(setq articles nil))))
|
|
|
|
groups))
|
|
|
|
|
|
|
|
(defun nnimap-find-process-buffer (buffer)
|
|
|
|
(cadr (assoc buffer nnimap-connection-alist)))
|
|
|
|
|
2010-09-18 23:36:29 +00:00
|
|
|
(deffoo nnimap-request-post (&optional server)
|
2010-09-18 10:02:19 +00:00
|
|
|
(setq nnimap-status-string "Read-only server")
|
|
|
|
nil)
|
2000-09-19 13:40:08 +00:00
|
|
|
|
2010-10-14 22:39:54 +00:00
|
|
|
(deffoo nnimap-request-thread (id)
|
2010-11-07 00:22:06 +00:00
|
|
|
(let* ((refs (split-string
|
|
|
|
(or (mail-header-references (gnus-summary-article-header))
|
|
|
|
"")))
|
|
|
|
(cmd (let ((value
|
|
|
|
(format
|
|
|
|
"(OR HEADER REFERENCES %s HEADER Message-Id %s)"
|
|
|
|
id id)))
|
|
|
|
(dolist (refid refs value)
|
|
|
|
(setq value (format
|
|
|
|
"(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
|
|
|
|
refid refid value)))))
|
|
|
|
(result (with-current-buffer (nnimap-buffer)
|
|
|
|
(nnimap-command "UID SEARCH %s" cmd))))
|
|
|
|
(gnus-fetch-headers
|
|
|
|
(and (car result) (delete 0 (mapcar #'string-to-number
|
|
|
|
(cdr (assoc "SEARCH" (cdr result))))))
|
|
|
|
nil t)))
|
2010-10-14 22:39:54 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-possibly-change-group (group server)
|
|
|
|
(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)
|
2010-09-18 23:36:29 +00:00
|
|
|
(setf (nnimap-group nnimap-object) group
|
|
|
|
(nnimap-select-result nnimap-object) result)
|
2010-09-18 10:02:19 +00:00
|
|
|
result))))))))
|
|
|
|
|
|
|
|
(defun nnimap-find-connection (buffer)
|
|
|
|
"Find the connection delivering to BUFFER."
|
|
|
|
(let ((entry (assoc buffer nnimap-connection-alist)))
|
|
|
|
(when entry
|
|
|
|
(if (and (buffer-name (cadr entry))
|
|
|
|
(get-buffer-process (cadr entry))
|
|
|
|
(memq (process-status (get-buffer-process (cadr entry)))
|
|
|
|
'(open run)))
|
|
|
|
(get-buffer-process (cadr entry))
|
|
|
|
(setq nnimap-connection-alist (delq entry nnimap-connection-alist))
|
|
|
|
nil))))
|
|
|
|
|
|
|
|
(defvar nnimap-sequence 0)
|
|
|
|
|
|
|
|
(defun nnimap-send-command (&rest args)
|
|
|
|
(process-send-string
|
|
|
|
(get-buffer-process (current-buffer))
|
|
|
|
(nnimap-log-command
|
2010-09-18 23:36:29 +00:00
|
|
|
(format "%d %s%s\n"
|
2010-09-18 10:02:19 +00:00
|
|
|
(incf nnimap-sequence)
|
2010-09-18 23:36:29 +00:00
|
|
|
(apply #'format args)
|
|
|
|
(if (nnimap-newlinep nnimap-object)
|
|
|
|
""
|
|
|
|
"\r"))))
|
2010-10-24 22:32:38 +00:00
|
|
|
;; Some servers apparently can't have many outstanding
|
|
|
|
;; commands, so throttle them.
|
|
|
|
(unless nnimap-streaming
|
|
|
|
(nnimap-wait-for-response nnimap-sequence))
|
2010-09-18 10:02:19 +00:00
|
|
|
nnimap-sequence)
|
|
|
|
|
|
|
|
(defun nnimap-log-command (command)
|
|
|
|
(with-current-buffer (get-buffer-create "*imap log*")
|
|
|
|
(goto-char (point-max))
|
|
|
|
(insert (format-time-string "%H:%M:%S") " " command))
|
|
|
|
command)
|
|
|
|
|
|
|
|
(defun nnimap-command (&rest args)
|
|
|
|
(erase-buffer)
|
2010-09-24 22:33:34 +00:00
|
|
|
(setf (nnimap-last-command-time nnimap-object) (current-time))
|
2010-09-18 10:02:19 +00:00
|
|
|
(let* ((sequence (apply #'nnimap-send-command args))
|
|
|
|
(response (nnimap-get-response sequence)))
|
|
|
|
(if (equal (caar response) "OK")
|
|
|
|
(cons t response)
|
|
|
|
(nnheader-report 'nnimap "%s"
|
2010-09-20 23:08:33 +00:00
|
|
|
(mapconcat (lambda (a)
|
|
|
|
(format "%s" a))
|
|
|
|
(car response) " "))
|
2010-09-18 10:02:19 +00:00
|
|
|
nil)))
|
|
|
|
|
|
|
|
(defun nnimap-get-response (sequence)
|
|
|
|
(nnimap-wait-for-response sequence)
|
|
|
|
(nnimap-parse-response))
|
|
|
|
|
2010-10-31 22:31:24 +00:00
|
|
|
(defun nnimap-wait-for-connection (&optional regexp)
|
|
|
|
(unless regexp
|
|
|
|
(setq regexp "^[*.] .*\n"))
|
2010-09-18 23:36:29 +00:00
|
|
|
(let ((process (get-buffer-process (current-buffer))))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (and (memq (process-status process)
|
|
|
|
'(open run))
|
2010-10-31 22:31:24 +00:00
|
|
|
(not (re-search-forward regexp nil t)))
|
2010-09-18 23:36:29 +00:00
|
|
|
(nnheader-accept-process-output process)
|
|
|
|
(goto-char (point-min)))
|
2010-09-20 00:36:54 +00:00
|
|
|
(forward-line -1)
|
2010-10-01 00:25:50 +00:00
|
|
|
(and (looking-at "[*.] \\([A-Z0-9]+\\)")
|
2010-09-20 00:36:54 +00:00
|
|
|
(match-string 1))))
|
2010-09-18 23:36:29 +00:00
|
|
|
|
2010-09-18 10:02:19 +00:00
|
|
|
(defun nnimap-wait-for-response (sequence &optional messagep)
|
2010-09-26 04:03:19 +00:00
|
|
|
(let ((process (get-buffer-process (current-buffer)))
|
|
|
|
openp)
|
2010-10-10 22:48:40 +00:00
|
|
|
(condition-case nil
|
|
|
|
(progn
|
|
|
|
(goto-char (point-max))
|
|
|
|
(while (and (setq openp (memq (process-status process)
|
|
|
|
'(open run)))
|
|
|
|
(not (re-search-backward
|
|
|
|
(format "^%d .*\n" sequence)
|
|
|
|
(if nnimap-streaming
|
|
|
|
(max (point-min) (- (point) 500))
|
|
|
|
(point-min))
|
|
|
|
t)))
|
|
|
|
(when messagep
|
2010-10-16 01:55:08 +00:00
|
|
|
(nnheader-message 7 "nnimap read %dk" (/ (buffer-size) 1000)))
|
2010-10-10 22:48:40 +00:00
|
|
|
(nnheader-accept-process-output process)
|
|
|
|
(goto-char (point-max)))
|
|
|
|
openp)
|
|
|
|
(quit
|
|
|
|
;; The user hit C-g while we were waiting: kill the process, in case
|
|
|
|
;; it's a gnutls-cli process that's stuck (tends to happen a lot behind
|
|
|
|
;; NAT routers).
|
|
|
|
(delete-process process)
|
|
|
|
nil))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-parse-response ()
|
|
|
|
(let ((lines (split-string (nnimap-last-response-string) "\r\n" t))
|
|
|
|
result)
|
|
|
|
(dolist (line lines)
|
|
|
|
(push (cdr (nnimap-parse-line line)) result))
|
|
|
|
;; Return the OK/error code first, and then all the "continuation
|
|
|
|
;; lines" afterwards.
|
|
|
|
(cons (pop result)
|
|
|
|
(nreverse result))))
|
|
|
|
|
|
|
|
;; Parse an IMAP response line lightly. They look like
|
|
|
|
;; "* OK [UIDVALIDITY 1164213559] UIDs valid", typically, so parse
|
|
|
|
;; the lines into a list of strings and lists of string.
|
|
|
|
(defun nnimap-parse-line (line)
|
|
|
|
(let (char result)
|
|
|
|
(with-temp-buffer
|
2010-10-19 00:13:27 +00:00
|
|
|
(mm-disable-multibyte)
|
2010-09-18 10:02:19 +00:00
|
|
|
(insert line)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (not (eobp))
|
|
|
|
(if (eql (setq char (following-char)) ? )
|
|
|
|
(forward-char 1)
|
|
|
|
(push
|
|
|
|
(cond
|
|
|
|
((eql char ?\[)
|
2010-10-10 00:15:21 +00:00
|
|
|
(split-string
|
|
|
|
(buffer-substring
|
|
|
|
(1+ (point))
|
2010-11-01 22:21:10 +00:00
|
|
|
(if (search-forward "]" (line-end-position) 'move)
|
|
|
|
(1- (point))
|
|
|
|
(point)))))
|
2010-09-18 10:02:19 +00:00
|
|
|
((eql char ?\()
|
2010-10-10 00:15:21 +00:00
|
|
|
(split-string
|
|
|
|
(buffer-substring
|
|
|
|
(1+ (point))
|
2010-11-01 22:21:10 +00:00
|
|
|
(if (search-forward ")" (line-end-position) 'move)
|
|
|
|
(1- (point))
|
|
|
|
(point)))))
|
2010-09-18 10:02:19 +00:00
|
|
|
((eql char ?\")
|
|
|
|
(forward-char 1)
|
2010-09-27 23:07:47 +00:00
|
|
|
(buffer-substring
|
|
|
|
(point)
|
|
|
|
(1- (or (search-forward "\"" (line-end-position) 'move)
|
|
|
|
(point)))))
|
2010-09-18 10:02:19 +00:00
|
|
|
(t
|
|
|
|
(buffer-substring (point) (if (search-forward " " nil t)
|
|
|
|
(1- (point))
|
|
|
|
(goto-char (point-max))))))
|
|
|
|
result)))
|
|
|
|
(nreverse result))))
|
|
|
|
|
|
|
|
(defun nnimap-last-response-string ()
|
|
|
|
(save-excursion
|
|
|
|
(forward-line 1)
|
|
|
|
(let ((end (point)))
|
|
|
|
(forward-line -1)
|
|
|
|
(when (not (bobp))
|
|
|
|
(forward-line -1)
|
|
|
|
(while (and (not (bobp))
|
|
|
|
(eql (following-char) ?*))
|
|
|
|
(forward-line -1))
|
|
|
|
(unless (eql (following-char) ?*)
|
|
|
|
(forward-line 1)))
|
|
|
|
(buffer-substring (point) end))))
|
|
|
|
|
|
|
|
(defun nnimap-get-responses (sequences)
|
|
|
|
(let (responses)
|
|
|
|
(dolist (sequence sequences)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(when (re-search-forward (format "^%d " sequence) nil t)
|
|
|
|
(push (list sequence (nnimap-parse-response))
|
|
|
|
responses)))
|
|
|
|
responses))
|
|
|
|
|
|
|
|
(defvar nnimap-incoming-split-list nil)
|
|
|
|
|
|
|
|
(defun nnimap-fetch-inbox (articles)
|
|
|
|
(erase-buffer)
|
|
|
|
(nnimap-wait-for-response
|
|
|
|
(nnimap-send-command
|
|
|
|
"UID FETCH %s %s"
|
|
|
|
(nnimap-article-ranges articles)
|
|
|
|
(format "(UID %s%s)"
|
|
|
|
(format
|
2010-09-26 04:03:19 +00:00
|
|
|
(if (nnimap-ver4-p)
|
2010-09-18 10:02:19 +00:00
|
|
|
"BODY.PEEK[HEADER] BODY.PEEK"
|
|
|
|
"RFC822.PEEK"))
|
|
|
|
(if nnimap-split-download-body-default
|
2010-09-20 23:08:33 +00:00
|
|
|
"[]"
|
2010-09-18 10:02:19 +00:00
|
|
|
"[1]")))
|
|
|
|
t))
|
|
|
|
|
|
|
|
(defun nnimap-split-incoming-mail ()
|
|
|
|
(with-current-buffer (nnimap-buffer)
|
|
|
|
(let ((nnimap-incoming-split-list nil)
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(nnmail-split-methods (if (eq nnimap-split-methods 'default)
|
|
|
|
nnmail-split-methods
|
|
|
|
nnimap-split-methods))
|
2010-10-01 00:25:50 +00:00
|
|
|
(nnmail-split-fancy (or nnimap-split-fancy
|
|
|
|
nnmail-split-fancy))
|
2010-09-18 10:02:19 +00:00
|
|
|
(nnmail-inhibit-default-split-group t)
|
|
|
|
(groups (nnimap-get-groups))
|
|
|
|
new-articles)
|
|
|
|
(erase-buffer)
|
|
|
|
(nnimap-command "SELECT %S" nnimap-inbox)
|
2010-10-30 05:59:34 +00:00
|
|
|
(setf (nnimap-group nnimap-object) nnimap-inbox)
|
2010-09-18 10:02:19 +00:00
|
|
|
(setq new-articles (nnimap-new-articles (nnimap-get-flags "1:*")))
|
|
|
|
(when new-articles
|
|
|
|
(nnimap-fetch-inbox new-articles)
|
|
|
|
(nnimap-transform-split-mail)
|
|
|
|
(nnheader-ms-strip-cr)
|
|
|
|
(nnmail-cache-open)
|
|
|
|
(nnmail-split-incoming (current-buffer)
|
|
|
|
#'nnimap-save-mail-spec
|
|
|
|
nil nil
|
2010-09-23 00:30:37 +00:00
|
|
|
#'nnimap-dummy-active-number
|
|
|
|
#'nnimap-save-mail-spec)
|
2010-09-18 10:02:19 +00:00
|
|
|
(when nnimap-incoming-split-list
|
|
|
|
(let ((specs (nnimap-make-split-specs nnimap-incoming-split-list))
|
2010-09-23 00:30:37 +00:00
|
|
|
sequences junk-articles)
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Create any groups that doesn't already exist on the
|
|
|
|
;; server first.
|
|
|
|
(dolist (spec specs)
|
2010-09-23 00:30:37 +00:00
|
|
|
(when (and (not (member (car spec) groups))
|
|
|
|
(not (eq (car spec) 'junk)))
|
2010-09-18 10:02:19 +00:00
|
|
|
(nnimap-command "CREATE %S" (utf7-encode (car spec) t))))
|
|
|
|
;; Then copy over all the messages.
|
|
|
|
(erase-buffer)
|
|
|
|
(dolist (spec specs)
|
|
|
|
(let ((group (car spec))
|
|
|
|
(ranges (cdr spec)))
|
2010-09-23 00:30:37 +00:00
|
|
|
(if (eq group 'junk)
|
|
|
|
(setq junk-articles ranges)
|
|
|
|
(push (list (nnimap-send-command
|
|
|
|
"UID COPY %s %S"
|
|
|
|
(nnimap-article-ranges ranges)
|
|
|
|
(utf7-encode group t))
|
|
|
|
ranges)
|
|
|
|
sequences))))
|
2010-09-18 10:02:19 +00:00
|
|
|
;; Wait for the last COPY response...
|
|
|
|
(when sequences
|
|
|
|
(nnimap-wait-for-response (caar sequences))
|
|
|
|
;; And then mark the successful copy actions as deleted,
|
|
|
|
;; and possibly expunge them.
|
|
|
|
(nnimap-mark-and-expunge-incoming
|
2010-09-24 22:33:34 +00:00
|
|
|
(nnimap-parse-copied-articles sequences)))
|
|
|
|
(nnimap-mark-and-expunge-incoming junk-articles)))))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-mark-and-expunge-incoming (range)
|
|
|
|
(when range
|
|
|
|
(setq range (nnimap-article-ranges range))
|
Merge changes made in Gnus trunk.
nndraft.el (nndraft-request-expire-articles): Use the group name instead if "nndraft".
gnus.texi (Using IMAP): Remove the @acronyms from the headings.
nnregistry.el: Added.
nnimap.el (nnimap-insert-partial-structure): Be way more permissive when interpreting the structures.
GNUS-NEWS: Minor error in GNUS-NEWS - password-cache.el.
nnimap.el (nnimap-request-accept-article): Add \r\n to the lines to make this work with Cyrus.
gnus-registry.el: Don't prompt on load, which makes it impossible to build Gnus.
gnus-gravatar.el: Add gnus-gravatar-properties.
gnus-agent.el, gnus-art.el, gnus-bookmark.el, gnus-dired.el, gnus-group.el,\
gnus-int.el, gnus-msg.el, gnus-registry.el, gnus-score.el, gnus-srvr.el,\
gnus-sum.el, gnus-topic.el, gnus-util.el, gnus.el, mm-decode.el, mm-util.el,\
mm-view.el, mml-smime.el, mml.el, nnmairix.el, nnrss.el, smime.el:\
Introduce gnus-completing-read.
gnus-util.el: Make completing-read function configurable.
gnus-util.el: Add requires and fix history for iswitchb.
webmail.el: Remove netscape/my-deja, since they no longer exist.
gnus.el (gnus-local-domain): Declare variable obsolete.
nnimap.el (nnimap-insert-partial-structure): Get the type from the correct slot, too.
pop3.el (pop3-send-streaming-command, pop3-stream-length): New variable.
nnimap.el (nnimap-open-connection): Revert the auto-network->starttls code.
nnimap.el (nnimap-request-set-mark): Erase the buffer before issuing commands.
nnimap.el (nnimap-split-rule): Mark as obsolete.
gnus-sum.el (gnus-valid-move-group-p): Make sure that `group' is a symbol.
nnimap.el (nnimap-split-incoming-mail): Allow `default' as nnimap-split-methods value.
nnimap.el (nnimap-request-article): Downcase the NILs so that they are nil.
nndoc.el (nndoc-retrieve-groups): New function.
gnus.texi: Fix Gravatar documentation.
2010-09-30 08:39:23 +00:00
|
|
|
(erase-buffer)
|
2010-09-21 23:13:46 +00:00
|
|
|
(let ((sequence
|
|
|
|
(nnimap-send-command
|
|
|
|
"UID STORE %s +FLAGS.SILENT (\\Deleted)" range)))
|
|
|
|
(cond
|
|
|
|
;; If the server supports it, we now delete the message we have
|
|
|
|
;; just copied over.
|
2010-10-31 22:31:24 +00:00
|
|
|
((nnimap-capability "UIDPLUS")
|
2010-09-21 23:13:46 +00:00
|
|
|
(setq sequence (nnimap-send-command "UID EXPUNGE %s" range)))
|
|
|
|
;; If it doesn't support UID EXPUNGE, then we only expunge if the
|
|
|
|
;; user has configured it.
|
2010-09-23 00:30:37 +00:00
|
|
|
(nnimap-expunge
|
2010-09-21 23:13:46 +00:00
|
|
|
(setq sequence (nnimap-send-command "EXPUNGE"))))
|
|
|
|
(nnimap-wait-for-response sequence))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-parse-copied-articles (sequences)
|
|
|
|
(let (sequence copied range)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^\\([0-9]+\\) OK " nil t)
|
|
|
|
(setq sequence (string-to-number (match-string 1)))
|
|
|
|
(when (setq range (cadr (assq sequence sequences)))
|
|
|
|
(push (gnus-uncompress-range range) copied)))
|
|
|
|
(gnus-compress-sequence (sort (apply #'nconc copied) #'<))))
|
|
|
|
|
|
|
|
(defun nnimap-new-articles (flags)
|
|
|
|
(let (new)
|
|
|
|
(dolist (elem flags)
|
2010-10-30 05:59:34 +00:00
|
|
|
(unless (gnus-list-memq-of-list nnimap-unsplittable-articles
|
|
|
|
(cdr elem))
|
2010-09-18 10:02:19 +00:00
|
|
|
(push (car elem) new)))
|
|
|
|
(gnus-compress-sequence (nreverse new))))
|
|
|
|
|
|
|
|
(defun nnimap-make-split-specs (list)
|
|
|
|
(let ((specs nil)
|
|
|
|
entry)
|
|
|
|
(dolist (elem list)
|
|
|
|
(destructuring-bind (article spec) elem
|
|
|
|
(dolist (group (delete nil (mapcar #'car spec)))
|
|
|
|
(unless (setq entry (assoc group specs))
|
|
|
|
(push (setq entry (list group)) specs))
|
|
|
|
(setcdr entry (cons article (cdr entry))))))
|
|
|
|
(dolist (entry specs)
|
|
|
|
(setcdr entry (gnus-compress-sequence (sort (cdr entry) #'<))))
|
|
|
|
specs))
|
|
|
|
|
|
|
|
(defun nnimap-transform-split-mail ()
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let (article bytes)
|
|
|
|
(block nil
|
|
|
|
(while (not (eobp))
|
|
|
|
(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
|
|
|
|
(delete-region (point) (progn (forward-line 1) (point)))
|
|
|
|
(when (eobp)
|
|
|
|
(return)))
|
|
|
|
(setq article (match-string 1)
|
|
|
|
bytes (nnimap-get-length))
|
|
|
|
(delete-region (line-beginning-position) (line-end-position))
|
|
|
|
;; Insert MMDF separator, and a way to remember what this
|
|
|
|
;; article UID is.
|
|
|
|
(insert (format "\^A\^A\^A\^A\n\nX-nnimap-article: %s" article))
|
|
|
|
(forward-char (1+ bytes))
|
|
|
|
(setq bytes (nnimap-get-length))
|
|
|
|
(delete-region (line-beginning-position) (line-end-position))
|
2010-10-11 22:27:28 +00:00
|
|
|
;; There's a body; skip past that.
|
|
|
|
(when bytes
|
|
|
|
(forward-char (1+ bytes))
|
|
|
|
(delete-region (line-beginning-position) (line-end-position)))))))
|
2010-09-18 10:02:19 +00:00
|
|
|
|
|
|
|
(defun nnimap-dummy-active-number (group &optional server)
|
|
|
|
1)
|
|
|
|
|
|
|
|
(defun nnimap-save-mail-spec (group-art &optional server full-nov)
|
|
|
|
(let (article)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (not (re-search-forward "X-nnimap-article: \\([0-9]+\\)" nil t))
|
|
|
|
(error "Invalid nnimap mail")
|
|
|
|
(setq article (string-to-number (match-string 1))))
|
2010-09-23 00:30:37 +00:00
|
|
|
(push (list article
|
|
|
|
(if (eq group-art 'junk)
|
|
|
|
(list (cons 'junk 1))
|
|
|
|
group-art))
|
2010-09-18 10:02:19 +00:00
|
|
|
nnimap-incoming-split-list)))
|
2000-09-19 13:40:08 +00:00
|
|
|
|
|
|
|
(provide 'nnimap)
|
|
|
|
|
|
|
|
;;; nnimap.el ends here
|