/// <summary> /// Returns parsed IMAP SEARCH <b>UID (sequence set)</b> key. /// </summary> /// <param name="r">String reader.</param> /// <returns>Returns parsed IMAP SEARCH <b>UID (sequence set)</b> key.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when parsing fails.</exception> internal static IMAP_Search_Key_Uid Parse(StringReader r) { if (r == null) { throw new ArgumentNullException("r"); } string word = r.ReadWord(); if (!string.Equals(word, "UID", StringComparison.InvariantCultureIgnoreCase)) { throw new ParseException("Parse error: Not a SEARCH 'UID' key."); } r.ReadToFirstChar(); string value = r.QuotedReadToDelimiter(' '); if (value == null) { throw new ParseException("Parse error: Invalid 'UID' value."); } try{ return(new IMAP_Search_Key_Uid(IMAP_t_SeqSet.Parse(value))); } catch { throw new ParseException("Parse error: Invalid 'UID' value."); } }
/// <summary> /// Parses COPYUID optional response from string. /// </summary> /// <param name="value">COPYUID optional response string.</param> /// <returns>Returns COPYUID optional response.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference.</exception> public new static IMAP_t_orc_CopyUid Parse(string value) { if (value == null) { throw new ArgumentNullException("value"); } /* RFC 4315 3. * COPYUID * Followed by the UIDVALIDITY of the destination mailbox, a UID set * containing the UIDs of the message(s) in the source mailbox that * were copied to the destination mailbox and containing the UIDs * assigned to the copied message(s) in the destination mailbox, * indicates that the message(s) have been copied to the destination * mailbox with the stated UID(s). */ string[] code_mailboxUid_sourceSeqSet_targetSeqSet = value.Split(new char[] { ' ' }, 4); if (!string.Equals("COPYUID", code_mailboxUid_sourceSeqSet_targetSeqSet[0], StringComparison.InvariantCultureIgnoreCase)) { throw new ArgumentException("Invalid COPYUID response value.", "value"); } if (code_mailboxUid_sourceSeqSet_targetSeqSet.Length != 4) { throw new ArgumentException("Invalid COPYUID response value.", "value"); } return(new IMAP_t_orc_CopyUid( Convert.ToInt64(code_mailboxUid_sourceSeqSet_targetSeqSet[1]), IMAP_t_SeqSet.Parse(code_mailboxUid_sourceSeqSet_targetSeqSet[2]), IMAP_t_SeqSet.Parse(code_mailboxUid_sourceSeqSet_targetSeqSet[3]) )); }
/// <summary> /// Default constructor. /// </summary> /// <param name="seqSet">IMAP sequence-set.</param> /// <exception cref="ArgumentNullException">Is raised when <b>seqSet</b> is null reference.</exception> public IMAP_Search_Key_Uid(IMAP_t_SeqSet seqSet) { if (seqSet == null) { throw new ArgumentNullException("seqSet"); } m_pSeqSet = seqSet; }
public IMAP_Search_Key_Uid(IMAP_SequenceSet seqSet) { if (seqSet == null) { throw new ArgumentNullException("seqSet"); } m_pSeqSet = IMAP_t_SeqSet.Parse(seqSet.ToSequenceSetString()); }
/// <summary> /// Default constructor. /// </summary> /// <param name="targetMailboxUid">Target folde UID value.</param> /// <param name="sourceSeqSet">Source messages UID's.</param> /// <param name="targetSeqSet">Target messages UID's.</param> /// <exception cref="ArgumentNullException">Is raised when <b>sourceSeqSet</b> or <b>targetSeqSet</b> is null reference.</exception> public IMAP_t_orc_CopyUid(long targetMailboxUid, IMAP_t_SeqSet sourceSeqSet, IMAP_t_SeqSet targetSeqSet) { if (sourceSeqSet == null) { throw new ArgumentNullException("sourceSeqSet"); } if (targetSeqSet == null) { throw new ArgumentNullException("targetSeqSet"); } m_TargetMailboxUid = targetMailboxUid; m_pSourceSeqSet = sourceSeqSet; m_pTargetSeqSet = targetSeqSet; }
/// <summary> /// Returns parsed IMAP SEARCH <b>sequence-set</b> key. /// </summary> /// <param name="r">String reader.</param> /// <returns>Returns parsed IMAP SEARCH <b>sequence-set</b> key.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception> /// <exception cref="ParseException">Is raised when parsing fails.</exception> internal static IMAP_Search_Key_SeqSet Parse(StringReader r) { if (r == null) { throw new ArgumentNullException("r"); } r.ReadToFirstChar(); string value = r.QuotedReadToDelimiter(' '); if (value == null) { throw new ParseException("Parse error: Invalid 'sequence-set' value."); } try{ return(new IMAP_Search_Key_SeqSet(IMAP_t_SeqSet.Parse(value))); } catch { throw new ParseException("Parse error: Invalid 'sequence-set' value."); } }
/// <summary> /// Parses <b>sequense-set</b> from string. /// </summary> /// <param name="value">Sequence-set string.</param> /// <returns>Returns parse sequence set.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference.</exception> public static IMAP_t_SeqSet Parse(string value) { if (value == null) { throw new ArgumentNullException("value"); } /* RFC 3501 * seq-number = nz-number / "*" * ; message sequence number (COPY, FETCH, STORE * ; commands) or unique identifier (UID COPY, * ; UID FETCH, UID STORE commands). * ; * represents the largest number in use. In * ; the case of message sequence numbers, it is * ; the number of messages in a non-empty mailbox. * ; In the case of unique identifiers, it is the * ; unique identifier of the last message in the * ; mailbox or, if the mailbox is empty, the * ; mailbox's current UIDNEXT value. * ; The server should respond with a tagged BAD * ; response to a command that uses a message * ; sequence number greater than the number of * ; messages in the selected mailbox. This * ; includes "*" if the selected mailbox is empty. * * seq-range = seq-number ":" seq-number * ; two seq-number values and all values between * ; these two regardless of order. * ; Example: 2:4 and 4:2 are equivalent and indicate * ; values 2, 3, and 4. * ; Example: a unique identifier sequence range of * ; 3291:* includes the UID of the last message in * ; the mailbox, even if that value is less than 3291. * * sequence-set = (seq-number / seq-range) *("," sequence-set) * ; set of seq-number values, regardless of order. * ; Servers MAY coalesce overlaps and/or execute the * ; sequence in any order. * ; Example: a message sequence number set of * ; 2,4:7,9,12:* for a mailbox with 15 messages is * ; equivalent to 2,4,5,6,7,9,12,13,14,15 * ; Example: a message sequence number set of *:4,5:7 * ; for a mailbox with 10 messages is equivalent to * ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and * ; overlap coalesced to be 4,5,6,7,8,9,10. */ long seqMaxValue = long.MaxValue; IMAP_t_SeqSet retVal = new IMAP_t_SeqSet(); //--- Validate sequence-set --------------------------------------------------------// string[] sequenceSets = value.Trim().Split(','); foreach (string sequenceSet in sequenceSets) { // seq-range if (sequenceSet.IndexOf(":") > -1) { string[] rangeParts = sequenceSet.Split(':'); if (rangeParts.Length == 2) { long start = retVal.Parse_Seq_Number(rangeParts[0], seqMaxValue); long end = retVal.Parse_Seq_Number(rangeParts[1], seqMaxValue); if (start <= end) { retVal.m_pSequenceParts.Add(new Range_long(start, end)); } else { retVal.m_pSequenceParts.Add(new Range_long(end, start)); } } else { throw new Exception("Invalid <seq-range> '" + sequenceSet + "' value !"); } } // seq-number else { retVal.m_pSequenceParts.Add(new Range_long(retVal.Parse_Seq_Number(sequenceSet, seqMaxValue))); } } //-----------------------------------------------------------------------------------// retVal.m_SequenceString = value; return(retVal); }