public static ImapData CreateListData(ImapData[] list) { if (list == null) throw new ArgumentNullException("list"); // 4.4. Parenthesized List var data = new ImapData(ImapDataFormat.List); data.list = list; return data; }
internal ImapResponseText(ImapResponseCode code, ImapData[] arguments, string text) { if (code == null) throw new ArgumentNullException("code"); if (arguments == null) throw new ArgumentNullException("arguments"); if (text == null) throw new ArgumentNullException("text"); this.Code = code; this.Arguments = arguments; this.Text = text; }
public ImapExtendedMessageRfc822BodyStructure(ImapMessageRfc822BodyStructure baseStructure, string md5, ImapBodyDisposition disposition, string[] languages, Uri location, ImapData[] extensions) : base(baseStructure) { this.MD5 = md5; this.Disposition = disposition; this.Languages = languages; this.Location = location; this.Extensions = extensions; }
public ImapExtendedMultiPartBodyStructure(ImapMultiPartBodyStructure baseStructure, IDictionary<string, string> parameters, ImapBodyDisposition disposition, string[] languages, Uri location, ImapData[] extensions) : base(baseStructure) { this.Parameters = (parameters ?? new Dictionary<string, string>()).AsReadOnly(StringComparer.OrdinalIgnoreCase); this.Disposition = disposition; this.Languages = languages; this.Location = location; this.Extensions = extensions; }
internal void SetContentData(string specifier, ImapData bodyText) { bodyData[specifier] = bodyText; }
public static ImapData CreateTextData(ByteString text) { if (text == null) throw new ArgumentNullException("text"); // 4.1. Atom, 4.2. Number, 4.3. String var data = new ImapData(ImapDataFormat.Text); data.text = text; return data; }
public void AddData(ImapData data) { nestedData[nest].Add(data); }
private bool ParseLiteral(bool literal8, ByteString line, ref int index, out ImapData parsed) { // literal = "{" number "}" CRLF *CHAR8 // ; Number represents the number of CHAR8s // CHAR8 = %x01-ff ; any OCTET except NUL, %x00 // number = 1*DIGIT // ; Unsigned 32-bit integer // ; (0 <= n < 4,294,967,296) var bytes = line.ByteArray; if (literal8) { /* * RFC 3516 - IMAP4 Binary Content Extension * http://tools.ietf.org/html/rfc3516 * 4.2. FETCH Command Extensions * literal8 = "~{" number "}" CRLF *OCTET * ; <number> represents the number of OCTETs * ; in the response string. */ if (bytes[index + 1] != ImapOctets.OpenBrace) { // not literal8 parsed = ImapData.CreateTextData(ParseNonQuotedString(line, ref index)); return false; } index++; // '~' } index++; // '{' var number = 0L; for (;;) { var num = bytes[index] - 0x30; // '0' if (0 <= num && num <= 9) // number number = checked((number * 10L) + num); else if (bytes[index] == ImapOctets.CloseBrace) break; // '}' else throw new ImapMalformedDataException("malformed literal (invalid number)"); index++; } if (bytes.Length - ++index != 2/*CRLF*/) throw new ImapMalformedDataException("malformed literal (extra data before CRLF)"); /* * to avoid allocating buffers on Large Object Heap * * http://msdn.microsoft.com/en-us/magazine/cc534993.aspx * http://tirania.org/blog/archive/2009/Nov-09.html */ const long literalAllocationThreshold = 40960L; // 40kBytes if (number <= literalAllocationThreshold) { var literal = new byte[number]; if (stream.Read(literal, 0, (int)number) != literal.Length) throw new ImapMalformedDataException("unexpected EOF"); parsed = ImapData.CreateTextData(new ByteString(literal)); } else { var literal = new ChunkedMemoryStream(); if (stream.Read(literal, number) != number) throw new ImapMalformedDataException("unexpected EOF"); literal.Position = 0L; parsed = ImapData.CreateTextData(literal); } return true; }
public ImapMalformedDataException(string message, ImapData causedData) : base(string.Format("{0}{1}data: {2}", message, Environment.NewLine, causedData)) { this.causedData = causedData; }
public ImapMalformedDataException(ImapData causedData) : this("invalid format", causedData) { }