private void RefreshJumpList() { InitJumpList(); if (Utils.IsWin7OrLater) { try { Iterator iterator = HistoryCollection.defaultCollection().iterator(); _jumpListManager.ClearAllUserTasks(); while (iterator.hasNext()) { Host host = (Host)iterator.next(); var file = FolderBookmarkCollection.favoritesCollection().getFile(host); if (file.exists()) { bookmarkCategory.AddJumpListItems(new JumpListLink(file.getAbsolute(), BookmarkNameProvider.toString(host)) { IconReference = new IconReference(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cyberduck-application.ico"), 0), }); } } _jumpListManager.Refresh(); } catch (Exception exception) { Logger.warn("Exception while refreshing jump list", exception); } } }
/// <summary> /// Mounts the default bookmark if any /// </summary> /// <param name="controller"></param> public static void OpenDefaultBookmark(BrowserController controller) { String defaultBookmark = PreferencesFactory.get().getProperty("browser.open.bookmark.default"); if (null == defaultBookmark) { return; //No default bookmark given } Host bookmark = FolderBookmarkCollection.favoritesCollection().lookup(defaultBookmark); if (null == bookmark) { Logger.info("Default bookmark no more available"); return; } foreach (BrowserController browser in Browsers) { if (browser.IsMounted()) { if (bookmark.equals(browser.Session.getHost())) { Logger.debug("Default bookmark already mounted"); return; } } } Logger.debug("Mounting default bookmark " + bookmark); controller.Mount(bookmark); }
private void RefreshJumpList() { if (Utils.IsWin7OrLater) { try { _jumpListManager.ClearCustomDestinations(); Iterator iterator = HistoryCollection.defaultCollection().iterator(); while (iterator.hasNext()) { Host host = (Host)iterator.next(); _jumpListManager.AddCustomDestination(new ShellLink { Path = FolderBookmarkCollection.favoritesCollection().getFile(host).getAbsolute(), Title = BookmarkNameProvider.toString(host, true), Category = LocaleFactory.localizedString("History"), IconLocation = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cyberduck-document.ico"), IconIndex = 0 }); } _jumpListManager.Refresh(); } catch (Exception exception) { Logger.warn("Exception while refreshing jump list", exception); } } }
protected override void Invalidate() { _ticklerReachability.Change(Timeout.Infinite, Timeout.Infinite); _ticklerFavicon.Change(Timeout.Infinite, Timeout.Infinite); PreferencesFactory.get().setProperty(ToggleProperty, View.OptionsVisible); FolderBookmarkCollection.favoritesCollection().removeListener(_bookmarkCollectionListener); base.Invalidate(); }
private void InitializeBookmarks(CountdownEvent bookmarksSemaphore) { // Load all bookmarks in background _controller.Background(() => { AbstractHostCollection c = FolderBookmarkCollection.favoritesCollection(); c.load(); bookmarksSemaphore.Signal(); }, () => { if (PreferencesFactory.get().getBoolean("browser.open.untitled")) { if (PreferencesFactory.get().getProperty("browser.open.bookmark.default") != null) { _bc.Invoke(() => { BrowserController bc = NewBrowser(); OpenDefaultBookmark(bc); }); } } }); }
/// <summary> /// A normal (non-single-instance) application raises the Startup event every time it starts. /// A single-instance application raises the Startup event when it starts only if the application /// is not already active; otherwise, it raises the StartupNextInstance event. /// </summary> /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/> /// <param name="sender"></param> /// <param name="e"></param> private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e) { Logger.debug("ApplicationDidFinishLaunching"); CommandsAfterLaunch(CommandLineArgs); UpdateController.Instance.CheckForUpdatesIfNecessary(); if (Preferences.instance().getBoolean("queue.openByDefault")) { TransferController.Instance.View.Show(); } if (Preferences.instance().getBoolean("browser.serialize")) { _bc.Background(delegate { _sessions.load(); }, delegate { foreach ( Host host in _sessions) { NewBrowser().Mount(host); } _sessions.clear(); }); } //Registering for Growl is an expensive operation. Takes up to 500ms on my machine. _bc.Background(delegate { ch.cyberduck.ui.growl.Growl.instance().register(); }, delegate { }); // User bookmarks and thirdparty applications CountdownEvent cde = new CountdownEvent(2); _bc.Background(delegate { BookmarkCollection c = BookmarkCollection.defaultCollection(); c.load(); cde.Signal(); }, delegate { if (Preferences.instance ().getBoolean( "browser.openUntitled")) { if ( Browsers.Count == 0) { OpenDefaultBookmark (NewBrowser()); } } }); _bc.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { }); _bc.Background(delegate { TransferCollection.defaultCollection().load(); }, delegate { }); // Bonjour initialization); if (Preferences.instance().getBoolean("rendezvous.enable")) { try { RendezvousFactory.instance().init(); } catch (COMException) { Logger.warn("No Bonjour support available"); } } if (Preferences.instance().getBoolean("defaulthandler.reminder") && Preferences.instance().getInteger("uses") > 0) { if (!URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForFtp() || !URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForSftp()) { _bc.CommandBox( Locale.localizedString("Default Protocol Handler", "Preferences"), Locale.localizedString("Set Cyberduck as default application for FTP and SFTP locations?", "Configuration"), Locale.localizedString( "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.", "Configuration"), String.Format("{0}|{1}", Locale.localizedString("Change", "Configuration"), Locale.localizedString("Cancel", "Configuration")), false, Locale.localizedString("Don't ask again", "Configuration"), SysIcons.Question, delegate(int option, bool verificationChecked) { if (verificationChecked) { // Never show again. Preferences.instance().setProperty( "defaulthandler.reminder", false); } switch (option) { case 0: URLSchemeHandlerConfiguration.Instance. RegisterFtpProtocol(); URLSchemeHandlerConfiguration.Instance. RegisterSftpProtocol(); break; } }); } } // Import thirdparty bookmarks. IList<ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks(); _bc.Background(delegate { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { if (!Preferences.instance().getBoolean(c.getConfiguration())) { if (!c.isInstalled()) { Logger.info("No application installed for " + c.getBundleIdentifier()); continue; } c.load(); if (c.isEmpty()) { // Flag as imported Preferences.instance().setProperty(c.getConfiguration(), true); } } } }, delegate { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { if (!Preferences.instance().getBoolean(c.getConfiguration())) { if (!c.isEmpty()) { ThirdpartyBookmarkCollection c1 = c; _bc.CommandBox(Locale.localizedString("Import", "Configuration"), String.Format( Locale.localizedString("Import {0} Bookmarks", "Configuration"), c.getName()), String.Format( Locale.localizedString( "{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"), c.size()), String.Format("{0}", Locale.localizedString("Import", "Configuration")), true, Locale.localizedString("Don't ask again", "Configuration"), SysIcons.Question, delegate(int option, bool verificationChecked) { if (verificationChecked) { // Flag as imported Preferences.instance().setProperty( c1.getConfiguration(), true); } switch (option) { case 0: BookmarkCollection.defaultCollection(). addAll(c1); // Flag as imported Preferences.instance().setProperty( c1.getConfiguration(), true); break; } }); } } } cde.Signal(); }); _bc.Background(delegate { cde.Wait(); BookmarkCollection c = BookmarkCollection.defaultCollection(); if (c.isEmpty()) { FolderBookmarkCollection defaults = new FolderBookmarkCollection(LocalFactory.createLocal( Preferences.instance().getProperty("application.bookmarks.path") )); defaults.load(); foreach (Host bookmark in defaults) { if (Logger.isDebugEnabled()) { Logger.debug("Adding default bookmark:" + bookmark); } c.add(bookmark); } } }, delegate { }); }
private void ImportBookmarks(CountdownEvent bookmarksSemaphore, CountdownEvent thirdpartySemaphore) { // Import thirdparty bookmarks. IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks(); _controller.Background(() => { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { if (!c.isInstalled()) { Logger.info("No application installed for " + c.getBundleIdentifier()); continue; } c.load(); if (c.isEmpty()) { if (!PreferencesFactory.get().getBoolean(c.getConfiguration())) { // Flag as imported PreferencesFactory.get().setProperty(c.getConfiguration(), true); } } } bookmarksSemaphore.Wait(); }, () => { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { AbstractHostCollection bookmarks = FolderBookmarkCollection.favoritesCollection(); c.filter(bookmarks); if (!c.isEmpty()) { ThirdpartyBookmarkCollection c1 = c; Core.Utils.CommandBox(LocaleFactory.localizedString("Import", "Configuration"), String.Format(LocaleFactory.localizedString("Import {0} Bookmarks", "Configuration"), c.getName()), String.Format( LocaleFactory.localizedString( "{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"), c.size()), String.Format("{0}", LocaleFactory.localizedString("Import", "Configuration")), true, LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question, (int option, bool verificationChecked) => { if (verificationChecked) { // Flag as imported PreferencesFactory.get().setProperty(c1.getConfiguration(), true); } switch (option) { case 0: FolderBookmarkCollection.favoritesCollection().addAll(c1); // Flag as imported PreferencesFactory.get().setProperty(c1.getConfiguration(), true); break; } }); } else { PreferencesFactory.get().setProperty(c.getConfiguration(), true); } } thirdpartySemaphore.Signal(); }); }
protected virtual void ItemChanged() { FolderBookmarkCollection.favoritesCollection().collectionItemChanged(_host); }
/// <summary> /// A normal (non-single-instance) application raises the Startup event every time it starts. /// A single-instance application raises the Startup event when it starts only if the application /// is not already active; otherwise, it raises the StartupNextInstance event. /// </summary> /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/> /// <param name="sender"></param> /// <param name="e"></param> private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e) { Logger.debug("ApplicationDidFinishLaunching"); CommandsAfterLaunch(CommandLineArgs); UpdateController.Instance.CheckForUpdatesIfNecessary(); if (Preferences.instance().getBoolean("queue.openByDefault")) { TransferController.Instance.View.Show(); } if (Preferences.instance().getBoolean("browser.serialize")) { _bc.Background(delegate { _sessions.load(); }, delegate { foreach ( Host host in _sessions) { NewBrowser().Mount(host); } _sessions.clear(); }); } //Registering for Growl is an expensive operation. Takes up to 500ms on my machine. _bc.Background(delegate { ch.cyberduck.ui.growl.Growl.instance().register(); }, delegate { }); // User bookmarks and thirdparty applications CountdownEvent cde = new CountdownEvent(2); _bc.Background(delegate { BookmarkCollection c = BookmarkCollection.defaultCollection(); c.load(); cde.Signal(); }, delegate { if (Preferences.instance ().getBoolean( "browser.openUntitled")) { if ( Browsers.Count == 0) { OpenDefaultBookmark (NewBrowser()); } } }); _bc.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { }); _bc.Background(delegate { TransferCollection.defaultCollection().load(); }, delegate { }); // Bonjour initialization); if (Preferences.instance().getBoolean("rendezvous.enable")) { try { RendezvousFactory.instance().init(); } catch (COMException) { Logger.warn("No Bonjour support available"); } } if (Preferences.instance().getBoolean("defaulthandler.reminder") && Preferences.instance().getInteger("uses") > 0) { if (!URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForFtp() || !URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForSftp()) { _bc.CommandBox( Locale.localizedString("Default Protocol Handler", "Preferences"), Locale.localizedString("Set Cyberduck as default application for FTP and SFTP locations?", "Configuration"), Locale.localizedString( "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.", "Configuration"), String.Format("{0}|{1}", Locale.localizedString("Change", "Configuration"), Locale.localizedString("Cancel", "Configuration")), false, Locale.localizedString("Don't ask again", "Configuration"), SysIcons.Question, delegate(int option, bool verificationChecked) { if (verificationChecked) { // Never show again. Preferences.instance().setProperty( "defaulthandler.reminder", false); } switch (option) { case 0: URLSchemeHandlerConfiguration.Instance. RegisterFtpProtocol(); URLSchemeHandlerConfiguration.Instance. RegisterSftpProtocol(); break; } }); } } // Import thirdparty bookmarks. IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks(); _bc.Background(delegate { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { if (!Preferences.instance().getBoolean(c.getConfiguration())) { if (!c.isInstalled()) { Logger.info("No application installed for " + c.getBundleIdentifier()); continue; } c.load(); if (c.isEmpty()) { // Flag as imported Preferences.instance().setProperty(c.getConfiguration(), true); } } } }, delegate { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { if (!Preferences.instance().getBoolean(c.getConfiguration())) { if (!c.isEmpty()) { ThirdpartyBookmarkCollection c1 = c; _bc.CommandBox(Locale.localizedString("Import", "Configuration"), String.Format( Locale.localizedString("Import {0} Bookmarks", "Configuration"), c.getName()), String.Format( Locale.localizedString( "{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"), c.size()), String.Format("{0}", Locale.localizedString("Import", "Configuration")), true, Locale.localizedString("Don't ask again", "Configuration"), SysIcons.Question, delegate(int option, bool verificationChecked) { if (verificationChecked) { // Flag as imported Preferences.instance().setProperty( c1.getConfiguration(), true); } switch (option) { case 0: BookmarkCollection.defaultCollection(). addAll(c1); // Flag as imported Preferences.instance().setProperty( c1.getConfiguration(), true); break; } }); } } } cde.Signal(); }); _bc.Background(delegate { cde.Wait(); BookmarkCollection c = BookmarkCollection.defaultCollection(); if (c.isEmpty()) { FolderBookmarkCollection defaults = new FolderBookmarkCollection(LocalFactory.createLocal( Preferences.instance().getProperty("application.bookmarks.path") )); defaults.load(); foreach (Host bookmark in defaults) { if (Logger.isDebugEnabled()) { Logger.debug("Adding default bookmark:" + bookmark); } c.add(bookmark); } } }, delegate { }); }