mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-18 11:38:05 -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:
parent
624f5b7d47
commit
199f381aa9
@ -3635,6 +3635,28 @@ int verify_ssh_host_key(void *frontend, char *host, int port,
|
|||||||
return -1; /* dialog still in progress */
|
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
|
* Ask whether the selected algorithm is acceptable (since it was
|
||||||
* below the configured 'warn' threshold).
|
* 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 "
|
"The first %s supported by the server is "
|
||||||
"%s, which is below the configured warning threshold.\n"
|
"%s, which is below the configured warning threshold.\n"
|
||||||
"Continue with connection?";
|
"Continue with connection?";
|
||||||
|
|
||||||
char *text;
|
char *text;
|
||||||
int ret;
|
struct simple_network_prompt_result_ctx *result_ctx;
|
||||||
|
GtkWidget *mainwin, *msgbox;
|
||||||
|
|
||||||
text = dupprintf(msg, algtype, algname);
|
text = dupprintf(msg, algtype, algname);
|
||||||
ret = message_box(GTK_WIDGET(get_window(frontend)),
|
|
||||||
"PuTTY Security Alert", text,
|
result_ctx = snew(struct simple_network_prompt_result_ctx);
|
||||||
string_width("Reasonably long line of text as a width"
|
result_ctx->callback = callback;
|
||||||
" template"),
|
result_ctx->callback_ctx = ctx;
|
||||||
FALSE, &buttons_yn);
|
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);
|
sfree(text);
|
||||||
|
|
||||||
if (ret) {
|
return -1; /* dialog still in progress */
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int askhk(void *frontend, const char *algname, const char *betteralgs,
|
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"
|
"above the threshold, which we do not have stored:\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
"Continue with connection?";
|
"Continue with connection?";
|
||||||
|
|
||||||
char *text;
|
char *text;
|
||||||
int ret;
|
struct simple_network_prompt_result_ctx *result_ctx;
|
||||||
|
GtkWidget *mainwin, *msgbox;
|
||||||
|
|
||||||
text = dupprintf(msg, algname, betteralgs);
|
text = dupprintf(msg, algname, betteralgs);
|
||||||
ret = message_box(GTK_WIDGET(get_window(frontend)),
|
|
||||||
"PuTTY Security Alert", text,
|
result_ctx = snew(struct simple_network_prompt_result_ctx);
|
||||||
string_width("is ecdsa-nistp521, which is"
|
result_ctx->callback = callback;
|
||||||
" below the configured warning threshold."),
|
result_ctx->callback_ctx = ctx;
|
||||||
FALSE, &buttons_yn);
|
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);
|
sfree(text);
|
||||||
|
|
||||||
if (ret) {
|
return -1; /* dialog still in progress */
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void old_keyfile_warning(void)
|
void old_keyfile_warning(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user