From 95491ab45dcea154fc0b471feb3f25ba55e49fb4 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 28 Jul 2020 18:55:28 -0300 Subject: [PATCH] Updating popup handler replacement (required for IPC modules). --- src/core/popup.c | 28 ++++++++++++++++++++++++++++ src/core/session.c | 21 ++------------------- src/core/telnet.c | 2 ++ src/include/lib3270/popup.h | 9 ++++++++- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/core/popup.c b/src/core/popup.c index e0f8bd5..b4a0929 100644 --- a/src/core/popup.c +++ b/src/core/popup.c @@ -142,3 +142,31 @@ LIB3270_POPUP * lib3270_popup_clone_printf(const LIB3270_POPUP *origin, const ch return popup; } +static int def_popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char GNUC_UNUSED wait) +{ + const char * text[] = { + popup->title, + popup->summary, + popup->body + }; + + size_t ix; + + for(ix = 0; ix < (sizeof(text)/sizeof(text[0])); ix++) + { + lib3270_write_log(hSession,"popup","%s",text[ix]); + } + + return ENOTSUP; +} + + +LIB3270_EXPORT void lib3270_set_popup_handler(H3270 *hSession, int (*handler)(H3270 *, const LIB3270_POPUP *, unsigned char wait)) { + + if(handler) + hSession->cbk.popup = handler; + else + hSession->cbk.popup = def_popup; + + +} diff --git a/src/core/session.c b/src/core/session.c index 82c06c2..16f5bbc 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -229,24 +229,6 @@ static void def_popup(H3270 *hSession, LIB3270_NOTIFY type, const char *title, c } */ -static int def_popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char GNUC_UNUSED wait) -{ - const char * text[] = { - popup->title, - popup->summary, - popup->body - }; - - size_t ix; - - for(ix = 0; ix < (sizeof(text)/sizeof(text[0])); ix++) - { - lib3270_write_log(hSession,"popup","%s",text[ix]); - } - - return ENOTSUP; -} - static void def_trace(H3270 GNUC_UNUSED(*session), void GNUC_UNUSED(*userdata), const char *fmt, va_list args) { vfprintf(stdout,fmt,args); @@ -324,7 +306,8 @@ void lib3270_reset_callbacks(H3270 *hSession) hSession->cbk.set_peer_certificate = set_peer_certificate; hSession->cbk.update_luname = default_update_luname; hSession->cbk.update_url = default_update_url; - hSession->cbk.popup = def_popup; + + lib3270_set_popup_handler(hSession, NULL); } diff --git a/src/core/telnet.c b/src/core/telnet.c index 023c99c..110ff32 100644 --- a/src/core/telnet.c +++ b/src/core/telnet.c @@ -652,6 +652,8 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED .popup = &popup }; + popup_ssl_error(hSession,0,&message); + /* unsigned long e; char err_buf[120]; diff --git a/src/include/lib3270/popup.h b/src/include/lib3270/popup.h index 042511b..d6574f4 100644 --- a/src/include/lib3270/popup.h +++ b/src/include/lib3270/popup.h @@ -71,7 +71,13 @@ } LIB3270_POPUP; /** - * Pop up an error dialog, based on an error number. + * @brief Replace popup handler. + * + */ + LIB3270_EXPORT void lib3270_set_popup_handler(H3270 *hSession, int (*handler)(H3270 *, const LIB3270_POPUP *, unsigned char wait)); + + /** + * @brief Pop up an error dialog, based on an error number. * * @param hSession Session handle * @param errn Error number (errno). @@ -109,6 +115,7 @@ * * @retval 0 User has confirmed, continue action. * @retval ECANCELED Operation was canceled. + * @retval ENOTSUP No popup handler available. */ LIB3270_EXPORT int lib3270_popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char wait); -- libgit2 0.21.2