From aa4812b80d3e6a12dae8d74e8375c94c94407bc1 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 25 Sep 2019 13:49:47 -0300 Subject: [PATCH] Adding new method to the ipc service core. --- server/src/core/linux/gobject.c | 4 ++++ server/src/core/methods/methods.c | 1 + server/src/core/methods/private.h | 1 + server/src/core/methods/set.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 0 deletions(-) diff --git a/server/src/core/linux/gobject.c b/server/src/core/linux/gobject.c index f7e0154..ff9156a 100644 --- a/server/src/core/linux/gobject.c +++ b/server/src/core/linux/gobject.c @@ -140,6 +140,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { " " \ " " \ " " \ + " " \ + " " \ + " " \ + " " \ " " \ " " \ " " \ diff --git a/server/src/core/methods/methods.c b/server/src/core/methods/methods.c index 3c97cbd..bac0a56 100644 --- a/server/src/core/methods/methods.c +++ b/server/src/core/methods/methods.c @@ -63,6 +63,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req { "waitForStringAt", ipc3270_method_wait_for_string }, { "waitForStringAtAddress", ipc3270_method_wait_for_string }, + { "setField", ipc3270_method_set_field_contents }, { "getFieldAttribute", ipc3270_method_get_field_attribute }, { "getFieldAttributeAt", ipc3270_method_get_field_attribute }, { "getFieldAttributeAtAddress", ipc3270_method_get_field_attribute }, diff --git a/server/src/core/methods/private.h b/server/src/core/methods/private.h index a74a3cf..4958541 100644 --- a/server/src/core/methods/private.h +++ b/server/src/core/methods/private.h @@ -46,6 +46,7 @@ G_GNUC_INTERNAL int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError **error); G_GNUC_INTERNAL int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error); + G_GNUC_INTERNAL int ipc3270_method_set_field_contents(GObject *session, GVariant *request, GObject *response, GError **error); G_GNUC_INTERNAL int ipc3270_method_wait_for_string(GObject *session, GVariant *request, GObject *response, GError **error); diff --git a/server/src/core/methods/set.c b/server/src/core/methods/set.c index be14c94..030023e 100644 --- a/server/src/core/methods/set.c +++ b/server/src/core/methods/set.c @@ -31,6 +31,37 @@ #include #include +int ipc3270_method_set_field_contents(GObject *session, GVariant *request, GObject *response, GError **error) +{ + H3270 *hSession = ipc3270_get_session(session); + + if(*error) + return 0; + + if(g_variant_n_children(request) != 1) + return EINVAL; + + gchar *text = NULL; + g_variant_get(request, "(&s)", &text); + + if(!text) + return EINVAL; + + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); + + int rc = lib3270_set_field(hSession,converted,-1); + + if(rc < 0) { + debug("lib3270_set_field has failed: %s", strerror(-rc)); + return -rc; + } + + ipc3270_response_append_int32(response, rc); + + return 0; + +} + int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error) { H3270 *hSession = ipc3270_get_session(session); -- libgit2 0.21.2