idnits 2.17.1 draft-ietf-imapext-condstore-01.txt: ** The Abstract section seems to be numbered 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 929 lines Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** There are 175 instances of too long lines in the document, the longest one being 18 characters in excess of 72. ** There are 3 instances of lines with control characters in the document. 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 (April 2003) is 7675 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 334, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 335, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 336, but not defined == Missing Reference: 'HIGHESTMODSEQ 20010715194045007' is mentioned on line 322, but not defined == Missing Reference: 'MODIFIED 7' is mentioned on line 372, but not defined -- Looks like a reference, but probably isn't: '9' on line 372 == Missing Reference: 'MODIFIED 12' is mentioned on line 386, but not defined == Missing Reference: 'MODIFIED 101' is mentioned on line 405, but not defined == Unused Reference: 'ACAP' is defined on line 831, 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: 9 errors (**), 0 flaws (~~), 10 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-01.txt S. Hole 3 Expires: October 2003 ACI WorldWide/MessagingDirect 4 April 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 0.1. Open issues 32 1). Should conditional STORE be atomic accross message set (i.e. either 33 all messages in message set weren't changed since and conditional 34 STORE succeeds or operation fails for all messages)? 35 This can be difficult to implement for some servers. 37 Is a server allowed to reply NO to a conditional STORE operation that 38 contains more than one message? Do we need a special response code 39 for this (probably yes). 41 0.2. Change History 43 Changes from draft-ietf-imapext-condstore-00 44 1. Dropped "/message" prefix in entry names as per decision in San Francisco. 45 2. Fixed ABNF for SEARCH and SORT untagged responses. 46 3. Changed "private" to "priv" to be consistent with ANNOTATE. 47 4. MODIFIED response code is now returned in OK response, not NO. 48 5. Added NOMODSEQ response code. 50 Changes from draft-melnikov-imap-condstore-09: 51 1. Some text clarifications based on suggestions by Harrie Hazewinkel 52 2. Added paragraph about mailbox locking and DOS when conditional STORE 53 operation is performed on a large mailbox. 54 3. Fixed syntax of to match the ANNOTATE extention. 55 4. Added sentence that a system flag MUST always be considered existent, 56 when UNCHANGEDSINCE 0 is used. Is this a good idea? 57 5. Clarified client behavior upon receipt of MODIFIED response code. 58 6. Updated ABNF to clarify where 0 is allowed as mod-sequence and where 59 it is not. 60 7. Got rid of MODSEQ response code and return this data in the untagged 61 SEARCH/SORT responses. 62 8. Updated RFC number for the IMAP4rev1 document. 64 Changes from -08 to -09: 65 1. Added an extended example about reporting regular (non-conditional) flag 66 changes to other sessions. 67 2. Simplified FETCH MODSEQ syntax by removing per-metadata requests and 68 responses. 70 Changes from -07 to -08: 71 1. Added note saying the change to UIDVALIDITY also invalidates HIGHESTMODSEQ. 72 2. Fixed several bugs in ABNF for STATUS and STORE commands. 74 Changes from -06 to -07: 75 1. Added clarification that when a server does command reordering, the second 76 completed operation gets the higher mod sequence. 77 2. Renamed annotation type specifier "both" to "all" as per suggestion 78 from Minneapolis meeting. 79 3. Removed PERFLAGMODSEQ capability, as it doesn't buy anything: a client 80 has to work with both types of servers (i.e. servers that support per 81 message per flag modseqs and servers that support only per message 82 modseqs) anyway. 83 4. Per flag mod-sequences are optional for a server to return. Updated syntax. 84 5. Allow MODSEQ response code only as a result of SEARCH/SORT as suggested 85 by John Myers. MODSEQ response code is not allowed after FETCH or STORE. 87 Changes from -05 to -06: 88 1. Replaced "/message/flags/system" with "/message/flags" to 89 match ANNOTATE draft. 90 2. Extended FETCH/SEARCH/SORT syntax to allow for specifying 91 whether an operation should be performed on a shared or a private 92 annotation (or both). 93 3. Corrected some examples. 95 Changes from -04 to -05: 96 1. Added support for SORT extension. 97 2. Multiple language/spelling fixes by Randall Gellens. 99 Changes from -03 to -04: 100 1. Added text saying that MODSEQ fetch data items cause server 101 to include MODSEQ data response in all subsuquent unsolicited FETCH 102 responses. 103 2. Added "authors address" section. 105 Changes from -02 to -03: 106 1. Changed MODTIME untagged response to MODTIME response code. 107 2. Added MODTIME response code to the tagged OK response for SEARCH. 108 Updated examples accordingly. 109 3. Changed rule for sending untagged FETCH response as a result of 110 STORE when .SILENT prefix is used. If .SILENT prefix is used, 111 server doesn't have to send untagged FETCH response, because 112 MODTIME response code already contains modtime. 113 4. Renamed MODTIME to MODSEQ to make sure there is no confusion 114 between mod-sequence and ACAP modtime. 115 5. Minor ABNF changes. 116 6. Minor language corrections. 118 Changes from -01 to -02: 119 1. Added MODTIME data item to STATUS command. 120 2. Added OK untagged response to SELECT/EXAMINE. 121 3. Clarified that MODIFIED response code contains list of UIDs for 122 conditional UID STORE and message set for STORE. 123 4. Added per-message modtime. 124 5. Added PERFLAGMODTIME capability. 125 6. Fixed several bugs in examples. 126 7. Added more comments to ABNF. 128 Changes from -00 to -01: 129 1. Refreshed the list of Open Issues. 130 2. Changed "attr-name" to "entry-name", because modtime applies to 131 entry, not attribute. 132 3. Added MODTIME untagged response. 133 4. Cleaned up ABNF. 134 5. Added "Acknowledgments" section. 135 6. Fixed some spelling mistakes. 137 Table of Contents 139 1 Abstract .................................................. X 140 2 Conventions Used in This Document ......................... X 141 3 Introduction and Overview ................................. X 142 4 IMAP Protocol Changes ..................................... X 143 4.1 New OK untagged responses for SELECT and EXAMINE ......... X 144 4.1.1 HIGHESTMODSEQ response code ............................ X 145 4.1.2 NOMODSEQ response code ................................. X 146 4.2 STORE and UID STORE Commands ............................. X 147 4.3 MODSEQ message data item in FETCH Command ................ X 148 4.4 MODSEQ search criterion in SEARCH ........................ X 149 4.5 MODSEQ Sort Criterion .................................... X 150 4.6 Modified SEARCH and SORT untagged responses .............. X 151 4.7 HIGHESTMODSEQ status data items .......................... X 152 5 Formal Syntax ............................................. X 153 6 Security Considerations ................................... X 154 7 References ................................................ X 155 7.1 Normative References ..................................... X 156 7.2 Informative References ................................... X 157 8 Acknowledgments ........................................... X 158 9 Author's Addresses ........................................ X 159 10 Full Copyright Statement ................................. X 161 1. Abstract 163 Often, multiple IMAP clients need to coordinate changes to a common 164 IMAP mailbox. Examples include different clients for the same user, 165 and multiple users accessing shared mailboxes. These clients 166 need a mechanism to synchronize state changes for messages within the 167 mailbox. They must be able to guarantee that only one client can change 168 message state (e.g., message flags or annotations) at any time. An 169 example of such an application is use of an IMAP mailbox as a message 170 queue with multiple dequeueing clients. 172 The Conditional Store facility provides a protected update mechanism for 173 message state information that can detect and resolve conflicts between 174 multiple writing mail clients. 176 2. Conventions Used in This Document 178 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 179 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 180 document are to be interpreted as described in RFC 2119 [KEYWORDS]. 182 In examples, lines beginning with "S:" are sent by the IMAP server, and 183 lines beginning with "C:" are sent by the client. Line breaks may appear 184 in example commands solely for editorial clarity; when present in 185 the actual message they are represented by "CRLF". 187 Formal syntax is defined using ABNF [ABNF] as modified by [IMAP4]. 189 The term "metadata" or "metadata item" is used throughout this document. 190 It refers to any system or user defined keyword or an annotation 191 [ANNOTATE]. 193 Some IMAP mailboxes are private, accessible only to the owning user. 194 Other mailboxes are not, either because the owner has set an ACL 195 [ACL] which permits access by other users, or because it is a 196 shared mailbox. Let's call a metadata item "shared" for the mailbox 197 if any changes to the metadata items are persistent and visible to all 198 other users accessing the mailbox. Otherwise the metadata item is called 199 "private". Note, that private metadata items are still visible to all 200 sessions accessing the mailbox as the same user. Also note, that different 201 mailboxes may have different metadata items as shared. 203 3. Introduction and Overview 205 The Conditional STORE extension is present in any IMAP4 implementation 206 which returns "CONDSTORE" as one of the supported capabilities in the 207 CAPABILITY command response. 209 Every IMAP message has an associated positive unsigned 64-bit value called a 210 modification sequence (mod-sequence). This is an opaque value updated by 211 the server whenever a metadata item is modified. The value is intended to 212 be used only for comparisons within a server. However, the server MUST 213 guarantee that each STORE command performed on the same mailbox, including 214 simultaneous stores to different metadata items from different connections, 215 will get a different mod-sequence value. Also, for any two successful 216 STORE operations performed in the same session on the same mailbox, 217 the mod-sequence of the second completed operation MUST be greater than 218 the mod-sequence of the first completed. Note that the latter rule disallows 219 the use of the system clock as a mod-sequence, because if system time changes 220 (e.g., a NTP [NTP] client adjusting the time), the next generated value might 221 be less than the previous one. 223 Mod-sequences allow a client that supports the CONDSTORE extension to 224 determine if a message metadata has changed since some known 225 moment. Whenever the state of a flag changes (i.e., the flag is added and 226 before it wasn't set, or the flag is removed and before it was set) the 227 value of the modification sequence for the message MUST be updated. 228 Adding the flag when it is already present or removing when it is not 229 present SHOULD NOT change the mod-sequence. 231 When a message is appended to a mailbox (via the IMAP APPEND command, 232 COPY to the mailbox or using an external mechanism) the server 233 generates a new modification sequence that is higher than the highest 234 modification sequence of all messages in the mailbox and assigns it to 235 the appended message. 237 When an annotation is added, modified or removed the corresponding message 238 mod-sequence MUST be updated. 240 The server MAY store separate (per message) modification sequence values for 241 different metadata items. If the server does so, per message mod-sequence is 242 the highest mod-sequence of all metadata items for the specified message. 244 The server that supports this extention is not required to be able to store 245 mod-sequences for every available mailbox. Section 4.1.2 describes how 246 the server may act if a particular mailbox doesn't support the persistent 247 storage of mod-sequences. 249 This extension makes the following changes to the IMAP4 protocol: 251 a) extends the syntax of the STORE command to allow STORE 252 modifiers 254 b) adds the MODIFIED response code which should be used with 255 an OK response to the STORE command 257 c) adds a new MODSEQ message data item for use with the FETCH command 259 d) adds a new MODSEQ search criterion 261 e) extends syntax of untagged SEARCH and SORT responses to include 262 mod-sequence. 264 f) adds a new OK untagged responses for the SELECT and EXAMINE commands 266 g) adds the HIGHESTMODSEQ status data item to the STATUS command 268 h) adds a new MODSEQ sort criterion 270 The rest of this document describes the protocol changes more rigorously. 272 4. IMAP Protocol Changes 274 4.1. New OK untagged responses for SELECT and EXAMINE 276 This document adds two new response codes HIGHESTMODSEQ and NOMODSEQ. 277 One of those response codes MUST be returned in the OK untagged 278 response for a successful SELECT and EXAMINE commands. 280 When opening a mailbox the server must check if the mailbox supports 281 the persistent storage of mod-sequences. If the mailbox supports 282 the persistent storage of mod-sequences and mailbox open operation succeeds, 283 the server MUST send the OK untagged response including HIGHESTMODSEQ 284 response code. If the persistent storage for the mailbox is not supported, 285 the server MUST send the OK untagged response including NOMODSEQ response 286 code instead. 288 4.1.1. HIGHESTMODSEQ response code 290 This document adds a new response code that is returned in the OK 291 untagged response for the SELECT and EXAMINE commands. A server 292 supporting the persistent storage of mod-sequences for the mailbox MUST 293 send the OK untagged response including HIGHESTMODSEQ response code with 294 every successful SELECT or EXAMINE command: 296 OK [HIGHESTMODSEQ ] 298 Where is the highest mod-sequence value of all 299 messages in the mailbox. When the server changes UIDVALIDITY for a 300 mailbox, it doesn't have to keep the same HIGHESTMODSEQ for the 301 mailbox. 303 A disconnected client can use the value of HIGHESTMODSEQ to check if 304 it has to refetch flags and/or annotations from the server. If the 305 UIDVALIDITY value has changed for the selected mailbox, the client 306 MUST delete the cached value of HIGHESTMODSEQ. If UIDVALIDITY for 307 the mailbox is the same and if the HIGHESTMODSEQ value stored in 308 the client's cache is less than the value returned by the server, 309 then some metadata items on the server have changed since the last 310 synchronization, and the client needs to update its cache. The client 311 MAY use SEARCH MODSEQ as described in section 4.4 to find out exactly 312 which metadata items have changed. 314 Example: C: A142 SELECT INBOX 315 S: * 172 EXISTS 316 S: * 1 RECENT 317 S: * OK [UNSEEN 12] Message 12 is first unseen 318 S: * OK [UIDVALIDITY 3857529045] UIDs valid 319 S: * OK [UIDNEXT 4392] Predicted next UID 320 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 321 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 322 S: * OK [HIGHESTMODSEQ 20010715194045007] 323 S: A142 OK [READ-WRITE] SELECT completed 325 4.1.2 NOMODSEQ response code 327 A server that doesn't support the persistent storage of mod-sequences for 328 the mailbox MUST send the OK untagged response including NOMODSEQ response 329 code with every successful SELECT or EXAMINE command. 331 Example: C: A142 SELECT INBOX 332 S: * 172 EXISTS 333 S: * 1 RECENT 334 S: * OK [UNSEEN 12] Message 12 is first unseen 335 S: * OK [UIDVALIDITY 3857529045] UIDs valid 336 S: * OK [UIDNEXT 4392] Predicted next UID 337 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 338 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 339 S: * OK [NOMODSEQ] Sorry, this mailbox format doesn't support modsequences 340 S: A142 OK [READ-WRITE] SELECT completed 342 4.2. STORE and UID STORE Commands 344 Arguments: message set 345 OPTIONAL store modifiers 346 message data item name 347 value for message data item 349 Responses: untagged responses: FETCH 351 Result: OK - store completed 352 NO - store error: can't store that data 353 BAD - command unknown or arguments invalid 355 This document extends the syntax of the STORE and UID STORE 356 commands (see section 6.4.6 of [IMAP4]) to include an optional STORE 357 modifier. The document defines the following modifier: 359 UNCHANGEDSINCE 360 If the mod-sequence of any metadata item specified in the STORE 361 operation for any message in the message set is greater than the 362 specified unchangedsince value, then the command MUST NOT change 363 any flags. Instead, the server replies with the OK tagged response that 364 includes a MODIFIED response code. The MODIFIED response code includes 365 the message set (for STORE) or set of UIDs (for UID STORE) 366 of all messages that failed the UNCHANGESINCE test. 368 Example: 370 C: a101 STORE 7,5,9 (UNCHANGEDSINCE 20000320162338) 371 +FLAGS.SILENT (\Deleted) 372 S: a101 OK [MODIFIED 7,9] Conditional STORE failed 374 In spite of the failure of the conditional STORE operation 375 for message 7, the server continues to process the conditional 376 STORE in order to find all messages which fail the test. 378 Use of UNCHANGEDSINCE with a modification sequence of 0 379 always fails if the metadata item exists. A system flag 380 MUST always be considered existent, whether it was set or not. 382 Example: 384 C: a102 STORE 12 (UNCHANGEDSINCE 0) 385 +FLAGS.SILENT ($MDNSent) 386 S: a102 OK [MODIFIED 12] Conditional STORE failed 388 Note: A client trying to atomically change the state of a particular 389 flag (or a set of flags) should be prepared to deal with the case 390 when the server returns MODIFIED response code if the state 391 of the flag being watched hasn't changed (but the state of some 392 other flag has). This is necessary, because some servers don't store 393 separate mod-sequences for different flags or annotations. However, 394 server implementations are discouraged from doing that, as it is 395 possible not to return spurious errors even when storing a single 396 mod-sequence per message. 398 Upon the receipt of MODIFIED response code the client SHOULD try to 399 figure out if the required flags have indeed changed. If they haven't 400 the client SHOULD retry the command. 402 Example: 403 C: a106 STORE 100:150 (UNCHANGEDSINCE 200212030000000) 404 +FLAGS.SILENT ($Processed) 405 S: a106 OK [MODIFIED 101] Conditional STORE failed 407 the flag $Processed was set on the message 101 ... 408 C: a107 NOOP 409 S: * 101 FETCH (MODSEQ (200303011130956) FLAGS ($Processed)) 410 S: a107 OK 412 ... so the client retries the operation for the rest of the messages 414 C: a108 STORE 100,102:150 (UNCHANGEDSINCE 200303011130956) 415 +FLAGS.SILENT ($Processed) 416 S: * 100 FETCH (MODSEQ (200303181230852)) 417 S: * 102 FETCH (MODSEQ (200303181230852)) 418 ... 419 S: a108 OK Conditional Store completed 421 Or the flag hasn't changed ... 422 C: b107 NOOP 423 S: * 101 FETCH (MODSEQ (200303011130956) FLAGS (\Deleted \Answered)) 424 S: b107 OK 426 ... and the client retries the operation for all messages 428 C: b108 STORE 100:150 (UNCHANGEDSINCE 200212030000000) 429 +FLAGS.SILENT ($Processed) 430 S: * 100 FETCH (MODSEQ (200303181230852)) 431 S: * 101 FETCH (MODSEQ (200303181230852)) 432 S: * 102 FETCH (MODSEQ (200303181230852)) 433 ... 434 S: b108 OK Conditional Store completed 436 If the operation is successful the server MUST update the 437 mod-sequence attribute for every message that was changed. 438 Untagged FETCH responses MUST be sent (even if .SILENT is 439 specified) and each response MUST include MODSEQ message data 440 item if its mod-sequence has changed. This is required to 441 update clients cache with the correct mod-sequence values. 442 See section 4.3 for more details. 444 Example: 446 C: a103 UID STORE 6,4,8 (UNCHANGEDSINCE 200012121230045) 447 +FLAGS.SILENT (\Deleted) 448 S: * 1 FETCH (UID 4 MODSEQ (200012121231000)) 449 S: * 2 FETCH (UID 6 MODSEQ (200012101230852)) 450 S: * 4 FETCH (UID 8 MODSEQ (200012121130956)) 451 S: a103 OK Conditional Store completed 453 Example: 455 C: a104 STORE * (UNCHANGEDSINCE 200012121230045) +FLAGS.SILENT 456 (\Deleted $Processed) 457 S: * 50 FETCH (MODSEQ (200012111230045)) 458 S: a104 OK Store (conditional) completed 460 Note: If a message is specified multiple times in the message 461 set, and the server doesn't internally eliminate duplicates from 462 the message set, it MUST NOT fail the conditional STORE 463 operation for the second (or subsequent) occurrence of the message 464 if the operation completed successfully for the first occurrence. 465 For example, if the client specifies: 467 a105 STORE 7,3:9 (UNCHANGEDSINCE 200012121230045) 468 +FLAGS.SILENT (\Deleted) 470 the server must not fail the operation for message 7 as part of 471 processing "3:9" if it succeeded when message 7 was processed 472 the first time. 474 4.3. MODSEQ message data item in FETCH Command 476 This extension adds a MODSEQ message data item to the FETCH command. 477 The MODSEQ message data item allows clients to retrieve mod-sequence 478 values for a range of messages in the currently selected mailbox. 480 Once the client specified the MODSEQ message data item in a FETCH request, 481 the server MUST include the MODSEQ fetch response data items in all 482 subsequent unsolicited FETCH responses. 484 Syntax: MODSEQ 486 The MODSEQ message data item causes the server to return MODSEQ fetch 487 response data items. 489 Syntax: MODSEQ ( ) 491 MODSEQ response data items contain per-message mod-sequences. 493 The MODSEQ response data item is returned if the client issued FETCH with 494 MODSEQ message data item. It also allows the server to notify the client 495 about mod-sequence changes caused by conditional STOREs (section 4.2) and/or 496 changes caused by external sources. 498 Example: 500 C: a FETCH 1:3 (MODSEQ) 501 S: * 1 FETCH (MODSEQ (20000624140003)) 502 S: * 2 FETCH (MODSEQ (20000624140007)) 503 S: * 3 FETCH (MODSEQ (20000624140005)) 504 S: a OK Fetch complete 506 In this example the client requests per message mod-sequences for a 507 set of messages. 509 When a flag for a message is modified in a different session, the server 510 sends an unsolicited FETCH response containing the mod-sequence for the 511 message. 513 Example: 515 (Session 1, authenticated as a user "alex"). The user adds a shared 516 flag \Deleted: 518 C: A142 SELECT INBOX 519 ... 520 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 521 S: * OK [PERMANENTFLAGS (\Answered \Deleted \Seen \*)] Limited 522 ... 524 C: A160 STORE 7 +FLAGS.SILENT (\Deleted) 525 S: * 7 FETCH (MODSEQ (200012121231000)) 526 S: A160 OK Store completed 528 (Session 2, also authenticated as the user "alex"). Any changes to flags 529 are always reported to all sessions authenticated as the same user as in 530 the session 1. 532 C: C180 NOOP 533 S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (200012121231000)) 534 S: C180 OK Noop completed 536 (Session 3, authenticated as a user "andrew"). As \Deleted is a shared 537 flag, changes in the session 1 are also reported in the session 3: 539 C: D210 NOOP 540 S: * 7 FETCH (FLAGS (\Deleted \Answered) MODSEQ (200012121231000)) 541 S: D210 OK Noop completed 543 The user modifies a private flag \Seen in the session 1 ... 545 C: A240 STORE 7 +FLAGS.SILENT (\Seen) 546 S: * 7 FETCH (MODSEQ (200012121231777)) 547 S: A240 OK Store completed 549 ... which is only reported in the session 2 ... 551 C: C270 NOOP 552 S: * 7 FETCH (FLAGS (\Deleted \Answered \Seen) MODSEQ (200012121231777)) 553 S: C270 OK Noop completed 555 ... but not in the session 3. 557 C: D300 NOOP 558 S: D300 OK Noop completed 560 And finally the user removes flags \Answered (shared) and \Seen (private) 561 in the session 1. 563 C: A330 STORE 7 -FLAGS.SILENT (\Answered \Seen) 564 S: * 7 FETCH (MODSEQ (200012121245160)) 565 S: A330 OK Store completed 567 Both changes are reported in the session 2 ... 569 C: C360 NOOP 570 S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160)) 571 S: C360 OK Noop completed 573 ... and only changes to shared flags are reported in session 3. 575 C: D390 NOOP 576 S: * 7 FETCH (FLAGS (\Deleted) MODSEQ (200012121245160)) 577 S: D390 OK Noop completed 579 4.4. MODSEQ search criterion in SEARCH 581 The MODSEQ criterion for the SEARCH command allows a client to search 582 for the metadata items that were modified since a specified moment. 584 Syntax: MODSEQ [ ] 586 Messages that have modification values which are equal to or 587 greater than . This allows a client, 588 for example, to find out which messages contain metadata items 589 that have changed since the last time it updated its disconnected 590 cache. The client may also specify (name of metadata 591 item) and (type of metadata item) before 592 . can be one of "shared", 593 "priv" (private) or "all". The latter means that the server should use 594 the biggest value among "priv" and "shared" mod-sequences for the 595 metadata item. If the server doesn't store internally separate 596 mod-sequences for different flags and annotations, it MUST ignore 597 and . Otherwise the server should 598 use them to narrow down the search. 600 For a flag the corresponding has a form 601 "/flags/" as defined in [ANNOTATE]. Note, that 602 the leading "\" character that denotes a system flag has to be 603 escaped as per Section 4.3 of [IMAP4], as the uses 604 syntax for quoted strings. 606 If client specifies a MODSEQ criterion in a SEARCH command and 607 the server returns a non-empty SEARCH result, the server MUST also 608 return a MODSEQ response code in the tagged OK response. The MODSEQ 609 response code covers all messages returned in the untagged SEARCH results. 610 See also section 4.6. 612 Example: 613 C: a SEARCH MODSEQ "/flags/draft" all 20010320162338 614 ANNOTATION "/comment" "value" "IMAP4" 615 S: * SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 20010917162500) 616 S: a OK Search complete 618 In the above example, the message numbers of any messages 619 containing the string "IMAP4" in the "value" attribute of the 620 "/comment" entry and having a mod-sequence equal to or 621 greater than 20010320162338 for the "\Draft" flag are returned in 622 the search results. 624 Example: 625 C: a SEARCH OR NOT MODSEQ 20010320162338 LARGER 50000 626 S: * SEARCH 627 S: a OK Search complete, nothing found 629 4.5. MODSEQ Sort Criterion 631 If a server implementing CONDSTORE also implements the SORT 632 extension as defined by [SORT], it MUST also support sorting on 633 per-message mod-sequence. 635 Syntax: MODSEQ 637 If client specifies a MODSEQ search (as per section 4.4) or sort 638 criterion in the SORT command and the server returns a non-empty 639 SORT result, the server MUST also return a MODSEQ response 640 code in the tagged OK response which covers all messages returned 641 in untagged SORT responses. See also section 4.6. 643 Example: 644 C: A282 SORT (SUBJECT MODSEQ) UTF-8 SINCE 1-Feb-2001 645 S: * SORT 2 81 83 84 82 882 (MODSEQ 117) 646 S: A282 OK SORT completed 648 Example: 649 C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 MODSEQ 21 650 S: * SORT 6 3 4 5 2 (MODSEQ 125) 651 S: A283 OK SORT completed 653 Example: 654 C: A284 SORT (MODSEQ) KOI8-R OR NOT MODSEQ 20010320162338 655 SUBJECT "Privet" 656 S: * SORT 657 S: A284 OK Sort complete, nothing found 659 4.6. Modified SEARCH and SORT untagged responses 661 Data: zero or more numbers 662 mod-sequence value (omitted if no match) 664 This document extends syntax of the untagged SEARCH and SORT responses 665 to include mod-sequence for all messages being returned. 667 If a client specifies a MODSEQ criterion in a SEARCH (or UID SEARCH) 668 command and the server returns a non-empty SEARCH result, the server 669 MUST also append (to the end of the untagged SEARCH response) the 670 highest mod-sequence for all messages being returned. 672 If client specifies a MODSEQ search or sort criterion in a SORT 673 (or UID SORT) command and the server returns a non-empty SORT result, 674 the server MUST also append (to the end of the untagged SORT response) 675 the highest mod-sequence for all messages being returned. 677 4.7. HIGHESTMODSEQ status data items 679 This document defines a new status data item: 681 HIGHESTMODSEQ 682 The highest mod-sequence value all messages 683 in the mailbox. This is the same value that is returned by the server 684 in the HIGHESTMODSEQ response code in OK untagged response 685 (see section 4.1.1). 687 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES HIGHESTMODSEQ) 688 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 689 HIGHESTMODSEQ 200201011231777) 690 S: A042 OK STATUS completed 692 5. Formal Syntax 694 The following syntax specification uses the Augmented Backus-Naur 695 Form (ABNF) notation as specified in [ABNF]. 697 Non-terminals referenced but not defined below are as defined by 698 [IMAP4]. 700 Except as noted otherwise, all alphabetic characters are case- 701 insensitive. The use of upper or lower case characters to define token 702 strings is for editorial clarity only. Implementations MUST accept 703 these strings in a case-insensitive fashion. 705 capability =/ "CONDSTORE" 707 status = "STATUS" SP mailbox SP 708 "(" status-att-req *(SP status-att-req) ")" 709 ;; redefine STATUS command syntax defined in [IMAP4] 711 status-att-req = status-att / "HIGHESTMODSEQ" 713 status-rsp-info = status-att SP number / 714 "HIGHESTMODSEQ" SP mod-sequence-value 716 store = "STORE" SP set store-modifiers SP store-att-flags 718 store-modifiers = [ SP "(" store-modifier *(SP store-modifier) ")" ] 720 store-modifier = "UNCHANGEDSINCE" SP mod-sequence-valzer 721 ;; Only single "UNCHANGEDSINCE" may be specified 722 ;; in a STORE operation 724 fetch-att =/ fetch-mod-sequence 725 ;; modifies original IMAP4 fetch-att 727 fetch-mod-sequence = "MODSEQ" 729 fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")" 731 search-key =/ search-modsequence 732 ;; modifies original IMAP4 search-key 734 search-modsequence = "MODSEQ" [search-modseq-ext] SP mod-sequence-valzer 736 search-modseq-ext = SP entry-name SP entry-type-req 738 resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value / 739 "NOMODSEQ" / 740 "MODIFIED" SP set 742 entry-name = '"' "/flags/" attr-flag '"' 743 ;; each system or user defined flag 744 ;; is mapped to "/flags/". 745 ;; 746 ;; follows the escape rules used 747 ;; by "quoted" string as described in Section 748 ;; 4.3 of [IMAP4], e.g. for the flag \Seen 749 ;; the corresponding is 750 ;; "/flags/\\seen", and for the flag 751 ;; $MDNSent, the corresponding 752 ;; is "/flags/$mdnsent". 754 entry-type-resp = "priv" | "shared" 755 ;; metadata item type 757 entry-type-req = entry-type-resp | "all" 758 ;; perform SEARCH operation on private 759 ;; metadata item, shared metadata item or both 761 permsg-modsequence = mod-sequence-value 762 ;; per message mod-sequence 764 mod-sequence-value = 1*DIGIT 765 ;; Positive unsigned 64-bit integer (mod-sequence) 766 ;; (1 <= n < 18,446,744,073,709,551,615) 768 mod-sequence-valzer = "0" | mod-sequence-value 770 search_sort_mod_seq = "(" "MODSEQ" SP mod-sequence-value ")" 772 sort-key =/ "MODSEQ" 774 ;;Borrowed from IMAP4rev1 and modified accordingly: 776 mailbox-data =/ "STATUS" SP mailbox SP "(" 777 [status-rsp-info *(SP status-rsp-info)] ")" / 778 "SEARCH" [1*(SP nz-number) SP search_sort_mod_seq] / 779 "SORT" [1*(SP nz-number) SP search_sort_mod_seq] 781 attr-flag = "\\Answered" / "\\Flagged" / "\\Deleted" / 782 "\\Seen" / "\\Draft" / attr-flag-keyword / 783 attr-flag-extension 784 ;; Does not include "\Recent" 786 attr-flag-extension = "\\" atom 787 ;; Future expansion. Client implementations 788 ;; MUST accept flag-extension flags. Server 789 ;; implementations MUST NOT generate 790 ;; flag-extension flags except as defined by 791 ;; future standard or standards-track 792 ;; revisions of this specification. 794 attr-flag-keyword = atom 796 6. Security Considerations 798 As a conditional STORE operation must be atomic for a message set, 799 an implementation may choose to use some kind of message or even 800 mailbox level locking for the duration of the conditional STORE 801 operation. Such implementation may suffer from a Deny of Service 802 Attack when conditional STORE is executed on a large mailbox. 804 Other IMAP4 security issues can be found in Security Considerations 805 section of [IMAP4]. 807 7. References 809 7.1. Normative References 811 [KEYWORDS] Bradner, "Key words for use in RFCs to Indicate 812 Requirement Levels", RFC 2119, Harvard University, March 1997. 814 [ABNF] Crocker, Overell, "Augmented BNF for Syntax Specifications: 815 ABNF", RFC 2234, Internet Mail Consortium, Demon Internet Ltd, 816 November 1997. 818 [IMAP4] Crispin, M., "Internet Message Access Protocol - Version 819 4rev1", RFC 3501, University of Washington, March 2003. 821 [ANNOTATE] Gellens, R., Daboo, C., "IMAP ANNOTATE Extension", 822 work in progress. 823 825 [SORT] Crispin, M., "Internet Message Access Protocol -- SORT 826 Extension", work in progress. 827 829 7.2. Informative References 831 [ACAP] Newman, Myers, "ACAP -- Application Configuration Access 832 Protocol", RFC 2244, Innosoft, Netscape, November 1997. 833 835 [ACL] Myers, "IMAP4 ACL extension", RFC 2086, Carnegie Mellon, 836 January 1997. 837 839 [NTP] Mills, D, "Network Time Protocol (Version 3) Specification, 840 Implementation and Analysis", RFC 1305, March 1992. 841 843 8. Acknowledgments 845 Some text was borrowed from "IMAP ANNOTATE Extension" by Randall Gellens 846 and Cyrus Daboo, and "ACAP -- Application Configuration Access Protocol" 847 by Chris Newman and John Myers. 849 Many thanks to Randall Gellens for his comments on how CONDSTORE should 850 interact with ANNOTATE extension and for thorough review of the document. 852 Authors also acknowledge the feedback provided by Cyrus Daboo, Larry 853 Greenfield, Chris Newman, Harrie Hazewinkel, Arnt Gulbrandsen Timo 854 Sirainen and Mark Crispin. 856 9. Author's Addresses 858 Alexey Melnikov 859 mailto: mel@messagingdirect.com 861 ACI WorldWide/MessagingDirect 862 59 Clarendon Road, Watford, Hertfordshire, 863 WD17 1FQ, United Kingdom 865 Steve Hole 866 mailto: Steve.Hole@messagingdirect.com 868 ACI WorldWide/MessagingDirect 869 #900, 10117 Jasper Avenue, 870 Edmonton, Alberta, T5J 1W8, CANADA 872 10. Full Copyright Statement 874 Copyright (C) The Internet Society 2001-2003. All Rights Reserved. 876 This document and translations of it may be copied and furnished to 877 others, and derivative works that comment on or otherwise explain it 878 or assist in its implementation may be prepared, copied, published 879 and distributed, in whole or in part, without restriction of any 880 kind, provided that the above copyright notice and this paragraph 881 are included on all such copies and derivative works. However, this 882 document itself may not be modified in any way, such as by removing 883 the copyright notice or references to the Internet Society or other 884 Internet organizations, except as needed for the purpose of 885 developing Internet standards in which case the procedures for 886 copyrights defined in the Internet Standards process must be 887 followed, or as required to translate it into languages other than 888 English. 890 The limited permissions granted above are perpetual and will not be 891 revoked by the Internet Society or its successors or assigns. 893 This document and the information contained herein is provided on an 894 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING 895 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 896 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 897 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 898 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 900 Acknowledgement 902 Funding for the RFC Editor function is currently provided by the 903 Internet Society.