Example #1
0
        /// <summary>
        ///   The STORE command alters data associated with a message in the mailbox.
        ///   http://tools.ietf.org/html/rfc2060#section-6.4.6
        /// </summary>
        /// <param name = "set">The sequence set representing the targeted messages, e.g. "1"; "1,2"; "2:4".</param>
        /// <param name = "value">The keywords to add or remove.</param>
        /// <param name = "procedure">The procedure, whether to add or remove the flags.</param>
        public ImapResponse StoreSilent(SequenceSet set, string value, StoreProcedures procedure)
        {
            var reader   = StoreInternal(set, value, procedure, "FLAGS.SILENT");
            var response = new ImapResponse();

            response.Parse(reader);
            return(response);
        }
Example #2
0
 public static SequenceSet CreateSet(int from, int to)
 {
     var set = new SequenceSet();
     for (var i = from; i <= to; i++) {
         set.Values.Add(i);
     }
     return set;
 }
Example #3
0
        private ImapResponseReader StoreInternal(SequenceSet set, string value, StoreProcedures procedure, string commandString)
        {
            var prefix  = procedure == StoreProcedures.Add ? "+" : "-";
            var isUid   = set.IsUid ? "UID " : string.Empty;
            var text    = string.Format("{0}STORE {1} {2}{3} ({4})", isUid, set, prefix, commandString, value);
            var command = new ImapCommand(text);

            return(SendAndReceive(command, false));
        }
Example #4
0
        /// <summary>
        ///   The FETCH command retrieves data associated with a message in the
        ///   mailbox.  The data items to be fetched can be either a single atom
        ///   or a parenthesized list.
        ///   http://tools.ietf.org/html/rfc3501#section-6.4.5
        /// </summary>
        /// <param name = "set">The list of ids of the messages to fetch.</param>
        /// <param name = "query">The query, consisting of message parts to fetch.</param>
        public FetchImapResponse Fetch(SequenceSet set, string query)
        {
            var text     = string.Format("FETCH {0} {1}", set, query);
            var command  = new ImapCommand(text);
            var reader   = SendAndReceive(command);
            var response = new FetchImapResponse();

            response.Parse(reader);
            return(response);
        }
Example #5
0
        public static SequenceSet CreateSet(int from, int to)
        {
            var set = new SequenceSet();

            for (var i = from; i <= to; i++)
            {
                set.Values.Add(i);
            }
            return(set);
        }
Example #6
0
        public static SequenceSet CreateSet(IEnumerable <int> values)
        {
            var set = new SequenceSet();

            foreach (var value in values)
            {
                set.Values.Add(value);
            }
            return(set);
        }
Example #7
0
        /// <summary>
        ///   The COPY command copies the specified message(s) to the end of the specified destination mailbox.
        ///   http://tools.ietf.org/html/rfc3501#section-6.4.7
        /// </summary>
        public ImapResponse Copy(SequenceSet set, string destinationMailboxName)
        {
            // we need to convert non ASCII names according to IMAP specs.
            // http://tools.ietf.org/html/rfc2060#section-5.1.3
            var name = MailboxNameEncoder.Encode(destinationMailboxName);

            var text    = string.Format("COPY {0} \"{1}\"", set, name);
            var command = new ImapCommand(text);
            var reader  = SendAndReceive(command);

            var response = new ImapResponse();

            response.Parse(reader);
            return(response);
        }
Example #8
0
        public static SequenceSet FromString(string text)
        {
            Arguments.VerifyNotNull(text);
            var set = new SequenceSet {
                IsUid = text.Contains("UID")
            };

            {
                var match = Regex.Match(text, @"\d+:\d+");
                if (match.Success)
                {
                    var values = match.Value.Split(Characters.Colon);
                    var from   = int.Parse(values[0]);
                    var to     = int.Parse(values[1]);
                    for (var i = from; i <= to; i++)
                    {
                        set.Values.Add(i);
                    }
                    return(set);
                }
            }

            {
                var matches = Regex.Matches(text, @"\d+");
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        var value = int.Parse(match.Value);
                        set.Values.Add(value);
                    }

                    return(set);
                }
            }

            return(set);
        }
Example #9
0
 /// <summary>
 ///   The STORE command alters data associated with a message in the mailbox.
 ///   http://tools.ietf.org/html/rfc2060#section-6.4.6
 /// </summary>
 /// <param name = "set">The sequence set representing the targeted messages, e.g. "1"; "1,2"; "2:4".</param>
 /// <param name = "value">The keywords to add or remove.</param>
 /// <param name = "procedure">The procedure, whether to add or remove the flags.</param>
 public ImapResponse StoreSilent(SequenceSet set, string value, StoreProcedures procedure)
 {
     var reader = StoreInternal(set, value, procedure, "FLAGS.SILENT");
     var response = new ImapResponse();
     response.Parse(reader);
     return response;
 }
