Пример #1
0
        public override void DecodeText(MailReader input, TextWriter output, GeneXus.Mail.Util.AsyncRunner runner)
        {
            string line;

            while (true)
            {
                line = input.ReadLine();
                ResetTimer(runner);
                if ((line == null) || line.Equals("."))
                {
                    break;
                }
                output.WriteLine(line);
            }
        }
Пример #2
0
        public override void DecodeFile(MailReader input, Stream output, GeneXus.Mail.Util.AsyncRunner runner)
        {
            string line;

            while (true)
            {
                line = input.ReadLine();
                ResetTimer(runner);
                if ((line == null) || line.Equals("."))
                {
                    break;
                }
                byte[] bytes = input.GetEncoding().GetBytes(line + CRLF);
                output.Write(bytes, 0, bytes.Length);
            }
        }
Пример #3
0
        private byte[] GetFromBase64String(MailReader input, GeneXus.Mail.Util.AsyncRunner runner)
        {
            StringBuilder strBuilder = new StringBuilder();
            string        str        = null;

            while (true)
            {
                str = input.ReadLine();
                ResetTimer(runner);
                if (string.IsNullOrEmpty(str) || str.Equals("."))
                {
                    break;
                }
                strBuilder.Append(str);
            }
            return(Convert.FromBase64String(strBuilder.ToString()));
        }
Пример #4
0
 public void ReadAllMessage()
 {
     this.timeoutException = null;
     if (timeout > 0)
     {
         runner = new GeneXus.Mail.Util.AsyncRunner(this, "ReadEntireMessage", Array.Empty <object>(), new GeneXus.Mail.Util.AsyncCallback(this, "SetFinishReading", false), timeout);
         runner.Run();
         mainThread.Suspend();
         if (this.timeoutException != null)
         {
             throw this.timeoutException;
         }
     }
     else
     {
         ReadEntireMessage();
         SetFinishReading(null);
     }
 }
        private string DecodeImp(MailReader input, Encoding enc, bool header, GeneXus.Mail.Util.AsyncRunner runner)
        {
            int           charRead = 0;
            StringBuilder sb       = new StringBuilder();

            while ((charRead = input.Read()) != -1)
            {
                if (header)
                {
                    if (charRead == 13 || charRead == 10) // CR LF must be removed from header.
                    {
                        continue;
                    }
                    else
                    if (charRead == 95)     // Underscore in Header must be replaced by space.
                    {
                        charRead = ' ';
                    }
                }
                sb.Append((char)charRead);
                ResetTimer(runner);
            }
            return(DecodeQuotedPrintable(sb.ToString(), enc));
        }
Пример #6
0
 public override void DecodeFile(MailReader input, Stream output, GeneXus.Mail.Util.AsyncRunner runner)
 {
     byte[] converted = GetFromBase64String(input, runner);
     output.Write(converted, 0, converted.Length);
 }
Пример #7
0
 public override void DecodeText(MailReader input, TextWriter output, GeneXus.Mail.Util.AsyncRunner runner)
 {
     output.Write(input.GetEncoding().GetString(GetFromBase64String(input, runner)));
 }
 public override void DecodeFile(MailReader input, Stream output, GeneXus.Mail.Util.AsyncRunner runner)
 {
     Decode(input, output, input.GetEncoding(), false, runner);
 }
        public void Decode(MailReader input, Stream output, Encoding enc, bool header, GeneXus.Mail.Util.AsyncRunner runner)
        {
            string result = DecodeImp(input, enc, header, runner);

            if (result.StartsWith("\r\n"))
            {
                result = result.Substring(2);
            }
            byte[] buffer = enc.GetBytes(result);
            output.Write(enc.GetBytes(result), 0, buffer.Length);
        }
 public override void DecodeText(MailReader input, TextWriter output, GeneXus.Mail.Util.AsyncRunner runner)
 {
     Decode(input, output, input.GetEncoding(), false, runner);
 }
        public void Decode(MailReader input, TextWriter output, Encoding enc, bool header, GeneXus.Mail.Util.AsyncRunner runner)
        {
            string result = DecodeImp(input, enc, header, runner);

            output.Write(result);
        }