mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Move host key dialogs over to using ShinyDialogBox.
They were previously using an ad-hoc system for getting hold of their context structure, which had to be different between the WM_INITDIALOG handler and everything else. That's exactly what ShinyDialogBox is good for preventing, so let's use it, to save effort.
This commit is contained in:
parent
d155009ded
commit
46332db26e
@ -853,14 +853,13 @@ struct hostkey_dialog_ctx {
|
|||||||
const char *helpctx;
|
const char *helpctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
static INT_PTR CALLBACK HostKeyMoreInfoProc(HWND hwnd, UINT msg,
|
static INT_PTR HostKeyMoreInfoProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
WPARAM wParam, LPARAM lParam)
|
LPARAM lParam, void *vctx)
|
||||||
{
|
{
|
||||||
|
struct hostkey_dialog_ctx *ctx = (struct hostkey_dialog_ctx *)vctx;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG: {
|
case WM_INITDIALOG: {
|
||||||
const struct hostkey_dialog_ctx *ctx =
|
|
||||||
(const struct hostkey_dialog_ctx *)lParam;
|
|
||||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (INT_PTR)ctx);
|
|
||||||
|
|
||||||
if (ctx->fingerprints[SSH_FPTYPE_SHA256])
|
if (ctx->fingerprints[SSH_FPTYPE_SHA256])
|
||||||
SetDlgItemText(hwnd, IDC_HKI_SHA256,
|
SetDlgItemText(hwnd, IDC_HKI_SHA256,
|
||||||
@ -876,26 +875,25 @@ static INT_PTR CALLBACK HostKeyMoreInfoProc(HWND hwnd, UINT msg,
|
|||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
EndDialog(hwnd, 0);
|
ShinyEndDialog(hwnd, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
EndDialog(hwnd, 0);
|
ShinyEndDialog(hwnd, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT_PTR CALLBACK HostKeyDialogProc(HWND hwnd, UINT msg,
|
static INT_PTR HostKeyDialogProc(HWND hwnd, UINT msg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam, void *vctx)
|
||||||
{
|
{
|
||||||
|
struct hostkey_dialog_ctx *ctx = (struct hostkey_dialog_ctx *)vctx;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG: {
|
case WM_INITDIALOG: {
|
||||||
strbuf *sb = strbuf_new();
|
strbuf *sb = strbuf_new();
|
||||||
const struct hostkey_dialog_ctx *ctx =
|
|
||||||
(const struct hostkey_dialog_ctx *)lParam;
|
|
||||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (INT_PTR)ctx);
|
|
||||||
for (int id = 100;; id++) {
|
for (int id = 100;; id++) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
@ -970,26 +968,21 @@ static INT_PTR CALLBACK HostKeyDialogProc(HWND hwnd, UINT msg,
|
|||||||
case IDC_HK_ACCEPT:
|
case IDC_HK_ACCEPT:
|
||||||
case IDC_HK_ONCE:
|
case IDC_HK_ONCE:
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hwnd, LOWORD(wParam));
|
ShinyEndDialog(hwnd, LOWORD(wParam));
|
||||||
return 0;
|
return 0;
|
||||||
case IDHELP: {
|
case IDHELP: {
|
||||||
const struct hostkey_dialog_ctx *ctx =
|
|
||||||
(const struct hostkey_dialog_ctx *)
|
|
||||||
GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
||||||
launch_help(hwnd, ctx->helpctx);
|
launch_help(hwnd, ctx->helpctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case IDC_HK_MOREINFO: {
|
case IDC_HK_MOREINFO: {
|
||||||
const struct hostkey_dialog_ctx *ctx =
|
ShinyDialogBox(hinst, MAKEINTRESOURCE(IDD_HK_MOREINFO),
|
||||||
(const struct hostkey_dialog_ctx *)
|
"PuTTYHostKeyMoreInfo", hwnd,
|
||||||
GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
HostKeyMoreInfoProc, ctx);
|
||||||
DialogBoxParam(hinst, MAKEINTRESOURCE(IDD_HK_MOREINFO),
|
|
||||||
hwnd, HostKeyMoreInfoProc, (LPARAM)ctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
EndDialog(hwnd, IDCANCEL);
|
ShinyEndDialog(hwnd, IDCANCEL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1021,9 +1014,9 @@ SeatPromptResult win_seat_confirm_ssh_host_key(
|
|||||||
ctx->host = host;
|
ctx->host = host;
|
||||||
ctx->port = port;
|
ctx->port = port;
|
||||||
int dlgid = (mismatch ? IDD_HK_WRONG : IDD_HK_ABSENT);
|
int dlgid = (mismatch ? IDD_HK_WRONG : IDD_HK_ABSENT);
|
||||||
int mbret = DialogBoxParam(
|
int mbret = ShinyDialogBox(
|
||||||
hinst, MAKEINTRESOURCE(dlgid), wgs->term_hwnd,
|
hinst, MAKEINTRESOURCE(dlgid), "PuTTYHostKeyDialog",
|
||||||
HostKeyDialogProc, (LPARAM)ctx);
|
wgs->term_hwnd, HostKeyDialogProc, ctx);
|
||||||
assert(mbret==IDC_HK_ACCEPT || mbret==IDC_HK_ONCE || mbret==IDCANCEL);
|
assert(mbret==IDC_HK_ACCEPT || mbret==IDC_HK_ONCE || mbret==IDCANCEL);
|
||||||
if (mbret == IDC_HK_ACCEPT) {
|
if (mbret == IDC_HK_ACCEPT) {
|
||||||
store_host_key(host, port, keytype, keystr);
|
store_host_key(host, port, keytype, keystr);
|
||||||
|
@ -61,6 +61,7 @@ IDD_HK_ABSENT DIALOG DISCARDABLE 50, 50, 340, 160
|
|||||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "PuTTY Security Alert"
|
CAPTION "PuTTY Security Alert"
|
||||||
FONT 8, "MS Shell Dlg"
|
FONT 8, "MS Shell Dlg"
|
||||||
|
CLASS "PuTTYHostKeyDialog"
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "The host key is not cached for this server:", 100, 40, 20, 300, 8
|
LTEXT "The host key is not cached for this server:", 100, 40, 20, 300, 8
|
||||||
LTEXT "You have no guarantee that the server is the computer you think it is.", 101, 40, 40, 300, 8
|
LTEXT "You have no guarantee that the server is the computer you think it is.", 101, 40, 40, 300, 8
|
||||||
@ -120,6 +121,7 @@ IDD_HK_MOREINFO DIALOG DISCARDABLE 140, 40, 400, 156
|
|||||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "PuTTY: information about the server's host key"
|
CAPTION "PuTTY: information about the server's host key"
|
||||||
FONT 8, "MS Shell Dlg"
|
FONT 8, "MS Shell Dlg"
|
||||||
|
CLASS "PuTTYHostKeyMoreInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "SHA256 fingerprint:", 100, 12, 12, 80, 8
|
LTEXT "SHA256 fingerprint:", 100, 12, 12, 80, 8
|
||||||
EDITTEXT IDC_HKI_SHA256, 100, 10, 288, 12, ES_READONLY
|
EDITTEXT IDC_HKI_SHA256, 100, 10, 288, 12, ES_READONLY
|
||||||
|
Loading…
Reference in New Issue
Block a user