From 7cc3ccda846ef522f36818c53110d6907f949951 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Sun, 15 Jan 2023 20:37:15 -0500 Subject: [PATCH] End open dialogs on state change Modal dialogs opened within the connection thread may hang around if the connection restarts. Intercept the state change message and call EndDialog when that happens. Signed-off-by: Selva Nair --- openvpn.c | 14 ++++++++++++-- pkcs11.c | 4 ++++ proxy.c | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/openvpn.c b/openvpn.c index 2cbccae..6342b56 100644 --- a/openvpn.c +++ b/openvpn.c @@ -658,6 +658,10 @@ UserAuthDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) } break; + case WM_OVPN_STATE: /* state changed -- destroy the dialog */ + EndDialog(hwndDlg, LOWORD(wParam)); + return TRUE; + case WM_CTLCOLORSTATIC: if (GetDlgCtrlID((HWND) lParam) == ID_TXT_WARNING) { @@ -860,14 +864,16 @@ GenericPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) * auth succeeds or connection restarts/aborts. * Close the CR_TEXT dialog if state changes to anything * other than GET_CONFIG. The state is in lParam. + * For other auth dialogs any state change signals a restart: end the dialog */ param = (auth_param_t *) GetProp(hwndDlg, cfgProp); - if ((param->flags & FLAG_CR_TYPE_CRTEXT) - && strcmp((const char *) lParam, "GET_CONFIG")) + if (!(param->flags & FLAG_CR_TYPE_CRTEXT) + || strcmp((const char *) lParam, "GET_CONFIG")) { EndDialog(hwndDlg, LOWORD(wParam)); } return TRUE; + case WM_CLOSE: EndDialog(hwndDlg, LOWORD(wParam)); return TRUE; @@ -973,6 +979,10 @@ PrivKeyPassDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) } break; + case WM_OVPN_STATE: /* state changed -- destroy the dialog */ + EndDialog(hwndDlg, LOWORD(wParam)); + return TRUE; + case WM_CTLCOLORSTATIC: if (GetDlgCtrlID((HWND) lParam) == ID_TXT_WARNING) { diff --git a/pkcs11.c b/pkcs11.c index 3e0d587..d429d0a 100644 --- a/pkcs11.c +++ b/pkcs11.c @@ -621,6 +621,10 @@ QueryPkcs11DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) } break; + case WM_OVPN_STATE: /* state changed -- destroy the dialog */ + EndDialog(hwndDlg, LOWORD(wParam)); + return TRUE; + case WM_CTLCOLORSTATIC: if (GetDlgCtrlID((HWND) lParam) == ID_TXT_WARNING) { diff --git a/proxy.c b/proxy.c index f3ac1c0..68ecdec 100644 --- a/proxy.c +++ b/proxy.c @@ -374,6 +374,10 @@ ProxyAuthDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) } break; + case WM_OVPN_STATE: /* state changed -- destroy the dialog */ + EndDialog(hwndDlg, LOWORD(wParam)); + return TRUE; + case WM_CLOSE: EndDialog(hwndDlg, LOWORD(wParam)); return TRUE;