[Ttssh2-commit] [7626] パスフレーズエディットボックスで制御コード使用フラグ、パスフレーズ表示フラグ変数をグローバルにおかないようにした

scmno****@osdn***** scmno****@osdn*****
2019年 4月 26日 (金) 01:37:42 JST


Revision: 7626
          https://osdn.net/projects/ttssh2/scm/svn/commits/7626
Author:   zmatsuo
Date:     2019-04-26 01:37:42 +0900 (Fri, 26 Apr 2019)
Log Message:
-----------
パスフレーズエディットボックスで制御コード使用フラグ、パスフレーズ表示フラグ変数をグローバルにおかないようにした

Modified Paths:
--------------
    branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c
    branches/ssh_auth_dialog/ttssh2/ttxssh/auth.h
    branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.c

-------------- next part --------------
Modified: branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c
===================================================================
--- branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c	2019-04-25 16:37:25 UTC (rev 7625)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c	2019-04-25 16:37:42 UTC (rev 7626)
@@ -81,15 +81,22 @@
 	IDC_SSHUSERHOSTS, IDC_SSHUSETIS, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, IDC_SSHUSEPAGEANT, -1
 };
-static BOOL UseControlChar = TRUE;
-static BOOL ShowPassPhrase = FALSE;
 
 typedef struct {
 	WNDPROC ProcOrg;
 	PTInstVar pvar;
 	TipWin *tipwin;
+	BOOL *UseControlChar;
 } TPasswordControlData;
 
+static void password_wnd_proc_close_tooltip(TPasswordControlData *data)
+{
+	if (data->tipwin != NULL) {
+		TipWinDestroy(data->tipwin);
+		data->tipwin = NULL;
+	}
+}
+
 static LRESULT CALLBACK password_wnd_proc(HWND control, UINT msg,
 										  WPARAM wParam, LPARAM lParam)
 {
@@ -97,11 +104,9 @@
 	TPasswordControlData *data = (TPasswordControlData *)GetWindowLongPtr(control, GWLP_USERDATA);
 	switch (msg) {
 	case WM_CHAR:
-		if (!UseControlChar) {
-			// \x90\xA7\x8C䕶\x8E\x9A\x82͎g\x97p\x82\xB5\x82Ȃ\xA2
-			break;
-		}
-		if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) {
+		if ((data->UseControlChar == NULL || *data->UseControlChar == TRUE) &&
+			(GetKeyState(VK_CONTROL) & 0x8000) != 0)
+		{	// \x90\xA7\x8C䕶\x8E\x9A\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9 && CTRL\x83L\x81[\x82\xAA\x89\x9F\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9
 			TCHAR chars[] = { (TCHAR) wParam, 0 };
 
 			SendMessage(control, EM_REPLACESEL, (WPARAM) TRUE,
@@ -125,17 +130,11 @@
 
 			return 0;
 		} else {
-			if (data->tipwin != NULL) {
-				TipWinDestroy(data->tipwin);
-				data->tipwin = NULL;
-			}
+			password_wnd_proc_close_tooltip(data);
 		}
 		break;
 	case WM_KILLFOCUS:
-		if (data->tipwin != NULL) {
-			TipWinDestroy(data->tipwin);
-			data->tipwin = NULL;
-		}
+		password_wnd_proc_close_tooltip(data);
 		break;
 	}
 
@@ -144,10 +143,7 @@
 
 	if (msg == WM_NCDESTROY) {
 		SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR)data->ProcOrg);
-		if (data->tipwin != NULL) {
-			TipWinDestroy(data->tipwin);
-			data->tipwin = NULL;
-		}
+		password_wnd_proc_close_tooltip(data);
 		free(data);
 	}
 
@@ -154,7 +150,7 @@
 	return result;
 }
 
