[Ttssh2-commit] [7520] ダイアログ上のチェックボックスの機能を一通り実装した

scmno****@osdn***** scmno****@osdn*****
2019年 3月 28日 (木) 00:24:33 JST


Revision: 7520
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7520
Author:   zmatsuo
Date:     2019-03-28 00:24:32 +0900 (Thu, 28 Mar 2019)
Log Message:
-----------
ダイアログ上のチェックボックスの機能を一通り実装した
- クリップボードからのペースト後にクリップボードをクリアする/しない
- パスフレーズで制御文字を使用する/しない
- パスフレーズを表示する/しない
- ユーザー名にwindowsのユーザー名をペーストするボタンを追加

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

-------------- next part --------------
Modified: branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c
===================================================================
--- branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c	2019-03-27 14:54:10 UTC (rev 7519)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c	2019-03-27 15:24:32 UTC (rev 7520)
@@ -37,6 +37,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <Lmcons.h>		// for UNLEN
 
 #include "resource.h"
 #include "keyfiles.h"
@@ -66,6 +67,7 @@
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, IDC_SSHUSEPAGEANT, -1
 };
 static TipWin *tipwin;
+static BOOL UseControlChar = TRUE;
 
 LRESULT CALLBACK password_wnd_proc(HWND control, UINT msg,
                                    WPARAM wParam, LPARAM lParam)
@@ -72,6 +74,10 @@
 {
 	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) {
 			TCHAR chars[] = { (TCHAR) wParam, 0 };
 
@@ -807,6 +813,9 @@
 		else {
 			DlgAuthFont = NULL;
 		}
+		UseControlChar = TRUE;
+		CheckDlgButton(dlg, IDC_USE_CONTROL_CHARACTER, UseControlChar ? BST_CHECKED : BST_UNCHECKED);
+		CheckDlgButton(dlg, IDC_CLEAR_CLIPBOARD, BST_UNCHECKED);
 
 		// 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) {
@@ -1013,16 +1022,64 @@
 			return TRUE;
 
 		case IDC_FROM_CLIPBOARD: {
-			char *clipboard = GetClipboardTextA(dlg, TRUE);
+			char *clipboard = GetClipboardTextA(dlg, IsDlgButtonChecked(dlg, IDC_CLEAR_CLIPBOARD) != BST_UNCHECKED);
 			if (clipboard != NULL) {
 				SetDlgItemTextA(dlg, IDC_SSHPASSWORD, clipboard);
 				free(clipboard);
-				SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDOK), TRUE);
+				SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
+				SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
 				return FALSE;
 			}
 			return TRUE;
 		}
 
+		case IDC_SHOW_PASSPHRASE: {
+			// \x95\x9A\x82\xB9\x8E\x9A on/off \x82\xF0\x90؂\xE8\x91ւ\xA6\x82\xE9
+			HWND hWnd = GetDlgItem(dlg, IDC_SSHPASSWORD);
+			static wchar_t password_char;
+			if (password_char == 0) {
+				wchar_t c = (wchar_t)SendMessage(hWnd, EM_GETPASSWORDCHAR, 0, 0);
+				password_char = c;
+			}
+			if (IsDlgButtonChecked(dlg, IDC_SHOW_PASSPHRASE) != BST_UNCHECKED) {
+				SendMessage(hWnd, EM_SETPASSWORDCHAR, 0, 0);
+			} else {
+#if !defined(UNICODE)
+				if (password_char < 0x100) {
+					SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
+				} else {
+					// TODO W\x8Cn\x92\xBC\x8CĂ\xD1 \x81\xAB\x82\xA4\x82܂\xAD\x82\xA2\x82\xA9\x82Ȃ\xA2
+					//SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
+					SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
+				}
+#else
+				SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
+#endif
+			}
+			//InvalidateRect(hWnd, NULL, TRUE);
+			SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
+			SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
+			return TRUE;
+		}
+
+		case IDC_FROM_GETUSERNAME: {
+			TCHAR user_name[UNLEN+1];
+			DWORD len = _countof(user_name);
+			BOOL r = GetUserName(user_name, &len);
+			if (r != 0) {
+				SetDlgItemText(dlg, IDC_SSHUSERNAME, user_name);
+				SendDlgItemMessage(dlg, IDC_SSHUSERNAME, EM_SETSEL, 0, -1);
+				SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHUSERNAME), TRUE);
+			}
+			return TRUE;
+		}
+
+		case IDC_USE_CONTROL_CHARACTER: {
+			UseControlChar =
+				(IsDlgButtonChecked(dlg, IDC_USE_CONTROL_CHARACTER) != BST_UNCHECKED) ?
+				TRUE : FALSE;
+			break;
+		}
 		default:
 			return FALSE;
 		}

