Mercurial > emacs
annotate lisp/gnus/imap.el @ 60102:8555807a4582
(Continuation Lines): Simplify description of truncation,
and refer to Display Custom for the rest of it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 16 Feb 2005 09:51:37 +0000 |
parents | 681d4e4ca613 |
children | b070535d2416 3ebd9bdb4fe5 |
rev | line source |
---|---|
31717 | 1 ;;; imap.el --- imap library |
59289 | 2 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 |
31717 | 3 ;; Free Software Foundation, Inc. |
4 | |
5 ;; Author: Simon Josefsson <jas@pdc.kth.se> | |
6 ;; Keywords: mail | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; imap.el is a elisp library providing an interface for talking to | |
28 ;; IMAP servers. | |
29 ;; | |
30 ;; imap.el is roughly divided in two parts, one that parses IMAP | |
31 ;; responses from the server and storing data into buffer-local | |
32 ;; variables, and one for utility functions which send commands to | |
33 ;; server, waits for an answer, and return information. The latter | |
34 ;; part is layered on top of the previous. | |
35 ;; | |
36 ;; The imap.el API consist of the following functions, other functions | |
37 ;; in this file should not be called directly and the result of doing | |
38 ;; so are at best undefined. | |
39 ;; | |
40 ;; Global commands: | |
41 ;; | |
42 ;; imap-open, imap-opened, imap-authenticate, imap-close, | |
43 ;; imap-capability, imap-namespace, imap-error-text | |
44 ;; | |
45 ;; Mailbox commands: | |
46 ;; | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
47 ;; imap-mailbox-get, imap-mailbox-map, imap-current-mailbox, |
31717 | 48 ;; imap-current-mailbox-p, imap-search, imap-mailbox-select, |
49 ;; imap-mailbox-examine, imap-mailbox-unselect, imap-mailbox-expunge | |
50 ;; imap-mailbox-close, imap-mailbox-create, imap-mailbox-delete | |
51 ;; imap-mailbox-rename, imap-mailbox-lsub, imap-mailbox-list | |
52 ;; imap-mailbox-subscribe, imap-mailbox-unsubscribe, imap-mailbox-status | |
53 ;; imap-mailbox-acl-get, imap-mailbox-acl-set, imap-mailbox-acl-delete | |
54 ;; | |
55 ;; Message commands: | |
56 ;; | |
57 ;; imap-fetch-asynch, imap-fetch, | |
58 ;; imap-current-message, imap-list-to-message-set, | |
59 ;; imap-message-get, imap-message-map | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
60 ;; imap-message-envelope-date, imap-message-envelope-subject, |
31717 | 61 ;; imap-message-envelope-from, imap-message-envelope-sender, |
62 ;; imap-message-envelope-reply-to, imap-message-envelope-to, | |
63 ;; imap-message-envelope-cc, imap-message-envelope-bcc | |
64 ;; imap-message-envelope-in-reply-to, imap-message-envelope-message-id | |
65 ;; imap-message-body, imap-message-flag-permanent-p | |
66 ;; imap-message-flags-set, imap-message-flags-del | |
67 ;; imap-message-flags-add, imap-message-copyuid | |
68 ;; imap-message-copy, imap-message-appenduid | |
69 ;; imap-message-append, imap-envelope-from | |
70 ;; imap-body-lines | |
71 ;; | |
59289 | 72 ;; It is my hope that these commands should be pretty self |
31717 | 73 ;; explanatory for someone that know IMAP. All functions have |
74 ;; additional documentation on how to invoke them. | |
75 ;; | |
76 ;; imap.el support RFC1730/2060 (IMAP4/IMAP4rev1), implemented IMAP | |
77 ;; extensions are RFC2195 (CRAM-MD5), RFC2086 (ACL), RFC2342 | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
78 ;; (NAMESPACE), RFC2359 (UIDPLUS), the IMAP-part of RFC2595 (STARTTLS, |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
79 ;; LOGINDISABLED) (with use of external library starttls.el and |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
80 ;; program starttls) and the GSSAPI / kerberos V4 sections of RFC1731 |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
81 ;; (with use of external program `imtest'). It also take advantage |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
82 ;; the UNSELECT extension in Cyrus IMAPD. |
31717 | 83 ;; |
84 ;; Without the work of John McClary Prevost and Jim Radford this library | |
85 ;; would not have seen the light of day. Many thanks. | |
86 ;; | |
87 ;; This is a transcript of short interactive session for demonstration | |
88 ;; purposes. | |
89 ;; | |
90 ;; (imap-open "my.mail.server") | |
91 ;; => " *imap* my.mail.server:0" | |
92 ;; | |
93 ;; The rest are invoked with current buffer as the buffer returned by | |
94 ;; `imap-open'. It is possible to do all without this, but it would | |
95 ;; look ugly here since `buffer' is always the last argument for all | |
96 ;; imap.el API functions. | |
97 ;; | |
98 ;; (imap-authenticate "myusername" "mypassword") | |
99 ;; => auth | |
100 ;; | |
101 ;; (imap-mailbox-lsub "*") | |
102 ;; => ("INBOX.sentmail" "INBOX.private" "INBOX.draft" "INBOX.spam") | |
103 ;; | |
104 ;; (imap-mailbox-list "INBOX.n%") | |
105 ;; => ("INBOX.namedroppers" "INBOX.nnimap" "INBOX.ntbugtraq") | |
106 ;; | |
107 ;; (imap-mailbox-select "INBOX.nnimap") | |
108 ;; => "INBOX.nnimap" | |
109 ;; | |
110 ;; (imap-mailbox-get 'exists) | |
111 ;; => 166 | |
112 ;; | |
113 ;; (imap-mailbox-get 'uidvalidity) | |
114 ;; => "908992622" | |
115 ;; | |
116 ;; (imap-search "FLAGGED SINCE 18-DEC-98") | |
117 ;; => (235 236) | |
118 ;; | |
119 ;; (imap-fetch 235 "RFC822.PEEK" 'RFC822) | |
120 ;; => "X-Sieve: cmu-sieve 1.3^M\nX-Username: <jas@pdc.kth.se>^M\r...." | |
121 ;; | |
122 ;; Todo: | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
123 ;; |
31717 | 124 ;; o Parse UIDs as strings? We need to overcome the 28 bit limit somehow. |
125 ;; o Don't use `read' at all (important places already fixed) | |
126 ;; o Accept list of articles instead of message set string in most | |
127 ;; imap-message-* functions. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
128 ;; o Send strings as literal if they contain, e.g., ". |
31717 | 129 ;; |
130 ;; Revision history: | |
131 ;; | |
132 ;; - 19991218 added starttls/digest-md5 patch, | |
133 ;; by Daiki Ueno <ueno@ueda.info.waseda.ac.jp> | |
134 ;; NB! you need SLIM for starttls.el and digest-md5.el | |
135 ;; - 19991023 commited to pgnus | |
136 ;; | |
137 | |
138 ;;; Code: | |
139 | |
140 (eval-when-compile (require 'cl)) | |
141 (eval-and-compile | |
142 (autoload 'base64-decode-string "base64") | |
143 (autoload 'base64-encode-string "base64") | |
144 (autoload 'starttls-open-stream "starttls") | |
145 (autoload 'starttls-negotiate "starttls") | |
146 (autoload 'digest-md5-parse-digest-challenge "digest-md5") | |
147 (autoload 'digest-md5-digest-response "digest-md5") | |
148 (autoload 'digest-md5-digest-uri "digest-md5") | |
149 (autoload 'digest-md5-challenge "digest-md5") | |
150 (autoload 'rfc2104-hash "rfc2104") | |
151 (autoload 'md5 "md5") | |
152 (autoload 'utf7-encode "utf7") | |
153 (autoload 'utf7-decode "utf7") | |
154 (autoload 'format-spec "format-spec") | |
33299
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
155 (autoload 'format-spec-make "format-spec") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
156 (autoload 'open-tls-stream "tls") |
33299
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
157 ;; Avoid use gnus-point-at-eol so we're independent of Gnus. These |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
158 ;; days we have point-at-eol anyhow. |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
159 (if (fboundp 'point-at-eol) |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
160 (defalias 'imap-point-at-eol 'point-at-eol) |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
161 (defun imap-point-at-eol () |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
162 (save-excursion |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
163 (end-of-line) |
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
164 (point))))) |
31717 | 165 |
166 ;; User variables. | |
167 | |
168 (defgroup imap nil | |
169 "Low-level IMAP issues." | |
170 :version "21.1" | |
171 :group 'mail) | |
172 | |
173 (defcustom imap-kerberos4-program '("imtest -m kerberos_v4 -u %l -p %p %s" | |
174 "imtest -kp %s %p") | |
175 "List of strings containing commands for Kerberos 4 authentication. | |
176 %s is replaced with server hostname, %p with port to connect to, and | |
177 %l with the value of `imap-default-user'. The program should accept | |
178 IMAP commands on stdin and return responses to stdout. Each entry in | |
179 the list is tried until a successful connection is made." | |
180 :group 'imap | |
181 :type '(repeat string)) | |
182 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
183 (defcustom imap-gssapi-program (list |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
184 (concat "gsasl --client --connect %s:%p " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
185 "--imap --application-data " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
186 "--mechanism GSSAPI " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
187 "--authentication-id %l") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
188 "imtest -m gssapi -u %l -p %p %s") |
31717 | 189 "List of strings containing commands for GSSAPI (krb5) authentication. |
190 %s is replaced with server hostname, %p with port to connect to, and | |
191 %l with the value of `imap-default-user'. The program should accept | |
192 IMAP commands on stdin and return responses to stdout. Each entry in | |
193 the list is tried until a successful connection is made." | |
194 :group 'imap | |
195 :type '(repeat string)) | |
196 | |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
197 (defcustom imap-ssl-program '("openssl s_client -quiet -ssl3 -connect %s:%p" |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
198 "openssl s_client -quiet -ssl2 -connect %s:%p" |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
199 "s_client -quiet -ssl3 -connect %s:%p" |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
200 "s_client -quiet -ssl2 -connect %s:%p") |
31717 | 201 "A string, or list of strings, containing commands for SSL connections. |
202 Within a string, %s is replaced with the server address and %p with | |
203 port number on server. The program should accept IMAP commands on | |
204 stdin and return responses to stdout. Each entry in the list is tried | |
205 until a successful connection is made." | |
206 :group 'imap | |
207 :type '(choice string | |
208 (repeat string))) | |
209 | |
210 (defcustom imap-shell-program '("ssh %s imapd" | |
211 "rsh %s imapd" | |
212 "ssh %g ssh %s imapd" | |
213 "rsh %g rsh %s imapd") | |
214 "A list of strings, containing commands for IMAP connection. | |
215 Within a string, %s is replaced with the server address, %p with port | |
216 number on server, %g with `imap-shell-host', and %l with | |
217 `imap-default-user'. The program should read IMAP commands from stdin | |
218 and write IMAP response to stdout. Each entry in the list is tried | |
219 until a successful connection is made." | |
220 :group 'imap | |
221 :type '(repeat string)) | |
222 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
223 (defcustom imap-process-connection-type nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
224 "*Value for `process-connection-type' to use for Kerberos4, GSSAPI and SSL. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
225 The `process-connection-type' variable control type of device |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
226 used to communicate with subprocesses. Values are nil to use a |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
227 pipe, or t or `pty' to use a pty. The value has no effect if the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
228 system has no ptys or if all ptys are busy: then a pipe is used |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
229 in any case. The value takes effect when a IMAP server is |
57153
497f0d2ca551
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-558
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
230 opened, changing it after that has no effect." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59289
diff
changeset
|
231 :version "22.1" |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
232 :group 'imap |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
233 :type 'boolean) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
234 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
235 (defcustom imap-use-utf7 t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
236 "If non-nil, do utf7 encoding/decoding of mailbox names. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
237 Since the UTF7 decoding currently only decodes into ISO-8859-1 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
238 characters, you may disable this decoding if you need to access UTF7 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
239 encoded mailboxes which doesn't translate into ISO-8859-1." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
240 :group 'imap |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
241 :type 'boolean) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
242 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
243 (defcustom imap-log nil |
60028
681d4e4ca613
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-95
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
244 "If non-nil, a imap session trace is placed in *imap-log* buffer. |
681d4e4ca613
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-95
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
245 Note that username, passwords and other privacy sensitive |
681d4e4ca613
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-95
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
246 information (such as e-mail) may be stored in the *imap-log* |
681d4e4ca613
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-95
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
247 buffer. It is not written to disk, however. Do not enable this |
681d4e4ca613
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-95
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
248 variable unless you are comfortable with that." |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
249 :group 'imap |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
250 :type 'boolean) |
31717 | 251 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
252 (defcustom imap-debug nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
253 "If non-nil, random debug spews are placed in *imap-debug* buffer." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
254 :group 'imap |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
255 :type 'boolean) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
256 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
257 (defcustom imap-shell-host "gateway" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
258 "Hostname of rlogin proxy." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
259 :group 'imap |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
260 :type 'string) |
31717 | 261 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
262 (defcustom imap-default-user (user-login-name) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
263 "Default username to use." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
264 :group 'imap |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
265 :type 'string) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
266 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
267 (defcustom imap-read-timeout (if (string-match |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
268 "windows-nt\\|os/2\\|emx\\|cygwin" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
269 (symbol-name system-type)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
270 1.0 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
271 0.1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
272 "*How long to wait between checking for the end of output. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
273 Shorter values mean quicker response, but is more CPU intensive." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
274 :type 'number |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
275 :group 'imap) |
31717 | 276 |
57581
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
277 (defcustom imap-store-password nil |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
278 "If non-nil, store session password without promting." |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
279 :group 'imap |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
280 :type 'boolean) |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
281 |
31717 | 282 ;; Various variables. |
283 | |
284 (defvar imap-fetch-data-hook nil | |
285 "Hooks called after receiving each FETCH response.") | |
286 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
287 (defvar imap-streams '(gssapi kerberos4 starttls tls ssl network shell) |
31717 | 288 "Priority of streams to consider when opening connection to server.") |
289 | |
290 (defvar imap-stream-alist | |
291 '((gssapi imap-gssapi-stream-p imap-gssapi-open) | |
292 (kerberos4 imap-kerberos4-stream-p imap-kerberos4-open) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
293 (tls imap-tls-p imap-tls-open) |
31717 | 294 (ssl imap-ssl-p imap-ssl-open) |
295 (network imap-network-p imap-network-open) | |
296 (shell imap-shell-p imap-shell-open) | |
297 (starttls imap-starttls-p imap-starttls-open)) | |
298 "Definition of network streams. | |
299 | |
47129
dd529e3b965b
(imap-authenticator-alist, imap-stream-alist, imap-continuation): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
42205
diff
changeset
|
300 \(NAME CHECK OPEN) |
31717 | 301 |
302 NAME names the stream, CHECK is a function returning non-nil if the | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
303 server support the stream and OPEN is a function for opening the |
31717 | 304 stream.") |
305 | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
306 (defvar imap-authenticators '(gssapi |
31717 | 307 kerberos4 |
308 digest-md5 | |
309 cram-md5 | |
310 login | |
311 anonymous) | |
312 "Priority of authenticators to consider when authenticating to server.") | |
313 | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
314 (defvar imap-authenticator-alist |
31717 | 315 '((gssapi imap-gssapi-auth-p imap-gssapi-auth) |
316 (kerberos4 imap-kerberos4-auth-p imap-kerberos4-auth) | |
317 (cram-md5 imap-cram-md5-p imap-cram-md5-auth) | |
318 (login imap-login-p imap-login-auth) | |
319 (anonymous imap-anonymous-p imap-anonymous-auth) | |
320 (digest-md5 imap-digest-md5-p imap-digest-md5-auth)) | |
321 "Definition of authenticators. | |
322 | |
47129
dd529e3b965b
(imap-authenticator-alist, imap-stream-alist, imap-continuation): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
42205
diff
changeset
|
323 \(NAME CHECK AUTHENTICATE) |
31717 | 324 |
325 NAME names the authenticator. CHECK is a function returning non-nil if | |
326 the server support the authenticator and AUTHENTICATE is a function | |
47129
dd529e3b965b
(imap-authenticator-alist, imap-stream-alist, imap-continuation): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
42205
diff
changeset
|
327 for doing the actual authentication.") |
31717 | 328 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
329 (defvar imap-error nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
330 "Error codes from the last command.") |
31717 | 331 |
59289 | 332 ;; Internal constants. Change these and die. |
31717 | 333 |
334 (defconst imap-default-port 143) | |
335 (defconst imap-default-ssl-port 993) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
336 (defconst imap-default-tls-port 993) |
31717 | 337 (defconst imap-default-stream 'network) |
338 (defconst imap-coding-system-for-read 'binary) | |
339 (defconst imap-coding-system-for-write 'binary) | |
340 (defconst imap-local-variables '(imap-server | |
341 imap-port | |
342 imap-client-eol | |
343 imap-server-eol | |
344 imap-auth | |
345 imap-stream | |
346 imap-username | |
347 imap-password | |
348 imap-current-mailbox | |
349 imap-current-target-mailbox | |
350 imap-message-data | |
351 imap-capability | |
352 imap-namespace | |
353 imap-state | |
354 imap-reached-tag | |
355 imap-failed-tags | |
356 imap-tag | |
357 imap-process | |
358 imap-calculate-literal-size-first | |
359 imap-mailbox-data)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
360 (defconst imap-log-buffer "*imap-log*") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
361 (defconst imap-debug-buffer "*imap-debug*") |
31717 | 362 |
363 ;; Internal variables. | |
364 | |
365 (defvar imap-stream nil) | |
366 (defvar imap-auth nil) | |
367 (defvar imap-server nil) | |
368 (defvar imap-port nil) | |
369 (defvar imap-username nil) | |
370 (defvar imap-password nil) | |
371 (defvar imap-calculate-literal-size-first nil) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
372 (defvar imap-state 'closed |
31717 | 373 "IMAP state. |
374 Valid states are `closed', `initial', `nonauth', `auth', `selected' | |
375 and `examine'.") | |
376 | |
377 (defvar imap-server-eol "\r\n" | |
378 "The EOL string sent from the server.") | |
379 | |
380 (defvar imap-client-eol "\r\n" | |
381 "The EOL string we send to the server.") | |
382 | |
383 (defvar imap-current-mailbox nil | |
384 "Current mailbox name.") | |
385 | |
386 (defvar imap-current-target-mailbox nil | |
387 "Current target mailbox for COPY and APPEND commands.") | |
388 | |
389 (defvar imap-mailbox-data nil | |
390 "Obarray with mailbox data.") | |
391 | |
392 (defvar imap-mailbox-prime 997 | |
393 "Length of imap-mailbox-data.") | |
394 | |
395 (defvar imap-current-message nil | |
396 "Current message number.") | |
397 | |
398 (defvar imap-message-data nil | |
399 "Obarray with message data.") | |
400 | |
401 (defvar imap-message-prime 997 | |
402 "Length of imap-message-data.") | |
403 | |
404 (defvar imap-capability nil | |
405 "Capability for server.") | |
406 | |
407 (defvar imap-namespace nil | |
408 "Namespace for current server.") | |
409 | |
410 (defvar imap-reached-tag 0 | |
411 "Lower limit on command tags that have been parsed.") | |
412 | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
413 (defvar imap-failed-tags nil |
31717 | 414 "Alist of tags that failed. |
415 Each element is a list with four elements; tag (a integer), response | |
416 state (a symbol, `OK', `NO' or `BAD'), response code (a string), and | |
417 human readable response text (a string).") | |
418 | |
419 (defvar imap-tag 0 | |
420 "Command tag number.") | |
421 | |
422 (defvar imap-process nil | |
423 "Process.") | |
424 | |
425 (defvar imap-continuation nil | |
426 "Non-nil indicates that the server emitted a continuation request. | |
47129
dd529e3b965b
(imap-authenticator-alist, imap-stream-alist, imap-continuation): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
42205
diff
changeset
|
427 The actual value is really the text on the continuation line.") |
31717 | 428 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
429 (defvar imap-callbacks nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
430 "List of response tags and callbacks, on the form `(number . function)'. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
431 The function should take two arguments, the first the IMAP tag and the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
432 second the status (OK, NO, BAD etc) of the command.") |
31717 | 433 |
434 | |
435 ;; Utility functions: | |
436 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
437 (defun imap-remassoc (key alist) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
438 "Delete by side effect any elements of LIST whose car is `equal' to KEY. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
439 The modified LIST is returned. If the first member |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
440 of LIST has a car that is `equal' to KEY, there is no way to remove it |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
441 by side effect; therefore, write `(setq foo (remassoc key foo))' to be |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
442 sure of changing the value of `foo'." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
443 (when alist |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
444 (if (equal key (caar alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
445 (cdr alist) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
446 (setcdr alist (imap-remassoc key (cdr alist))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
447 alist))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
448 |
31717 | 449 (defsubst imap-disable-multibyte () |
450 "Enable multibyte in the current buffer." | |
451 (when (fboundp 'set-buffer-multibyte) | |
452 (set-buffer-multibyte nil))) | |
453 | |
454 (defsubst imap-utf7-encode (string) | |
455 (if imap-use-utf7 | |
456 (and string | |
457 (condition-case () | |
458 (utf7-encode string t) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
459 (error (message |
31717 | 460 "imap: Could not UTF7 encode `%s', using it unencoded..." |
461 string) | |
462 string))) | |
463 string)) | |
464 | |
465 (defsubst imap-utf7-decode (string) | |
466 (if imap-use-utf7 | |
467 (and string | |
468 (condition-case () | |
469 (utf7-decode string t) | |
470 (error (message | |
471 "imap: Could not UTF7 decode `%s', using it undecoded..." | |
472 string) | |
473 string))) | |
474 string)) | |
475 | |
476 (defsubst imap-ok-p (status) | |
477 (if (eq status 'OK) | |
478 t | |
479 (setq imap-error status) | |
480 nil)) | |
481 | |
482 (defun imap-error-text (&optional buffer) | |
483 (with-current-buffer (or buffer (current-buffer)) | |
484 (nth 3 (car imap-failed-tags)))) | |
485 | |
486 | |
487 ;; Server functions; stream stuff: | |
488 | |
489 (defun imap-kerberos4-stream-p (buffer) | |
490 (imap-capability 'AUTH=KERBEROS_V4 buffer)) | |
491 | |
492 (defun imap-kerberos4-open (name buffer server port) | |
493 (let ((cmds imap-kerberos4-program) | |
494 cmd done) | |
495 (while (and (not done) (setq cmd (pop cmds))) | |
496 (message "Opening Kerberos 4 IMAP connection with `%s'..." cmd) | |
497 (erase-buffer) | |
498 (let* ((port (or port imap-default-port)) | |
499 (coding-system-for-read imap-coding-system-for-read) | |
500 (coding-system-for-write imap-coding-system-for-write) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
501 (process-connection-type imap-process-connection-type) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
502 (process (start-process |
31717 | 503 name buffer shell-file-name shell-command-switch |
504 (format-spec | |
505 cmd | |
506 (format-spec-make | |
507 ?s server | |
508 ?p (number-to-string port) | |
509 ?l imap-default-user)))) | |
510 response) | |
511 (when process | |
512 (with-current-buffer buffer | |
513 (setq imap-client-eol "\n" | |
514 imap-calculate-literal-size-first t) | |
515 (while (and (memq (process-status process) '(open run)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
516 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
31717 | 517 (goto-char (point-min)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
518 ;; Athena IMTEST can output SSL verify errors |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
519 (or (while (looking-at "^verify error:num=") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
520 (forward-line)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
521 t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
522 (or (while (looking-at "^TLS connection established") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
523 (forward-line)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
524 t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
525 ;; cyrus 1.6.x (13? < x <= 22) queries capabilities |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
526 (or (while (looking-at "^C:") |
31717 | 527 (forward-line)) |
528 t) | |
529 ;; cyrus 1.6 imtest print "S: " before server greeting | |
530 (or (not (looking-at "S: ")) | |
531 (forward-char 3) | |
532 t) | |
533 (not (and (imap-parse-greeting) | |
534 ;; success in imtest < 1.6: | |
535 (or (re-search-forward | |
536 "^__\\(.*\\)__\n" nil t) | |
537 ;; success in imtest 1.6: | |
538 (re-search-forward | |
539 "^\\(Authenticat.*\\)" nil t)) | |
540 (setq response (match-string 1))))) | |
541 (accept-process-output process 1) | |
542 (sit-for 1)) | |
543 (and imap-log | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
544 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 545 (imap-disable-multibyte) |
546 (buffer-disable-undo) | |
547 (goto-char (point-max)) | |
548 (insert-buffer-substring buffer))) | |
549 (erase-buffer) | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
550 (message "Opening Kerberos 4 IMAP connection with `%s'...%s" cmd |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
551 (if response (concat "done, " response) "failed")) |
31717 | 552 (if (and response (let ((case-fold-search nil)) |
553 (not (string-match "failed" response)))) | |
554 (setq done process) | |
555 (if (memq (process-status process) '(open run)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
556 (imap-send-command "LOGOUT")) |
31717 | 557 (delete-process process) |
558 nil))))) | |
559 done)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
560 |
31717 | 561 (defun imap-gssapi-stream-p (buffer) |
562 (imap-capability 'AUTH=GSSAPI buffer)) | |
563 | |
564 (defun imap-gssapi-open (name buffer server port) | |
565 (let ((cmds imap-gssapi-program) | |
566 cmd done) | |
567 (while (and (not done) (setq cmd (pop cmds))) | |
568 (message "Opening GSSAPI IMAP connection with `%s'..." cmd) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
569 (erase-buffer) |
31717 | 570 (let* ((port (or port imap-default-port)) |
571 (coding-system-for-read imap-coding-system-for-read) | |
572 (coding-system-for-write imap-coding-system-for-write) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
573 (process-connection-type imap-process-connection-type) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
574 (process (start-process |
31717 | 575 name buffer shell-file-name shell-command-switch |
576 (format-spec | |
577 cmd | |
578 (format-spec-make | |
579 ?s server | |
580 ?p (number-to-string port) | |
581 ?l imap-default-user)))) | |
582 response) | |
583 (when process | |
584 (with-current-buffer buffer | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
585 (setq imap-client-eol "\n" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
586 imap-calculate-literal-size-first t) |
31717 | 587 (while (and (memq (process-status process) '(open run)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
588 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
31717 | 589 (goto-char (point-min)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
590 ;; cyrus 1.6.x (13? < x <= 22) queries capabilities |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
591 (or (while (looking-at "^C:") |
31717 | 592 (forward-line)) |
593 t) | |
594 ;; cyrus 1.6 imtest print "S: " before server greeting | |
595 (or (not (looking-at "S: ")) | |
596 (forward-char 3) | |
597 t) | |
598 (not (and (imap-parse-greeting) | |
599 ;; success in imtest 1.6: | |
600 (re-search-forward | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
601 (concat "^\\(\\(Authenticat.*\\)\\|\\(" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
602 "Client authentication " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
603 "finished.*\\)\\)") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
604 nil t) |
31717 | 605 (setq response (match-string 1))))) |
606 (accept-process-output process 1) | |
607 (sit-for 1)) | |
608 (and imap-log | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
609 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 610 (imap-disable-multibyte) |
611 (buffer-disable-undo) | |
612 (goto-char (point-max)) | |
613 (insert-buffer-substring buffer))) | |
614 (erase-buffer) | |
615 (message "GSSAPI IMAP connection: %s" (or response "failed")) | |
616 (if (and response (let ((case-fold-search nil)) | |
617 (not (string-match "failed" response)))) | |
618 (setq done process) | |
619 (if (memq (process-status process) '(open run)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
620 (imap-send-command "LOGOUT")) |
31717 | 621 (delete-process process) |
622 nil))))) | |
623 done)) | |
624 | |
625 (defun imap-ssl-p (buffer) | |
626 nil) | |
627 | |
628 (defun imap-ssl-open (name buffer server port) | |
629 "Open a SSL connection to server." | |
630 (let ((cmds (if (listp imap-ssl-program) imap-ssl-program | |
631 (list imap-ssl-program))) | |
632 cmd done) | |
633 (while (and (not done) (setq cmd (pop cmds))) | |
634 (message "imap: Opening SSL connection with `%s'..." cmd) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
635 (erase-buffer) |
31717 | 636 (let* ((port (or port imap-default-ssl-port)) |
637 (coding-system-for-read imap-coding-system-for-read) | |
638 (coding-system-for-write imap-coding-system-for-write) | |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
639 (process-connection-type nil) |
31717 | 640 process) |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
641 (when (progn |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
642 (setq process (start-process |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
643 name buffer shell-file-name |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
644 shell-command-switch |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
645 (format-spec cmd |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
646 (format-spec-make |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
647 ?s server |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
648 ?p (number-to-string port))))) |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
649 (process-kill-without-query process) |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
650 process) |
31717 | 651 (with-current-buffer buffer |
652 (goto-char (point-min)) | |
653 (while (and (memq (process-status process) '(open run)) | |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49474
diff
changeset
|
654 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
31717 | 655 (goto-char (point-max)) |
656 (forward-line -1) | |
657 (not (imap-parse-greeting))) | |
658 (accept-process-output process 1) | |
659 (sit-for 1)) | |
660 (and imap-log | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
661 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 662 (imap-disable-multibyte) |
663 (buffer-disable-undo) | |
664 (goto-char (point-max)) | |
665 (insert-buffer-substring buffer))) | |
666 (erase-buffer) | |
667 (when (memq (process-status process) '(open run)) | |
668 (setq done process)))))) | |
669 (if done | |
670 (progn | |
671 (message "imap: Opening SSL connection with `%s'...done" cmd) | |
672 done) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
673 (message "imap: Opening SSL connection with `%s'...failed" cmd) |
31717 | 674 nil))) |
675 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
676 (defun imap-tls-p (buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
677 nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
678 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
679 (defun imap-tls-open (name buffer server port) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
680 (let* ((port (or port imap-default-tls-port)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
681 (coding-system-for-read imap-coding-system-for-read) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
682 (coding-system-for-write imap-coding-system-for-write) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
683 (process (open-tls-stream name buffer server port))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
684 (when process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
685 (while (and (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
686 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
687 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
688 (forward-line -1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
689 (not (imap-parse-greeting))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
690 (accept-process-output process 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
691 (sit-for 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
692 (and imap-log |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
693 (with-current-buffer (get-buffer-create imap-log-buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
694 (imap-disable-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
695 (buffer-disable-undo) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
696 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
697 (insert-buffer-substring buffer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
698 (when (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
699 process)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
700 |
31717 | 701 (defun imap-network-p (buffer) |
702 t) | |
703 | |
704 (defun imap-network-open (name buffer server port) | |
705 (let* ((port (or port imap-default-port)) | |
706 (coding-system-for-read imap-coding-system-for-read) | |
707 (coding-system-for-write imap-coding-system-for-write) | |
708 (process (open-network-stream name buffer server port))) | |
709 (when process | |
710 (while (and (memq (process-status process) '(open run)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
711 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
31717 | 712 (goto-char (point-min)) |
713 (not (imap-parse-greeting))) | |
714 (accept-process-output process 1) | |
715 (sit-for 1)) | |
716 (and imap-log | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
717 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 718 (imap-disable-multibyte) |
719 (buffer-disable-undo) | |
720 (goto-char (point-max)) | |
721 (insert-buffer-substring buffer))) | |
722 (when (memq (process-status process) '(open run)) | |
723 process)))) | |
724 | |
725 (defun imap-shell-p (buffer) | |
726 nil) | |
727 | |
728 (defun imap-shell-open (name buffer server port) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
729 (let ((cmds (if (listp imap-shell-program) imap-shell-program |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
730 (list imap-shell-program))) |
31717 | 731 cmd done) |
732 (while (and (not done) (setq cmd (pop cmds))) | |
733 (message "imap: Opening IMAP connection with `%s'..." cmd) | |
734 (setq imap-client-eol "\n") | |
735 (let* ((port (or port imap-default-port)) | |
736 (coding-system-for-read imap-coding-system-for-read) | |
737 (coding-system-for-write imap-coding-system-for-write) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
738 (process (start-process |
31717 | 739 name buffer shell-file-name shell-command-switch |
740 (format-spec | |
741 cmd | |
742 (format-spec-make | |
743 ?s server | |
744 ?g imap-shell-host | |
745 ?p (number-to-string port) | |
746 ?l imap-default-user))))) | |
747 (when process | |
748 (while (and (memq (process-status process) '(open run)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
749 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
750 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
751 (forward-line -1) |
31717 | 752 (not (imap-parse-greeting))) |
753 (accept-process-output process 1) | |
754 (sit-for 1)) | |
755 (and imap-log | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
756 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 757 (imap-disable-multibyte) |
758 (buffer-disable-undo) | |
759 (goto-char (point-max)) | |
760 (insert-buffer-substring buffer))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
761 (erase-buffer) |
31717 | 762 (when (memq (process-status process) '(open run)) |
763 (setq done process))))) | |
764 (if done | |
765 (progn | |
766 (message "imap: Opening IMAP connection with `%s'...done" cmd) | |
767 done) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
768 (message "imap: Opening IMAP connection with `%s'...failed" cmd) |
31717 | 769 nil))) |
770 | |
771 (defun imap-starttls-p (buffer) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
772 (imap-capability 'STARTTLS buffer)) |
31717 | 773 |
774 (defun imap-starttls-open (name buffer server port) | |
775 (let* ((port (or port imap-default-port)) | |
776 (coding-system-for-read imap-coding-system-for-read) | |
777 (coding-system-for-write imap-coding-system-for-write) | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
778 (process (starttls-open-stream name buffer server port)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
779 done tls-info) |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
780 (message "imap: Connecting with STARTTLS...") |
31717 | 781 (when process |
782 (while (and (memq (process-status process) '(open run)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
783 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
784 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
785 (forward-line -1) |
31717 | 786 (not (imap-parse-greeting))) |
787 (accept-process-output process 1) | |
788 (sit-for 1)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
789 (imap-send-command "STARTTLS") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
790 (while (and (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
791 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
792 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
793 (forward-line -1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
794 (not (re-search-forward "[0-9]+ OK.*\r?\n" nil t))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
795 (accept-process-output process 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
796 (sit-for 1)) |
31717 | 797 (and imap-log |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
798 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 799 (buffer-disable-undo) |
800 (goto-char (point-max)) | |
801 (insert-buffer-substring buffer))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
802 (when (and (setq tls-info (starttls-negotiate process)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
803 (memq (process-status process) '(open run))) |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
804 (setq done process))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
805 (if (stringp tls-info) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
806 (message "imap: STARTTLS info: %s" tls-info)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
807 (message "imap: Connecting with STARTTLS...%s" (if done "done" "failed")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
808 done)) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
809 |
31717 | 810 ;; Server functions; authenticator stuff: |
811 | |
812 (defun imap-interactive-login (buffer loginfunc) | |
813 "Login to server in BUFFER. | |
814 LOGINFUNC is passed a username and a password, it should return t if | |
48588 | 815 it where successful authenticating itself to the server, nil otherwise. |
31717 | 816 Returns t if login was successful, nil otherwise." |
817 (with-current-buffer buffer | |
41516
52c9115c94be
(imap-interactive-login, imap-open, imap-authenticate):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39064
diff
changeset
|
818 (make-local-variable 'imap-username) |
52c9115c94be
(imap-interactive-login, imap-open, imap-authenticate):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39064
diff
changeset
|
819 (make-local-variable 'imap-password) |
31717 | 820 (let (user passwd ret) |
821 ;; (condition-case () | |
822 (while (or (not user) (not passwd)) | |
823 (setq user (or imap-username | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
824 (read-from-minibuffer |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
825 (concat "IMAP username for " imap-server |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
826 " (using stream `" (symbol-name imap-stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
827 "'): ") |
31717 | 828 (or user imap-default-user)))) |
829 (setq passwd (or imap-password | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
830 (read-passwd |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
831 (concat "IMAP password for " user "@" |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
832 imap-server " (using authenticator `" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
833 (symbol-name imap-auth) "'): ")))) |
31717 | 834 (when (and user passwd) |
835 (if (funcall loginfunc user passwd) | |
836 (progn | |
837 (setq ret t | |
838 imap-username user) | |
57581
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
839 (when (and (not imap-password) |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
840 (or imap-store-password |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
841 (y-or-n-p "Store password for this session? "))) |
645f020dcc8a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
842 (setq imap-password passwd))) |
31717 | 843 (message "Login failed...") |
844 (setq passwd nil) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
845 (setq imap-password nil) |
31717 | 846 (sit-for 1)))) |
847 ;; (quit (with-current-buffer buffer | |
848 ;; (setq user nil | |
849 ;; passwd nil))) | |
850 ;; (error (with-current-buffer buffer | |
851 ;; (setq user nil | |
852 ;; passwd nil)))) | |
853 ret))) | |
854 | |
855 (defun imap-gssapi-auth-p (buffer) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
856 (eq imap-stream 'gssapi)) |
31717 | 857 |
858 (defun imap-gssapi-auth (buffer) | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
859 (message "imap: Authenticating using GSSAPI...%s" |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
860 (if (eq imap-stream 'gssapi) "done" "failed")) |
31717 | 861 (eq imap-stream 'gssapi)) |
862 | |
863 (defun imap-kerberos4-auth-p (buffer) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
864 (and (imap-capability 'AUTH=KERBEROS_V4 buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
865 (eq imap-stream 'kerberos4))) |
31717 | 866 |
867 (defun imap-kerberos4-auth (buffer) | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
868 (message "imap: Authenticating using Kerberos 4...%s" |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
869 (if (eq imap-stream 'kerberos4) "done" "failed")) |
31717 | 870 (eq imap-stream 'kerberos4)) |
871 | |
872 (defun imap-cram-md5-p (buffer) | |
873 (imap-capability 'AUTH=CRAM-MD5 buffer)) | |
874 | |
875 (defun imap-cram-md5-auth (buffer) | |
876 "Login to server using the AUTH CRAM-MD5 method." | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
877 (message "imap: Authenticating using CRAM-MD5...") |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
878 (let ((done (imap-interactive-login |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
879 buffer |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
880 (lambda (user passwd) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
881 (imap-ok-p |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
882 (imap-send-command-wait |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
883 (list |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
884 "AUTHENTICATE CRAM-MD5" |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
885 (lambda (challenge) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
886 (let* ((decoded (base64-decode-string challenge)) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
887 (hash (rfc2104-hash 'md5 64 16 passwd decoded)) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
888 (response (concat user " " hash)) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
889 (encoded (base64-encode-string response))) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
890 encoded))))))))) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
891 (if done |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
892 (message "imap: Authenticating using CRAM-MD5...done") |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
893 (message "imap: Authenticating using CRAM-MD5...failed")))) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
894 |
31717 | 895 (defun imap-login-p (buffer) |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
896 (and (not (imap-capability 'LOGINDISABLED buffer)) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
897 (not (imap-capability 'X-LOGIN-CMD-DISABLED buffer)))) |
31717 | 898 |
899 (defun imap-login-auth (buffer) | |
900 "Login to server using the LOGIN command." | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
901 (message "imap: Plaintext authentication...") |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
902 (imap-interactive-login buffer |
31717 | 903 (lambda (user passwd) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
904 (imap-ok-p (imap-send-command-wait |
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
905 (concat "LOGIN \"" user "\" \"" |
31717 | 906 passwd "\"")))))) |
907 | |
908 (defun imap-anonymous-p (buffer) | |
909 t) | |
910 | |
911 (defun imap-anonymous-auth (buffer) | |
48588 | 912 (message "imap: Logging in anonymously...") |
31717 | 913 (with-current-buffer buffer |
914 (imap-ok-p (imap-send-command-wait | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
915 (concat "LOGIN anonymous \"" (concat (user-login-name) "@" |
31717 | 916 (system-name)) "\""))))) |
917 | |
918 (defun imap-digest-md5-p (buffer) | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
919 (and (imap-capability 'AUTH=DIGEST-MD5 buffer) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
920 (condition-case () |
31717 | 921 (require 'digest-md5) |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
922 (error nil)))) |
31717 | 923 |
924 (defun imap-digest-md5-auth (buffer) | |
925 "Login to server using the AUTH DIGEST-MD5 method." | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
926 (message "imap: Authenticating using DIGEST-MD5...") |
31717 | 927 (imap-interactive-login |
928 buffer | |
929 (lambda (user passwd) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
930 (let ((tag |
31717 | 931 (imap-send-command |
932 (list | |
933 "AUTHENTICATE DIGEST-MD5" | |
934 (lambda (challenge) | |
935 (digest-md5-parse-digest-challenge | |
936 (base64-decode-string challenge)) | |
937 (let* ((digest-uri | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
938 (digest-md5-digest-uri |
31717 | 939 "imap" (digest-md5-challenge 'realm))) |
940 (response | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
941 (digest-md5-digest-response |
31717 | 942 user passwd digest-uri))) |
943 (base64-encode-string response 'no-line-break)))) | |
944 ))) | |
945 (if (not (eq (imap-wait-for-tag tag) 'INCOMPLETE)) | |
946 nil | |
947 (setq imap-continuation nil) | |
948 (imap-send-command-1 "") | |
949 (imap-ok-p (imap-wait-for-tag tag))))))) | |
950 | |
951 ;; Server functions: | |
952 | |
953 (defun imap-open-1 (buffer) | |
954 (with-current-buffer buffer | |
955 (erase-buffer) | |
956 (setq imap-current-mailbox nil | |
957 imap-current-message nil | |
958 imap-state 'initial | |
959 imap-process (condition-case () | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
960 (funcall (nth 2 (assq imap-stream |
31717 | 961 imap-stream-alist)) |
962 "imap" buffer imap-server imap-port) | |
963 ((error quit) nil))) | |
964 (when imap-process | |
965 (set-process-filter imap-process 'imap-arrival-filter) | |
966 (set-process-sentinel imap-process 'imap-sentinel) | |
967 (while (and (eq imap-state 'initial) | |
968 (memq (process-status imap-process) '(open run))) | |
969 (message "Waiting for response from %s..." imap-server) | |
970 (accept-process-output imap-process 1)) | |
971 (message "Waiting for response from %s...done" imap-server) | |
972 (and (memq (process-status imap-process) '(open run)) | |
973 imap-process)))) | |
974 | |
975 (defun imap-open (server &optional port stream auth buffer) | |
976 "Open a IMAP connection to host SERVER at PORT returning a buffer. | |
977 If PORT is unspecified, a default value is used (143 except | |
978 for SSL which use 993). | |
979 STREAM indicates the stream to use, see `imap-streams' for available | |
980 streams. If nil, it choices the best stream the server is capable of. | |
981 AUTH indicates authenticator to use, see `imap-authenticators' for | |
982 available authenticators. If nil, it choices the best stream the | |
983 server is capable of. | |
984 BUFFER can be a buffer or a name of a buffer, which is created if | |
48588 | 985 necessary. If nil, the buffer name is generated." |
31717 | 986 (setq buffer (or buffer (format " *imap* %s:%d" server (or port 0)))) |
987 (with-current-buffer (get-buffer-create buffer) | |
988 (if (imap-opened buffer) | |
989 (imap-close buffer)) | |
41516
52c9115c94be
(imap-interactive-login, imap-open, imap-authenticate):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39064
diff
changeset
|
990 (mapcar 'make-local-variable imap-local-variables) |
31717 | 991 (imap-disable-multibyte) |
992 (buffer-disable-undo) | |
993 (setq imap-server (or server imap-server)) | |
994 (setq imap-port (or port imap-port)) | |
995 (setq imap-auth (or auth imap-auth)) | |
996 (setq imap-stream (or stream imap-stream)) | |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
997 (message "imap: Connecting to %s..." imap-server) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
998 (if (null (let ((imap-stream (or imap-stream imap-default-stream))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
999 (imap-open-1 buffer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1000 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1001 (message "imap: Connecting to %s...failed" imap-server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1002 nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1003 (when (null imap-stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1004 ;; Need to choose stream. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1005 (let ((streams imap-streams)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1006 (while (setq stream (pop streams)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1007 ;; OK to use this stream? |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1008 (when (funcall (nth 1 (assq stream imap-stream-alist)) buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1009 ;; Stream changed? |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1010 (if (not (eq imap-default-stream stream)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1011 (with-current-buffer (get-buffer-create |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1012 (generate-new-buffer-name " *temp*")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1013 (mapcar 'make-local-variable imap-local-variables) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1014 (imap-disable-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1015 (buffer-disable-undo) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1016 (setq imap-server (or server imap-server)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1017 (setq imap-port (or port imap-port)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1018 (setq imap-auth (or auth imap-auth)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1019 (message "imap: Reconnecting with stream `%s'..." stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1020 (if (null (let ((imap-stream stream)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1021 (imap-open-1 (current-buffer)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1022 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1023 (kill-buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1024 (message |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1025 "imap: Reconnecting with stream `%s'...failed" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1026 stream)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1027 ;; We're done, kill the first connection |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1028 (imap-close buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1029 (kill-buffer buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1030 (rename-buffer buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1031 (message "imap: Reconnecting with stream `%s'...done" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1032 stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1033 (setq imap-stream stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1034 (setq imap-capability nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1035 (setq streams nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1036 ;; We're done |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1037 (message "imap: Connecting to %s...done" imap-server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1038 (setq imap-stream stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1039 (setq imap-capability nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1040 (setq streams nil)))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1041 (when (imap-opened buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1042 (setq imap-mailbox-data (make-vector imap-mailbox-prime 0))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1043 (when imap-stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1044 buffer)))) |
31717 | 1045 |
1046 (defun imap-opened (&optional buffer) | |
1047 "Return non-nil if connection to imap server in BUFFER is open. | |
1048 If BUFFER is nil then the current buffer is used." | |
1049 (and (setq buffer (get-buffer (or buffer (current-buffer)))) | |
1050 (buffer-live-p buffer) | |
1051 (with-current-buffer buffer | |
1052 (and imap-process | |
1053 (memq (process-status imap-process) '(open run)))))) | |
1054 | |
1055 (defun imap-authenticate (&optional user passwd buffer) | |
1056 "Authenticate to server in BUFFER, using current buffer if nil. | |
1057 It uses the authenticator specified when opening the server. If the | |
1058 authenticator requires username/passwords, they are queried from the | |
1059 user and optionally stored in the buffer. If USER and/or PASSWD is | |
1060 specified, the user will not be questioned and the username and/or | |
1061 password is remembered in the buffer." | |
1062 (with-current-buffer (or buffer (current-buffer)) | |
1063 (if (not (eq imap-state 'nonauth)) | |
1064 (or (eq imap-state 'auth) | |
1065 (eq imap-state 'select) | |
1066 (eq imap-state 'examine)) | |
41516
52c9115c94be
(imap-interactive-login, imap-open, imap-authenticate):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39064
diff
changeset
|
1067 (make-local-variable 'imap-username) |
52c9115c94be
(imap-interactive-login, imap-open, imap-authenticate):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39064
diff
changeset
|
1068 (make-local-variable 'imap-password) |
31717 | 1069 (if user (setq imap-username user)) |
1070 (if passwd (setq imap-password passwd)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1071 (if imap-auth |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1072 (and (funcall (nth 2 (assq imap-auth |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1073 imap-authenticator-alist)) buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1074 (setq imap-state 'auth)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1075 ;; Choose authenticator. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1076 (let ((auths imap-authenticators) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1077 auth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1078 (while (setq auth (pop auths)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1079 ;; OK to use authenticator? |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1080 (when (funcall (nth 1 (assq auth imap-authenticator-alist)) buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1081 (message "imap: Authenticating to `%s' using `%s'..." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1082 imap-server auth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1083 (setq imap-auth auth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1084 (if (funcall (nth 2 (assq auth imap-authenticator-alist)) buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1085 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1086 (message "imap: Authenticating to `%s' using `%s'...done" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1087 imap-server auth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1088 (setq auths nil)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1089 (message "imap: Authenticating to `%s' using `%s'...failed" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1090 imap-server auth))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1091 imap-state)))) |
31717 | 1092 |
1093 (defun imap-close (&optional buffer) | |
1094 "Close connection to server in BUFFER. | |
1095 If BUFFER is nil, the current buffer is used." | |
1096 (with-current-buffer (or buffer (current-buffer)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1097 (when (imap-opened) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1098 (condition-case nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1099 (imap-send-command-wait "LOGOUT") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1100 (quit nil))) |
31717 | 1101 (when (and imap-process |
1102 (memq (process-status imap-process) '(open run))) | |
1103 (delete-process imap-process)) | |
1104 (setq imap-current-mailbox nil | |
1105 imap-current-message nil | |
1106 imap-process nil) | |
1107 (erase-buffer) | |
1108 t)) | |
1109 | |
1110 (defun imap-capability (&optional identifier buffer) | |
1111 "Return a list of identifiers which server in BUFFER support. | |
1112 If IDENTIFIER, return non-nil if it's among the servers capabilities. | |
1113 If BUFFER is nil, the current buffer is assumed." | |
1114 (with-current-buffer (or buffer (current-buffer)) | |
1115 (unless imap-capability | |
1116 (unless (imap-ok-p (imap-send-command-wait "CAPABILITY")) | |
1117 (setq imap-capability '(IMAP2)))) | |
1118 (if identifier | |
1119 (memq (intern (upcase (symbol-name identifier))) imap-capability) | |
1120 imap-capability))) | |
1121 | |
1122 (defun imap-namespace (&optional buffer) | |
1123 "Return a namespace hierarchy at server in BUFFER. | |
1124 If BUFFER is nil, the current buffer is assumed." | |
1125 (with-current-buffer (or buffer (current-buffer)) | |
1126 (unless imap-namespace | |
1127 (when (imap-capability 'NAMESPACE) | |
1128 (imap-send-command-wait "NAMESPACE"))) | |
1129 imap-namespace)) | |
1130 | |
1131 (defun imap-send-command-wait (command &optional buffer) | |
1132 (imap-wait-for-tag (imap-send-command command buffer) buffer)) | |
1133 | |
1134 | |
1135 ;; Mailbox functions: | |
1136 | |
1137 (defun imap-mailbox-put (propname value &optional mailbox buffer) | |
1138 (with-current-buffer (or buffer (current-buffer)) | |
1139 (if imap-mailbox-data | |
1140 (put (intern (or mailbox imap-current-mailbox) imap-mailbox-data) | |
1141 propname value) | |
1142 (error "Imap-mailbox-data is nil, prop %s value %s mailbox %s buffer %s" | |
1143 propname value mailbox (current-buffer))) | |
1144 t)) | |
1145 | |
1146 (defsubst imap-mailbox-get-1 (propname &optional mailbox) | |
1147 (get (intern-soft (or mailbox imap-current-mailbox) imap-mailbox-data) | |
1148 propname)) | |
1149 | |
1150 (defun imap-mailbox-get (propname &optional mailbox buffer) | |
1151 (let ((mailbox (imap-utf7-encode mailbox))) | |
1152 (with-current-buffer (or buffer (current-buffer)) | |
1153 (imap-mailbox-get-1 propname (or mailbox imap-current-mailbox))))) | |
1154 | |
1155 (defun imap-mailbox-map-1 (func &optional mailbox-decoder buffer) | |
1156 (with-current-buffer (or buffer (current-buffer)) | |
1157 (let (result) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1158 (mapatoms |
31717 | 1159 (lambda (s) |
1160 (push (funcall func (if mailbox-decoder | |
1161 (funcall mailbox-decoder (symbol-name s)) | |
1162 (symbol-name s))) result)) | |
1163 imap-mailbox-data) | |
1164 result))) | |
1165 | |
1166 (defun imap-mailbox-map (func &optional buffer) | |
1167 "Map a function across each mailbox in `imap-mailbox-data', returning a list. | |
1168 Function should take a mailbox name (a string) as | |
1169 the only argument." | |
1170 (imap-mailbox-map-1 func 'imap-utf7-decode buffer)) | |
1171 | |
1172 (defun imap-current-mailbox (&optional buffer) | |
1173 (with-current-buffer (or buffer (current-buffer)) | |
1174 (imap-utf7-decode imap-current-mailbox))) | |
1175 | |
1176 (defun imap-current-mailbox-p-1 (mailbox &optional examine) | |
1177 (and (string= mailbox imap-current-mailbox) | |
1178 (or (and examine | |
1179 (eq imap-state 'examine)) | |
1180 (and (not examine) | |
1181 (eq imap-state 'selected))))) | |
1182 | |
1183 (defun imap-current-mailbox-p (mailbox &optional examine buffer) | |
1184 (with-current-buffer (or buffer (current-buffer)) | |
1185 (imap-current-mailbox-p-1 (imap-utf7-encode mailbox) examine))) | |
1186 | |
1187 (defun imap-mailbox-select-1 (mailbox &optional examine) | |
1188 "Select MAILBOX on server in BUFFER. | |
1189 If EXAMINE is non-nil, do a read-only select." | |
1190 (if (imap-current-mailbox-p-1 mailbox examine) | |
1191 imap-current-mailbox | |
1192 (setq imap-current-mailbox mailbox) | |
1193 (if (imap-ok-p (imap-send-command-wait | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1194 (concat (if examine "EXAMINE" "SELECT") " \"" |
31717 | 1195 mailbox "\""))) |
1196 (progn | |
1197 (setq imap-message-data (make-vector imap-message-prime 0) | |
1198 imap-state (if examine 'examine 'selected)) | |
1199 imap-current-mailbox) | |
1200 ;; Failed SELECT/EXAMINE unselects current mailbox | |
1201 (setq imap-current-mailbox nil)))) | |
1202 | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1203 (defun imap-mailbox-select (mailbox &optional examine buffer) |
31717 | 1204 (with-current-buffer (or buffer (current-buffer)) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1205 (imap-utf7-decode |
31717 | 1206 (imap-mailbox-select-1 (imap-utf7-encode mailbox) examine)))) |
1207 | |
1208 (defun imap-mailbox-examine-1 (mailbox &optional buffer) | |
1209 (with-current-buffer (or buffer (current-buffer)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1210 (imap-mailbox-select-1 mailbox 'examine))) |
31717 | 1211 |
1212 (defun imap-mailbox-examine (mailbox &optional buffer) | |
1213 "Examine MAILBOX on server in BUFFER." | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1214 (imap-mailbox-select mailbox 'examine buffer)) |
31717 | 1215 |
1216 (defun imap-mailbox-unselect (&optional buffer) | |
1217 "Close current folder in BUFFER, without expunging articles." | |
1218 (with-current-buffer (or buffer (current-buffer)) | |
1219 (when (or (eq imap-state 'auth) | |
1220 (and (imap-capability 'UNSELECT) | |
1221 (imap-ok-p (imap-send-command-wait "UNSELECT"))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1222 (and (imap-ok-p |
31717 | 1223 (imap-send-command-wait (concat "EXAMINE \"" |
1224 imap-current-mailbox | |
1225 "\""))) | |
1226 (imap-ok-p (imap-send-command-wait "CLOSE")))) | |
1227 (setq imap-current-mailbox nil | |
1228 imap-message-data nil | |
1229 imap-state 'auth) | |
1230 t))) | |
1231 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1232 (defun imap-mailbox-expunge (&optional asynch buffer) |
31717 | 1233 "Expunge articles in current folder in BUFFER. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1234 If ASYNCH, do not wait for succesful completion of the command. |
31717 | 1235 If BUFFER is nil the current buffer is assumed." |
1236 (with-current-buffer (or buffer (current-buffer)) | |
1237 (when (and imap-current-mailbox (not (eq imap-state 'examine))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1238 (if asynch |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1239 (imap-send-command "EXPUNGE") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1240 (imap-ok-p (imap-send-command-wait "EXPUNGE")))))) |
31717 | 1241 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1242 (defun imap-mailbox-close (&optional asynch buffer) |
31717 | 1243 "Expunge articles and close current folder in BUFFER. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1244 If ASYNCH, do not wait for succesful completion of the command. |
31717 | 1245 If BUFFER is nil the current buffer is assumed." |
1246 (with-current-buffer (or buffer (current-buffer)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1247 (when imap-current-mailbox |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1248 (if asynch |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1249 (imap-add-callback (imap-send-command "CLOSE") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1250 `(lambda (tag status) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1251 (message "IMAP mailbox `%s' closed... %s" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1252 imap-current-mailbox status) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1253 (when (eq ,imap-current-mailbox |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1254 imap-current-mailbox) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1255 ;; Don't wipe out data if another mailbox |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1256 ;; was selected... |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1257 (setq imap-current-mailbox nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1258 imap-message-data nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1259 imap-state 'auth)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1260 (when (imap-ok-p (imap-send-command-wait "CLOSE")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1261 (setq imap-current-mailbox nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1262 imap-message-data nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1263 imap-state 'auth))) |
31717 | 1264 t))) |
1265 | |
1266 (defun imap-mailbox-create-1 (mailbox) | |
1267 (imap-ok-p (imap-send-command-wait (list "CREATE \"" mailbox "\"")))) | |
1268 | |
1269 (defun imap-mailbox-create (mailbox &optional buffer) | |
1270 "Create MAILBOX on server in BUFFER. | |
1271 If BUFFER is nil the current buffer is assumed." | |
1272 (with-current-buffer (or buffer (current-buffer)) | |
1273 (imap-mailbox-create-1 (imap-utf7-encode mailbox)))) | |
1274 | |
1275 (defun imap-mailbox-delete (mailbox &optional buffer) | |
1276 "Delete MAILBOX on server in BUFFER. | |
1277 If BUFFER is nil the current buffer is assumed." | |
1278 (let ((mailbox (imap-utf7-encode mailbox))) | |
1279 (with-current-buffer (or buffer (current-buffer)) | |
1280 (imap-ok-p | |
1281 (imap-send-command-wait (list "DELETE \"" mailbox "\"")))))) | |
1282 | |
1283 (defun imap-mailbox-rename (oldname newname &optional buffer) | |
1284 "Rename mailbox OLDNAME to NEWNAME on server in BUFFER. | |
1285 If BUFFER is nil the current buffer is assumed." | |
1286 (let ((oldname (imap-utf7-encode oldname)) | |
1287 (newname (imap-utf7-encode newname))) | |
1288 (with-current-buffer (or buffer (current-buffer)) | |
1289 (imap-ok-p | |
1290 (imap-send-command-wait (list "RENAME \"" oldname "\" " | |
1291 "\"" newname "\"")))))) | |
1292 | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1293 (defun imap-mailbox-lsub (&optional root reference add-delimiter buffer) |
31717 | 1294 "Return a list of subscribed mailboxes on server in BUFFER. |
1295 If ROOT is non-nil, only list matching mailboxes. If ADD-DELIMITER is | |
1296 non-nil, a hierarchy delimiter is added to root. REFERENCE is a | |
1297 implementation-specific string that has to be passed to lsub command." | |
1298 (with-current-buffer (or buffer (current-buffer)) | |
1299 ;; Make sure we know the hierarchy separator for root's hierarchy | |
1300 (when (and add-delimiter (null (imap-mailbox-get-1 'delimiter root))) | |
1301 (imap-send-command-wait (concat "LIST \"" reference "\" \"" | |
1302 (imap-utf7-encode root) "\""))) | |
1303 ;; clear list data (NB not delimiter and other stuff) | |
1304 (imap-mailbox-map-1 (lambda (mailbox) | |
1305 (imap-mailbox-put 'lsub nil mailbox))) | |
1306 (when (imap-ok-p | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1307 (imap-send-command-wait |
31717 | 1308 (concat "LSUB \"" reference "\" \"" (imap-utf7-encode root) |
1309 (and add-delimiter (imap-mailbox-get-1 'delimiter root)) | |
1310 "%\""))) | |
1311 (let (out) | |
1312 (imap-mailbox-map-1 (lambda (mailbox) | |
1313 (when (imap-mailbox-get-1 'lsub mailbox) | |
1314 (push (imap-utf7-decode mailbox) out)))) | |
1315 (nreverse out))))) | |
1316 | |
1317 (defun imap-mailbox-list (root &optional reference add-delimiter buffer) | |
1318 "Return a list of mailboxes matching ROOT on server in BUFFER. | |
1319 If ADD-DELIMITER is non-nil, a hierarchy delimiter is added to | |
1320 root. REFERENCE is a implementation-specific string that has to be | |
1321 passed to list command." | |
1322 (with-current-buffer (or buffer (current-buffer)) | |
1323 ;; Make sure we know the hierarchy separator for root's hierarchy | |
1324 (when (and add-delimiter (null (imap-mailbox-get-1 'delimiter root))) | |
1325 (imap-send-command-wait (concat "LIST \"" reference "\" \"" | |
1326 (imap-utf7-encode root) "\""))) | |
1327 ;; clear list data (NB not delimiter and other stuff) | |
1328 (imap-mailbox-map-1 (lambda (mailbox) | |
1329 (imap-mailbox-put 'list nil mailbox))) | |
1330 (when (imap-ok-p | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1331 (imap-send-command-wait |
31717 | 1332 (concat "LIST \"" reference "\" \"" (imap-utf7-encode root) |
1333 (and add-delimiter (imap-mailbox-get-1 'delimiter root)) | |
1334 "%\""))) | |
1335 (let (out) | |
1336 (imap-mailbox-map-1 (lambda (mailbox) | |
1337 (when (imap-mailbox-get-1 'list mailbox) | |
1338 (push (imap-utf7-decode mailbox) out)))) | |
1339 (nreverse out))))) | |
1340 | |
1341 (defun imap-mailbox-subscribe (mailbox &optional buffer) | |
1342 "Send the SUBSCRIBE command on the mailbox to server in BUFFER. | |
1343 Returns non-nil if successful." | |
1344 (with-current-buffer (or buffer (current-buffer)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1345 (imap-ok-p (imap-send-command-wait (concat "SUBSCRIBE \"" |
31717 | 1346 (imap-utf7-encode mailbox) |
1347 "\""))))) | |
1348 | |
1349 (defun imap-mailbox-unsubscribe (mailbox &optional buffer) | |
1350 "Send the SUBSCRIBE command on the mailbox to server in BUFFER. | |
1351 Returns non-nil if successful." | |
1352 (with-current-buffer (or buffer (current-buffer)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1353 (imap-ok-p (imap-send-command-wait (concat "UNSUBSCRIBE " |
31717 | 1354 (imap-utf7-encode mailbox) |
1355 "\""))))) | |
1356 | |
1357 (defun imap-mailbox-status (mailbox items &optional buffer) | |
1358 "Get status items ITEM in MAILBOX from server in BUFFER. | |
1359 ITEMS can be a symbol or a list of symbols, valid symbols are one of | |
1360 the STATUS data items -- ie 'messages, 'recent, 'uidnext, 'uidvalidity | |
1361 or 'unseen. If ITEMS is a list of symbols, a list of values is | |
49474
a53b597e29e0
(imap-mailbox-status): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
48588
diff
changeset
|
1362 returned, if ITEMS is a symbol only its value is returned." |
31717 | 1363 (with-current-buffer (or buffer (current-buffer)) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1364 (when (imap-ok-p |
31717 | 1365 (imap-send-command-wait (list "STATUS \"" |
1366 (imap-utf7-encode mailbox) | |
1367 "\" " | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1368 (upcase |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1369 (format "%s" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1370 (if (listp items) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1371 items |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1372 (list items))))))) |
31717 | 1373 (if (listp items) |
1374 (mapcar (lambda (item) | |
1375 (imap-mailbox-get item mailbox)) | |
1376 items) | |
1377 (imap-mailbox-get items mailbox))))) | |
1378 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1379 (defun imap-mailbox-status-asynch (mailbox items &optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1380 "Send status item request ITEM on MAILBOX to server in BUFFER. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1381 ITEMS can be a symbol or a list of symbols, valid symbols are one of |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1382 the STATUS data items -- ie 'messages, 'recent, 'uidnext, 'uidvalidity |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1383 or 'unseen. The IMAP command tag is returned." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1384 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1385 (imap-send-command (list "STATUS \"" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1386 (imap-utf7-encode mailbox) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1387 "\" " |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1388 (format "%s" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1389 (if (listp items) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1390 items |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1391 (list items))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1392 |
31717 | 1393 (defun imap-mailbox-acl-get (&optional mailbox buffer) |
1394 "Get ACL on mailbox from server in BUFFER." | |
1395 (let ((mailbox (imap-utf7-encode mailbox))) | |
1396 (with-current-buffer (or buffer (current-buffer)) | |
1397 (when (imap-ok-p | |
1398 (imap-send-command-wait (list "GETACL \"" | |
1399 (or mailbox imap-current-mailbox) | |
1400 "\""))) | |
1401 (imap-mailbox-get-1 'acl (or mailbox imap-current-mailbox)))))) | |
1402 | |
1403 (defun imap-mailbox-acl-set (identifier rights &optional mailbox buffer) | |
1404 "Change/set ACL for IDENTIFIER to RIGHTS in MAILBOX from server in BUFFER." | |
1405 (let ((mailbox (imap-utf7-encode mailbox))) | |
1406 (with-current-buffer (or buffer (current-buffer)) | |
1407 (imap-ok-p | |
1408 (imap-send-command-wait (list "SETACL \"" | |
1409 (or mailbox imap-current-mailbox) | |
1410 "\" " | |
1411 identifier | |
1412 " " | |
1413 rights)))))) | |
1414 | |
1415 (defun imap-mailbox-acl-delete (identifier &optional mailbox buffer) | |
1416 "Removes any <identifier,rights> pair for IDENTIFIER in MAILBOX from server in BUFFER." | |
1417 (let ((mailbox (imap-utf7-encode mailbox))) | |
1418 (with-current-buffer (or buffer (current-buffer)) | |
1419 (imap-ok-p | |
1420 (imap-send-command-wait (list "DELETEACL \"" | |
1421 (or mailbox imap-current-mailbox) | |
1422 "\" " | |
1423 identifier)))))) | |
1424 | |
1425 | |
1426 ;; Message functions: | |
1427 | |
1428 (defun imap-current-message (&optional buffer) | |
1429 (with-current-buffer (or buffer (current-buffer)) | |
1430 imap-current-message)) | |
1431 | |
1432 (defun imap-list-to-message-set (list) | |
1433 (mapconcat (lambda (item) | |
1434 (number-to-string item)) | |
1435 (if (listp list) | |
1436 list | |
1437 (list list)) | |
1438 ",")) | |
1439 | |
1440 (defun imap-range-to-message-set (range) | |
1441 (mapconcat | |
1442 (lambda (item) | |
1443 (if (consp item) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1444 (format "%d:%d" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1445 (car item) (cdr item)) |
31717 | 1446 (format "%d" item))) |
1447 (if (and (listp range) (not (listp (cdr range)))) | |
1448 (list range) ;; make (1 . 2) into ((1 . 2)) | |
1449 range) | |
1450 ",")) | |
1451 | |
1452 (defun imap-fetch-asynch (uids props &optional nouidfetch buffer) | |
1453 (with-current-buffer (or buffer (current-buffer)) | |
1454 (imap-send-command (format "%sFETCH %s %s" (if nouidfetch "" "UID ") | |
1455 (if (listp uids) | |
1456 (imap-list-to-message-set uids) | |
1457 uids) | |
1458 props)))) | |
1459 | |
1460 (defun imap-fetch (uids props &optional receive nouidfetch buffer) | |
1461 "Fetch properties PROPS from message set UIDS from server in BUFFER. | |
1462 UIDS can be a string, number or a list of numbers. If RECEIVE | |
59289 | 1463 is non-nil return these properties." |
31717 | 1464 (with-current-buffer (or buffer (current-buffer)) |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1465 (when (imap-ok-p (imap-send-command-wait |
31717 | 1466 (format "%sFETCH %s %s" (if nouidfetch "" "UID ") |
1467 (if (listp uids) | |
1468 (imap-list-to-message-set uids) | |
1469 uids) | |
1470 props))) | |
1471 (if (or (null receive) (stringp uids)) | |
1472 t | |
1473 (if (listp uids) | |
1474 (mapcar (lambda (uid) | |
1475 (if (listp receive) | |
1476 (mapcar (lambda (prop) | |
1477 (imap-message-get uid prop)) | |
1478 receive) | |
1479 (imap-message-get uid receive))) | |
1480 uids) | |
1481 (imap-message-get uids receive)))))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1482 |
31717 | 1483 (defun imap-message-put (uid propname value &optional buffer) |
1484 (with-current-buffer (or buffer (current-buffer)) | |
1485 (if imap-message-data | |
1486 (put (intern (number-to-string uid) imap-message-data) | |
1487 propname value) | |
1488 (error "Imap-message-data is nil, uid %s prop %s value %s buffer %s" | |
1489 uid propname value (current-buffer))) | |
1490 t)) | |
1491 | |
1492 (defun imap-message-get (uid propname &optional buffer) | |
1493 (with-current-buffer (or buffer (current-buffer)) | |
1494 (get (intern-soft (number-to-string uid) imap-message-data) | |
1495 propname))) | |
1496 | |
1497 (defun imap-message-map (func propname &optional buffer) | |
1498 "Map a function across each mailbox in `imap-message-data', returning a list." | |
1499 (with-current-buffer (or buffer (current-buffer)) | |
1500 (let (result) | |
1501 (mapatoms | |
1502 (lambda (s) | |
1503 (push (funcall func (get s 'UID) (get s propname)) result)) | |
1504 imap-message-data) | |
1505 result))) | |
1506 | |
1507 (defmacro imap-message-envelope-date (uid &optional buffer) | |
1508 `(with-current-buffer (or ,buffer (current-buffer)) | |
1509 (elt (imap-message-get ,uid 'ENVELOPE) 0))) | |
1510 | |
1511 (defmacro imap-message-envelope-subject (uid &optional buffer) | |
1512 `(with-current-buffer (or ,buffer (current-buffer)) | |
1513 (elt (imap-message-get ,uid 'ENVELOPE) 1))) | |
1514 | |
1515 (defmacro imap-message-envelope-from (uid &optional buffer) | |
1516 `(with-current-buffer (or ,buffer (current-buffer)) | |
1517 (elt (imap-message-get ,uid 'ENVELOPE) 2))) | |
1518 | |
1519 (defmacro imap-message-envelope-sender (uid &optional buffer) | |
1520 `(with-current-buffer (or ,buffer (current-buffer)) | |
1521 (elt (imap-message-get ,uid 'ENVELOPE) 3))) | |
1522 | |
1523 (defmacro imap-message-envelope-reply-to (uid &optional buffer) | |
1524 `(with-current-buffer (or ,buffer (current-buffer)) | |
1525 (elt (imap-message-get ,uid 'ENVELOPE) 4))) | |
1526 | |
1527 (defmacro imap-message-envelope-to (uid &optional buffer) | |
1528 `(with-current-buffer (or ,buffer (current-buffer)) | |
1529 (elt (imap-message-get ,uid 'ENVELOPE) 5))) | |
1530 | |
1531 (defmacro imap-message-envelope-cc (uid &optional buffer) | |
1532 `(with-current-buffer (or ,buffer (current-buffer)) | |
1533 (elt (imap-message-get ,uid 'ENVELOPE) 6))) | |
1534 | |
1535 (defmacro imap-message-envelope-bcc (uid &optional buffer) | |
1536 `(with-current-buffer (or ,buffer (current-buffer)) | |
1537 (elt (imap-message-get ,uid 'ENVELOPE) 7))) | |
1538 | |
1539 (defmacro imap-message-envelope-in-reply-to (uid &optional buffer) | |
1540 `(with-current-buffer (or ,buffer (current-buffer)) | |
1541 (elt (imap-message-get ,uid 'ENVELOPE) 8))) | |
1542 | |
1543 (defmacro imap-message-envelope-message-id (uid &optional buffer) | |
1544 `(with-current-buffer (or ,buffer (current-buffer)) | |
1545 (elt (imap-message-get ,uid 'ENVELOPE) 9))) | |
1546 | |
1547 (defmacro imap-message-body (uid &optional buffer) | |
1548 `(with-current-buffer (or ,buffer (current-buffer)) | |
1549 (imap-message-get ,uid 'BODY))) | |
1550 | |
1551 (defun imap-search (predicate &optional buffer) | |
1552 (with-current-buffer (or buffer (current-buffer)) | |
1553 (imap-mailbox-put 'search 'dummy) | |
1554 (when (imap-ok-p (imap-send-command-wait (concat "UID SEARCH " predicate))) | |
1555 (if (eq (imap-mailbox-get-1 'search imap-current-mailbox) 'dummy) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1556 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1557 (message "Missing SEARCH response to a SEARCH command (server not RFC compliant)...") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1558 nil) |
31717 | 1559 (imap-mailbox-get-1 'search imap-current-mailbox))))) |
1560 | |
1561 (defun imap-message-flag-permanent-p (flag &optional mailbox buffer) | |
1562 "Return t iff FLAG can be permanently (between IMAP sessions) saved on articles, in MAILBOX on server in BUFFER." | |
1563 (with-current-buffer (or buffer (current-buffer)) | |
1564 (or (member "\\*" (imap-mailbox-get 'permanentflags mailbox)) | |
1565 (member flag (imap-mailbox-get 'permanentflags mailbox))))) | |
1566 | |
1567 (defun imap-message-flags-set (articles flags &optional silent buffer) | |
1568 (when (and articles flags) | |
1569 (with-current-buffer (or buffer (current-buffer)) | |
1570 (imap-ok-p (imap-send-command-wait | |
1571 (concat "UID STORE " articles | |
1572 " FLAGS" (if silent ".SILENT") " (" flags ")")))))) | |
1573 | |
1574 (defun imap-message-flags-del (articles flags &optional silent buffer) | |
1575 (when (and articles flags) | |
1576 (with-current-buffer (or buffer (current-buffer)) | |
1577 (imap-ok-p (imap-send-command-wait | |
1578 (concat "UID STORE " articles | |
1579 " -FLAGS" (if silent ".SILENT") " (" flags ")")))))) | |
1580 | |
1581 (defun imap-message-flags-add (articles flags &optional silent buffer) | |
1582 (when (and articles flags) | |
1583 (with-current-buffer (or buffer (current-buffer)) | |
1584 (imap-ok-p (imap-send-command-wait | |
1585 (concat "UID STORE " articles | |
1586 " +FLAGS" (if silent ".SILENT") " (" flags ")")))))) | |
1587 | |
1588 (defun imap-message-copyuid-1 (mailbox) | |
1589 (if (imap-capability 'UIDPLUS) | |
1590 (list (nth 0 (imap-mailbox-get-1 'copyuid mailbox)) | |
1591 (string-to-number (nth 2 (imap-mailbox-get-1 'copyuid mailbox)))) | |
1592 (let ((old-mailbox imap-current-mailbox) | |
1593 (state imap-state) | |
1594 (imap-message-data (make-vector 2 0))) | |
1595 (when (imap-mailbox-examine-1 mailbox) | |
1596 (prog1 | |
1597 (and (imap-fetch "*" "UID") | |
1598 (list (imap-mailbox-get-1 'uidvalidity mailbox) | |
1599 (apply 'max (imap-message-map | |
1600 (lambda (uid prop) uid) 'UID)))) | |
1601 (if old-mailbox | |
1602 (imap-mailbox-select old-mailbox (eq state 'examine)) | |
1603 (imap-mailbox-unselect))))))) | |
1604 | |
1605 (defun imap-message-copyuid (mailbox &optional buffer) | |
1606 (with-current-buffer (or buffer (current-buffer)) | |
1607 (imap-message-copyuid-1 (imap-utf7-decode mailbox)))) | |
1608 | |
1609 (defun imap-message-copy (articles mailbox | |
1610 &optional dont-create no-copyuid buffer) | |
1611 "Copy ARTICLES (a string message set) to MAILBOX on server in | |
1612 BUFFER, creating mailbox if it doesn't exist. If dont-create is | |
1613 non-nil, it will not create a mailbox. On success, return a list with | |
1614 the UIDVALIDITY of the mailbox the article(s) was copied to as the | |
1615 first element, rest of list contain the saved articles' UIDs." | |
1616 (when articles | |
1617 (with-current-buffer (or buffer (current-buffer)) | |
1618 (let ((mailbox (imap-utf7-encode mailbox))) | |
1619 (if (let ((cmd (concat "UID COPY " articles " \"" mailbox "\"")) | |
1620 (imap-current-target-mailbox mailbox)) | |
1621 (if (imap-ok-p (imap-send-command-wait cmd)) | |
1622 t | |
1623 (when (and (not dont-create) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1624 ;; removed because of buggy Oracle server |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1625 ;; that doesn't send TRYCREATE tags (which |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1626 ;; is a MUST according to specifications): |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1627 ;;(imap-mailbox-get-1 'trycreate mailbox) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1628 (imap-mailbox-create-1 mailbox)) |
31717 | 1629 (imap-ok-p (imap-send-command-wait cmd))))) |
1630 (or no-copyuid | |
1631 (imap-message-copyuid-1 mailbox))))))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1632 |
31717 | 1633 (defun imap-message-appenduid-1 (mailbox) |
1634 (if (imap-capability 'UIDPLUS) | |
1635 (imap-mailbox-get-1 'appenduid mailbox) | |
1636 (let ((old-mailbox imap-current-mailbox) | |
1637 (state imap-state) | |
1638 (imap-message-data (make-vector 2 0))) | |
1639 (when (imap-mailbox-examine-1 mailbox) | |
1640 (prog1 | |
1641 (and (imap-fetch "*" "UID") | |
1642 (list (imap-mailbox-get-1 'uidvalidity mailbox) | |
1643 (apply 'max (imap-message-map | |
1644 (lambda (uid prop) uid) 'UID)))) | |
1645 (if old-mailbox | |
1646 (imap-mailbox-select old-mailbox (eq state 'examine)) | |
1647 (imap-mailbox-unselect))))))) | |
1648 | |
1649 (defun imap-message-appenduid (mailbox &optional buffer) | |
1650 (with-current-buffer (or buffer (current-buffer)) | |
1651 (imap-message-appenduid-1 (imap-utf7-encode mailbox)))) | |
1652 | |
1653 (defun imap-message-append (mailbox article &optional flags date-time buffer) | |
1654 "Append ARTICLE (a buffer) to MAILBOX on server in BUFFER. | |
1655 FLAGS and DATE-TIME is currently not used. Return a cons holding | |
1656 uidvalidity of MAILBOX and UID the newly created article got, or nil | |
1657 on failure." | |
1658 (let ((mailbox (imap-utf7-encode mailbox))) | |
1659 (with-current-buffer (or buffer (current-buffer)) | |
1660 (and (let ((imap-current-target-mailbox mailbox)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1661 (imap-ok-p |
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1662 (imap-send-command-wait |
31717 | 1663 (list "APPEND \"" mailbox "\" " article)))) |
1664 (imap-message-appenduid-1 mailbox))))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1665 |
31717 | 1666 (defun imap-body-lines (body) |
1667 "Return number of lines in article by looking at the mime bodystructure BODY." | |
1668 (if (listp body) | |
1669 (if (stringp (car body)) | |
1670 (cond ((and (string= (upcase (car body)) "TEXT") | |
1671 (numberp (nth 7 body))) | |
1672 (nth 7 body)) | |
1673 ((and (string= (upcase (car body)) "MESSAGE") | |
1674 (numberp (nth 9 body))) | |
1675 (nth 9 body)) | |
1676 (t 0)) | |
1677 (apply '+ (mapcar 'imap-body-lines body))) | |
1678 0)) | |
1679 | |
1680 (defun imap-envelope-from (from) | |
1681 "Return a from string line." | |
1682 (and from | |
1683 (concat (aref from 0) | |
1684 (if (aref from 0) " <") | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1685 (aref from 2) |
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1686 "@" |
31717 | 1687 (aref from 3) |
1688 (if (aref from 0) ">")))) | |
1689 | |
1690 | |
1691 ;; Internal functions. | |
1692 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1693 (defun imap-add-callback (tag func) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1694 (setq imap-callbacks (append (list (cons tag func)) imap-callbacks))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1695 |
31717 | 1696 (defun imap-send-command-1 (cmdstr) |
1697 (setq cmdstr (concat cmdstr imap-client-eol)) | |
1698 (and imap-log | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1699 (with-current-buffer (get-buffer-create imap-log-buffer) |
31717 | 1700 (imap-disable-multibyte) |
1701 (buffer-disable-undo) | |
1702 (goto-char (point-max)) | |
1703 (insert cmdstr))) | |
1704 (process-send-string imap-process cmdstr)) | |
1705 | |
1706 (defun imap-send-command (command &optional buffer) | |
1707 (with-current-buffer (or buffer (current-buffer)) | |
1708 (if (not (listp command)) (setq command (list command))) | |
1709 (let ((tag (setq imap-tag (1+ imap-tag))) | |
1710 cmd cmdstr) | |
1711 (setq cmdstr (concat (number-to-string imap-tag) " ")) | |
1712 (while (setq cmd (pop command)) | |
1713 (cond ((stringp cmd) | |
1714 (setq cmdstr (concat cmdstr cmd))) | |
1715 ((bufferp cmd) | |
1716 (let ((eol imap-client-eol) | |
1717 (calcfirst imap-calculate-literal-size-first) | |
1718 size) | |
1719 (with-current-buffer cmd | |
1720 (if calcfirst | |
1721 (setq size (buffer-size))) | |
1722 (when (not (equal eol "\r\n")) | |
1723 ;; XXX modifies buffer! | |
1724 (goto-char (point-min)) | |
1725 (while (search-forward "\r\n" nil t) | |
1726 (replace-match eol))) | |
1727 (if (not calcfirst) | |
1728 (setq size (buffer-size)))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1729 (setq cmdstr |
31717 | 1730 (concat cmdstr (format "{%d}" size)))) |
1731 (unwind-protect | |
1732 (progn | |
1733 (imap-send-command-1 cmdstr) | |
1734 (setq cmdstr nil) | |
1735 (if (not (eq (imap-wait-for-tag tag) 'INCOMPLETE)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1736 (setq command nil) ;; abort command if no cont-req |
31717 | 1737 (let ((process imap-process) |
1738 (stream imap-stream) | |
1739 (eol imap-client-eol)) | |
1740 (with-current-buffer cmd | |
1741 (and imap-log | |
1742 (with-current-buffer (get-buffer-create | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1743 imap-log-buffer) |
31717 | 1744 (imap-disable-multibyte) |
1745 (buffer-disable-undo) | |
1746 (goto-char (point-max)) | |
1747 (insert-buffer-substring cmd))) | |
1748 (process-send-region process (point-min) | |
1749 (point-max))) | |
1750 (process-send-string process imap-client-eol)))) | |
1751 (setq imap-continuation nil))) | |
1752 ((functionp cmd) | |
1753 (imap-send-command-1 cmdstr) | |
1754 (setq cmdstr nil) | |
1755 (unwind-protect | |
1756 (if (not (eq (imap-wait-for-tag tag) 'INCOMPLETE)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1757 (setq command nil) ;; abort command if no cont-req |
31717 | 1758 (setq command (cons (funcall cmd imap-continuation) |
1759 command))) | |
1760 (setq imap-continuation nil))) | |
1761 (t | |
1762 (error "Unknown command type")))) | |
1763 (if cmdstr | |
1764 (imap-send-command-1 cmdstr)) | |
1765 tag))) | |
1766 | |
1767 (defun imap-wait-for-tag (tag &optional buffer) | |
1768 (with-current-buffer (or buffer (current-buffer)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1769 (let (imap-have-messaged) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1770 (while (and (null imap-continuation) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1771 (memq (process-status imap-process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1772 (< imap-reached-tag tag)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1773 (let ((len (/ (point-max) 1024)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1774 message-log-max) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1775 (unless (< len 10) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1776 (setq imap-have-messaged t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1777 (message "imap read: %dk" len)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1778 (accept-process-output imap-process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1779 (truncate imap-read-timeout) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1780 (truncate (* (- imap-read-timeout |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1781 (truncate imap-read-timeout)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1782 1000))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1783 ;; A process can die _before_ we have processed everything it |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1784 ;; has to say. Moreover, this can happen in between the call to |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1785 ;; accept-process-output and the call to process-status in an |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1786 ;; iteration of the loop above. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1787 (when (and (null imap-continuation) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1788 (< imap-reached-tag tag)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1789 (accept-process-output imap-process 0 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1790 (when imap-have-messaged |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1791 (message "")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1792 (and (memq (process-status imap-process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1793 (or (assq tag imap-failed-tags) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1794 (if imap-continuation |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1795 'INCOMPLETE |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1796 'OK)))))) |
31717 | 1797 |
1798 (defun imap-sentinel (process string) | |
1799 (delete-process process)) | |
1800 | |
1801 (defun imap-find-next-line () | |
1802 "Return point at end of current line, taking into account literals. | |
1803 Return nil if no complete line has arrived." | |
1804 (when (re-search-forward (concat imap-server-eol "\\|{\\([0-9]+\\)}" | |
1805 imap-server-eol) | |
1806 nil t) | |
1807 (if (match-string 1) | |
1808 (if (< (point-max) (+ (point) (string-to-number (match-string 1)))) | |
1809 nil | |
1810 (goto-char (+ (point) (string-to-number (match-string 1)))) | |
1811 (imap-find-next-line)) | |
1812 (point)))) | |
1813 | |
1814 (defun imap-arrival-filter (proc string) | |
1815 "IMAP process filter." | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1816 ;; Sometimes, we are called even though the process has died. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1817 ;; Better abstain from doing stuff in that case. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1818 (when (buffer-name (process-buffer proc)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1819 (with-current-buffer (process-buffer proc) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1820 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1821 (insert string) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1822 (and imap-log |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1823 (with-current-buffer (get-buffer-create imap-log-buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1824 (imap-disable-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1825 (buffer-disable-undo) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1826 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1827 (insert string))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1828 (let (end) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1829 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1830 (while (setq end (imap-find-next-line)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1831 (save-restriction |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1832 (narrow-to-region (point-min) end) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1833 (delete-backward-char (length imap-server-eol)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1834 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1835 (unwind-protect |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1836 (cond ((eq imap-state 'initial) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1837 (imap-parse-greeting)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1838 ((or (eq imap-state 'auth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1839 (eq imap-state 'nonauth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1840 (eq imap-state 'selected) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1841 (eq imap-state 'examine)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1842 (imap-parse-response)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1843 (t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1844 (message "Unknown state %s in arrival filter" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1845 imap-state))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1846 (delete-region (point-min) (point-max))))))))) |
31717 | 1847 |
1848 | |
1849 ;; Imap parser. | |
1850 | |
1851 (defsubst imap-forward () | |
1852 (or (eobp) (forward-char))) | |
1853 | |
1854 ;; number = 1*DIGIT | |
1855 ;; ; Unsigned 32-bit integer | |
1856 ;; ; (0 <= n < 4,294,967,296) | |
1857 | |
1858 (defsubst imap-parse-number () | |
1859 (when (looking-at "[0-9]+") | |
1860 (prog1 | |
1861 (string-to-number (match-string 0)) | |
1862 (goto-char (match-end 0))))) | |
1863 | |
1864 ;; literal = "{" number "}" CRLF *CHAR8 | |
1865 ;; ; Number represents the number of CHAR8s | |
1866 | |
1867 (defsubst imap-parse-literal () | |
1868 (when (looking-at "{\\([0-9]+\\)}\r\n") | |
1869 (let ((pos (match-end 0)) | |
1870 (len (string-to-number (match-string 1)))) | |
1871 (if (< (point-max) (+ pos len)) | |
1872 nil | |
1873 (goto-char (+ pos len)) | |
1874 (buffer-substring pos (+ pos len)))))) | |
1875 | |
1876 ;; string = quoted / literal | |
1877 ;; | |
1878 ;; quoted = DQUOTE *QUOTED-CHAR DQUOTE | |
1879 ;; | |
1880 ;; QUOTED-CHAR = <any TEXT-CHAR except quoted-specials> / | |
1881 ;; "\" quoted-specials | |
1882 ;; | |
1883 ;; quoted-specials = DQUOTE / "\" | |
1884 ;; | |
1885 ;; TEXT-CHAR = <any CHAR except CR and LF> | |
1886 | |
1887 (defsubst imap-parse-string () | |
1888 (cond ((eq (char-after) ?\") | |
1889 (forward-char 1) | |
1890 (let ((p (point)) (name "")) | |
1891 (skip-chars-forward "^\"\\\\") | |
1892 (setq name (buffer-substring p (point))) | |
1893 (while (eq (char-after) ?\\) | |
1894 (setq p (1+ (point))) | |
1895 (forward-char 2) | |
1896 (skip-chars-forward "^\"\\\\") | |
1897 (setq name (concat name (buffer-substring p (point))))) | |
1898 (forward-char 1) | |
1899 name)) | |
1900 ((eq (char-after) ?{) | |
1901 (imap-parse-literal)))) | |
1902 | |
1903 ;; nil = "NIL" | |
1904 | |
1905 (defsubst imap-parse-nil () | |
1906 (if (looking-at "NIL") | |
1907 (goto-char (match-end 0)))) | |
1908 | |
1909 ;; nstring = string / nil | |
1910 | |
1911 (defsubst imap-parse-nstring () | |
1912 (or (imap-parse-string) | |
1913 (and (imap-parse-nil) | |
1914 nil))) | |
1915 | |
1916 ;; astring = atom / string | |
1917 ;; | |
1918 ;; atom = 1*ATOM-CHAR | |
1919 ;; | |
1920 ;; ATOM-CHAR = <any CHAR except atom-specials> | |
1921 ;; | |
1922 ;; atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / | |
1923 ;; quoted-specials | |
1924 ;; | |
1925 ;; list-wildcards = "%" / "*" | |
1926 ;; | |
1927 ;; quoted-specials = DQUOTE / "\" | |
1928 | |
1929 (defsubst imap-parse-astring () | |
1930 (or (imap-parse-string) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
1931 (buffer-substring (point) |
31717 | 1932 (if (re-search-forward "[(){ \r\n%*\"\\]" nil t) |
1933 (goto-char (1- (match-end 0))) | |
1934 (end-of-line) | |
1935 (point))))) | |
1936 | |
1937 ;; address = "(" addr-name SP addr-adl SP addr-mailbox SP | |
1938 ;; addr-host ")" | |
1939 ;; | |
1940 ;; addr-adl = nstring | |
1941 ;; ; Holds route from [RFC-822] route-addr if | |
42205 | 1942 ;; ; non-nil |
31717 | 1943 ;; |
1944 ;; addr-host = nstring | |
42205 | 1945 ;; ; nil indicates [RFC-822] group syntax. |
31717 | 1946 ;; ; Otherwise, holds [RFC-822] domain name |
1947 ;; | |
1948 ;; addr-mailbox = nstring | |
42205 | 1949 ;; ; nil indicates end of [RFC-822] group; if |
1950 ;; ; non-nil and addr-host is nil, holds | |
31717 | 1951 ;; ; [RFC-822] group name. |
1952 ;; ; Otherwise, holds [RFC-822] local-part | |
1953 ;; ; after removing [RFC-822] quoting | |
1954 ;; | |
1955 ;; addr-name = nstring | |
42205 | 1956 ;; ; If non-nil, holds phrase from [RFC-822] |
31717 | 1957 ;; ; mailbox after removing [RFC-822] quoting |
1958 ;; | |
1959 | |
1960 (defsubst imap-parse-address () | |
1961 (let (address) | |
1962 (when (eq (char-after) ?\() | |
1963 (imap-forward) | |
1964 (setq address (vector (prog1 (imap-parse-nstring) | |
1965 (imap-forward)) | |
1966 (prog1 (imap-parse-nstring) | |
1967 (imap-forward)) | |
1968 (prog1 (imap-parse-nstring) | |
1969 (imap-forward)) | |
1970 (imap-parse-nstring))) | |
1971 (when (eq (char-after) ?\)) | |
1972 (imap-forward) | |
1973 address)))) | |
1974 | |
1975 ;; address-list = "(" 1*address ")" / nil | |
1976 ;; | |
1977 ;; nil = "NIL" | |
1978 | |
1979 (defsubst imap-parse-address-list () | |
1980 (if (eq (char-after) ?\() | |
1981 (let (address addresses) | |
1982 (imap-forward) | |
1983 (while (and (not (eq (char-after) ?\))) | |
1984 ;; next line for MS Exchange bug | |
1985 (progn (and (eq (char-after) ? ) (imap-forward)) t) | |
1986 (setq address (imap-parse-address))) | |
1987 (setq addresses (cons address addresses))) | |
1988 (when (eq (char-after) ?\)) | |
1989 (imap-forward) | |
1990 (nreverse addresses))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1991 ;; With assert, the code might not be eval'd. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
1992 ;; (assert (imap-parse-nil) t "In imap-parse-address-list") |
54490
0045ce238ded
(imap-parse-address-list, imap-parse-body-ext): Disable wrong use of `assert'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1993 (imap-parse-nil))) |
31717 | 1994 |
1995 ;; mailbox = "INBOX" / astring | |
1996 ;; ; INBOX is case-insensitive. All case variants of | |
1997 ;; ; INBOX (e.g. "iNbOx") MUST be interpreted as INBOX | |
1998 ;; ; not as an astring. An astring which consists of | |
1999 ;; ; the case-insensitive sequence "I" "N" "B" "O" "X" | |
2000 ;; ; is considered to be INBOX and not an astring. | |
2001 ;; ; Refer to section 5.1 for further | |
2002 ;; ; semantic details of mailbox names. | |
2003 | |
2004 (defsubst imap-parse-mailbox () | |
2005 (let ((mailbox (imap-parse-astring))) | |
2006 (if (string-equal "INBOX" (upcase mailbox)) | |
2007 "INBOX" | |
2008 mailbox))) | |
2009 | |
2010 ;; greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF | |
2011 ;; | |
2012 ;; resp-cond-auth = ("OK" / "PREAUTH") SP resp-text | |
2013 ;; ; Authentication condition | |
2014 ;; | |
2015 ;; resp-cond-bye = "BYE" SP resp-text | |
2016 | |
2017 (defun imap-parse-greeting () | |
2018 "Parse a IMAP greeting." | |
2019 (cond ((looking-at "\\* OK ") | |
2020 (setq imap-state 'nonauth)) | |
2021 ((looking-at "\\* PREAUTH ") | |
2022 (setq imap-state 'auth)) | |
2023 ((looking-at "\\* BYE ") | |
2024 (setq imap-state 'closed)))) | |
2025 | |
2026 ;; response = *(continue-req / response-data) response-done | |
2027 ;; | |
2028 ;; continue-req = "+" SP (resp-text / base64) CRLF | |
2029 ;; | |
2030 ;; response-data = "*" SP (resp-cond-state / resp-cond-bye / | |
2031 ;; mailbox-data / message-data / capability-data) CRLF | |
2032 ;; | |
2033 ;; response-done = response-tagged / response-fatal | |
2034 ;; | |
2035 ;; response-fatal = "*" SP resp-cond-bye CRLF | |
2036 ;; ; Server closes connection immediately | |
2037 ;; | |
2038 ;; response-tagged = tag SP resp-cond-state CRLF | |
2039 ;; | |
2040 ;; resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text | |
2041 ;; ; Status condition | |
2042 ;; | |
2043 ;; resp-cond-bye = "BYE" SP resp-text | |
2044 ;; | |
2045 ;; mailbox-data = "FLAGS" SP flag-list / | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2046 ;; "LIST" SP mailbox-list / |
31717 | 2047 ;; "LSUB" SP mailbox-list / |
2048 ;; "SEARCH" *(SP nz-number) / | |
2049 ;; "STATUS" SP mailbox SP "(" | |
2050 ;; [status-att SP number *(SP status-att SP number)] ")" / | |
2051 ;; number SP "EXISTS" / | |
2052 ;; number SP "RECENT" | |
2053 ;; | |
2054 ;; message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) | |
2055 ;; | |
2056 ;; capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1" | |
2057 ;; *(SP capability) | |
2058 ;; ; IMAP4rev1 servers which offer RFC 1730 | |
2059 ;; ; compatibility MUST list "IMAP4" as the first | |
2060 ;; ; capability. | |
2061 | |
2062 (defun imap-parse-response () | |
2063 "Parse a IMAP command response." | |
2064 (let (token) | |
2065 (case (setq token (read (current-buffer))) | |
2066 (+ (setq imap-continuation | |
2067 (or (buffer-substring (min (point-max) (1+ (point))) | |
2068 (point-max)) | |
2069 t))) | |
2070 (* (case (prog1 (setq token (read (current-buffer))) | |
2071 (imap-forward)) | |
2072 (OK (imap-parse-resp-text)) | |
2073 (NO (imap-parse-resp-text)) | |
2074 (BAD (imap-parse-resp-text)) | |
2075 (BYE (imap-parse-resp-text)) | |
2076 (FLAGS (imap-mailbox-put 'flags (imap-parse-flag-list))) | |
2077 (LIST (imap-parse-data-list 'list)) | |
2078 (LSUB (imap-parse-data-list 'lsub)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2079 (SEARCH (imap-mailbox-put |
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2080 'search |
31717 | 2081 (read (concat "(" (buffer-substring (point) (point-max)) ")")))) |
2082 (STATUS (imap-parse-status)) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2083 (CAPABILITY (setq imap-capability |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2084 (read (concat "(" (upcase (buffer-substring |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2085 (point) (point-max))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2086 ")")))) |
31717 | 2087 (ACL (imap-parse-acl)) |
2088 (t (case (prog1 (read (current-buffer)) | |
2089 (imap-forward)) | |
2090 (EXISTS (imap-mailbox-put 'exists token)) | |
2091 (RECENT (imap-mailbox-put 'recent token)) | |
2092 (EXPUNGE t) | |
2093 (FETCH (imap-parse-fetch token)) | |
2094 (t (message "Garbage: %s" (buffer-string))))))) | |
2095 (t (let (status) | |
2096 (if (not (integerp token)) | |
2097 (message "Garbage: %s" (buffer-string)) | |
2098 (case (prog1 (setq status (read (current-buffer))) | |
2099 (imap-forward)) | |
2100 (OK (progn | |
2101 (setq imap-reached-tag (max imap-reached-tag token)) | |
2102 (imap-parse-resp-text))) | |
2103 (NO (progn | |
2104 (setq imap-reached-tag (max imap-reached-tag token)) | |
2105 (save-excursion | |
2106 (imap-parse-resp-text)) | |
2107 (let (code text) | |
2108 (when (eq (char-after) ?\[) | |
2109 (setq code (buffer-substring (point) | |
2110 (search-forward "]"))) | |
2111 (imap-forward)) | |
2112 (setq text (buffer-substring (point) (point-max))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2113 (push (list token status code text) |
31717 | 2114 imap-failed-tags)))) |
2115 (BAD (progn | |
2116 (setq imap-reached-tag (max imap-reached-tag token)) | |
2117 (save-excursion | |
2118 (imap-parse-resp-text)) | |
2119 (let (code text) | |
2120 (when (eq (char-after) ?\[) | |
2121 (setq code (buffer-substring (point) | |
2122 (search-forward "]"))) | |
2123 (imap-forward)) | |
2124 (setq text (buffer-substring (point) (point-max))) | |
2125 (push (list token status code text) imap-failed-tags) | |
2126 (error "Internal error, tag %s status %s code %s text %s" | |
2127 token status code text)))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2128 (t (message "Garbage: %s" (buffer-string)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2129 (when (assq token imap-callbacks) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2130 (funcall (cdr (assq token imap-callbacks)) token status) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2131 (setq imap-callbacks |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2132 (imap-remassoc token imap-callbacks))))))))) |
31717 | 2133 |
2134 ;; resp-text = ["[" resp-text-code "]" SP] text | |
2135 ;; | |
2136 ;; text = 1*TEXT-CHAR | |
2137 ;; | |
2138 ;; TEXT-CHAR = <any CHAR except CR and LF> | |
2139 | |
2140 (defun imap-parse-resp-text () | |
2141 (imap-parse-resp-text-code)) | |
2142 | |
2143 ;; resp-text-code = "ALERT" / | |
2144 ;; "BADCHARSET [SP "(" astring *(SP astring) ")" ] / | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2145 ;; "NEWNAME" SP string SP string / |
31717 | 2146 ;; "PARSE" / |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2147 ;; "PERMANENTFLAGS" SP "(" |
31717 | 2148 ;; [flag-perm *(SP flag-perm)] ")" / |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2149 ;; "READ-ONLY" / |
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2150 ;; "READ-WRITE" / |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2151 ;; "TRYCREATE" / |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2152 ;; "UIDNEXT" SP nz-number / |
31717 | 2153 ;; "UIDVALIDITY" SP nz-number / |
2154 ;; "UNSEEN" SP nz-number / | |
2155 ;; resp-text-atom [SP 1*<any TEXT-CHAR except "]">] | |
2156 ;; | |
2157 ;; resp_code_apnd = "APPENDUID" SPACE nz_number SPACE uniqueid | |
2158 ;; | |
2159 ;; resp_code_copy = "COPYUID" SPACE nz_number SPACE set SPACE set | |
2160 ;; | |
2161 ;; set = sequence-num / (sequence-num ":" sequence-num) / | |
2162 ;; (set "," set) | |
2163 ;; ; Identifies a set of messages. For message | |
2164 ;; ; sequence numbers, these are consecutive | |
2165 ;; ; numbers from 1 to the number of messages in | |
2166 ;; ; the mailbox | |
2167 ;; ; Comma delimits individual numbers, colon | |
2168 ;; ; delimits between two numbers inclusive. | |
2169 ;; ; Example: 2,4:7,9,12:* is 2,4,5,6,7,9,12,13, | |
2170 ;; ; 14,15 for a mailbox with 15 messages. | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2171 ;; |
31717 | 2172 ;; sequence-num = nz-number / "*" |
2173 ;; ; * is the largest number in use. For message | |
2174 ;; ; sequence numbers, it is the number of messages | |
2175 ;; ; in the mailbox. For unique identifiers, it is | |
2176 ;; ; the unique identifier of the last message in | |
2177 ;; ; the mailbox. | |
2178 ;; | |
2179 ;; flag-perm = flag / "\*" | |
2180 ;; | |
2181 ;; flag = "\Answered" / "\Flagged" / "\Deleted" / | |
2182 ;; "\Seen" / "\Draft" / flag-keyword / flag-extension | |
2183 ;; ; Does not include "\Recent" | |
2184 ;; | |
2185 ;; flag-extension = "\" atom | |
2186 ;; ; Future expansion. Client implementations | |
2187 ;; ; MUST accept flag-extension flags. Server | |
2188 ;; ; implementations MUST NOT generate | |
2189 ;; ; flag-extension flags except as defined by | |
2190 ;; ; future standard or standards-track | |
2191 ;; ; revisions of this specification. | |
2192 ;; | |
2193 ;; flag-keyword = atom | |
2194 ;; | |
2195 ;; resp-text-atom = 1*<any ATOM-CHAR except "]"> | |
2196 | |
2197 (defun imap-parse-resp-text-code () | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2198 ;; xxx next line for stalker communigate pro 3.3.1 bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2199 (when (looking-at " \\[") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2200 (imap-forward)) |
31717 | 2201 (when (eq (char-after) ?\[) |
2202 (imap-forward) | |
2203 (cond ((search-forward "PERMANENTFLAGS " nil t) | |
2204 (imap-mailbox-put 'permanentflags (imap-parse-flag-list))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2205 ((search-forward "UIDNEXT \\([0-9]+\\)" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2206 (imap-mailbox-put 'uidnext (match-string 1))) |
31717 | 2207 ((search-forward "UNSEEN " nil t) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2208 (imap-mailbox-put 'first-unseen (read (current-buffer)))) |
31717 | 2209 ((looking-at "UIDVALIDITY \\([0-9]+\\)") |
2210 (imap-mailbox-put 'uidvalidity (match-string 1))) | |
2211 ((search-forward "READ-ONLY" nil t) | |
2212 (imap-mailbox-put 'read-only t)) | |
2213 ((search-forward "NEWNAME " nil t) | |
2214 (let (oldname newname) | |
2215 (setq oldname (imap-parse-string)) | |
2216 (imap-forward) | |
2217 (setq newname (imap-parse-string)) | |
2218 (imap-mailbox-put 'newname newname oldname))) | |
2219 ((search-forward "TRYCREATE" nil t) | |
2220 (imap-mailbox-put 'trycreate t imap-current-target-mailbox)) | |
2221 ((looking-at "APPENDUID \\([0-9]+\\) \\([0-9]+\\)") | |
2222 (imap-mailbox-put 'appenduid | |
2223 (list (match-string 1) | |
2224 (string-to-number (match-string 2))) | |
2225 imap-current-target-mailbox)) | |
2226 ((looking-at "COPYUID \\([0-9]+\\) \\([0-9,:]+\\) \\([0-9,:]+\\)") | |
2227 (imap-mailbox-put 'copyuid (list (match-string 1) | |
2228 (match-string 2) | |
2229 (match-string 3)) | |
2230 imap-current-target-mailbox)) | |
2231 ((search-forward "ALERT] " nil t) | |
2232 (message "Imap server %s information: %s" imap-server | |
2233 (buffer-substring (point) (point-max))))))) | |
2234 | |
2235 ;; mailbox-list = "(" [mbx-list-flags] ")" SP | |
2236 ;; (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox | |
2237 ;; | |
2238 ;; mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag | |
2239 ;; *(SP mbx-list-oflag) / | |
2240 ;; mbx-list-oflag *(SP mbx-list-oflag) | |
2241 ;; | |
2242 ;; mbx-list-oflag = "\Noinferiors" / flag-extension | |
2243 ;; ; Other flags; multiple possible per LIST response | |
2244 ;; | |
2245 ;; mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked" | |
2246 ;; ; Selectability flags; only one per LIST response | |
2247 ;; | |
2248 ;; QUOTED-CHAR = <any TEXT-CHAR except quoted-specials> / | |
2249 ;; "\" quoted-specials | |
2250 ;; | |
2251 ;; quoted-specials = DQUOTE / "\" | |
2252 | |
2253 (defun imap-parse-data-list (type) | |
2254 (let (flags delimiter mailbox) | |
2255 (setq flags (imap-parse-flag-list)) | |
2256 (when (looking-at " NIL\\| \"\\\\?\\(.\\)\"") | |
2257 (setq delimiter (match-string 1)) | |
2258 (goto-char (1+ (match-end 0))) | |
2259 (when (setq mailbox (imap-parse-mailbox)) | |
2260 (imap-mailbox-put type t mailbox) | |
2261 (imap-mailbox-put 'list-flags flags mailbox) | |
2262 (imap-mailbox-put 'delimiter delimiter mailbox))))) | |
2263 | |
2264 ;; msg_att ::= "(" 1#("ENVELOPE" SPACE envelope / | |
2265 ;; "FLAGS" SPACE "(" #(flag / "\Recent") ")" / | |
2266 ;; "INTERNALDATE" SPACE date_time / | |
2267 ;; "RFC822" [".HEADER" / ".TEXT"] SPACE nstring / | |
2268 ;; "RFC822.SIZE" SPACE number / | |
2269 ;; "BODY" ["STRUCTURE"] SPACE body / | |
2270 ;; "BODY" section ["<" number ">"] SPACE nstring / | |
2271 ;; "UID" SPACE uniqueid) ")" | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2272 ;; |
31717 | 2273 ;; date_time ::= <"> date_day_fixed "-" date_month "-" date_year |
2274 ;; SPACE time SPACE zone <"> | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2275 ;; |
31717 | 2276 ;; section ::= "[" [section_text / (nz_number *["." nz_number] |
2277 ;; ["." (section_text / "MIME")])] "]" | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2278 ;; |
31717 | 2279 ;; section_text ::= "HEADER" / "HEADER.FIELDS" [".NOT"] |
2280 ;; SPACE header_list / "TEXT" | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2281 ;; |
31717 | 2282 ;; header_fld_name ::= astring |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2283 ;; |
31717 | 2284 ;; header_list ::= "(" 1#header_fld_name ")" |
2285 | |
2286 (defsubst imap-parse-header-list () | |
2287 (when (eq (char-after) ?\() | |
2288 (let (strlist) | |
2289 (while (not (eq (char-after) ?\))) | |
2290 (imap-forward) | |
2291 (push (imap-parse-astring) strlist)) | |
2292 (imap-forward) | |
2293 (nreverse strlist)))) | |
2294 | |
2295 (defsubst imap-parse-fetch-body-section () | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2296 (let ((section |
31717 | 2297 (buffer-substring (point) (1- (re-search-forward "[] ]" nil t))))) |
2298 (if (eq (char-before) ? ) | |
2299 (prog1 | |
2300 (mapconcat 'identity (cons section (imap-parse-header-list)) " ") | |
2301 (search-forward "]" nil t)) | |
2302 section))) | |
2303 | |
2304 (defun imap-parse-fetch (response) | |
2305 (when (eq (char-after) ?\() | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2306 (let (uid flags envelope internaldate rfc822 rfc822header rfc822text |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2307 rfc822size body bodydetail bodystructure flags-empty) |
31717 | 2308 (while (not (eq (char-after) ?\))) |
2309 (imap-forward) | |
2310 (let ((token (read (current-buffer)))) | |
2311 (imap-forward) | |
2312 (cond ((eq token 'UID) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2313 (setq uid (condition-case () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2314 (read (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2315 (error)))) |
31717 | 2316 ((eq token 'FLAGS) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2317 (setq flags (imap-parse-flag-list)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2318 (if (not flags) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2319 (setq flags-empty 't))) |
31717 | 2320 ((eq token 'ENVELOPE) |
2321 (setq envelope (imap-parse-envelope))) | |
2322 ((eq token 'INTERNALDATE) | |
2323 (setq internaldate (imap-parse-string))) | |
2324 ((eq token 'RFC822) | |
2325 (setq rfc822 (imap-parse-nstring))) | |
2326 ((eq token 'RFC822.HEADER) | |
2327 (setq rfc822header (imap-parse-nstring))) | |
2328 ((eq token 'RFC822.TEXT) | |
2329 (setq rfc822text (imap-parse-nstring))) | |
2330 ((eq token 'RFC822.SIZE) | |
2331 (setq rfc822size (read (current-buffer)))) | |
2332 ((eq token 'BODY) | |
2333 (if (eq (char-before) ?\[) | |
2334 (push (list | |
2335 (upcase (imap-parse-fetch-body-section)) | |
2336 (and (eq (char-after) ?<) | |
2337 (buffer-substring (1+ (point)) | |
2338 (search-forward ">" nil t))) | |
2339 (progn (imap-forward) | |
2340 (imap-parse-nstring))) | |
2341 bodydetail) | |
2342 (setq body (imap-parse-body)))) | |
2343 ((eq token 'BODYSTRUCTURE) | |
2344 (setq bodystructure (imap-parse-body)))))) | |
2345 (when uid | |
2346 (setq imap-current-message uid) | |
2347 (imap-message-put uid 'UID uid) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2348 (and (or flags flags-empty) (imap-message-put uid 'FLAGS flags)) |
31717 | 2349 (and envelope (imap-message-put uid 'ENVELOPE envelope)) |
2350 (and internaldate (imap-message-put uid 'INTERNALDATE internaldate)) | |
2351 (and rfc822 (imap-message-put uid 'RFC822 rfc822)) | |
2352 (and rfc822header (imap-message-put uid 'RFC822.HEADER rfc822header)) | |
2353 (and rfc822text (imap-message-put uid 'RFC822.TEXT rfc822text)) | |
2354 (and rfc822size (imap-message-put uid 'RFC822.SIZE rfc822size)) | |
2355 (and body (imap-message-put uid 'BODY body)) | |
2356 (and bodydetail (imap-message-put uid 'BODYDETAIL bodydetail)) | |
2357 (and bodystructure (imap-message-put uid 'BODYSTRUCTURE bodystructure)) | |
2358 (run-hooks 'imap-fetch-data-hook))))) | |
2359 | |
2360 ;; mailbox-data = ... | |
2361 ;; "STATUS" SP mailbox SP "(" | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2362 ;; [status-att SP number |
31717 | 2363 ;; *(SP status-att SP number)] ")" |
2364 ;; ... | |
2365 ;; | |
2366 ;; status-att = "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" / | |
2367 ;; "UNSEEN" | |
2368 | |
2369 (defun imap-parse-status () | |
2370 (let ((mailbox (imap-parse-mailbox))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2371 (if (eq (char-after) ? ) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2372 (forward-char)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2373 (when (and mailbox (eq (char-after) ?\()) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2374 (while (and (not (eq (char-after) ?\))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2375 (or (forward-char) t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2376 (looking-at "\\([A-Za-z]+\\) ")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2377 (let ((token (match-string 1))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2378 (goto-char (match-end 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2379 (cond ((string= token "MESSAGES") |
31717 | 2380 (imap-mailbox-put 'messages (read (current-buffer)) mailbox)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2381 ((string= token "RECENT") |
31717 | 2382 (imap-mailbox-put 'recent (read (current-buffer)) mailbox)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2383 ((string= token "UIDNEXT") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2384 (and (looking-at "[0-9]+") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2385 (imap-mailbox-put 'uidnext (match-string 0) mailbox) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2386 (goto-char (match-end 0)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2387 ((string= token "UIDVALIDITY") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2388 (and (looking-at "[0-9]+") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2389 (imap-mailbox-put 'uidvalidity (match-string 0) mailbox) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2390 (goto-char (match-end 0)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2391 ((string= token "UNSEEN") |
31717 | 2392 (imap-mailbox-put 'unseen (read (current-buffer)) mailbox)) |
2393 (t | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2394 (message "Unknown status data %s in mailbox %s ignored" |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2395 token mailbox) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2396 (read (current-buffer))))))))) |
31717 | 2397 |
2398 ;; acl_data ::= "ACL" SPACE mailbox *(SPACE identifier SPACE | |
2399 ;; rights) | |
2400 ;; | |
2401 ;; identifier ::= astring | |
2402 ;; | |
2403 ;; rights ::= astring | |
2404 | |
2405 (defun imap-parse-acl () | |
2406 (let ((mailbox (imap-parse-mailbox)) | |
2407 identifier rights acl) | |
2408 (while (eq (char-after) ?\ ) | |
2409 (imap-forward) | |
2410 (setq identifier (imap-parse-astring)) | |
2411 (imap-forward) | |
2412 (setq rights (imap-parse-astring)) | |
2413 (setq acl (append acl (list (cons identifier rights))))) | |
2414 (imap-mailbox-put 'acl acl mailbox))) | |
2415 | |
2416 ;; flag-list = "(" [flag *(SP flag)] ")" | |
2417 ;; | |
2418 ;; flag = "\Answered" / "\Flagged" / "\Deleted" / | |
2419 ;; "\Seen" / "\Draft" / flag-keyword / flag-extension | |
2420 ;; ; Does not include "\Recent" | |
2421 ;; | |
2422 ;; flag-keyword = atom | |
2423 ;; | |
2424 ;; flag-extension = "\" atom | |
2425 ;; ; Future expansion. Client implementations | |
2426 ;; ; MUST accept flag-extension flags. Server | |
2427 ;; ; implementations MUST NOT generate | |
2428 ;; ; flag-extension flags except as defined by | |
2429 ;; ; future standard or standards-track | |
2430 ;; ; revisions of this specification. | |
2431 | |
2432 (defun imap-parse-flag-list () | |
2433 (let (flag-list start) | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
2434 (assert (eq (char-after) ?\() nil "In imap-parse-flag-list") |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
2435 (while (and (not (eq (char-after) ?\))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2436 (setq start (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2437 (imap-forward) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2438 ;; next line for Courier IMAP bug. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2439 (skip-chars-forward " ") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2440 (point))) |
33299
be95f43e08db
(imap-point-at-eol): New, replacing gnus-point-at-eol.
Dave Love <fx@gnu.org>
parents:
32995
diff
changeset
|
2441 (> (skip-chars-forward "^ )" (imap-point-at-eol)) 0)) |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
2442 (push (buffer-substring start (point)) flag-list)) |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
2443 (assert (eq (char-after) ?\)) nil "In imap-parse-flag-list") |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
2444 (imap-forward) |
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
2445 (nreverse flag-list))) |
31717 | 2446 |
2447 ;; envelope = "(" env-date SP env-subject SP env-from SP env-sender SP | |
2448 ;; env-reply-to SP env-to SP env-cc SP env-bcc SP | |
2449 ;; env-in-reply-to SP env-message-id ")" | |
2450 ;; | |
2451 ;; env-bcc = "(" 1*address ")" / nil | |
2452 ;; | |
2453 ;; env-cc = "(" 1*address ")" / nil | |
2454 ;; | |
2455 ;; env-date = nstring | |
2456 ;; | |
2457 ;; env-from = "(" 1*address ")" / nil | |
2458 ;; | |
2459 ;; env-in-reply-to = nstring | |
2460 ;; | |
2461 ;; env-message-id = nstring | |
2462 ;; | |
2463 ;; env-reply-to = "(" 1*address ")" / nil | |
2464 ;; | |
2465 ;; env-sender = "(" 1*address ")" / nil | |
2466 ;; | |
2467 ;; env-subject = nstring | |
2468 ;; | |
2469 ;; env-to = "(" 1*address ")" / nil | |
2470 | |
2471 (defun imap-parse-envelope () | |
2472 (when (eq (char-after) ?\() | |
2473 (imap-forward) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2474 (vector (prog1 (imap-parse-nstring) ;; date |
31717 | 2475 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2476 (prog1 (imap-parse-nstring) ;; subject |
31717 | 2477 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2478 (prog1 (imap-parse-address-list) ;; from |
31717 | 2479 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2480 (prog1 (imap-parse-address-list) ;; sender |
31717 | 2481 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2482 (prog1 (imap-parse-address-list) ;; reply-to |
31717 | 2483 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2484 (prog1 (imap-parse-address-list) ;; to |
31717 | 2485 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2486 (prog1 (imap-parse-address-list) ;; cc |
31717 | 2487 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2488 (prog1 (imap-parse-address-list) ;; bcc |
31717 | 2489 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2490 (prog1 (imap-parse-nstring) ;; in-reply-to |
31717 | 2491 (imap-forward)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2492 (prog1 (imap-parse-nstring) ;; message-id |
31717 | 2493 (imap-forward))))) |
2494 | |
2495 ;; body-fld-param = "(" string SP string *(SP string SP string) ")" / nil | |
2496 | |
2497 (defsubst imap-parse-string-list () | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2498 (cond ((eq (char-after) ?\() ;; body-fld-param |
31717 | 2499 (let (strlist str) |
2500 (imap-forward) | |
2501 (while (setq str (imap-parse-string)) | |
2502 (push str strlist) | |
2503 ;; buggy stalker communigate pro 3.0 doesn't print SPC | |
2504 ;; between body-fld-param's sometimes | |
2505 (or (eq (char-after) ?\") | |
2506 (imap-forward))) | |
2507 (nreverse strlist))) | |
2508 ((imap-parse-nil) | |
2509 nil))) | |
2510 | |
2511 ;; body-extension = nstring / number / | |
2512 ;; "(" body-extension *(SP body-extension) ")" | |
2513 ;; ; Future expansion. Client implementations | |
2514 ;; ; MUST accept body-extension fields. Server | |
2515 ;; ; implementations MUST NOT generate | |
2516 ;; ; body-extension fields except as defined by | |
2517 ;; ; future standard or standards-track | |
2518 ;; ; revisions of this specification. | |
2519 | |
2520 (defun imap-parse-body-extension () | |
2521 (if (eq (char-after) ?\() | |
2522 (let (b-e) | |
2523 (imap-forward) | |
2524 (push (imap-parse-body-extension) b-e) | |
2525 (while (eq (char-after) ?\ ) | |
2526 (imap-forward) | |
2527 (push (imap-parse-body-extension) b-e)) | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
2528 (assert (eq (char-after) ?\)) nil "In imap-parse-body-extension") |
31717 | 2529 (imap-forward) |
2530 (nreverse b-e)) | |
2531 (or (imap-parse-number) | |
2532 (imap-parse-nstring)))) | |
2533 | |
2534 ;; body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang | |
2535 ;; *(SP body-extension)]] | |
2536 ;; ; MUST NOT be returned on non-extensible | |
2537 ;; ; "BODY" fetch | |
2538 ;; | |
2539 ;; body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang | |
2540 ;; *(SP body-extension)]] | |
2541 ;; ; MUST NOT be returned on non-extensible | |
2542 ;; ; "BODY" fetch | |
2543 | |
2544 (defsubst imap-parse-body-ext () | |
2545 (let (ext) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2546 (when (eq (char-after) ?\ ) ;; body-fld-dsp |
31717 | 2547 (imap-forward) |
2548 (let (dsp) | |
2549 (if (eq (char-after) ?\() | |
2550 (progn | |
2551 (imap-forward) | |
2552 (push (imap-parse-string) dsp) | |
2553 (imap-forward) | |
2554 (push (imap-parse-string-list) dsp) | |
2555 (imap-forward)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2556 ;; With assert, the code might not be eval'd. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2557 ;; (assert (imap-parse-nil) t "In imap-parse-body-ext") |
54490
0045ce238ded
(imap-parse-address-list, imap-parse-body-ext): Disable wrong use of `assert'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
2558 (imap-parse-nil)) |
31717 | 2559 (push (nreverse dsp) ext)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2560 (when (eq (char-after) ?\ ) ;; body-fld-lang |
31717 | 2561 (imap-forward) |
2562 (if (eq (char-after) ?\() | |
2563 (push (imap-parse-string-list) ext) | |
2564 (push (imap-parse-nstring) ext)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2565 (while (eq (char-after) ?\ ) ;; body-extension |
31717 | 2566 (imap-forward) |
2567 (setq ext (append (imap-parse-body-extension) ext))))) | |
2568 ext)) | |
2569 | |
2570 ;; body = "(" body-type-1part / body-type-mpart ")" | |
2571 ;; | |
2572 ;; body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang | |
2573 ;; *(SP body-extension)]] | |
2574 ;; ; MUST NOT be returned on non-extensible | |
2575 ;; ; "BODY" fetch | |
2576 ;; | |
2577 ;; body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang | |
2578 ;; *(SP body-extension)]] | |
2579 ;; ; MUST NOT be returned on non-extensible | |
2580 ;; ; "BODY" fetch | |
2581 ;; | |
2582 ;; body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP | |
2583 ;; body-fld-enc SP body-fld-octets | |
2584 ;; | |
2585 ;; body-fld-desc = nstring | |
2586 ;; | |
2587 ;; body-fld-dsp = "(" string SP body-fld-param ")" / nil | |
2588 ;; | |
2589 ;; body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ | |
2590 ;; "QUOTED-PRINTABLE") DQUOTE) / string | |
2591 ;; | |
2592 ;; body-fld-id = nstring | |
2593 ;; | |
2594 ;; body-fld-lang = nstring / "(" string *(SP string) ")" | |
2595 ;; | |
2596 ;; body-fld-lines = number | |
2597 ;; | |
2598 ;; body-fld-md5 = nstring | |
2599 ;; | |
2600 ;; body-fld-octets = number | |
2601 ;; | |
2602 ;; body-fld-param = "(" string SP string *(SP string SP string) ")" / nil | |
2603 ;; | |
2604 ;; body-type-1part = (body-type-basic / body-type-msg / body-type-text) | |
2605 ;; [SP body-ext-1part] | |
2606 ;; | |
2607 ;; body-type-basic = media-basic SP body-fields | |
2608 ;; ; MESSAGE subtype MUST NOT be "RFC822" | |
2609 ;; | |
2610 ;; body-type-msg = media-message SP body-fields SP envelope | |
2611 ;; SP body SP body-fld-lines | |
2612 ;; | |
2613 ;; body-type-text = media-text SP body-fields SP body-fld-lines | |
2614 ;; | |
2615 ;; body-type-mpart = 1*body SP media-subtype | |
2616 ;; [SP body-ext-mpart] | |
2617 ;; | |
2618 ;; media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / | |
2619 ;; "MESSAGE" / "VIDEO") DQUOTE) / string) SP media-subtype | |
2620 ;; ; Defined in [MIME-IMT] | |
2621 ;; | |
2622 ;; media-message = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE | |
2623 ;; ; Defined in [MIME-IMT] | |
2624 ;; | |
2625 ;; media-subtype = string | |
2626 ;; ; Defined in [MIME-IMT] | |
2627 ;; | |
2628 ;; media-text = DQUOTE "TEXT" DQUOTE SP media-subtype | |
2629 ;; ; Defined in [MIME-IMT] | |
2630 | |
2631 (defun imap-parse-body () | |
2632 (let (body) | |
2633 (when (eq (char-after) ?\() | |
2634 (imap-forward) | |
2635 (if (eq (char-after) ?\() | |
2636 (let (subbody) | |
2637 (while (and (eq (char-after) ?\() | |
2638 (setq subbody (imap-parse-body))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2639 ;; buggy stalker communigate pro 3.0 insert a SPC between |
31717 | 2640 ;; parts in multiparts |
2641 (when (and (eq (char-after) ?\ ) | |
2642 (eq (char-after (1+ (point))) ?\()) | |
2643 (imap-forward)) | |
2644 (push subbody body)) | |
2645 (imap-forward) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2646 (push (imap-parse-string) body) ;; media-subtype |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2647 (when (eq (char-after) ?\ ) ;; body-ext-mpart: |
31717 | 2648 (imap-forward) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2649 (if (eq (char-after) ?\() ;; body-fld-param |
31717 | 2650 (push (imap-parse-string-list) body) |
2651 (push (and (imap-parse-nil) nil) body)) | |
2652 (setq body | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2653 (append (imap-parse-body-ext) body))) ;; body-ext-... |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
2654 (assert (eq (char-after) ?\)) nil "In imap-parse-body") |
31717 | 2655 (imap-forward) |
2656 (nreverse body)) | |
2657 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2658 (push (imap-parse-string) body) ;; media-type |
31717 | 2659 (imap-forward) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2660 (push (imap-parse-string) body) ;; media-subtype |
31717 | 2661 (imap-forward) |
2662 ;; next line for Sun SIMS bug | |
2663 (and (eq (char-after) ? ) (imap-forward)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2664 (if (eq (char-after) ?\() ;; body-fld-param |
31717 | 2665 (push (imap-parse-string-list) body) |
2666 (push (and (imap-parse-nil) nil) body)) | |
2667 (imap-forward) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2668 (push (imap-parse-nstring) body) ;; body-fld-id |
31717 | 2669 (imap-forward) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2670 (push (imap-parse-nstring) body) ;; body-fld-desc |
31717 | 2671 (imap-forward) |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
2672 ;; next `or' for Sun SIMS bug, it regard body-fld-enc as a |
42205 | 2673 ;; nstring and return nil instead of defaulting back to 7BIT |
32995
3720ccaca161
2000-10-27 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31717
diff
changeset
|
2674 ;; as the standard says. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2675 (push (or (imap-parse-nstring) "7BIT") body) ;; body-fld-enc |
31717 | 2676 (imap-forward) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2677 (push (imap-parse-number) body) ;; body-fld-octets |
31717 | 2678 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2679 ;; ok, we're done parsing the required parts, what comes now is one |
31717 | 2680 ;; of three things: |
2681 ;; | |
2682 ;; envelope (then we're parsing body-type-msg) | |
2683 ;; body-fld-lines (then we're parsing body-type-text) | |
2684 ;; body-ext-1part (then we're parsing body-type-basic) | |
2685 ;; | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2686 ;; the problem is that the two first are in turn optionally followed |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2687 ;; by the third. So we parse the first two here (if there are any)... |
31717 | 2688 |
2689 (when (eq (char-after) ?\ ) | |
2690 (imap-forward) | |
2691 (let (lines) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2692 (cond ((eq (char-after) ?\() ;; body-type-msg: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2693 (push (imap-parse-envelope) body) ;; envelope |
31717 | 2694 (imap-forward) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2695 (push (imap-parse-body) body) ;; body |
31717 | 2696 ;; buggy stalker communigate pro 3.0 doesn't print |
2697 ;; number of lines in message/rfc822 attachment | |
2698 (if (eq (char-after) ?\)) | |
2699 (push 0 body) | |
2700 (imap-forward) | |
2701 (push (imap-parse-number) body))) ;; body-fld-lines | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2702 ((setq lines (imap-parse-number)) ;; body-type-text: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2703 (push lines body)) ;; body-fld-lines |
31717 | 2704 (t |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2705 (backward-char))))) ;; no match... |
31717 | 2706 |
2707 ;; ...and then parse the third one here... | |
2708 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2709 (when (eq (char-after) ?\ ) ;; body-ext-1part: |
31717 | 2710 (imap-forward) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2711 (push (imap-parse-nstring) body) ;; body-fld-md5 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2712 (setq body (append (imap-parse-body-ext) body))) ;; body-ext-1part.. |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2713 |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
2714 (assert (eq (char-after) ?\)) nil "In imap-parse-body 2") |
31717 | 2715 (imap-forward) |
2716 (nreverse body))))) | |
2717 | |
2718 (when imap-debug ; (untrace-all) | |
2719 (require 'trace) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2720 (buffer-disable-undo (get-buffer-create imap-debug-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54490
diff
changeset
|
2721 (mapcar (lambda (f) (trace-function-background f imap-debug-buffer)) |
31717 | 2722 '( |
2723 imap-utf7-encode | |
2724 imap-utf7-decode | |
2725 imap-error-text | |
2726 imap-kerberos4s-p | |
2727 imap-kerberos4-open | |
2728 imap-ssl-p | |
2729 imap-ssl-open | |
2730 imap-network-p | |
2731 imap-network-open | |
2732 imap-interactive-login | |
2733 imap-kerberos4a-p | |
2734 imap-kerberos4-auth | |
2735 imap-cram-md5-p | |
2736 imap-cram-md5-auth | |
2737 imap-login-p | |
2738 imap-login-auth | |
2739 imap-anonymous-p | |
2740 imap-anonymous-auth | |
2741 imap-open-1 | |
2742 imap-open | |
2743 imap-opened | |
2744 imap-authenticate | |
2745 imap-close | |
2746 imap-capability | |
2747 imap-namespace | |
2748 imap-send-command-wait | |
2749 imap-mailbox-put | |
2750 imap-mailbox-get | |
2751 imap-mailbox-map-1 | |
2752 imap-mailbox-map | |
2753 imap-current-mailbox | |
2754 imap-current-mailbox-p-1 | |
2755 imap-current-mailbox-p | |
2756 imap-mailbox-select-1 | |
2757 imap-mailbox-select | |
2758 imap-mailbox-examine-1 | |
2759 imap-mailbox-examine | |
2760 imap-mailbox-unselect | |
2761 imap-mailbox-expunge | |
2762 imap-mailbox-close | |
2763 imap-mailbox-create-1 | |
2764 imap-mailbox-create | |
2765 imap-mailbox-delete | |
2766 imap-mailbox-rename | |
2767 imap-mailbox-lsub | |
2768 imap-mailbox-list | |
2769 imap-mailbox-subscribe | |
2770 imap-mailbox-unsubscribe | |
2771 imap-mailbox-status | |
2772 imap-mailbox-acl-get | |
2773 imap-mailbox-acl-set | |
2774 imap-mailbox-acl-delete | |
2775 imap-current-message | |
2776 imap-list-to-message-set | |
2777 imap-fetch-asynch | |
2778 imap-fetch | |
2779 imap-message-put | |
2780 imap-message-get | |
2781 imap-message-map | |
2782 imap-search | |
2783 imap-message-flag-permanent-p | |
2784 imap-message-flags-set | |
2785 imap-message-flags-del | |
2786 imap-message-flags-add | |
2787 imap-message-copyuid-1 | |
2788 imap-message-copyuid | |
2789 imap-message-copy | |
2790 imap-message-appenduid-1 | |
2791 imap-message-appenduid | |
2792 imap-message-append | |
2793 imap-body-lines | |
2794 imap-envelope-from | |
2795 imap-send-command-1 | |
2796 imap-send-command | |
2797 imap-wait-for-tag | |
2798 imap-sentinel | |
2799 imap-find-next-line | |
2800 imap-arrival-filter | |
2801 imap-parse-greeting | |
2802 imap-parse-response | |
2803 imap-parse-resp-text | |
2804 imap-parse-resp-text-code | |
2805 imap-parse-data-list | |
2806 imap-parse-fetch | |
2807 imap-parse-status | |
2808 imap-parse-acl | |
2809 imap-parse-flag-list | |
2810 imap-parse-envelope | |
2811 imap-parse-body-extension | |
2812 imap-parse-body | |
2813 ))) | |
39064
c545df001cd2
(imap-mailbox-examine, imap-mailbox-examine-1): Fix a typo: `exmine' --> `examine'.
Sam Steingold <sds@gnu.org>
parents:
33299
diff
changeset
|
2814 |
31717 | 2815 (provide 'imap) |
2816 | |
52401 | 2817 ;;; arch-tag: 27369ed6-33e4-482f-96f1-8bb906ba70f7 |
31717 | 2818 ;;; imap.el ends here |