Commit 5a3042e81bb021c865b15a13ce21d3c3e4fea34d
1 parent
01810383
Exists in
master
and in
5 other branches
Incluindo metodos para permitir que scripts obtenham posição e tamanho de campos
Showing
13 changed files
with
219 additions
and
2 deletions
Show diff stats
src/include/lib3270.h
| ... | ... | @@ -932,6 +932,9 @@ |
| 932 | 932 | */ |
| 933 | 933 | LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *start, int *end); |
| 934 | 934 | |
| 935 | + LIB3270_EXPORT int lib3270_get_field_start(H3270 *hSession, int baddr); | |
| 936 | + LIB3270_EXPORT int lib3270_get_field_len(H3270 *hSession, int baddr); | |
| 937 | + | |
| 935 | 938 | LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *hSession, int baddr, int *start, int *end); |
| 936 | 939 | |
| 937 | 940 | ... | ... |
src/include/pw3270/ipcpackets.h
| ... | ... | @@ -49,7 +49,9 @@ |
| 49 | 49 | HLLAPI_PACKET_ERASE_EOF, |
| 50 | 50 | HLLAPI_PACKET_PRINT, |
| 51 | 51 | HLLAPI_PACKET_GET_CSTATE, |
| 52 | - HLLAPI_PACKET_IS_READY, HLLAPI_PACKET_SET_TOGGLE, | |
| 52 | + HLLAPI_PACKET_IS_READY, HLLAPI_PACKET_SET_TOGGLE, | |
| 53 | + HLLAPI_PACKET_FIELD_START, | |
| 54 | + HLLAPI_PACKET_FIELD_LEN, | |
| 53 | 55 | |
| 54 | 56 | HLLAPI_PACKET_INVALID |
| 55 | 57 | ... | ... |
src/lib3270/ctlr.c
| ... | ... | @@ -303,6 +303,62 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno) |
| 303 | 303 | hSession->crm_nattr = 0; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | +LIB3270_EXPORT int lib3270_get_field_start(H3270 *hSession, int baddr) | |
| 307 | +{ | |
| 308 | + int sbaddr; | |
| 309 | + | |
| 310 | + CHECK_SESSION_HANDLE(hSession); | |
| 311 | + | |
| 312 | + if (!hSession->formatted) | |
| 313 | + return -1; | |
| 314 | + | |
| 315 | + if(baddr < 0) | |
| 316 | + baddr = hSession->cursor_addr; | |
| 317 | + | |
| 318 | + sbaddr = baddr; | |
| 319 | + do | |
| 320 | + { | |
| 321 | + if(hSession->ea_buf[baddr].fa) | |
| 322 | + return baddr; | |
| 323 | + DEC_BA(baddr); | |
| 324 | + } while (baddr != sbaddr); | |
| 325 | + | |
| 326 | + return -1; | |
| 327 | + | |
| 328 | +} | |
| 329 | + | |
| 330 | +LIB3270_EXPORT int lib3270_get_field_len(H3270 *hSession, int baddr) | |
| 331 | +{ | |
| 332 | + int saddr; | |
| 333 | + int addr; | |
| 334 | + int width = 0; | |
| 335 | + | |
| 336 | + CHECK_SESSION_HANDLE(hSession); | |
| 337 | + | |
| 338 | + if (!hSession->formatted) | |
| 339 | + return -1; | |
| 340 | + | |
| 341 | + if(baddr < 0) | |
| 342 | + baddr = hSession->cursor_addr; | |
| 343 | + | |
| 344 | + addr = find_field_attribute(hSession,baddr); | |
| 345 | + | |
| 346 | + if(addr < 0) | |
| 347 | + return -1; | |
| 348 | + | |
| 349 | + saddr = addr; | |
| 350 | + INC_BA(addr); | |
| 351 | + do | |
| 352 | + { | |
| 353 | + if(hSession->ea_buf[addr].fa) | |
| 354 | + return width; | |
| 355 | + INC_BA(addr); | |
| 356 | + width++; | |
| 357 | + } while (addr != saddr); | |
| 358 | + | |
| 359 | + return -1; | |
| 360 | +} | |
| 361 | + | |
| 306 | 362 | LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) |
| 307 | 363 | { |
| 308 | 364 | int sbaddr; | ... | ... |
src/plugins/dbus3270/gobject.c
| ... | ... | @@ -319,3 +319,15 @@ void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *cont |
| 319 | 319 | return; |
| 320 | 320 | dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key)); |
| 321 | 321 | } |
| 322 | + | |
| 323 | + void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 324 | + { | |
| 325 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 326 | + dbus_g_method_return(context,lib3270_get_field_start(pw3270_dbus_get_session_handle(object),baddr)); | |
| 327 | + } | |
| 328 | + | |
| 329 | +void pw3270_dbus_get_field_len(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context) | |
| 330 | + { | |
| 331 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
| 332 | + dbus_g_method_return(context,lib3270_get_field_len(pw3270_dbus_get_session_handle(object),baddr)); | |
| 333 | + } | ... | ... |
src/plugins/dbus3270/pw3270dbus.xml
| ... | ... | @@ -93,6 +93,15 @@ |
| 93 | 93 | <arg type="s" name="text" direction="in" /> |
| 94 | 94 | <arg type="i" name="result" direction="out" /> |
| 95 | 95 | </method> |
| 96 | - | |
| 96 | + <method name="getFieldStart"> | |
| 97 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 98 | + <arg type="i" name="addr" direction="in" /> | |
| 99 | + <arg type="i" name="result" direction="out" /> | |
| 100 | + </method> | |
| 101 | + <method name="getFieldLength"> | |
| 102 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
| 103 | + <arg type="i" name="addr" direction="in" /> | |
| 104 | + <arg type="i" name="result" direction="out" /> | |
| 105 | + </method> | |
| 97 | 106 | </interface> |
| 98 | 107 | </node> | ... | ... |
src/plugins/dbus3270/service.h
| ... | ... | @@ -81,6 +81,9 @@ |
| 81 | 81 | |
| 82 | 82 | void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context); |
| 83 | 83 | |
| 84 | + void pw3270_dbus_get_field_start(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 85 | + void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | |
| 86 | + | |
| 84 | 87 | // Actions |
| 85 | 88 | void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); |
| 86 | 89 | void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | ... | ... |
src/plugins/hllapi/pluginmain.c
| ... | ... | @@ -282,6 +282,18 @@ |
| 282 | 282 | ((struct hllapi_packet_set *) source->buffer)->id, |
| 283 | 283 | ((struct hllapi_packet_set *) source->buffer)->value)); |
| 284 | 284 | break; |
| 285 | + | |
| 286 | + case HLLAPI_PACKET_FIELD_START: | |
| 287 | + send_result(source,lib3270_get_field_start(lib3270_get_default_session_handle(), | |
| 288 | + ((struct hllapi_packet_addr *) source->buffer)->addr)); | |
| 289 | + break; | |
| 290 | + | |
| 291 | + | |
| 292 | + case HLLAPI_PACKET_FIELD_LEN: | |
| 293 | + send_result(source,lib3270_get_field_len(lib3270_get_default_session_handle(), | |
| 294 | + ((struct hllapi_packet_addr *) source->buffer)->addr)); | |
| 295 | + break; | |
| 296 | + | |
| 285 | 297 | default: |
| 286 | 298 | send_result(source, EINVAL); |
| 287 | 299 | g_message("Invalid remote request (id=%d)",source->buffer[0]); | ... | ... |
src/plugins/rx3270/local.cc
| ... | ... | @@ -81,6 +81,9 @@ |
| 81 | 81 | int pfkey(int key); |
| 82 | 82 | int pakey(int key); |
| 83 | 83 | |
| 84 | + int get_field_start(int baddr = -1); | |
| 85 | + int get_field_len(int baddr = -1); | |
| 86 | + | |
| 84 | 87 | private: |
| 85 | 88 | |
| 86 | 89 | const char * (*_get_version)(void); |
| ... | ... | @@ -101,6 +104,8 @@ |
| 101 | 104 | int (*_is_ready)(H3270 *h); |
| 102 | 105 | int (*_set_cursor_position)(H3270 *h, int row, int col); |
| 103 | 106 | int (*_set_toggle)(H3270 *h, LIB3270_TOGGLE ix, int value); |
| 107 | + int (*_get_field_start)(H3270 *h, int baddr); | |
| 108 | + int (*_get_field_len)(H3270 *h, int baddr); | |
| 104 | 109 | |
| 105 | 110 | #ifdef WIN32 |
| 106 | 111 | HMODULE hModule; |
| ... | ... | @@ -227,6 +232,8 @@ dynamic::dynamic() |
| 227 | 232 | { (void **) & _is_ready, "lib3270_is_ready" }, |
| 228 | 233 | { (void **) & _set_cursor_position, "lib3270_set_cursor_position" }, |
| 229 | 234 | { (void **) & _set_toggle, "lib3270_set_toggle" }, |
| 235 | + { (void **) & _get_field_start, "lib3270_get_field_start" }, | |
| 236 | + { (void **) & _get_field_len, "lib3270_get_field_len" }, | |
| 230 | 237 | |
| 231 | 238 | }; |
| 232 | 239 | |
| ... | ... | @@ -508,3 +515,18 @@ int dynamic::set_toggle(LIB3270_TOGGLE ix, bool value) |
| 508 | 515 | return _set_toggle(hSession,ix,(int) value); |
| 509 | 516 | return -1; |
| 510 | 517 | } |
| 518 | + | |
| 519 | +int dynamic::get_field_start(int baddr) | |
| 520 | +{ | |
| 521 | + if(hModule) | |
| 522 | + return _get_field_start(hSession,baddr); | |
| 523 | + return -1; | |
| 524 | +} | |
| 525 | + | |
| 526 | +int dynamic::get_field_len(int baddr) | |
| 527 | +{ | |
| 528 | + if(hModule) | |
| 529 | + return _get_field_len(hSession,baddr); | |
| 530 | + return -1; | |
| 531 | +} | |
| 532 | + | ... | ... |
src/plugins/rx3270/pluginmain.cc
| ... | ... | @@ -91,6 +91,9 @@ |
| 91 | 91 | int pfkey(int key); |
| 92 | 92 | int pakey(int key); |
| 93 | 93 | |
| 94 | + int get_field_start(int baddr = -1); | |
| 95 | + int get_field_len(int baddr = -1); | |
| 96 | + | |
| 94 | 97 | private: |
| 95 | 98 | H3270 *hSession; |
| 96 | 99 | |
| ... | ... | @@ -231,6 +234,16 @@ |
| 231 | 234 | return lib3270_get_text(hSession,baddr,len); |
| 232 | 235 | } |
| 233 | 236 | |
| 237 | + int plugin::get_field_start(int baddr) | |
| 238 | + { | |
| 239 | + return lib3270_get_field_start(hSession,baddr); | |
| 240 | + } | |
| 241 | + | |
| 242 | + int plugin::get_field_len(int baddr) | |
| 243 | + { | |
| 244 | + return lib3270_get_field_len(hSession,baddr); | |
| 245 | + } | |
| 246 | + | |
| 234 | 247 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) |
| 235 | 248 | { |
| 236 | 249 | trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); | ... | ... |
src/plugins/rx3270/remote.cc
| ... | ... | @@ -76,6 +76,9 @@ |
| 76 | 76 | int pfkey(int key); |
| 77 | 77 | int pakey(int key); |
| 78 | 78 | |
| 79 | + int get_field_start(int baddr = -1); | |
| 80 | + int get_field_len(int baddr = -1); | |
| 81 | + | |
| 79 | 82 | private: |
| 80 | 83 | #if defined(WIN32) |
| 81 | 84 | |
| ... | ... | @@ -911,6 +914,66 @@ int remote::pakey(int key) |
| 911 | 914 | return -1; |
| 912 | 915 | } |
| 913 | 916 | |
| 917 | +int remote::get_field_start(int baddr) | |
| 918 | +{ | |
| 919 | +#if defined(WIN32) | |
| 920 | + | |
| 921 | + if(hPipe != INVALID_HANDLE_VALUE) | |
| 922 | + { | |
| 923 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_START, (unsigned short) baddr }; | |
| 924 | + struct hllapi_packet_result response; | |
| 925 | + DWORD cbSize = sizeof(query); | |
| 926 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 927 | + return response.rc; | |
| 928 | + } | |
| 929 | + | |
| 930 | +#elif defined(HAVE_DBUS) | |
| 931 | + | |
| 932 | + dbus_int32_t k = (dbus_int32_t) baddr; | |
| 933 | + | |
| 934 | + DBusMessage * msg = create_message("getFieldStart"); | |
| 935 | + if(msg) | |
| 936 | + { | |
| 937 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 938 | + return get_intval(call(msg)); | |
| 939 | + } | |
| 940 | + | |
| 941 | +#endif | |
| 942 | + | |
| 943 | + return -1; | |
| 944 | +} | |
| 945 | + | |
| 946 | +int remote::get_field_len(int baddr) | |
| 947 | +{ | |
| 948 | +#if defined(WIN32) | |
| 949 | + | |
| 950 | + if(hPipe != INVALID_HANDLE_VALUE) | |
| 951 | + { | |
| 952 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_LEN, (unsigned short) baddr }; | |
| 953 | + struct hllapi_packet_result response; | |
| 954 | + DWORD cbSize = sizeof(query); | |
| 955 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 956 | + return response.rc; | |
| 957 | + } | |
| 958 | + | |
| 959 | +#elif defined(HAVE_DBUS) | |
| 960 | + | |
| 961 | + dbus_int32_t k = (dbus_int32_t) baddr; | |
| 962 | + | |
| 963 | + DBusMessage * msg = create_message("getFieldLength"); | |
| 964 | + if(msg) | |
| 965 | + { | |
| 966 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 967 | + return get_intval(call(msg)); | |
| 968 | + } | |
| 969 | + | |
| 970 | +#endif | |
| 971 | + | |
| 972 | + return -1; | |
| 973 | +} | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 914 | 977 | int remote::set_toggle(LIB3270_TOGGLE ix, bool value) |
| 915 | 978 | { |
| 916 | 979 | #if defined(WIN32) | ... | ... |
src/plugins/rx3270/rexx_methods.cc
| ... | ... | @@ -357,3 +357,19 @@ RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONA |
| 357 | 357 | |
| 358 | 358 | return context->String(""); |
| 359 | 359 | } |
| 360 | + | |
| 361 | +RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, baddr) | |
| 362 | +{ | |
| 363 | + rx3270 *hSession = (rx3270 *) sessionPtr; | |
| 364 | + if(!hSession) | |
| 365 | + return -1; | |
| 366 | + return hSession->get_field_len(baddr); | |
| 367 | +} | |
| 368 | + | |
| 369 | +RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int, baddr) | |
| 370 | +{ | |
| 371 | + rx3270 *hSession = (rx3270 *) sessionPtr; | |
| 372 | + if(!hSession) | |
| 373 | + return -1; | |
| 374 | + return hSession->get_field_start(baddr); | |
| 375 | +} | ... | ... |
src/plugins/rx3270/rx3270.cls
| ... | ... | @@ -68,6 +68,9 @@ |
| 68 | 68 | ::METHOD WAITFORTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_wait_for_text_at" |
| 69 | 69 | ::METHOD TEST EXTERNAL "LIBRARY rx3270 rx3270_method_test" |
| 70 | 70 | |
| 71 | +::METHOD GETFIELDSTART EXTERNAL "LIBRARY rx3270 rx3270_method_get_field_start" | |
| 72 | +::METHOD GETFIELDLEN EXTERNAL "LIBRARY rx3270 rx3270_method_get_field_len" | |
| 73 | + | |
| 71 | 74 | /* |
| 72 | 75 | getConnectionState |
| 73 | 76 | waitForEvents | ... | ... |
src/plugins/rx3270/rx3270.h
| ... | ... | @@ -168,6 +168,9 @@ |
| 168 | 168 | virtual int cmp_text_at(int row, int col, const char *text) = 0; |
| 169 | 169 | virtual int set_text_at(int row, int col, const char *str) = 0; |
| 170 | 170 | |
| 171 | + virtual int get_field_start(int baddr = -1) = 0; | |
| 172 | + virtual int get_field_len(int baddr = -1) = 0; | |
| 173 | + | |
| 171 | 174 | }; |
| 172 | 175 | |
| 173 | 176 | rx3270 * create_lib3270_instance(void); | ... | ... |