Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="host"></param>
 /// <param name="settings"></param>
 /// <param name="connection"></param>
 /// <exclude/>
 public TerminalTransmission(AbstractTerminal host, ITerminalSettings settings, ITerminalConnection connection)
 {
     _host = host;
     _settings = settings;
     _connection = connection;
     _dataForLocalEcho = new ByteDataFragment();
 }
        public SSHShortcutLoginDialog(IPoderosaMainWindow parent, ISSHLoginParameter param, ITerminalSettings settings)
            : base(parent) {
            this.TerminalSettings = settings;

            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();

            this._privateKeyLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._privateKeyLabel");
            this._passphraseLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._passphraseLabel");
            this._logFileLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._logFileLabel");
            this._hostLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._hostLabel");
            this._methodLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._methodLabel");
            this._accountLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._accountLabel");
            this._authenticationTypeLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._authenticationTypeLabel");
            this._encodingLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._encodingLabel");
            this._logTypeLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._logTypeLabel");
            this.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog.Text");
            this._autoExecMacroPathLabel.Text = TEnv.Strings.GetString("Form.SSHShortcutLoginDialog._autoExecMacroPathLabel");
            this._cancelButton.Text = TEnv.Strings.GetString("Common.Cancel");
            this._loginButton.Text = TEnv.Strings.GetString("Common.OK");

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

            _sshParam = param;
            InitUI();
        }
Example #3
0
 public void IsolateSettings()
 {
     AssureContent();
     //TerminalParam, Settingsそれぞれでクローンを持つように変化させる
     _terminalParam    = (ITerminalParameter)_terminalParam.Clone();
     _terminalSettings = _terminalSettings.Clone();
 }
Example #4
0
        protected void Dispose(bool disposing)
        {
            if (_debug > 0)
            {
                Console.WriteLine("TelnetSSH-Dispose-End");
            }

            if (!this.disposed)
            {
                if (disposing)
                {
                    _isRunning = false;
                    this.close();
                    if (_Console != null)
                    {
                        _Console = null;
                    }
                    if (_terminalOptions != null)
                    {
                        _terminalOptions = null;
                    }
                    if (_terminalSettings != null)
                    {
                        _terminalSettings = null;
                    }
                }

                //free unmanaged objects
                //AdditionalCleanup();

                this.disposed = true;
            }
        }
Example #5
0
 public ParameterItem(ITelnetParameter telnetParam, ITCPParameter tcpParam, ITerminalParameter terminalParam, ITerminalSettings terminalSettings)
 {
     TelnetParameter   = telnetParam;
     TCPParameter      = tcpParam;
     TerminalParameter = terminalParam;
     TerminalSettings  = terminalSettings;
 }
Example #6
0
        public bool IsSupporting(ITerminalParameter param, ITerminalSettings settings)
        {
            SerialTerminalParam    sp = param as SerialTerminalParam;
            SerialTerminalSettings ts = settings as SerialTerminalSettings;

            return(sp != null && ts != null);
        }
 public ParameterItem(ISSHLoginParameter sshParam, ITCPParameter tcpParam, ITerminalParameter terminalParam, ITerminalSettings terminalSettings)
 {
     SSHParameter      = sshParam;
     TCPParameter      = tcpParam;
     TerminalParameter = terminalParam;
     TerminalSettings  = terminalSettings;
 }
