Пример #1
0
        private bool AskUserReliability(ISSHHostKeyInformationProvider info, string keystr, string message_text_id)
        {
            //比較結果に基づく処理
            IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow;

            Debug.Assert(form.AsForm().InvokeRequired); //別スレッドで実行しているはず

            //fingerprint
            StringBuilder bld = new StringBuilder();

            byte[] fingerprint = info.HostKeyFingerPrint;
            for (int i = 0; i < fingerprint.Length; i++)
            {
                if (bld.Length > 0)
                {
                    bld.Append(':');
                }
                bld.Append(fingerprint[i].ToString("x2"));
            }

            string message = String.Format("ssh hostkey fingerprint {0}\n\n{1}", bld.ToString(), UsabilityPlugin.Strings.GetString(message_text_id));

            if (form.AskUserYesNo(message) == DialogResult.Yes)
            {
                Update(info, keystr, true);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public PrepareCloseResult PrepareCloseSession()
        {
            //閉じるのをキャンセルするテスト
            IPoderosaForm f = _host.GetParentFormFor(_document);
            DialogResult  r = f.AskUserYesNo("Close?");

            return(r == DialogResult.Yes? PrepareCloseResult.TerminateSession : PrepareCloseResult.Cancel);

            //return PrepareCloseResult.TerminateSession;
        }
Пример #3
0
        public PrepareCloseResult PrepareCloseDocument(IPoderosaDocument document)
        {
            Debug.Assert(document == _document);

            //閉じるのをキャンセルするテスト
            IPoderosaForm f = _host.GetParentFormFor(document);
            DialogResult  r = f.AskUserYesNo("Close?");

            return(r == DialogResult.Yes? PrepareCloseResult.ContinueSession : PrepareCloseResult.Cancel);

            //return PrepareCloseResult.TerminateSession;
        }
Пример #4
0
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            IPoderosaView    view;
            ITerminalSession session;

            if (!GetViewAndSession(target, out view, out session))
            {
                return(CommandResult.Ignored);
            }
            var clipboardData = Clipboard.GetDataObject();

            if (!clipboardData.GetDataPresent("Text"))
            {
                return(CommandResult.Ignored);
            }

            string data = clipboardData.GetData("Text") as string;

            if (data == null)
            {
                return(CommandResult.Ignored);
            }

            ITerminalEmulatorOptions options = TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions;

            if (options.AlertOnPasteNewLineChar)
            {
                // Data will be split by CR, LF, CRLF or Environment.NewLine by TextReader.ReadLine,
                // So we check the data about CR, LF and Environment.NewLine.
                if (data.IndexOfAny(new char[] { '\r', '\n' }) >= 0 || data.Contains(Environment.NewLine))
                {
                    IPoderosaForm form = view.ParentForm;
                    if (form != null)
                    {
                        DialogResult res = form.AskUserYesNo(TEnv.Strings.GetString("Message.AskPasteNewLineChar"));
                        if (res != DialogResult.Yes)
                        {
                            return(CommandResult.Ignored);
                        }
                    }
                }
            }

            StringReader         reader = new StringReader(data);
            TerminalTransmission output = session.TerminalTransmission;

            output.SendTextStream(reader, data[data.Length - 1] == '\n');
            return(CommandResult.Succeeded);
        }
Пример #5
0
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            if (!CanExecute(target))
            {
                return(CommandResult.Ignored);
            }
            TerminalTransmission output = GetSession().TerminalTransmission;

            //string data = Clipboard.GetDataObject().GetData("Text") as string;
            string data = Clipboard.GetText();

            if (data == null || data.Length == 0)
            {
                return(CommandResult.Ignored);
            }

            ITerminalEmulatorOptions options = TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions;

            if (options.AlertOnPasteNewLineChar)
            {
                // Data will be split by CR, LF, CRLF or Environment.NewLine by TextReader.ReadLine,
                // So we check the data about CR, LF and Environment.NewLine.
                if (data.IndexOfAny(new char[] { '\r', '\n' }) >= 0 || data.Contains(Environment.NewLine))
                {
                    IPoderosaView view = (IPoderosaView)_control.GetAdapter(typeof(IPoderosaView));
                    IPoderosaForm form = view.ParentForm;
                    if (form != null)
                    {
                        DialogResult res = form.AskUserYesNo(TEnv.Strings.GetString("Message.AskPasteNewLineChar"));
                        if (res != DialogResult.Yes)
                        {
                            return(CommandResult.Ignored);
                        }
                    }
                }
            }

            //TODO 長文のときにダイアログを出して中途キャンセル可能に
            StringReader reader = new StringReader(data);

            output.SendTextStream(reader, data[data.Length - 1] == '\n');
            return(CommandResult.Succeeded);
        }