Пример #1
0
        /// <summary>
        /// Send IDLE command to IMAP server.
        /// You can receive message from server by register event handler to MessageReceived event of ImapIdleCommand object
        /// </summary>
        /// <returns></returns>
        public void ExecuteIdle(ImapIdleCommand command)
        {
            this.ValidateState(ImapConnectionState.Authenticated);
            this.Send(this.Tag + " IDLE");
            var bb = command.GetByteArray();

            command.IAsyncResult = this.Stream.BeginRead(bb, 0, bb.Length, this.ExecuteIdleCallback, command);
            this._State          = ImapConnectionState.Idle;
        }
Пример #2
0
 public ImapConnectionState Open()                    //Nustato ar esame prisijunge ir grazina connecter/disconnected
 {
     if (this.Connect() == true)                      //Grazina true jei turim socketa sujungta su hosty ir ne null Stream
     {
         this._State = ImapConnectionState.Connected; //+
     }
     else
     {
         this._State = ImapConnectionState.Disconnected; //+
     }
     return(this._State);                                //+
 }
Пример #3
0
        /// <summary>
        /// Send Logout command to IMAP server.
        /// </summary>
        /// <returns></returns>
        public ImapCommandResult ExecuteLogout()
        {
            this.ValidateState(ImapConnectionState.Authenticated);
            String s  = this.Execute(this.Tag + " Logout");
            var    rs = new ImapCommandResult(this.Tag, s);

            if (rs.Status == ImapCommandResultStatus.Ok)
            {
                this._State = ImapConnectionState.Connected;
            }
            return(rs);
        }
Пример #4
0
 /// <summary>
 /// Open connection to a server.
 /// </summary>
 public ImapConnectionState Open()
 {
     if (this.Connect() == true)
     {
         this._State = ImapConnectionState.Connected;
     }
     else
     {
         this._State = ImapConnectionState.Disconnected;
     }
     return(this._State);
 }