Example #8
0
        public AbstractTerminal(TerminalInitializeInfo info)
        {
            //TerminalEmulatorPlugin.Instance.LaterInitialize();
            _session = info.Session;

            // //_invalidateParam = new InvalidateParam();
            _document = new TerminalDocument(info.InitialWidth, info.InitialHeight);
            //_document.SetOwner(_session.ISession);
            _afterExitLockActions = new List <AfterExitLockDelegate>();

            _decoder      = new ISO2022CharDecoder(this, EncodingProfile.Get(info.Session.TerminalSettings.Encoding));
            _terminalMode = TerminalMode.Normal;
            _logService   = new LogService(info.TerminalParameter, _session.TerminalSettings, _session.TerminalOptions);
            //_promptRecognizer = new PromptRecognizer(this);

            //if (info.Session.TerminalSettings.LogSettings != null)
            //{
            //    _logService.ApplyLogSettings(_session.TerminalSettings.LogSettings, false);
            //}

            //event handlers
            ITerminalSettings ts = info.Session.TerminalSettings;

            ts.ChangeEncoding  += delegate(EncodingType t) { this.Reset(); };
            _document.DebugFlag = ts.DebugFlag;

            _document.LineFeedRule = GetTerminalSettings().LineFeedRule; //(Telnet.LineFeedRule)
            //ToDo: Set Encoding
            //_document.Encoding = Encoding.GetEncoding("iso-2022-jp")
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="host"></param>
 /// <param name="settings"></param>
 /// <param name="connection"></param>
 /// <exclude/>
 public TerminalTransmission(AbstractTerminal host, ITerminalSettings settings, ITerminalConnection connection)
 {
     _host             = host;
     _settings         = settings;
     _connection       = connection;
     _dataForLocalEcho = new ByteDataFragment();
 }
        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);
        }
        private void ApplyParam(ICygwinParameter shellparam, ITerminalSettings terminalSettings)
        {
            _param = (ICygwinParameter)shellparam.Clone();
            this.TerminalSettings = terminalSettings.Clone();

            this.Text = TEnv.Strings.GetString("Form.CygwinLoginDialog.TextCygwin");
        }
Example #12
0
        private void OnHostIsSelected(object sender, System.EventArgs e)
        {
            if (_initializing || _loginDialogUISupport == null)
            {
                return;
            }

            ITerminalParameter parameter = null;
            ITerminalSettings  settings  = null;

            _loginDialogUISupport.FillCorrespondingDestination(typeof(ITCPParameter), _hostBox.Text, out parameter, out settings);
            if (parameter != null && settings != null) //原理的には片方のみの適用もあるが
            {
                ISSHLoginParameter ssh = (ISSHLoginParameter)parameter.GetAdapter(typeof(ISSHLoginParameter));
                ITCPParameter      tcp = (ITCPParameter)parameter.GetAdapter(typeof(ITCPParameter));
                if (ssh != null)
                {
                    ssh.PasswordOrPassphrase = "";
                    if (TerminalSessionsPlugin.Instance.ProtocolService.ProtocolOptions.RetainsPassphrase)
                    {
                        ssh.PasswordOrPassphrase = TerminalSessionsPlugin.Instance.ProtocolService.PassphraseCache.GetOrEmpty(tcp.Destination, ssh.Account);
                    }
                }

                ApplyParam(parameter, settings);
            }
        }
Example #13
0
        private void _loginButton_Click(object sender, EventArgs e)
        {
            int tabPageIndex = _sessionTypeTab.SelectedIndex;
            var tabPage      = _tabPages[tabPageIndex];

            _loginButton.Enabled    = false;
            _cancelButton.Enabled   = false;
            _sessionTypeTab.Enabled = false;

            this.Cursor = Cursors.WaitCursor;

            ITerminalSettings terminalSettings;
            IInterruptable    interruptable;
            bool started = tabPage.OpenSession(this, out terminalSettings, out interruptable);

            if (!started)
            {
                _loginButton.Enabled    = true;
                _cancelButton.Enabled   = true;
                _sessionTypeTab.Enabled = true;
                return;
            }

            this.Text             = TEnv.Strings.GetString("Caption.LoginDialog.Connecting");
            _terminalSettings     = terminalSettings;
            _interruptable        = interruptable;
            _cancelButton.Enabled = true;
        }
Example #14
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);
        }
