Ejemplo n.º 1
0
 public bool IssueCommand(RFC1939.POPCommand command)
 {
     try
     {
         if (m_CurrentState.IssueCommand(command, this))
         {
             OnCommandIssued(this,
                             new CommandIssuedEventArgs(command));
             return(true);
         }
     }
     catch (RFC1939.POPException ex)
     {
         if (ex.InnerException != null)
         {
             if (ex.InnerException.InnerException != null)
             {
                 if (ex.InnerException.InnerException is System.Net.Sockets.SocketException)
                 {
                     CloseConnection();
                     CurrentState = DisconnectedState.GetInstane();
                     return(false);
                 }
             }
         }
         throw ex;
     }
     return(false);
 }
Ejemplo n.º 2
0
 public override bool IsLegalCommand(RFC1939.POPCommand command)
 {
     if (command is RFC1939.GreetingCommand)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
 internal void LoggCommand(RFC1939.POPCommand command)
 {
     if (m_CommandHistory.Count > m_MaxHistoryLenght)
     {
         m_CommandHistory.Dequeue();
     }
     m_CommandHistory.Enqueue(command);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 执行命令,如果命令是与登录相关则不执行
        /// </summary>
        /// <returns>如果返回true,则说明命令执行成功</returns>
        public override bool IssueCommand(RFC1939.POPCommand command, POPClient context)
        {
            if (!IsLegalCommand(command))
            {
                return(false);
            }

            if (command is RFC1939.QuitCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = DisconnectedState.GetInstane();
                    return(true);
                }
                context.CurrentState = DisconnectedState.GetInstane();
                context.LoggCommand(command);
            }
            else if (command is RFC1939.RetriveCommand || command is RFC1939.TopCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = ReadingState.GetInstance();
                    return(true);
                }
                context.LoggCommand(command);
            }
            else if (command is RFC1939.NoopCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    return(true);
                }
                else
                {
                    context.LoggCommand(command);
                    context.Disconnect();
                    context.CurrentState = DisconnectedState.GetInstane();
                }
            }
            else
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    return(true);
                }
                context.LoggCommand(command);
            }
            return(false);
        }
Ejemplo n.º 5
0
 public override bool IssueCommand(RFC1939.POPCommand command, POPClient context)
 {
     if (IsLegalCommand(command))
     {
         if (command.Execute())
         {
             context.LoggCommand(command);
             context.CurrentState = AuthorizationState.GetInstance();
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 6
0
        public override bool IssueCommand(RFC1939.POPCommand command, POPClient context)
        {
            if (!IsLegalCommand(command))
            {
                return(false);
            }

            if (command is RFC1939.ConnectCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = TransactionState.GetInstance();
                    return(true);
                }
                context.LoggCommand(command);
            }
            else if (command is RFC1939.UserCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    return(true);
                }
                context.LoggCommand(command);
            }
            else if (command is RFC1939.PassCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = TransactionState.GetInstance();
                    return(true);
                }
                context.LoggCommand(command);
            }
            else if (command is RFC1939.QuitCommand)
            {
                if (command.Execute())
                {
                    context.LoggCommand(command);
                    context.CurrentState = DisconnectedState.GetInstane();
                    return(true);
                }
                context.LoggCommand(command);
            }

            return(false);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 判断是不是与登录不相关的命令
        /// </summary>
        /// <returns>如果返回true,则说明命令是与登录不相关的命令</returns>
        public override bool IsLegalCommand(RFC1939.POPCommand command)
        {
            if (command is RFC1939.UserCommand)
            {
                return(false);
            }
            if (command is RFC1939.PassCommand)
            {
                return(false);
            }
            if (command is RFC1939.ApopCommand)
            {
                return(false);
            }

            return(true);
        }
 public CommandIssuedEventArgs(RFC1939.POPCommand command)
 {
     m_Command = command;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 判断是不是合法命令
 /// </summary>
 public abstract bool IsLegalCommand(RFC1939.POPCommand command);
Ejemplo n.º 10
0
 /// <summary>
 /// 判断是不是合法命令,如果是则执行命令
 /// </summary>
 public abstract bool IssueCommand(RFC1939.POPCommand command, POPClient context);
Ejemplo n.º 11
0
 public override bool IsLegalCommand(RFC1939.POPCommand command)
 {
     return(false);
 }
Ejemplo n.º 12
0
 public override bool IssueCommand(RFC1939.POPCommand command, POPClient context)
 {
     return(IsLegalCommand(command));
 }