private void OpenInputPassphraseDialog(IPoderosaForm form, AgentPrivateKey key) { Debug.Assert(!form.AsForm().InvokeRequired); InputPassphraseDialog dlg = new InputPassphraseDialog(key); dlg.ShowDialog(form.AsForm()); }
private void CleanupDocument(DocumentHost dh) { IPoderosaForm owner_window = ViewToForm(dh.LastAttachedView); IPoderosaView visible_view = dh.CurrentView; bool was_active = false; if (visible_view != null) { was_active = visible_view.AsControl().Focused; dh.DetachView(); FireDocViewRelationChange(); } if (owner_window != null) { NotifyRemove(owner_window, dh.Document); } dh.SessionHost.CloseDocument(dh.Document); _documentMap.Remove(dh.Document); //閉じたドキュメントのビューが見えていた場合は、その位置の別のドキュメントを見せる //TODO ウィンドウを閉じるときはこの処理は不要 if (visible_view != null && visible_view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow)) != null) { ShowBackgroundDocument(visible_view); if (was_active && visible_view.Document != null) { ActivateDocument(visible_view.Document, ActivateReason.InternalAction); } } }
public SSH2UserAuthKey[] GetAvailableSSH2UserAuthKeys() { if (_loadRequiredFlag) { LoadKeys(); } IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow; List <SSH2UserAuthKey> keys = new List <SSH2UserAuthKey>(); foreach (AgentPrivateKey key in _keys) { if (key.Status == PrivateKeyStatus.OK) { keys.Add(key.Key); //有効であれば追加 } else if (key.Status != PrivateKeyStatus.FileError) //ファイルエラーだったら再試行はしない { if (key.GuessValidKeyFileOrWarn(form)) { form.AsForm().Invoke(new InputPassphraseDelegate(OpenInputPassphraseDialog), form, key); if (key.Status == PrivateKeyStatus.OK) { keys.Add(key.Key); } } } } return(keys.ToArray()); }
private bool AskUserReliability(ISSHHostKeyInformationProvider info, string keystr, string message_text_id) { //比較結果に基づく処理 IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow; Debug.Assert(form.AsForm().InvokeRequired); //別スレッドで実行しているはず //fingerprint StringBuilder bld = new StringBuilder(); byte[] fingerprint = info.HostKeyFingerPrint; for (int i = 0; i < fingerprint.Length; i++) { if (bld.Length > 0) { bld.Append(':'); } bld.Append(fingerprint[i].ToString("x2")); } string message = String.Format("ssh hostkey fingerprint {0}\n\n{1}", bld.ToString(), UsabilityPlugin.Strings.GetString(message_text_id)); if (form.AskUserYesNo(message) == DialogResult.Yes) { Update(info, keystr, true); return(true); } else { return(false); } }
private bool InternalGuessValidKeyFileOrWarn(IPoderosaForm pf, Form wf) { if (_status == PrivateKeyStatus.OK || _status == PrivateKeyStatus.PassphraseRequired) { return(true); } StringResource sr = SSHUtilPlugin.Instance.Strings; try { if (!File.Exists(_filename)) { Warning(pf, wf, String.Format(sr.GetString("Message.KeyAgent.FileNotExist"), _filename)); _status = PrivateKeyStatus.FileError; return(false); } } catch (Exception ex) { Warning(pf, wf, ex.Message); _status = PrivateKeyStatus.FileError; return(false); } _status = PrivateKeyStatus.PassphraseRequired; return(true); }
public TerminalView(IPoderosaForm parent, TerminalControl control) { _parent = parent; _control = control; _copyCommand = TerminalSessionsPlugin.Instance.WindowManager.SelectionService.DefaultCopyCommand; _pasteCommand = TerminalSessionsPlugin.Instance.GetPasteCommand(); control.Tag = this; }
public void AttachDocumentAndView(IPoderosaDocument document, IPoderosaView view) { view = AdjustToOuterView(view); DocumentHost dh = FindDocumentHost(document); Debug.Assert(dh != null, "the document must be registered by calling ISessionHost#RegisterDocument"); if (view.Document == document) { Debug.Assert(dh.CurrentView == view); return; //何もしない } IPoderosaView previous_view = dh.CurrentView; //関連づけを指定するドキュメントがもともと見えていたビュー IPoderosaForm last_window = ViewToForm(dh.LastAttachedView); //もともとの所有ウィンドウ。初めてのAttachではnullであることにちゅうい //現在の関連を一旦切る if (previous_view != null) { Debug.WriteLineIf(DebugOpt.DumpDocumentRelation, "Detach Prev View " + ViewName(previous_view)); dh.DetachView(); } Debug.Assert(dh.CurrentView == null); //接続先にドキュメントが存在していればそれを切り離す IPoderosaDocument existing_doc = view.Document; if (existing_doc != null) //対象のビューに古いのがひっついていたら外す { DocumentHost eh = FindDocumentHost(existing_doc); Debug.Assert(eh.CurrentView == view); Debug.WriteLineIf(DebugOpt.DumpDocumentRelation, String.Format("Detach Destination View doc={0} view={1}", existing_doc.GetType().Name, ViewName(view))); eh.DetachView(); } //新規の接続 Debug.Assert(view.Document == null && dh.CurrentView == null); //Attach準備ができていること確認 dh.AttachView(view); //移動することで新規に見えるようになるドキュメントを探索 if (previous_view != null && previous_view != view) { DocumentHost new_visible_doc = ShowBackgroundDocument(previous_view); Debug.Assert(new_visible_doc != dh); } //ドキュメントを保有するウィンドウが変化したら通知。初回Attachではlast_mainwindow==nullであることに注意 if (last_window != view.ParentForm) { if (last_window != null) { NotifyRemove(last_window, document); } NotifyAdd(ViewToForm(view), document); } FireDocViewRelationChange(); }
private void NotifyAdd(IPoderosaForm form, IPoderosaDocument document) { IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { window.DocumentTabFeature.Add(document); } }
public PrepareCloseResult PrepareCloseSession() { //閉じるのをキャンセルするテスト IPoderosaForm f = _host.GetParentFormFor(_document); DialogResult r = f.AskUserYesNo("Close?"); return(r == DialogResult.Yes? PrepareCloseResult.TerminateSession : PrepareCloseResult.Cancel); //return PrepareCloseResult.TerminateSession; }
private void Warning(IPoderosaForm pf, Form wf, string msg) { if (pf != null) { pf.Warning(msg); } else { GUtil.Warning(wf, msg); } }
//接続先のSocketを準備して返す。失敗すればparentを親にしてエラーを表示し、nullを返す。 internal static ITerminalConnection PrepareSocket(IPoderosaForm parent, ICygwinParameter param) { try { return new Connector(param).Connect(); } catch (Exception ex) { //string key = IsCygwin(param)? "Message.CygwinUtil.FailedToConnect" : "Message.SFUUtil.FailedToConnect"; string key = "Message.CygwinUtil.FailedToConnect"; parent.Warning(PEnv.Strings.GetString(key) + ex.Message); return null; } }
public PrepareCloseResult PrepareCloseDocument(IPoderosaDocument document) { Debug.Assert(document == _document); //閉じるのをキャンセルするテスト IPoderosaForm f = _host.GetParentFormFor(document); DialogResult r = f.AskUserYesNo("Close?"); return(r == DialogResult.Yes? PrepareCloseResult.ContinueSession : PrepareCloseResult.Cancel); //return PrepareCloseResult.TerminateSession; }
//接続先のSocketを準備して返す。失敗すればparentを親にしてエラーを表示し、nullを返す。 internal static ITerminalConnection PrepareSocket(IPoderosaForm parent, ICygwinParameter param) { try { return(new Connector(param).Connect()); } catch (Exception ex) { //string key = IsCygwin(param)? "Message.CygwinUtil.FailedToConnect" : "Message.SFUUtil.FailedToConnect"; string key = "Message.CygwinUtil.FailedToConnect"; parent.Warning(PEnv.Strings.GetString(key) + ex.Message); return(null); } }
/// <summary> /// <ja>プラグイン実行</ja> /// </summary> public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { IPoderosaView view; ITerminalSession session; // ビュー/セッション取得 if (!GetViewAndSession(target, out view, out session)) { return(CommandResult.Ignored); } // クリップボードデータ取得 var clipboardData = Clipboard.GetDataObject(); if (!clipboardData.GetDataPresent("Text")) { return(CommandResult.Ignored); } string data = (string)clipboardData.GetData("Text"); if (data == null) { return(CommandResult.Ignored); } // オプション取得 ExtendPasteOptions opt = ExtendPastePlugin.Instance.ExtendPasteOptionSupplier.OriginalOptions; // 改行存在チェック bool newLineFlg = ((data.IndexOfAny(new char[] { '\r', '\n' }) >= 0) || (data.Contains(Environment.NewLine))) ? true : false; // セッション名取得 //ITerminalSession sessionName = (ITerminalSession)view.Document.OwnerSession.GetAdapter(typeof(ITerminalSession)); // 確認ダイアログ表示 if (((opt.UseAction == UseAction.NewLine) && (newLineFlg)) || (opt.UseAction == UseAction.Always)) { IPoderosaForm poderosaForm = view.ParentForm; ExtendPasteDialog Form = new ExtendPasteDialog(data, newLineFlg, session.Caption); if (Form.ShowDialog(poderosaForm.AsForm()) != DialogResult.OK) { return(CommandResult.Ignored); } } // クリップボードデータ送信 StringReader reader = new StringReader(data); TerminalTransmission output = session.TerminalTransmission; output.SendTextStream(reader, data[data.Length - 1] == '\n', true); return(CommandResult.Succeeded); }
private IPoderosaDocument ViewToActiveDocument(IPoderosaView view) { IPoderosaForm form = view.ParentForm; IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { return(window.DocumentTabFeature.ActiveDocument); } else { return(view.Document); } }
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { IPoderosaView view; ITerminalSession session; if (!GetViewAndSession(target, out view, out session)) { return(CommandResult.Ignored); } var clipboardData = Clipboard.GetDataObject(); if (!clipboardData.GetDataPresent("Text")) { return(CommandResult.Ignored); } string data = clipboardData.GetData("Text") as string; if (data == null) { return(CommandResult.Ignored); } ITerminalEmulatorOptions options = TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions; if (options.AlertOnPasteNewLineChar) { // Data will be split by CR, LF, CRLF or Environment.NewLine by TextReader.ReadLine, // So we check the data about CR, LF and Environment.NewLine. if (data.IndexOfAny(new char[] { '\r', '\n' }) >= 0 || data.Contains(Environment.NewLine)) { IPoderosaForm form = view.ParentForm; if (form != null) { DialogResult res = form.AskUserYesNo(TEnv.Strings.GetString("Message.AskPasteNewLineChar")); if (res != DialogResult.Yes) { return(CommandResult.Ignored); } } } } StringReader reader = new StringReader(data); TerminalTransmission output = session.TerminalTransmission; output.SendTextStream(reader, data[data.Length - 1] == '\n'); return(CommandResult.Succeeded); }
public void MouseRightButton(TabKey key) { IPoderosaDocument doc = KeyToDocument(key); IPoderosaContextMenuPoint ctx_pt = (IPoderosaContextMenuPoint)doc.GetAdapter(typeof(IPoderosaContextMenuPoint)); //メニューが取れない場合は無視 if (ctx_pt == null || ctx_pt.ContextMenu == null || ctx_pt.ContextMenu.Length == 0) { return; } IPoderosaForm f = (IPoderosaForm)_tabBarTable.ParentForm; f.ShowContextMenu(ctx_pt.ContextMenu, doc, Control.MousePosition, ContextMenuFlags.None); }
private void NotifyRemove(IPoderosaForm form, IPoderosaDocument document) { IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { IPoderosaDocument former = window.DocumentTabFeature.ActiveDocument; window.DocumentTabFeature.Remove(document); //TODO アクティブなのを記憶する場所を変えることでタブへの通知を先にする制約から解放される if (former == document) { foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners) { listener.OnDocumentDeactivated(window); } } } }
private void ShowMenu() { TerminalControl tc = _terminal.TerminalHost.TerminalControl; Debug.Assert(tc != null); TerminalDocument doc = _terminal.GetDocument(); SizeF pitch = tc.GetRenderProfile().Pitch; Point popup = new Point((int)(doc.CaretColumn * pitch.Width), (int)((doc.CurrentLineNumber - doc.TopLineNumber + 1) * pitch.Height)); IPoderosaForm f = tc.FindForm() as IPoderosaForm; Debug.Assert(f != null); //EXTPにしてもいいんだけど f.ShowContextMenu(new IPoderosaMenuGroup[] { new PoderosaMenuGroupImpl(CreatePopupMenuItems()) }, (ICommandTarget)tc.GetAdapter(typeof(ICommandTarget)), tc.PointToScreen(popup), ContextMenuFlags.SelectFirstItem); }
private void NotifyActivation(IPoderosaForm form, IPoderosaDocument document, ActivateReason reason) { Debug.Assert(document != null); IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { //Tabへの通知。TabClickのときはTabが自前で処理してるのでOK if (reason != ActivateReason.TabClick) { window.DocumentTabFeature.Activate(document); } //listenerへの通知 foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners) { listener.OnDocumentActivated(window, document); } } }
public void RefreshDocumentStatus(IPoderosaDocument document) { DocumentHost dh = FindDocumentHost(document); Debug.Assert(dh != null); IPoderosaForm f = ViewToForm(dh.LastAttachedView); //ちょっと汚い分岐 IPoderosaMainWindow mw = (IPoderosaMainWindow)f.GetAdapter(typeof(IPoderosaMainWindow)); if (mw != null) { mw.DocumentTabFeature.Update(document); } else { ((IPoderosaPopupWindow)f.GetAdapter(typeof(IPoderosaPopupWindow))).UpdateStatus(); } }
//ビューにフォーカスをセットした状態にする。ポップアップウィンドウの場合、まだウィンドウがロードされていないケースもあるのでそこに注意! private void SetFocusToView(IPoderosaView view) { IPoderosaForm form = view.ParentForm; IPoderosaPopupWindow popup = (IPoderosaPopupWindow)form.GetAdapter(typeof(IPoderosaPopupWindow)); if (popup != null) { if (!popup.AsForm().Visible) { popup.UpdateStatus(); popup.AsForm().Show(); } } if (!view.AsControl().Focused) { view.AsControl().Focus(); //既にウィンドウは見えている } }
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { if (!CanExecute(target)) { return(CommandResult.Ignored); } TerminalTransmission output = GetSession().TerminalTransmission; //string data = Clipboard.GetDataObject().GetData("Text") as string; string data = Clipboard.GetText(); if (data == null || data.Length == 0) { return(CommandResult.Ignored); } ITerminalEmulatorOptions options = TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions; if (options.AlertOnPasteNewLineChar) { // Data will be split by CR, LF, CRLF or Environment.NewLine by TextReader.ReadLine, // So we check the data about CR, LF and Environment.NewLine. if (data.IndexOfAny(new char[] { '\r', '\n' }) >= 0 || data.Contains(Environment.NewLine)) { IPoderosaView view = (IPoderosaView)_control.GetAdapter(typeof(IPoderosaView)); IPoderosaForm form = view.ParentForm; if (form != null) { DialogResult res = form.AskUserYesNo(TEnv.Strings.GetString("Message.AskPasteNewLineChar")); if (res != DialogResult.Yes) { return(CommandResult.Ignored); } } } } //TODO 長文のときにダイアログを出して中途キャンセル可能に StringReader reader = new StringReader(data); output.SendTextStream(reader, data[data.Length - 1] == '\n'); return(CommandResult.Succeeded); }
private bool InternalGuessValidKeyFileOrWarn(IPoderosaForm pf, Form wf) { if (_status == PrivateKeyStatus.OK || _status == PrivateKeyStatus.PassphraseRequired) return true; StringResource sr = SSHUtilPlugin.Instance.Strings; try { if (!File.Exists(_filename)) { Warning(pf, wf, String.Format(sr.GetString("Message.KeyAgent.FileNotExist"), _filename)); _status = PrivateKeyStatus.FileError; return false; } } catch (Exception ex) { Warning(pf, wf, ex.Message); _status = PrivateKeyStatus.FileError; return false; } _status = PrivateKeyStatus.PassphraseRequired; return true; }
private void NotifyAdd(IPoderosaForm form, IPoderosaDocument document) { IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) window.DocumentTabFeature.Add(document); }
private void NotifyActivation(IPoderosaForm form, IPoderosaDocument document, ActivateReason reason) { Debug.Assert(document != null); IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { //Tabへの通知。TabClickのときはTabが自前で処理してるのでOK if (reason != ActivateReason.TabClick) window.DocumentTabFeature.Activate(document); //listenerへの通知 foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners) listener.OnDocumentActivated(window, document); } }
public IPoderosaView CreateNew(IPoderosaForm parent) { return new PoderosaLogViewControl(parent); }
public SilentClient(IPoderosaForm form) { _event = new AutoResetEvent(false); _form = form; }
//パスフレーズ入力まではいけそうかどうかを判定し、statusも更新する public bool GuessValidKeyFileOrWarn(IPoderosaForm form) //別スレッドから呼ぶ版 { return(InternalGuessValidKeyFileOrWarn(form, null)); }
private void OpenInputPassphraseDialog(IPoderosaForm form, AgentPrivateKey key) { Debug.Assert(!form.AsForm().InvokeRequired); InputPassphraseDialog dlg = new InputPassphraseDialog(key); dlg.ShowDialog(form.AsForm()); }
public IPoderosaView CreateNew(IPoderosaForm parent) { return new DummySession.ViewBridge(); }
private void NotifyActivation(IPoderosaForm form, IPoderosaDocument document, ActivateReason reason) { Debug.Assert(document != null); IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { //Tab�ւ̒ʒm�BTabClick�̂Ƃ���Tab�����O�ŏ������Ă�̂�OK if (reason != ActivateReason.TabClick) window.DocumentTabFeature.Activate(document); //listener�ւ̒ʒm foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners) listener.OnDocumentActivated(window, document); } }
public SilentClient(IPoderosaForm form) { _event = new AutoResetEvent(false); _form = form; }
public IPoderosaView CreateNew(IPoderosaForm parent) { return(new CommandResultViewerControl(parent)); }
public CommandResultViewerControl(IPoderosaForm form) { _form = form; _caret.Enabled = false; _caret.Blink = false; }
private void NotifyRemove(IPoderosaForm form, IPoderosaDocument document) { IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { IPoderosaDocument former = window.DocumentTabFeature.ActiveDocument; window.DocumentTabFeature.Remove(document); //TODO アクティブなのを記憶する場所を変えることでタブへの通知を先にする制約から解放される if (former == document) { foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners) listener.OnDocumentDeactivated(window); } } }
//cygwinの同期的接続 public static ITerminalConnection CreateNewLocalShellConnection(IPoderosaForm form, ICygwinParameter param) { return LocalShellUtil.PrepareSocket(form, param); }
//パスフレーズ入力まではいけそうかどうかを判定し、statusも更新する public bool GuessValidKeyFileOrWarn(IPoderosaForm form) { //別スレッドから呼ぶ版 return InternalGuessValidKeyFileOrWarn(form, null); }
public IPoderosaView CreateNew(IPoderosaForm parent) { return(new TerminalView(parent, new TerminalControl())); }
public IPoderosaView CreateNew(IPoderosaForm parent) { return new PoderosaLogViewControl(parent); }
private void NotifyRemove(IPoderosaForm form, IPoderosaDocument document) { IPoderosaMainWindow window = (IPoderosaMainWindow)form.GetAdapter(typeof(IPoderosaMainWindow)); if (window != null) { IPoderosaDocument former = window.DocumentTabFeature.ActiveDocument; window.DocumentTabFeature.Remove(document); //TODO �A�N�e�B�u�Ȃ̂�L������ꏊ��ς��邱�ƂŃ^�u�ւ̒ʒm���ɂ��鐧��������� if (former == document) { foreach (IActiveDocumentChangeListener listener in _activeDocumentChangeListeners) listener.OnDocumentDeactivated(window); } } }
public PoderosaLogViewControl(IPoderosaForm form) { _form = form; _caret.Enabled = false; _caret.Blink = false; }
public PoderosaLogViewControl(IPoderosaForm form) { _form = form; _caret.Enabled = false; _caret.Blink = false; }
//�p�X�t���[�Y���͂܂ł͂����������ǂ����肵�Astatus��X�V���� public bool GuessValidKeyFileOrWarn(IPoderosaForm form) { //�ʃX���b�h����ĂԔ� return InternalGuessValidKeyFileOrWarn(form, null); }
private void Warning(IPoderosaForm pf, Form wf, string msg) { if (pf != null) pf.Warning(msg); else GUtil.Warning(wf, msg); }
public ISynchronizedConnector CreateFormBasedSynchronozedConnector(IPoderosaForm form) { return(new SilentClient(form)); }
public CommandResultViewerControl(IPoderosaForm form) { _form = form; _caret.Enabled = false; _caret.Blink = false; }
public IPoderosaView CreateNew(IPoderosaForm parent) { return new CommandResultViewerControl(parent); }
public ISynchronizedConnector CreateFormBasedSynchronozedConnector(IPoderosaForm form) { return new SilentClient(form); }