private Indexable ToAddMailMessageIndexable(XmlDocument document) { GMime.Message message = null; // Check if the entire message is available if (ToBool(GetText(document, "HasOffline"))) { // We must make sure we don't get an exception here since we can fallback to // other information try { int offset = Convert.ToInt32(GetText(document, "MessageOffset")), size = Convert.ToInt32(GetText(document, "OfflineSize")); message = GetGMimeMessage(GetText(document, "FolderFile"), offset, size); } catch (Exception e) { Logger.Log.Debug(e, "Failed to parse GMime message"); } } if (message == null) { message = GetStubMessage(document); } Indexable indexable = new Indexable(GenerateUniqueUri(document)); indexable.HitType = "MailMessage"; indexable.MimeType = "message/rfc822"; indexable.Timestamp = DateTimeUtil.UnixToDateTimeUtc(Convert.ToInt64(GetText(document, "Date"))); indexable.CacheContent = true; indexable.FlushBufferCache = true; indexable.SetBinaryStream(message.Stream); 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"))); message.Dispose(); return(indexable); }
private Indexable MailToIndexable(TB.Mail mail) { Indexable indexable; GMime.Message message = mail.Message; FullIndex = mail.GetBool("FullIndex"); // Make sure this is up to date string mailbox = (MailboxName != null ? MailboxName : (string)mail.GetString("mailbox")); indexable = NewIndexable(mail.Uri, message.Date.ToUniversalTime(), "MailMessage"); indexable.MimeType = "message/rfc822"; indexable.CacheContent = true; indexable.AddProperty(Property.NewKeyword("fixme:folder", mailbox)); indexable.SetBinaryStream(message.Stream); if (mail.GetBool("FullIndex")) { indexable.ContentUri = UriFu.PathToFileUri(Thunderbird.GetFullyIndexableFile(DbFile)); } message.Dispose(); return(indexable); }