Пример #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);
     }
 }
Пример #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]);
        }
Пример #3
0
        public void Register()
        {
            _bookmarkService = new BookmarkService();

            RegisterTypes();

            IUIManager uiMgr = Core.UIManager;

            uiMgr.RegisterWizardPane("Import Bookmarks", ImportBookmarksOptionsPane.StartupWizardPaneCreator, 1);
            uiMgr.RegisterOptionsGroup("Internet", "The Internet options enable you to control how [product name] works with several types of online content.");
            OptionsPaneCreator favoritesPaneCreator = FavoritesOptionsPane.FavoritesOptionsPaneCreator;

            uiMgr.RegisterOptionsPane("Internet", "Favorites", favoritesPaneCreator,
                                      "The Favorites options enable you to control how your Internet Explorer Favorites are imported and synchronized with Internet Explorer.");
            ImportBookmarksOptionsPane.AddPane(favoritesPaneCreator);

            if (OperaBookmarkProfile.OperaBookmarksPath().Length > 0)
            {
                OptionsPaneCreator operaPaneCreator = OperaOptionsPane.CreatePane;
                uiMgr.RegisterOptionsPane("Internet", "Opera Bookmarks", operaPaneCreator,
                                          "The Opera Bookmarks options enable you to control how your Opera Bookmarks are imported.");
                ImportBookmarksOptionsPane.AddPane(operaPaneCreator);
            }

            OptionsPaneCreator downloadOptionsPaneCreator = DownloadOptionsPane.DownloadOptionsPaneCreator;

            uiMgr.RegisterOptionsPane("Internet", "Web Pages", downloadOptionsPaneCreator,
                                      "The Web Pages options enable you to control how your bookmarked Web pages are downloaded.");
            IPropTypeCollection propTypes = Core.ResourceStore.PropTypes;
            int sourceId = propTypes["Source"].Id;

            propTypes.RegisterDisplayName(sourceId, "Web Bookmark");
            Core.TabManager.RegisterResourceTypeTab("Web", "Web", new[] { "Weblink", "Folder" }, sourceId, 4);
            uiMgr.RegisterResourceLocationLink("Weblink", _propParent, "Folder");
            uiMgr.RegisterResourceLocationLink("Folder", _propParent, "Folder");
            uiMgr.RegisterResourceSelectPane("Weblink", typeof(ResourceTreeSelectPane));
            Core.WorkspaceManager.RegisterWorkspaceType("Weblink",
                                                        new[] { Core.ResourceStore.PropTypes["Source"].Id }, WorkspaceResourceType.Container);
            Core.WorkspaceManager.RegisterWorkspaceFolderType("Folder", "Weblink", new[] { _propParent });
            IPluginLoader loader = Core.PluginLoader;

            loader.RegisterResourceDisplayer("Weblink", this);
            loader.RegisterStreamProvider("Weblink", this);
            loader.RegisterResourceUIHandler("Folder", this);
            loader.RegisterResourceUIHandler("Weblink", this);
            loader.RegisterResourceTextProvider(null, this);
            _favIconManager = (FavIconManager)Core.GetComponentImplementation(typeof(FavIconManager));

            Image img = Utils.TryGetEmbeddedResourceImageFromAssembly(Assembly.GetExecutingAssembly(), "Favorites.Icons.Favorites24.png");

            _favoritesTreePane = Core.LeftSidebar.RegisterResourceStructureTreePane("Favorites", "Web", "Bookmarks", img, "Weblink");
            _favoritesTreePane.WorkspaceFilterTypes = new[] { "Weblink", "Folder" };
            _favoritesTreePane.EnableDropOnEmpty(this);
            JetResourceTreePane realPane = (JetResourceTreePane)_favoritesTreePane;

            realPane.AddNodeDecorator(new WeblinkNodeDecorator());
            realPane.AddNodeFilter(new BookmarkProfileFilter());
            _favoritesTreePane.ToolTipCallback = DisplayWeblinkError;
            Core.LeftSidebar.RegisterViewPaneShortcut("Favorites", Keys.Control | Keys.Alt | Keys.B);

            Core.ResourceIconManager.RegisterResourceIconProvider("Weblink", this);
            Core.ResourceIconManager.RegisterPropTypeIcon(Core.ResourceStore.PropTypes["Source"].Id, LoadIconFromAssembly("favorites1.ico"));
            _emptyWeblinkIcon = LoadIconFromAssembly("weblink_empty.ico");
            _errorWeblinkIcon = LoadIconFromAssembly("weblink_error.ico");
            WebLinksPaneFilter filter = new WebLinksPaneFilter();

            Core.ResourceBrowser.RegisterLinksPaneFilter("Weblink", filter);
            Core.ResourceBrowser.RegisterLinksPaneFilter("Folder", filter);
            Core.ResourceBrowser.RegisterResourceDisplayForwarder("Weblink", ForwardWeblinkDisplay);
            Core.FilterEngine.RegisterRuleApplicableResourceType("Weblink");

            Core.RemoteControllerManager.AddRemoteCall("Favorites.ExportMozillaBookmarkChanges.1",
                                                       new RemoteExportMozillaBookmarkChangesDelegate(RemoteExportMozillaBookmarkChanges));
            Core.RemoteControllerManager.AddRemoteCall("Favorites.SetMozillaBookmarkId.1",
                                                       new RemoteSetMozillaBookmarkIdDelegate(RemoteSetMozillaBookmarkId));
            Core.RemoteControllerManager.AddRemoteCall("Favorites.RefreshMozillaBookmarks.1",
                                                       new RemoteRefreshBookmarksDelegate(RemoteRefreshBookmarks));
            Core.RemoteControllerManager.AddRemoteCall("Favorites.AnnotateWeblink.1",
                                                       new RemoteAnnotateWeblinkDelegate(RemoteAnnotateWeblink));

            Core.DisplayColumnManager.RegisterDisplayColumn("Weblink", 0,
                                                            new ColumnDescriptor(new[] { "Name", "DisplayName" }, 300, ColumnDescriptorFlags.AutoSize));
            Core.DisplayColumnManager.RegisterDisplayColumn("Weblink", 1, new ColumnDescriptor("LastUpdated", 120));

            /**
             * bookmark profiles
             */
            Core.PluginLoader.RegisterPluginService(_bookmarkService);
            _favoritesProfile = new IEFavoritesBookmarkProfile(_bookmarkService);
            _bookmarkService.RegisterProfile(_favoritesProfile);
            if (OperaBookmarkProfile.OperaBookmarksPath().Length > 0)
            {
                _operaProfile = new OperaBookmarkProfile(_bookmarkService);
                _bookmarkService.RegisterProfile(_operaProfile);
            }
            if (MozillaProfiles.PresentOnComputer)
            {
                OptionsPaneCreator mozillaPaneCreator = MozillaOptionsPane.MozillaOptionsPaneCreator;
                uiMgr.RegisterOptionsPane("Internet", "Mozilla Bookmarks", mozillaPaneCreator,
                                          "The Mozilla Bookmarks options enable you to select Mozilla or Firefox profile which bookmarks are imported.");
                ImportBookmarksOptionsPane.AddPane(mozillaPaneCreator);
                RegisterMozillaProfiles(MozillaProfiles.GetMozillaProfiles());
                RegisterMozillaProfiles(MozillaProfiles.GetFirefoxProfiles());
                RegisterMozillaProfiles(MozillaProfiles.GetFirefox09Profiles());
                RegisterMozillaProfiles(MozillaProfiles.GetAbsoluteFirefoxProfiles());
                MozillaBookmarkProfile.SetImportPropertiesOfProfiles();
            }
        }
