From 42e6c7b28f07d1ed322fa296d88532295a437370 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 20 Aug 2015 18:38:14 +0000 Subject: [PATCH] Acertando suporte a scripts rexx (incluindo funções que faltavam), testando métodos para verificação se um ponto da tela é editável --- src/classlib/local.cc | 7 +++++++ src/classlib/remote.cc | 30 ++++++++++++++++++++++++++++++ src/include/lib3270.h | 12 +++++++++++- src/include/pw3270/class.h | 2 ++ src/java/plugin.cc | 4 ++++ src/lib3270/ctlr.c | 7 ++++++- src/plugins/rx3270/pluginmain.cc | 11 +++++++++++ src/plugins/rx3270/rexx_methods.cc | 12 ++++++++++++ src/plugins/rx3270/rx3270.cls | 1 + src/plugins/rx3270/rx3270.h | 4 ++++ src/plugins/rx3270/rxapimain.cc | 13 ++++++++++++- src/plugins/rx3270/sample/protected.rex | 12 ++++++++++++ src/plugins/rx3270/typed_routines.cc | 27 +++++++++++++++++++++++++++ 13 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 src/plugins/rx3270/sample/protected.rex diff --git a/src/classlib/local.cc b/src/classlib/local.cc index e1f4d97..a64778e 100644 --- a/src/classlib/local.cc +++ b/src/classlib/local.cc @@ -147,6 +147,7 @@ int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting); int (*_get_next_unprotected)(H3270 *hSession, int baddr0); int (*_get_is_protected)(H3270 *hSession, int baddr); + int (*_get_is_protected_at)(H3270 *hSession, int row, int col); void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); void * (*_free)(void *); const char * (*_get_display_charset)(H3270 *hSession); @@ -206,6 +207,7 @@ { (void **) & _emulate_input, "lib3270_emulate_input" }, { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" }, { (void **) & _get_is_protected, "lib3270_get_is_protected" }, + { (void **) & _get_is_protected_at, "lib3270_get_is_protected_at" }, { (void **) & _popup_va, "lib3270_popup_va" }, { (void **) & _free, "lib3270_free" }, { (void **) & _get_display_charset, "lib3270_get_display_charset" }, @@ -401,6 +403,11 @@ return _get_is_protected(hSession,baddr); } + int get_is_protected_at(int row, int col) + { + return _get_is_protected_at(hSession,row,col); + } + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) { va_list args; diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc index 1aba487..edbd1cc 100644 --- a/src/classlib/remote.cc +++ b/src/classlib/remote.cc @@ -1257,6 +1257,36 @@ } + int get_is_protected_at(int row,int col) + { +#if defined(WIN32) + + struct hllapi_packet_query_at query = { HLLAPI_PACKET_IS_PROTECTED_AT, (unsigned short) row, (unsigned short) col, 0 }; + + return query_intval((void *) &query, sizeof(query)); + +#elif defined(HAVE_DBUS) + + dbus_int32_t r = (dbus_int32_t) row; + dbus_int32_t c = (dbus_int32_t) col; + + DBusMessage * msg = create_message("getIsProtectedAt"); + if(msg) + { + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INVALID); + return get_intval(call(msg)); + } + + return -1; + +#else + + return -1; + +#endif + + } + int set_host_charset(const char *charset) { diff --git a/src/include/lib3270.h b/src/include/lib3270.h index fa2ac3e..f4963a1 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -935,11 +935,20 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0); /** - * @brief Check if the screen position is unprotected. + * @brief Check if the screen position is protected. * */ LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr0); + /** + * Get Check if the screen position is protected. + * + * @param h Session Handle. + * @param row Desired row. + * @param col Desired col. + * + */ + LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col); /** * Get address of the first blank. @@ -1017,6 +1026,7 @@ LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession); LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr); + LIB3270_EXPORT int lib3270_is_protected_at(H3270 *h, unsigned int row, unsigned int col); /** * Alloc/Realloc memory buffer. diff --git a/src/include/pw3270/class.h b/src/include/pw3270/class.h index 100e0a9..f0a40c8 100644 --- a/src/include/pw3270/class.h +++ b/src/include/pw3270/class.h @@ -220,7 +220,9 @@ virtual int get_field_start(int baddr = -1) = 0; virtual int get_field_len(int baddr = -1) = 0; virtual int get_next_unprotected(int baddr = -1) = 0; + virtual int get_is_protected(int baddr = -1) = 0; + virtual int get_is_protected_at(int row, int col) = 0; // Clipboard management virtual int set_copy(const char *text); diff --git a/src/java/plugin.cc b/src/java/plugin.cc index c9fd292..d952178 100644 --- a/src/java/plugin.cc +++ b/src/java/plugin.cc @@ -238,6 +238,10 @@ return lib3270_is_protected(hSession,baddr); } + int get_is_protected_at(int row, int col) { + return lib3270_is_protected_at(hSession,row,col); + } + int set_copy(const char *text) { v3270_set_copy(GTK_WIDGET(lib3270_get_user_data(hSession)),text); return 0; diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index 64a6f4a..997052d 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -612,6 +612,11 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0) return 0; } +LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col) { + CHECK_SESSION_HANDLE(h); + return lib3270_get_is_protected(h, ((row-1) * h->cols) + (col-1)); +} + LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr) { CHECK_SESSION_HANDLE(hSession); @@ -621,7 +626,7 @@ LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr) int faddr = find_field_attribute(hSession,baddr); - return FA_IS_PROTECTED(hSession->ea_buf[faddr].fa); + return FA_IS_PROTECTED(hSession->ea_buf[faddr].fa) ? 1 : 0; } diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index afb14bc..d1146db 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -127,6 +127,7 @@ int get_field_len(int baddr = -1); int get_next_unprotected(int baddr = -1); int get_is_protected(int baddr = -1); + int get_is_protected_at(int row, int col); int set_copy(const char *text); string get_copy(void); @@ -726,6 +727,16 @@ extern "C" return lib3270_get_next_unprotected(hSession,baddr); } + int plugin::get_is_protected(int baddr) + { + return lib3270_get_is_protected(hSession,baddr); + } + + int plugin::get_is_protected_at(int row, int col) + { + return lib3270_get_is_protected_at(hSession,row,col); + } + int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) { va_list args; diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc index a4b6171..297f53f 100644 --- a/src/plugins/rx3270/rexx_methods.cc +++ b/src/plugins/rx3270/rexx_methods.cc @@ -467,6 +467,7 @@ RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int, baddr) { + session *hSession = (session *) sessionPtr; if(!hSession) return -1; @@ -474,6 +475,17 @@ RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int return hSession->get_is_protected(baddr); } +RexxMethod3(int, rx3270_method_get_is_protected_at, CSELF, sessionPtr, int, row, int, col) +{ + + session *hSession = (session *) sessionPtr; + if(!hSession) + return -1; + + return hSession->get_is_protected_at(row,col); +} + + RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr) { try diff --git a/src/plugins/rx3270/rx3270.cls b/src/plugins/rx3270/rx3270.cls index 007c1ff..c388a42 100644 --- a/src/plugins/rx3270/rx3270.cls +++ b/src/plugins/rx3270/rx3270.cls @@ -83,6 +83,7 @@ ::METHOD GETFIELDLEN EXTERNAL "LIBRARY rx3270 rx3270_method_get_field_len" ::METHOD GETNEXTUNPROTECTED EXTERNAL "LIBRARY rx3270 rx3270_method_get_next_unprotected" ::METHOD GETISPROTECTED EXTERNAL "LIBRARY rx3270 rx3270_method_get_is_protected" +::METHOD GETISPROTECTEDAT EXTERNAL "LIBRARY rx3270 rx3270_method_get_is_protected_at" ::METHOD GETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_get_selection" ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection" diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index 841e661..7968ae0 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -91,6 +91,9 @@ REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL); REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput); + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected); + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt); + REXX_METHOD_PROTOTYPE(rx3270_method_version); REXX_METHOD_PROTOTYPE(rx3270_method_revision); REXX_METHOD_PROTOTYPE(rx3270_method_init); @@ -125,6 +128,7 @@ REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start); REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected); REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected); + REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at); REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); diff --git a/src/plugins/rx3270/rxapimain.cc b/src/plugins/rx3270/rxapimain.cc index 4a4e918..0568a5a 100644 --- a/src/plugins/rx3270/rxapimain.cc +++ b/src/plugins/rx3270/rxapimain.cc @@ -119,12 +119,14 @@ RexxRoutineEntry rx3270_functions[] = REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL), REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput), + REXX_TYPED_ROUTINE(rx3270Erase, rx3270IsProtected), + REXX_TYPED_ROUTINE(rx3270Erase, rx3270IsProtectedAt), + REXX_TYPED_ROUTINE(ebc2asc, ebc2asc), REXX_TYPED_ROUTINE(asc2ebc, asc2ebc), // rx3270Popup - REXX_LAST_METHOD() }; @@ -164,11 +166,20 @@ RexxMethodEntry rx3270_methods[] = REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ), REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ), REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ), + + REXX_METHOD(rx3270_method_get_is_protected, rx3270_method_get_is_protected ), + REXX_METHOD(rx3270_method_get_is_protected_at, rx3270_method_get_is_protected_at ), + REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ), REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), + REXX_METHOD(rx3270_method_erase, rx3270_method_erase ), + REXX_METHOD(rx3270_method_erase_eof, rx3270_method_erase_eof ), + REXX_METHOD(rx3270_method_erase_eol, rx3270_method_erase_eol ), + REXX_METHOD(rx3270_method_erase_input, rx3270_method_erase_input ), + REXX_METHOD(rx3270_method_popup, rx3270_method_popup ), REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ), diff --git a/src/plugins/rx3270/sample/protected.rex b/src/plugins/rx3270/sample/protected.rex new file mode 100644 index 0000000..ec3a149 --- /dev/null +++ b/src/plugins/rx3270/sample/protected.rex @@ -0,0 +1,12 @@ +/* + * Sample rexx code to get host charset + */ + + host = .rx3270~new("") + + say "Posição 19,39: "||host~getIsProtectedAt(19,39) + say "Posição 20,39: "||host~getIsProtectedAt(20,39) + + return 0 + +::requires "rx3270.cls" diff --git a/src/plugins/rx3270/typed_routines.cc b/src/plugins/rx3270/typed_routines.cc index 4fc63ae..6b2dc04 100644 --- a/src/plugins/rx3270/typed_routines.cc +++ b/src/plugins/rx3270/typed_routines.cc @@ -279,3 +279,30 @@ RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz) return context->String(""); } +RexxRoutine1(int, rx3270IsProtected, int, baddr) +{ + try + { + return session::get_default()->get_is_protected(baddr); + } + catch(std::exception &e) + { + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); + } + + return -1; +} + +RexxRoutine2(int, rx3270IsProtectedAt, int, row, int, col) +{ + try + { + return session::get_default()->get_is_protected_at(row,col); + } + catch(std::exception &e) + { + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what())); + } + + return -1; +} -- libgit2 0.21.2