//基本のスタートセッション
        public ITerminalSession StartTerminalSession(ICommandTarget target, ITerminalConnection connection, ITerminalSettings settings)
        {
            Debug.Assert(connection != null);
            Debug.Assert(settings != null);
            //ここでターミナルエミュレータの遅延初期化
            TerminalSessionsPlugin.Instance.TerminalEmulatorService.LaterInitialize();

            ISessionManager sm = (ISessionManager)TerminalSessionsPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));

            IPoderosaView view = ToPoderosaView(target);

            Debug.Assert(view != null);

            TerminalSession session = new TerminalSession(connection, settings);

            sm.StartNewSession(session, view);
            sm.ActivateDocument(session.Terminal.IDocument, ActivateReason.InternalAction);

            IAutoExecMacroParameter autoExecParam = connection.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
            {
                TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, session);
            }

            return(session);
        }
Beispiel #2
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));

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

                using (OpenSessionDialog dlg = new OpenSessionDialog(window)) {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        IContentReplaceableView view       = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
                        IPoderosaView           targetView = view.AssureViewClass(typeof(TerminalView));

                        ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                        TerminalSession ts = new TerminalSession(dlg.TerminalConnection, dlg.TerminalSettings);
                        sm.StartNewSession(ts, targetView);
                        sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                        IAutoExecMacroParameter autoExecParam = dlg.TerminalConnection.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                        if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
                        {
                            TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                        }
                        return(CommandResult.Succeeded);
                    }
                    return(CommandResult.Cancelled);
                }
            }
Beispiel #3
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);
        }
Beispiel #4
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));

                if (window == null)
                {
                    return(CommandResult.Ignored);
                }
                TelnetSSHLoginDialog dlg = new TelnetSSHLoginDialog(window);

                dlg.ApplyParam();

                CommandResult res = CommandResult.Cancelled;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    ITerminalConnection con = dlg.Result;
                    if (con != null)
                    {
                        ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                        TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
                        sm.StartNewSession(ts, (IPoderosaView)dlg.TargetView.GetAdapter(typeof(IPoderosaView)));
                        sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                        IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                        if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
                        {
                            TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                        }

                        return(CommandResult.Succeeded);
                    }
                }
                dlg.Dispose();

                return(res);
            }
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
                if (window == null)
                    return CommandResult.Ignored;

                #if OLD_LOGIN_DIALOG
                TelnetSSHLoginDialog dlg = new TelnetSSHLoginDialog(window);

                dlg.ApplyParam();

                CommandResult res = CommandResult.Cancelled;
                if (dlg.ShowDialog() == DialogResult.OK) {
                    ITerminalConnection con = dlg.Result;
                    if (con != null) {
                        ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                        TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
                        sm.StartNewSession(ts, (IPoderosaView)dlg.TargetView.GetAdapter(typeof(IPoderosaView)));
                        sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                        IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                        if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null) {
                            TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                        }

                        return CommandResult.Succeeded;
                    }
                }
                dlg.Dispose();

                return res;
                #else
                using (OpenSessionDialog dlg = new OpenSessionDialog(window)) {
                    if (dlg.ShowDialog() == DialogResult.OK) {
                        IContentReplaceableView view = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
                        IPoderosaView targetView = view.AssureViewClass(typeof(TerminalView));

                        ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                        TerminalSession ts = new TerminalSession(dlg.TerminalConnection, dlg.TerminalSettings);
                        sm.StartNewSession(ts, targetView);
                        sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                        IAutoExecMacroParameter autoExecParam = dlg.TerminalConnection.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                        if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null) {
                            TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                        }
                        return CommandResult.Succeeded;
                    }
                    return CommandResult.Cancelled;
                }
                #endif
            }
Beispiel #6
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
                if (window == null)
                    return CommandResult.Ignored;
                LocalShellLoginDialog dlg = new LocalShellLoginDialog(window);
                using (dlg) {

                    dlg.ApplyParam();

                    if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) {
                        ITerminalConnection con = dlg.Result;
                        if (con != null) {
                            ISessionManager sm = (ISessionManager)CygwinPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                            TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
                            sm.StartNewSession(ts, dlg.TargetView);
                            sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                            IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                            if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && CygwinPlugin.Instance.MacroEngine != null) {
                                CygwinPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                            }

                            return CommandResult.Succeeded;
                        }
                    }
                }

                return CommandResult.Cancelled;
            }
