private GMime.Message FullMessage() { int fd; string file = Thunderbird.GetFullyIndexableFile(workfile); GMime.Message message = null; // gmime will go nuts and make the daemon "segmentation fault" in case the file doesn't exist! if (!File.Exists(file)) { return(message); } try { fd = Mono.Unix.Native.Syscall.open(file, Mono.Unix.Native.OpenFlags.O_RDONLY); StreamFs stream = new StreamFs(fd, Offset, Offset + Size); Parser parser = new Parser(stream); message = parser.ConstructMessage(); stream.Dispose(); parser.Dispose(); } catch {} return(message); }
public Contact(Account account, Hashtable data, string workfile) { this.account = account; this.data = data; this.workfile = workfile; this.uri = NewUri(account, Thunderbird.ConstructMailboxString(workfile, account), GetString("id")); }
public static string GetRelativePath(string mork_file) { string path = null; AccountReader reader = null; foreach (string root in Thunderbird.GetProfilePaths(Thunderbird.GetRootPath())) { try { reader = new AccountReader(root); foreach (Account account in reader) { if (!mork_file.StartsWith(account.Path)) { continue; } path = String.Format("{0}/{1}", account.Server, mork_file.Substring(account.Path.Length + 1)); break; } } catch { continue; } } return(path); }
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 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")); }
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")); }
public ThunderbirdIndexableGenerator (ThunderbirdIndexer indexer, TB.Account account, string db_file) { this.indexer = indexer; this.indexer.NotificationEvent += OnNotification; this.account = account; this.full_index = true; this.db_file = db_file; this.done = false; this.relative_path = Thunderbird.GetRelativePath (db_file); // Load the database and make sure the enumerator is up to date. Otherwise we will // get lots of null exceptions when enumerating the database. LoadDatabase (); ResetEnumerator (); // Fetch all already stored uris in the index. This way we can remove one uri at the time // while we are indexing and thus in the end now which mails that doesn't exist anymore. if (relative_path != null) stored_cache = indexer.Lucene.GetStoredUriStrings (account.Server, relative_path); else Logger.Log.Debug ("Relative path could not be determined for: {0}. Indexing speed will suffer.", db_file); }
private Indexable RssFeedToIndexable (TB.RssFeed feed) { Indexable indexable; StringReader content = feed.Content; indexable = NewIndexable (feed.Uri, DateTime.Parse (feed.GetString ("date")).ToUniversalTime (), "FeedItem"); indexable.MimeType = "text/html"; indexable.AddProperty (Property.NewKeyword ("dc:identifier", feed.GetString ("message-id"))); indexable.AddProperty (Property.NewKeyword ("dc:source", feed_url)); indexable.AddProperty (Property.New ("dc:publisher", feed.GetString ("sender"))); if (content == null) indexable.AddProperty (Property.New ("dc:title", feed.GetString ("subject"))); indexable.SetTextReader (content); return indexable; }
public RssIndexableGenerator (ThunderbirdIndexer indexer, TB.Account account, string mork_file) : base (indexer, account, mork_file) { }
private Indexable ContactToIndexable (TB.Contact contact) { Indexable indexable = NewIndexable (contact.Uri, DateTime.Now.ToUniversalTime (), "Contact"); indexable.AddProperty (Property.New ("fixme:FirstName", contact.GetString ("FirstName"))); indexable.AddProperty (Property.New ("fixme:LastName", contact.GetString ("LastName"))); indexable.AddProperty (Property.New ("fixme:DisplayName", contact.GetString ("LastName"))); indexable.AddProperty (Property.New ("fixme:NickName", contact.GetString ("NickName"))); indexable.AddProperty (Property.NewKeyword ("fixme:PrimaryEmail", contact.GetString ("PrimaryEmail"))); indexable.AddProperty (Property.NewKeyword ("fixme:SecondEmail", contact.GetString ("SecondEmail"))); indexable.AddProperty (Property.New ("fixme:WorkPhone", contact.GetString ("WorkPhone"))); indexable.AddProperty (Property.New ("fixme:FaxNumber", contact.GetString ("FaxNumber"))); indexable.AddProperty (Property.New ("fixme:HomePhone", contact.GetString ("HomePhone"))); indexable.AddProperty (Property.New ("fixme:PagerNumber", contact.GetString ("PagerNumber"))); indexable.AddProperty (Property.New ("fixme:CellularNumber", contact.GetString ("CellularNumber"))); indexable.AddProperty (Property.New ("fixme:HomeAddress", contact.GetString ("HomeAddress"))); indexable.AddProperty (Property.New ("fixme:HomeAddress2", contact.GetString ("HomeAddress2"))); indexable.AddProperty (Property.New ("fixme:HomeCity", contact.GetString ("HomeCity"))); indexable.AddProperty (Property.New ("fixme:HomeState", contact.GetString ("HomeState"))); indexable.AddProperty (Property.New ("fixme:HomeZipCode", contact.GetString("HomeZipCode"))); indexable.AddProperty (Property.New ("fixme:HomeCountry", contact.GetString ("HomeCountry"))); indexable.AddProperty (Property.New ("fixme:WorkAddress", contact.GetString ("WorkAddress"))); indexable.AddProperty (Property.New ("fixme:WorkAddress2", contact.GetString ("WorkAddress2"))); indexable.AddProperty (Property.New ("fixme:WorkCity", contact.GetString ("WorkCity"))); indexable.AddProperty (Property.New ("fixme:WorkState", contact.GetString ("WorkState"))); indexable.AddProperty (Property.New ("fixme:WorkZipCode", contact.GetString ("WorkZipCode"))); indexable.AddProperty (Property.New ("fixme:WorkCountry", contact.GetString ("WorkCountry"))); indexable.AddProperty (Property.New ("fixme:JobTitle", contact.GetString ("JobTitle"))); indexable.AddProperty (Property.New ("fixme:Department", contact.GetString ("Department"))); indexable.AddProperty (Property.New ("fixme:Company", contact.GetString ("Company"))); indexable.AddProperty (Property.New ("fixme:_AimScreenName", contact.GetString ("_AimScreenName"))); indexable.AddProperty (Property.New ("fixme:FamilyName", contact.GetString ("FamilyName"))); indexable.AddProperty (Property.NewKeyword ("fixme:WebPage1", contact.GetString ("WebPage1"))); indexable.AddProperty (Property.NewKeyword ("fixme:WebPage2", contact.GetString ("WebPage2"))); indexable.AddProperty (Property.New ("fixme:BirthYear", contact.GetString ("BirthYear"))); indexable.AddProperty (Property.New ("fixme:BirthMonth", contact.GetString ("BirthMonth"))); indexable.AddProperty (Property.New ("fixme:BirthDay", contact.GetString ("BirthDay"))); indexable.AddProperty (Property.New ("fixme:Custom1", contact.GetString ("Custom1"))); indexable.AddProperty (Property.New ("fixme:Custom2", contact.GetString ("Custom2"))); indexable.AddProperty (Property.New ("fixme:Custom3", contact.GetString ("Custom3"))); indexable.AddProperty (Property.New ("fixme:Custom4", contact.GetString ("Custom4"))); indexable.AddProperty (Property.New ("fixme:Notes", contact.GetString ("Notes"))); indexable.AddProperty (Property.New ("fixme:PreferMailFormat", contact.GetString ("PreferMailFormat"))); indexable.AddProperty (Property.NewKeyword ("fixme:Email", contact.GetString ("PrimaryEmail"))); indexable.AddProperty (Property.New ("fixme:Name", contact.GetString ("DisplayName"))); return indexable; }
public ContactIndexableGenerator (ThunderbirdIndexer indexer, TB.Account account, string abook_file) : base (indexer, account, abook_file) { }
public NntpIndexableGenerator (ThunderbirdIndexer indexer, TB.Account account, string file) : base (indexer, account, file) { }
// FIXME: This need some more info private Indexable MoveMailToIndexable (TB.MoveMail mail) { Indexable indexable; indexable = NewIndexable (mail.Uri, DateTime.UtcNow, "MailMessage"); indexable.MimeType = "message/rfc822"; string subject = GMime.Utils.HeaderDecodePhrase (mail.GetString ("subject")); indexable.AddProperty (Property.New ("dc:title", subject)); 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; }
public NotificationEventArgs (NotificationType type, TB.Account account) { this.type = type; this.account = account; }
public void RemoveAccount (TB.Account account) { TB.Account acc = GetParentAccount (account.Path); if (acc == null) return; ScheduleRemoval (Property.NewKeyword ("fixme:account", acc.Server), Scheduler.Priority.Delayed); OnNotification (new NotificationEventArgs (NotificationType.StopIndexing, account)); account_list.Remove (acc); }
public void IndexAccount (TB.Account account) { TB.Account stored_account = GetParentAccount (account.Path); // We need to act upon changes made to accounts during Thunderbird runtime. // The user might change from plain to SSL, which leads to a new port number // that has to be taken in account for when indexing. if (stored_account == null && Directory.Exists (account.Path) && supported_types [account.Type] != null) { account_list.Add (account); IndexDirectory (account.Path); //Logger.Log.Info ("Indexing {0} account {1}", account.Type.ToString (), account.Server); } else if (stored_account == null && File.Exists (account.Path) && supported_types [account.Type] != null) { account_list.Add (account); IndexFile (account.Path); //Logger.Log.Info ("Indexing {0} account {1}", account.Type.ToString (), account.Server); } else if (stored_account != null && (stored_account.Server != account.Server || stored_account.Port != account.Port || stored_account.Type != account.Type || stored_account.Delimiter != account.Delimiter)) { account_list.Remove (stored_account); account_list.Add (account); // Make sure all running indexables are aware of this since it can affect the way they index NotificationEventArgs args; args = new NotificationEventArgs (NotificationType.UpdateAccountInformation, stored_account); args.Data = (object) account; OnNotification (args); Logger.Log.Info ("Updated {0} with new account details", account.Server); } }
// FIXME: This need some more info private Indexable NntpMessageToIndexable (TB.NntpMessage message) { Indexable indexable; indexable = new Indexable (message.Uri); indexable.HitType = "MailMessage"; indexable.MimeType = "message/rfc822"; indexable.Timestamp = DateTime.Parse (message.GetString ("date")).ToUniversalTime (); indexable.AddProperty (Property.NewKeyword ("fixme:client", "thunderbird")); indexable.AddProperty (Property.NewUnsearched ("fixme:fullyIndexed", message.GetBool ("FullIndex"))); indexable.AddProperty (Property.NewDate ("fixme:indexDateTime", DateTime.UtcNow)); string subject = GMime.Utils.HeaderDecodePhrase (message.GetString ("subject")); indexable.AddProperty (Property.New ("dc:title", subject)); return indexable; }
public ThunderbirdIndexableGeneratorAttribute (TB.AccountType type, string description, bool enabled) { this.type = type; this.description = description; this.enabled = enabled; }