Пример #1
0
        public ChangeLog(ITerminalSession session)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            StringResource sr = TerminalUIPlugin.Instance.Strings;

            this._logTypeLabel.Text  = sr.GetString("Form.ChangeLog._logTypeLabel");
            this._fileNameLabel.Text = sr.GetString("Form.ChangeLog._fileNameLabel");
            this._cancelButton.Text  = sr.GetString("Common.Cancel");
            this._okButton.Text      = sr.GetString("Common.OK");
            this.Text = sr.GetString("Form.ChangeLog.Text");

            this._logTypeBox.Items.AddRange(EnumListItem <LogType> .GetListItems());

            _session = session;
            ISimpleLogSettings ls = GetSimpleLogSettings();

            if (ls != null)
            {
                _logTypeBox.SelectedItem = ls.LogType;  // select EnumListItem<T> by T
                if (ls.LogType != LogType.None)
                {
                    _fileNameBox.Items.Add(ls.LogPath);
                    _fileNameBox.SelectedIndex = 0;
                }
            }
            else
            {
                _logTypeBox.SelectedItem = LogType.None;    // select EnumListItem<T> by T
            }
            AdjustUI();
        }
Пример #2
0
        //実行するセッションにタスク登録。マクロ実行時に動いていたセッションだけでなく、マクロによって開設されるセッションも同様
        public void AddRuntimeSession(ITerminalSession session)
        {
            ReceptionDataPool pool = new ReceptionDataPool();

            _receptionDataPool.Add(pool);
            session.Terminal.StartModalTerminalTask(pool);
        }
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            if (args.Length != 2)
            {
                StartCommandArgError();
            }
            ITerminalParameter  param      = (ITerminalParameter)args[0].GetAdapter(typeof(ITerminalParameter));
            ITerminalConnection connection = (ITerminalConnection)args[0].GetAdapter(typeof(ITerminalConnection));
            ITerminalSettings   settings   = (ITerminalSettings)args[1].GetAdapter(typeof(ITerminalSettings));

            if ((param == null && connection == null) || settings == null)
            {
                StartCommandArgError();
            }

            ITerminalSession result = null;

            if (connection != null)
            {
                result = StartTerminalSession(target, connection, settings);
            }
            else
            {
                result = StartTerminalSession(target, param, settings);
            }

            return(result != null? CommandResult.Succeeded : CommandResult.Failed);
        }
Пример #4
0
        public ChangeLog(ITerminalSession session)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            StringResource sr = TerminalUIPlugin.Instance.Strings;
            this._logTypeLabel.Text = sr.GetString("Form.ChangeLog._logTypeLabel");
            this._fileNameLabel.Text = sr.GetString("Form.ChangeLog._fileNameLabel");
            this._cancelButton.Text = sr.GetString("Common.Cancel");
            this._okButton.Text = sr.GetString("Common.OK");
            this.Text = sr.GetString("Form.ChangeLog.Text");

            this._logTypeBox.Items.AddRange(EnumListItem<LogType>.GetListItems());

            _session = session;
            ISimpleLogSettings ls = GetSimpleLogSettings();
            if (ls != null) {
                _logTypeBox.SelectedItem = ls.LogType;  // select EnumListItem<T> by T
                if (ls.LogType != LogType.None) {
                    _fileNameBox.Items.Add(ls.LogPath);
                    _fileNameBox.SelectedIndex = 0;
                }
            }
            else
                _logTypeBox.SelectedItem = LogType.None;    // select EnumListItem<T> by T

            AdjustUI();
        }
Пример #5
0
 /// <summary>
 /// Starts benchmark thread int the derived class
 /// </summary>
 protected override void StartBenchmarkThread(ITerminalEmulatorOptions options, ITerminalSession session) {
     _options = options;
     _session = session;
     Thread thread = new Thread(new ThreadStart(BenchmarkThread));
     thread.Name = "Poderosa.Benchmark.DataLoadBenchmark";
     thread.Start();
 }
Пример #6
0
        /// <summary>
        /// Start benchmark
        /// </summary>
        /// <returns></returns>
        public CommandResult Start()
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();

            ITerminalEmulatorService emulatorService =
                BenchmarkPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.terminalemulator", typeof(ITerminalEmulatorService)) as ITerminalEmulatorService;
            ITerminalSessionsService sessionService =
                (ITerminalSessionsService)BenchmarkPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.terminalsessions", typeof(ITerminalSessionsService));

            if (emulatorService == null || sessionService == null)
            {
                return(CommandResult.Ignored);
            }

            ITerminalSettings settings = emulatorService.CreateDefaultTerminalSettings(GetTerminalCaption(), null);

            settings.BeginUpdate();
            settings.Encoding = Poderosa.ConnectionParam.EncodingType.UTF8;
            settings.EndUpdate();
            ITerminalConnection          connection   = GetTerminalConnection();
            ITerminalSessionStartCommand startCommand = sessionService.TerminalSessionStartCommand;
            ITerminalSession             session      = startCommand.StartTerminalSession(_target, connection, settings);

            StartBenchmarkThread(emulatorService.TerminalEmulatorOptions, session);

            return(CommandResult.Succeeded);
        }