Example #15
0
        public void SuccessfullyExit(ITerminalConnection connection)
        {
            ITerminalSettings terminalSettings = PoderosaTerminalEmulatorService.CreateDefaultTerminalSettings(Connection.DisplayName, null);

            TerminalSession session       = new TerminalSession(connection, terminalSettings);
            SessionHost     sessionHost   = new SessionHost(PoderosaSessionManagerPlugin, session);
            TerminalView    terminalView  = new TerminalView(null, _terminal);
            RenderProfile   renderProfile = new RenderProfile(_terminal.GetRenderProfile());

            renderProfile.BackColor = Connection.BackgroundColor;
            renderProfile.ForeColor = Connection.TextColor;

            session.TerminalSettings.BeginUpdate();
            session.TerminalSettings.RenderProfile = renderProfile;
            session.TerminalSettings.EndUpdate();

            _sshConnection = (SSHTerminalConnection)connection;

            Invoke(
                new Action(
                    () =>
            {
                _terminal.Attach(session);

                session.InternalStart(sessionHost);
                session.InternalAttachView(sessionHost.DocumentAt(0), terminalView);

                _sshConnection.ConnectionEventReceiver.NormalTermination   += ConnectionEventReceiver_NormalTermination;
                _sshConnection.ConnectionEventReceiver.AbnormalTermination += ConnectionEventReceiver_AbnormalTermination;

                ParentForm.Closing += ParentForm_OnClosing;

                OnConnected(_terminal, null);
            }));
        }
            public bool IsSupporting(ITerminalParameter param, ITerminalSettings settings)
            {
                ITCPParameter      tcp = (ITCPParameter)param.GetAdapter(typeof(ITCPParameter));
                ISSHLoginParameter ssh = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));

                return(tcp != null && ssh == null); //SSHならSSHを使う。
            }
        //EXTP使用
        public void ApplyParam()
        {
            ICygwinParameter  parameter = null;
            ITerminalSettings settings  = null;

            if (_loginDialogUISupport != null)
            {
                ITerminalParameter tp = null;
                _loginDialogUISupport.FillTopDestination(typeof(ICygwinParameter), out tp, out settings);
                parameter = tp == null ? null : (ICygwinParameter)tp.GetAdapter(typeof(ICygwinParameter));
            }
            if (parameter == null)
            {
                parameter = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultCygwinParameter();
            }
            if (settings == null)
            {
                settings = CygwinPlugin.Instance.CreateDefaultCygwinTerminalSettings();
            }

            IAutoExecMacroParameter autoExecParams = parameter.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParams != null && CygwinPlugin.Instance.MacroEngine != null)
            {
                _autoExecMacroPathBox.Text = (autoExecParams.AutoExecMacroPath != null) ? autoExecParams.AutoExecMacroPath : String.Empty;
            }
            else
            {
                _autoExecMacroPathLabel.Enabled    = false;
                _autoExecMacroPathBox.Enabled      = false;
                _selectAutoExecMacroButton.Enabled = false;
            }

            ApplyParam(parameter, settings);
        }
        public static ITerminalSession InvokeOpenSessionOrNull(ICommandTarget target, TerminalParam param)
        {
            ITerminalParameter tp = param.ConvertToTerminalParameter();
            ITerminalSettings  ts = CreateTerminalSettings(param);

            IViewManager pm = CommandTargetUtil.AsWindow(target).ViewManager;
            //独立ウィンドウにポップアップさせるようなことは考えていない
            IContentReplaceableView rv = (IContentReplaceableView)pm.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
            TerminalControl         tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(TerminalControl));

            if (tc != null) //ターミナルコントロールがないときは無理に設定しにいかない
            {
                Size sz;
                if (ts.UsingDefaultRenderProfile)
                {
                    using (RenderProfile profile = MacroPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile())
                        sz = tc.CalcTerminalSize(profile);
                }
                else
                {
                    sz = tc.CalcTerminalSize(ts.RenderProfile);
                }
                //RenderProfile rp = ts.UsingDefaultRenderProfile? MacroPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : ts.RenderProfile;
                //Size sz = tc.CalcTerminalSize(rp);
                tp.SetTerminalSize(sz.Width, sz.Height);
            }


            return((ITerminalSession)MacroPlugin.Instance.WindowManager.ActiveWindow.AsForm().Invoke(new OpenSessionDelegate(OpenSessionOrNull), tp, ts));
        }
Example #19
0
 public void BaseImport(ITerminalSettings ts)
 {
     base.Import(ts);
     //アイコンは保持する
     this.BeginUpdate();
     this.Icon = SerialPortPlugin.Instance.LoadIcon();
     this.EndUpdate();
 }
Example #20
0
        public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter param, ITerminalSettings settings)
        {
            SerialTerminalParam sp = param as SerialTerminalParam;
            SerialTerminalSettings ts = settings as SerialTerminalSettings;
            Debug.Assert(sp != null && ts != null);

            return SerialPortUtil.CreateNewSerialConnection(window, sp, ts);
        }
Example #21
0
 public TelnetSSHLogin()
 {
     _instance         = this;
     _isRunning        = true;
     _Console          = new ConsoleMain();
     _terminalOptions  = new TerminalOptions("");
     _terminalSettings = new TerminalSettings();
     _timeout          = _Console.ProtocolOptions.SocketConnectTimeout / 1000;
 }
            public override void OnChange(ICommandTarget target, int selectedIndex)
            {
                ITerminalControlHost session = TerminalCommandTarget.AsTerminal(target);
                ITerminalSettings    ts      = session.TerminalSettings;

                ts.BeginUpdate();
                ts.TransmitNL = (NewLine)selectedIndex;
                ts.EndUpdate();
            }