Beispiel #7
0
        //基本のスタートセッション
        public ITerminalSession StartTerminalSession(ICommandTarget target, ITerminalConnection connection, ITerminalSettings settings) {
            Debug.Assert(connection != null);
            Debug.Assert(settings != null);
            //ここでターミナルエミュレータの遅延初期化
            TerminalSessionsPlugin.Instance.TerminalEmulatorService.LaterInitialize();

            ISessionManager sm = (ISessionManager)TerminalSessionsPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));

            IPoderosaView view = ToPoderosaView(target);
            Debug.Assert(view != null);

            TerminalSession session = new TerminalSession(connection, settings);
            sm.StartNewSession(session, view);
            sm.ActivateDocument(session.Terminal.IDocument, ActivateReason.InternalAction);

            IAutoExecMacroParameter autoExecParam = connection.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
            if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null) {
                TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, session);
            }

            return session;
        }
Beispiel #8
0
            public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
            {
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
                if (window == null)
                    return CommandResult.Ignored;
                TelnetSSHLoginDialog dlg = new TelnetSSHLoginDialog(window);

                dlg.ApplyParam();

                CommandResult res = CommandResult.Cancelled;
                //Task.Run(() =>
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ITerminalConnection con = dlg.Result;
                        if (con != null)
                        {
                            ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
                            TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
                            sm.StartNewSession(ts, (IPoderosaView)dlg.TargetView.GetAdapter(typeof(IPoderosaView)));
                            sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);

                            IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                            if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
                            {
                                TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
                            }

                            return CommandResult.Succeeded;
                        }
                    }
                    dlg.Dispose();
                }
                //);

                return res;
            }
 public void Connect()
 {
     try
     {
         switch (_protocol)
         {
             case ProtocolType.Cywin:
                 _synchronizedConnector = _basePoderosaInstance.ProtocolService.CreateFormBasedSynchronozedConnector(_window);
                 _asyncConnection = _basePoderosaInstance.ProtocolService.AsyncCygwinConnect(_synchronizedConnector.InterruptableConnectorClient, (ICygwinParameter)_terminalParameter);
                 _terminalConnection = _synchronizedConnector.WaitConnection(_asyncConnection, _basePoderosaInstance.TerminalSessionsPlugin.TerminalSessionOptions.TerminalEstablishTimeout);
                 break;
             case ProtocolType.Raw:
                 break;
             case ProtocolType.RLogin:
                 break;
             case ProtocolType.Serial:
                 _terminalConnection =(ITerminalConnection) SerialPortUtil.CreateNewSerialConnection(_window,(SerialTerminalParam)_terminalParameter,(SerialTerminalSettings)_terminalSettings);
                 break;
             case ProtocolType.SSH1:
             case ProtocolType.SSH2:
                 _synchronizedConnector = _basePoderosaInstance.ProtocolService.CreateFormBasedSynchronozedConnector(_window);
                 _asyncConnection = _basePoderosaInstance.ProtocolService.AsyncSSHConnect(_synchronizedConnector.InterruptableConnectorClient, (ISSHLoginParameter)_terminalParameter);
                 _terminalConnection = _synchronizedConnector.WaitConnection(_asyncConnection, _basePoderosaInstance.TerminalSessionsPlugin.TerminalSessionOptions.TerminalEstablishTimeout);
                 break;
             case ProtocolType.Telnet:
                 _synchronizedConnector = _basePoderosaInstance.ProtocolService.CreateFormBasedSynchronozedConnector(_window);
                 _asyncConnection = _basePoderosaInstance.ProtocolService.AsyncTelnetConnect(_synchronizedConnector.InterruptableConnectorClient, (ITCPParameter)_terminalParameter);
                 _terminalConnection = _synchronizedConnector.WaitConnection(_asyncConnection, _basePoderosaInstance.TerminalSessionsPlugin.TerminalSessionOptions.TerminalEstablishTimeout);
                 break;
             default:
                 _terminalConnection = null;
                 break;
         }
         _terminalSession = new TerminalSession(_terminalConnection, _terminalSettings);
         _basePoderosaInstance.SessionManagerPlugin.StartNewSession(_terminalSession, _terminalView);
         _basePoderosaInstance.SessionManagerPlugin.ActivateDocument(_terminalSession.Terminal.IDocument, ActivateReason.InternalAction);
     }
     catch (Exception ex)
     {
         RuntimeUtil.ReportException(ex);
         //return CommandResult.Failed;
     }
 }