diff --git a/server/src/core/linux/gobject.c b/server/src/core/linux/gobject.c index 326be92..3da45ee 100644 --- a/server/src/core/linux/gobject.c +++ b/server/src/core/linux/gobject.c @@ -136,7 +136,7 @@ void ipc3270_add_terminal_introspection(GString *introspection) { " " \ " " \ " " \ - " " \ + " " \ " " \ " " \ " " \ @@ -169,8 +169,8 @@ void ipc3270_add_terminal_introspection(GString *introspection) { " " \ " " \ " " \ - " " \ - " " \ + " " \ + " " \ " " \ " " \ " " \ diff --git a/server/src/core/linux/response.c b/server/src/core/linux/response.c new file mode 100644 index 0000000..64ca262 --- /dev/null +++ b/server/src/core/linux/response.c @@ -0,0 +1,139 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Referências: + * + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#include "gobject.h" +#include +#include +#include +#include +#include + +#include +#include + +/*--[ Widget definition ]----------------------------------------------------------------------------*/ + +struct _ipc3270Response { + GObject parent; + GVariant * value; +}; + +struct _ipc3270ResponseClass { + + GObjectClass parent; + int dummy; + +}; + + +G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +static void ipc3270Response_finalize(GObject *object) { + + ipc3270Response * response = IPC3270_RESPONSE(object); + + debug("%s value=%p",__FUNCTION__,response->value); + + if(response->value) + g_variant_unref(response->value); + +} + + +static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { + + debug("%s",__FUNCTION__); + + GObjectClass *object_class; + object_class = G_OBJECT_CLASS (klass); + object_class->finalize = ipc3270Response_finalize; + +} + +static void ipc3270Response_init(ipc3270Response *object) { + + object->value = NULL; + +} + +GObject * ipc3270_response_new() { + return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); +} + +void ipc3270_response_append_int32(GObject *object, gint32 value) { + + ipc3270Response * response = IPC3270_RESPONSE(object); + + if(response->value) + g_variant_unref(response->value); + + response->value = g_variant_new_int32(value); +} + +void ipc3270_response_append_uint32(GObject *object, guint32 value) { + + ipc3270Response * response = IPC3270_RESPONSE(object); + + if(response->value) + g_variant_unref(response->value); + + response->value = g_variant_new_uint32(value); +} + +void ipc3270_response_append_string(GObject *object, const gchar *text) { + + ipc3270Response * response = IPC3270_RESPONSE(object); + + if(response->value) + g_variant_unref(response->value); + + response->value = g_variant_new_string(text); + +} + +GVariant * ipc3270_response_steal_value(GObject *object) { + + ipc3270Response * response = IPC3270_RESPONSE(object); + + GVariant * value = response->value; + response->value = NULL; + + return value; +} + +gboolean ipc3270_response_has_values(GObject *object) { + return IPC3270_RESPONSE(object)->value != NULL; +} diff --git a/server/src/core/methods/field.c b/server/src/core/methods/field.c new file mode 100644 index 0000000..bec58d2 --- /dev/null +++ b/server/src/core/methods/field.c @@ -0,0 +1,38 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#include "private.h" + +int ipc3270_method_get_field_attribute(GObject *session, GVariant *request, GObject *response, GError **error) { + + debug("%s childs=%u",__FUNCTION__,(unsigned int) g_variant_n_children(request)); + + return ENOTSUP; +} + diff --git a/server/src/core/methods/get.c b/server/src/core/methods/get.c index 600d067..2552bad 100644 --- a/server/src/core/methods/get.c +++ b/server/src/core/methods/get.c @@ -38,15 +38,14 @@ int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *resp switch(g_variant_n_children(request)) { case 0: // No arguments { - + text = lib3270_get_string_at_address(hSession, 0, -1, '\n'); } break; case 3: // address, length, line-delimiter { - gint addr; - guint len; - guchar lf; + gint addr = 0, len = -1; + guchar lf = 0; g_variant_get(request, "(iiy)", &addr, &len, &lf); @@ -57,9 +56,11 @@ int ipc3270_method_get_string(GObject *session, GVariant *request, GObject *resp case 4: // row, col, length, line-delimiter { - guint row,col,len; - guchar lf; - g_variant_get(request, "(uuuy)", &row, &col, &len, &lf); + guint row = 0, col = 0; + gint len = -1; + guchar lf = 0; + + g_variant_get(request, "(uuiy)", &row, &col, &len, &lf); text = lib3270_get_string_at(hSession, row, col, len, lf); diff --git a/server/src/core/methods/set.c b/server/src/core/methods/set.c new file mode 100644 index 0000000..dbf737a --- /dev/null +++ b/server/src/core/methods/set.c @@ -0,0 +1,105 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + +#include "private.h" + +int ipc3270_method_set_string(GObject *session, GVariant *request, GObject *response, GError **error) { + + H3270 *hSession = ipc3270_get_session(session); + + gchar *text = NULL; + g_variant_get(request, "(&s)", &text); + + + if(*error) + return 0; + + switch(g_variant_n_children(request)) { + case 1: // Just text + { + gchar *text = NULL; + g_variant_get(request, "(&s)", &text); + + if(text) { + + g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); + + if(!lib3270_input_string(hSession,(const unsigned char *) converted, -1)) + return errno; + } + + } + + break; + + case 2: // Address and text + { + gint addr; + gchar *text = NULL; + g_variant_get(request, "(i&s)", &addr, &text); + + if(text) { + + g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); + + if(lib3270_set_string_at_address(hSession,addr,(unsigned char *) converted, -1) < 0) + return errno; + + } + + } + break; + + case 3: // Row, col & text + { + guint row, col; + gchar *text = NULL; + g_variant_get(request, "(uu&s)", &row, &col, &text); + + if(text) { + + g_autofree gchar * converted = ipc3270_convert_to_3270(session,text,error); + + if(lib3270_set_string_at(hSession, row, col, (unsigned char *) converted) < 0) + return errno; + + } + + } + break; + + default: + return EINVAL; + } + + ipc3270_response_append_uint32(response, 0); + + return 0; +} + diff --git a/server/testscripts/getstringat.sh b/server/testscripts/getstringat.sh new file mode 100755 index 0000000..220b320 --- /dev/null +++ b/server/testscripts/getstringat.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# https://stackoverflow.com/questions/48648952/set-get-property-using-dbus-send +# + +dbus-send \ + --session \ + --dest=br.com.bb.pw3270.a\ + --print-reply \ + "/br/com/bb/tn3270/session" \ + "br.com.bb.tn3270.session.getStringAtAddress" \ + int32:0 \ + int32:-1 \ + byte:0 + -- libgit2 0.21.2