Пример #7
0
        public ChangeLog(ITerminalSession session)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            StringResource sr = TerminalUIPlugin.Instance.Strings;

            this._logTypeLabel.Text  = sr.GetString("Form.ChangeLog._logTypeLabel");
            this._fileNameLabel.Text = sr.GetString("Form.ChangeLog._fileNameLabel");
            this._cancelButton.Text  = sr.GetString("Common.Cancel");
            this._okButton.Text      = sr.GetString("Common.OK");
            this.Text = sr.GetString("Form.ChangeLog.Text");

            this._logTypeBox.Items.AddRange(EnumDescAttribute.For(typeof(LogType)).DescriptionCollection());

            _session = session;
            ISimpleLogSettings ls = GetSimpleLogSettings();

            if (ls != null)
            {
                _logTypeBox.SelectedIndex = (int)ls.LogType;
                if (ls.LogType != LogType.None)
                {
                    _fileNameBox.Items.Add(ls.LogPath);
                    _fileNameBox.SelectedIndex = 0;
                }
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }

            AdjustUI();
        }
Пример #8
0
        public CreateTerminalResponse CreateTerminal(CreateTerminalRequest request)
        {
            ITerminalSession terminal = null;

            try
            {
                if (request.SessionType == SessionType.WinPty)
                {
                    terminal = new WinPtySession();
                }
                else if (request.SessionType == SessionType.ConPty)
                {
                    terminal = new ConPtySession();
                }
                terminal.Start(request, this);
            }
            catch (Exception e)
            {
                return(new CreateTerminalResponse {
                    Error = e.ToString()
                });
            }

            terminal.ConnectionClosed += OnTerminalConnectionClosed;
            _terminals.Add(terminal.Id, terminal);
            return(new CreateTerminalResponse
            {
                Success = true,
                Id = terminal.Id,
                ShellExecutableName = terminal.ShellExecutableName
            });
        }
Пример #9
0
        /// <summary>
        /// Starts benchmark thread int the derived class
        /// </summary>
        protected override void StartBenchmarkThread(ITerminalEmulatorOptions options, ITerminalSession session)
        {
            _options = options;
            _session = session;
            Thread thread = new Thread(new ThreadStart(BenchmarkThread));

            thread.Name = "Poderosa.Benchmark.DataLoadBenchmark";
            thread.Start();
        }
Пример #10
0
        private static CommandResult PromptRecogTestCommand(ICommandTarget target)
        {
            ITerminalSession ts = (ITerminalSession)CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target).OwnerSession.GetAdapter(typeof(ITerminalSession));

            Debug.Assert(ts != null);

            new PromptRecognitionTest().Start(ts);
            return(CommandResult.Succeeded);
        }
Пример #11
0
        public CommentLog(ITerminalSession session) {
            InitializeComponent();
            _session = session;

            StringResource sr = TerminalUIPlugin.Instance.Strings;
            this._okButton.Text = sr.GetString("Common.OK");
            this._cancelButton.Text = sr.GetString("Common.Cancel");
            this._insertButton.Text = sr.GetString("Form.CommentLog._insertButton");
            this.Text = sr.GetString("Form.CommentLog.Text");
        }
Пример #12
0
        public static CommandResult OpenShortcutFile(ICommandTarget target, string filename)
        {
            IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target);

            if (window == null)
            {
                window = (IPoderosaMainWindow)CommandTargetUtil.AsViewOrLastActivatedView(target).ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
            }
            if (window == null)
            {
                return(CommandResult.Ignored);
            }

            if (!File.Exists(filename))
            {
                window.Warning(String.Format("{0} is not a file", filename));
                return(CommandResult.Failed);
            }

            ShortcutFileContent f = null;

            try {
                f = ShortcutFileContent.LoadFromXML(filename);
            }
            catch (Exception ex) {
                //変なファイルをドロップしたなどで例外は簡単に起こりうる
                window.Warning(String.Format("Failed to read {0}\n{1}", filename, ex.Message));
                return(CommandResult.Failed);
            }

            try {
                //独立ウィンドウにポップアップさせるようなことは考えていない
                IContentReplaceableView rv = (IContentReplaceableView)target.GetAdapter(typeof(IContentReplaceableView));
                if (rv == null)
                {
                    rv = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
                }

                TerminalControl tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(TerminalControl));
                if (tc != null)   //ターミナルコントロールがないときは無理に設定しにいかない
                {
                    RenderProfile rp = f.TerminalSettings.UsingDefaultRenderProfile ? TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : f.TerminalSettings.RenderProfile;
                    Size          sz = tc.CalcTerminalSize(rp);
                    f.TerminalParameter.SetTerminalSize(sz.Width, sz.Height);
                }

                ITerminalSession s = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(target, f.TerminalParameter, f.TerminalSettings);
                return(s != null ? CommandResult.Succeeded : CommandResult.Failed);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
                return(CommandResult.Failed);
            }
        }
Пример #13
0
        private CommandResult Reproduce(ITerminalSession ts) {
            //TODO SSH2では同一コネクションでもう一本張るショートカット、シリアルでは複製できないことを通知するショートカットがあるが...
            ITerminalParameter param = (ITerminalParameter)ts.TerminalTransmission.Connection.Destination.Clone();
            ISSHLoginParameter ssh = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));
            if (ssh != null)
                ssh.LetUserInputPassword = false;
            ITerminalSettings settings = ts.TerminalSettings.Clone();

            ITerminalSession session = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(ts.OwnerWindow, param, settings);
            return session != null ? CommandResult.Succeeded : CommandResult.Failed;
        }
