Example #1
0
 public bool MoveNext()
 {
     _currentProfile = null;
     if (_dirEnumerator != null)
     {
         while (_dirEnumerator.MoveNext())
         {
             _currentProfile = new MozillaProfile(((DirectoryInfo)_dirEnumerator.Current).FullName);
             if (_currentProfile.Name != null)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        public static MozillaProfile GetProfile(string name)
        {
            MozillaProfile profile = SearchForProfile(GetMozillaProfiles(), name);

            if (profile == null)
            {
                profile = SearchForProfile(GetFirefoxProfiles(), name);
                if (profile == null)
                {
                    profile = SearchForProfile(GetFirefox09Profiles(), name);
                    if (profile == null)
                    {
                        profile = SearchForProfile(GetAbsoluteFirefoxProfiles(), name);
                    }
                }
            }
            return(profile);
        }
Example #3
0
            public bool MoveNext()
            {
                string profile = "Profile" + _profileNumber++;

                _profilePath = _profilesIni.ReadString(profile, "Path");
                if (_profilePath == null || _profilePath.Length == 0)
                {
                    return(false);
                }
                if (_profilesIni.ReadBool(profile, "IsRelative", false))
                {
                    return(MoveNext());
                }
                _currentProfile = new MozillaProfile(_profilePath);
                if (_currentProfile.Name == null)
                {
                    return(MoveNext());
                }
                return(true);
            }
Example #4
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);
     }
 }
Example #5
0
        private static string ProfilePath2Name(string profilePath)
        {
            string profileName = (string)_profilePath2Name[profilePath];

            if (profileName == null)
            {
                MozillaProfile profile = new MozillaProfile(profilePath);
                profileName = profile.Name ?? string.Empty;
                string lname = profileName.ToLower();
                if (lname.IndexOf("mozilla") < 0 && lname.IndexOf("firefox") < 0 && lname.IndexOf("phoenix") < 0)
                {
                    profile     = new MozillaProfile(IOTools.GetFullName(IOTools.GetParent(profilePath)));
                    profileName = profile.Name;
                    if (string.IsNullOrEmpty(profileName))
                    {
                        Trace.WriteLine("ProfilePath2Name( " + profilePath + " ) : not found");
                        return(null);
                    }
                }
                _profilePath2Name[profilePath] = profileName;
            }
            Trace.WriteLine("ProfilePath2Name( " + profilePath + " ) : " + profileName);
            return(profileName);
        }
Example #6
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]);
        }