Commit b6677ed497fd79d5355f245fb4470c9e7138e840
1 parent
fea686b0
Exists in
master
and in
1 other branch
Updating windows code.
Showing
4 changed files
with
157 additions
and
2 deletions
Show diff stats
server/src/core/windows/gobject.c
| ... | ... | @@ -56,6 +56,8 @@ static void ipc3270_finalize(GObject *object) { |
| 56 | 56 | v3270_set_session_name(ipc->terminal,widget_name); |
| 57 | 57 | lib3270_set_session_id(ipc->hSession, 0); |
| 58 | 58 | |
| 59 | + g_free(ipc->charset); | |
| 60 | + | |
| 59 | 61 | G_OBJECT_CLASS(ipc3270_parent_class)->finalize(object); |
| 60 | 62 | |
| 61 | 63 | } |
| ... | ... | @@ -76,6 +78,12 @@ static void ipc3270_init(ipc3270 *object) { |
| 76 | 78 | debug("%s(%p)",__FUNCTION__,object); |
| 77 | 79 | object->error_domain = g_quark_from_static_string(PACKAGE_NAME); |
| 78 | 80 | |
| 81 | + // Get charset | |
| 82 | + const gchar * scharset = NULL; | |
| 83 | + g_get_charset(&scharset); | |
| 84 | + | |
| 85 | + object->charset = g_strdup(scharset); | |
| 86 | + | |
| 79 | 87 | } |
| 80 | 88 | |
| 81 | 89 | GObject * ipc3270_new() { |
| ... | ... | @@ -108,8 +116,11 @@ GQuark ipc3270_get_error_domain(GObject *object) { |
| 108 | 116 | } |
| 109 | 117 | |
| 110 | 118 | gchar * ipc3270_convert_to_3270(GObject *object, const gchar *string, GError **error) { |
| 111 | - return g_convert_with_fallback(string,-1,ipc3270_get_display_charset(object),"UTF-8","?",NULL,NULL,error); | |
| 119 | + return g_convert_with_fallback(string,-1,lib3270_get_display_charset(IPC3270(object)->hSession),IPC3270(object)->charset,"?",NULL,NULL,error); | |
| 112 | 120 | } |
| 113 | 121 | |
| 122 | +gchar * ipc3270_convert_from_3270(GObject *object, const gchar *string, GError **error) { | |
| 123 | + return g_convert_with_fallback(string,-1,IPC3270(object)->charset,lib3270_get_display_charset(IPC3270(object)->hSession),"?",NULL,NULL,error); | |
| 124 | +} | |
| 114 | 125 | |
| 115 | 126 | ... | ... |
server/src/core/windows/gobject.h
server/src/core/windows/pipesource.c
| ... | ... | @@ -121,7 +121,14 @@ static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) { |
| 121 | 121 | break; |
| 122 | 122 | |
| 123 | 123 | case 3: // method |
| 124 | - response = ipc3270_method_call(source->object, request_name, parameters, &error); | |
| 124 | + { | |
| 125 | + g_autoptr(GObject) rsp = ipc3270_response_new(); | |
| 126 | + ipc3270_method_call(source->object, request_name, parameters, response, &error); | |
| 127 | + | |
| 128 | + if(ipc3270_response_has_values(rsp)) | |
| 129 | + response = ipc3270_response_steal_value(rsp); | |
| 130 | + | |
| 131 | + } | |
| 125 | 132 | break; |
| 126 | 133 | |
| 127 | 134 | default: | ... | ... |
| ... | ... | @@ -0,0 +1,136 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Referências: | |
| 24 | + * | |
| 25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | + * | |
| 28 | + * Contatos: | |
| 29 | + * | |
| 30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | +#include "gobject.h" | |
| 36 | +#include <lib3270.h> | |
| 37 | +#include <lib3270/actions.h> | |
| 38 | +#include <lib3270/properties.h> | |
| 39 | +#include <lib3270/toggle.h> | |
| 40 | +#include <v3270.h> | |
| 41 | + | |
| 42 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 43 | + | |
| 44 | +struct _ipc3270Response { | |
| 45 | + GObject parent; | |
| 46 | + GVariant * value; | |
| 47 | +}; | |
| 48 | + | |
| 49 | +struct _ipc3270ResponseClass { | |
| 50 | + | |
| 51 | + GObjectClass parent; | |
| 52 | + int dummy; | |
| 53 | + | |
| 54 | +}; | |
| 55 | + | |
| 56 | + | |
| 57 | +G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 58 | + | |
| 59 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 60 | + | |
| 61 | +static void ipc3270Response_finalize(GObject *object) { | |
| 62 | + | |
| 63 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 64 | + | |
| 65 | + debug("%s value=%p",__FUNCTION__,response->value); | |
| 66 | + | |
| 67 | + if(response->value) | |
| 68 | + g_variant_unref(response->value); | |
| 69 | + | |
| 70 | +} | |
| 71 | + | |
| 72 | + | |
| 73 | +static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 74 | + | |
| 75 | + debug("%s",__FUNCTION__); | |
| 76 | + | |
| 77 | + GObjectClass *object_class; | |
| 78 | + object_class = G_OBJECT_CLASS (klass); | |
| 79 | + object_class->finalize = ipc3270Response_finalize; | |
| 80 | + | |
| 81 | +} | |
| 82 | + | |
| 83 | +static void ipc3270Response_init(ipc3270Response *object) { | |
| 84 | + | |
| 85 | + object->value = NULL; | |
| 86 | + | |
| 87 | +} | |
| 88 | + | |
| 89 | +GObject * ipc3270_response_new() { | |
| 90 | + return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 91 | +} | |
| 92 | + | |
| 93 | +void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 94 | + | |
| 95 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 96 | + | |
| 97 | + if(response->value) | |
| 98 | + g_variant_unref(response->value); | |
| 99 | + | |
| 100 | + response->value = g_variant_new_int32(value); | |
| 101 | +} | |
| 102 | + | |
| 103 | +void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 104 | + | |
| 105 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 106 | + | |
| 107 | + if(response->value) | |
| 108 | + g_variant_unref(response->value); | |
| 109 | + | |
| 110 | + response->value = g_variant_new_uint32(value); | |
| 111 | +} | |
| 112 | + | |
| 113 | +void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 114 | + | |
| 115 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 116 | + | |
| 117 | + if(response->value) | |
| 118 | + g_variant_unref(response->value); | |
| 119 | + | |
| 120 | + response->value = g_variant_new_string(text); | |
| 121 | + | |
| 122 | +} | |
| 123 | + | |
| 124 | +GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 125 | + | |
| 126 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 127 | + | |
| 128 | + GVariant * value = response->value; | |
| 129 | + response->value = NULL; | |
| 130 | + | |
| 131 | + return value; | |
| 132 | +} | |
| 133 | + | |
| 134 | +gboolean ipc3270_response_has_values(GObject *object) { | |
| 135 | + return IPC3270_RESPONSE(object)->value != NULL; | |
| 136 | +} | ... | ... |