Пример #4
0
 public override void ShowPane()
 {
     _profilesList.BeginUpdate();
     try
     {
         IEnumerable firefoxProfiles   = MozillaProfiles.GetFirefoxProfiles();
         IEnumerable firefox09Profiles = MozillaProfiles.GetFirefox09Profiles();
         IEnumerable mozillaProfiles   = MozillaProfiles.GetMozillaProfiles();
         string[]    activeProfiles    = new string[0];
         if (!IsStartupPane)
         {
             _savedProfiles = Core.SettingStore.ReadString("Favorites", "MozillaProfile");
             activeProfiles = _savedProfiles.ToLower().Split(';');
         }
         else
         {
             string activeProfile = null;
             foreach (MozillaProfile profile in firefoxProfiles)
             {
                 string name = profile.Name;
                 if (name.IndexOf("default") >= 0)
                 {
                     activeProfile = name;
                     break;
                 }
             }
             if (activeProfile == null)
             {
                 foreach (MozillaProfile profile in firefox09Profiles)
                 {
                     string name = profile.Name;
                     if (name.IndexOf("default") >= 0)
                     {
                         activeProfile = name;
                         break;
                     }
                 }
                 if (activeProfile == null)
                 {
                     foreach (MozillaProfile profile in firefoxProfiles)
                     {
                         activeProfile = profile.Name;
                         break;
                     }
                     if (activeProfile == null)
                     {
                         foreach (MozillaProfile profile in firefox09Profiles)
                         {
                             activeProfile = profile.Name;
                             break;
                         }
                         if (activeProfile == null)
                         {
                             foreach (MozillaProfile profile in mozillaProfiles)
                             {
                                 string name = profile.Name;
                                 if (name.IndexOf("default") >= 0)
                                 {
                                     activeProfile = name;
                                     break;
                                 }
                             }
                             if (activeProfile == null)
                             {
                                 foreach (MozillaProfile profile in mozillaProfiles)
                                 {
                                     activeProfile = profile.Name;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             if (activeProfile != null)
             {
                 activeProfiles = new string[] { activeProfile.ToLower() };
             }
         }
         UpdateProfileList(activeProfiles, firefoxProfiles);
         UpdateProfileList(activeProfiles, firefox09Profiles);
         UpdateProfileList(activeProfiles, mozillaProfiles);
         UpdateProfileList(activeProfiles, MozillaProfiles.GetAbsoluteFirefoxProfiles());
     }
     finally
     {
         _profilesList.EndUpdate();
     }
 }