예제 #1
0
파일: Pop3Engine.cs 프로젝트: radiy/MailKit
        void ProcessCommand(Pop3Command pc)
        {
            string response, text;

            byte[] buf;

            buf = Encoding.UTF8.GetBytes(pc.Command + "\r\n");
            stream.Write(buf, 0, buf.Length);

            try {
                response = ReadLine(pc.CancellationToken).TrimEnd();
            } catch {
                pc.Status = Pop3CommandStatus.ProtocolError;
                Disconnect();
                throw;
            }

            pc.Status = GetCommandStatus(response, out text);
            switch (pc.Status)
            {
            case Pop3CommandStatus.ProtocolError:
                Disconnect();
                throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response));

            case Pop3CommandStatus.Continue:
            case Pop3CommandStatus.Ok:
                if (pc.Handler != null)
                {
                    try {
                        pc.Handler(this, pc, text);
                    } catch {
                        pc.Status = Pop3CommandStatus.ProtocolError;
                        Disconnect();
                        throw;
                    }
                }
                break;
            }
        }
예제 #2
0
        async Task ReadResponseAsync(Pop3Command pc, bool doAsync)
        {
            string response, text;

            try {
                response = (await ReadLineAsync(doAsync, pc.CancellationToken).ConfigureAwait(false)).TrimEnd();
            } catch {
                pc.Status = Pop3CommandStatus.ProtocolError;
                Disconnect();
                throw;
            }

            pc.Status     = GetCommandStatus(response, out text);
            pc.StatusText = text;

            switch (pc.Status)
            {
            case Pop3CommandStatus.ProtocolError:
                Disconnect();
                throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response));

            case Pop3CommandStatus.Continue:
            case Pop3CommandStatus.Ok:
                if (pc.Handler != null)
                {
                    try {
                        await pc.Handler(this, pc, text, doAsync).ConfigureAwait(false);
                    } catch {
                        pc.Status = Pop3CommandStatus.ProtocolError;
                        Disconnect();
                        throw;
                    }
                }
                break;
            }
        }
예제 #3
0
        void ReadResponse(Pop3Command pc)
        {
            string response, text;

            try {
                response = ReadLine(pc.CancellationToken).TrimEnd();
            } catch {
                pc.Status = Pop3CommandStatus.ProtocolError;
                Disconnect();
                throw;
            }

            pc.Status     = GetCommandStatus(response, out text);
            pc.StatusText = text;

            switch (pc.Status)
            {
            case Pop3CommandStatus.ProtocolError:
                Disconnect();
                throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response));

            case Pop3CommandStatus.Continue:
            case Pop3CommandStatus.Ok:
                if (pc.Handler != null)
                {
                    try {
                        pc.Handler(this, pc, text);
                    } catch {
                        pc.Status = Pop3CommandStatus.ProtocolError;
                        Disconnect();
                        throw;
                    }
                }
                break;
            }
        }
예제 #4
0
        void ProcessCommand(Pop3Command pc)
        {
            string response, text;
            byte[] buf;

            buf = Encoding.UTF8.GetBytes (pc.Command + "\r\n");
            stream.Write (buf, 0, buf.Length);

            try {
                response = ReadLine (pc.CancellationToken).TrimEnd ();
            } catch {
                pc.Status = Pop3CommandStatus.ProtocolError;
                Disconnect ();
                throw;
            }

            pc.Status = GetCommandStatus (response, out text);
            switch (pc.Status) {
            case Pop3CommandStatus.ProtocolError:
                Disconnect ();
                throw new Pop3ProtocolException (string.Format ("Unexpected response from server: {0}", response));
            case Pop3CommandStatus.Continue:
            case Pop3CommandStatus.Ok:
                if (pc.Handler != null) {
                    try {
                        pc.Handler (this, pc, text);
                    } catch {
                        pc.Status = Pop3CommandStatus.ProtocolError;
                        Disconnect ();
                        throw;
                    }
                }
                break;
            }
        }
예제 #5
0
		void ReadResponse (Pop3Command pc)
		{
			string response, text;

			try {
				response = ReadLine (pc.CancellationToken).TrimEnd ();
			} catch {
				pc.Status = Pop3CommandStatus.ProtocolError;
				Disconnect ();
				throw;
			}

			pc.Status = GetCommandStatus (response, out text);
			pc.StatusText = text;

			switch (pc.Status) {
			case Pop3CommandStatus.ProtocolError:
				Disconnect ();
				throw new Pop3ProtocolException (string.Format ("Unexpected response from server: {0}", response));
			case Pop3CommandStatus.Continue:
			case Pop3CommandStatus.Ok:
				if (pc.Handler != null) {
					try {
						pc.Handler (this, pc, text);
					} catch {
						pc.Status = Pop3CommandStatus.ProtocolError;
						Disconnect ();
						throw;
					}
				}
				break;
			}
		}