Example #23
0
            public override void OnChange(ICommandTarget target, bool is_checked)
            {
                ITerminalControlHost session = TerminalCommandTarget.AsTerminal(target);
                ITerminalSettings    ts      = session.TerminalSettings;

                ts.BeginUpdate();
                ts.LocalEcho = is_checked;
                ts.EndUpdate();
            }
Example #24
0
        public ITerminalSettings CreateDefaultCygwinTerminalSettings()
        {
            ITerminalSettings settings = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings("", Poderosa.TerminalSession.Properties.Resources.Cygwin16x16);

            settings.BeginUpdate();
            settings.Encoding = EncodingType.UTF8;
            settings.EndUpdate();
            return(settings);
        }
Example #25
0
 public void Detach()
 {
     if (_terminalSettings != null)
     {
         _terminalSettings.RemoveListener(this);
     }
     _terminalSettings = null;
     _toolBar.RefreshComponent(_parent);
 }
            public override void OnChange(ICommandTarget target, int selectedIndex)
            {
                ITerminalControlHost session = TerminalCommandTarget.AsOpenTerminal(target);
                ITerminalSettings    ts      = session.TerminalSettings;

                ts.BeginUpdate();
                ts.ShellScheme = TerminalEmulatorPlugin.Instance.ShellSchemeCollection.GetAt(selectedIndex);
                ts.EndUpdate();
            }
Example #27
0
            public override void OnChange(ICommandTarget target, bool is_checked)
            {
                ITerminalControlHost session = TerminalCommandTarget.AsOpenTerminal(target);
                ITerminalSettings    ts      = session.TerminalSettings;

                ts.BeginUpdate();
                ts.EnabledCharTriggerIntelliSense = is_checked;
                ts.EndUpdate();
            }
Example #28
0
 public TerminalSession(ITerminalConnection connection, ITerminalSettings terminalSettings, TerminalOptions terminalOptions)
 {
     _terminalSettings = terminalSettings;
     _terminalOptions  = terminalOptions;
     //VT100Žw’è‚Å‚àxtermƒV[ƒPƒ“ƒX‚ð‘—‚Á‚Ä‚­‚éƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ªŒã‚ð‚½‚½‚È‚¢‚Ì‚Å
     _terminal  = AbstractTerminal.Create(new TerminalInitializeInfo(this, connection.Destination));
     _output    = new TerminalTransmission(_terminal, _terminalSettings, connection);
     _keepAlive = new KeepAlive(this);
 }