Пример #14
0
 private void InitReceptionPool()
 {
     foreach (ISession session in MacroPlugin.Instance.SessionManager.AllSessions)
     {
         ITerminalSession ts = (ITerminalSession)session.GetAdapter(typeof(ITerminalSession));
         if (ts != null)
         {
             AddRuntimeSession(ts);
         }
     }
 }
 /// <summary>
 /// ターミナルセッションInvoke
 /// </summary>
 /// <param name="tp">ターミナルパラメータ</param>
 /// <param name="ts">ターミナルセッティング</param>
 private static ITerminalSession InvokeOpenSessionOrNull(ITerminalParameter tp, ITerminalSettings ts)
 {
     try {
         ITerminalSessionsService ss         = ConnectProfilePlugin.Instance.TerminalSessionsService;
         ITerminalSession         newsession = ss.TerminalSessionStartCommand.StartTerminalSession(ConnectProfilePlugin.Instance.WindowManager.ActiveWindow, tp, ts);
         return((newsession == null) ? null : newsession);
     } catch (Exception ex) {
         Poderosa.RuntimeUtil.ReportException(ex);
         return(null);
     }
 }
Пример #16
0
        //送信可能状態であるときのみTerminalSessionを返す
        private ITerminalSession GetSession()
        {
            if (!_control.EnabledEx)
            {
                return(null);
            }

            IPoderosaView    view = (IPoderosaView)_control.GetAdapter(typeof(IPoderosaView));
            ITerminalSession s    = (ITerminalSession)view.Document.OwnerSession.GetAdapter(typeof(ITerminalSession));

            return(s.TerminalConnection.IsClosed ? null : s);
        }
Пример #17
0
        public CommentLog(ITerminalSession session)
        {
            InitializeComponent();
            _session = session;

            StringResource sr = TerminalUIPlugin.Instance.Strings;

            this._okButton.Text     = sr.GetString("Common.OK");
            this._cancelButton.Text = sr.GetString("Common.Cancel");
            this._insertButton.Text = sr.GetString("Form.CommentLog._insertButton");
            this.Text = sr.GetString("Form.CommentLog.Text");
        }
Пример #18
0
        public void Start(ITerminalSession session) {
            _session = session;
            _output = session.TerminalTransmission;
            _consoleFlag = true;

            _session.Terminal.PromptRecognizer.AddListener(this);
            //Test Body
            Test1();
            Test2();
            Test3();

            _session.Terminal.PromptRecognizer.RemoveListener(this);
        }
Пример #19
0
        public CreateTerminalResponse CreateTerminal(CreateTerminalRequest request)
        {
            if (_terminals.ContainsKey(request.Id))
            {
                // App terminated without cleaning up, removing orphaned sessions
                foreach (var item in _terminals.Values)
                {
                    item.Dispose();
                }
                _terminals.Clear();
            }

            string error = request.Profile?.CheckIfMosh();

            if (!string.IsNullOrEmpty(error))
            {
                return(new CreateTerminalResponse
                {
                    Error = error, ShellExecutableName = request.Profile.Location, Success = false
                });
            }

            ITerminalSession terminal = null;

            try
            {
                if (request.SessionType == SessionType.WinPty)
                {
                    terminal = new WinPtySession();
                }
                else if (request.SessionType == SessionType.ConPty)
                {
                    terminal = new ConPtySession();
                }
                terminal.Start(request, this);
            }
            catch (Exception e)
            {
                return(new CreateTerminalResponse {
                    Error = e.ToString()
                });
            }

            terminal.ConnectionClosed += OnTerminalConnectionClosed;
            _terminals.Add(terminal.Id, terminal);
            return(new CreateTerminalResponse
            {
                Success = true,
                ShellExecutableName = terminal.ShellExecutableName
            });
        }
        public CreateTerminalResponse CreateTerminal(CreateTerminalRequest request)
        {
            if (_terminals.ContainsKey(request.Id))
            {
                // App terminated without cleaning up, removing orphaned sessions
                foreach (var item in _terminals.Values)
                {
                    item.Session.Dispose();
                }
                _terminals.Clear();
            }

            request.Profile.Location = Utilities.ResolveLocation(request.Profile.Location);

            ITerminalSession terminal = null;

            try
            {
                if (request.SessionType == SessionType.WinPty)
                {
                    terminal = new WinPtySession();
                }
                else
                {
                    terminal = new ConPtySession();
                }
                terminal.Start(request, this);
            }
            catch (Exception e)
            {
                return(new CreateTerminalResponse {
                    Error = e.ToString()
                });
            }

            var name = string.IsNullOrEmpty(request.Profile.Name) ? terminal.ShellExecutableName : request.Profile.Name;

            terminal.ConnectionClosed += OnTerminalConnectionClosed;
            _terminals.Add(terminal.Id, new TerminalSessionInfo
            {
                ProfileName = name,
                StartTime   = DateTime.Now,
                Session     = terminal
            });
            return(new CreateTerminalResponse
            {
                Success = true,
                Name = name
            });
        }
Пример #21
0
        public void Start(ITerminalSession session)
        {
            _session     = session;
            _output      = session.TerminalTransmission;
            _consoleFlag = true;

            _session.Terminal.PromptRecognizer.AddListener(this);
            //Test Body
            Test1();
            Test2();
            Test3();

            _session.Terminal.PromptRecognizer.RemoveListener(this);
        }
