public NntpMessage(Account account, Hashtable data, string workfile)
                : base(account, data, workfile)
            {
                foreach (string key in data.Keys)
                {
                    if (key == "id")
                    {
                        SetObject(key, data [key]);
                    }
                    else if (key == "subject")
                    {
                        SetObject(key, Utils.HeaderDecodeText((string)data [key]));
                    }
                    else if (key == "sender")
                    {
                        SetObject(key, Utils.HeaderDecodePhrase((string)data [key]));
                    }
                    else if (key == "date")
                    {
                        SetObject(key, Thunderbird.HexDateToString((string)data [key]));
                    }
                    else if (key == "size")
                    {
                        SetObject(key, Thunderbird.Hex2Dec((string)data [key]));
                    }
                }

                Uri = NewUri(account, ConstructMailboxString(workfile, account), GetString("id"));
            }
Exemple #2
0
        public static string Decode(string str, System.Text.Encoding to_encoding)
        {
            if (str == null || str == string.Empty || to_encoding == null || str.IndexOf('$') == -1)
            {
                return(str);
            }

            foreach (Match m in Regex.Matches(str, @"\$(?<1>[0-9A-F]{2})\$(?<2>[0-9A-F]{2})|\$(?<3>[0-9A-F]{2})"))
            {
                string char1 = m.Result("${1}"), char2 = m.Result("${2}"), char3 = m.Result("${3}");

                if (char1 != string.Empty)
                {
                    str = str.Replace(String.Format(@"${0}${1}", char1, char2),
                                      Convert(Thunderbird.Hex2Dec(char1), Thunderbird.Hex2Dec(char2), to_encoding));
                }
                else
                {
                    str = str.Replace(String.Format(@"${0}", char3),
                                      Convert(Thunderbird.Hex2Dec(char3), -1, to_encoding));
                }
            }

            return(str);
        }
            public Mail(Account account, Hashtable data, string workfile)
            {
                foreach (string key in data.Keys)
                {
                    if (key == "id")
                    {
                        SetObject(key, data [key]);
                    }
                    else if (key == "sender")
                    {
                        SetObject(key, Utils.HeaderDecodePhrase((string)data [key]));
                    }
                    else if (key == "subject")
                    {
                        SetObject(key, Utils.HeaderDecodeText((string)data [key]));
                    }
                    else if (key == "recipients")
                    {
                        SetObject(key, Utils.HeaderDecodePhrase((string)data [key]));
                    }
                    else if (key == "date")
                    {
                        SetObject(key, Thunderbird.HexDateToString((string)data [key]));
                    }
                    else if (key == "size")
                    {
                        SetObject(key, Thunderbird.Hex2Dec((string)data [key]));
                    }
                    else if (key == "msgOffset")
                    {
                        SetObject(key, Thunderbird.Hex2Dec((string)data[key]));
                    }
                    else if (key == "offlineMsgSize")
                    {
                        SetObject(key, Thunderbird.Hex2Dec((string)data [key]));
                    }
                    else if (key == "message-id")
                    {
                        SetObject(key, (string)data [key]);
                    }
                    else if (key == "references")
                    {
                        SetObject(key, (data [key] as string).Replace("\\", ""));
                    }
                }

                this.account  = account;
                this.workfile = workfile;
                SetObject("mailbox", Thunderbird.ConstructMailboxString(workfile, account));
                this.uri = Thunderbird.NewUri(Account, GetString("mailbox"), GetString("id"));
            }