Example #29
0
        /// <summary>
        /// Initiates the SSH connection process by getting the <see cref="IProtocolService"/> instance and calling
        /// <see cref="IProtocolService.AsyncSSHConnect"/>.  This is an asynchronous process:  the <see cref="SuccessfullyExit"/> method is called when the
        /// connection is established successfully and <see cref="ConnectionFailed"/> method is called when we are unable to establish the connection.
        /// </summary>
        public void AsyncConnect()
        {
            ITerminalEmulatorService terminalEmulatorService =
                (ITerminalEmulatorService)_poderosaWorld.PluginManager.FindPlugin("org.poderosa.terminalemulator", typeof(ITerminalEmulatorService));
            IProtocolService protocolService = (IProtocolService)_poderosaWorld.PluginManager.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));

            // Create and initialize the SSH login parameters
            ISSHLoginParameter sshLoginParameter = protocolService.CreateDefaultSSHParameter();

            sshLoginParameter.Account = Username;

            if (!String.IsNullOrEmpty(IdentityFile))
            {
                sshLoginParameter.AuthenticationType = AuthenticationType.PublicKey;
                sshLoginParameter.IdentityFileName   = IdentityFile;
            }

            else
            {
                sshLoginParameter.AuthenticationType = AuthenticationType.Password;

                if (Password != null && Password.Length > 0)
                {
                    IntPtr passwordBytes = Marshal.SecureStringToGlobalAllocAnsi(Password);
                    sshLoginParameter.PasswordOrPassphrase = Marshal.PtrToStringAnsi(passwordBytes);
                }
            }

            sshLoginParameter.Method = (SSHProtocol)Enum.Parse(typeof(SSHProtocol), SshProtocol.ToString("G"));

            // Create and initialize the various socket connection properties
            ITCPParameter tcpParameter = (ITCPParameter)sshLoginParameter.GetAdapter(typeof(ITCPParameter));

            tcpParameter.Destination = HostName;
            tcpParameter.Port        = Port;

            // Set the UI settings to use for the terminal itself
            terminalEmulatorService.TerminalEmulatorOptions.RightButtonAction = MouseButtonAction.Paste;
            _settings = terminalEmulatorService.CreateDefaultTerminalSettings(tcpParameter.Destination, null);

            _settings.BeginUpdate();
            _settings.TerminalType            = (ConnectionParam.TerminalType)Enum.Parse(typeof(ConnectionParam.TerminalType), TerminalType.ToString("G"));
            _settings.RenderProfile           = terminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
            _settings.RenderProfile.BackColor = BackColor;
            _settings.RenderProfile.ForeColor = ForeColor;
            _settings.RenderProfile.FontName  = Font.Name;
            _settings.RenderProfile.FontSize  = Font.Size;
            _settings.EndUpdate();

            ITerminalParameter param = (ITerminalParameter)tcpParameter.GetAdapter(typeof(ITerminalParameter));

            param.SetTerminalName(_settings.TerminalType.ToString("G").ToLower());

            // Initiate the connection process
            protocolService.AsyncSSHConnect(this, sshLoginParameter);
        }
        protected override ITerminalParameter PrepareTerminalParameter()
        {
            _param.Home      = _homeDirectoryBox.Text;
            _param.ShellName = _shellBox.Text;

            //ログ設定
            LogType            logtype     = (LogType)EnumDescAttribute.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);
            ISimpleLogSettings logsettings = null;

            if (logtype != LogType.None)
            {
                logsettings = CreateSimpleLogSettings(logtype, _logFileBox.Text);
                if (logsettings == null)
                {
                    return(null);                                  //動作キャンセル
                }
            }
            ITerminalSettings settings = this.TerminalSettings;

            settings.BeginUpdate();
            if (logsettings != null)
            {
                settings.LogSettings.Reset(logsettings);
            }
            settings.Caption      = _param.ShellBody;
            settings.Icon         = Poderosa.TerminalSession.Properties.Resources.Cygwin16x16;
            settings.Encoding     = (EncodingType)_encodingBox.SelectedIndex;
            settings.TerminalType = (TerminalType)_terminalTypeBox.SelectedIndex;
            settings.EndUpdate();

            ITerminalParameter termParam = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter));

            termParam.SetTerminalName(_terminalTypeBox.Text);                   // Used for TERM environment variable (LocalShellUtil)

            _param.CygwinDir = _cygwinDirBox.Text;
            if (_param.CygwinDir.Length > 0 && _param.CygwinDir[_param.CygwinDir.Length - 1] == Path.PathSeparator)
            {
                _param.CygwinDir = _param.CygwinDir.Substring(0, _param.CygwinDir.Length - 1);
            }

            string autoExecMacroPath = null;

            if (_autoExecMacroPathBox.Text.Length != 0)
            {
                autoExecMacroPath = _autoExecMacroPathBox.Text;
            }

            IAutoExecMacroParameter autoExecParams = _param.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;

            if (autoExecParams != null)
            {
                autoExecParams.AutoExecMacroPath = autoExecMacroPath;
            }

            return((ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)));
        }
Example #31
0
 public void Attach(ITerminalSettings ts)
 {
     if (_terminalSettings != null)
     {
         _terminalSettings.RemoveListener(this);
     }
     _terminalSettings = ts;
     _terminalSettings.AddListener(this);
     _toolBar.RefreshComponent(_parent);
 }
        public PromptRecognizer(AbstractTerminal term)
        {
            _terminal      = term;
            _commandBuffer = new StringBuilder();
            ITerminalSettings ts = term.TerminalHost.TerminalSettings;

            ts.AddListener(this);
            _promptExpression = new Regex(ts.ShellScheme.PromptExpression, RegexOptions.Compiled); //これはシェルにより可変
            _listeners        = new List <IPromptProcessor>();
        }