Пример #22
0
        private CommandResult ConnectAgain(ITerminalSession ts0) {
            TerminalSession ts = (TerminalSession)ts0.GetAdapter(typeof(TerminalSession));
            ITerminalParameter param = (ITerminalParameter)ts.TerminalTransmission.Connection.Destination.Clone();
            ISSHLoginParameter ssh = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));
            if (ssh != null)
                ssh.LetUserInputPassword = false;

            ITerminalConnection connection = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.OpenConnection(ts.OwnerWindow, param, ts.TerminalSettings);
            if (connection == null)
                return CommandResult.Failed;

            ts.Revive(connection); //接続を復活
            return CommandResult.Succeeded;
        }
Пример #23
0
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            Debug.Assert(args != null && args.Length == 1);
            MRUItem item = (MRUItem)args[0].GetAdapter(typeof(MRUItem));

            //コマンド実行時点でIsolateする。
            //なぜなら、TerminalSettingsはSessionごとにコピーを持たないといけない(セッション間の共有はNG)し、
            //しかしSettingを接続後に変更したらそれは保存するMRUに反映したい。
            //結果として、同じMRUItemを複数回インスタンシエートしたら、最後に開いた接続のTerminalSettingsがMRUデータとして保存される。
            item.IsolateSettings();
            ITerminalSession ts = MRUPlugin.Instance.TerminalSessionsService.TerminalSessionStartCommand.StartTerminalSession(target, item.TerminalParameter, item.TerminalSettings);

            return(ts != null ? CommandResult.Succeeded : CommandResult.Failed);
        }
Пример #24
0
        /// <summary>
        /// アクティブセッション追加コマンド
        /// </summary>
        /// <param name="target">CommandTarget</param>
        private static CommandResult AddConnectProfile(ICommandTarget target)
        {
            IPoderosaDocument document = CommandTargetUtil.AsDocumentOrViewOrLastActivatedDocument(target);

            if (document != null)
            {
                ITerminalSession ts = (ITerminalSession)document.OwnerSession.GetAdapter(typeof(ITerminalSession));
                if (ts != null)
                {
                    Commands _cmd = new Commands();
                    _cmd.NewProfileCurrentSessionCommand(ts);
                    return(CommandResult.Succeeded);
                }
            }
            return(CommandResult.Cancelled);
        }
Пример #25
0
        private CommandResult Reproduce(ITerminalSession ts)
        {
            //TODO SSH2では同一コネクションでもう一本張るショートカット、シリアルでは複製できないことを通知するショートカットがあるが...
            ITerminalParameter param = (ITerminalParameter)ts.TerminalTransmission.Connection.Destination.Clone();
            ISSHLoginParameter ssh   = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));

            if (ssh != null)
            {
                ssh.LetUserInputPassword = false;
            }
            ITerminalSettings settings = ts.TerminalSettings.Clone();

            ITerminalSession session = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(ts.OwnerWindow, param, settings);

            return(session != null ? CommandResult.Succeeded : CommandResult.Failed);
        }
Пример #26
0
        /// <summary>
        /// 選択済セッション取得
        /// </summary>
        private string GetSelectedSessionList()
        {
            string Str = "";

            _selectSessions.Clear();
            foreach (ListViewItem li in _sessionListView.CheckedItems)
            {
                IPoderosaDocument doc = li.Tag as IPoderosaDocument;
                ITerminalSession  ts  = (ITerminalSession)doc.OwnerSession.GetAdapter(typeof(ITerminalSession));
                if (ts != null)
                {
                    _selectSessions.Add(ts);
                    Str += ts.Caption + " ";
                }
            }
            return(Str.Trim());
        }
Пример #27
0
        public ConnectionParameterCollectionImpl(ITerminalSession session)
        {
            if (session != null && session.TerminalConnection != null)
            {
                termialParameter = session.TerminalConnection.Destination;
            }
            else
            {
                termialParameter = null;
            }

            if (session != null)
            {
                termialSettings = session.TerminalSettings;
            }
            else
            {
                termialSettings = null;
            }

            List <string> names = new List <string>();

            foreach (object obj in new object[] { termialParameter, termialSettings })
            {
                if (obj != null)
                {
                    foreach (PropertyInfo prop in obj.GetType().GetProperties(PROPERTY_BINDING_FLAGS))
                    {
                        if (!prop.CanRead || prop.GetIndexParameters().Length > 0)
                        {
                            continue;
                        }
                        object[] attribs = prop.GetCustomAttributes(typeof(MacroConnectionParameterAttribute), true);
                        if (attribs.Length > 0)
                        {
                            names.Add(prop.Name);
                        }
                    }
                }
            }

            names.Sort();
            names.TrimExcess();
            paramNames = names;
        }
Пример #28
0
        private static ITerminalSession OpenSessionOrNull(ITerminalParameter tp, ITerminalSettings ts)
        {
            try {
                ITerminalSessionsService ss         = MacroPlugin.Instance.TerminalSessionsService;
                ITerminalSession         newsession = ss.TerminalSessionStartCommand.StartTerminalSession(MacroPlugin.Instance.WindowManager.ActiveWindow, tp, ts);
                if (newsession == null)
                {
                    return(null);
                }

                MacroPlugin.Instance.MacroManager.CurrentExecutor.AddRuntimeSession(newsession);
                return(newsession);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
                return(null);
            }
        }
