Пример #1
0
 internal void SendCommandAsync(string command, AsyncCallback readCallback, DataCommunicator.GetCommandResponseDelegate responseDelegate, object callerArguments)
 {
     if (this.dataStream == null)
     {
         return;
     }
     DataCommunicator.State state = new DataCommunicator.State();
     state.ReadDataCallback = readCallback;
     state.ResponseDelegate = responseDelegate;
     state.CallerArguments  = callerArguments;
     state.DataStream       = this.dataStream;
     try
     {
         this.StartTimer();
         byte[] bytes = Encoding.ASCII.GetBytes(command);
         this.dataStream.BeginWrite(bytes, 0, bytes.Length, new AsyncCallback(this.SendDataCallback), state);
     }
     catch (IOException exception)
     {
         this.HandleException(exception);
     }
     catch (InvalidOperationException exception2)
     {
         this.HandleException(exception2);
     }
 }
Пример #2
0
        internal void PassCommand(DataCommunicator.GetCommandResponseDelegate callback, string password)
        {
            string command = string.Format(CultureInfo.InvariantCulture, "PASS {0}\r\n", new object[]
            {
                password
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(base.SingleLineResponseCallback), callback, null);
        }
Пример #3
0
        internal void UserCommand(DataCommunicator.GetCommandResponseDelegate callback, string userID)
        {
            string command = string.Format(CultureInfo.InvariantCulture, "USER {0}\r\n", new object[]
            {
                userID
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(base.SingleLineResponseCallback), callback, null);
        }
Пример #4
0
        internal void DeleteMessage(DataCommunicator.GetCommandResponseDelegate callback, string messageNumber)
        {
            string command = string.Format(CultureInfo.InvariantCulture, "DELE {0}\r\n", new object[]
            {
                messageNumber
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(base.SingleLineResponseCallback), callback, null);
        }
Пример #5
0
        internal void StartTls(DataCommunicator.GetCommandResponseDelegate callback)
        {
            this.GenerateCommandTag();
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                "STARTTLS\r\n"
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(base.SingleLineResponseCallback), callback, null);
        }
Пример #6
0
        internal void ExpungeMessages(DataCommunicator.GetCommandResponseDelegate callback)
        {
            this.GenerateCommandTag();
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                "EXPUNGE\r\n"
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #7
0
 internal void InitializeSecureStreamAsync(DataCommunicator.GetCommandResponseDelegate responseDelegate)
 {
     if (this.dataStream == null)
     {
         return;
     }
     this.InitializeSecureStreamAsync(new DataCommunicator.State
     {
         ResponseDelegate = responseDelegate,
         DataStream       = this.DataStream
     });
 }
Пример #8
0
        internal void SelectFolder(DataCommunicator.GetCommandResponseDelegate callback, string folder)
        {
            this.GenerateCommandTag();
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                string.Format(CultureInfo.InvariantCulture, "SELECT \"{0}\"\r\n", new object[]
                {
                    folder
                })
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #9
0
        internal void FindMessageIDsBySubject(string subjectKey, DataCommunicator.GetCommandResponseDelegate callback)
        {
            this.GenerateCommandTag();
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                string.Format(CultureInfo.InvariantCulture, "SEARCH SUBJECT \"{0}\"\r\n", new object[]
                {
                    subjectKey
                })
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #10
0
 internal void ReadResponseAsync(AsyncCallback readCallback, DataCommunicator.GetCommandResponseDelegate responseDelegate, object callerArguments)
 {
     if (this.dataStream == null)
     {
         return;
     }
     DataCommunicator.State state = new DataCommunicator.State();
     state.ReadDataCallback = readCallback;
     state.ResponseDelegate = responseDelegate;
     state.CallerArguments  = callerArguments;
     state.DataStream       = this.dataStream;
     this.StartTimer();
     this.ReadResponseAsync(state);
 }
Пример #11
0
        internal void LogOn(DataCommunicator.GetCommandResponseDelegate callback, string userID, string password)
        {
            this.GenerateCommandTag();
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                string.Format(CultureInfo.InvariantCulture, "LOGIN {0} {1}\r\n", new object[]
                {
                    userID,
                    password
                })
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(base.SingleLineResponseCallback), callback, null);
        }
Пример #12
0
 internal void ConnectAsync(AsyncCallback readCallback, DataCommunicator.GetCommandResponseDelegate responseDelegate, object callerArguments)
 {
     DataCommunicator.State state = new DataCommunicator.State();
     state.ResponseDelegate = responseDelegate;
     state.ReadDataCallback = readCallback;
     state.CallerArguments  = callerArguments;
     try
     {
         this.tcpClient = new TcpClient();
     }
     catch (SocketException exception)
     {
         this.HandleException(exception);
     }
     this.StartTimer();
     this.tcpClient.BeginConnect(this.serverName, this.port, new AsyncCallback(this.ConnectAsyncCallback), state);
 }
Пример #13
0
        internal void FindMessagesBeforeTodayContainingSubject(DataCommunicator.GetCommandResponseDelegate callback, string subject)
        {
            this.GenerateCommandTag();
            string text  = ExDateTime.Now.ToString("dd-MMM-yyyy", CultureInfo.InvariantCulture);
            string text2 = string.Format(CultureInfo.InvariantCulture, "SEARCH BEFORE \"{0}\" SUBJECT \"{1}\"\r\n", new object[]
            {
                text,
                subject
            });
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                text2
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #14
0
        internal void StoreMessages(DataCommunicator.GetCommandResponseDelegate callback, string[] messageIDs)
        {
            StringBuilder stringBuilder = new StringBuilder(messageIDs[0]);

            for (int i = 1; i < messageIDs.Length; i++)
            {
                stringBuilder.AppendFormat(",{0}", messageIDs[i]);
            }
            this.GenerateCommandTag();
            string command = string.Format(CultureInfo.InvariantCulture, "{0} {1}", new object[]
            {
                this.currentTag,
                string.Format(CultureInfo.InvariantCulture, "STORE {0} +FLAGS (\\Deleted)\r\n", new object[]
                {
                    stringBuilder.ToString()
                })
            });

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #15
0
 internal void LogOff(DataCommunicator.GetCommandResponseDelegate callback)
 {
     base.Communicator.SendCommandAsync("QUIT\r\n", new AsyncCallback(base.SingleLineResponseCallback), callback, null);
 }
Пример #16
0
 internal virtual void Connect(DataCommunicator.GetCommandResponseDelegate responseDelegate)
 {
     this.communicator.ConnectAsync(new AsyncCallback(this.SingleLineResponseCallback), responseDelegate, null);
 }
Пример #17
0
 internal void SetUpSecureStreamForTls(DataCommunicator.GetCommandResponseDelegate callback)
 {
     this.Communicator.InitializeSecureStreamAsync(callback);
 }
Пример #18
0
        internal void List(DataCommunicator.GetCommandResponseDelegate callback)
        {
            string command = "LIST\r\n";

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #19
0
        internal void Capa(DataCommunicator.GetCommandResponseDelegate callback)
        {
            string command = string.Format(CultureInfo.InvariantCulture, "CAPA\r\n", new object[0]);

            base.Communicator.SendCommandAsync(command, new AsyncCallback(this.MultiLineResponseCallback), callback, null);
        }
Пример #20
0
        internal void Stls(DataCommunicator.GetCommandResponseDelegate callback)
        {
            string command = string.Format(CultureInfo.InvariantCulture, "STLS\r\n", new object[0]);

            base.Communicator.SendCommandAsync(command, new AsyncCallback(base.SingleLineResponseCallback), callback, null);
        }