Exemple #1
0
        public void OnOK(object sender, System.EventArgs e)
        {
            this.DialogResult = DialogResult.None;
            TCPTerminalParam param = ValidateContent();

            if (param == null)
            {
                return;                          //パラメータに誤りがあれば即脱出
            }
            _loginButton.Enabled  = false;
            _cancelButton.Enabled = false;
            this.Cursor           = Cursors.WaitCursor;
            this.Text             = GApp.Strings.GetString("Caption.LoginDialog.Connecting");
            _savedHWND            = this.Handle;

            HostKeyCheckCallback checker = null;

            if (param.IsSSH)
            {
                checker = new HostKeyCheckCallback(new HostKeyChecker(this, (SSHTerminalParam)param).CheckHostKeyCallback);
            }

            _connector = CommunicationUtil.StartNewConnection(this, param, _passphraseBox.Text, checker);
            if (_connector == null)
            {
                ClearConnectingState();
            }
        }
 private void ClearConnectingState()
 {
     _loginButton.Enabled  = true;
     _cancelButton.Enabled = true;
     this.Cursor           = Cursors.Default;
     this.Text             = GApp.Strings.GetString("Form.SSHShortcutLoginDialog.Text");
     _connector            = null;
 }
        public void Connect()
        {
            #region old stuff

            /*
             * Poderosa.ConnectionParam.LogType logType = Poderosa.ConnectionParam.LogType.Default;
             * string file = null;
             * if (this.TerminalPane.Connection != null)
             * {
             *  logType = this.TerminalPane.Connection.LogType;
             *  file = this.TerminalPane.Connection.LogPath;
             *  //GApp.GetConnectionCommandTarget().Close();
             *  this.TerminalPane.Connection.Close();
             *  this.TerminalPane.Detach();
             * }
             *
             *
             * SSHTerminalParam p = new SSHTerminalParam((Poderosa.ConnectionParam.ConnectionMethod)this.Method, this.Host, this.UserName, this.Password);
             *
             * GApp.GlobalCommandTarget.SilentNewConnection(p);
             *
             *
             * if (file != null)
             *  this.SetLog((LogType) logType, file, true);
             */
            #endregion

            // Save old log info in case this is a reconnect
            Poderosa.ConnectionParam.LogType logType = Poderosa.ConnectionParam.LogType.Default;
            string file = null;
            if (this.TerminalPane.Connection != null)
            {
                logType = this.TerminalPane.Connection.LogType;
                file    = this.TerminalPane.Connection.LogPath;
                //GApp.GetConnectionCommandTarget().Close();
                this.TerminalPane.Connection.Close();
                this.TerminalPane.Detach();
            }

            try
            {
                TCPTerminalParam  connParam      = null;
                SocketWithTimeout swt            = null;
                CommunicationUtil.SilentClient s = new CommunicationUtil.SilentClient();
                Size sz = this.Size;

                if (Method == ConnectionMethod.Telnet)
                {
                    connParam               = new TelnetTerminalParam(this.Host);
                    connParam.Encoding      = EncodingType.ISO8859_1;
                    connParam.Port          = _port;
                    connParam.RenderProfile = new RenderProfile();
                    connParam.TerminalType  = TerminalType.XTerm;

                    swt = new TelnetConnector((TelnetTerminalParam)connParam, sz);
                }
                else if (Method == ConnectionMethod.SSH1 || Method == ConnectionMethod.SSH2)
                {
                    connParam = new SSHTerminalParam((Poderosa.ConnectionParam.ConnectionMethod) this.Method, this.Host, this.UserName, this.Password);
                    ((SSHTerminalParam)connParam).AuthType     = this.AuthType;
                    ((SSHTerminalParam)connParam).IdentityFile = this.IdentifyFile;
                    connParam.Encoding      = EncodingType.ISO8859_1;
                    connParam.Port          = _port;
                    connParam.RenderProfile = new RenderProfile();
                    connParam.TerminalType  = TerminalType.XTerm;

                    swt = new SSHConnector((SSHTerminalParam)connParam, sz, ((SSHTerminalParam)connParam).Passphrase, (HostKeyCheckCallback)null);
                }

                swt.AsyncConnect(s, connParam.Host, connParam.Port);

                ConnectionTag ct = s.Wait(swt);

                this.TerminalPane.FakeVisible = true;

                this.TerminalPane.Attach(ct);
                ct.Receiver.Listen();

                //-------------------------------------------------------------
                if (file != null)
                {
                    this.SetLog((LogType)logType, file, true);
                }
                this.TerminalPane.ConnectionTag.RenderProfile = new RenderProfile();
                this.SetPaneColors(Color.LightBlue, Color.Black);
            }
            catch
            {
                //MessageBox.Show(e.Message, "Connection Error");
                return;
            }
        }
        private void OnOK(object sender, System.EventArgs e)
        {
            this.DialogResult = DialogResult.None;
            if(ValidateContent()==null) return;  //�p�����[�^�Ɍ�肪����Α��E�o

            _loginButton.Enabled = false;
            _cancelButton.Enabled = false;
            this.Cursor = Cursors.WaitCursor;
            this.Text = Env.Strings.GetString("Caption.SSHShortcutLoginDialog.Connecting");

            //HostKeyChecker checker = new HostKeyChecker(this, param);
            _savedHWND = this.Handle;
            _connector = ConnectionManager.StartNewConnection(this, _profile, _passphraseBox.Text, null/*new HostKeyCheckCallback(checker.CheckHostKeyCallback)*/);
            if(_connector==null) ClearConnectingState();
        }
 private void ClearConnectingState()
 {
     _loginButton.Enabled = true;
     _cancelButton.Enabled = true;
     this.Cursor = Cursors.Default;
     this.Text = Env.Strings.GetString("Form.SSHShortcutLoginDialog.Text");
     _connector = null;
 }