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)));
        }
        //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);
        }
Пример #3
0
        internal override ITerminalParameter ConvertToTerminalParameter()
        {
            ICygwinParameter cygwin = MacroPlugin.Instance.ProtocolService.CreateDefaultCygwinParameter();

            cygwin.Home      = _home;
            cygwin.ShellName = _shell;
            return((ITerminalParameter)cygwin.GetAdapter(typeof(ITerminalParameter)));
        }
Пример #4
0
            public ITerminalConnection Connect()
            {
                lock (_lockObject) {
                    if (_localPort == 0)
                    {
                        PrepareListener();
                    }
                }

                //string cygtermPath = "cygterm\\"+(IsCygwin(_param)? "cygterm.exe" : "sfuterm.exe");
                //string connectionName = IsCygwin(_param)? "Cygwin" : "SFU";
                string cygtermPath = String.Format("{0}cygterm\\cygterm.exe", ProtocolUtil.ProtocolsPluginHomeDir);
                //string connectionName = "Cygwin";

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

                //mwg: Construct args for cygterm.exe
                System.Text.StringBuilder args = new System.Text.StringBuilder();
                args.AppendFormat(" -p {0}", _localPort);
                args.AppendFormat(" -v HOME=\"{0}\"", _param.Home);
                args.AppendFormat(" -v TERM=\"{0}\"", term.TerminalType);
                args.AppendFormat(" -s \"{0}\"", _param.ShellName);
                args.AppendFormat(" -v ROSATERM=\"{0}\"", "rosaterm");

                ProcessStartInfo psi = new ProcessStartInfo(cygtermPath, args.ToString());

                PrepareEnv(psi, _param);
                psi.CreateNoWindow  = true;
                psi.ErrorDialog     = true;
                psi.UseShellExecute = false;
                psi.WindowStyle     = ProcessWindowStyle.Hidden;

                //mwg: Set working directory/mwg
                string wdir = _param.Home;

                if (wdir.StartsWith("/"))
                {
                    wdir = wdir.Substring(1);
                }
                wdir = System.IO.Path.Combine(CygwinUtil.GuessRootDirectory(_param.CygwinDir), wdir);
                psi.WorkingDirectory = wdir;

                try {
                    _process = Process.Start(psi);
                }catch (System.ComponentModel.Win32Exception ex) {
                    throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.FailedToRunCygterm") + ": " + cygtermPath, ex);
                }
                while (true)
                {
                    List <Socket> chk = new List <Socket>();
                    chk.Add(_listener);
                    Socket.Select(chk, null, null, 100);
                    if (_interrupted)
                    {
                        return(null);
                    }
                    if (chk.Count > 0)
                    {
                        break;
                    }
                }
                Socket sock = _listener.Accept();

                if (_interrupted)
                {
                    return(null);
                }

                TelnetNegotiator neg        = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight);
                TelnetParameter  shellparam = new TelnetParameter();

                shellparam.Destination = "localhost";
                shellparam.SetTerminalName(term.TerminalType);
                shellparam.SetTerminalSize(term.InitialWidth, term.InitialHeight);
                TelnetTerminalConnection r = new TelnetTerminalConnection(shellparam, neg, new PlainPoderosaSocket(sock));

                r.Destination = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter));                 //TelnetでなくオリジナルのCygwinParamで上書き
                r.UsingSocks  = false;
                return(r);
            }
Пример #5
0
            public ITerminalConnection Connect()
            {
                lock (_lockObject) {
                    if (_localPort == 0)
                    {
                        PrepareListener();
                    }
                }

                string cygtermPath = GetCygtermPath();

                if (cygtermPath == null)
                {
                    throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.CygtermExeNotFound"));
                }

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

                string           args = String.Format("-p {0} -v HOME=\"{1}\" -v TERM=\"{2}\" -s \"{3}\"", _localPort, _param.Home, term.TerminalType, _param.ShellName);
                ProcessStartInfo psi  = new ProcessStartInfo(cygtermPath, args);

                PrepareEnv(psi, _param);
                psi.CreateNoWindow  = true;
                psi.ErrorDialog     = true;
                psi.UseShellExecute = false;
                psi.WindowStyle     = ProcessWindowStyle.Hidden;

                try {
                    _process = Process.Start(psi);
                }
                catch (System.ComponentModel.Win32Exception ex) {
                    throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.FailedToRunCygterm") + ": " + cygtermPath, ex);
                }
                while (true)
                {
                    List <Socket> chk = new List <Socket>();
                    chk.Add(_listener);
                    Socket.Select(chk, null, null, 100);
                    if (_interrupted)
                    {
                        return(null);
                    }
                    if (chk.Count > 0)
                    {
                        break;
                    }
                }
                Socket sock = _listener.Accept();

                if (_interrupted)
                {
                    return(null);
                }

                TelnetNegotiator neg        = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight);
                TelnetParameter  shellparam = new TelnetParameter();

                shellparam.Destination = "localhost";
                shellparam.SetTerminalName(term.TerminalType);
                shellparam.SetTerminalSize(term.InitialWidth, term.InitialHeight);
                TelnetTerminalConnection r = new TelnetTerminalConnection(shellparam, neg, new PlainPoderosaSocket(sock));

                r.Destination = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter)); //TelnetでなくオリジナルのCygwinParamで上書き
                r.UsingSocks  = false;
                return(r);
            }