Exemple #1
0
        void ICyberduck.RegisterBookmark(string bookmarkPath)
        {
            Local f        = LocalFactory.get(bookmarkPath);
            Host  bookmark = (Host)HostReaderFactory.get().read(f);

            if (null == bookmark)
            {
                return;
            }
            NewBrowser().Mount(bookmark);
        }
Exemple #2
0
 private void View_ChangedPrivateKey(object sender, PrivateKeyArgs e, Credentials credentials,
                                     LoginOptions options)
 {
     credentials.setIdentity(null == e.KeyFile ? null : LocalFactory.get(e.KeyFile));
     if (!_keys.Contains(e.KeyFile))
     {
         _keys.Add(e.KeyFile);
         View.PopulatePrivateKeys(_keys);
     }
     Update(credentials, options);
 }
Exemple #3
0
 private void InitPrivateKeys()
 {
     foreach (
         Local key in
         Utils.ConvertFromJavaList <Local>(
             new OpenSSHPrivateKeyConfigurator(
                 LocalFactory.get(PreferencesFactory.get().getProperty("local.user.home"), ".ssh")).list()))
     {
         _keys.Add(key.getAbsolute());
     }
     View.PopulatePrivateKeys(_keys);
 }
Exemple #4
0
        public static IList <KeyValuePair <string, string> > OpenWithListForExtension(String ext)
        {
            IList <String> progs = new List <string>();
            List <KeyValuePair <string, string> > map = new List <KeyValuePair <string, string> >();

            if (IsBlank(ext))
            {
                return(map);
            }

            if (!ext.StartsWith("."))
            {
                ext = "." + ext;
            }
            using (RegistryKey clsExt = Registry.ClassesRoot.OpenSubKey(ext))
            {
                IList <string> rootList = OpenWithListForExtension(ext, clsExt);
                foreach (string s in rootList)
                {
                    progs.Add(s);
                }
            }
            using (
                RegistryKey clsExt =
                    Registry.CurrentUser.OpenSubKey(
                        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\" + ext))
            {
                IList <string> explorerList = OpenWithListForExtension(ext, clsExt);
                foreach (string s in explorerList)
                {
                    progs.Add(s);
                }
            }

            foreach (string exe in progs.Distinct())
            {
                String appName = GetApplicationNameForExe(exe);
                if (null != appName)
                {
                    map.Add(new KeyValuePair <string, string>(appName, exe));
                }
                else
                {
                    map.Add(new KeyValuePair <string, string>(LocalFactory.createLocal(exe).getName(), exe));
                }
            }
            map.Sort(
                delegate(KeyValuePair <string, string> pair1, KeyValuePair <string, string> pair2) { return(pair1.Key.CompareTo(pair2.Key)); });

            return(map);
        }
Exemple #5
0
        void ICyberduck.RegisterBookmark(string bookmarkPath)
        {
            Local f = LocalFactory.get(bookmarkPath);

            try
            {
                Host bookmark = (Host)HostReaderFactory.get().read(f);
                NewBrowser().Mount(bookmark);
            }
            catch (AccessDeniedException ex)
            {
                Logger.error($"Failure reading bookmark from {f}. {ex.getMessage()}");
            }
        }
Exemple #6
0
 void ICyberduck.QuickConnect(string arg)
 {
     try
     {
         Host h = HostParser.parse(arg);
         h.setCredentials(CredentialsConfiguratorFactory.get(h.getProtocol()).configure(h));
         if (AbstractPath.Type.file == _detector.detect(h.getDefaultPath()))
         {
             Path file = new Path(PathNormalizer.normalize(h.getDefaultPath()), EnumSet.of(AbstractPath.Type.file));
             // wait until transferCollection is loaded
             transfersSemaphore.Wait();
             TransferController.Instance.StartTransfer(new DownloadTransfer(h, file,
                                                                            LocalFactory.get(PreferencesFactory.get().getProperty("queue.download.folder"),
                                                                                             file.getName())));
         }
         else
         {
             foreach (BrowserController b in Browsers)
             {
                 if (b.IsMounted())
                 {
                     if (
                         new HostUrlProvider().get(b.Session.getHost())
                         .Equals(new HostUrlProvider().get(h)))
                     {
                         b.View.BringToFront();
                         if (Path.Type.directory == _detector.detect(h.getDefaultPath()))
                         {
                             b.SetWorkdir(new Path(PathNormalizer.normalize(h.getDefaultPath()), EnumSet.of(AbstractPath.Type.directory)));
                         }
                         return;
                     }
                 }
             }
             NewBrowser().Mount(h);
         }
     }
     catch (HostParserException e)
     {
         Logger.warn(e.getDetail());
     }
 }
Exemple #7
0
 /// <summary>
 /// Update this host credentials from the OpenSSH configuration file in ~/.ssh/config
 /// </summary>
 private void ReadOpenSshConfiguration()
 {
     if (_host.getProtocol().equals(Protocol.SFTP))
     {
         OpenSshConfig.Host entry = OpenSshConfig.create().lookup(_host.getHostname());
         if (null != entry.getIdentityFile())
         {
             _host.getCredentials().setIdentity(
                 LocalFactory.createLocal(entry.getIdentityFile().getAbsolutePath()));
         }
         if (Utils.IsNotBlank(entry.getUser()))
         {
             _host.getCredentials().setUsername(entry.getUser());
         }
     }
     else
     {
         _host.getCredentials().setIdentity(null);
     }
 }
Exemple #8
0
        void ICyberduck.RegisterProfile(string profilePath)
        {
            Local    f       = LocalFactory.get(profilePath);
            Protocol profile = (Protocol)ProfileReaderFactory.get().read(f);

            if (null == profile)
            {
                return;
            }
            if (profile.isEnabled())
            {
                ProtocolFactory.get().register(profile);
                Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                NewBrowser().AddBookmark(host);
                // Register in application support
                Local profiles =
                    LocalFactory.get(SupportDirectoryFinderFactory.get().find(),
                                     PreferencesFactory.get().getProperty("profiles.folder.name"));
                profiles.mkdir();
                f.copy(LocalFactory.get(profiles, f.getName()));
            }
        }
Exemple #9
0
 public ch.cyberduck.core.Local find()
 {
     return
         (LocalFactory.get(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                        PreferencesFactory.get().getProperty("application.datafolder.name"))));
 }
 private void View_ChangedPrivateKey(object sender, PrivateKeyArgs e)
 {
     _credentials.setIdentity(null == e.KeyFile ? null : LocalFactory.createLocal(e.KeyFile));
     Update();
 }
Exemple #11
0
 public static void Register()
 {
     LocalFactory.addFactory(ch.cyberduck.core.Factory.NATIVE_PLATFORM, new Factory());
 }
Exemple #12
0
 private void CommandsAfterLaunch(ReadOnlyCollection <string> args)
 {
     if (args.Count > 0)
     {
         string filename = args[0];
         Logger.debug("applicationOpenFile:" + filename);
         Local f = LocalFactory.createLocal(filename);
         if (f.exists())
         {
             if ("cyberducklicense".Equals(f.getExtension()))
             {
                 License license = LicenseFactory.create(f);
                 if (license.verify())
                 {
                     f.copy(
                         LocalFactory.createLocal(
                             Preferences.instance().getProperty("application.support.path"), f.getName()));
                     if (DialogResult.OK == _bc.InfoBox(
                             license.ToString(),
                             Locale.localizedString(
                                 "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                 "License"),
                             Locale.localizedString(
                                 "Your donation key has been copied to the Application Support folder.", "License"),
                             String.Format("{0}", Locale.localizedString("Continue", "License")),
                             null, false))
                     {
                         ;
                     }
                 }
                 else
                 {
                     if (DialogResult.OK == _bc.WarningBox(
                             Locale.localizedString("Not a valid donation key", "License"),
                             Locale.localizedString("Not a valid donation key", "License"),
                             Locale.localizedString("This donation key does not appear to be valid.", "License"),
                             null,
                             String.Format("{0}", Locale.localizedString("Continue", "License")),
                             false, Preferences.instance().getProperty("website.help") + "/faq"))
                     {
                         ;
                     }
                 }
             }
             else if ("cyberduckprofile".Equals(f.getExtension()))
             {
                 Protocol profile = (Protocol)ProtocolReaderFactory.instance().read(f);
                 profile.register();
                 Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                 NewBrowser().AddBookmark(host);
                 // Register in application support
                 Local profiles =
                     LocalFactory.createLocal(Preferences.instance().getProperty("application.support.path"),
                                              "Profiles");
                 profiles.mkdir(true);
                 f.copy(LocalFactory.createLocal(profiles, f.getName()));
             }
             else if ("duck".Equals(f.getExtension()))
             {
                 Host host = (Host)HostReaderFactory.instance().read(f);
                 NewBrowser().Mount(host);
             }
         }
     }
 }
Exemple #13
0
 private void CommandsAfterLaunch(IList <string> args)
 {
     if (args.Count > 0)
     {
         string arg = args[0];
         Logger.debug("applicationOpenFile:" + arg);
         Local f = LocalFactory.get(arg);
         if (f.exists())
         {
             if ("cyberducklicense".Equals(f.getExtension()))
             {
                 License license = LicenseFactory.get(f);
                 if (license.verify())
                 {
                     f.copy(LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                             f.getName()));
                     _bc.InfoBox(license.ToString(),
                                 LocaleFactory.localizedString(
                                     "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                     "License"),
                                 LocaleFactory.localizedString(
                                     "Your registration key has been copied to the Application Support folder.",
                                     "License"),
                                 String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), null, false);
                     foreach (BrowserController controller in new List <BrowserController>(Browsers))
                     {
                         controller.RemoveDonateButton();
                     }
                 }
                 else
                 {
                     _bc.WarningBox(LocaleFactory.localizedString("Not a valid registration key", "License"),
                                    LocaleFactory.localizedString("Not a valid registration key", "License"),
                                    LocaleFactory.localizedString("This registration key does not appear to be valid.",
                                                                  "License"), null,
                                    String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), false,
                                    PreferencesFactory.get().getProperty("website.help") + "/faq", delegate { });
                 }
             }
             else if ("cyberduckprofile".Equals(f.getExtension()))
             {
                 Protocol profile = (Protocol)ProfileReaderFactory.get().read(f);
                 if (null == profile)
                 {
                     return;
                 }
                 if (profile.isEnabled())
                 {
                     ProtocolFactory.register(profile);
                     Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                     NewBrowser().AddBookmark(host);
                     // Register in application support
                     Local profiles =
                         LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                          PreferencesFactory.get().getProperty("profiles.folder.name"));
                     profiles.mkdir();
                     f.copy(LocalFactory.get(profiles, f.getName()));
                 }
             }
             else if ("duck".Equals(f.getExtension()))
             {
                 Host bookmark = (Host)HostReaderFactory.get().read(f);
                 if (null == bookmark)
                 {
                     return;
                 }
                 NewBrowser().Mount(bookmark);
             }
         }
         else
         {
             // it might be an URL
             if (Uri.IsWellFormedUriString(arg, UriKind.Absolute))
             {
                 Host h = HostParser.parse(arg);
                 if (AbstractPath.Type.file == _detector.detect(h.getDefaultPath()))
                 {
                     Path file = new Path(h.getDefaultPath(), EnumSet.of(AbstractPath.Type.file));
                     // wait until transferCollection is loaded
                     transfersSemaphore.Wait();
                     TransferController.Instance.StartTransfer(new DownloadTransfer(h, file,
                                                                                    LocalFactory.get(PreferencesFactory.get().getProperty("queue.download.folder"),
                                                                                                     file.getName())));
                 }
                 else
                 {
                     foreach (BrowserController b in Browsers)
                     {
                         if (b.IsMounted())
                         {
                             if (
                                 new HostUrlProvider().get(b.Session.getHost())
                                 .Equals(new HostUrlProvider().get(h)))
                             {
                                 b.View.BringToFront();
                                 return;
                             }
                         }
                     }
                     NewBrowser().Mount(h);
                 }
             }
         }
     }
 }
 public ch.cyberduck.core.Local find()
 {
     return(LocalFactory.get(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
 }
Exemple #15
0
        /// <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 { });
        }
Exemple #16
0
        private void View_OpenDownloadFolderEvent()
        {
            Local folder = new DownloadDirectoryFinder().find(_host);

            ApplicationLauncherFactory.get().open(LocalFactory.get(folder.getAbsolute()));
        }
Exemple #17
0
 private void View_ChangedBrowserDownloadPathEvent()
 {
     _host.setDownloadFolder(LocalFactory.get(View.SelectedDownloadFolder));
     ItemChanged();
     Update();
 }
Exemple #18
0
 private void Awake()
 {
     btns       = new List <GameButton>();
     btnFactory = new LocalFactory <GameButton>(transform);
 }
Exemple #19
0
        static void Main(string[] args)
        {
            TransporteService transporteService = new TransporteService(TripulanteFactory.Create(),
                                                                        CarroFactory.Create(), LocalFactory.Create());

            Console.WriteLine("Iniciar o transporte? S / N ?");
            if (Console.ReadLine().ToUpper() == "S")
            {
                transporteService.IniciarTransporte();
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Sair!");
            }
        }
 public ReferenceService(LocalFactory factory)
 {
     this.factory = factory;
 }