Beispiel #1
0
        /// <summary>
        /// Parses the X-GM-LABELS list.
        /// </summary>
        /// <returns>The message labels.</returns>
        /// <param name="engine">The IMAP engine.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public static ReadOnlyCollection <string> ParseLabelsList(ImapEngine engine, CancellationToken cancellationToken)
        {
            var token  = engine.ReadToken(cancellationToken);
            var labels = new List <string> ();

            if (token.Type != ImapTokenType.OpenParen)
            {
                throw ImapEngine.UnexpectedToken(token, false);
            }

            // Note: GMail's IMAP implementation is broken and does not quote strings with ']' like it should.
            token = engine.ReadToken(ImapStream.GMailLabelSpecials, cancellationToken);

            while (token.Type == ImapTokenType.Flag || token.Type == ImapTokenType.Atom || token.Type == ImapTokenType.QString)
            {
                var label = engine.DecodeMailboxName((string)token.Value);

                labels.Add(label);

                token = engine.ReadToken(cancellationToken);
            }

            if (token.Type != ImapTokenType.CloseParen)
            {
                throw ImapEngine.UnexpectedToken(token, false);
            }

            return(new ReadOnlyCollection <string> (labels));
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MailKit.Net.Imap.ImapFolderConstructorArgs"/> class.
 /// </summary>
 /// <param name="engine">The IMAP command engine.</param>
 /// <param name="encodedName">The encoded name.</param>
 /// <param name="attributes">The attributes.</param>
 /// <param name="delim">The directory separator.</param>
 internal ImapFolderConstructorArgs(ImapEngine engine, string encodedName, FolderAttributes attributes, char delim)
 {
     FullName           = engine.DecodeMailboxName(encodedName);
     Name               = GetBaseName(FullName, delim);
     DirectorySeparator = delim;
     EncodedName        = encodedName;
     Attributes         = attributes;
     Engine             = engine;
 }