Пример #29
0
        public void OnSessionStart(ISession session)
        {
            ITerminalSession ts = (ITerminalSession)session.GetAdapter(typeof(ITerminalSession));

            if (ts == null ||
                HasExcludeFromMRUAttribute(ts) ||
                HasExcludeFromMRUAttribute(ts.TerminalTransmission.Connection.Destination))
            {
                return;
            }

            _data.Update(new MRUItem(ts));
            int limit = MRUPlugin.Instance.OptionSupplier.OriginalOptions.LimitCount;

            _data.LimitCount(limit);

            ////VolatileにするかわりにReloadスタイル
            //MRUPlugin.Instance.WindowManager.ReloadMenu("org.poderosa.menu.file");
        }
Пример #30
0
        private static CommandResult CmdCommentLog(ICommandTarget target)
        {
            ITerminalSession s = AsTerminalSession(target);

            if (s == null)
            {
                return(CommandResult.Ignored);
            }
            CommentLog dlg = new CommentLog(s);

            if (dlg.ShowDialog(s.OwnerWindow.AsForm()) == DialogResult.OK)
            {
                return(CommandResult.Succeeded);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
Пример #31
0
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            ITerminalSession ts = AsTerminalSession(target);

            if (ts == null)
            {
                return(CommandResult.Failed);
            }

            //閉じてるかどうかで再接続か複製
            if (ts.TerminalTransmission.Connection.IsClosed)
            {
                return(ConnectAgain(ts));
            }
            else
            {
                return(Reproduce(ts));
            }
        }
Пример #32
0
        private CommandResult ConnectAgain(ITerminalSession ts0)
        {
            TerminalSession    ts    = (TerminalSession)ts0.GetAdapter(typeof(TerminalSession));
            ITerminalParameter param = (ITerminalParameter)ts.TerminalTransmission.Connection.Destination.Clone();
            ISSHLoginParameter ssh   = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));

            if (ssh != null)
            {
                ssh.LetUserInputPassword = false;
            }

            ITerminalConnection connection = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.OpenConnection(ts.OwnerWindow, param, ts.TerminalSettings);

            if (connection == null)
            {
                return(CommandResult.Failed);
            }

            ts.Revive(connection); //接続を復活
            return(CommandResult.Succeeded);
        }
        private static CommandResult CmdEditRenderProfile(ICommandTarget target)
        {
            ITerminalSession s = AsTerminalSession(target);

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

            using (EditRenderProfile dlg = new EditRenderProfile(s.TerminalSettings.RenderProfile))
                if (dlg.ShowDialog(s.OwnerWindow.AsForm()) == DialogResult.OK)
                {
                    s.TerminalSettings.BeginUpdate();
                    s.TerminalSettings.RenderProfile = (View.RenderProfile)dlg.Result.Clone();
                    s.TerminalSettings.EndUpdate();
                    return(CommandResult.Succeeded);
                }
                else
                {
                    return(CommandResult.Cancelled);
                }
        }
