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
| @@ -96,6 +96,8 @@ | @@ -96,6 +96,8 @@ | ||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | void IPC::Session::setCharSet(const char *charset) { | 98 | void IPC::Session::setCharSet(const char *charset) { |
| 99 | + // D-Bus calls are always UTF-8 | ||
| 100 | + Abstract::Session::setCharSet("UTF-8",charset); | ||
| 99 | } | 101 | } |
| 100 | 102 | ||
| 101 | unsigned short IPC::Session::getScreenWidth() const { | 103 | unsigned short IPC::Session::getScreenWidth() const { |
client/src/testprogram/testprogram.cc
| @@ -96,7 +96,7 @@ | @@ -96,7 +96,7 @@ | ||
| 96 | << "\tRevision: " << host.getRevision() | 96 | << "\tRevision: " << host.getRevision() |
| 97 | << std::endl; | 97 | << std::endl; |
| 98 | 98 | ||
| 99 | -// host.connect(nullptr); | 99 | + host.connect(nullptr); |
| 100 | 100 | ||
| 101 | cout | 101 | cout |
| 102 | << "Connection state is " << toCharString(host.getConnectionState()) << std::endl | 102 | << "Connection state is " << toCharString(host.getConnectionState()) << std::endl |
server/src/core/methods/get.c
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | 29 | ||
| 30 | #include "private.h" | 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 | H3270 *hSession = ipc3270_get_session(session); | 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,7 +75,9 @@ int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *resp | ||
| 75 | if(!text) | 75 | if(!text) |
| 76 | return errno; | 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 | return 0; | 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,7 +38,6 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | ||
| 38 | gchar *text = NULL; | 38 | gchar *text = NULL; |
| 39 | g_variant_get(request, "(&s)", &text); | 39 | g_variant_get(request, "(&s)", &text); |
| 40 | 40 | ||
| 41 | - | ||
| 42 | if(*error) | 41 | if(*error) |
| 43 | return 0; | 42 | return 0; |
| 44 | 43 | ||
| @@ -50,7 +49,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | @@ -50,7 +49,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | ||
| 50 | 49 | ||
| 51 | if(text) { | 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 | debug("lib3270_input_string has failed: %s", strerror(errno)); | 55 | debug("lib3270_input_string has failed: %s", strerror(errno)); |
| 55 | return errno; | 56 | return errno; |
| 56 | } | 57 | } |
| @@ -69,7 +70,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | @@ -69,7 +70,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | ||
| 69 | 70 | ||
| 70 | if(text) { | 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 | return errno; | 76 | return errno; |
| 74 | 77 | ||
| 75 | } | 78 | } |
| @@ -85,7 +88,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | @@ -85,7 +88,9 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | ||
| 85 | 88 | ||
| 86 | if(text) { | 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 | return errno; | 94 | return errno; |
| 90 | 95 | ||
| 91 | } | 96 | } |
| @@ -94,6 +99,7 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | @@ -94,6 +99,7 @@ int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *resp | ||
| 94 | break; | 99 | break; |
| 95 | 100 | ||
| 96 | default: | 101 | default: |
| 102 | + g_message("setstring was called with %u arguments.",(unsigned int) g_variant_n_children(request)); | ||
| 97 | return EINVAL; | 103 | return EINVAL; |
| 98 | } | 104 | } |
| 99 | 105 |