Commit bf50c2f22ba7f2f84eaf3deccfad43081376df9a
1 parent
579ad177
Exists in
master
and in
5 other branches
Implementando metodos rexx
Showing
13 changed files
with
89 additions
and
34 deletions
Show diff stats
src/include/lib3270.h
| ... | ... | @@ -571,9 +571,9 @@ |
| 571 | 571 | * @param h Session handle. |
| 572 | 572 | * @param ix Toggle id. |
| 573 | 573 | * @param value New toggle state (non zero for true). |
| 574 | - * | |
| 574 | + * * @returns 0 if the toggle is already at the state, 1 if the toggle was changed; < 0 on invalid toggle id | |
| 575 | 575 | */ |
| 576 | - LIB3270_EXPORT void lib3270_set_toggle(H3270 *h, LIB3270_TOGGLE ix, int value); | |
| 576 | + LIB3270_EXPORT int lib3270_set_toggle(H3270 *h, LIB3270_TOGGLE ix, int value); | |
| 577 | 577 | |
| 578 | 578 | /** |
| 579 | 579 | * Translate a string toggle name to the corresponding value. | ... | ... |
src/include/pw3270/ipcpackets.h
| ... | ... | @@ -49,7 +49,7 @@ |
| 49 | 49 | HLLAPI_PACKET_ERASE_EOF, |
| 50 | 50 | HLLAPI_PACKET_PRINT, |
| 51 | 51 | HLLAPI_PACKET_GET_CSTATE, |
| 52 | - HLLAPI_PACKET_IS_READY, | |
| 52 | + HLLAPI_PACKET_IS_READY, HLLAPI_PACKET_SET_TOGGLE, | |
| 53 | 53 | |
| 54 | 54 | HLLAPI_PACKET_INVALID |
| 55 | 55 | |
| ... | ... | @@ -149,6 +149,11 @@ struct hllapi_packet_emulate_input |
| 149 | 149 | unsigned char pasting; |
| 150 | 150 | char text[1]; |
| 151 | 151 | }; |
| 152 | + struct hllapi_packet_set | |
| 153 | +{ | |
| 154 | + unsigned char packet_id; | |
| 155 | + unsigned short id; unsigned short value; | |
| 156 | +}; | |
| 152 | 157 | |
| 153 | 158 | |
| 154 | 159 | #pragma pack() | ... | ... |
src/lib3270/toggles.c
| ... | ... | @@ -105,25 +105,22 @@ static void toggle_notify(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGG |
| 105 | 105 | session->update_toggle(session,ix,t->value,TT_INTERACTIVE,toggle_names[ix]); |
| 106 | 106 | |
| 107 | 107 | } |
| 108 | - | |
| 109 | -LIB3270_EXPORT void lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE ix, int value) | |
| 108 | + LIB3270_EXPORT int lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE ix, int value) | |
| 110 | 109 | { |
| 111 | - char v = value ? True : False; | |
| 112 | - struct lib3270_toggle * t; | |
| 110 | + char v = value ? True : False; struct lib3270_toggle * t; | |
| 113 | 111 | |
| 114 | 112 | CHECK_SESSION_HANDLE(session); |
| 115 | 113 | |
| 116 | 114 | if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) |
| 117 | - return; | |
| 115 | + return -EINVAL; | |
| 118 | 116 | |
| 119 | 117 | t = &session->toggle[ix]; |
| 120 | 118 | |
| 121 | 119 | if(v == t->value) |
| 122 | - return; | |
| 123 | - | |
| 124 | - t->value = v; | |
| 120 | + return 0; | |
| 121 | + t->value = v; | |
| 125 | 122 | |
| 126 | - toggle_notify(session,t,ix); | |
| 123 | + toggle_notify(session,t,ix); return 1; | |
| 127 | 124 | } |
| 128 | 125 | |
| 129 | 126 | LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE ix) | ... | ... |
src/plugins/dbus3270/gobject.c
| ... | ... | @@ -279,8 +279,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus |
| 279 | 279 | void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context) |
| 280 | 280 | { |
| 281 | 281 | trace("%s object=%p context=%p",__FUNCTION__,object,context); |
| 282 | - lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value); | |
| 283 | - dbus_g_method_return(context,0); | |
| 282 | + dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value)); | |
| 284 | 283 | } |
| 285 | 284 | |
| 286 | 285 | void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context) | ... | ... |
src/plugins/hllapi/pluginmain.c
| ... | ... | @@ -274,7 +274,9 @@ |
| 274 | 274 | case HLLAPI_PACKET_GET_CSTATE: |
| 275 | 275 | send_result(source,lib3270_get_connection_state(lib3270_get_default_session_handle())); |
| 276 | 276 | break; |
| 277 | - | |
| 277 | + case HLLAPI_PACKET_SET_TOGGLE: | |
| 278 | + send_result(source,lib3270_set_toggle(lib3270_get_default_session_handle(), | |
| 279 | + ((struct hllapi_packet_set *) source->buffer)->id, ((struct hllapi_packet_set *) source->buffer)->value)); break; | |
| 278 | 280 | default: |
| 279 | 281 | send_result(source, EINVAL); |
| 280 | 282 | g_message("Invalid remote request (id=%d)",source->buffer[0]); | ... | ... |
src/plugins/rx3270/local.cc
| ... | ... | @@ -68,13 +68,14 @@ |
| 68 | 68 | int wait(int seconds); |
| 69 | 69 | int wait_for_ready(int seconds); |
| 70 | 70 | |
| 71 | + char * get_text(int baddr, size_t len); | |
| 71 | 72 | char * get_text_at(int row, int col, size_t sz); |
| 72 | 73 | int cmp_text_at(int row, int col, const char *text); |
| 73 | 74 | int set_text_at(int row, int col, const char *str); |
| 74 | 75 | |
| 75 | 76 | int set_cursor_position(int row, int col); |
| 76 | 77 | |
| 77 | - void set_toggle(LIB3270_TOGGLE ix, bool value); | |
| 78 | + int set_toggle(LIB3270_TOGGLE ix, bool value); | |
| 78 | 79 | |
| 79 | 80 | int enter(void); |
| 80 | 81 | int pfkey(int key); |
| ... | ... | @@ -93,12 +94,13 @@ |
| 93 | 94 | int (*_pfkey)(H3270 *hSession, int key); |
| 94 | 95 | int (*_pakey)(H3270 *hSession, int key); |
| 95 | 96 | int (*_wait_for_ready)(H3270 *hSession, int seconds); |
| 97 | + char * (*_get_text)(H3270 *h, int offset, int len); | |
| 96 | 98 | char * (*_get_text_at)(H3270 *h, int row, int col, int len); |
| 97 | 99 | int (*_cmp_text_at)(H3270 *h, int row, int col, const char *text); |
| 98 | 100 | int (*_set_text_at)(H3270 *h, int row, int col, const unsigned char *str); |
| 99 | 101 | int (*_is_ready)(H3270 *h); |
| 100 | 102 | int (*_set_cursor_position)(H3270 *h, int row, int col); |
| 101 | - void (*_set_toggle)(H3270 *h, LIB3270_TOGGLE ix, int value); | |
| 103 | + int (*_set_toggle)(H3270 *h, LIB3270_TOGGLE ix, int value); | |
| 102 | 104 | |
| 103 | 105 | #ifdef WIN32 |
| 104 | 106 | HMODULE hModule; |
| ... | ... | @@ -283,6 +285,7 @@ dynamic::dynamic() |
| 283 | 285 | { (void **) & _pfkey, "lib3270_pfkey" }, |
| 284 | 286 | { (void **) & _pakey, "lib3270_pakey" }, |
| 285 | 287 | { (void **) & _wait_for_ready, "lib3270_wait_for_ready" }, |
| 288 | + { (void **) & _get_text, "lib3270_get_text" }, | |
| 286 | 289 | { (void **) & _get_text_at, "lib3270_get_text_at" }, |
| 287 | 290 | { (void **) & _cmp_text_at, "lib3270_cmp_text_at" }, |
| 288 | 291 | { (void **) & _set_text_at, "lib3270_set_string_at" }, |
| ... | ... | @@ -505,6 +508,13 @@ int dynamic::wait_for_ready(int seconds) |
| 505 | 508 | return _wait_for_ready(hSession,seconds); |
| 506 | 509 | } |
| 507 | 510 | |
| 511 | +char * dynamic::get_text(int offset, size_t len) | |
| 512 | +{ | |
| 513 | + if(!hModule) | |
| 514 | + return NULL; | |
| 515 | + return _get_text(hSession,offset,len); | |
| 516 | +} | |
| 517 | + | |
| 508 | 518 | char * dynamic::get_text_at(int row, int col, size_t sz) |
| 509 | 519 | { |
| 510 | 520 | if(!hModule) |
| ... | ... | @@ -554,8 +564,9 @@ int dynamic::pakey(int key) |
| 554 | 564 | return _pakey(hSession,key); |
| 555 | 565 | } |
| 556 | 566 | |
| 557 | -void dynamic::set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 567 | +int dynamic::set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 558 | 568 | { |
| 559 | 569 | if(hModule) |
| 560 | - _set_toggle(hSession,ix,(int) value); | |
| 570 | + return _set_toggle(hSession,ix,(int) value); | |
| 571 | + return -1; | |
| 561 | 572 | } | ... | ... |
src/plugins/rx3270/pluginmain.cc
| ... | ... | @@ -53,13 +53,14 @@ |
| 53 | 53 | int wait(int seconds); |
| 54 | 54 | int wait_for_ready(int seconds); |
| 55 | 55 | |
| 56 | + char * get_text(int baddr, size_t len); | |
| 56 | 57 | char * get_text_at(int row, int col, size_t sz); |
| 57 | 58 | int cmp_text_at(int row, int col, const char *text); |
| 58 | 59 | int set_text_at(int row, int col, const char *str); |
| 59 | 60 | |
| 60 | 61 | int set_cursor_position(int row, int col); |
| 61 | 62 | |
| 62 | - void set_toggle(LIB3270_TOGGLE ix, bool value); | |
| 63 | + int set_toggle(LIB3270_TOGGLE ix, bool value); | |
| 63 | 64 | |
| 64 | 65 | int enter(void); |
| 65 | 66 | int pfkey(int key); |
| ... | ... | @@ -183,12 +184,17 @@ |
| 183 | 184 | return lib3270_set_cursor_position(hSession,row,col); |
| 184 | 185 | } |
| 185 | 186 | |
| 186 | - void plugin::set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 187 | + int plugin::set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 187 | 188 | { |
| 188 | - lib3270_set_toggle(hSession,ix,(int) value); | |
| 189 | + return lib3270_set_toggle(hSession,ix,(int) value); | |
| 189 | 190 | } |
| 190 | 191 | |
| 191 | 192 | void plugin::logva(const char *fmt, va_list args) |
| 192 | 193 | { |
| 193 | 194 | lib3270_write_va_log(hSession,"REXX",fmt,args); |
| 194 | 195 | } |
| 196 | + | |
| 197 | + char * plugin::get_text(int baddr, size_t len) | |
| 198 | + { | |
| 199 | + return lib3270_get_text(hSession,baddr,len); | |
| 200 | + } | ... | ... |
src/plugins/rx3270/remote.cc
| ... | ... | @@ -61,6 +61,7 @@ |
| 61 | 61 | int wait(int seconds); |
| 62 | 62 | int wait_for_ready(int seconds); |
| 63 | 63 | |
| 64 | + char * get_text(int baddr, size_t len); | |
| 64 | 65 | char * get_text_at(int row, int col, size_t sz); |
| 65 | 66 | int cmp_text_at(int row, int col, const char *text); |
| 66 | 67 | int set_text_at(int row, int col, const char *str); |
| ... | ... | @@ -69,7 +70,7 @@ |
| 69 | 70 | |
| 70 | 71 | int set_cursor_position(int row, int col); |
| 71 | 72 | |
| 72 | - void set_toggle(LIB3270_TOGGLE ix, bool value); | |
| 73 | + int set_toggle(LIB3270_TOGGLE ix, bool value); | |
| 73 | 74 | |
| 74 | 75 | int enter(void); |
| 75 | 76 | int pfkey(int key); |
| ... | ... | @@ -910,13 +911,17 @@ int remote::pakey(int key) |
| 910 | 911 | return -1; |
| 911 | 912 | } |
| 912 | 913 | |
| 913 | -void remote::set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 914 | +int remote::set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 914 | 915 | { |
| 915 | 916 | #if defined(WIN32) |
| 916 | 917 | |
| 917 | 918 | if(hPipe != INVALID_HANDLE_VALUE) |
| 918 | 919 | { |
| 919 | - #warning Implementar | |
| 920 | + struct hllapi_packet_set query = { HLLAPI_PACKET_SET_TOGGLE, (unsigned short) ix, (unsigned short) value }; | |
| 921 | + struct hllapi_packet_result response; | |
| 922 | + DWORD cbSize = sizeof(query); | |
| 923 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 924 | + return response.rc; | |
| 920 | 925 | } |
| 921 | 926 | |
| 922 | 927 | #elif defined(HAVE_DBUS) |
| ... | ... | @@ -928,12 +933,12 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value) |
| 928 | 933 | if(msg) |
| 929 | 934 | { |
| 930 | 935 | dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &v, DBUS_TYPE_INVALID); |
| 931 | - get_intval(call(msg)); | |
| 936 | + return get_intval(call(msg)); | |
| 932 | 937 | } |
| 933 | 938 | |
| 934 | - | |
| 935 | 939 | #endif |
| 936 | 940 | |
| 941 | + return -1; | |
| 937 | 942 | } |
| 938 | 943 | |
| 939 | 944 | int remote::wait_for_text_at(int row, int col, const char *key, int timeout) |
| ... | ... | @@ -957,3 +962,9 @@ int remote::wait_for_text_at(int row, int col, const char *key, int timeout) |
| 957 | 962 | |
| 958 | 963 | return ETIMEDOUT; |
| 959 | 964 | } |
| 965 | + | |
| 966 | +char * remote::get_text(int baddr, size_t len) | |
| 967 | +{ | |
| 968 | + #warning IMPLEMENTAR | |
| 969 | + return NULL; | |
| 970 | +} | ... | ... |
src/plugins/rx3270/rexx_methods.cc
| ... | ... | @@ -338,3 +338,22 @@ RexxMethod5(int, rx3270_method_wait_for_text_at, CSELF, sessionPtr, int, row, in |
| 338 | 338 | return -1; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | +RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONAL_int, baddr, OPTIONAL_int, sz) | |
| 342 | +{ | |
| 343 | + rx3270 * hSession = (rx3270 *) sessionPtr; | |
| 344 | + | |
| 345 | + if(hSession) | |
| 346 | + { | |
| 347 | + char *str = hSession->get_text(baddr,sz > 0 ? sz : -1); | |
| 348 | + if(str) | |
| 349 | + { | |
| 350 | + char * text = hSession->get_local_string(str); | |
| 351 | + RexxStringObject ret = context->String((CSTRING) text); | |
| 352 | + free(str); | |
| 353 | + free(text); | |
| 354 | + return ret; | |
| 355 | + } | |
| 356 | + } | |
| 357 | + | |
| 358 | + return context->String(""); | |
| 359 | +} | ... | ... |
src/plugins/rx3270/rx3270.cls
| ... | ... | @@ -64,25 +64,28 @@ |
| 64 | 64 | ::METHOD GETTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_get_text_at" |
| 65 | 65 | ::METHOD SETTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_set_text_at" |
| 66 | 66 | ::METHOD CMPTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_cmp_text_at" |
| 67 | +::METHOD GET EXTERNAL "LIBRARY rx3270 rx3270_method_get_text" | |
| 67 | 68 | ::METHOD WAITFORTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_wait_for_text_at" |
| 68 | 69 | ::METHOD TEST EXTERNAL "LIBRARY rx3270 rx3270_method_test" |
| 69 | 70 | |
| 70 | 71 | /* |
| 71 | 72 | getConnectionState |
| 72 | 73 | waitForEvents |
| 73 | -getScreenContent | |
| 74 | 74 | RunMode |
| 75 | 75 | |
| 76 | 76 | ::method isConnected |
| 77 | 77 | return self~getConnectionState() = "CONNECTED_TN3270E" |
| 78 | 78 | |
| 79 | +*/ | |
| 80 | + | |
| 79 | 81 | ::method waitForStringAt |
| 80 | 82 | use arg row, col, key, timeout |
| 81 | 83 | if datatype(timeout) <> "NUM" |
| 82 | 84 | then timeout = 60 |
| 83 | 85 | return self~WaitForTextAt(row,col,key,timeout) |
| 84 | 86 | |
| 85 | -*/ | |
| 87 | +::method getScreenContent | |
| 88 | +return self~get() | |
| 86 | 89 | |
| 87 | 90 | ::method queryStringAt |
| 88 | 91 | use arg row, col, key |
| ... | ... | @@ -104,7 +107,7 @@ return self~SetTextAt(row,col,str) |
| 104 | 107 | return self~GetTextAt(row,col,size) |
| 105 | 108 | |
| 106 | 109 | ::method sendEnterKey |
| 107 | -return self~Enter() | |
| 110 | +return self~enter() | |
| 108 | 111 | |
| 109 | 112 | ::method sendPFKey |
| 110 | 113 | use arg key | ... | ... |
src/plugins/rx3270/rx3270.h
| ... | ... | @@ -95,7 +95,7 @@ |
| 95 | 95 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor); |
| 96 | 96 | REXX_METHOD_PROTOTYPE(rx3270_method_enter); |
| 97 | 97 | REXX_METHOD_PROTOTYPE(rx3270_method_pfkey); |
| 98 | - REXX_METHOD_PROTOTYPE(rx3270_method_pakey); | |
| 98 | + REXX_METHOD_PROTOTYPE(rx3270_method_pakey); REXX_METHOD_PROTOTYPE(rx3270_method_get_text); | |
| 99 | 99 | REXX_METHOD_PROTOTYPE(rx3270_method_get_text_at); |
| 100 | 100 | REXX_METHOD_PROTOTYPE(rx3270_method_set_text_at); |
| 101 | 101 | REXX_METHOD_PROTOTYPE(rx3270_method_cmp_text_at); |
| ... | ... | @@ -157,13 +157,13 @@ |
| 157 | 157 | virtual int wait_for_ready(int seconds) = 0; |
| 158 | 158 | virtual int wait_for_text_at(int row, int col, const char *key, int timeout); |
| 159 | 159 | virtual int set_cursor_position(int row, int col) = 0; |
| 160 | - virtual void set_toggle(LIB3270_TOGGLE ix, bool value) = 0; | |
| 160 | + virtual int set_toggle(LIB3270_TOGGLE ix, bool value) = 0; | |
| 161 | 161 | |
| 162 | 162 | virtual int enter(void) = 0; |
| 163 | 163 | virtual int pfkey(int key) = 0; |
| 164 | 164 | virtual int pakey(int key) = 0; |
| 165 | 165 | |
| 166 | - virtual char * get_text_at(int row, int col, size_t sz) = 0; | |
| 166 | + virtual char * get_text_at(int row, int col, size_t sz) = 0; virtual char * get_text(int baddr, size_t len) = 0; | |
| 167 | 167 | virtual int cmp_text_at(int row, int col, const char *text) = 0; |
| 168 | 168 | virtual int set_text_at(int row, int col, const char *str) = 0; |
| 169 | 169 | ... | ... |
src/plugins/rx3270/rxapimain.cc
| ... | ... | @@ -36,6 +36,7 @@ |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | 38 | #include "rx3270.h" |
| 39 | + #include <time.h> | |
| 39 | 40 | #include <lib3270/actions.h> |
| 40 | 41 | |
| 41 | 42 | #ifdef HAVE_SYSLOG |
| ... | ... | @@ -131,6 +132,7 @@ RexxMethodEntry rx3270_methods[] = |
| 131 | 132 | REXX_METHOD(rx3270_method_enter, rx3270_method_enter ), |
| 132 | 133 | REXX_METHOD(rx3270_method_pfkey, rx3270_method_pfkey ), |
| 133 | 134 | REXX_METHOD(rx3270_method_pakey, rx3270_method_pakey ), |
| 135 | + REXX_METHOD(rx3270_method_get_text, rx3270_method_get_text ), | |
| 134 | 136 | REXX_METHOD(rx3270_method_get_text_at, rx3270_method_get_text_at ), |
| 135 | 137 | REXX_METHOD(rx3270_method_set_text_at, rx3270_method_set_text_at ), |
| 136 | 138 | REXX_METHOD(rx3270_method_cmp_text_at, rx3270_method_cmp_text_at ), | ... | ... |
src/plugins/rx3270/text.cc