Commit ec42a8c0 ec42a8c02e31a41c225e75d1935b539435b09222 by Sergey Poznyakoff

Implement UNSELECT extension.

* doc/rfc/Makefile.am: Add rfc3691.txt
* doc/rfc/rfc3691.txt: New file.
* imap4d/capability.c: Announce UNSELECT capability.
* imap4d/close.c: Implement UNSELECT command.
* imap4d/commands.c: Add UNSELECT command.
* imap4d/imap4d.h (imap4d_unselect): New proto.
* imap4d/testsuite/imap4d/anystate.exp: Reflect UNSELECT
capability.
* imap4d/testsuite/imap4d/examine.exp: Reflect yesterday's changes
to STATUS output.
1 parent 7a626fa1
1 2008-08-17 Sergey Poznyakoff <gray@gnu.org.ua>
2
3 Implement UNSELECT extension.
4 * doc/rfc/Makefile.am: Add rfc3691.txt
5 * doc/rfc/rfc3691.txt: New file.
6 * imap4d/capability.c: Announce UNSELECT capability.
7 * imap4d/close.c: Implement UNSELECT command.
8 * imap4d/commands.c: Add UNSELECT command.
9 * imap4d/imap4d.h (imap4d_unselect): New proto.
10 * imap4d/testsuite/imap4d/anystate.exp: Reflect UNSELECT
11 capability.
12 * imap4d/testsuite/imap4d/examine.exp: Reflect yesterday's changes
13 to STATUS output.
14
1 2008-08-16 Sergey Poznyakoff <gray@gnu.org.ua> 15 2008-08-16 Sergey Poznyakoff <gray@gnu.org.ua>
2 16
3 * imap4d/status.c (imap4d_status): Remove extra whitespace 17 * imap4d/status.c (imap4d_status): Remove extra whitespace
......
1 ## Process this file with GNU Automake to create Makefile.in 1 ## Process this file with GNU Automake to create Makefile.in
2 2
3 ## Copyright (C) 2001, 2002, 2003, 2007 Free Software Foundation, Inc. 3 ## Copyright (C) 2001, 2002, 2003, 2007, 2008 Free Software Foundation, Inc.
4 ## 4 ##
5 ## GNU Mailutils is free software; you can redistribute it and/or 5 ## GNU Mailutils is free software; you can redistribute it and/or
6 ## modify it under the terms of the GNU General Public License as 6 ## modify it under the terms of the GNU General Public License as
...@@ -18,38 +18,39 @@ ...@@ -18,38 +18,39 @@
18 ## 02110-1301 USA 18 ## 02110-1301 USA
19 19
20 EXTRA_DIST = \ 20 EXTRA_DIST = \
21 rfc821.txt \ 21 rfc821.txt\
22 rfc822.txt \ 22 rfc822.txt\
23 rfc934.txt \ 23 rfc934.txt\
24 rfc1521.txt \ 24 rfc1521.txt\
25 rfc1731.txt \ 25 rfc1731.txt\
26 rfc1734.txt \ 26 rfc1734.txt\
27 rfc1738.txt \ 27 rfc1738.txt\
28 rfc1939.txt \ 28 rfc1939.txt\
29 rfc1957.txt \ 29 rfc1957.txt\
30 rfc2045.txt \ 30 rfc2045.txt\
31 rfc2046.txt \ 31 rfc2046.txt\
32 rfc2047.txt \ 32 rfc2047.txt\
33 rfc2049.txt \ 33 rfc2049.txt\
34 rfc2060.txt \ 34 rfc2060.txt\
35 rfc2060-errata \ 35 rfc2060-errata\
36 rfc2088.txt \ 36 rfc2088.txt\
37 rfc2111.txt \ 37 rfc2111.txt\
38 rfc2177.txt \ 38 rfc2177.txt\
39 rfc2192.txt \ 39 rfc2192.txt\
40 rfc2193.txt \ 40 rfc2193.txt\
41 rfc2221.txt \ 41 rfc2221.txt\
42 rfc2245.txt \ 42 rfc2245.txt\
43 rfc2298.txt \ 43 rfc2298.txt\
44 rfc2231.txt \ 44 rfc2231.txt\
45 rfc2342.txt \ 45 rfc2342.txt\
46 rfc2368.txt \ 46 rfc2368.txt\
47 rfc2384.txt \ 47 rfc2384.txt\
48 rfc2449.txt \ 48 rfc2449.txt\
49 rfc2595.txt \ 49 rfc2595.txt\
50 rfc2821.txt \ 50 rfc2821.txt\
51 rfc2822.txt \ 51 rfc2822.txt\
52 rfc3028.txt \ 52 rfc3028.txt\
53 rfc3206.txt \ 53 rfc3206.txt\
54 rfc3431.txt \ 54 rfc3431.txt\
55 rfc3501.txt 55 rfc3501.txt\
56 rfc3691.txt
......
1
2
3
4
5
6
7 Network Working Group A. Melnikov
8 Request for Comments: 3691 Isode Ltd.
9 Category: Standards Track February 2004
10
11
12 Internet Message Access Protocol (IMAP) UNSELECT command
13
14 Status of this Memo
15
16 This document specifies an Internet standards track protocol for the
17 Internet community, and requests discussion and suggestions for
18 improvements. Please refer to the current edition of the "Internet
19 Official Protocol Standards" (STD 1) for the standardization state
20 and status of this protocol. Distribution of this memo is unlimited.
21
22 Copyright Notice
23
24 Copyright (C) The Internet Society (2004). All Rights Reserved.
25
26 Abstract
27
28 This document defines an UNSELECT command that can be used to close
29 the current mailbox in an Internet Message Access Protocol - version
30 4 (IMAP4) session without expunging it. Certain types of IMAP
31 clients need to release resources associated with the selected
32 mailbox without selecting a different mailbox. While IMAP4 provides
33 this functionality (via a SELECT command with a nonexistent mailbox
34 name or reselecting the same mailbox with EXAMINE command), a more
35 clean solution is desirable.
36
37 Table of Contents
38
39 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
40 2. UNSELECT command . . . . . . . . . . . . . . . . . . . . . . . 2
41 3. Security Considerations. . . . . . . . . . . . . . . . . . . . 3
42 4. Formal Syntax. . . . . . . . . . . . . . . . . . . . . . . . . 3
43 5. IANA Considerations. . . . . . . . . . . . . . . . . . . . . . 3
44 6. Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . 3
45 7. Normative References . . . . . . . . . . . . . . . . . . . . . 4
46 8. Author's Address . . . . . . . . . . . . . . . . . . . . . . . 4
47 9. Full Copyright Statement . . . . . . . . . . . . . . . . . . . 5
48
49
50
51
52
53
54
55
56
57
58 Melnikov Standards Track [Page 1]
59
60 RFC 3691 IMAP UNSELECT command February 2004
61
62
63 1. Introduction
64
65 Certain types of IMAP clients need to release resources associated
66 with the selected mailbox without selecting a different mailbox.
67 While [IMAP4] provides this functionality (via a SELECT command with
68 a nonexistent mailbox name or reselecting the same mailbox with
69 EXAMINE command), a more clean solution is desirable.
70
71 [IMAP4] defines the CLOSE command that closes the selected mailbox as
72 well as permanently removes all messages with the \Deleted flag set.
73
74 However [IMAP4] lacks a command that simply closes the mailbox
75 without expunging it. This document defines the UNSELECT command for
76 this purpose.
77
78 A server which supports this extension indicates this with a
79 capability name of "UNSELECT".
80
81 "C:" and "S:" in examples show lines sent by the client and server
82 respectively.
83
84 The keywords "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and "MAY" in
85 this document when typed in uppercase are to be interpreted as
86 defined in "Key words for use in RFCs to Indicate Requirement Levels"
87 [KEYWORDS].
88
89 2. UNSELECT Command
90
91 Arguments: none
92
93 Responses: no specific responses for this command
94
95 Result: OK - unselect completed, now in authenticated state
96 BAD - no mailbox selected, or argument supplied but
97 none permitted
98
99 The UNSELECT command frees server's resources associated with the
100 selected mailbox and returns the server to the authenticated
101 state. This command performs the same actions as CLOSE, except
102 that no messages are permanently removed from the currently
103 selected mailbox.
104
105 Example: C: A341 UNSELECT
106 S: A341 OK Unselect completed
107
108
109
110
111
112
113
114 Melnikov Standards Track [Page 2]
115
116 RFC 3691 IMAP UNSELECT command February 2004
117
118
119 3. Security Considerations
120
121 It is believed that this extension doesn't raise any additional
122 security concerns not already discussed in [IMAP4].
123
124 4. Formal Syntax
125
126 The following syntax specification uses the Augmented Backus-Naur
127 Form (ABNF) notation as specified in [ABNF]. Non-terminals
128 referenced but not defined below are as defined by [IMAP4].
129
130 Except as noted otherwise, all alphabetic characters are case-
131 insensitive. The use of upper or lower case characters to define
132 token strings is for editorial clarity only. Implementations MUST
133 accept these strings in a case-insensitive fashion.
134
135 command-select /= "UNSELECT"
136
137 5. IANA Considerations
138
139 IMAP4 capabilities are registered by publishing a standards track or
140 IESG approved experimental RFC. The registry is currently located
141 at:
142
143 http://www.iana.org/assignments/imap4-capabilities
144
145 This document defines the UNSELECT IMAP capabilities. IANA has added
146 this capability to the registry.
147
148 6. Acknowledgments
149
150 UNSELECT command was originally implemented by Tim Showalter in Cyrus
151 IMAP server.
152
153 Also, the author of the document would like to thank Vladimir Butenko
154 and Mark Crispin for reminding that UNSELECT has to be documented.
155 Also thanks to Simon Josefsson for pointing out that there are
156 multiple ways to implement UNSELECT.
157
158
159
160
161
162
163
164
165
166
167
168
169
170 Melnikov Standards Track [Page 3]
171
172 RFC 3691 IMAP UNSELECT command February 2004
173
174
175 7. Normative References
176
177 [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate
178 Requirement Levels", BCP 14, RFC 2119, March 1997.
179
180 [IMAP4] Crispin, M., "Internet Message Access Protocol - Version
181 4rev1", RFC 3501, March 2003.
182
183 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
184 Specifications: ABNF", RFC 2234, November 1997.
185
186 8. Author's Address
187
188 Alexey Melnikov
189 Isode Limited
190 5 Castle Business Village
191 Hampton, Middlesex TW12 2BX
192
193 EMail: Alexey.Melnikov@isode.com
194 URI: http://www.melnikov.ca/
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226 Melnikov Standards Track [Page 4]
227
228 RFC 3691 IMAP UNSELECT command February 2004
229
230
231 9. Full Copyright Statement
232
233 Copyright (C) The Internet Society (2004). This document is subject
234 to the rights, licenses and restrictions contained in BCP 78 and
235 except as set forth therein, the authors retain all their rights.
236
237 This document and the information contained herein are provided on an
238 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE
239 REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE
240 INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR
241 IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF
242 THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
243 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
244
245 Intellectual Property
246
247 The IETF takes no position regarding the validity or scope of any
248 Intellectual Property Rights or other rights that might be claimed
249 to pertain to the implementation or use of the technology
250 described in this document or the extent to which any license
251 under such rights might or might not be available; nor does it
252 represent that it has made any independent effort to identify any
253 such rights. Information on the procedures with respect to
254 rights in RFC documents can be found in BCP 78 and BCP 79.
255
256 Copies of IPR disclosures made to the IETF Secretariat and any
257 assurances of licenses to be made available, or the result of an
258 attempt made to obtain a general license or permission for the use
259 of such proprietary rights by implementers or users of this
260 specification can be obtained from the IETF on-line IPR repository
261 at http://www.ietf.org/ipr.
262
263 The IETF invites any interested party to bring to its attention
264 any copyrights, patents or patent applications, or other
265 proprietary rights that may cover technology that may be required
266 to implement this standard. Please address the information to the
267 IETF at ietf-ipr@ietf.org.
268
269 Acknowledgement
270
271 Funding for the RFC Editor function is currently provided by the
272 Internet Society.
273
274
275
276
277
278
279
280
281
282 Melnikov Standards Track [Page 5]
283
...@@ -52,6 +52,7 @@ imap4d_capability_init () ...@@ -52,6 +52,7 @@ imap4d_capability_init ()
52 "NAMESPACE", 52 "NAMESPACE",
53 "IDLE", 53 "IDLE",
54 "LITERAL+", 54 "LITERAL+",
55 "UNSELECT",
55 "X-VERSION", 56 "X-VERSION",
56 NULL 57 NULL
57 }; 58 };
......
...@@ -19,22 +19,9 @@ ...@@ -19,22 +19,9 @@
19 19
20 #include "imap4d.h" 20 #include "imap4d.h"
21 21
22 /* 22 static int
23 6.4.2. CLOSE Command 23 imap4d_close0 (struct imap4d_command *command, imap4d_tokbuf_t tok,
24 24 int expunge)
25 Arguments: none
26
27 Responses: no specific responses for this command
28
29 Result: OK - close completed, now in authenticated state
30 NO - close failure: no mailbox selected
31 BAD - command unknown or arguments invalid
32
33 The CLOSE command permanently removes from the currently selected
34 mailbox all messages that have the \\Deleted flag set, and returns
35 to authenticated state from selected state. */
36 int
37 imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok)
38 { 25 {
39 const char *msg = NULL; 26 const char *msg = NULL;
40 int status, flags; 27 int status, flags;
...@@ -45,7 +32,7 @@ imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok) ...@@ -45,7 +32,7 @@ imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok)
45 mu_mailbox_get_flags (mbox, &flags); 32 mu_mailbox_get_flags (mbox, &flags);
46 if ((flags & MU_STREAM_READ) == 0) 33 if ((flags & MU_STREAM_READ) == 0)
47 { 34 {
48 status = mu_mailbox_flush (mbox, 1); 35 status = mu_mailbox_flush (mbox, expunge);
49 if (status) 36 if (status)
50 { 37 {
51 mu_diag_output (MU_DIAG_ERROR, 38 mu_diag_output (MU_DIAG_ERROR,
...@@ -59,7 +46,8 @@ imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok) ...@@ -59,7 +46,8 @@ imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok)
59 status = mu_mailbox_close (mbox); 46 status = mu_mailbox_close (mbox);
60 if (status) 47 if (status)
61 { 48 {
62 mu_diag_output (MU_DIAG_ERROR, _("closing mailbox failed: %s"), mu_strerror (status)); 49 mu_diag_output (MU_DIAG_ERROR,
50 _("closing mailbox failed: %s"), mu_strerror (status));
63 msg = "closing mailbox failed"; 51 msg = "closing mailbox failed";
64 } 52 }
65 mu_mailbox_destroy (&mbox); 53 mu_mailbox_destroy (&mbox);
...@@ -68,3 +56,47 @@ imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok) ...@@ -68,3 +56,47 @@ imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok)
68 return util_finish (command, RESP_NO, msg); 56 return util_finish (command, RESP_NO, msg);
69 return util_finish (command, RESP_OK, "Completed"); 57 return util_finish (command, RESP_OK, "Completed");
70 } 58 }
59
60 /*
61 6.4.2. CLOSE Command
62
63 Arguments: none
64
65 Responses: no specific responses for this command
66
67 Result: OK - close completed, now in authenticated state
68 NO - close failure: no mailbox selected
69 BAD - command unknown or arguments invalid
70
71 The CLOSE command permanently removes from the currently selected
72 mailbox all messages that have the \\Deleted flag set, and returns
73 to authenticated state from selected state. */
74 int
75 imap4d_close (struct imap4d_command *command, imap4d_tokbuf_t tok)
76 {
77 return imap4d_close0 (command, tok, 1);
78 }
79
80 /* RFC 3691:
81
82 2. UNSELECT Command
83
84 Arguments: none
85
86 Responses: no specific responses for this command
87
88 Result: OK - unselect completed, now in authenticated state
89 BAD - no mailbox selected, or argument supplied but
90 none permitted
91
92 The UNSELECT command frees server's resources associated with the
93 selected mailbox and returns the server to the authenticated
94 state. This command performs the same actions as CLOSE, except
95 that no messages are permanently removed from the currently
96 selected mailbox.
97 */
98 int
99 imap4d_unselect (struct imap4d_command *command, imap4d_tokbuf_t tok)
100 {
101 return imap4d_close0 (command, tok, 0);
102 }
......
...@@ -38,6 +38,7 @@ struct imap4d_command imap4d_command_table [] = ...@@ -38,6 +38,7 @@ struct imap4d_command imap4d_command_table [] =
38 { "APPEND", imap4d_append, STATE_AUTH | STATE_SEL, STATE_NONE, STATE_NONE, NULL }, 38 { "APPEND", imap4d_append, STATE_AUTH | STATE_SEL, STATE_NONE, STATE_NONE, NULL },
39 { "CHECK", imap4d_check, STATE_SEL, STATE_NONE, STATE_NONE, NULL }, 39 { "CHECK", imap4d_check, STATE_SEL, STATE_NONE, STATE_NONE, NULL },
40 { "CLOSE", imap4d_close, STATE_SEL, STATE_AUTH, STATE_AUTH, NULL }, 40 { "CLOSE", imap4d_close, STATE_SEL, STATE_AUTH, STATE_AUTH, NULL },
41 { "UNSELECT", imap4d_unselect, STATE_SEL, STATE_AUTH, STATE_AUTH, NULL },
41 { "EXPUNGE", imap4d_expunge, STATE_SEL, STATE_NONE, STATE_NONE, NULL }, 42 { "EXPUNGE", imap4d_expunge, STATE_SEL, STATE_NONE, STATE_NONE, NULL },
42 { "SEARCH", imap4d_search, STATE_SEL, STATE_NONE, STATE_NONE, NULL }, 43 { "SEARCH", imap4d_search, STATE_SEL, STATE_NONE, STATE_NONE, NULL },
43 { "FETCH", imap4d_fetch, STATE_SEL, STATE_NONE, STATE_NONE, NULL }, 44 { "FETCH", imap4d_fetch, STATE_SEL, STATE_NONE, STATE_NONE, NULL },
......
...@@ -218,6 +218,7 @@ extern void imap4d_auth_capability (void); ...@@ -218,6 +218,7 @@ extern void imap4d_auth_capability (void);
218 extern int imap4d_capability (struct imap4d_command *, imap4d_tokbuf_t); 218 extern int imap4d_capability (struct imap4d_command *, imap4d_tokbuf_t);
219 extern int imap4d_check (struct imap4d_command *, imap4d_tokbuf_t); 219 extern int imap4d_check (struct imap4d_command *, imap4d_tokbuf_t);
220 extern int imap4d_close (struct imap4d_command *, imap4d_tokbuf_t); 220 extern int imap4d_close (struct imap4d_command *, imap4d_tokbuf_t);
221 extern int imap4d_unselect (struct imap4d_command *, imap4d_tokbuf_t);
221 extern int imap4d_copy (struct imap4d_command *, imap4d_tokbuf_t); 222 extern int imap4d_copy (struct imap4d_command *, imap4d_tokbuf_t);
222 extern int imap4d_copy0 (imap4d_tokbuf_t, int isuid, char **err_text); 223 extern int imap4d_copy0 (imap4d_tokbuf_t, int isuid, char **err_text);
223 extern int imap4d_create (struct imap4d_command *, imap4d_tokbuf_t); 224 extern int imap4d_create (struct imap4d_command *, imap4d_tokbuf_t);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
20 imap4d_start 20 imap4d_start
21 21
22 imap4d_test "CAPABILITY" \ 22 imap4d_test "CAPABILITY" \
23 "CAPABILITY IMAP4rev1 NAMESPACE IDLE LITERAL+ X-VERSION" \ 23 "CAPABILITY IMAP4rev1 NAMESPACE IDLE LITERAL+ UNSELECT X-VERSION" \
24 "OK" 24 "OK"
25 imap4d_test "NOOP" 25 imap4d_test "NOOP"
26 26
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2008 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -40,11 +40,11 @@ imap4d_test "SELECT INBOX"\ ...@@ -40,11 +40,11 @@ imap4d_test "SELECT INBOX"\
40 "OK \[READ-WRITE\] SELECT Completed" 40 "OK \[READ-WRITE\] SELECT Completed"
41 41
42 imap4d_test "STATUS INBOX (MESSAGES RECENT UNSEEN UIDVALIDITY UIDNEXT)" \ 42 imap4d_test "STATUS INBOX (MESSAGES RECENT UNSEEN UIDVALIDITY UIDNEXT)" \
43 -re {STATUS INBOX \(MESSAGES 95 RECENT 95 UNSEEN 95 UIDVALIDITY [0-9]+ UIDNEXT 96 \)} \ 43 -re {STATUS INBOX \(MESSAGES 95 RECENT 95 UNSEEN 95 UIDVALIDITY [0-9]+ UIDNEXT 96\)} \
44 "OK" 44 "OK"
45 45
46 imap4d_test "STATUS mbox1 (MESSAGES RECENT UNSEEN UIDNEXT)" \ 46 imap4d_test "STATUS mbox1 (MESSAGES RECENT UNSEEN UIDNEXT)" \
47 "STATUS mbox1 (MESSAGES 5 RECENT 5 UNSEEN 5 UIDNEXT 6 )" \ 47 "STATUS mbox1 (MESSAGES 5 RECENT 5 UNSEEN 5 UIDNEXT 6)" \
48 "OK" 48 "OK"
49 49
50 imap4d_test "EXAMINE mbox1" \ 50 imap4d_test "EXAMINE mbox1" \
......