mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
Mention any extant downstreams in close warning.
Suggested by Brian Rak.
This commit is contained in:
parent
a859955689
commit
0ec45782b5
6
putty.h
6
putty.h
@ -652,6 +652,12 @@ struct BackendVtable {
|
|||||||
/* Only implemented in the SSH protocol: check whether a
|
/* Only implemented in the SSH protocol: check whether a
|
||||||
* connection-sharing upstream exists for a given configuration. */
|
* connection-sharing upstream exists for a given configuration. */
|
||||||
bool (*test_for_upstream)(const char *host, int port, Conf *conf);
|
bool (*test_for_upstream)(const char *host, int port, Conf *conf);
|
||||||
|
/* Special-purpose function to return additional information to put
|
||||||
|
* in a "are you sure you want to close this session" dialog;
|
||||||
|
* return NULL if no such info, otherwise caller must free.
|
||||||
|
* Only implemented in the SSH protocol, to warn about downstream
|
||||||
|
* connections that would be lost if this one were terminated. */
|
||||||
|
char *(*close_warn_text)(Backend *be);
|
||||||
|
|
||||||
/* 'id' is a machine-readable name for the backend, used in
|
/* 'id' is a machine-readable name for the backend, used in
|
||||||
* saved-session storage. 'displayname' is a human-readable name
|
* saved-session storage. 'displayname' is a human-readable name
|
||||||
|
1
raw.c
1
raw.c
@ -324,6 +324,7 @@ const BackendVtable raw_backend = {
|
|||||||
.unthrottle = raw_unthrottle,
|
.unthrottle = raw_unthrottle,
|
||||||
.cfg_info = raw_cfg_info,
|
.cfg_info = raw_cfg_info,
|
||||||
.test_for_upstream = NULL,
|
.test_for_upstream = NULL,
|
||||||
|
.close_warn_text = NULL,
|
||||||
.id = "raw",
|
.id = "raw",
|
||||||
.displayname = "Raw",
|
.displayname = "Raw",
|
||||||
.protocol = PROT_RAW,
|
.protocol = PROT_RAW,
|
||||||
|
1
rlogin.c
1
rlogin.c
@ -422,6 +422,7 @@ const BackendVtable rlogin_backend = {
|
|||||||
.unthrottle = rlogin_unthrottle,
|
.unthrottle = rlogin_unthrottle,
|
||||||
.cfg_info = rlogin_cfg_info,
|
.cfg_info = rlogin_cfg_info,
|
||||||
.test_for_upstream = NULL,
|
.test_for_upstream = NULL,
|
||||||
|
.close_warn_text = NULL,
|
||||||
.id = "rlogin",
|
.id = "rlogin",
|
||||||
.displayname = "Rlogin",
|
.displayname = "Rlogin",
|
||||||
.protocol = PROT_RLOGIN,
|
.protocol = PROT_RLOGIN,
|
||||||
|
15
ssh.c
15
ssh.c
@ -691,6 +691,19 @@ static bool ssh_test_for_upstream(const char *host, int port, Conf *conf)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *ssh_close_warn_text(Backend *be)
|
||||||
|
{
|
||||||
|
Ssh *ssh = container_of(be, Ssh, backend);
|
||||||
|
if (!ssh->connshare)
|
||||||
|
return NULL;
|
||||||
|
int ndowns = share_ndownstreams(ssh->connshare);
|
||||||
|
if (ndowns == 0)
|
||||||
|
return NULL;
|
||||||
|
char *msg = dupprintf("This will also close %d downstream connection%s.",
|
||||||
|
ndowns, ndowns==1 ? "" : "s");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
static const PlugVtable Ssh_plugvt = {
|
static const PlugVtable Ssh_plugvt = {
|
||||||
.log = ssh_socket_log,
|
.log = ssh_socket_log,
|
||||||
.closing = ssh_closing,
|
.closing = ssh_closing,
|
||||||
@ -1204,6 +1217,7 @@ const BackendVtable ssh_backend = {
|
|||||||
.unthrottle = ssh_unthrottle,
|
.unthrottle = ssh_unthrottle,
|
||||||
.cfg_info = ssh_cfg_info,
|
.cfg_info = ssh_cfg_info,
|
||||||
.test_for_upstream = ssh_test_for_upstream,
|
.test_for_upstream = ssh_test_for_upstream,
|
||||||
|
.close_warn_text = ssh_close_warn_text,
|
||||||
.id = "ssh",
|
.id = "ssh",
|
||||||
.displayname = "SSH",
|
.displayname = "SSH",
|
||||||
.protocol = PROT_SSH,
|
.protocol = PROT_SSH,
|
||||||
@ -1227,6 +1241,7 @@ const BackendVtable sshconn_backend = {
|
|||||||
.unthrottle = ssh_unthrottle,
|
.unthrottle = ssh_unthrottle,
|
||||||
.cfg_info = ssh_cfg_info,
|
.cfg_info = ssh_cfg_info,
|
||||||
.test_for_upstream = ssh_test_for_upstream,
|
.test_for_upstream = ssh_test_for_upstream,
|
||||||
|
.close_warn_text = ssh_close_warn_text,
|
||||||
.id = "ssh-connection",
|
.id = "ssh-connection",
|
||||||
.displayname = "Bare ssh-connection",
|
.displayname = "Bare ssh-connection",
|
||||||
.protocol = PROT_SSHCONN,
|
.protocol = PROT_SSHCONN,
|
||||||
|
@ -618,13 +618,21 @@ gint delete_window(GtkWidget *widget, GdkEvent *event, GtkFrontend *inst)
|
|||||||
*/
|
*/
|
||||||
if (!find_and_raise_dialog(inst, DIALOG_SLOT_WARN_ON_CLOSE)) {
|
if (!find_and_raise_dialog(inst, DIALOG_SLOT_WARN_ON_CLOSE)) {
|
||||||
char *title = dupcat(appname, " Exit Confirmation");
|
char *title = dupcat(appname, " Exit Confirmation");
|
||||||
|
char *msg, *additional = NULL;
|
||||||
|
if (inst && inst->backend && inst->backend->vt->close_warn_text) {
|
||||||
|
additional = inst->backend->vt->close_warn_text(inst->backend);
|
||||||
|
}
|
||||||
|
msg = dupprintf("Are you sure you want to close this session?%s%s",
|
||||||
|
additional ? "\n" : "",
|
||||||
|
additional ? additional : "");
|
||||||
GtkWidget *dialog = create_message_box(
|
GtkWidget *dialog = create_message_box(
|
||||||
inst->window, title,
|
inst->window, title, msg,
|
||||||
"Are you sure you want to close this session?",
|
|
||||||
string_width("Most of the width of the above text"),
|
string_width("Most of the width of the above text"),
|
||||||
false, &buttons_yn, warn_on_close_callback, inst);
|
false, &buttons_yn, warn_on_close_callback, inst);
|
||||||
register_dialog(&inst->seat, DIALOG_SLOT_WARN_ON_CLOSE, dialog);
|
register_dialog(&inst->seat, DIALOG_SLOT_WARN_ON_CLOSE, dialog);
|
||||||
sfree(title);
|
sfree(title);
|
||||||
|
sfree(msg);
|
||||||
|
sfree(additional);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2122,16 +2122,23 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
break;
|
break;
|
||||||
case WM_CLOSE: {
|
case WM_CLOSE: {
|
||||||
char *str;
|
char *title, *msg, *additional = NULL;
|
||||||
show_mouseptr(true);
|
show_mouseptr(true);
|
||||||
str = dupprintf("%s Exit Confirmation", appname);
|
title = dupprintf("%s Exit Confirmation", appname);
|
||||||
|
if (backend && backend->vt->close_warn_text) {
|
||||||
|
additional = backend->vt->close_warn_text(backend);
|
||||||
|
}
|
||||||
|
msg = dupprintf("Are you sure you want to close this session?%s%s",
|
||||||
|
additional ? "\n" : "",
|
||||||
|
additional ? additional : "");
|
||||||
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
||||||
MessageBox(hwnd,
|
MessageBox(hwnd, msg, title,
|
||||||
"Are you sure you want to close this session?",
|
MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
||||||
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
|
||||||
== IDOK)
|
== IDOK)
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
sfree(str);
|
sfree(title);
|
||||||
|
sfree(msg);
|
||||||
|
sfree(additional);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
|
Loading…
Reference in New Issue
Block a user