Exemplo n.º 1
0
        void ICyberduck.RegisterRegistration(string registrationPath)
        {
            Local   f       = LocalFactory.get(registrationPath);
            License license = LicenseFactory.get(f);

            if (license.verify(new DisabledLicenseVerifierCallback()))
            {
                f.copy(LocalFactory.get(SupportDirectoryFinderFactory.get().find(),
                                        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,
                               ProviderHelpServiceFactory.get().help(), delegate { });
            }
        }
Exemplo n.º 2
0
        public void warn(Host bookmark, String title, String message, String continueButton, String disconnectButton,
                         String preference)
        {
            AsyncDelegate d = delegate
            {
                _browser.CommandBox(title, title, message, String.Format("{0}|{1}", continueButton, disconnectButton),
                                    false, Utils.IsNotBlank(preference) ? LocaleFactory.localizedString("Don't show again", "Credentials") : null, TaskDialogIcon.Question,
                                    ProviderHelpServiceFactory.get().help(bookmark.getProtocol().getScheme()),
                                    delegate(int option, Boolean verificationChecked)
                {
                    if (verificationChecked)
                    {
                        // Never show again.
                        PreferencesFactory.get().setProperty(preference, true);
                    }
                    switch (option)
                    {
                    case 1:
                        throw new LoginCanceledException();
                    }
                });
            };

            _browser.Invoke(d);
            //Proceed nevertheless.
        }
Exemplo n.º 3
0
        protected override bool isChangedKeyAccepted(string hostname, PublicKey key)
        {
            AsyncController.AsyncDelegate d = delegate
            {
                _parent.CommandBox(
                    String.Format(LocaleFactory.localizedString("Changed fingerprint", "Sftp"), hostname),
                    String.Format(LocaleFactory.localizedString("Changed fingerprint", "Sftp"), hostname),
                    String.Format(
                        LocaleFactory.localizedString("The fingerprint for the {1} key sent by the server is {0}.",
                                                      "Sftp"), new SSHFingerprintGenerator().fingerprint(key), KeyType.fromKey(key).name()),
                    String.Format("{0}|{1}", LocaleFactory.localizedString("Allow"),
                                  LocaleFactory.localizedString("Deny")), false, LocaleFactory.localizedString("Always"),
                    TaskDialogIcon.Warning,
                    ProviderHelpServiceFactory.get().help(Scheme.sftp),
                    delegate(int option, bool verificationChecked)
                {
                    switch (option)
                    {
                    case 0:
                        allow(hostname, key, verificationChecked);
                        break;

                    case 1:
                        Log.warn("Cannot continue without a valid host key");
                        throw new ConnectionCanceledException();
                    }
                });
            };
            _parent.Invoke(d, true);
            return(true);
        }
Exemplo n.º 4
0
        public bool alert(Host host, BackgroundException failure, StringBuilder log)
        {
            FailureDiagnostics.Type type = _diagnostics.determine(failure);
            if (type == FailureDiagnostics.Type.cancel)
            {
                return(false);
            }
            _notification.alert(host, failure, log);
            bool r = false;

            _controller.Invoke(delegate
            {
                string footer   = ProviderHelpServiceFactory.get().help(host.getProtocol());
                string title    = LocaleFactory.localizedString("Error");
                string message  = failure.getMessage() ?? LocaleFactory.localizedString("Unknown");
                string detail   = failure.getDetail() ?? LocaleFactory.localizedString("Unknown");
                string expanded = log.length() > 0 ? log.toString() : null;
                string commandButtons;
                if (type == FailureDiagnostics.Type.network)
                {
                    commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Try Again", "Alert"),
                                                   LocaleFactory.localizedString("Network Diagnostics", "Alert"));
                }
                else if (type == FailureDiagnostics.Type.quota)
                {
                    commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Try Again", "Alert"),
                                                   LocaleFactory.localizedString("Help", "Main"));
                }
                else
                {
                    commandButtons = String.Format("{0}", LocaleFactory.localizedString("Try Again", "Alert"));
                }
                _controller.WarningBox(title, message, detail, expanded, commandButtons, true, footer,
                                       delegate(int option, bool @checked)
                {
                    switch (option)
                    {
                    case 0:
                        r = true;
                        break;

                    case 1:
                        if (type == FailureDiagnostics.Type.network)
                        {
                            ReachabilityFactory.get().diagnose(host);
                        }
                        if (type == FailureDiagnostics.Type.quota)
                        {
                            BrowserLauncherFactory.get().open(new DefaultProviderHelpService().help(host.getProtocol()));
                        }
                        r = false;
                        break;
                    }
                });
            }, true);
            return(r);
        }
Exemplo n.º 5
0
        public ProfileViewModel(ProfileDescription profile)
        {
            ProfileDescription = profile;
            Profile            = (Profile)profile.getProfile().get();
            Installed          = profile.isInstalled() && Profile.isEnabled();
            IsEnabled          = !(Profile.isBundled() || Utils.ConvertFromJavaList <Host>(BookmarkCollection.defaultCollection()).Any(x => x.getProtocol().Equals(Profile)));

            OpenHelp = ReactiveCommand.Create(() =>
            {
                BrowserLauncherFactory.get().open(ProviderHelpServiceFactory.get().help(Profile));
            });
        }
Exemplo n.º 6
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(new DisabledLicenseVerifierCallback()))
                 {
                     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,
                                    ProviderHelpServiceFactory.get().help(), delegate { });
                 }
             }
             else if ("cyberduckprofile".Equals(f.getExtension()))
             {
                 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(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);
                 }
             }
         }
     }
 }