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,9 +156,6 @@ | ||
156 | <Unit filename="src/lib3270/macros.c"> | 156 | <Unit filename="src/lib3270/macros.c"> |
157 | <Option compilerVar="CC" /> | 157 | <Option compilerVar="CC" /> |
158 | </Unit> | 158 | </Unit> |
159 | - <Unit filename="src/lib3270/mkfb.c"> | ||
160 | - <Option compilerVar="CC" /> | ||
161 | - </Unit> | ||
162 | <Unit filename="src/lib3270/options.c"> | 159 | <Unit filename="src/lib3270/options.c"> |
163 | <Option compilerVar="CC" /> | 160 | <Option compilerVar="CC" /> |
164 | </Unit> | 161 | </Unit> |
src/include/lib3270/popup.h
@@ -51,8 +51,6 @@ | @@ -51,8 +51,6 @@ | ||
51 | LIB3270_NOTIFY_USER /**< Reserved, always the last one */ | 51 | LIB3270_NOTIFY_USER /**< Reserved, always the last one */ |
52 | } LIB3270_NOTIFY; | 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 | * Pop up an error dialog, based on an error number. | 55 | * Pop up an error dialog, based on an error number. |
58 | * | 56 | * |
src/include/lib3270/session.h
@@ -77,6 +77,7 @@ | @@ -77,6 +77,7 @@ | ||
77 | int (*print)(H3270 *session); | 77 | int (*print)(H3270 *session); |
78 | 78 | ||
79 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); | 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 | #ifdef HAVE_LIBSSL | 82 | #ifdef HAVE_LIBSSL |
82 | void (*set_peer_certificate)(const X509 *cert); | 83 | void (*set_peer_certificate)(const X509 *cert); |
src/lib3270/private.h
@@ -295,7 +295,7 @@ typedef struct input | @@ -295,7 +295,7 @@ typedef struct input | ||
295 | */ | 295 | */ |
296 | struct _h3270 | 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 | // unsigned short sz; /**< Struct size */ | 300 | // unsigned short sz; /**< Struct size */ |
301 | 301 |
src/lib3270/screen.c
@@ -24,8 +24,6 @@ | @@ -24,8 +24,6 @@ | ||
24 | * | 24 | * |
25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | 25 | * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) |
26 | * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | 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,15 +72,8 @@ | ||
74 | 72 | ||
75 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 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 | static void status_connect(H3270 *session, int ignored, void *dunno); | 75 | static void status_connect(H3270 *session, int ignored, void *dunno); |
84 | static void status_3270_mode(H3270 *session, int ignored, void *dunno); | 76 | static void status_3270_mode(H3270 *session, int ignored, void *dunno); |
85 | -// static void status_printer(H3270 *session, int on, void *dunno); | ||
86 | static unsigned short color_from_fa(H3270 *hSession, unsigned char fa); | 77 | static unsigned short color_from_fa(H3270 *hSession, unsigned char fa); |
87 | 78 | ||
88 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 79 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
@@ -667,6 +658,7 @@ void status_untiming(H3270 *session) | @@ -667,6 +658,7 @@ void status_untiming(H3270 *session) | ||
667 | session->cbk.set_timer(session,0); | 658 | session->cbk.set_timer(session,0); |
668 | } | 659 | } |
669 | 660 | ||
661 | +/* | ||
670 | static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) | 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 | #ifdef ANDROID | 664 | #ifdef ANDROID |
@@ -680,6 +672,7 @@ static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const cha | @@ -680,6 +672,7 @@ static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const cha | ||
680 | #endif // ANDROID | 672 | #endif // ANDROID |
681 | return 0; | 673 | return 0; |
682 | } | 674 | } |
675 | +*/ | ||
683 | 676 | ||
684 | void Error(H3270 *session, const char *fmt, ...) | 677 | void Error(H3270 *session, const char *fmt, ...) |
685 | { | 678 | { |
@@ -691,7 +684,7 @@ void Error(H3270 *session, const char *fmt, ...) | @@ -691,7 +684,7 @@ void Error(H3270 *session, const char *fmt, ...) | ||
691 | 684 | ||
692 | va_start(arg_ptr, fmt); | 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 | va_end(arg_ptr); | 689 | va_end(arg_ptr); |
697 | 690 | ||
@@ -706,7 +699,7 @@ void Warning(H3270 *session, const char *fmt, ...) | @@ -706,7 +699,7 @@ void Warning(H3270 *session, const char *fmt, ...) | ||
706 | trace("%s: title=%s fmt=%s",__FUNCTION__,"3270 Warning",fmt); | 699 | trace("%s: title=%s fmt=%s",__FUNCTION__,"3270 Warning",fmt); |
707 | 700 | ||
708 | va_start(arg_ptr, fmt); | 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 | va_end(arg_ptr); | 703 | va_end(arg_ptr); |
711 | 704 | ||
712 | } | 705 | } |
@@ -721,7 +714,7 @@ void popup_an_error(H3270 *session, const char *fmt, ...) | @@ -721,7 +714,7 @@ void popup_an_error(H3270 *session, const char *fmt, ...) | ||
721 | trace("%s: title=%s fmt=%s",__FUNCTION__,"3270 Error",fmt); | 714 | trace("%s: title=%s fmt=%s",__FUNCTION__,"3270 Error",fmt); |
722 | 715 | ||
723 | va_start(args, fmt); | 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 | va_end(args); | 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,7 +728,7 @@ void popup_system_error(H3270 *session, const char *title, const char *message, | ||
735 | trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); | 728 | trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); |
736 | 729 | ||
737 | va_start(args, fmt); | 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 | va_end(args); | 732 | va_end(args); |
740 | } | 733 | } |
741 | 734 | ||
@@ -845,11 +838,6 @@ LIB3270_ACTION( testpattern ) | @@ -845,11 +838,6 @@ LIB3270_ACTION( testpattern ) | ||
845 | return 0; | 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 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | 841 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) |
854 | { | 842 | { |
855 | va_list args; | 843 | va_list args; |
@@ -860,12 +848,8 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con | @@ -860,12 +848,8 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con | ||
860 | 848 | ||
861 | LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list args) | 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 | CHECK_SESSION_HANDLE(session); | 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 | LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) | 855 | LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) |
src/lib3270/session.c
@@ -34,7 +34,6 @@ | @@ -34,7 +34,6 @@ | ||
34 | #endif // !ANDROID | 34 | #endif // !ANDROID |
35 | 35 | ||
36 | #include "private.h" | 36 | #include "private.h" |
37 | -// #include "charsetc.h" | ||
38 | #include "kybdc.h" | 37 | #include "kybdc.h" |
39 | #include "ansic.h" | 38 | #include "ansic.h" |
40 | #include "togglesc.h" | 39 | #include "togglesc.h" |
@@ -44,9 +43,7 @@ | @@ -44,9 +43,7 @@ | ||
44 | #include "ftc.h" | 43 | #include "ftc.h" |
45 | #include "kybdc.h" | 44 | #include "kybdc.h" |
46 | #include "3270ds.h" | 45 | #include "3270ds.h" |
47 | -// #include "tablesc.h" | ||
48 | #include "popupsc.h" | 46 | #include "popupsc.h" |
49 | -//#include "charset.h" | ||
50 | 47 | ||
51 | /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ | 48 | /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ |
52 | 49 | ||
@@ -166,6 +163,20 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const | @@ -166,6 +163,20 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const | ||
166 | #endif // ANDROID | 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 | static void update_ssl(H3270 *session, LIB3270_SSL_STATE state) | 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,6 +233,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char | ||
222 | hSession->cbk.update_selection = update_selection; | 233 | hSession->cbk.update_selection = update_selection; |
223 | hSession->cbk.cursor = set_cursor; | 234 | hSession->cbk.cursor = set_cursor; |
224 | hSession->cbk.message = message; | 235 | hSession->cbk.message = message; |
236 | + hSession->cbk.popup = popup; | ||
225 | hSession->cbk.update_ssl = update_ssl; | 237 | hSession->cbk.update_ssl = update_ssl; |
226 | hSession->cbk.display = screen_disp; | 238 | hSession->cbk.display = screen_disp; |
227 | hSession->cbk.set_width = nop_int; | 239 | hSession->cbk.set_width = nop_int; |