-void init_password_control(PTInstVar pvar, HWND dlg, int item)
+void init_password_control(PTInstVar pvar, HWND dlg, int item, BOOL *UseControlChar)
 {
 	HWND passwordControl = GetDlgItem(dlg, item);
 	TPasswordControlData *data = (TPasswordControlData *)malloc(sizeof(TPasswordControlData));
@@ -161,6 +157,7 @@
 	data->ProcOrg = (WNDPROC)GetWindowLongPtr(passwordControl, GWLP_WNDPROC);
 	data->pvar = pvar;
 	data->tipwin = NULL;
+	data->UseControlChar = UseControlChar;
 	SetWindowLongPtr(passwordControl, GWLP_WNDPROC, (LONG_PTR)password_wnd_proc);
 	SetWindowLongPtr(passwordControl, GWLP_USERDATA, (LONG_PTR)data);
 	SetFocus(passwordControl);
@@ -249,7 +246,7 @@
 	}
 }
 
-static void init_auth_dlg(PTInstVar pvar, HWND dlg)
+static void init_auth_dlg(PTInstVar pvar, HWND dlg, BOOL *UseControlChar)
 {
 	const static DlgTextInfo text_info[] = {
 		{ 0, "DLG_AUTH_TITLE" },
@@ -274,7 +271,7 @@
 	SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile);
 
 	init_auth_machine_banner(pvar, dlg);
-	init_password_control(pvar, dlg, IDC_SSHPASSWORD);
+	init_password_control(pvar, dlg, IDC_SSHPASSWORD, UseControlChar);
 
 	// \x94F\x8F؎\xB8\x94s\x8C\xE3\x82̓\x89\x83x\x83\x8B\x82\xF0\x8F\x91\x82\xAB\x8A\xB7\x82\xA6
 	if (pvar->auth_state.failed_method != SSH_AUTH_NONE) {
@@ -802,6 +799,8 @@
 	PTInstVar pvar;
 //	LOGFONT logfont;
 //	HFONT font;
+	static BOOL UseControlChar;
+	static BOOL ShowPassPhrase;
 
 	switch (msg) {
 	case WM_INITDIALOG:
@@ -809,7 +808,9 @@
 		pvar->auth_state.auth_dialog = dlg;
 		SetWindowLong(dlg, DWL_USER, lParam);
 
-		init_auth_dlg(pvar, dlg);
+		UseControlChar = TRUE;
+		ShowPassPhrase = FALSE;
+		init_auth_dlg(pvar, dlg, &UseControlChar);
 #if 0
 		font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
 		GetObject(font, sizeof(LOGFONT), &logfont);
@@ -840,7 +841,6 @@
 			DlgAuthFont = NULL;
 		}
 #endif
-		UseControlChar = TRUE;
 
 		// SSH2 autologin\x82\xAA\x97L\x8C\xF8\x82̏ꍇ\x82́A\x83^\x83C\x83}\x82\xF0\x8Ed\x8A|\x82\xAF\x82\xE9\x81B (2004.12.1 yutaka)
 		if (pvar->ssh2_autologin == 1) {
@@ -1054,22 +1054,22 @@
 			HMENU hMenu= CreatePopupMenu();
 			GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_CLIPBOARD",
 						uimsg, _countof(uimsg),
-						"Paste from clipboard",
+						"Paste from &clipboard",
 						pvar->ts->UILanguageFile);
 			AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
 			GetI18nStrT("ttssh", "DLG_AUTH_CLEAR_CLIPBOARD",
 						uimsg, _countof(uimsg),
-						"and clear clipboard",
+						"Paste from &clipboard and cl&ear clipboard",
 						pvar->ts->UILanguageFile);
 			AppendMenu(hMenu, MF_ENABLED | MF_STRING, 2, uimsg);
 			GetI18nStrT("ttssh", "DLG_AUTH_USE_CONTORL_CHARACTERS",
 						uimsg, _countof(uimsg),
-						"Use control characters",
+						"Use control charac&ters",
 						pvar->ts->UILanguageFile);
 			AppendMenu(hMenu, MF_ENABLED | MF_STRING  | (UseControlChar ? MFS_CHECKED : 0), 3, uimsg);
 			GetI18nStrT("ttssh", "DLG_AUTH_SHOW_PASSPHRASE",
 						uimsg, _countof(uimsg),
-						"Show passphrase",
+						"&Show passphrase",
 						pvar->ts->UILanguageFile);
 			AppendMenu(hMenu, MF_ENABLED | MF_STRING | (ShowPassPhrase ? MFS_CHECKED : 0), 4, uimsg);
 			RECT rect;
@@ -1137,7 +1137,7 @@
 			HMENU hMenu= CreatePopupMenu();
 			GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_WINDOWS_USERNAME",
 						uimsg, _countof(uimsg),
-						"Paste Windows username",
+						"Paste &Windows username",
 						pvar->ts->UILanguageFile);
 			AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
 			RECT rect;
@@ -1334,7 +1334,7 @@
 	SetDlgItemText(dlg, IDCANCEL, pvar->ts->UIMsg);
 
 	init_auth_machine_banner(pvar, dlg);
-	init_password_control(pvar, dlg, IDC_SSHPASSWORD);
+	init_password_control(pvar, dlg, IDC_SSHPASSWORD, NULL);
 
 	if (pvar->auth_state.TIS_prompt != NULL) {
 		if (strlen(pvar->auth_state.TIS_prompt) > 10000) {
@@ -1535,6 +1535,10 @@
 		CheckDlgButton(dlg, IDC_CHECKAUTH, TRUE);
 	}
 
+	if (pvar->session_settings.DefaultUserName[0] == 0) {
+		// \x8B\xF3\x82Ȃ̂Łu\x93\xFC\x97͂\xB5\x82Ȃ\xA2\x81v\x82ɂ\xB5\x82Ă\xA8\x82\xAD
+		pvar->session_settings.DefaultUserType = 0;
+	}
 	id = pvar->settings.DefaultUserType == 1 ? IDC_SSH_DEFAULTUSERNAME :
 		pvar->settings.DefaultUserType == 2 ? IDC_SSH_WINDOWS_USERNAME :
 		IDC_SSH_NO_USERNAME;

Modified: branches/ssh_auth_dialog/ttssh2/ttxssh/auth.h
===================================================================
--- branches/ssh_auth_dialog/ttssh2/ttxssh/auth.h	2019-04-25 16:37:25 UTC (rev 7625)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/auth.h	2019-04-25 16:37:42 UTC (rev 7626)
@@ -73,7 +73,7 @@
 void AUTH_notify_end_error(PTInstVar pvar);
 void AUTH_end(PTInstVar pvar);
 void destroy_malloced_string(char **str);
-void init_password_control(PTInstVar pvar, HWND dlg, int item);
+void init_password_control(PTInstVar pvar, HWND dlg, int item, BOOL *UseControlChar);
 
 #define AUTH_get_cur_cred(pvar) (&(pvar)->auth_state.cur_cred)
 

Modified: branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.c
===================================================================
--- branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.c	2019-04-25 16:37:25 UTC (rev 7625)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.c	2019-04-25 16:37:42 UTC (rev 7626)
@@ -4402,8 +4402,8 @@
 		}
 #endif
 
-		init_password_control(pvar, dlg, IDC_KEY_EDIT);
-		init_password_control(pvar, dlg, IDC_CONFIRM_EDIT);
+		init_password_control(pvar, dlg, IDC_KEY_EDIT, NULL);
+		init_password_control(pvar, dlg, IDC_CONFIRM_EDIT, NULL);
 
 		// default key type
 		SendMessage(GetDlgItem(dlg, IDC_RSA_TYPE), BM_SETCHECK, BST_CHECKED, 0);


Ttssh2-commit メーリングリストの案内