Ejemplo n.º 1
0
        /// <summary>
        /// Creates the response.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <returns>
        /// The <c>Pop3Response</c> containing the results of the
        /// Pop3 command execution.
        /// </returns>
        protected override RetrResponse CreateResponse(byte[] buffer)
        {
            Pop3Response response = Pop3Response.CreateResponse(buffer);

            string[] messageLines = GetResponseLines(StripPop3HostMessage(buffer, response.HostMessage));

            return(new RetrResponse(response, messageLines));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the response.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <returns>
        /// The <c>Pop3Response</c> containing the results of the
        /// Pop3 command execution.
        /// </returns>
        protected override StatResponse CreateResponse(byte[] buffer)
        {
            Pop3Response response = Pop3Response.CreateResponse(buffer);

            string[] values = response.HostMessage.Split(' ');

            //should consist of '+OK', 'messagecount', 'octets'
            if (values.Length < 3)
            {
                throw new Pop3Exception(string.Concat("Invalid response message: ", response.HostMessage));
            }

            int  messageCount = Convert.ToInt32(values[1]);
            long octets       = Convert.ToInt64(values[2]);

            return(new StatResponse(response, messageCount, octets));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the response.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <returns>A <c>ListResponse</c> containing the results of the Pop3 LIST command.</returns>
        protected override ListResponse CreateResponse(byte[] buffer)
        {
            Pop3Response response = Pop3Response.CreateResponse(buffer);

            List <Pop3ListItem> items;

            if (IsMultiline)
            {
                items = new List <Pop3ListItem>();
                string[] values;
                string[] lines = GetResponseLines(StripPop3HostMessage(buffer, response.HostMessage));

                foreach (string line in lines)
                {
                    //each line should consist of 'n m' where n is the message number and m is the number of octets
                    values = line.Split(' ');
                    if (values.Length < 2)
                    {
                        throw new Pop3Exception(string.Concat("Invalid line in multiline response:  ", line));
                    }

                    items.Add(new Pop3ListItem(Convert.ToInt32(values[0]),
                                               Convert.ToInt64(values[1])));
                }
            } //Parse the multiline response.
            else
            {
                items = new List <Pop3ListItem>(1);
                string[] values = response.HostMessage.Split(' ');

                //should consist of '+OK messageNumber octets'
                if (values.Length < 3)
                {
                    throw new Pop3Exception(string.Concat("Invalid response message: ", response.HostMessage));
                }
                items.Add(new Pop3ListItem(Convert.ToInt32(values[1]), Convert.ToInt64(values[2])));
            } //Parse the single line results.

            return(new ListResponse(response, items));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates the response.
 /// </summary>
 /// <param name="buffer">The buffer.</param>
 /// <returns>The <c>Pop3Response</c> containing the results of the
 /// Pop3 command execution.</returns>
 protected virtual T CreateResponse(byte[] buffer)
 {
     return(Pop3Response.CreateResponse(buffer) as T);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates the response.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <returns>
        /// The <c>Pop3Response</c> containing the results of the
        /// Pop3 command execution.
        /// </returns>
        protected override ConnectResponse CreateResponse(byte[] buffer)
        {
            Pop3Response response = Pop3Response.CreateResponse(buffer);

            return(new ConnectResponse(response, NetworkStream));
        }