• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7520 (tree)
Time2019-03-28 00:24:32
Authorzmatsuo

Log Message

ダイアログ上のチェックボックスの機能を一通り実装した
- クリップボードからのペースト後にクリップボードをクリアする/しない
- パスフレーズで制御文字を使用する/しない
- パスフレーズを表示する/しない
- ユーザー名にwindowsのユーザー名をペーストするボタンを追加

Change Summary

Incremental Difference

--- branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c (revision 7519)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/auth.c (revision 7520)
@@ -37,6 +37,7 @@
3737 #include <fcntl.h>
3838 #include <stdlib.h>
3939 #include <errno.h>
40+#include <Lmcons.h> // for UNLEN
4041
4142 #include "resource.h"
4243 #include "keyfiles.h"
@@ -66,6 +67,7 @@
6667 -1, -1, -1, -1, -1, -1, -1, -1, -1, IDC_SSHUSEPAGEANT, -1
6768 };
6869 static TipWin *tipwin;
70+static BOOL UseControlChar = TRUE;
6971
7072 LRESULT CALLBACK password_wnd_proc(HWND control, UINT msg,
7173 WPARAM wParam, LPARAM lParam)
@@ -72,6 +74,10 @@
7274 {
7375 switch (msg) {
7476 case WM_CHAR:
77+ if (!UseControlChar) {
78+ // 制御文字は使用しない
79+ break;
80+ }
7581 if ((GetKeyState(VK_CONTROL) & 0x8000) != 0) {
7682 TCHAR chars[] = { (TCHAR) wParam, 0 };
7783
@@ -807,6 +813,9 @@
807813 else {
808814 DlgAuthFont = NULL;
809815 }
816+ UseControlChar = TRUE;
817+ CheckDlgButton(dlg, IDC_USE_CONTROL_CHARACTER, UseControlChar ? BST_CHECKED : BST_UNCHECKED);
818+ CheckDlgButton(dlg, IDC_CLEAR_CLIPBOARD, BST_UNCHECKED);
810819
811820 // SSH2 autologinが有効の場合は、タイマを仕掛ける。 (2004.12.1 yutaka)
812821 if (pvar->ssh2_autologin == 1) {
@@ -1013,16 +1022,64 @@
10131022 return TRUE;
10141023
10151024 case IDC_FROM_CLIPBOARD: {
1016- char *clipboard = GetClipboardTextA(dlg, TRUE);
1025+ char *clipboard = GetClipboardTextA(dlg, IsDlgButtonChecked(dlg, IDC_CLEAR_CLIPBOARD) != BST_UNCHECKED);
10171026 if (clipboard != NULL) {
10181027 SetDlgItemTextA(dlg, IDC_SSHPASSWORD, clipboard);
10191028 free(clipboard);
1020- SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDOK), TRUE);
1029+ SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
1030+ SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
10211031 return FALSE;
10221032 }
10231033 return TRUE;
10241034 }
10251035
1036+ case IDC_SHOW_PASSPHRASE: {
1037+ // 伏せ字 on/off を切り替える
1038+ HWND hWnd = GetDlgItem(dlg, IDC_SSHPASSWORD);
1039+ static wchar_t password_char;
1040+ if (password_char == 0) {
1041+ wchar_t c = (wchar_t)SendMessage(hWnd, EM_GETPASSWORDCHAR, 0, 0);
1042+ password_char = c;
1043+ }
1044+ if (IsDlgButtonChecked(dlg, IDC_SHOW_PASSPHRASE) != BST_UNCHECKED) {
1045+ SendMessage(hWnd, EM_SETPASSWORDCHAR, 0, 0);
1046+ } else {
1047+#if !defined(UNICODE)
1048+ if (password_char < 0x100) {
1049+ SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1050+ } else {
1051+ // TODO W系直呼び ↓うまくいかない
1052+ //SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1053+ SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
1054+ }
1055+#else
1056+ SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1057+#endif
1058+ }
1059+ //InvalidateRect(hWnd, NULL, TRUE);
1060+ SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
1061+ SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
1062+ return TRUE;
1063+ }
1064+
1065+ case IDC_FROM_GETUSERNAME: {
1066+ TCHAR user_name[UNLEN+1];
1067+ DWORD len = _countof(user_name);
1068+ BOOL r = GetUserName(user_name, &len);
1069+ if (r != 0) {
1070+ SetDlgItemText(dlg, IDC_SSHUSERNAME, user_name);
1071+ SendDlgItemMessage(dlg, IDC_SSHUSERNAME, EM_SETSEL, 0, -1);
1072+ SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHUSERNAME), TRUE);
1073+ }
1074+ return TRUE;
1075+ }
1076+
1077+ case IDC_USE_CONTROL_CHARACTER: {
1078+ UseControlChar =
1079+ (IsDlgButtonChecked(dlg, IDC_USE_CONTROL_CHARACTER) != BST_UNCHECKED) ?
1080+ TRUE : FALSE;
1081+ break;
1082+ }
10261083 default:
10271084 return FALSE;
10281085 }
--- branches/ssh_auth_dialog/ttssh2/ttxssh/resource.h (revision 7519)
+++ branches/ssh_auth_dialog/ttssh2/ttxssh/resource.h (revision 7520)
@@ -230,12 +230,13 @@
230230 #define IDC_USE_CONTROL_CHARACTER 1234
231231 #define IDC_HOSTRSAFILENAMELABEL 1235
232232 #define IDC_RSAFILENAMELABEL 1236
233+#define IDC_FROM_GETUSERNAME 1237
233234
234235 // Next default values for new objects
235236 //
236237 #ifdef APSTUDIO_INVOKED
237238 #ifndef APSTUDIO_READONLY_SYMBOLS
238-#define _APS_NEXT_RESOURCE_VALUE 116
239+#define _APS_NEXT_RESOURCE_VALUE 117
239240 #define _APS_NEXT_COMMAND_VALUE 40001
240241 #define _APS_NEXT_CONTROL_VALUE 1237
241242 #define _APS_NEXT_SYMED_VALUE 101
Show on old repository browser