예제 #1
0
        //profに対応したSSHConnectionを返す。接続がなければparentを親に認証ダイアログを出して認証する
        public ISSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent)
        {
            //ホスト名とアカウントのペアからコネクションを共有する仕組みがあるとよいかも
            ISSHConnection c = _profileToConnection[prof] as ISSHConnection;

            if (c != null)
            {
                return(c);
            }

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);

            if (dlg.ShowDialog(parent) == DialogResult.OK)
            {
                c = dlg.Result.Connection;
                try {
                    dlg.Result.WaitRequest();
                }
                catch (Exception ex) {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return(null);
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return(c);
        }
예제 #2
0
        //profに対応したSSHConnectionを返す。接続がなければparentを親に認証ダイアログを出して認証する
        public SSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent) {
            //ホスト名とアカウントのペアからコネクションを共有する仕組みがあるとよいかも
            SSHConnection c = (SSHConnection)_profileToConnection[prof];
            if (c != null)
                return c;

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);
            DialogResult result = DialogResult.No;

            //認証設定がない場合はそのまま接続
            if (!prof.Auth)
            {
                // 疑似的にOKボタン押下
                dlg.OnOK(null, EventArgs.Empty);
                // 非同期で接続が行われるので1秒待つ
                System.Threading.Thread.Sleep(1000);
                result = DialogResult.OK;
            }
            // 認証が必要な場合
            else
            {
                // ダイアログによるユーザ認証
                result = dlg.ShowDialog(parent);
            }

            if (result == DialogResult.OK)
            {
                c = dlg.Result.Connection;
                try
                {
                    dlg.Result.WaitRequest();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return null;
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return c;
        }
예제 #3
0
        //profに対応したSSHConnectionを返す。接続がなければparentを親に認証ダイアログを出して認証する
        public SSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent) {
            //ホスト名とアカウントのペアからコネクションを共有する仕組みがあるとよいかも
            SSHConnection c = (SSHConnection)_profileToConnection[prof];
            if (c != null)
                return c;

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);
            if (dlg.ShowDialog(parent) == DialogResult.OK) {
                c = dlg.Result.Connection;
                try {
                    dlg.Result.WaitRequest();
                }
                catch (Exception ex) {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return null;
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return c;
        }
예제 #4
0
        //prof�ɑΉ�����SSHConnection��Ԃ��B�ڑ����Ȃ����parent��e�ɔF�؃_�C�A���O��o���ĔF�؂���
        public SSHConnection GetOrCreateConnection(ChannelProfile prof, Form parent)
        {
            //�z�X�g���ƃA�J�E���g�̃y�A����R�l�N�V��������L����d�g�݂�����Ƃ悢����
            SSHConnection c = (SSHConnection)_profileToConnection[prof];
            if(c!=null) return c;

            SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(prof);
            if(Util.ShowModalDialog(parent, dlg)==DialogResult.OK) {
                c = dlg.Result.Connection;
                try {
                    dlg.Result.WaitRequest();
                }
                catch(Exception ex) {
                    Debug.WriteLine(ex.StackTrace);
                    Util.Warning(parent, ex.Message);
                    c.Close();
                    return null;
                }
                _profileToConnection[prof] = c;
                Env.MainForm.RefreshProfileStatus(prof);
            }

            return c;
        }