public Credentials prompt(Host bookmark, String username, String title, String reason, LoginOptions options) { View = ObjectFactory.GetInstance <ILoginView>(); InitEventHandlers(); _bookmark = bookmark; _options = options; View.Title = LocaleFactory.localizedString(title, "Credentials"); View.Message = LocaleFactory.localizedString(reason, "Credentials"); View.Username = _credentials.getUsername(); View.SavePasswordState = _options.save(); View.DiskIcon = IconCache.Instance.IconForName(_options.icon(), 64); InitPrivateKeys(); Update(); AsyncController.AsyncDelegate d = delegate { if (DialogResult.Cancel == View.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } }; _browser.Invoke(d); return(_credentials); }
public override void prompt(Protocol protocol, Credentials credentials, String title, String reason, bool enableKeychain, bool enablePublicKey, bool enableAnonymous) { _protocol = protocol; _credentials = credentials; _enableKeychain = enableKeychain; _enablePublicKey = enablePublicKey; _enableAnonymous = enableAnonymous; _view.Title = Locale.localizedString(title, "Credentials"); _view.Message = Locale.localizedString(reason, "Credentials"); _view.Username = credentials.getUsername(); _view.UsernameLabel = protocol.getUsernamePlaceholder(); _view.PasswordLabel = protocol.getPasswordPlaceholder(); _view.SavePasswordState = Preferences.instance().getBoolean("connection.login.useKeychain") && Preferences.instance().getBoolean("connection.login.addKeychain"); _view.DiskIcon = IconCache.Instance.IconForName(_protocol.disk(), 64); Update(); AsyncController.AsyncDelegate d = delegate { if (DialogResult.Cancel == _view.ShowDialog(_browser.View)) { throw new LoginCanceledException(); } credentials.setUseKeychain(_view.SavePasswordState); credentials.setUsername(Utils.SafeString(_view.Username)); credentials.setPassword(Utils.SafeString(_view.Password)); }; _browser.Invoke(d); }
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); }
public void warn(Host bookmark, String title, String message, String continueButton, String disconnectButton, String preference) { AsyncController.AsyncDelegate d = delegate { _browser.CommandBox(title, title, message, String.Format("{0}|{1}", continueButton, disconnectButton), false, LocaleFactory.localizedString("Don't show again", "Credentials"), 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. }
protected override bool isChangedKeyAccepted(string hostname, int port, string serverHostKeyAlgorithm, byte[] serverHostKey) { AsyncController.AsyncDelegate d = delegate { _parent.CommandBox(String.Format(Locale.localizedString("Host key mismatch for {0}"), hostname), String.Format(Locale.localizedString("Host key mismatch for {0}"), hostname), String.Format(Locale.localizedString("The host key supplied is {0}."), KnownHosts.createHexFingerprint(serverHostKeyAlgorithm, serverHostKey)), String.Format("{0}|{1}", Locale.localizedString("Allow"), Locale.localizedString("Deny")), false, isHostKeyDatabaseWritable() ? Locale.localizedString("Always") : null, SysIcons.Warning, Preferences.instance().getProperty("website.help") + "/" + Protocol.SFTP.getIdentifier(), delegate(int option, bool verificationChecked) { switch (option) { case 0: allow(hostname, serverHostKeyAlgorithm, serverHostKey, verificationChecked); break; case 1: Log.warn("Cannot continue without a valid host key"); throw new ConnectionCanceledException(); } }); }; _parent.Invoke(d, true); return(true); }
public override void finish() { AsyncController.AsyncDelegate mainAction = delegate { _controller.View.StopActivityAnimation(); _controller.UpdateStatusLabel(); }; _controller.Invoke(mainAction); }
public override bool prepare() { AsyncController.AsyncDelegate mainAction = delegate { BrowserController.View.StartActivityAnimation(); BrowserController.UpdateStatusLabel(getActivity()); }; BrowserController.Invoke(mainAction); return(base.prepare()); }
public override void chunk(Path parent, AttributedList list) { if (_supressed) { return; } try { base.chunk(parent, list); } catch (ListCanceledException e) { if (_controller.Visible) { AtomicBoolean c = new AtomicBoolean(true); AsyncController.AsyncDelegate d = delegate { _controller.CommandBox( string.Format(LocaleFactory.localizedString("Listing directory {0}", "Status"), string.Empty), string.Format(LocaleFactory.localizedString("Listing directory {0}", "Status"), string.Empty), string.Format( LocaleFactory.localizedString("Continue listing directory with more than {0} files.", "Alert"), e.getChunk().size()), string.Format("{0}|{1}", LocaleFactory.localizedString("Continue", "Credentials"), LocaleFactory.localizedString("Cancel")), false, LocaleFactory.localizedString("Always"), TaskDialogIcon.Warning, delegate(int option, bool verificationChecked) { if (option == 0) { _supressed = true; } if (option == 1) { c.SetValue(false); } if (verificationChecked) { _supressed = true; disable(); } }); }; _controller.Invoke(d, true); if (!c.Value) { throw e; } } } }
public override void warn(String title, String message, String continueButton, String disconnectButton, String preference) { AsyncController.AsyncDelegate d = delegate { _browser.CommandBox(title, title, message, String.Format("{0}|{1}", continueButton, disconnectButton), false, Locale.localizedString("Don't show again", "Credentials"), SysIcons.Question, Preferences.instance().getProperty( "website.help") + "/" + Protocol.FTP.getIdentifier(), delegate(int option, Boolean verificationChecked) { if (verificationChecked) { // Never show again. Preferences.instance().setProperty (preference, true); } switch (option) { case 1: throw new LoginCanceledException (); } }); }; _browser.Invoke(d); //Proceed nevertheless. }
public SimpleDefaultMainAction(AbstractController controller, AsyncController.AsyncDelegate main) : base(controller) { _background = main; }
public SimpleWindowMainAction(AsyncController.AsyncDelegate main, WindowController c) : base(c) { _main = main; }
public AsyncDelegateBackgroundAction(AsyncController.AsyncDelegate background, AsyncController.AsyncDelegate cleanup) { _background = background; _cleanup = cleanup; }
public override bool prepare() { AsyncController.AsyncDelegate mainAction = () => _controller.View.StartActivityAnimation(); _controller.Invoke(mainAction); return(base.prepare()); }
public void Background(AsyncController.AsyncDelegate del, AsyncController.AsyncDelegate cleanup) { // Move to background thread background(new AsyncDelegateBackgroundAction(del, cleanup)); }