protected override CompletionResponse Behaviour()
        {
            uint commandId = base._dispatcher.SendCommand("AUTHENTICATE LOGIN");

            if (base._dispatcher.GetResponse(commandId).Type != EIMAP4ResponseType.Continuation)
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            base._dispatcher.SendContinuationCommand(base.GetBase64String(base._username));
            if (base._dispatcher.GetResponse(commandId).Type != EIMAP4ResponseType.Continuation)
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            base._dispatcher.SendContinuationCommand(base.GetBase64String(base._password));
            IMAP4Response response = base._dispatcher.GetResponse(commandId);

            if (!CompletionResponse.IsCompletionResponse(response.Response))
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            CompletionResponse response2 = new CompletionResponse(response.Response);

            if (response2.CompletionResult == ECompletionResponseType.NO)
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            return(response2);
        }
Example #2
0
        protected override CompletionResponse Behaviour()
        {
            uint          commandId = base._dispatcher.SendCommand("LOGOUT", this.filter);
            IMAP4Response response  = base._dispatcher.GetResponse(commandId);

            if (CompletionResponse.IsCompletionResponse(response.Response))
            {
                CompletionResponse response2 = new CompletionResponse(response.Response);
                if (response2.CompletionResult != ECompletionResponseType.BAD)
                {
                    throw new UnexpectedResponseException("Unexpected response");
                }
                return(response2);
            }
            if ((response.Name != "BYE") || (response.Type != EIMAP4ResponseType.Untagged))
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            response = base._dispatcher.GetResponse(commandId);
            if (!CompletionResponse.IsCompletionResponse(response.Response))
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            CompletionResponse response3 = new CompletionResponse(response.Response);

            if (response3.CompletionResult == ECompletionResponseType.NO)
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            return(response3);
        }
Example #3
0
        protected override CompletionResponse Behaviour()
        {
            IMAP4Response response;
            string        flagSetMode = GetFlagSetMode(this._mode);
            string        command     = string.Format("UID STORE {0} {1}FLAGS{2} ({3})", new object[] { this._sequence, flagSetMode, ".SILENT", JoinFlags(this._flags) });
            uint          commandId   = base._dispatcher.SendCommand(command);

            do
            {
                response = base._dispatcher.GetResponse(commandId);
            }while (!CompletionResponse.IsCompletionResponse(response.Response));
            return(new CompletionResponse(response.Response));
        }
Example #4
0
        protected override CompletionResponse Behaviour()
        {
            uint          commandId = base._dispatcher.SendCommand("STARTTLS");
            IMAP4Response response  = base._dispatcher.GetResponse(commandId);

            if (!CompletionResponse.IsCompletionResponse(response.Response))
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            CompletionResponse response2 = new CompletionResponse(response.Response);

            if (response2.CompletionResult == ECompletionResponseType.NO)
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            return(response2);
        }
Example #5
0
        protected override CompletionResponse Behaviour()
        {
            CompletionResponse response2;

            this.capabilities = new List <string>();
            uint          commandId = base._dispatcher.SendCommand("CAPABILITY", this.filter);
            IMAP4Response response  = base._dispatcher.GetResponse(commandId);

            if ((response.Name == "CAPABILITY") && (response.Type == EIMAP4ResponseType.Untagged))
            {
                if (response.Data.IndexOf(' ') != -1)
                {
                    string[] collection = response.Data.Substring(response.Name.Length + 1).Split(new char[] { ' ' });
                    this.capabilities = new List <string>(collection);
                }
                response = base._dispatcher.GetResponse(commandId);
                if (!CompletionResponse.IsCompletionResponse(response.Response))
                {
                    throw new UnexpectedResponseException("Unexpected response");
                }
                response2 = new CompletionResponse(response.Response);
                if (response2.CompletionResult == ECompletionResponseType.NO)
                {
                    throw new UnexpectedResponseException("Unexpected response");
                }
                return(response2);
            }
            if (!CompletionResponse.IsCompletionResponse(response.Response))
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            response2 = new CompletionResponse(response.Response);
            if (response2.CompletionResult != ECompletionResponseType.BAD)
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            return(response2);
        }
Example #6
0
        protected override CompletionResponse Behaviour()
        {
            uint          commandId = base._dispatcher.SendCommand(this.command, this.filter);
            IMAP4Response response  = base._dispatcher.GetResponse(commandId);

            if ((response.Name == "STATUS") && (response.Type == EIMAP4ResponseType.Untagged))
            {
                int index = response.Data.IndexOf('(');
                int num3  = response.Data.IndexOf(')');
                if ((index != -1) && (num3 != -1))
                {
                    string[] strArray = response.Data.Substring(index + 1, (num3 - index) - 1).Split(new char[] { ' ' });
                    if ((strArray.Length % 2) != 0)
                    {
                        throw new UnexpectedResponseException("Unexpected response");
                    }
                    for (int i = 0; i < strArray.Length; i += 2)
                    {
                        string str2 = strArray[i];
                        if (str2 == "MESSAGES")
                        {
                            this.messages = int.Parse(strArray[i + 1]);
                        }
                        else if (str2 == "RECENT")
                        {
                            this.recent = int.Parse(strArray[i + 1]);
                        }
                        else if (str2 == "UIDNEXT")
                        {
                            this.uidnext = long.Parse(strArray[i + 1]);
                        }
                        else if (str2 == "UIDVALIDITY")
                        {
                            this.uidvalidity = long.Parse(strArray[i + 1]);
                        }
                        else
                        {
                            if (str2 != "UNSEEN")
                            {
                                throw new UnexpectedResponseException("Unexpected response");
                            }
                            this.unseen = int.Parse(strArray[i + 1]);
                        }
                    }
                }
            }
            else
            {
                if (!CompletionResponse.IsCompletionResponse(response.Response))
                {
                    throw new UnexpectedResponseException("Unexpected response");
                }
                return(new CompletionResponse(response.Response));
            }
            response = base._dispatcher.GetResponse(commandId);
            if (!CompletionResponse.IsCompletionResponse(response.Response))
            {
                throw new UnexpectedResponseException("Unexpected response");
            }
            return(new CompletionResponse(response.Response));
        }