Example #33
0
        public TerminalSession(ITerminalConnection connection, ITerminalSettings terminalSettings) {
            _terminalSettings = terminalSettings;
            //VT100指定でもxtermシーケンスを送ってくるアプリケーションが後をたたないので
            _terminal = AbstractTerminal.Create(new TerminalInitializeInfo(this, connection.Destination));
            _output = new TerminalTransmission(_terminal, _terminalSettings, connection);

            _terminalSettings.ChangeCaption += delegate(string caption) {
                this.OwnerWindow.DocumentTabFeature.Update(_terminal.IDocument);
            };

        }
        public TerminalSession(ITerminalConnection connection, ITerminalSettings terminalSettings)
        {
            _terminalSettings = terminalSettings;
            //VT100�w��ł�xterm�V�[�P���X�𑗂��Ă���A�v���P�[�V�������������Ȃ��̂�
            _terminal = AbstractTerminal.Create(new TerminalInitializeInfo(this, connection.Destination));
            _output = new TerminalTransmission(_terminal, _terminalSettings, connection);

            _terminalSettings.ChangeCaption += delegate(string caption) {
                this.OwnerWindow.DocumentTabFeature.Update(_terminal.IDocument);
            };
        }
Example #35
0
        public TerminalSession(ITerminalConnection connection, ITerminalSettings terminalSettings) {
            _terminalSettings = terminalSettings;
            //VT100指定でもxtermシーケンスを送ってくるアプリケーションが後をたたないので
            _terminal = AbstractTerminal.Create(new TerminalInitializeInfo(this, connection.Destination));
            _output = new TerminalTransmission(_terminal, _terminalSettings, connection);

            _terminalSettings.ChangeCaption += delegate(string caption) {
                this.OwnerWindow.DocumentTabFeature.Update(_terminal.IDocument);
            };

        }
Example #36
0
 //Listener以外を持ってくる
 public virtual void Import(ITerminalSettings src) {
     _encoding = src.Encoding;
     _terminalType = src.TerminalType;
     _localecho = src.LocalEcho;
     _lineFeedRule = src.LineFeedRule;
     _transmitnl = src.TransmitNL;
     _caption = src.Caption;
     _icon = src.Icon;
     TerminalSettings src_r = (TerminalSettings)src;
     _shellSchemeName = src_r._shellSchemeName; //ちょっとインチキ
     if (src_r._shellScheme != null) {
         _shellScheme = src_r._shellScheme;
         TerminalEmulatorPlugin.Instance.ShellSchemeCollection.AddDynamicChangeListener(this);
     }
     _enabledCharTriggerIntelliSense = src.EnabledCharTriggerIntelliSense;
     _renderProfile = src.RenderProfile == null ? null : (RenderProfile)src.RenderProfile.Clone();
     _multiLogSettings = src.LogSettings == null ? null : (IMultiLogSettings)_multiLogSettings.Clone();
 }
Example #37
0
        public ITerminalConnection OpenConnection(IPoderosaMainWindow owner, ITerminalParameter destination, ITerminalSettings settings) {
            //NOTE 同時接続数チェックあたりあってもいい

            ITerminalConnectionFactory[] fs = (ITerminalConnectionFactory[])TerminalSessionsPlugin.Instance.PoderosaWorld.PluginManager.FindExtensionPoint(TerminalSessionsPlugin.TERMINAL_CONNECTION_FACTORY_ID).GetExtensions();
            //後に登録されたやつを優先するため、逆順に舐める
            for (int i = fs.Length - 1; i >= 0; i--) {
                ITerminalConnectionFactory f = fs[i];
                if (f.IsSupporting(destination, settings)) {
                    return f.EstablishConnection(owner, destination, settings);
                }
            }
            throw new ArgumentException("Failed to make an ITerminalConnection using extension point."); //ましなエラーメッセージ
        }
Example #38
0
 public void OnEndUpdate(ITerminalSettings current) {
     _toolBar.RefreshComponent(_parent);
 }
Example #39
0
 public void OnBeginUpdate(ITerminalSettings current) {
 }
Example #40
0
 public void Detach() {
     if (_terminalSettings != null)
         _terminalSettings.RemoveListener(this);
     _terminalSettings = null;
     _toolBar.RefreshComponent(_parent);
 }
Example #41
0
 public void Attach(ITerminalSettings ts) {
     if (_terminalSettings != null)
         _terminalSettings.RemoveListener(this);
     _terminalSettings = ts;
     _terminalSettings.AddListener(this);
     _toolBar.RefreshComponent(_parent);
 }