Пример #34
0
        private static CommandResult CmdRenameTab(ICommandTarget target)
        {
            ITerminalSession s = AsTerminalSession(target);

            if (s == null)
            {
                return(CommandResult.Ignored);
            }
            RenameTabBox dlg = new RenameTabBox();

            dlg.Content = s.TerminalSettings.Caption;
            if (dlg.ShowDialog(s.OwnerWindow.AsForm()) == DialogResult.OK)
            {
                s.TerminalSettings.BeginUpdate();
                s.TerminalSettings.Caption = dlg.Content;
                s.TerminalSettings.EndUpdate();
                return(CommandResult.Succeeded);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
        /// <summary>
        /// 接続
        /// </summary>
        public void Connect()
        {
            ITCPParameter tcp = null;

            // プロトコル
            if (_prof.Protocol == ConnectionMethod.Telnet) {
                // Telnet
                tcp = ConnectProfilePlugin.Instance.ProtocolService.CreateDefaultTelnetParameter();
                tcp.Destination = _prof.HostName;
                tcp.Port = _prof.Port;
                ITelnetParameter telnetParameter = null;
                telnetParameter = (ITelnetParameter)tcp.GetAdapter(typeof(ITelnetParameter));
                if (telnetParameter != null) telnetParameter.TelnetNewLine = _prof.TelnetNewLine;
            } else if ((_prof.Protocol == ConnectionMethod.SSH1) || (_prof.Protocol == ConnectionMethod.SSH2)) {
                // SSH
                ISSHLoginParameter ssh = ConnectProfilePlugin.Instance.ProtocolService.CreateDefaultSSHParameter();
                tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));
                tcp.Destination = _prof.HostName;
                tcp.Port = _prof.Port;
                ssh.Method = (_prof.Protocol == ConnectionMethod.SSH1) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
                ssh.Account = _prof.UserName;
                ssh.AuthenticationType = ConvertAuth(_prof.AuthType);
                ssh.PasswordOrPassphrase = _prof.Password;
                ssh.IdentityFileName = _prof.KeyFile;
                ssh.LetUserInputPassword = (_prof.AutoLogin == true) ? false : true;
            }

            // TerminalSettings(表示プロファイル/改行コード/文字コード)
            ITerminalSettings terminalSettings = ConnectProfilePlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings(_prof.HostName, null);
            terminalSettings.BeginUpdate();
            terminalSettings.RenderProfile = _prof.RenderProfile;
            terminalSettings.TransmitNL = _prof.NewLine;
            terminalSettings.Encoding = _prof.CharCode;
            terminalSettings.LocalEcho = false;
            terminalSettings.EndUpdate();

            // TerminalParameter
            ITerminalParameter terminalParam = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter));

            // ターミナルサイズ(これを行わないとPoderosa起動直後のOnReceptionが何故か機能しない, 行わない場合は2回目以降の接続時は正常)
            IViewManager viewManager = CommandTargetUtil.AsWindow(ConnectProfilePlugin.Instance.WindowManager.ActiveWindow).ViewManager;
            IContentReplaceableView contentReplaceableView = (IContentReplaceableView)viewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
            TerminalControl terminalControl = (TerminalControl)contentReplaceableView.GetCurrentContent().GetAdapter(typeof(TerminalControl));
            if (terminalControl != null) {
                Size size = terminalControl.CalcTerminalSize(terminalSettings.RenderProfile);
                terminalParam.SetTerminalSize(size.Width, size.Height);
            }

            // 接続(セッションオープン)
            _terminalSession = (ITerminalSession)ConnectProfilePlugin.Instance.WindowManager.ActiveWindow.AsForm().Invoke(new OpenSessionDelegate(InvokeOpenSessionOrNull), terminalParam, terminalSettings);

            // 自動ログイン/SU/実行コマンド
            if (_terminalSession != null) {
                // 受信データオブジェクト作成(ユーザからのキーボード入力が不可)
                ReceptionData pool = new ReceptionData();
                _terminalSession.Terminal.StartModalTerminalTask(pool);

                // Telnet自動ログイン
                if ((_prof.AutoLogin == true) && (_prof.Protocol == ConnectionMethod.Telnet)) {
                    if (TelnetAutoLogin() != true) return;
                }

                // SU
                if ((_prof.AutoLogin == true) && (_prof.SUUserName != "")) {
                    if (SUSwitch() != true) return;
                }

                // 実行コマンド
                if ((_prof.AutoLogin == true) && (_prof.ExecCommand != "")) {
                    if (ExecCommand() != true) return;
                }

                // 受信データオブジェクト定義解除(ユーザからのキーボード入力を許可)
                _terminalSession.Terminal.EndModalTerminalTask();
            }
        }
        /// <summary>
        /// カレントセッションプロファイルを新規作成
        /// </summary>
        /// <param name="ts">ターミナルセッション</param>
        public void NewProfileCurrentSessionCommand(ITerminalSession ts)
        {
            ISSHLoginParameter ssh = (ISSHLoginParameter)ts.TerminalConnection.Destination.GetAdapter(typeof(ISSHLoginParameter));
            ITelnetParameter telnet = (ITelnetParameter)ts.TerminalConnection.Destination.GetAdapter(typeof(ITelnetParameter));
            ITCPParameter tcp = null;
            ConnectProfileStruct prof = new ConnectProfileStruct();

            // プロトコルチェック
            if (telnet != null) {
                // Telnet
                tcp = (ITCPParameter)ts.TerminalConnection.Destination.GetAdapter(typeof(ITCPParameter));
                prof.Protocol = ConnectionMethod.Telnet;
                prof.HostName = tcp.Destination;
                prof.Port = tcp.Port;
                prof.TelnetNewLine = telnet.TelnetNewLine;
            } else {
                // SSH
                tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));
                prof.HostName = tcp.Destination;
                prof.Port = tcp.Port;
                prof.UserName = ssh.Account;
                prof.Password = ssh.PasswordOrPassphrase;
                prof.KeyFile = ssh.IdentityFileName;
                prof.AutoLogin = true;
                if (ssh.Method.ToString() == "SSH1") { prof.Protocol = ConnectionMethod.SSH1; }
                else if (ssh.Method.ToString() == "SSH2") { prof.Protocol = ConnectionMethod.SSH2; }
                if (ssh.AuthenticationType.ToString() == "Password") { prof.AuthType = AuthType.Password; }
                else if (ssh.AuthenticationType.ToString() == "PublicKey") { prof.AuthType = AuthType.PublicKey; }
                else if (ssh.AuthenticationType.ToString() == "KeyboardInteractive") { prof.AuthType = AuthType.KeyboardInteractive; }
            }

            // その他設定
            prof.CharCode = ts.TerminalSettings.Encoding;
            prof.NewLine = ts.TerminalSettings.TransmitNL;
            prof.TerminalType = ts.TerminalSettings.TerminalType;
            if (ts.TerminalSettings.RenderProfile == null) {
                prof.RenderProfile = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
                prof.RenderProfile.ESColorSet = new EscapesequenceColorSet();
                prof.RenderProfile.ESColorSet.ResetToDefault();
            } else {
                prof.RenderProfile = ts.TerminalSettings.RenderProfile;
            }
            prof.CommandSendInterval = ConnectProfileStruct.DEFAULT_CMD_SEND_INTERVAL;
            prof.PromptRecvTimeout = ConnectProfileStruct.DEFAULT_PROMPT_RECV_TIMEOUT;
            prof.ProfileItemColor = System.Drawing.Color.Black;

            // ウィンドウ表示/プロファイル追加
            ProfileEditForm dlg = new ProfileEditForm(prof);
            if (dlg.ShowDialog() == DialogResult.OK) {
                AddProfileCommand(ConnectProfilePlugin.Profiles, dlg.ResultProfile);
            }
        }
Пример #37
0
 /// <summary>
 /// <ja>GetViewAndSession</ja>
 /// </summary>
 private bool GetViewAndSession(ICommandTarget target, out IPoderosaView view, out ITerminalSession session)
 {
     view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
     if ((view != null) && (view.Document != null)) {
         session = (ITerminalSession)view.Document.OwnerSession.GetAdapter(typeof(ITerminalSession));
         if (!session.TerminalConnection.IsClosed) return true;
     } else {
         session = null;
     }
     return false;
 }
