Exemplo n.º 1
0
        internal void View_ChangedServerEvent()
        {
            String input = View.Hostname;

            if (Scheme.isURL(input))
            {
                try
                {
                    Host parsed = HostParser.parse(input);
                    _host.setHostname(parsed.getHostname());
                    _host.setProtocol(parsed.getProtocol());
                    _host.setPort(parsed.getPort());
                    _host.setDefaultPath(parsed.getDefaultPath());
                }
                catch (HostParserException e)
                {
                    Log.warn(e.getDetail());
                }
            }
            else
            {
                _host.setHostname(input);
                _host.setCredentials(CredentialsConfiguratorFactory.get(_host.getProtocol()).configure(_host));
            }

            ItemChanged();
            Update();
            Reachable();
        }
Exemplo n.º 2
0
        public void EdgeCasesShouldWork(string line)
        {
            var hosts = HostParser.Parse(line);

            hosts.Should().HaveCount(1);
            hosts[0].Should().Be("example.com");
        }
Exemplo n.º 3
0
        void ICyberduck.QuickConnect(string arg)
        {
            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);
            }
        }
Exemplo n.º 4
0
        public void EmptyHostListWithCommentsShouldReturnEmpty()
        {
            var hostfile = "";
            var hosts    = HostParser.Parse(hostfile);

            hosts.Should().HaveCount(0);
        }
Exemplo n.º 5
0
        public void HostListShouldReturnAllHostNames()
        {
            var hostfile = string.Join(Environment.NewLine, new[]
            {
                "0.0.0.0 example.com",
                "0.0.0.0 foobar.com",
                "0.0.0.0 blub.com"
            });
            var hosts = HostParser.Parse(hostfile);

            hosts.Should().HaveCount(3);
            hosts.Should().ContainInOrder("example.com", "foobar.com", "blub.com");
        }
Exemplo n.º 6
0
        public void HostListWithIpv6ShouldReturnHostNames()
        {
            var hostfile = string.Join(Environment.NewLine, new[]
            {
                ":: example.com",
                "::1 foobar.com",
                "# comment.com"
            });
            var hosts = HostParser.Parse(hostfile);

            hosts.Should().HaveCount(2);
            hosts.Should().ContainInOrder("example.com", "foobar.com");
        }
Exemplo n.º 7
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());
     }
 }
Exemplo n.º 8
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);
                 }
             }
         }
     }
 }