Modified: branches/ssh_auth_dialog/ttssh2/ttxssh/resource.h
===================================================================
--- branches/ssh_auth_dialog/ttssh2/ttxssh/resource.h	2019-03-27 14:54:10 UTC (rev 7519)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/resource.h	2019-03-27 15:24:32 UTC (rev 7520)
@@ -230,12 +230,13 @@
 #define IDC_USE_CONTROL_CHARACTER       1234
 #define IDC_HOSTRSAFILENAMELABEL        1235
 #define IDC_RSAFILENAMELABEL            1236
+#define IDC_FROM_GETUSERNAME            1237
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        116
+#define _APS_NEXT_RESOURCE_VALUE        117
 #define _APS_NEXT_COMMAND_VALUE         40001
 #define _APS_NEXT_CONTROL_VALUE         1237
 #define _APS_NEXT_SYMED_VALUE           101

Modified: branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.rc
===================================================================
--- branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.rc	2019-03-27 14:54:10 UTC (rev 7519)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/ttxssh.rc	2019-03-27 15:24:32 UTC (rev 7520)
@@ -16,10 +16,8 @@
 // \x89p\x8C\xEA (\x95č\x91) resources
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 #pragma code_page(1252)
-#endif //_WIN32
 
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -48,7 +46,7 @@
     DEFPUSHBUTTON   "OK",IDOK,112,310,50,14
 END
 
-IDD_SSHAUTH DIALOGEX 0, 0, 331, 402
+IDD_SSHAUTH DIALOGEX 0, 0, 331, 415
 STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "SSH Authentication"
 FONT 8, "Tahoma", 0, 0, 0x0
@@ -57,36 +55,37 @@
     LTEXT           "Authentication required.",IDC_SSHAUTHBANNER2,6,16,319,10
     LTEXT           "User &name:",IDC_SSHUSERNAMELABEL,17,31,57,8
     EDITTEXT        IDC_SSHUSERNAME,28,44,145,12,ES_AUTOHSCROLL
-    LTEXT           "&Passphrase:",IDC_SSHPASSWORDCAPTION,17,62,56,8
-    EDITTEXT        IDC_SSHPASSWORD,28,76,145,12,ES_PASSWORD | ES_AUTOHSCROLL
-    PUSHBUTTON      "Paste from &clipboard",IDC_FROM_CLIPBOARD,28,92,80,14
+    PUSHBUTTON      "Paste &Windows Username",IDC_FROM_GETUSERNAME,28,60,95,14
+    LTEXT           "&Passphrase:",IDC_SSHPASSWORDCAPTION,17,77,56,8
+    EDITTEXT        IDC_SSHPASSWORD,28,91,145,12,ES_PASSWORD | ES_AUTOHSCROLL
+    PUSHBUTTON      "Paste from &clipboard",IDC_FROM_CLIPBOARD,28,107,80,14
     CONTROL         "Cl&ear clipboard after paste",IDC_CLEAR_CLIPBOARD,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,110,132,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,125,132,10
     CONTROL         "Use control characters",IDC_USE_CONTROL_CHARACTER,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,125,132,10
-    CONTROL         "&Show passphrase",IDC_SHOW_PASSPHRASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,140,132,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,140,132,10
+    CONTROL         "&Show passphrase",IDC_SHOW_PASSPHRASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,155,132,10
     CONTROL         "Remember password in &memory",IDC_REMEMBER_PASSWORD,