Пример #5
0
        /// <summary>
        /// Send done command to IMAP server.
        /// </summary>
        /// <returns></returns>
        public ImapCommandResult ExecuteDone(ImapIdleCommand command)
        {
            this.ValidateState(ImapConnectionState.Idle);
            if (command.IAsyncResult != null)
            {
                var x = this.Stream.EndRead(command.IAsyncResult);
            }
            String s = this.Execute("DONE");

            this._State = ImapConnectionState.Authenticated;

            return(new ImapCommandResult(this.Tag, s));
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ImapCommandResult ExecuteLogin()
        {
            if (this.EnsureOpen() == ImapConnectionState.Disconnected)
            {
                throw new MailClientException();
            }

            String            commandText = String.Format(this.Tag + " LOGIN {0} {1}", this.UserName, this.Password);
            String            s           = this.Execute(commandText);
            ImapCommandResult rs          = new ImapCommandResult(this.Tag, s);

            if (rs.Status == ImapCommandResultStatus.Ok)
            {
                this._State = ImapConnectionState.Authenticated;
            }
            else
            {
                this._State = ImapConnectionState.Connected;
            }
            return(rs);
        }
Пример #7
0
        private void ValidateState(ImapConnectionState state, Boolean folderSelected)
        {
            if (this._State != state)
            {
                switch (state)
                {
                case ImapConnectionState.Disconnected: throw new MailClientException("You can execute this command only when State is Disconnected");

                case ImapConnectionState.Connected: throw new MailClientException("You can execute this command only when State is Connected");

                case ImapConnectionState.Authenticated: throw new MailClientException("You can execute this command only when State is Authenticated");

                default: throw new MailClientException();
                }
            }
            if (folderSelected == true && this.CurrentFolder == null)
            {
                throw new MailClientException("You must select folder before executing this command."
                                              + "You can select folder by calling SelectFolder,ExecuteSelect,ExecuteExamine method of this object.");
            }
        }
Пример #8
0
        public ImapCommandResult ExecuteLogin()   //Grazina informacija apie atsakyma (ar geras ar ne) ir nustato ImapConnectionState (authenticated / conneceted)
        {
            if (this.EnsureOpen() == ImapConnectionState.Disconnected)
            {
                throw new MailClientException();
            }                                                                                               //Metamas error jei esame disconnected ir negalima prisijungti

            String            commandText = String.Format(this.Tag + " LOGIN {0} {1}", this.UserName, this.Password);
            String            s           = this.Execute(commandText);          //Ivykdo komanda ir grazina atsakyma
            ImapCommandResult rs          = new ImapCommandResult(this.Tag, s); //Laiko informacija apie atsakyma (ar geras ar ne)

            if (rs.Status == ImapCommandResultStatus.Ok)                        //+
            {
                this._State = ImapConnectionState.Authenticated;                //+
            }
            else //+
            {
                this._State = ImapConnectionState.Connected; //+
            }
            return(rs);                                      //+
        }
Пример #9
0
        private void ValidateState(ImapConnectionState state, Boolean folderSelected)                                                                   //Meta error jei esame blogame state arba isrinkome neegzistuojanti folderi
        {
            if (this._State != state)                                                                                                                   //+
            {
                switch (state)                                                                                                                          //+
                {
                case ImapConnectionState.Disconnected: throw new MailClientException("You can execute this command only when State is Disconnected");   //+

                case ImapConnectionState.Connected: throw new MailClientException("You can execute this command only when State is Connected");         //+

                case ImapConnectionState.Authenticated: throw new MailClientException("You can execute this command only when State is Authenticated"); //+

                default: throw new MailClientException();                                                                                               //+
                }
            }
            if (folderSelected == true && this.CurrentFolder == null)
            {
                throw new MailClientException("You must select folder before executing this command."                                                 //+
                                              + "You can select folder by calling SelectFolder,ExecuteSelect,ExecuteExamine method of this object."); //+
            }
        }
Пример #10
0
 private void ValidateState(ImapConnectionState state)
 {
     this.ValidateState(state, false);
 }
Пример #11
0
 /// <summary>
 /// disconnect connection to IMAP server.
 /// </summary>
 public void Close()
 {
     this.Socket.Close();
     this.Socket = null;
     this._State = ImapConnectionState.Disconnected;
 }
Пример #12
0
 private void ValidateState(ImapConnectionState state)
 {
     this.ValidateState(state, false);
 }
Пример #13
0
 private void ValidateState(ImapConnectionState state, Boolean folderSelected)
 {
     if (this._State != state)
     {
         switch (state)
         {
             case ImapConnectionState.Disconnected: throw new MailClientException("You can execute this command only when State is Disconnected");
             case ImapConnectionState.Connected: throw new MailClientException("You can execute this command only when State is Connected");
             case ImapConnectionState.Authenticated: throw new MailClientException("You can execute this command only when State is Authenticated");
             default: throw new MailClientException();
         }
     }
     if (folderSelected == true && this.CurrentFolder == null)
     {
         throw new MailClientException("You must select folder before executing this command."
           + "You can select folder by calling SelectFolder,ExecuteSelect,ExecuteExamine method of this object.");
     }
 }
Пример #14
0
 /// <summary>
 /// Send Logout command to IMAP server.
 /// </summary>
 /// <returns></returns>
 public ImapCommandResult ExecuteLogout()
 {
     this.ValidateState(ImapConnectionState.Authenticated);
     ImapCommandResult rs = this.Execute(this.Tag + " Logout");
     if (rs.Status == ImapCommandResultStatus.Ok)
     {
         this._State = ImapConnectionState.Connected;
     }
     return rs;
 }
Пример #15
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ImapCommandResult ExecuteLogin()
        {
            if (this.EnsureOpen() == ImapConnectionState.Disconnected) { throw new MailClientException("Connection is not available."); }

            String commandText = String.Format(this.Tag + " LOGIN {0} \"{1}\"", this.UserName, this.Password);
            ImapCommandResult rs = this.Execute(commandText);
            if (rs.Status == ImapCommandResultStatus.Ok)
            {
                this._State = ImapConnectionState.Authenticated;
            }
            else
            {
                this._State = ImapConnectionState.Connected;
            }
            return rs;
        }
Пример #16
0
 /// <summary>
 /// Send IDLE command to IMAP server.
 /// You can receive message from server by register event handler to MessageReceived event of ImapIdleCommand object
 /// </summary>
 /// <returns></returns>
 public void ExecuteIdle(ImapIdleCommand command)
 {
     this.ValidateState(ImapConnectionState.Authenticated);
     this.Send(this.Tag + " IDLE");
     var bb = command.Buffer;
     command.IAsyncResult = this.Stream.BeginRead(bb, 0, bb.Length, this.ExecuteIdleCallback, command);
     this._State = ImapConnectionState.Idle;
 }
Пример #17
0
 /// <summary>
 /// Send done command to IMAP server.
 /// </summary>
 /// <returns></returns>
 public ImapCommandResult ExecuteDone(ImapIdleCommand command)
 {
     this.ValidateState(ImapConnectionState.Idle);
     if (command.IAsyncResult != null)
     {
         var x = this.Stream.EndRead(command.IAsyncResult);
     }
     var rs = this.Execute("DONE");
     this._State = ImapConnectionState.Authenticated;
     return rs;
 }
Пример #18
0
 /// <summary>
 /// disconnect connection to IMAP server.
 /// </summary>
 public override void Close()
 {
     base.Close();
     this._State = ImapConnectionState.Disconnected;
 }
Пример #19
0
 private void ValidateState(ImapConnectionState state) //Meta error jei esame blogame state
 {
     this.ValidateState(state, false);                 //Meta error jei esame blogame state arba isrinkome neegzistuojanti folderi
 }
Пример #20
0
 /// <summary>
 /// Open connection to a server.
 /// </summary>
 public ImapConnectionState Open()
 {
     if (this.Connect() == true)
     {
         this._State = ImapConnectionState.Connected;
     }
     else
     {
         this._State = ImapConnectionState.Disconnected;
     }
     return this._State;
 }