Example #10
0
 /// <summary>
 ///   The STORE command alters data associated with a message in the mailbox.
 ///   http://tools.ietf.org/html/rfc2060#section-6.4.6
 /// </summary>
 /// <param name = "set">The sequence set representing the targeted messages, e.g. "1"; "1,2"; "2:4".</param>
 /// <param name = "flags">The flags to add or remove.</param>
 /// <param name = "procedure">The procedure, whether to add or remove the flags.</param>
 public ImapResponse StoreSilent(SequenceSet set, MessageFlags flags, StoreProcedures procedure)
 {
     var value = flags.ToMimeFormat();
     return StoreSilent(set, value, procedure);
 }
Example #11
0
        /// <summary>
        ///   The FETCH command retrieves data associated with a message in the
        ///   mailbox.  The data items to be fetched can be either a single atom
        ///   or a parenthesized list.
        ///   http://tools.ietf.org/html/rfc3501#section-6.4.5
        /// </summary>
        /// <param name = "set">The list of ids of the messages to fetch.</param>
        /// <param name = "query">The query, consisting of message parts to fetch.</param>
        public FetchImapResponse Fetch(SequenceSet set, string query)
        {
            var text = string.Format("FETCH {0} {1}", set, query);
            var command = new ImapCommand(text);
            var reader = SendAndReceive(command);
            var response = new FetchImapResponse();

            response.Parse(reader);
            return response;
        }
Example #12
0
        /// <summary>
        ///   The COPY command copies the specified message(s) to the end of the specified destination mailbox.
        ///   http://tools.ietf.org/html/rfc3501#section-6.4.7
        /// </summary>
        public ImapResponse Copy(SequenceSet set, string destinationMailboxName)
        {
            // we need to convert non ASCII names according to IMAP specs.
            // http://tools.ietf.org/html/rfc2060#section-5.1.3
            var name = MailboxNameEncoder.Encode(destinationMailboxName);

            var text = string.Format("COPY {0} \"{1}\"", set, name);
            var command = new ImapCommand(text);
            var reader = SendAndReceive(command);

            var response = new ImapResponse();
            response.Parse(reader);
            return response;
        }
Example #13
0
 private ImapResponseReader StoreInternal(SequenceSet set, string value, StoreProcedures procedure, string commandString)
 {
     var prefix = procedure == StoreProcedures.Add ? "+" : "-";
     var isUid = set.IsUid ? "UID " : string.Empty;
     var text = string.Format("{0}STORE {1} {2}{3} ({4})", isUid, set, prefix, commandString, value);
     var command = new ImapCommand(text);
     return SendAndReceive(command, false);
 }
Example #14
0
        public static SequenceSet FromString(string text)
        {
            Arguments.VerifyNotNull(text);
            var set = new SequenceSet {IsUid = text.Contains("UID")};

            {
                var match = Regex.Match(text, @"\d+:\d+");
                if (match.Success) {
                    var values = match.Value.Split(Characters.Colon);
                    var from = int.Parse(values[0]);
                    var to = int.Parse(values[1]);
                    for (var i = from; i <= to; i++) {
                        set.Values.Add(i);
                    }
                    return set;
                }
            }

            {
                var matches = Regex.Matches(text, @"\d+");
                if (matches.Count > 0) {
                    foreach (Match match in matches) {
                        var value = int.Parse(match.Value);
                        set.Values.Add(value);
                    }

                    return set;
                }
            }

            return set;
        }
Example #15
0
        /// <summary>
        ///   The STORE command alters data associated with a message in the mailbox.
        ///   http://tools.ietf.org/html/rfc2060#section-6.4.6
        /// </summary>
        /// <param name = "set">The sequence set representing the targeted messages, e.g. "1"; "1,2"; "2:4".</param>
        /// <param name = "flags">The flags to add or remove.</param>
        /// <param name = "procedure">The procedure, whether to add or remove the flags.</param>
        public ImapResponse StoreSilent(SequenceSet set, MessageFlags flags, StoreProcedures procedure)
        {
            var value = flags.ToMimeFormat();

            return(StoreSilent(set, value, procedure));
        }
Example #16
0
 public static SequenceSet CreateSet(IEnumerable<int> values)
 {
     var set = new SequenceSet();
     foreach (var value in values) {
         set.Values.Add(value);
     }
     return set;
 }
Example #17
0
 /// <summary>
 ///   This method does nothing, it is merely used for automated command translations by the LINQ provider.
 /// </summary>
 /// <param name = "query">The query to apply this method to.</param>
 /// <param name = "set">The set of message ids from which to query.</param>
 public static IQueryable <IMessageQueryable> From(this IQueryable <IMessageQueryable> query, SequenceSet set)
 {
     return(query);
 }
 /// <summary>
 ///   This method does nothing, it is merely used for automated command translations by the LINQ provider.
 /// </summary>
 /// <param name = "query">The query to apply this method to.</param>
 /// <param name = "set">The set of message ids from which to query.</param>
 public static IQueryable<IMessageQueryable> From(this IQueryable<IMessageQueryable> query, SequenceSet set)
 {
     return query;
 }