Пример #38
0
        private StructuredText _lateBindContent; //これがnullでないときは遅延ロードの必要あり

        public MRUItem(ITerminalSession ts) {
            _terminalParam = ts.TerminalTransmission.Connection.Destination;
            _terminalSettings = ts.TerminalSettings;
            _lateBindContent = null;
        }
Пример #39
0
 public Action(ITerminalSession target, string command, MainThreadAction ma)
 {
     _target = target;
     _command = command;
     _mainThreadAction = ma;
 }
Пример #40
0
 public ConnectionImpl(ITerminalSession ts) {
     _session = ts;
     _connectionParameters = null;
 }
Пример #41
0
        public ConnectionParameterCollectionImpl(ITerminalSession session) {
            if (session != null && session.TerminalConnection != null)
                termialParameter = session.TerminalConnection.Destination;
            else
                termialParameter = null;

            if (session != null)
                termialSettings = session.TerminalSettings;
            else
                termialSettings = null;

            List<string> names = new List<string>();
            foreach (object obj in new object[] { termialParameter, termialSettings }) {
                if (obj != null) {
                    foreach (PropertyInfo prop in obj.GetType().GetProperties(PROPERTY_BINDING_FLAGS)) {
                        if (!prop.CanRead || prop.GetIndexParameters().Length > 0)
                            continue;
                        object[] attribs = prop.GetCustomAttributes(typeof(MacroConnectionParameterAttribute), true);
                        if (attribs.Length > 0)
                            names.Add(prop.Name);
                    }
                }
            }

            names.Sort();
            names.TrimExcess();
            paramNames = names;
        }
        /// <summary>
        /// カレントセッションプロファイルを新規作成
        /// </summary>
        /// <param name="ts">ターミナルセッション</param>
        public void NewProfileCurrentSessionCommand(ITerminalSession ts)
        {
            ISSHLoginParameter   ssh    = (ISSHLoginParameter)ts.TerminalConnection.Destination.GetAdapter(typeof(ISSHLoginParameter));
            ITelnetParameter     telnet = (ITelnetParameter)ts.TerminalConnection.Destination.GetAdapter(typeof(ITelnetParameter));
            ITCPParameter        tcp    = null;
            ConnectProfileStruct prof   = new ConnectProfileStruct();

            // プロトコルチェック
            if (telnet != null)
            {
                // Telnet
                tcp                = (ITCPParameter)ts.TerminalConnection.Destination.GetAdapter(typeof(ITCPParameter));
                prof.Protocol      = ConnectionMethod.Telnet;
                prof.HostName      = tcp.Destination;
                prof.Port          = tcp.Port;
                prof.TelnetNewLine = telnet.TelnetNewLine;
            }
            else
            {
                // SSH
                tcp            = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));
                prof.HostName  = tcp.Destination;
                prof.Port      = tcp.Port;
                prof.UserName  = ssh.Account;
                prof.Password  = ssh.PasswordOrPassphrase;
                prof.KeyFile   = ssh.IdentityFileName;
                prof.AutoLogin = true;
                if (ssh.Method.ToString() == "SSH1")
                {
                    prof.Protocol = ConnectionMethod.SSH1;
                }
                else if (ssh.Method.ToString() == "SSH2")
                {
                    prof.Protocol = ConnectionMethod.SSH2;
                }
                if (ssh.AuthenticationType.ToString() == "Password")
                {
                    prof.AuthType = AuthType.Password;
                }
                else if (ssh.AuthenticationType.ToString() == "PublicKey")
                {
                    prof.AuthType = AuthType.PublicKey;
                }
                else if (ssh.AuthenticationType.ToString() == "KeyboardInteractive")
                {
                    prof.AuthType = AuthType.KeyboardInteractive;
                }
            }

            // その他設定
            prof.CharCode     = ts.TerminalSettings.Encoding;
            prof.NewLine      = ts.TerminalSettings.TransmitNL;
            prof.TerminalType = ts.TerminalSettings.TerminalType;
            if (ts.TerminalSettings.RenderProfile == null)
            {
                prof.RenderProfile            = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
                prof.RenderProfile.ESColorSet = new EscapesequenceColorSet();
                prof.RenderProfile.ESColorSet.ResetToDefault();
            }
            else
            {
                prof.RenderProfile = ts.TerminalSettings.RenderProfile;
            }
            prof.CommandSendInterval = ConnectProfileStruct.DEFAULT_CMD_SEND_INTERVAL;
            prof.PromptRecvTimeout   = ConnectProfileStruct.DEFAULT_PROMPT_RECV_TIMEOUT;
            prof.ProfileItemColor    = System.Drawing.Color.Black;

            // ウィンドウ表示/プロファイル追加
            ProfileEditForm dlg = new ProfileEditForm(prof);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                AddProfileCommand(ConnectProfilePlugin.Profiles, dlg.ResultProfile);
            }
        }
Пример #43
0
 /// <summary>
 /// Starts benchmark thread in the derived class
 /// </summary>
 protected abstract void StartBenchmarkThread(ITerminalEmulatorOptions options, ITerminalSession session);
Пример #44
0
 public Action(ITerminalSession target, string command, ReceiverThreadAction ra)
 {
     _target = target;
     _command = command;
     _receiverThreadAction = ra;
 }
