Inheritance: TCPTerminalConnection
Exemple #1
0
 public TelnetSocket(TelnetTerminalConnection parent, IPoderosaSocket socket, TelnetReceiver receiver, bool telnetNewLine)
 {
     _parent        = parent;
     _callback      = receiver;
     _socket        = socket;
     _telnetNewLine = telnetNewLine;
 }
Exemple #2
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;
        }
Exemple #3
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;
            }
Exemple #4
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;
 }
Exemple #5
0
 public TelnetReceiver(TelnetTerminalConnection parent, TelnetNegotiator negotiator)
 {
     _parent     = parent;
     _negotiator = negotiator;
     _localdata  = new ByteDataFragment();
 }
            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);
            }
 public TelnetSocket(TelnetTerminalConnection parent, IPoderosaSocket socket, TelnetReceiver receiver, bool telnetNewLine)
 {
     _parent = parent;
     _callback = receiver;
     _socket = socket;
     _telnetNewLine = telnetNewLine;
 }
 public TelnetReceiver(TelnetTerminalConnection parent, TelnetNegotiator negotiator)
 {
     _parent = parent;
     _negotiator = negotiator;
     _localdata = new ByteDataFragment();
 }
Exemple #9
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);
            }
 public TelnetSocket(TelnetTerminalConnection parent, IPoderosaSocket socket, TelnetReceiver receiver)
 {
     _parent   = parent;
     _callback = receiver;
     _socket   = socket;
 }