-                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,157,132,10
-    CONTROL         "F&orward agent",IDC_FORWARD_AGENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,173,132,10
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,172,132,10
+    CONTROL         "F&orward agent",IDC_FORWARD_AGENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,188,132,10
     CONTROL         "Use p&lain password to log in",IDC_SSHUSEPASSWORD,
-                    "Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,204,219,10
+                    "Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,219,219,10
     CONTROL         "Use &RSA/DSA/ECDSA/ED25519 key to log in",IDC_SSHUSERSA,
-                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,222,152,10
-    CONTROL         "Use r&hosts to log in (SSH1)",IDC_SSHUSERHOSTS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,272,99,10
+                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,237,152,10
+    CONTROL         "Use r&hosts to log in (SSH1)",IDC_SSHUSERHOSTS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,287,99,10
     CONTROL         "Use SSH1:challenge/response(&TIS) / SSH2:keyboard-interactive to log in",IDC_SSHUSETIS,
-                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,341,260,10
-    CONTROL         "Use P&ageant to log in",IDC_SSHUSEPAGEANT,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,358,276,10
-    LTEXT           "Private &key file:",IDC_RSAFILENAMELABEL,38,238,91,8
-    EDITTEXT        IDC_RSAFILENAME,50,250,150,13,ES_AUTOHSCROLL
-    PUSHBUTTON      "...",IDC_CHOOSERSAFILE,207,249,14,14,WS_GROUP
-    LTEXT           "Local &user name:",IDC_LOCALUSERNAMELABEL,38,284,91,8
-    EDITTEXT        IDC_LOCALUSERNAME,50,296,106,13,ES_AUTOHSCROLL
-    LTEXT           "Host private key &file:",IDC_HOSTRSAFILENAMELABEL,38,312,91,8
-    EDITTEXT        IDC_HOSTRSAFILENAME,50,326,151,13,ES_AUTOHSCROLL
-    PUSHBUTTON      "...",IDC_CHOOSEHOSTRSAFILE,208,325,17,14
-    DEFPUSHBUTTON   "OK",IDOK,217,382,50,14,WS_GROUP
-    PUSHBUTTON      "&Disconnect",IDCANCEL,275,382,50,14
-    GROUPBOX        "authentication methods ",IDC_STATIC,17,191,300,185
+                    "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,356,260,10
+    CONTROL         "Use P&ageant to log in",IDC_SSHUSEPAGEANT,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,373,276,10
+    LTEXT           "Private &key file:",IDC_RSAFILENAMELABEL,38,253,91,8
+    EDITTEXT        IDC_RSAFILENAME,50,265,150,13,ES_AUTOHSCROLL
+    PUSHBUTTON      "...",IDC_CHOOSERSAFILE,207,264,14,14,WS_GROUP
+    LTEXT           "Local &user name:",IDC_LOCALUSERNAMELABEL,38,299,91,8
+    EDITTEXT        IDC_LOCALUSERNAME,50,311,106,13,ES_AUTOHSCROLL
+    LTEXT           "Host private key &file:",IDC_HOSTRSAFILENAMELABEL,38,327,91,8
+    EDITTEXT        IDC_HOSTRSAFILENAME,50,341,151,13,ES_AUTOHSCROLL
+    PUSHBUTTON      "...",IDC_CHOOSEHOSTRSAFILE,208,340,17,14
+    DEFPUSHBUTTON   "OK",IDOK,217,395,50,14,WS_GROUP
+    PUSHBUTTON      "&Disconnect",IDCANCEL,275,395,50,14
+    GROUPBOX        "Authentication methods ",IDC_STATIC,17,206,300,185
 END
 
 IDD_HOSTDLG DIALOGEX 20, 20, 240, 128
@@ -628,8 +627,22 @@
 // Icon with lowest ID value placed first to ensure application icon
 // remains consistent on all systems.
 IDI_SECURETT            ICON                    "ttsecure.ico"
+
 IDI_SECURETT_GREEN      ICON                    "ttsecure_green.ico"
+
 IDI_SECURETT_YELLOW     ICON                    "ttsecure_yellow.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_SSHAUTH AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
 #endif    // \x89p\x8C\xEA (\x95č\x91) resources
 /////////////////////////////////////////////////////////////////////////////
 


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