private Indexable ToAddRssIndexable(XmlDocument document) { string encoding_str = null; StringReader reader = null; if (ToBool(GetText(document, "HasOffline"))) { try { // RSS does not use OfflineSize but MessageSize instead (for some reason...) int offset = Convert.ToInt32(GetText(document, "MessageOffset")), size = Convert.ToInt32(GetText(document, "MessageSize")); reader = GetRssBody(GetText(document, "FolderFile"), offset, size, out encoding_str); } catch (Exception e) { Logger.Log.Debug(e, "Failed to parse RSS body"); } } Indexable indexable = new Indexable(GenerateUniqueUri(document)); indexable.HitType = "FeedItem"; indexable.MimeType = "text/html"; indexable.Timestamp = DateTimeUtil.UnixToDateTimeUtc(Convert.ToInt64(GetText(document, "Date"))); indexable.CacheContent = true; indexable.FlushBufferCache = true; indexable.AddProperty(Property.NewKeyword("fixme:client", "thunderbird")); indexable.AddProperty(Property.NewKeyword("fixme:folder", GetText(document, "Folder"))); indexable.AddProperty(Property.NewUnsearched("ParentUri", GetText(document, "FolderFile"))); indexable.AddProperty(Property.NewUnsearched("fixme:uri", GetText(document, "Uri"))); indexable.AddProperty(Property.NewKeyword("dc:identifier", ExtractUrl(GetText(document, "MessageId")))); indexable.AddProperty(Property.NewKeyword("dc:source", GetText(document, "FeedURL"))); indexable.AddProperty(Property.New("dc:publisher", Mime.HeaderDecodePhrase(GetText(document, "Author")))); // The title will be added by the filter. In case we add it twice we will just get // an empty tile in the search tool (a bug maybe?). if (reader != null) { // If we got an encoding, make sure we use that if (!String.IsNullOrEmpty(encoding_str)) { indexable.AddProperty(Property.New( String.Format("{0}encoding", StringFu.UnindexedNamespace), encoding_str)); } indexable.SetTextReader(reader); } else { indexable.AddProperty(Property.New("dc:title", Mime.HeaderDecodePhrase(GetText(document, "Subject")))); } return(indexable); }
private GMime.Message GetStubMessage(XmlDocument document) { GMime.Message message = new GMime.Message(true); message.Subject = Mime.HeaderDecodeText(GetText(document, "Subject")); message.Sender = Mime.HeaderDecodePhrase(GetText(document, "Author")); message.MessageId = GetText(document, "MessageId"); message.Date = DateTimeUtil.UnixToDateTimeUtc(Convert.ToInt64(GetText(document, "Date"))); string str = GetText(document, "Recipients"); GMime.InternetAddressList recipients = GMime.InternetAddressList.Parse(str); foreach (GMime.InternetAddress ia in recipients) { message.To.Add(ia); } recipients.Dispose(); return(message); }