Esempio n. 1
0
        protected override IEnumerable <FacetMoniker> EnumerateIndexImpl()
        {
            var profilesIniDirectory =
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Mozilla\\Firefox";

            var activeProfileDirectory = ProfileManager.GetActiveProfileDirectory(profilesIniDirectory);

            if (activeProfileDirectory == null)
            {
                yield break;
            }

            var placesPath = Path.Combine(activeProfileDirectory, "places.sqlite");

            if (!File.Exists(placesPath))
            {
                yield break;
            }

            using (var copy = new DisposableFileCopy(placesPath))
                using (var conn = new SQLiteConnection("Data Source=" + copy.TempCopyPath))
                {
                    const string cmdText =
                        @"SELECT mp.url, mb.title AS mbtitle, mp.title AS mptitle, mp.visit_count
                        FROM moz_bookmarks AS mb 
                        INNER JOIN moz_places AS mp on mp.id = mb.fk";

                    conn.Open();

                    using (var cmd = new SQLiteCommand(cmdText, conn))
                        foreach (var row in cmd.ExecuteReader().AsEnumerable())
                        {
                            var url = row.ValOrDefault <string>(0);

                            if (url == null)
                            {
                                continue;
                            }

                            var title = row.ValOrDefault(1, url);

                            yield return(new FacetMoniker(GetType(), typeof(UrlFacet), url, title, sourceName: "Firefox Bookmarks", iconPath: null));
                        }
                }
        }
Esempio n. 2
0
        public bool Load()
        {
            var profilesIniDirectory =
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Thunderbird";

            var activeProfileDirectory = ProfileManager.GetActiveProfileDirectory(profilesIniDirectory);

            if (activeProfileDirectory == null)
            {
                return(false);
            }

            var addressBookPath = Path.Combine(activeProfileDirectory, "abook.mab");

            if (!File.Exists(addressBookPath))
            {
                return(false);
            }

            using (var copy = new DisposableFileCopy(addressBookPath))
            {
                var p = new MorkParser();
                p.Open(copy.TempCopyPath);

                FirstNameOid   = p.GetColumnOid("FirstName");
                LastNameOid    = p.GetColumnOid("LastName");
                DisplayNameOid = p.GetColumnOid("DisplayName");
                EmailOid       = p.GetColumnOid("PrimaryEmail");

                _data = new ReadOnlyCollection <ReadOnlyDictionary <int, string> >(
                    (from table in p.GetTables(0x80)
                     from rowScope in table.Value.Select(x => x.Value)
                     from row in p.GetRows(rowScope)
                     select new ReadOnlyDictionary <int, string>(row.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))).ToList());
            }

            return(true);
        }