Commit aa4812b80d3e6a12dae8d74e8375c94c94407bc1
1 parent
c6a08916
Exists in
master
and in
1 other branch
Adding new method to the ipc service core.
Showing
4 changed files
with
37 additions
and
0 deletions
Show diff stats
server/src/core/linux/gobject.c
@@ -140,6 +140,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { | @@ -140,6 +140,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { | ||
140 | " <arg type='y' name='lf' direction='in' />" \ | 140 | " <arg type='y' name='lf' direction='in' />" \ |
141 | " <arg type='s' name='text' direction='out' />" \ | 141 | " <arg type='s' name='text' direction='out' />" \ |
142 | " </method>" \ | 142 | " </method>" \ |
143 | + " <method name='setField'>" \ | ||
144 | + " <arg type='s' name='text' direction='in' />" \ | ||
145 | + " <arg type='i' name='result' direction='out' />" \ | ||
146 | + " </method>" \ | ||
143 | " <method name='setStringAtAddress'>" \ | 147 | " <method name='setStringAtAddress'>" \ |
144 | " <arg type='i' name='addr' direction='in' />" \ | 148 | " <arg type='i' name='addr' direction='in' />" \ |
145 | " <arg type='s' name='text' direction='in' />" \ | 149 | " <arg type='s' name='text' direction='in' />" \ |
server/src/core/methods/methods.c
@@ -63,6 +63,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req | @@ -63,6 +63,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req | ||
63 | { "waitForStringAt", ipc3270_method_wait_for_string }, | 63 | { "waitForStringAt", ipc3270_method_wait_for_string }, |
64 | { "waitForStringAtAddress", ipc3270_method_wait_for_string }, | 64 | { "waitForStringAtAddress", ipc3270_method_wait_for_string }, |
65 | 65 | ||
66 | + { "setField", ipc3270_method_set_field_contents }, | ||
66 | { "getFieldAttribute", ipc3270_method_get_field_attribute }, | 67 | { "getFieldAttribute", ipc3270_method_get_field_attribute }, |
67 | { "getFieldAttributeAt", ipc3270_method_get_field_attribute }, | 68 | { "getFieldAttributeAt", ipc3270_method_get_field_attribute }, |
68 | { "getFieldAttributeAtAddress", ipc3270_method_get_field_attribute }, | 69 | { "getFieldAttributeAtAddress", ipc3270_method_get_field_attribute }, |
server/src/core/methods/private.h
@@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
46 | G_GNUC_INTERNAL int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError **error); | 46 | G_GNUC_INTERNAL int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError **error); |
47 | 47 | ||
48 | G_GNUC_INTERNAL int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error); | 48 | G_GNUC_INTERNAL int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error); |
49 | + G_GNUC_INTERNAL int ipc3270_method_set_field_contents(GObject *session, GVariant *request, GObject *response, GError **error); | ||
49 | 50 | ||
50 | G_GNUC_INTERNAL int ipc3270_method_wait_for_string(GObject *session, GVariant *request, GObject *response, GError **error); | 51 | G_GNUC_INTERNAL int ipc3270_method_wait_for_string(GObject *session, GVariant *request, GObject *response, GError **error); |
51 | 52 |
server/src/core/methods/set.c
@@ -31,6 +31,37 @@ | @@ -31,6 +31,37 @@ | ||
31 | #include <errno.h> | 31 | #include <errno.h> |
32 | #include <string.h> | 32 | #include <string.h> |
33 | 33 | ||
34 | +int ipc3270_method_set_field_contents(GObject *session, GVariant *request, GObject *response, GError **error) | ||
35 | +{ | ||
36 | + H3270 *hSession = ipc3270_get_session(session); | ||
37 | + | ||
38 | + if(*error) | ||
39 | + return 0; | ||
40 | + | ||
41 | + if(g_variant_n_children(request) != 1) | ||
42 | + return EINVAL; | ||
43 | + | ||
44 | + gchar *text = NULL; | ||
45 | + g_variant_get(request, "(&s)", &text); | ||
46 | + | ||
47 | + if(!text) | ||
48 | + return EINVAL; | ||
49 | + | ||
50 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | ||
51 | + | ||
52 | + int rc = lib3270_set_field(hSession,converted,-1); | ||
53 | + | ||
54 | + if(rc < 0) { | ||
55 | + debug("lib3270_set_field has failed: %s", strerror(-rc)); | ||
56 | + return -rc; | ||
57 | + } | ||
58 | + | ||
59 | + ipc3270_response_append_int32(response, rc); | ||
60 | + | ||
61 | + return 0; | ||
62 | + | ||
63 | +} | ||
64 | + | ||
34 | int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error) { | 65 | int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error) { |
35 | 66 | ||
36 | H3270 *hSession = ipc3270_get_session(session); | 67 | H3270 *hSession = ipc3270_get_session(session); |