コード例 #1
0
        protected override void Negotiate()
        {
            ITerminalParameter       term = (ITerminalParameter)_destination.GetAdapter(typeof(ITerminalParameter));
            TelnetNegotiator         neg  = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight);
            TelnetTerminalConnection r    = new TelnetTerminalConnection(_destination, neg, new PlainPoderosaSocket(_socket));

            //BACK-BURNER r.UsingSocks = _socks!=null;
            _result = r;
        }
コード例 #2
0
 public TelnetTerminalConnection(ITCPParameter p, TelnetNegotiator neg, PlainPoderosaSocket s)
     : base(p)
 {
     s.SetOwnerConnection(this);
     _telnetReceiver = new TelnetReceiver(this, neg);
     _telnetSocket   = new TelnetSocket(this, s, _telnetReceiver);
     _rawSocket      = s;
     _socket         = _telnetSocket;
     _terminalOutput = _telnetSocket;
 }
コード例 #3
0
        public TelnetTerminalConnection(ITCPParameter p, TelnetNegotiator neg, PlainPoderosaSocket s)
            : base(p)
        {
            s.SetOwnerConnection(this);
            _telnetReceiver = new TelnetReceiver(this, neg);
            ITelnetParameter telnetParams  = (ITelnetParameter)p.GetAdapter(typeof(ITelnetParameter));
            bool             telnetNewLine = (telnetParams != null) ? telnetParams.TelnetNewLine : true /*default*/;

            _telnetSocket   = new TelnetSocket(this, s, _telnetReceiver, telnetNewLine);
            _rawSocket      = s;
            _socket         = _telnetSocket;
            _terminalOutput = _telnetSocket;
        }
コード例 #4
0
ファイル: LocalShell.cs プロジェクト: Ricordanza/poderosa
            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;
            }
コード例 #5
0
 public TelnetReceiver(TelnetTerminalConnection parent, TelnetNegotiator negotiator)
 {
     _parent     = parent;
     _negotiator = negotiator;
     _localdata  = new ByteDataFragment();
 }
コード例 #6
0
ファイル: Connector.cs プロジェクト: FNKGino/poderosa
 protected override void Negotiate()
 {
     ITerminalParameter term = (ITerminalParameter)_destination.GetAdapter(typeof(ITerminalParameter));
     TelnetNegotiator neg = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight);
     TelnetTerminalConnection r = new TelnetTerminalConnection(_destination, neg, new PlainPoderosaSocket(_socket));
     //BACK-BURNER r.UsingSocks = _socks!=null;
     _result = r;
 }
コード例 #7
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);
            }
コード例 #8
0
 public TelnetTerminalConnection(ITCPParameter p, TelnetNegotiator neg, PlainPoderosaSocket s)
     : base(p)
 {
     s.SetOwnerConnection(this);
     _telnetReceiver = new TelnetReceiver(this, neg);
     ITelnetParameter telnetParams = (ITelnetParameter)p.GetAdapter(typeof(ITelnetParameter));
     bool telnetNewLine = (telnetParams != null) ? telnetParams.TelnetNewLine : true/*default*/;
     _telnetSocket = new TelnetSocket(this, s, _telnetReceiver, telnetNewLine);
     _rawSocket = s;
     _socket = _telnetSocket;
     _terminalOutput = _telnetSocket;
 }
コード例 #9
0
 public TelnetReceiver(TelnetTerminalConnection parent, TelnetNegotiator negotiator)
 {
     _parent = parent;
     _negotiator = negotiator;
     _localdata = new ByteDataFragment();
 }
コード例 #10
0
ファイル: LocalShell.cs プロジェクト: saitoha/poderosa
            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);
            }