diff --git a/common/src/include/lib3270/ipc-glib.h b/common/src/include/lib3270/ipc-glib.h index 85a6fde..18adfe0 100644 --- a/common/src/include/lib3270/ipc-glib.h +++ b/common/src/include/lib3270/ipc-glib.h @@ -95,42 +95,6 @@ void ipc3270_set_terminal_widget(GObject *object, GtkWidget *widget); void ipc3270_export_object(GObject *object, const char *name, GError **error); - /** - * @brief Convert from native charset to lib3270 charset. - * - * @param object ipc3270 Object. - * @param string UTF-8 string to convert. - * @param error Pointer to error object. - * - * @return Converted string in lib3270 charset. - * - */ - gchar * ipc3270_convert_to_3270(GObject *object, const gchar *string, GError **error); - - /** - * @brief Convert lib3270 received string to UTF-8. - * - * @param object ipc3270 object. - * @param string String received from lib3270. - * @param error Pointer to error object. - * - * @return The string converted to UTF-8. - * - */ - gchar * ipc3270_convert_from_3270(GObject *object, const gchar *string, GError **error); - - /** - * @brief Create a GVariant from a lib3270 string. - * - * @param object ipc3270 object. - * @param string String received from lib3270. - * @param error Pointer to error object. - * - * @return GVariant with the string converted to UTF-8. - * - */ - GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error); - void ipc3270_add_terminal_introspection(GString *string); const gchar * ipc3270_get_display_charset(GObject *object); diff --git a/server/pw3270-plugin-ipc.cbp b/server/pw3270-plugin-ipc.cbp index 01092c3..8b59236 100644 --- a/server/pw3270-plugin-ipc.cbp +++ b/server/pw3270-plugin-ipc.cbp @@ -63,9 +63,6 @@ - - diff --git a/server/src/core/convert.c b/server/src/core/convert.c deleted file mode 100644 index 4b6fe8b..0000000 --- a/server/src/core/convert.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como - e possui - linhas de código. - * - * Referências: - * - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * - */ - -#include -#include -#include - -gchar * ipc3270_convert_output_string(GObject *object, const gchar *string, GError **error) { - return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,error); -} - -gchar * ipc3270_convert_input_string(GObject *object, const gchar *string, GError **error) { - return g_convert_with_fallback(string,-1,"UTF-8",ipc3270_get_display_charset(object),"?",NULL,NULL,error); -} - -GVariant * ipc3270_GVariant_from_input_string(GObject *object, char *string, GError **error) { - - if(string) { - g_autofree gchar * utfstring = ipc3270_convert_input_string(object,string,error); - lib3270_free(string); - return g_variant_new_string(utfstring); - } - - ipc3270_set_error(object,errno,error); - return g_variant_new_string(""); -} - - diff --git a/server/src/core/linux/gobject.c b/server/src/core/linux/gobject.c index 51d7839..9505831 100644 --- a/server/src/core/linux/gobject.c +++ b/server/src/core/linux/gobject.c @@ -168,6 +168,9 @@ void ipc3270_add_terminal_introspection(GString *introspection) { " " \ " " \ " " \ + " " \ + " " \ + " " \ " " \ " " \ " " \ diff --git a/server/src/core/methods/field.c b/server/src/core/methods/field.c index bec58d2..3242020 100644 --- a/server/src/core/methods/field.c +++ b/server/src/core/methods/field.c @@ -29,10 +29,39 @@ #include "private.h" -int ipc3270_method_get_field_attribute(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_get_field_attribute(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { debug("%s childs=%u",__FUNCTION__,(unsigned int) g_variant_n_children(request)); - return ENOTSUP; + + H3270 *hSession = ipc3270_get_session(session); + guint row = 0, col = 0; + gint baddr = -1; + + switch(g_variant_n_children(request)) { + case 0: // No arguments, get at the current cursor position + baddr = -1; + break; + + case 1: // address + g_variant_get(request, "(i)", &baddr); + break; + + case 2: // row, col + g_variant_get(request, "(ii)", &row, &col); + baddr = lib3270_translate_to_address(hSession,row,col); + break; + + default: + return EINVAL; + } + + LIB3270_FIELD_ATTRIBUTE attr = lib3270_get_field_attribute(hSession,baddr); + if(attr == LIB3270_FIELD_ATTRIBUTE_INVALID) + return errno; + + ipc3270_response_append_uint32(response, (guint32) attr); + + return 0; } diff --git a/server/src/core/methods/get.c b/server/src/core/methods/get.c index 2552bad..36f39bf 100644 --- a/server/src/core/methods/get.c +++ b/server/src/core/methods/get.c @@ -29,7 +29,7 @@ #include "private.h" -int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { H3270 *hSession = ipc3270_get_session(session); @@ -76,8 +76,7 @@ int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *resp if(!text) return errno; - g_autofree gchar * converted = ipc3270_convert_from_3270(session,text,error); - ipc3270_response_append_string(response, converted); + ipc3270_response_append_string(response, text); return 0; diff --git a/server/src/core/methods/network.c b/server/src/core/methods/network.c index 480dc87..91e72cc 100644 --- a/server/src/core/methods/network.c +++ b/server/src/core/methods/network.c @@ -29,20 +29,15 @@ #include "private.h" -int ipc3270_method_connect(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_connect(GObject *session, GVariant *request, GObject G_GNUC_UNUSED(*response), GError G_GNUC_UNUSED(**error)) { gchar *text = NULL; g_variant_get(request, "(&s)", &text); - g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); - - if(!*error) - return lib3270_connect_url(ipc3270_get_session(session),converted,0); - - return 0; + return lib3270_connect_url(ipc3270_get_session(session),text,0); } -int ipc3270_method_disconnect(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_disconnect(GObject *session, GVariant G_GNUC_UNUSED(*request), GObject G_GNUC_UNUSED(*response), GError G_GNUC_UNUSED(**error)) { return lib3270_disconnect(ipc3270_get_session(session)); } diff --git a/server/src/core/methods/set.c b/server/src/core/methods/set.c index 00ccd88..00938e7 100644 --- a/server/src/core/methods/set.c +++ b/server/src/core/methods/set.c @@ -50,14 +50,11 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp if(text) { - g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); - - debug("Converted: \"%s\"",converted); - - if(lib3270_input_string(hSession,(const unsigned char *) converted, -1)) { + if(lib3270_input_string(hSession,(const unsigned char *) text, -1)) { debug("lib3270_input_string has failed: %s", strerror(errno)); return errno; } + } } @@ -72,9 +69,7 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp if(text) { - g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); - - if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) converted, -1) < 0) + if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) text, -1) < 0) return errno; } @@ -90,9 +85,7 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp if(text) { - g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); - - if(lib3270_set_string_at(hSession, row, col, (unsigned char *) converted, -1) < 0) + if(lib3270_set_string_at(hSession, row, col, (unsigned char *) text, -1) < 0) return errno; } diff --git a/server/src/core/methods/wait.c b/server/src/core/methods/wait.c index d863205..1037f6b 100644 --- a/server/src/core/methods/wait.c +++ b/server/src/core/methods/wait.c @@ -29,7 +29,7 @@ #include "private.h" -int ipc3270_method_wait(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_wait(GObject *session, GVariant *request, GObject G_GNUC_UNUSED(*response), GError G_GNUC_UNUSED(**error)) { guint seconds = 1; g_variant_get(request, "(u)", &seconds); @@ -37,7 +37,7 @@ int ipc3270_method_wait(GObject *session, GVariant *request, GObject *response, } -int ipc3270_method_wait_for_ready(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_wait_for_ready(GObject *session, GVariant *request, GObject G_GNUC_UNUSED(*response), GError G_GNUC_UNUSED(**error)) { guint seconds = 1; g_variant_get(request, "(u)", &seconds); @@ -45,7 +45,7 @@ int ipc3270_method_wait_for_ready(GObject *session, GVariant *request, GObject * } -int ipc3270_method_wait_for_update(GObject *session, GVariant *request, GObject *response, GError **error) { +int ipc3270_method_wait_for_update(GObject *session, GVariant *request, GObject G_GNUC_UNUSED(*response), GError G_GNUC_UNUSED(**error)) { guint seconds = 1; g_variant_get(request, "(u)", &seconds); -- libgit2 0.21.2