Commit 36eda0f84d78b45d97dfa488b877d03bdeb437f6
1 parent
251cf480
Exists in
master
and in
3 other branches
Moving popup support for session instead of global method.
Showing
6 changed files
with
24 additions
and
32 deletions
Show diff stats
lib3270.cbp
| ... | ... | @@ -156,9 +156,6 @@ |
| 156 | 156 | <Unit filename="src/lib3270/macros.c"> |
| 157 | 157 | <Option compilerVar="CC" /> |
| 158 | 158 | </Unit> |
| 159 | - <Unit filename="src/lib3270/mkfb.c"> | |
| 160 | - <Option compilerVar="CC" /> | |
| 161 | - </Unit> | |
| 162 | 159 | <Unit filename="src/lib3270/options.c"> |
| 163 | 160 | <Option compilerVar="CC" /> |
| 164 | 161 | </Unit> | ... | ... |
src/include/lib3270/popup.h
| ... | ... | @@ -51,8 +51,6 @@ |
| 51 | 51 | LIB3270_NOTIFY_USER /**< Reserved, always the last one */ |
| 52 | 52 | } LIB3270_NOTIFY; |
| 53 | 53 | |
| 54 | - LIB3270_EXPORT void lib3270_set_popup_handler(int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)); | |
| 55 | - | |
| 56 | 54 | /** |
| 57 | 55 | * Pop up an error dialog, based on an error number. |
| 58 | 56 | * | ... | ... |
src/include/lib3270/session.h
| ... | ... | @@ -77,6 +77,7 @@ |
| 77 | 77 | int (*print)(H3270 *session); |
| 78 | 78 | |
| 79 | 79 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); |
| 80 | + void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); | |
| 80 | 81 | |
| 81 | 82 | #ifdef HAVE_LIBSSL |
| 82 | 83 | void (*set_peer_certificate)(const X509 *cert); | ... | ... |
src/lib3270/private.h
| ... | ... | @@ -295,7 +295,7 @@ typedef struct input |
| 295 | 295 | */ |
| 296 | 296 | struct _h3270 |
| 297 | 297 | { |
| 298 | - struct lib3270_session_callbacks cbk; // Callback table - Always the first one. | |
| 298 | + struct lib3270_session_callbacks cbk; // Callback table - Always the first one. | |
| 299 | 299 | |
| 300 | 300 | // unsigned short sz; /**< Struct size */ |
| 301 | 301 | ... | ... |
src/lib3270/screen.c
| ... | ... | @@ -24,8 +24,6 @@ |
| 24 | 24 | * |
| 25 | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
| 26 | 26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) |
| 27 | - * licinio@bb.com.br (Licínio Luis Branco) | |
| 28 | - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
| 29 | 27 | * |
| 30 | 28 | */ |
| 31 | 29 | |
| ... | ... | @@ -74,15 +72,8 @@ |
| 74 | 72 | |
| 75 | 73 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 76 | 74 | |
| 77 | -static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); | |
| 78 | - | |
| 79 | -static int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup; | |
| 80 | - | |
| 81 | -// enum ts { TS_AUTO, TS_ON, TS_OFF }; | |
| 82 | - | |
| 83 | 75 | static void status_connect(H3270 *session, int ignored, void *dunno); |
| 84 | 76 | static void status_3270_mode(H3270 *session, int ignored, void *dunno); |
| 85 | -// static void status_printer(H3270 *session, int on, void *dunno); | |
| 86 | 77 | static unsigned short color_from_fa(H3270 *hSession, unsigned char fa); |
| 87 | 78 | |
| 88 | 79 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| ... | ... | @@ -667,6 +658,7 @@ void status_untiming(H3270 *session) |
| 667 | 658 | session->cbk.set_timer(session,0); |
| 668 | 659 | } |
| 669 | 660 | |
| 661 | +/* | |
| 670 | 662 | static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) |
| 671 | 663 | { |
| 672 | 664 | #ifdef ANDROID |
| ... | ... | @@ -680,6 +672,7 @@ static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const cha |
| 680 | 672 | #endif // ANDROID |
| 681 | 673 | return 0; |
| 682 | 674 | } |
| 675 | +*/ | |
| 683 | 676 | |
| 684 | 677 | void Error(H3270 *session, const char *fmt, ...) |
| 685 | 678 | { |
| ... | ... | @@ -691,7 +684,7 @@ void Error(H3270 *session, const char *fmt, ...) |
| 691 | 684 | |
| 692 | 685 | va_start(arg_ptr, fmt); |
| 693 | 686 | |
| 694 | - popup_handler(session,session->user_data,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr); | |
| 687 | + session->cbk.popup(session,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr); | |
| 695 | 688 | |
| 696 | 689 | va_end(arg_ptr); |
| 697 | 690 | |
| ... | ... | @@ -706,7 +699,7 @@ void Warning(H3270 *session, const char *fmt, ...) |
| 706 | 699 | trace("%s: title=%s fmt=%s",__FUNCTION__,"3270 Warning",fmt); |
| 707 | 700 | |
| 708 | 701 | va_start(arg_ptr, fmt); |
| 709 | - popup_handler(session,session->user_data,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr); | |
| 702 | + session->cbk.popup(session,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr); | |
| 710 | 703 | va_end(arg_ptr); |
| 711 | 704 | |
| 712 | 705 | } |
| ... | ... | @@ -721,7 +714,7 @@ void popup_an_error(H3270 *session, const char *fmt, ...) |
| 721 | 714 | trace("%s: title=%s fmt=%s",__FUNCTION__,"3270 Error",fmt); |
| 722 | 715 | |
| 723 | 716 | va_start(args, fmt); |
| 724 | - popup_handler(session,session->user_data,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args); | |
| 717 | + session->cbk.popup(session,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args); | |
| 725 | 718 | va_end(args); |
| 726 | 719 | |
| 727 | 720 | } |
| ... | ... | @@ -735,7 +728,7 @@ void popup_system_error(H3270 *session, const char *title, const char *message, |
| 735 | 728 | trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); |
| 736 | 729 | |
| 737 | 730 | va_start(args, fmt); |
| 738 | - popup_handler(session,session->user_data,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args); | |
| 731 | + session->cbk.popup(session,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args); | |
| 739 | 732 | va_end(args); |
| 740 | 733 | } |
| 741 | 734 | |
| ... | ... | @@ -845,11 +838,6 @@ LIB3270_ACTION( testpattern ) |
| 845 | 838 | return 0; |
| 846 | 839 | } |
| 847 | 840 | |
| 848 | -LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)) | |
| 849 | -{ | |
| 850 | - popup_handler = handler ? handler : logpopup; | |
| 851 | -} | |
| 852 | - | |
| 853 | 841 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) |
| 854 | 842 | { |
| 855 | 843 | va_list args; |
| ... | ... | @@ -860,12 +848,8 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con |
| 860 | 848 | |
| 861 | 849 | LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list args) |
| 862 | 850 | { |
| 863 | - | |
| 864 | 851 | CHECK_SESSION_HANDLE(session); |
| 865 | - | |
| 866 | - trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); | |
| 867 | - | |
| 868 | - popup_handler(session,session->user_data,id,title ? title : _( "3270 Error" ), message,fmt,args); | |
| 852 | + session->cbk.popup(session,id,title ? title : _( "3270 Error" ), message,fmt,args); | |
| 869 | 853 | } |
| 870 | 854 | |
| 871 | 855 | LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) | ... | ... |
src/lib3270/session.c
| ... | ... | @@ -34,7 +34,6 @@ |
| 34 | 34 | #endif // !ANDROID |
| 35 | 35 | |
| 36 | 36 | #include "private.h" |
| 37 | -// #include "charsetc.h" | |
| 38 | 37 | #include "kybdc.h" |
| 39 | 38 | #include "ansic.h" |
| 40 | 39 | #include "togglesc.h" |
| ... | ... | @@ -44,9 +43,7 @@ |
| 44 | 43 | #include "ftc.h" |
| 45 | 44 | #include "kybdc.h" |
| 46 | 45 | #include "3270ds.h" |
| 47 | -// #include "tablesc.h" | |
| 48 | 46 | #include "popupsc.h" |
| 49 | -//#include "charset.h" | |
| 50 | 47 | |
| 51 | 48 | /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ |
| 52 | 49 | |
| ... | ... | @@ -166,6 +163,20 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const |
| 166 | 163 | #endif // ANDROID |
| 167 | 164 | } |
| 168 | 165 | |
| 166 | +static int popup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) | |
| 167 | +{ | |
| 168 | +#ifdef ANDROID | |
| 169 | + char *mask = xs_buffer("%s\n",fmt); | |
| 170 | + __android_log_vprint(ANDROID_LOG_VERBOSE, PACKAGE_NAME, mask, arg); | |
| 171 | + lib3270_free(mask); | |
| 172 | +#else | |
| 173 | + lib3270_write_log(session,"popup","%s",title); | |
| 174 | + lib3270_write_log(session,"popup","%s",msg); | |
| 175 | + lib3270_write_va_log(session,"popup",fmt,arg); | |
| 176 | +#endif // ANDROID | |
| 177 | + return 0; | |
| 178 | +} | |
| 179 | + | |
| 169 | 180 | static void update_ssl(H3270 *session, LIB3270_SSL_STATE state) |
| 170 | 181 | { |
| 171 | 182 | } |
| ... | ... | @@ -222,6 +233,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
| 222 | 233 | hSession->cbk.update_selection = update_selection; |
| 223 | 234 | hSession->cbk.cursor = set_cursor; |
| 224 | 235 | hSession->cbk.message = message; |
| 236 | + hSession->cbk.popup = popup; | |
| 225 | 237 | hSession->cbk.update_ssl = update_ssl; |
| 226 | 238 | hSession->cbk.display = screen_disp; |
| 227 | 239 | hSession->cbk.set_width = nop_int; | ... | ... |