Example #42
0
 public bool IsSupporting(ITerminalParameter destination, ITerminalSettings settings) {
     ISSHLoginParameter ssh = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));
     return ssh != null;
 }
 /// <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;
     }
 }
Example #44
0
 public void BaseImport(ITerminalSettings ts) {
     base.Import(ts);
     //アイコンは保持する
     this.BeginUpdate();
     this.Icon = SerialPortPlugin.Instance.LoadIcon();
     this.EndUpdate();
 }
        public void ApplyParam(IAdaptable destination, ITerminalSettings terminal) {
            _initializing = true;
            Debug.Assert(destination != null);
            Debug.Assert(terminal != null);
            this.TerminalSettings = terminal.Clone();

            ITCPParameter tcp_destination = (ITCPParameter)destination.GetAdapter(typeof(ITCPParameter));
            ISSHLoginParameter ssh_destination = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));
            bool is_telnet = ssh_destination == null;

            _methodBox.SelectedItem =
                is_telnet ? ConnectionMethod.Telnet :
                    ssh_destination.Method == SSHProtocol.SSH1 ? ConnectionMethod.SSH1 : ConnectionMethod.SSH2; // select ListItem<T> by T
            _portBox.SelectedIndex = _portBox.FindStringExact(PortDescription(tcp_destination.Port));
            if (ssh_destination != null) {
                _userNameBox.SelectedIndex = _userNameBox.FindStringExact(ssh_destination.Account);
                _passphraseBox.Text = ssh_destination.PasswordOrPassphrase;

                if (ssh_destination.AuthenticationType == AuthenticationType.PublicKey)
                    _privateKeyFile.Text = ssh_destination.IdentityFileName;
                else
                    _privateKeyFile.Text = "";
                _authOptions.SelectedItem = ToAuthType(ssh_destination.AuthenticationType); // select EnumListItem<T> by T
            }

            IAutoExecMacroParameter autoExecParams = destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
            if (autoExecParams != null && TelnetSSHPlugin.Instance.MacroEngine != null) {
                _autoExecMacroPathBox.Text = (autoExecParams.AutoExecMacroPath != null) ? autoExecParams.AutoExecMacroPath : String.Empty;
            }
            else {
                _autoExecMacroPathLabel.Enabled = false;
                _autoExecMacroPathBox.Enabled = false;
                _selectAutoExecMacroButton.Enabled = false;
            }

            if (is_telnet) {
                ITelnetParameter telnetParams = (ITelnetParameter)destination.GetAdapter(typeof(ITelnetParameter));
                _telnetNewLine.Checked = (telnetParams != null) ? telnetParams.TelnetNewLine : true;
            }
            else {
                _telnetNewLine.Checked = true;
            }

            _encodingBox.SelectedItem = terminal.Encoding;              // select EnumListItem<T> by T
            _newLineBox.SelectedItem = terminal.TransmitNL;             // select EnumListItem<T> by T
            _localEchoBox.SelectedItem = terminal.LocalEcho;            // select ListItem<T> by T
            _terminalTypeBox.SelectedItem = terminal.TerminalType;      // select EnumListItem<T> by T
            _initializing = false;

            EnableValidControls();
        }
Example #46
0
        private static void AdjustCaptionAndText(ITerminalSettings terminal_settings, string caption, StartCommandIcon icon) {
            terminal_settings.BeginUpdate();
            if (terminal_settings.Caption == null || terminal_settings.Caption.Length == 0)
                terminal_settings.Caption = caption; //長さ0はいかん
            if (terminal_settings.Icon == null) {
                switch (icon) {
                    case StartCommandIcon.NewConnection:
                        terminal_settings.Icon = Poderosa.TerminalSession.Properties.Resources.NewConnection16x16;
                        break;
                    case StartCommandIcon.Cygwin:
                        terminal_settings.Icon = Poderosa.TerminalSession.Properties.Resources.Cygwin16x16;
                        break;
                }
            }
            terminal_settings.EndUpdate();

        }
Example #47
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;
            }
        }
Example #48
0
            public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter destination, ITerminalSettings settings) {
                ITCPParameter tcp = (ITCPParameter)destination.GetAdapter(typeof(ITCPParameter));
                IProtocolService ps = TerminalSessionsPlugin.Instance.ProtocolService;
                ISynchronizedConnector sc = ps.CreateFormBasedSynchronozedConnector(window);
                IInterruptable t = ps.AsyncTelnetConnect(sc.InterruptableConnectorClient, tcp);
                ITerminalConnection con = sc.WaitConnection(t, TerminalSessionsPlugin.Instance.TerminalSessionOptions.TerminalEstablishTimeout);

                AdjustCaptionAndText(settings, tcp.Destination, StartCommandIcon.NewConnection);
                return con;
            }
