Commit 796d2d6e2cb7b37fb5b4b92febd7badfbfc782ad
1 parent
150e6b71
Exists in
master
and in
1 other branch
IPC/D-Bus string should be in UTF-8, doing the necessary conversions.
Showing
4 changed files
with
17 additions
and
7 deletions
Show diff stats
client/src/session/remote/properties.cc
client/src/testprogram/testprogram.cc
server/src/core/methods/get.c
| ... | ... | @@ -29,7 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | #include "private.h" |
| 31 | 31 | |
| 32 | -int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { | |
| 32 | +int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *response, GError **error) { | |
| 33 | 33 | |
| 34 | 34 | H3270 *hSession = ipc3270_get_session(session); |
| 35 | 35 | |
| ... | ... | @@ -75,7 +75,9 @@ int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *resp |
| 75 | 75 | if(!text) |
| 76 | 76 | return errno; |
| 77 | 77 | |
| 78 | - ipc3270_response_append_string(response, text); | |
| 78 | + // Send response as UTF-8. | |
| 79 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,error); | |
| 80 | + ipc3270_response_append_string(response, converted); | |
| 79 | 81 | |
| 80 | 82 | return 0; |
| 81 | 83 | ... | ... |
server/src/core/methods/set.c
| ... | ... | @@ -38,7 +38,6 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp |
| 38 | 38 | gchar *text = NULL; |
| 39 | 39 | g_variant_get(request, "(&s)", &text); |
| 40 | 40 | |
| 41 | - | |
| 42 | 41 | if(*error) |
| 43 | 42 | return 0; |
| 44 | 43 | |
| ... | ... | @@ -50,7 +49,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp |
| 50 | 49 | |
| 51 | 50 | if(text) { |
| 52 | 51 | |
| 53 | - if(lib3270_input_string(hSession,(const unsigned char *) text, -1)) { | |
| 52 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | |
| 53 | + | |
| 54 | + if(lib3270_input_string(hSession,(const unsigned char *) converted, -1)) { | |
| 54 | 55 | debug("lib3270_input_string has failed: %s", strerror(errno)); |
| 55 | 56 | return errno; |
| 56 | 57 | } |
| ... | ... | @@ -69,7 +70,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp |
| 69 | 70 | |
| 70 | 71 | if(text) { |
| 71 | 72 | |
| 72 | - if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) text, -1) < 0) | |
| 73 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | |
| 74 | + | |
| 75 | + if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) converted, -1) < 0) | |
| 73 | 76 | return errno; |
| 74 | 77 | |
| 75 | 78 | } |
| ... | ... | @@ -85,7 +88,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp |
| 85 | 88 | |
| 86 | 89 | if(text) { |
| 87 | 90 | |
| 88 | - if(lib3270_set_string_at(hSession, row, col, (unsigned char *) text, -1) < 0) | |
| 91 | + g_autofree gchar * converted = g_convert_with_fallback(text,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,error); | |
| 92 | + | |
| 93 | + if(lib3270_set_string_at(hSession, row, col, (unsigned char *) converted, -1) < 0) | |
| 89 | 94 | return errno; |
| 90 | 95 | |
| 91 | 96 | } |
| ... | ... | @@ -94,6 +99,7 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp |
| 94 | 99 | break; |
| 95 | 100 | |
| 96 | 101 | default: |
| 102 | + g_message("setstring was called with %u arguments.",(unsigned int) g_variant_n_children(request)); | |
| 97 | 103 | return EINVAL; |
| 98 | 104 | } |
| 99 | 105 | ... | ... |