Commit 95491ab45dcea154fc0b471feb3f25ba55e49fb4
1 parent
8cb489d2
Exists in
master
and in
3 other branches
Updating popup handler replacement (required for IPC modules).
Showing
4 changed files
with
40 additions
and
20 deletions
Show diff stats
src/core/popup.c
| ... | ... | @@ -142,3 +142,31 @@ LIB3270_POPUP * lib3270_popup_clone_printf(const LIB3270_POPUP *origin, const ch |
| 142 | 142 | return popup; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | +static int def_popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char GNUC_UNUSED wait) | |
| 146 | +{ | |
| 147 | + const char * text[] = { | |
| 148 | + popup->title, | |
| 149 | + popup->summary, | |
| 150 | + popup->body | |
| 151 | + }; | |
| 152 | + | |
| 153 | + size_t ix; | |
| 154 | + | |
| 155 | + for(ix = 0; ix < (sizeof(text)/sizeof(text[0])); ix++) | |
| 156 | + { | |
| 157 | + lib3270_write_log(hSession,"popup","%s",text[ix]); | |
| 158 | + } | |
| 159 | + | |
| 160 | + return ENOTSUP; | |
| 161 | +} | |
| 162 | + | |
| 163 | + | |
| 164 | +LIB3270_EXPORT void lib3270_set_popup_handler(H3270 *hSession, int (*handler)(H3270 *, const LIB3270_POPUP *, unsigned char wait)) { | |
| 165 | + | |
| 166 | + if(handler) | |
| 167 | + hSession->cbk.popup = handler; | |
| 168 | + else | |
| 169 | + hSession->cbk.popup = def_popup; | |
| 170 | + | |
| 171 | + | |
| 172 | +} | ... | ... |
src/core/session.c
| ... | ... | @@ -229,24 +229,6 @@ static void def_popup(H3270 *hSession, LIB3270_NOTIFY type, const char *title, c |
| 229 | 229 | } |
| 230 | 230 | */ |
| 231 | 231 | |
| 232 | -static int def_popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char GNUC_UNUSED wait) | |
| 233 | -{ | |
| 234 | - const char * text[] = { | |
| 235 | - popup->title, | |
| 236 | - popup->summary, | |
| 237 | - popup->body | |
| 238 | - }; | |
| 239 | - | |
| 240 | - size_t ix; | |
| 241 | - | |
| 242 | - for(ix = 0; ix < (sizeof(text)/sizeof(text[0])); ix++) | |
| 243 | - { | |
| 244 | - lib3270_write_log(hSession,"popup","%s",text[ix]); | |
| 245 | - } | |
| 246 | - | |
| 247 | - return ENOTSUP; | |
| 248 | -} | |
| 249 | - | |
| 250 | 232 | static void def_trace(H3270 GNUC_UNUSED(*session), void GNUC_UNUSED(*userdata), const char *fmt, va_list args) |
| 251 | 233 | { |
| 252 | 234 | vfprintf(stdout,fmt,args); |
| ... | ... | @@ -324,7 +306,8 @@ void lib3270_reset_callbacks(H3270 *hSession) |
| 324 | 306 | hSession->cbk.set_peer_certificate = set_peer_certificate; |
| 325 | 307 | hSession->cbk.update_luname = default_update_luname; |
| 326 | 308 | hSession->cbk.update_url = default_update_url; |
| 327 | - hSession->cbk.popup = def_popup; | |
| 309 | + | |
| 310 | + lib3270_set_popup_handler(hSession, NULL); | |
| 328 | 311 | |
| 329 | 312 | } |
| 330 | 313 | ... | ... |
src/core/telnet.c
src/include/lib3270/popup.h
| ... | ... | @@ -71,7 +71,13 @@ |
| 71 | 71 | } LIB3270_POPUP; |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Pop up an error dialog, based on an error number. | |
| 74 | + * @brief Replace popup handler. | |
| 75 | + * | |
| 76 | + */ | |
| 77 | + LIB3270_EXPORT void lib3270_set_popup_handler(H3270 *hSession, int (*handler)(H3270 *, const LIB3270_POPUP *, unsigned char wait)); | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * @brief Pop up an error dialog, based on an error number. | |
| 75 | 81 | * |
| 76 | 82 | * @param hSession Session handle |
| 77 | 83 | * @param errn Error number (errno). |
| ... | ... | @@ -109,6 +115,7 @@ |
| 109 | 115 | * |
| 110 | 116 | * @retval 0 User has confirmed, continue action. |
| 111 | 117 | * @retval ECANCELED Operation was canceled. |
| 118 | + * @retval ENOTSUP No popup handler available. | |
| 112 | 119 | */ |
| 113 | 120 | LIB3270_EXPORT int lib3270_popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char wait); |
| 114 | 121 | ... | ... |