Пример #45
0
 //実行するセッションにタスク登録。マクロ実行時に動いていたセッションだけでなく、マクロによって開設されるセッションも同様
 public void AddRuntimeSession(ITerminalSession session)
 {
     ReceptionDataPool pool = new ReceptionDataPool();
     _receptionDataPool.Add(pool);
     session.Terminal.StartModalTerminalTask(pool);
 }
        /// <summary>
        /// 接続
        /// </summary>
        public void Connect()
        {
            ITCPParameter tcp = null;

            // プロトコル
            if (_prof.Protocol == ConnectionMethod.Telnet)
            {
                // Telnet
                tcp             = ConnectProfilePlugin.Instance.ProtocolService.CreateDefaultTelnetParameter();
                tcp.Destination = _prof.HostName;
                tcp.Port        = _prof.Port;
                ITelnetParameter telnetParameter = null;
                telnetParameter = (ITelnetParameter)tcp.GetAdapter(typeof(ITelnetParameter));
                if (telnetParameter != null)
                {
                    telnetParameter.TelnetNewLine = _prof.TelnetNewLine;
                }
            }
            else if ((_prof.Protocol == ConnectionMethod.SSH1) || (_prof.Protocol == ConnectionMethod.SSH2))
            {
                // SSH
                ISSHLoginParameter ssh = ConnectProfilePlugin.Instance.ProtocolService.CreateDefaultSSHParameter();
                tcp                      = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));
                tcp.Destination          = _prof.HostName;
                tcp.Port                 = _prof.Port;
                ssh.Method               = (_prof.Protocol == ConnectionMethod.SSH1) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
                ssh.Account              = _prof.UserName;
                ssh.AuthenticationType   = ConvertAuth(_prof.AuthType);
                ssh.PasswordOrPassphrase = _prof.Password;
                ssh.IdentityFileName     = _prof.KeyFile;
                ssh.LetUserInputPassword = (_prof.AutoLogin == true) ? false : true;
            }

            // TerminalSettings(表示プロファイル/改行コード/文字コード)
            ITerminalSettings terminalSettings = ConnectProfilePlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings(_prof.HostName, null);

            terminalSettings.BeginUpdate();
            terminalSettings.RenderProfile = _prof.RenderProfile;
            terminalSettings.TransmitNL    = _prof.NewLine;
            terminalSettings.Encoding      = _prof.CharCode;
            terminalSettings.LocalEcho     = false;
            terminalSettings.EndUpdate();

            // TerminalParameter
            ITerminalParameter terminalParam = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter));

            // ターミナルサイズ(これを行わないとPoderosa起動直後のOnReceptionが何故か機能しない, 行わない場合は2回目以降の接続時は正常)
            IViewManager            viewManager            = CommandTargetUtil.AsWindow(ConnectProfilePlugin.Instance.WindowManager.ActiveWindow).ViewManager;
            IContentReplaceableView contentReplaceableView = (IContentReplaceableView)viewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
            TerminalControl         terminalControl        = (TerminalControl)contentReplaceableView.GetCurrentContent().GetAdapter(typeof(TerminalControl));

            if (terminalControl != null)
            {
                Size size = terminalControl.CalcTerminalSize(terminalSettings.RenderProfile);
                terminalParam.SetTerminalSize(size.Width, size.Height);
            }

            // 接続(セッションオープン)
            _terminalSession = (ITerminalSession)ConnectProfilePlugin.Instance.WindowManager.ActiveWindow.AsForm().Invoke(new OpenSessionDelegate(InvokeOpenSessionOrNull), terminalParam, terminalSettings);

            // 自動ログイン/SU/実行コマンド
            if (_terminalSession != null)
            {
                // 受信データオブジェクト作成(ユーザからのキーボード入力が不可)
                ReceptionData pool = new ReceptionData();
                _terminalSession.Terminal.StartModalTerminalTask(pool);

                // Telnet自動ログイン
                if ((_prof.AutoLogin == true) && (_prof.Protocol == ConnectionMethod.Telnet))
                {
                    if (TelnetAutoLogin() != true)
                    {
                        return;
                    }
                }

                // SU
                if ((_prof.AutoLogin == true) && (_prof.SUUserName != ""))
                {
                    if (SUSwitch() != true)
                    {
                        return;
                    }
                }

                // 実行コマンド
                if ((_prof.AutoLogin == true) && (_prof.ExecCommand != ""))
                {
                    if (ExecCommand() != true)
                    {
                        return;
                    }
                }

                // 受信データオブジェクト定義解除(ユーザからのキーボード入力を許可)
                _terminalSession.Terminal.EndModalTerminalTask();
            }
        }
Пример #47
0
        private CommandResult Reproduce(ITerminalSession ts)
        {
            //TODO SSH2�ł͓���R�l�N�V�����ł����{����V���[�g�J�b�g�A�V���A���ł͕����ł��Ȃ����Ƃ�ʒm����V���[�g�J�b�g�����邪...
            ITerminalParameter param = (ITerminalParameter)ts.TerminalTransmission.Connection.Destination.Clone();
            ISSHLoginParameter ssh = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));
            if (ssh != null)
                ssh.LetUserInputPassword = false;
            ITerminalSettings settings = ts.TerminalSettings.Clone();

            ITerminalSession session = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(ts.OwnerWindow, param, settings);
            return session != null ? CommandResult.Succeeded : CommandResult.Failed;
        }