1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-11 16:18:06 -05:00

Make GTK askalg() and askhk() non-modal.

This follows exactly the same pattern as for verify_ssh_host_key, but
the results of the dialog box are simpler (a plain yes-no response),
so the two dialog types can share a callback.
This commit is contained in:
Simon Tatham 2017-11-26 15:13:08 +00:00
parent 624f5b7d47
commit 199f381aa9

View File

@ -3635,6 +3635,28 @@ int verify_ssh_host_key(void *frontend, char *host, int port,
return -1; /* dialog still in progress */
}
struct simple_network_prompt_result_ctx {
void (*callback)(void *callback_ctx, int result);
void *callback_ctx;
void *frontend;
};
static void simple_network_prompt_result_callback(void *vctx, int result)
{
struct simple_network_prompt_result_ctx *ctx =
(struct simple_network_prompt_result_ctx *)vctx;
if (result >= 0)
ctx->callback(ctx->callback_ctx, result);
/*
* Clean up this context structure, whether or not a result was
* ever actually delivered from the dialog box.
*/
unregister_network_prompt_dialog(ctx->frontend);
sfree(ctx);
}
/*
* Ask whether the selected algorithm is acceptable (since it was
* below the configured 'warn' threshold).
@ -3646,22 +3668,28 @@ int askalg(void *frontend, const char *algtype, const char *algname,
"The first %s supported by the server is "
"%s, which is below the configured warning threshold.\n"
"Continue with connection?";
char *text;
int ret;
struct simple_network_prompt_result_ctx *result_ctx;
GtkWidget *mainwin, *msgbox;
text = dupprintf(msg, algtype, algname);
ret = message_box(GTK_WIDGET(get_window(frontend)),
"PuTTY Security Alert", text,
string_width("Reasonably long line of text as a width"
" template"),
FALSE, &buttons_yn);
result_ctx = snew(struct simple_network_prompt_result_ctx);
result_ctx->callback = callback;
result_ctx->callback_ctx = ctx;
result_ctx->frontend = frontend;
mainwin = GTK_WIDGET(get_window(frontend));
msgbox = create_message_box(
mainwin, "PuTTY Security Alert", text,
string_width("Reasonably long line of text as a width template"),
FALSE, &buttons_yn, simple_network_prompt_result_callback, result_ctx);
register_network_prompt_dialog(frontend, msgbox);
sfree(text);
if (ret) {
return 1;
} else {
return 0;
}
return -1; /* dialog still in progress */
}
int askhk(void *frontend, const char *algname, const char *betteralgs,
@ -3674,22 +3702,29 @@ int askhk(void *frontend, const char *algname, const char *betteralgs,
"above the threshold, which we do not have stored:\n"
"%s\n"
"Continue with connection?";
char *text;
int ret;
struct simple_network_prompt_result_ctx *result_ctx;
GtkWidget *mainwin, *msgbox;
text = dupprintf(msg, algname, betteralgs);
ret = message_box(GTK_WIDGET(get_window(frontend)),
"PuTTY Security Alert", text,
string_width("is ecdsa-nistp521, which is"
" below the configured warning threshold."),
FALSE, &buttons_yn);
result_ctx = snew(struct simple_network_prompt_result_ctx);
result_ctx->callback = callback;
result_ctx->callback_ctx = ctx;
result_ctx->frontend = frontend;
mainwin = GTK_WIDGET(get_window(frontend));
msgbox = create_message_box(
mainwin, "PuTTY Security Alert", text,
string_width("is ecdsa-nistp521, which is below the configured"
" warning threshold."),
FALSE, &buttons_yn, simple_network_prompt_result_callback, result_ctx);
register_network_prompt_dialog(frontend, msgbox);
sfree(text);
if (ret) {
return 1;
} else {
return 0;
}
return -1; /* dialog still in progress */
}
void old_keyfile_warning(void)