Exemple #1
0
 public void StartImport()
 {
     _root = _bookmarkservice.GetProfileRoot(this);
     if (!_root.IsDeleted)
     {
         if (!_importAllowed)
         {
             _root.SetProp(FavoritesPlugin._propInvisible, true);
         }
         else
         {
             _root.DeleteProp(FavoritesPlugin._propInvisible);
             MozillaProfile activeProfile = MozillaProfiles.GetProfile(_profileName);
             if (activeProfile != null)
             {
                 ArrayList   bookmarks  = new ArrayList();
                 IEnumerator enumerator = activeProfile.GetEnumerator();
                 while (enumerator.MoveNext())
                 {
                     object current = enumerator.Current;
                     if (current is string)  // is description of last added bookmark?
                     {
                         if (bookmarks.Count > 0)
                         {
                             ((MozillaBookmark)bookmarks[bookmarks.Count - 1]).Description = current as string;
                         }
                     }
                     else
                     {
                         bookmarks.Add(current);
                     }
                 }
                 int index = 0;
                 CollectBookmarks(
                     _root, (MozillaBookmark[])bookmarks.ToArray(typeof(MozillaBookmark)), ref index, 0);
             }
         }
         FavoritesPlugin._favoritesTreePane.UpdateNodeFilter(false);
     }
 }
Exemple #2
0
        public string GetCookies(string url)
        {
            MozillaProfile activeProfile = MozillaProfiles.GetProfile(_profileName);
            string         cookiesFile   = IOTools.Combine(activeProfile.Path, "cookies.txt");
            DateTime       ftime         = IOTools.GetFileLastWriteTime(cookiesFile);

            if (ftime > _lastCookiesFileTime)
            {
                _cookies.Clear();
                using (StreamReader reader = new StreamReader(cookiesFile))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Length == 0 || line.StartsWith("#"))
                        {
                            continue;
                        }
                        string[] cookieProps = line.Split('\t');
                        if (cookieProps.Length > 6)
                        {
                            string cookie = cookieProps[5] + '=' + cookieProps[6];
                            string domain = cookieProps[0];
                            if (domain.StartsWith("."))
                            {
                                SetUrlCookie(domain.TrimStart('.'), cookieProps[2], cookie);
                                domain = "www" + domain;
                            }
                            SetUrlCookie(domain, cookieProps[2], cookie);
                        }
                    }
                }
                _lastCookiesFileTime = ftime;
            }
            return((string)_cookies[url]);
        }