idnits 2.17.1 draft-ietf-imapext-condstore-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** Looks like you're using RFC 2026 boilerplate. This must be updated to follow RFC 3978/3979, as updated by RFC 4748. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- ** The document seems to lack a 1id_guidelines paragraph about Internet-Drafts being working documents. ** The document is more than 15 pages and seems to lack a Table of Contents. == No 'Intended status' indicated for this document; assuming Proposed Standard == The page length should not exceed 58 lines per page, but there was 1 longer page, the longest (page 1) being 1104 lines Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 245 instances of too long lines in the document, the longest one being 18 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (June 2003) is 7614 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'UNSEEN 12' is mentioned on line 696, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 697, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 698, but not defined == Missing Reference: 'HIGHESTMODSEQ 20010715194045007' is mentioned on line 701, but not defined == Missing Reference: 'MODIFIED 7' is mentioned on line 349, but not defined -- Looks like a reference, but probably isn't: '9' on line 349 == Missing Reference: 'MODIFIED 12' is mentioned on line 359, but not defined == Missing Reference: 'MODIFIED 101' is mentioned on line 382, but not defined == Missing Reference: 'MODIFIED 2' is mentioned on line 414, but not defined == Unused Reference: 'ACAP' is defined on line 852, but no explicit reference was found in the text ** Obsolete normative reference: RFC 2234 (ref. 'ABNF') (Obsoleted by RFC 4234) ** Obsolete normative reference: RFC 3501 (ref. 'IMAP4') (Obsoleted by RFC 9051) -- Possible downref: Non-RFC (?) normative reference: ref. 'ANNOTATE' -- Possible downref: Non-RFC (?) normative reference: ref. 'SORT' -- Obsolete informational reference (is this intentional?): RFC 2086 (ref. 'ACL') (Obsoleted by RFC 4314) -- Obsolete informational reference (is this intentional?): RFC 1305 (ref. 'NTP') (Obsoleted by RFC 5905) Summary: 6 errors (**), 0 flaws (~~), 11 warnings (==), 8 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 1 Internet Draft: IMAP Extension for Conditional STORE A. Melnikov 2 Document: draft-ietf-imapext-condstore-02.txt S. Hole 3 Expires: December 2003 ACI WorldWide/MessagingDirect 4 June 2003 6 IMAP Extension for Conditional STORE operation 8 Status of this Memo 10 This document is an Internet-Draft and is in full conformance with 11 all provisions of Section 10 of RFC2026. Internet-Drafts are 12 working documents of the Internet Engineering Task Force (IETF), its 13 areas, and its working groups. Note that other groups may also 14 distribute working documents as Internet-Drafts. 16 Internet-Drafts are draft documents valid for a maximum of six 17 months and may be updated, replaced, or obsoleted by other documents 18 at any time. It is inappropriate to use Internet-Drafts as 19 reference material or to cite them other than as "work in progress." 21 The list of current Internet-Drafts can be accessed at 22 http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet- 23 Draft Shadow Directories can be accessed at 24 http://www.ietf.org/shadow.html. 26 Copyright Notice 28 Copyright (C) The Internet Society 2001-2003. All Rights Reserved. 30 Please see the Full Copyright section near the end of this document 31 for more information. 33 Abstract 35 Often, multiple IMAP clients need to coordinate changes to a common 36 IMAP mailbox. Examples include different clients for the same user, 37 and multiple users accessing shared mailboxes. These clients 38 need a mechanism to synchronize state changes for messages within the 39 mailbox. They must be able to guarantee that only one client can change 40 message state (e.g., message flags or annotations) at any time. An 41 example of such an application is use of an IMAP mailbox as a message 42 queue with multiple dequeueing clients. 44 The Conditional Store facility provides a protected update mechanism for 45 message state information that can detect and resolve conflicts between 46 multiple writing mail clients. 48 Table of Contents 50 1 Conventions Used in This Document ......................... X 51 2 Introduction and Overview ................................. X 52 3 IMAP Protocol Changes ..................................... X 53 3.1 New OK untagged responses for SELECT and EXAMINE ......... X 54 3.1.1 HIGHESTMODSEQ response code ............................ X 55 3.1.2 NOMODSEQ response code ................................. X 56 3.2 STORE and UID STORE Commands ............................. X 57 3.3 MODSEQ message data item in FETCH Command ................ X 58 3.4 MODSEQ search criterion in SEARCH ........................ X 59 3.5 MODSEQ Sort Criterion .................................... X 60 3.6 Modified SEARCH and SORT untagged responses .............. X 61 3.7 HIGHESTMODSEQ status data items .......................... X 62 3.8 CONDSTORE parameter to SELECT and EXAMINE ................ X 63 4 Formal Syntax ............................................. X 64 5 Security Considerations ................................... X 65 6 References ................................................ X 66 6.1 Normative References ..................................... X 67 6.2 Informative References ................................... X 68 7 IANA Considerations ....................................... X 69 8 Acknowledgments ........................................... X 70 9 Author's Addresses ........................................ X 71 10 Intellectual Property Rights .............................. X 72 11 Full Copyright Statement .................................. X 74 1. Conventions Used in This Document 76 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 77 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 78 document are to be interpreted as described in RFC 2119 [KEYWORDS]. 80 In examples, lines beginning with "S:" are sent by the IMAP server, and 81 lines beginning with "C:" are sent by the client. Line breaks may appear 82 in example commands solely for editorial clarity; when present in 83 the actual message they are represented by "CRLF". 85 Formal syntax is defined using ABNF [ABNF] as modified by [IMAP4]. 87 The term "metadata" or "metadata item" is used throughout this document. 88 It refers to any system or user defined keyword or an annotation 89 [ANNOTATE]. 91 Some IMAP mailboxes are private, accessible only to the owning user. 92 Other mailboxes are not, either because the owner has set an ACL 93 [ACL] which permits access by other users, or because it is a 94 shared mailbox. Let's call a metadata item "shared" for the mailbox 95 if any changes to the metadata items are persistent and visible to all 96 other users accessing the mailbox. Otherwise the metadata item is called 97 "private". Note, that private metadata items are still visible to all 98 sessions accessing the mailbox as the same user. Also note, that different 99 mailboxes may have different metadata items as shared. 101 See the next section for the definition of a "CONDSTORE-aware client" 102 and a "CONDSTORE enabling command". 104 2. Introduction and Overview 106 The Conditional STORE extension is present in any IMAP4 implementation 107 which returns "CONDSTORE" as one of the supported capabilities in the 108 CAPABILITY command response. 110 Every IMAP message has an associated positive unsigned 64-bit value called a 111 modification sequence (mod-sequence). This is an opaque value updated by 112 the server whenever a metadata item is modified. The value is intended to 113 be used only for comparisons within a server. However, the server MUST 114 guarantee that each STORE command performed on the same mailbox, including 115 simultaneous stores to different metadata items from different connections, 116 will get a different mod-sequence value. Also, for any two successful 117 STORE operations performed in the same session on the same mailbox, 118 the mod-sequence of the second completed operation MUST be greater than 119 the mod-sequence of the first completed. Note that the latter rule disallows 120 the use of the system clock as a mod-sequence, because if system time changes 121 (e.g., a NTP [NTP] client adjusting the time), the next generated value might 122 be less than the previous one. 124 Mod-sequences allow a client that supports the CONDSTORE extension to 125 determine if a message metadata has changed since some known 126 moment. Whenever the state of a flag changes (i.e., the flag is added and 127 before it wasn't set, or the flag is removed and before it was set) the 128 value of the modification sequence for the message MUST be updated. 129 Adding the flag when it is already present or removing when it is not 130 present SHOULD NOT change the mod-sequence. 132 When a message is appended to a mailbox (via the IMAP APPEND command, 133 COPY to the mailbox or using an external mechanism) the server 134 generates a new modification sequence that is higher than the highest 135 modification sequence of all messages in the mailbox and assigns it to 136 the appended message. 138 When an annotation is added, modified or removed the corresponding message 139 mod-sequence MUST be updated. 141 The server MAY store separate (per message) modification sequence values for 142 different metadata items. If the server does so, per message mod-sequence is 143 the highest mod-sequence of all metadata items for the specified message. 145 The server that supports this extention is not required to be able to store 146 mod-sequences for every available mailbox. Section 3.1.2 describes how 147 the server may act if a particular mailbox doesn't support the persistent 148 storage of mod-sequences. 150 This extension makes the following changes to the IMAP4 protocol: 152 a) extends the syntax of the STORE command to allow STORE 153 modifiers 155 b) adds the MODIFIED response code which should be used with 156 an OK response to the STORE command 158 c) adds a new MODSEQ message data item for use with the FETCH command 160 d) adds a new MODSEQ search criterion 162 e) extends the syntax of untagged SEARCH responses to include mod-sequence 164 f) adds new OK untagged responses for the SELECT and EXAMINE commands 166 g) defines an additional parameter to SELECT/EXAMINE commands 168 h) adds the HIGHESTMODSEQ status data item to the STATUS command 170 A client supporting CONDSTORE extension indicates its willingness to receive 171 mod-sequence updates in all untagged FETCH responses by issuing a SELECT or 172 EXAMINE command with the CONDSTORE parameter, or a FETCH, SEARCH, or SORT 173 (if it also supports SORT=MODSEQ extension, see below) command that includes 174 the MODSEQ message data item, or a STORE command with the UNCHANGEDSINCE modifier. 175 The server will include mod-sequence data in all FETCH responses, whether they 176 were caused by a regular STORE, STORE with UNCHANGEDSINCE modifier, or an external 177 agent, until the connection is closed. 179 This document uses the term "CONSTORE-aware client" to refer to a client 180 that announces its willingness to receive mod-sequence updates as described 181 above. The term "CONDSTORE enabling command" will refer any of the commands 182 listed above. 184 This document also defines a new SORT extension with a capability name 185 "SORT=MODSEQ". This extension is upwards compatible with the SORT extension 186 defined in [SORT]. Server implementations that support both the CONDSTORE and 187 SORT extensions SHOULD also support the SORT=MODSEQ extension. The 188 SORT=MODSEQ extension makes the following additions to the SORT extension: 190 a) extends syntax of untagged SORT responses to include mod-sequence 191 (see section 3.6) 193 b) adds a new MODSEQ sort criterion (see sections 3.4 and 3.5) 195 The rest of this document describes the protocol changes more rigorously. 197 3. IMAP Protocol Changes 199 3.1. New OK untagged responses for SELECT and EXAMINE 201 This document adds two new response codes HIGHESTMODSEQ and NOMODSEQ. 202 One of those response codes MUST be returned in the OK untagged 203 response for a successful SELECT and EXAMINE commands. 205 When opening a mailbox the server must check if the mailbox supports 206 the persistent storage of mod-sequences. If the mailbox supports 207 the persistent storage of mod-sequences and mailbox open operation succeeds, 208 the server MUST send the OK untagged response including HIGHESTMODSEQ 209 response code. If the persistent storage for the mailbox is not supported, 210 the server MUST send the OK untagged response including NOMODSEQ response 211 code instead. 213 3.1.1. HIGHESTMODSEQ response code 215 This document adds a new response code that is returned in the OK 216 untagged response for the SELECT and EXAMINE commands. A server 217 supporting the persistent storage of mod-sequences for the mailbox MUST 218 send the OK untagged response including HIGHESTMODSEQ response code with 219 every successful SELECT or EXAMINE command: 221 OK [HIGHESTMODSEQ ] 223 Where is the highest mod-sequence value of all 224 messages in the mailbox. When the server changes UIDVALIDITY for a 225 mailbox, it doesn't have to keep the same HIGHESTMODSEQ for the 226 mailbox. 228 A disconnected client can use the value of HIGHESTMODSEQ to check if 229 it has to refetch flags and/or annotations from the server. If the 230 UIDVALIDITY value has changed for the selected mailbox, the client 231 MUST delete the cached value of HIGHESTMODSEQ. If UIDVALIDITY for 232 the mailbox is the same and if the HIGHESTMODSEQ value stored in 233 the client's cache is less than the value returned by the server, 234 then some metadata items on the server have changed since the last 235 synchronization, and the client needs to update its cache. The client 236 MAY use SEARCH MODSEQ as described in section 3.4 to find out exactly 237 which metadata items have changed. 239 Example: C: A142 SELECT INBOX 240 S: * 172 EXISTS 241 S: * 1 RECENT 242 S: * OK [UNSEEN 12] Message 12 is first unseen 243 S: * OK [UIDVALIDITY 3857529045] UIDs valid 244 S: * OK [UIDNEXT 4392] Predicted next UID 245 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 246 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 247 S: * OK [HIGHESTMODSEQ 20010715194045007] 248 S: A142 OK [READ-WRITE] SELECT completed 250 3.1.2 NOMODSEQ response code 252 A server that doesn't support the persistent storage of mod-sequences for 253 the mailbox MUST send the OK untagged response including NOMODSEQ response 254 code with every successful SELECT or EXAMINE command. 256 Example: C: A142 SELECT INBOX 257 S: * 172 EXISTS 258 S: * 1 RECENT 259 S: * OK [UNSEEN 12] Message 12 is first unseen 260 S: * OK [UIDVALIDITY 3857529045] UIDs valid 261 S: * OK [UIDNEXT 4392] Predicted next UID 262 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 263 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 264 S: * OK [NOMODSEQ] Sorry, this mailbox format doesn't support modsequences 265 S: A142 OK [READ-WRITE] SELECT completed 267 3.2. STORE and UID STORE Commands 269 Arguments: message set 270 OPTIONAL store modifiers 271 message data item name 272 value for message data item 274 Responses: untagged responses: FETCH 276 Result: OK - store completed 277 NO - store error: can't store that data 278 BAD - command unknown or arguments invalid 280 This document extends the syntax of the STORE and UID STORE 281 commands (see section 6.4.6 of [IMAP4]) to include an optional STORE 282 modifier. The document defines the following modifier: 284 UNCHANGEDSINCE 285 For each message specified in the message set the server performs 286 the following. If the mod-sequence of any metadata item of the 287 message is equal or less than the specified UNCHANGEDSINCE value, 288 then the requested operation (as described by the 289 message data item) is performed. If the operation is successful 290 the server MUST update the mod-sequence attribute of the message. 291 An untagged FETCH response MUST be sent (even if the .SILENT suffix 292 is specified) and the response MUST include the MODSEQ message data 293 item. This is required to update the client's cache with the correct 294 mod-sequence values. See section 3.3 for more details. 296 However, if the mod-sequence of any metadata item of the 297 message is greater than the specified UNCHANGEDSINCE value, than 298 the requested operation MUST NOT be performed. In this case, 299 the mod-sequence attribute of the message is not updated, and the 300 message number (or unique identifier in the case of the UID STORE 301 command) is added to the list of messages that failed the UNCHANGESINCE test. 303 When the server finished performing the operation on all the messages 304 in the message set, it checks for a non-empty list of messages that 305 failed the UNCHANGESINCE test. If this list is non-empty, the server MUST 306 return in the tagged response a MODIFIED response code. The MODIFIED 307 response code includes the message set (for STORE) or set of UIDs 308 (for UID STORE) of all messages that failed the UNCHANGESINCE test. 310 Example : 312 All messages pass the UNCHANGESINCE test. 314 C: a103 UID STORE 6,4,8 (UNCHANGEDSINCE 200012121230045) 315 +FLAGS.SILENT (\Deleted) 316 S: * 1 FETCH (UID 4 MODSEQ (200012121231000)) 317 S: * 2 FETCH (UID 6 MODSEQ (200012101230852)) 318 S: * 4 FETCH (UID 8 MODSEQ (200012121130956)) 319 S: a103 OK Conditional Store completed 321 Example: 323 C: a104 STORE * (UNCHANGEDSINCE 200012121230045) +FLAGS.SILENT 324 (\Deleted $Processed) 325 S: * 50 FETCH (MODSEQ (200012111230045)) 326 S: a104 OK Store (conditional) completed 328 Example: 330 In spite of the failure of the conditional STORE operation 331 for message 7, the server continues to process the conditional 332 STORE in order to find all messages which fail the test. 334 C: a105 STORE 7,5,9 (UNCHANGEDSINCE 20000320162338) 335 +FLAGS.SILENT (\Deleted) 336 S: * 5 FETCH (MODSEQ (20000320162350)) 337 S: a105 OK [MODIFIED 7,9] Conditional STORE failed 339 Example: 341 Same as above, but the server follows SHOULD recommendation 342 in section 6.4.6 of [IMAP4]. 344 C: a105 STORE 7,5,9 (UNCHANGEDSINCE 20000320162338) 345 +FLAGS.SILENT (\Deleted) 346 S: * 7 FETCH (MODSEQ (20000320162342) FLAGS (\Seen \Deleted)) 347 S: * 5 FETCH (MODSEQ (20000320162350)) 348 S: * 9 FETCH (MODSEQ (20000320162349) FLAGS (\Answered)) 349 S: a105 OK [MODIFIED 7,9] Conditional STORE failed 351 Use of UNCHANGEDSINCE with a modification sequence of 0 352 always fails if the metadata item exists. A system flag 353 MUST always be considered existent, whether it was set or not. 355 Example: 357 C: a102 STORE 12 (UNCHANGEDSINCE 0) 358 +FLAGS.SILENT ($MDNSent) 359 S: a102 OK [MODIFIED 12] Conditional STORE failed 361 Note: A client trying to make an atomic change to the state of a particular 362 metadata item (or a set of metadata items) should be prepared 363 to deal with the case when the server returns MODIFIED response code 364 if the state of the metadata item being watched hasn't changed (but 365 the state of some other metadata item has). This is necessary, because 366 some servers don't store separate mod-sequences for different metadata 367 items. However, a server implementation SHOULD avoid generating 368 spurious MODIFIED responses for +FLAGS/-FLAGS STORE operations, 369 even when the server stores a single mod-sequence per message. 371 Upon the receipt of MODIFIED response code the client SHOULD try to 372 figure out if the required metadata items have indeed changed. If they 373 haven't the client SHOULD retry the command. 375 Example: 376 C: a106 STORE 100:150 (UNCHANGEDSINCE 200212030000000) 377 +FLAGS.SILENT ($Processed) 378 S: * 100 FETCH (MODSEQ (200303181230852)) 379 S: * 102 FETCH (MODSEQ (200303181230852)) 380 ... 381 S: * 150 FETCH (MODSEQ (200303181230852)) 382 S: a106 OK [MODIFIED 101] Conditional STORE failed 384 the flag $Processed was set on the message 101 ... 385 C: a107 NOOP 386 S: * 101 FETCH (MODSEQ (200303011130956) FLAGS ($Processed)) 387 S: a107 OK 389 Or the flag hasn't changed ... 390 C: b107 NOOP 391 S: * 101 FETCH (MODSEQ (200303011130956) FLAGS (\Deleted \Answered)) 392 S: b107 OK 394 ... and the client retries the operation for the message 100 395 with the updated UNCHANGEDSINCE value 397 C: b108 STORE 100 (UNCHANGEDSINCE 200303011130956) 398 +FLAGS.SILENT ($Processed) 399 S: * 100 FETCH (MODSEQ (200303181230852)) 400 S: b108 OK Conditional Store completed 402 Example: 404 The following example is based on the example from the section 4.2.3 of 405 [RFC-2180] and demonstrates that the MODIFIED response code may be also 406 returned in the tagged NO response. 408 Client tries to conditionally STORE flags on a mixture of expunged 409 and non-expunged messages, one message fails the UNCHANGEDSINCE test. 411 C: B001 STORE 1:7 (UNCHANGEDSINCE 20000320172338) +FLAGS (\SEEN) 412 S: * 1 FETCH FLAGS (MODSEQ (20000320172342) \SEEN) 413 S: * 3 FETCH FLAGS (MODSEQ (20000320172342) \SEEN) 414 S: B001 NO [MODIFIED 2] Some of the messages no longer exist. 416 C: B002 NOOP 417 S: * 4 EXPUNGE 418 S: * 4 EXPUNGE 419 S: * 4 EXPUNGE 420 S: * 4 EXPUNGE 421 S: * 2 FETCH (MODSEQ (20000320172340) FLAGS (\Deleted \Answered)) 422 S: B002 OK NOOP Completed. 424 By receiving FETCH responses for messages 1 and 3, and EXPUNGE 425 responses that indicate that messages 4:7 have been expunged, 426 the client retries the operation only for the message 2. The 427 updated UNCHANGEDSINCE value is used. 429 C: b003 STORE 2 (UNCHANGEDSINCE 20000320172340) +FLAGS (\Seen) 430 S: * 2 FETCH (MODSEQ (20000320180050)) 431 S: b003 OK Conditional Store completed 433 Note: If a message is specified multiple times in the message 434 set, and the server doesn't internally eliminate duplicates from 435 the message set, it MUST NOT fail the conditional STORE 436 operation for the second (or subsequent) occurrence of the message 437 if the operation completed successfully for the first occurrence. 438 For example, if the client specifies: 440 a105 STORE 7,3:9 (UNCHANGEDSINCE 200012121230045) 441 +FLAGS.SILENT (\Deleted) 443 the server must not fail the operation for message 7 as part of 444 processing "3:9" if it succeeded when message 7 was processed 445 the first time. 447 Once the client specified the UNCHANGEDSINCE modifier in a STORE command, 448 the server MUST include the MODSEQ fetch response data items in all 449 subsequent unsolicited FETCH responses. 451 This document also changes the behaviour of the server when it has performed 452 a STORE or UID STORE command and the UNCHANGEDSINCE modifier is not specified. 453 If the operation is successful for a message, the server MUST update 454 the mod-sequence attribute of the message. The server is REQUIRED to 455 include the mod-sequence value whenever it decides to send the 456 unsolicited FETCH response to all CONDSTORE-aware clients that have opened 457 the mailbox containing the message. 459 3.3. MODSEQ message data item in FETCH Command 461 This extension adds a MODSEQ message data item to the FETCH command. 462 The MODSEQ message data item allows clients to retrieve mod-sequence 463 values for a range of messages in the currently selected mailbox. 465 Once the client specified the MODSEQ message data item in a FETCH request, 466 the server MUST include the MODSEQ fetch response data items in all 467 subsequent unsolicited FETCH responses. 469 Syntax: MODSEQ 471 The MODSEQ message data item causes the server to return MODSEQ fetch 472 response data items. 474 Syntax: MODSEQ ( ) 476 MODSEQ response data items contain per-message mod-sequences. 478 The MODSEQ response data item is returned if the client issued FETCH with 479 MODSEQ message data item. It also allows the server to notify the client 480 about mod-sequence changes caused by conditional STOREs (section 3.2) and/or 481 changes caused by external sources. 483 Example: 485 C: a FETCH 1:3 (MODSEQ) 486 S: * 1 FETCH (MODSEQ (20000624140003)) 487 S: * 2 FETCH (MODSEQ (20000624140007)) 488 S: * 3 FETCH (MODSEQ (20000624140005)) 489 S: a OK Fetch complete 491 In this example the client requests per message mod-sequences for a 492 set of messages. 494 When a flag for a message is modified in a different session, the server 495 sends an unsolicited FETCH response containing the mod-sequence for the 496 message. 498 Example: 500 (Session 1, authenticated as a user "alex"). The user adds a shared 501 flag \Deleted: 503 C: A142 SELECT INBOX 504 ... 505 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 506 S: * OK [PERMANENTFLAGS (\Answered \Deleted \Seen \*)] Limited 507 ... 509 C: A160 STORE 7 +FLAGS.SILENT (\Deleted) 510 S: * 7 FETCH (MODSEQ (200012121231000)) 511 S: A160 OK Store completed 513 (Session 2, also authenticated as the user "alex"). Any changes to flags 514 are always reported to all sessions authenticated as the same user as in 515 the session 1. 517 C: C180 NOOP 518 S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (200012121231000)) 519 S: C180 OK Noop completed 521 (Session 3, authenticated as a user "andrew"). As \Deleted is a shared 522 flag, changes in the session 1 are also reported in the session 3: 524 C: D210 NOOP 525 S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (200012121231000)) 526 S: D210 OK Noop completed 528 The user modifies a private flag \Seen in the session 1 ... 530 C: A240 STORE 7 +FLAGS.SILENT (\Seen) 531 S: * 7 FETCH (MODSEQ (200012121231777)) 532 S: A240 OK Store completed 534 ... which is only reported in the session 2 ... 536 C: C270 NOOP 537 S: * 7 FETCH (FLAGS (\Deleted \Answered \Seen) MODSEQ (200012121231777)) 538 S: C270 OK Noop completed 540 ... but not in the session 3. 542 C: D300 NOOP 543 S: D300 OK Noop completed 545 And finally the user removes flags \Answered (shared) and \Seen (private) 546 in the session 1. 548 C: A330 STORE 7 -FLAGS.SILENT (\Answered \Seen) 549 S: * 7 FETCH (MODSEQ (200012121245160)) 550 S: A330 OK Store completed 552 Both changes are reported in the session 2 ... 554 C: C360 NOOP 555 S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160)) 556 S: C360 OK Noop completed 558 ... and only changes to shared flags are reported in session 3. 560 C: D390 NOOP 561 S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160)) 562 S: D390 OK Noop completed 564 3.4. MODSEQ search criterion in SEARCH 566 The MODSEQ criterion for the SEARCH command allows a client to search 567 for the metadata items that were modified since a specified moment. 569 Syntax: MODSEQ [ ] 571 Messages that have modification values which are equal to or 572 greater than . This allows a client, 573 for example, to find out which messages contain metadata items 574 that have changed since the last time it updated its disconnected 575 cache. The client may also specify (name of metadata 576 item) and (type of metadata item) before 577 . can be one of "shared", 578 "priv" (private) or "all". The latter means that the server should use 579 the biggest value among "priv" and "shared" mod-sequences for the 580 metadata item. If the server doesn't store internally separate 581 mod-sequences for different metadata items, it MUST ignore 582 and . Otherwise the server should 583 use them to narrow down the search. 585 For a flag the corresponding has a form 586 "/flags/" as defined in [ANNOTATE]. Note, that 587 the leading "\" character that denotes a system flag has to be 588 escaped as per Section 4.3 of [IMAP4], as the uses 589 syntax for quoted strings. 591 If client specifies a MODSEQ criterion in a SEARCH command and 592 the server returns a non-empty SEARCH result, the server MUST also 593 append (to the end of the untagged SEARCH response) the highest 594 mod-sequence for all messages being returned. See also section 3.6. 596 Example: 597 C: a SEARCH MODSEQ "/flags/\\draft" all 20010320162338 598 ANNOTATION "/comment" "value" "IMAP4" 599 S: * SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 20010917162500) 600 S: a OK Search complete 602 In the above example, the message numbers of any messages 603 containing the string "IMAP4" in the "value" attribute of the 604 "/comment" entry and having a mod-sequence equal to or 605 greater than 20010320162338 for the "\Draft" flag are returned in 606 the search results. 608 Example: 609 C: a SEARCH OR NOT MODSEQ 20010320162338 LARGER 50000 610 S: * SEARCH 611 S: a OK Search complete, nothing found 613 3.5. MODSEQ Sort Criterion 615 If a server implementing CONDSTORE also implements the SORT 616 extension as defined by [SORT], it SHOULD implement the 617 SORT=MODSEQ extension that allows for sorting on per-message 618 mod-sequence. SORT=MODSEQ extension adds MODSEQ sort criterion 619 that allows to sort the matching messages based on their mod-sequence. 621 If client specifies a MODSEQ search (as per section 3.4) or sort 622 criterion in the SORT command and the server returns a non-empty 623 SORT result, the server MUST also append (to the end of the untagged 624 SORT response) the highest mod-sequence for all messages being returned. 625 See also section 3.6. 627 Example (MODSEQ search criterion): 629 C: A282 SORT (SUBJECT MODSEQ) UTF-8 SINCE 1-Feb-2001 630 S: * SORT 2 81 83 84 82 882 (MODSEQ 117) 631 S: A282 OK SORT completed 633 Example (MODSEQ sort criterion): 635 C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 MODSEQ 21 636 S: * SORT 6 3 4 5 2 (MODSEQ 125) 637 S: A283 OK SORT completed 639 Example (MODSEQ search criterion and MODSEQ SORT criterion, 640 but no messages matching the search criteria): 642 C: A284 SORT (MODSEQ) KOI8-R OR NOT MODSEQ 20010320162338 643 SUBJECT "Privet" 644 S: * SORT 645 S: A284 OK Sort complete, nothing found 647 3.6. Modified SEARCH and SORT untagged responses 649 Data: zero or more numbers 650 mod-sequence value (omitted if no match) 652 This document extends syntax of the untagged SEARCH and SORT responses 653 to include mod-sequence for all messages being returned. 655 If a client specifies a MODSEQ criterion in a SEARCH (or UID SEARCH) 656 command and the server returns a non-empty SEARCH result, the server 657 MUST also append (to the end of the untagged SEARCH response) the 658 highest mod-sequence for all messages being returned. See section 659 3.4 for examples. 661 If client specifies a MODSEQ search or sort criterion in a SORT 662 (or UID SORT) command and the server returns a non-empty SORT result, 663 the server MUST also append (to the end of the untagged SORT response) 664 the highest mod-sequence for all messages being returned. See section 665 3.5 for examples. 667 3.7. HIGHESTMODSEQ status data items 669 This document defines a new status data item: 671 HIGHESTMODSEQ 672 The highest mod-sequence value all messages 673 in the mailbox. This is the same value that is returned by the server 674 in the HIGHESTMODSEQ response code in OK untagged response 675 (see section 3.1.1). 677 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES HIGHESTMODSEQ) 678 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 679 HIGHESTMODSEQ 200201011231777) 680 S: A042 OK STATUS completed 682 3.8. CONDSTORE parameter to SELECT and EXAMINE 684 The CONDSTORE extension defines a single optional select parameter 685 "CONDSTORE", which tells the server that it MUST include the MODSEQ 686 fetch response data items in all subsequent unsolicited FETCH responses. 688 The CONDSTORE parameter to SELECT/EXAMINE helps to avoid a race condition 689 that might arise when a metadata item(s) is(are) modified in another session 690 after the server has sent the HIGHESTMODSEQ response code and before the 691 client was able to issue a CONDSTORE enabling command. 693 Example: C: A142 SELECT INBOX (CONDSTORE) 694 S: * 172 EXISTS 695 S: * 1 RECENT 696 S: * OK [UNSEEN 12] Message 12 is first unseen 697 S: * OK [UIDVALIDITY 3857529045] UIDs valid 698 S: * OK [UIDNEXT 4392] Predicted next UID 699 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 700 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 701 S: * OK [HIGHESTMODSEQ 20010715194045007] 702 S: A142 OK [READ-WRITE] SELECT completed, CONDSTORE is now enabled 704 4. Formal Syntax 706 The following syntax specification uses the Augmented Backus-Naur 707 Form (ABNF) notation as specified in [ABNF]. 709 Non-terminals referenced but not defined below are as defined by 710 [IMAP4]. 712 Except as noted otherwise, all alphabetic characters are case- 713 insensitive. The use of upper or lower case characters to define token 714 strings is for editorial clarity only. Implementations MUST accept 715 these strings in a case-insensitive fashion. 717 capability =/ "CONDSTORE" / "SORT=MODSEQ" 719 status = "STATUS" SP mailbox SP 720 "(" status-att-req *(SP status-att-req) ")" 721 ;; redefine STATUS command syntax defined in [IMAP4] 723 status-att-req = status-att / "HIGHESTMODSEQ" 725 status-rsp-info = status-att SP number / 726 "HIGHESTMODSEQ" SP mod-sequence-value 728 store = "STORE" SP set store-modifiers SP store-att-flags 730 store-modifiers = [ SP "(" store-modifier *(SP store-modifier) ")" ] 732 store-modifier = "UNCHANGEDSINCE" SP mod-sequence-valzer 733 ;; Only single "UNCHANGEDSINCE" may be specified 734 ;; in a STORE operation 736 fetch-att =/ fetch-mod-sequence 737 ;; modifies original IMAP4 fetch-att 739 fetch-mod-sequence = "MODSEQ" 741 fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")" 743 search-key =/ search-modsequence 744 ;; modifies original IMAP4 search-key 745 ;; 746 ;; This change applies to all command referencing this 747 ;; non-terminal, in particular SEARCH and SORT. 749 search-modsequence = "MODSEQ" [search-modseq-ext] SP mod-sequence-valzer 751 search-modseq-ext = SP entry-name SP entry-type-req 753 resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value / 754 "NOMODSEQ" / 755 "MODIFIED" SP set 757 entry-name = entry-name-flag / entry-annotate-name 758 ;; The server MUST understand entry-name-flag. 759 ;; If the server also supports [ANNOTATE], it MUST 760 ;; also support entry-annotate-name. 762 entry-flag-name = '"' "/flags/" attr-flag '"' 763 ;; each system or user defined flag 764 ;; is mapped to "/flags/". 765 ;; 766 ;; follows the escape rules used 767 ;; by "quoted" string as described in Section 768 ;; 4.3 of [IMAP4], e.g. for the flag \Seen 769 ;; the corresponding is 770 ;; "/flags/\\seen", and for the flag 771 ;; $MDNSent, the corresponding 772 ;; is "/flags/$mdnsent". 774 entry-annotate-name = entry 775 ;; is defined in [ANNOTATE] 777 entry-type-resp = "priv" | "shared" 778 ;; metadata item type 780 entry-type-req = entry-type-resp | "all" 781 ;; perform SEARCH operation on private 782 ;; metadata item, shared metadata item or both 784 permsg-modsequence = mod-sequence-value 785 ;; per message mod-sequence 787 mod-sequence-value = 1*DIGIT 788 ;; Positive unsigned 64-bit integer (mod-sequence) 789 ;; (1 <= n < 18,446,744,073,709,551,615) 791 mod-sequence-valzer = "0" | mod-sequence-value 793 search_sort_mod_seq = "(" "MODSEQ" SP mod-sequence-value ")" 795 sort-key =/ "MODSEQ" 797 condstore-param = "CONDSTORE" 798 ;; defines the select parameter used with 799 ;; CONDSTORE extension 801 ;;Borrowed from IMAP4rev1 and modified accordingly: 803 mailbox-data =/ "STATUS" SP mailbox SP "(" 804 [status-rsp-info *(SP status-rsp-info)] ")" / 805 "SEARCH" [1*(SP nz-number) SP search_sort_mod_seq] / 806 "SORT" [1*(SP nz-number) SP search_sort_mod_seq] 808 attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" / 809 "\\Seen" / "\\Draft" / attr-flag-keyword / 810 attr-flag-extension 811 ;; Does not include "\\Recent" 813 attr-flag-extension = "\\" atom 814 ;; Future expansion. Client implementations 815 ;; MUST accept flag-extension flags. Server 816 ;; implementations MUST NOT generate 817 ;; flag-extension flags except as defined by 818 ;; future standard or standards-track 819 ;; revisions of [IMAP4]. 821 attr-flag-keyword = atom 823 5. Security Considerations 825 It is believed that the Conditional STORE extension doesn't raise 826 any new security concerns that are not already discussed in [IMAP4]. 828 6. References 830 6.1. Normative References 832 [KEYWORDS] Bradner, "Key words for use in RFCs to Indicate 833 Requirement Levels", RFC 2119, Harvard University, March 1997. 835 [ABNF] Crocker, Overell, "Augmented BNF for Syntax Specifications: 836 ABNF", RFC 2234, Internet Mail Consortium, Demon Internet Ltd, 837 November 1997. 839 [IMAP4] Crispin, M., "Internet Message Access Protocol - Version 840 4rev1", RFC 3501, University of Washington, March 2003. 842 [ANNOTATE] Gellens, R., Daboo, C., "IMAP ANNOTATE Extension", 843 work in progress. 844 846 [SORT] Crispin, M., Murchison, K., "Internet Message Access Protocol -- 847 SORT AND THREAD EXTENSIONS", work in progress. 848 850 6.2. Informative References 852 [ACAP] Newman, Myers, "ACAP -- Application Configuration Access 853 Protocol", RFC 2244, Innosoft, Netscape, November 1997. 854 856 [ACL] Myers, "IMAP4 ACL extension", RFC 2086, Carnegie Mellon, 857 January 1997. 858 860 [NTP] Mills, D, "Network Time Protocol (Version 3) Specification, 861 Implementation and Analysis", RFC 1305, March 1992. 862 864 [RFC-2180] Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 865 RFC 2180, July 1997. 866 868 7. IANA Considerations 870 IMAP4 capabilities are registered by publishing a standards track or 871 IESG approved experimental RFC. The registry is currently located 872 at: 874 http://www.iana.org/assignments/imap4-capabilities 876 This document consitutes registration of the CONDSTORE and SORT=MODSEQ 877 IMAP capabilities. 879 8. Acknowledgments 881 Some text was borrowed from "IMAP ANNOTATE Extension" by Randall Gellens 882 and Cyrus Daboo, and "ACAP -- Application Configuration Access Protocol" 883 by Chris Newman and John Myers. 885 Many thanks to Randall Gellens for his comments on how CONDSTORE should 886 interact with ANNOTATE extension and for thorough review of the document. 888 Authors also acknowledge the feedback provided by Cyrus Daboo, Larry 889 Greenfield, Chris Newman, Harrie Hazewinkel, Arnt Gulbrandsen, Timo 890 Sirainen and Mark Crispin. 892 9. Author's Addresses 894 Alexey Melnikov 895 mailto: mel@isode.com 897 Isode Limited 899 Steve Hole 900 mailto: Steve.Hole@messagingdirect.com 902 ACI WorldWide/MessagingDirect 903 #900, 10117 Jasper Avenue, 904 Edmonton, Alberta, T5J 1W8, CANADA 906 10. Intellectual Property Rights 908 The IETF takes no position regarding the validity or scope of any 909 intellectual property or other rights that might be claimed to pertain 910 to the implementation or use of the technology described in this 911 document or the extent to which any license under such rights might or 912 might not be available; neither does it represent that it has made any 913 effort to identify any such rights. Information on the IETF's 914 procedures with respect to rights in standards-track and 915 standards-related documentation can be found in BCP-11. Copies of 916 claims of rights made available for publication and any assurances of 917 licenses to be made available, or the result of an attempt made to 918 obtain a general license or permission for the use of such proprietary 919 rights by implementors or users of this specification can be obtained 920 from the IETF Secretariat. 922 The IETF invites any interested party to bring to its attention any 923 copyrights, patents or patent applications, or other proprietary 924 rights which may cover technology that may be required to practice 925 this standard. Please address the information to the IETF Executive 926 Director. 928 11. Full Copyright Statement 930 Copyright (C) The Internet Society 2001-2003. All Rights Reserved. 932 This document and translations of it may be copied and furnished to 933 others, and derivative works that comment on or otherwise explain it 934 or assist in its implementation may be prepared, copied, published 935 and distributed, in whole or in part, without restriction of any 936 kind, provided that the above copyright notice and this paragraph 937 are included on all such copies and derivative works. However, this 938 document itself may not be modified in any way, such as by removing 939 the copyright notice or references to the Internet Society or other 940 Internet organizations, except as needed for the purpose of 941 developing Internet standards in which case the procedures for 942 copyrights defined in the Internet Standards process must be 943 followed, or as required to translate it into languages other than 944 English. 946 The limited permissions granted above are perpetual and will not be 947 revoked by the Internet Society or its successors or assigns. 949 This document and the information contained herein is provided on an 950 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING 951 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 952 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 953 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 954 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 956 Acknowledgement 958 Funding for the RFC Editor function is currently provided by the 959 Internet Society. 961 Appendix A. Open Issues and Change History 963 Note that this appendix will be removed before publication. 965 0.1. Change History 967 Changes from draft-ietf-imapext-condstore-01 968 1. Fixed missing \\ in one example. 969 2. Added explanatory comment that search-key modifications apply at 970 least to SEARCH and SORT command. 971 3. Don't require from a conditional store operation to be atomic accross 972 message set, updated text and examples. 973 4. Added SORT=MODSEQ extension and reworked text in the Introduction section. 974 5. Added Conditional STORE example based on suggestions from RFC 2180. 975 6. Removed the paragraph about DOS attack from the Security considerations 976 section, as it doesn't apply anymore. 977 7. Updated entry-name ABNF. 978 8. Added an optional CONDSTORE parameter to SELECT/EXAMINE. 980 Changes from draft-ietf-imapext-condstore-00 981 1. Dropped "/message" prefix in entry names as per decision in San Francisco. 982 2. Fixed ABNF for SEARCH and SORT untagged responses. 983 3. Changed "private" to "priv" to be consistent with ANNOTATE. 984 4. MODIFIED response code is now returned in OK response, not NO. 985 5. Added NOMODSEQ response code. 987 Changes from draft-melnikov-imap-condstore-09: 988 1. Some text clarifications based on suggestions by Harrie Hazewinkel 989 2. Added paragraph about mailbox locking and DOS when conditional STORE 990 operation is performed on a large mailbox. 991 3. Fixed syntax of to match the ANNOTATE extention. 992 4. Added sentence that a system flag MUST always be considered existent, 993 when UNCHANGEDSINCE 0 is used. Is this a good idea? 994 5. Clarified client behavior upon receipt of MODIFIED response code. 995 6. Updated ABNF to clarify where 0 is allowed as mod-sequence and where 996 it is not. 997 7. Got rid of MODSEQ response code and return this data in the untagged 998 SEARCH/SORT responses. 999 8. Updated RFC number for the IMAP4rev1 document. 1001 Changes from -08 to -09: 1002 1. Added an extended example about reporting regular (non-conditional) flag 1003 changes to other sessions. 1004 2. Simplified FETCH MODSEQ syntax by removing per-metadata requests and 1005 responses. 1007 Changes from -07 to -08: 1008 1. Added note saying the change to UIDVALIDITY also invalidates HIGHESTMODSEQ. 1009 2. Fixed several bugs in ABNF for STATUS and STORE commands. 1011 Changes from -06 to -07: 1012 1. Added clarification that when a server does command reordering, the second 1013 completed operation gets the higher mod sequence. 1014 2. Renamed annotation type specifier "both" to "all" as per suggestion 1015 from Minneapolis meeting. 1016 3. Removed PERFLAGMODSEQ capability, as it doesn't buy anything: a client 1017 has to work with both types of servers (i.e. servers that support per 1018 message per flag modseqs and servers that support only per message 1019 modseqs) anyway. 1020 4. Per flag mod-sequences are optional for a server to return. Updated syntax. 1021 5. Allow MODSEQ response code only as a result of SEARCH/SORT as suggested 1022 by John Myers. MODSEQ response code is not allowed after FETCH or STORE. 1024 Changes from -05 to -06: 1025 1. Replaced "/message/flags/system" with "/message/flags" to 1026 match ANNOTATE draft. 1027 2. Extended FETCH/SEARCH/SORT syntax to allow for specifying 1028 whether an operation should be performed on a shared or a private 1029 annotation (or both). 1030 3. Corrected some examples. 1032 Changes from -04 to -05: 1033 1. Added support for SORT extension. 1034 2. Multiple language/spelling fixes by Randall Gellens. 1036 Changes from -03 to -04: 1037 1. Added text saying that MODSEQ fetch data items cause server 1038 to include MODSEQ data response in all subsuquent unsolicited FETCH 1039 responses. 1040 2. Added "authors address" section. 1042 Changes from -02 to -03: 1043 1. Changed MODTIME untagged response to MODTIME response code. 1044 2. Added MODTIME response code to the tagged OK response for SEARCH. 1045 Updated examples accordingly. 1046 3. Changed rule for sending untagged FETCH response as a result of 1047 STORE when .SILENT prefix is used. If .SILENT prefix is used, 1048 server doesn't have to send untagged FETCH response, because 1049 MODTIME response code already contains modtime. 1050 4. Renamed MODTIME to MODSEQ to make sure there is no confusion 1051 between mod-sequence and ACAP modtime. 1052 5. Minor ABNF changes. 1053 6. Minor language corrections. 1055 Changes from -01 to -02: 1056 1. Added MODTIME data item to STATUS command. 1057 2. Added OK untagged response to SELECT/EXAMINE. 1058 3. Clarified that MODIFIED response code contains list of UIDs for 1059 conditional UID STORE and message set for STORE. 1060 4. Added per-message modtime. 1061 5. Added PERFLAGMODTIME capability. 1062 6. Fixed several bugs in examples. 1063 7. Added more comments to ABNF. 1065 Changes from -00 to -01: 1066 1. Refreshed the list of Open Issues. 1067 2. Changed "attr-name" to "entry-name", because modtime applies to 1068 entry, not attribute. 1069 3. Added MODTIME untagged response. 1070 4. Cleaned up ABNF. 1071 5. Added "Acknowledgments" section. 1072 6. Fixed some spelling mistakes.