Example #49
0
 public LocalEchoChanger(ITerminalSettings settings, bool value) {
     _settings = settings;
     _value = value;
 }
Example #50
0
        //Parameterからスタートするタイプ 今はtargetはwindow強制だがViewでも可能にしたい
        public ITerminalSession StartTerminalSession(ICommandTarget target, ITerminalParameter destination, ITerminalSettings settings) {
            IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
            if (window == null) {
                IPoderosaView view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
                window = (IPoderosaMainWindow)view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
            }
            Debug.Assert(window != null);

            ITerminalConnection connection = OpenConnection(window, destination, settings);
            if (connection == null)
                return null;

            return StartTerminalSession(target, connection, settings);

        }
Example #51
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;
        }
Example #52
0
 public bool IsSupporting(ITerminalParameter param, ITerminalSettings settings)
 {
     SerialTerminalParam sp = param as SerialTerminalParam;
     SerialTerminalSettings ts = settings as SerialTerminalSettings;
     return sp != null && ts != null;
 }
Example #53
0
 public bool IsSupporting(ITerminalParameter param, ITerminalSettings settings) {
     ITCPParameter tcp = (ITCPParameter)param.GetAdapter(typeof(ITCPParameter));
     ISSHLoginParameter ssh = (ISSHLoginParameter)param.GetAdapter(typeof(ISSHLoginParameter));
     return tcp != null && ssh == null; //SSHならSSHを使う。
 }
Example #54
0
 public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter destination, ITerminalSettings settings) {
     ISSHLoginParameter ssh = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));
     if (ssh.LetUserInputPassword && ssh.AuthenticationType != Granados.AuthenticationType.KeyboardInteractive) { //ダイアログで入力を促して接続
         SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(window, ssh, settings);
         if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) {
             ITerminalConnection con = dlg.Result;
             AdjustCaptionAndText(settings, ((ITCPParameter)con.Destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection);
             return con;
         }
         else
             return null;
     }
     else { //主にReproduceやマクロ。設定済みのパスワードで接続
         IProtocolService protocolservice = TerminalSessionsPlugin.Instance.ProtocolService;
         ISynchronizedConnector conn = protocolservice.CreateFormBasedSynchronozedConnector(window);
         IInterruptable r = protocolservice.AsyncSSHConnect(conn.InterruptableConnectorClient, ssh);
         AdjustCaptionAndText(settings, ((ITCPParameter)destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection);
         return conn.WaitConnection(r, TerminalSessionsPlugin.Instance.TerminalSessionOptions.TerminalEstablishTimeout); //時間?
     }
 }
Example #55
0
 public CaptionChanger(ITerminalSettings settings, string title)
 {
     _settings = settings;
     _title = title;
 }
Example #56
0
 public ShortcutFileContent(ITerminalSettings settings, ITerminalParameter param)
 {
     _settings = settings;
     _param = param;
 }
Example #57
0
        public override void Import(ITerminalSettings src) {
            base.Import(src);
            SerialTerminalSettings p = src as SerialTerminalSettings;
            Debug.Assert(p != null);

            _baudRate = p._baudRate;
            _byteSize = p._byteSize;
            _parity = p._parity;
            _stopBits = p._stopBits;
            _flowControl = p._flowControl;
            _transmitDelayPerChar = p._transmitDelayPerChar;
            _transmitDelayPerLine = p._transmitDelayPerLine;
        }
Example #58
0
 public bool IsSupporting(ITerminalParameter param, ITerminalSettings settings) {
     ICygwinParameter cygwin = (ICygwinParameter)param.GetAdapter(typeof(ICygwinParameter));
     return cygwin != null;
 }
Example #59
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;
        }
Example #60
0
        private void ApplyParam(ICygwinParameter shellparam, ITerminalSettings terminalSettings) {
            _param = (ICygwinParameter)shellparam.Clone();
            this.TerminalSettings = terminalSettings.Clone();

            this.Text = TEnv.Strings.GetString("Form.CygwinLoginDialog.TextCygwin");

        }