Commit 6c6092190e1933d2982105f6de61c511738731b9
1 parent
0a3c9668
Exists in
master
and in
5 other branches
Incluindo suporte para janelas popup no plugin rexx
Showing
13 changed files
with
114 additions
and
32 deletions
Show diff stats
src/include/lib3270.h
| @@ -275,21 +275,6 @@ | @@ -275,21 +275,6 @@ | ||
| 275 | 275 | ||
| 276 | #define LIB3270_SSL_FAILED LIB3270_SSL_UNSECURE | 276 | #define LIB3270_SSL_FAILED LIB3270_SSL_UNSECURE |
| 277 | 277 | ||
| 278 | - /** | ||
| 279 | - * Notification message types. | ||
| 280 | - * | ||
| 281 | - */ | ||
| 282 | - typedef enum _LIB3270_NOTIFY | ||
| 283 | - { | ||
| 284 | - LIB3270_NOTIFY_INFO, /**< Simple information dialog */ | ||
| 285 | - LIB3270_NOTIFY_WARNING, | ||
| 286 | - LIB3270_NOTIFY_ERROR, | ||
| 287 | - LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ | ||
| 288 | - | ||
| 289 | - LIB3270_NOTIFY_USER /**< Reserved, always the last one */ | ||
| 290 | - } LIB3270_NOTIFY; | ||
| 291 | - | ||
| 292 | - | ||
| 293 | #ifdef __cplusplus | 278 | #ifdef __cplusplus |
| 294 | extern "C" { | 279 | extern "C" { |
| 295 | #endif | 280 | #endif |
| @@ -1018,17 +1003,6 @@ | @@ -1018,17 +1003,6 @@ | ||
| 1018 | */ | 1003 | */ |
| 1019 | LIB3270_EXPORT const char * lib3270_get_revision(void); | 1004 | LIB3270_EXPORT const char * lib3270_get_revision(void); |
| 1020 | 1005 | ||
| 1021 | - /** | ||
| 1022 | - * Pop up an error dialog, based on an error number. | ||
| 1023 | - * | ||
| 1024 | - * @param hSession Session handle | ||
| 1025 | - * @param errn Error number (errno). | ||
| 1026 | - * @param fmt Message format | ||
| 1027 | - * @param ... Arguments for message | ||
| 1028 | - */ | ||
| 1029 | - LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...); | ||
| 1030 | - | ||
| 1031 | - | ||
| 1032 | LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args); | 1006 | LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args); |
| 1033 | 1007 | ||
| 1034 | LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); | 1008 | LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); |
src/include/lib3270/popup.h
| @@ -37,9 +37,35 @@ | @@ -37,9 +37,35 @@ | ||
| 37 | extern "C" { | 37 | extern "C" { |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | + /** | ||
| 41 | + * Notification message types. | ||
| 42 | + * | ||
| 43 | + */ | ||
| 44 | + typedef enum _LIB3270_NOTIFY | ||
| 45 | + { | ||
| 46 | + LIB3270_NOTIFY_INFO, /**< Simple information dialog */ | ||
| 47 | + LIB3270_NOTIFY_WARNING, | ||
| 48 | + LIB3270_NOTIFY_ERROR, | ||
| 49 | + LIB3270_NOTIFY_CRITICAL, /**< Critical error, user can abort application */ | ||
| 50 | + | ||
| 51 | + LIB3270_NOTIFY_USER /**< Reserved, always the last one */ | ||
| 52 | + } LIB3270_NOTIFY; | ||
| 53 | + | ||
| 40 | LIB3270_EXPORT void lib3270_set_popup_handler(int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)); | 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 | + /** | ||
| 57 | + * Pop up an error dialog, based on an error number. | ||
| 58 | + * | ||
| 59 | + * @param hSession Session handle | ||
| 60 | + * @param errn Error number (errno). | ||
| 61 | + * @param fmt Message format | ||
| 62 | + * @param ... Arguments for message | ||
| 63 | + */ | ||
| 64 | + LIB3270_EXPORT void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...); | ||
| 65 | + | ||
| 41 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | 66 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); |
| 42 | 67 | ||
| 68 | + LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); | ||
| 43 | 69 | ||
| 44 | #ifdef __cplusplus | 70 | #ifdef __cplusplus |
| 45 | } | 71 | } |
src/include/lib3270/session.h
| @@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
| 33 | 33 | ||
| 34 | #define LIB3270_SESSION_H_INCLUDED 1 | 34 | #define LIB3270_SESSION_H_INCLUDED 1 |
| 35 | #include <sys/time.h> | 35 | #include <sys/time.h> |
| 36 | + #include <lib3270/popup.h> | ||
| 36 | 37 | ||
| 37 | #define LIB3270_LUNAME_LENGTH 16 | 38 | #define LIB3270_LUNAME_LENGTH 16 |
| 38 | #define LIB3270_FULL_MODEL_NAME_LENGTH 13 | 39 | #define LIB3270_FULL_MODEL_NAME_LENGTH 13 |
src/include/pw3270/v3270.h
src/lib3270/screen.c
| @@ -845,14 +845,19 @@ LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, void *, LI | @@ -845,14 +845,19 @@ LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, void *, LI | ||
| 845 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | 845 | LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) |
| 846 | { | 846 | { |
| 847 | va_list args; | 847 | va_list args; |
| 848 | + va_start(args, fmt); | ||
| 849 | + lib3270_popup_va(session, id, title, message, fmt, args); | ||
| 850 | + va_end(args); | ||
| 851 | +} | ||
| 852 | + | ||
| 853 | +LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list args) | ||
| 854 | +{ | ||
| 848 | 855 | ||
| 849 | CHECK_SESSION_HANDLE(session); | 856 | CHECK_SESSION_HANDLE(session); |
| 850 | 857 | ||
| 851 | trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); | 858 | trace("%s: title=%s msg=%s",__FUNCTION__,"3270 Error",message); |
| 852 | 859 | ||
| 853 | - va_start(args, fmt); | ||
| 854 | popup_handler(session,session->widget,id,title ? title : _( "3270 Error" ), message,fmt,args); | 860 | popup_handler(session,session->widget,id,title ? title : _( "3270 Error" ), message,fmt,args); |
| 855 | - va_end(args); | ||
| 856 | } | 861 | } |
| 857 | 862 | ||
| 858 | LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) | 863 | LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) |
src/plugins/rx3270/local.cc
| @@ -88,6 +88,8 @@ | @@ -88,6 +88,8 @@ | ||
| 88 | int get_field_len(int baddr = -1); | 88 | int get_field_len(int baddr = -1); |
| 89 | int get_next_unprotected(int baddr = -1); | 89 | int get_next_unprotected(int baddr = -1); |
| 90 | 90 | ||
| 91 | + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | ||
| 92 | + | ||
| 91 | private: | 93 | private: |
| 92 | 94 | ||
| 93 | const char * (*_get_version)(void); | 95 | const char * (*_get_version)(void); |
| @@ -114,6 +116,7 @@ | @@ -114,6 +116,7 @@ | ||
| 114 | int (*_get_cursor_addr)(H3270 *h); | 116 | int (*_get_cursor_addr)(H3270 *h); |
| 115 | int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting); | 117 | int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting); |
| 116 | int (*_get_next_unprotected)(H3270 *hSession, int baddr0); | 118 | int (*_get_next_unprotected)(H3270 *hSession, int baddr0); |
| 119 | + void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); | ||
| 117 | 120 | ||
| 118 | #ifdef WIN32 | 121 | #ifdef WIN32 |
| 119 | HMODULE hModule; | 122 | HMODULE hModule; |
| @@ -247,7 +250,7 @@ dynamic::dynamic() | @@ -247,7 +250,7 @@ dynamic::dynamic() | ||
| 247 | { (void **) & _get_cursor_addr, "lib3270_get_cursor_address" }, | 250 | { (void **) & _get_cursor_addr, "lib3270_get_cursor_address" }, |
| 248 | { (void **) & _emulate_input, "lib3270_emulate_input" }, | 251 | { (void **) & _emulate_input, "lib3270_emulate_input" }, |
| 249 | { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" }, | 252 | { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" }, |
| 250 | - | 253 | + { (void **) & _popup_va, "lib3270_popup_va" }, |
| 251 | }; | 254 | }; |
| 252 | 255 | ||
| 253 | // Load lib3270.dll | 256 | // Load lib3270.dll |
| @@ -572,3 +575,16 @@ int dynamic::get_next_unprotected(int baddr) | @@ -572,3 +575,16 @@ int dynamic::get_next_unprotected(int baddr) | ||
| 572 | return _get_next_unprotected(hSession,baddr); | 575 | return _get_next_unprotected(hSession,baddr); |
| 573 | return -1; | 576 | return -1; |
| 574 | } | 577 | } |
| 578 | + | ||
| 579 | +int dynamic::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | ||
| 580 | +{ | ||
| 581 | + if(hModule) | ||
| 582 | + { | ||
| 583 | + va_list args; | ||
| 584 | + va_start(args, fmt); | ||
| 585 | + _popup_va(hSession, id, title, message, fmt, args); | ||
| 586 | + va_end(args); | ||
| 587 | + return 0; | ||
| 588 | + } | ||
| 589 | + return -1; | ||
| 590 | +} |
src/plugins/rx3270/pluginmain.cc
| @@ -107,6 +107,8 @@ | @@ -107,6 +107,8 @@ | ||
| 107 | char * get_clipboard(void); | 107 | char * get_clipboard(void); |
| 108 | int set_clipboard(const char *text); | 108 | int set_clipboard(const char *text); |
| 109 | 109 | ||
| 110 | + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | ||
| 111 | + | ||
| 110 | protected: | 112 | protected: |
| 111 | 113 | ||
| 112 | private: | 114 | private: |
| @@ -313,6 +315,15 @@ | @@ -313,6 +315,15 @@ | ||
| 313 | return lib3270_get_next_unprotected(hSession,baddr); | 315 | return lib3270_get_next_unprotected(hSession,baddr); |
| 314 | } | 316 | } |
| 315 | 317 | ||
| 318 | +int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | ||
| 319 | +{ | ||
| 320 | + va_list args; | ||
| 321 | + va_start(args, fmt); | ||
| 322 | + lib3270_popup_va(hSession, id, title, message, fmt, args); | ||
| 323 | + va_end(args); | ||
| 324 | + return 0; | ||
| 325 | +} | ||
| 326 | + | ||
| 316 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) | 327 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) |
| 317 | { | 328 | { |
| 318 | trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); | 329 | trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); |
src/plugins/rx3270/rexx_methods.cc
| @@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
| 35 | #include "rx3270.h" | 35 | #include "rx3270.h" |
| 36 | #include <time.h> | 36 | #include <time.h> |
| 37 | #include <string.h> | 37 | #include <string.h> |
| 38 | + #include <ctype.h> | ||
| 38 | 39 | ||
| 39 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 40 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 40 | 41 | ||
| @@ -491,3 +492,38 @@ RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text) | @@ -491,3 +492,38 @@ RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text) | ||
| 491 | return -1; | 492 | return -1; |
| 492 | } | 493 | } |
| 493 | 494 | ||
| 495 | + | ||
| 496 | +RexxMethod5(int, rx3270_method_popup, CSELF, sessionPtr, CSTRING, s_id, CSTRING, title, CSTRING, message, OPTIONAL_CSTRING, det) | ||
| 497 | +{ | ||
| 498 | + LIB3270_NOTIFY id = LIB3270_NOTIFY_INFO; | ||
| 499 | + rx3270 * hSession = (rx3270 *) sessionPtr; | ||
| 500 | + | ||
| 501 | + if(!hSession) | ||
| 502 | + return -1; | ||
| 503 | + | ||
| 504 | + if(*s_id) | ||
| 505 | + { | ||
| 506 | + static const struct _descr | ||
| 507 | + { | ||
| 508 | + char str; | ||
| 509 | + LIB3270_NOTIFY id; | ||
| 510 | + } descr[] = | ||
| 511 | + { | ||
| 512 | + { 'I', LIB3270_NOTIFY_INFO }, | ||
| 513 | + { 'W', LIB3270_NOTIFY_WARNING }, | ||
| 514 | + { 'E', LIB3270_NOTIFY_ERROR }, | ||
| 515 | + { 'C', LIB3270_NOTIFY_CRITICAL }, | ||
| 516 | + }; | ||
| 517 | + | ||
| 518 | + for(int f=0;f<4;f++) | ||
| 519 | + { | ||
| 520 | + if(toupper(*s_id) == descr[f].str) | ||
| 521 | + { | ||
| 522 | + id = descr[f].id; | ||
| 523 | + trace("Using mode %c (%d)",toupper(*s_id),(int) id); | ||
| 524 | + } | ||
| 525 | + } | ||
| 526 | + } | ||
| 527 | + | ||
| 528 | + return hSession->popup_dialog(id, title, message, "%s", det ? det : ""); | ||
| 529 | +} |
src/plugins/rx3270/rx3270.cc
| @@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
| 44 | #endif // HAVE_SYSLOG | 44 | #endif // HAVE_SYSLOG |
| 45 | 45 | ||
| 46 | #include <string.h> | 46 | #include <string.h> |
| 47 | - | 47 | + #include <stdarg.h> |
| 48 | 48 | ||
| 49 | static rx3270 * factory_default(const char *type); | 49 | static rx3270 * factory_default(const char *type); |
| 50 | 50 | ||
| @@ -198,4 +198,8 @@ void rx3270::free(void *ptr) | @@ -198,4 +198,8 @@ void rx3270::free(void *ptr) | ||
| 198 | free(ptr); | 198 | free(ptr); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | +int rx3270::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | ||
| 202 | +{ | ||
| 203 | + return -1; | ||
| 204 | +} | ||
| 201 | 205 |
src/plugins/rx3270/rx3270.cls
| @@ -82,6 +82,8 @@ | @@ -82,6 +82,8 @@ | ||
| 82 | ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" | 82 | ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" |
| 83 | ::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard" | 83 | ::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard" |
| 84 | 84 | ||
| 85 | +::METHOD POPUP EXTERNAL "LIBRARY rx3270 rx3270_method_popup" | ||
| 86 | + | ||
| 85 | ::method waitForStringAt | 87 | ::method waitForStringAt |
| 86 | use arg row, col, key, timeout | 88 | use arg row, col, key, timeout |
| 87 | if datatype(timeout) <> "NUM" | 89 | if datatype(timeout) <> "NUM" |
src/plugins/rx3270/rx3270.h
| @@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
| 46 | #include <stdio.h> | 46 | #include <stdio.h> |
| 47 | #include <lib3270.h> | 47 | #include <lib3270.h> |
| 48 | #include <lib3270/log.h> | 48 | #include <lib3270/log.h> |
| 49 | + #include <lib3270/popup.h> | ||
| 49 | #include <stdarg.h> | 50 | #include <stdarg.h> |
| 50 | 51 | ||
| 51 | #ifndef ETIMEDOUT | 52 | #ifndef ETIMEDOUT |
| @@ -114,6 +115,7 @@ | @@ -114,6 +115,7 @@ | ||
| 114 | REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); | 115 | REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); |
| 115 | REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); | 116 | REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); |
| 116 | REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); | 117 | REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); |
| 118 | + REXX_METHOD_PROTOTYPE(rx3270_method_popup); | ||
| 117 | REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); | 119 | REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); |
| 118 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); | 120 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); |
| 119 | REXX_METHOD_PROTOTYPE(rx3270_method_input_text); | 121 | REXX_METHOD_PROTOTYPE(rx3270_method_input_text); |
| @@ -198,6 +200,8 @@ | @@ -198,6 +200,8 @@ | ||
| 198 | virtual char * get_clipboard(void); | 200 | virtual char * get_clipboard(void); |
| 199 | virtual int set_clipboard(const char *text); | 201 | virtual int set_clipboard(const char *text); |
| 200 | 202 | ||
| 203 | + virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | ||
| 204 | + | ||
| 201 | }; | 205 | }; |
| 202 | 206 | ||
| 203 | rx3270 * create_lib3270_instance(void); | 207 | rx3270 * create_lib3270_instance(void); |
src/plugins/rx3270/rxapimain.cc
| @@ -153,6 +153,8 @@ RexxMethodEntry rx3270_methods[] = | @@ -153,6 +153,8 @@ RexxMethodEntry rx3270_methods[] = | ||
| 153 | REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), | 153 | REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), |
| 154 | REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), | 154 | REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), |
| 155 | 155 | ||
| 156 | + REXX_METHOD(rx3270_method_popup, rx3270_method_popup ), | ||
| 157 | + | ||
| 156 | REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), | 158 | REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), |
| 157 | REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), | 159 | REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), |
| 158 | REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ), | 160 | REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ), |
src/plugins/rx3270/sample/clipboard.rex
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | 9 | ||
| 10 | if host~connected() = 0 then | 10 | if host~connected() = 0 then |
| 11 | do | 11 | do |
| 12 | - say "Disconnected from host" | 12 | + host~popup("error","Can't start script","Disconnected from host") |
| 13 | return 0 | 13 | return 0 |
| 14 | end | 14 | end |
| 15 | 15 | ||
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | 22 | ||
| 23 | if host~WaitForReady(60) <> 0 then | 23 | if host~WaitForReady(60) <> 0 then |
| 24 | do | 24 | do |
| 25 | - say "Timeout waiting for host" | 25 | + host~popup("error","Failed","Timeout waiting for host response") |
| 26 | return 0 | 26 | return 0 |
| 27 | end | 27 | end |
| 28 | 28 |