diff --git a/src/linux/getproperties.c b/src/linux/getproperties.c index 943c27c..31487ed 100644 --- a/src/linux/getproperties.c +++ b/src/linux/getproperties.c @@ -33,7 +33,8 @@ */ #include "gobject.h" -#include +#include +#include #include #include @@ -47,13 +48,41 @@ ipc3270_get_property (GDBusConnection *connection, GError **error, gpointer user_data) { - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); + size_t ix; + + errno = 0; // Just in case. + + // Check for property + const LIB3270_INT_PROPERTY * proplist = lib3270_get_int_properties_list(); + for(ix = 0; proplist[ix].name; ix++) { + + if(proplist[ix].get && !g_ascii_strcasecmp(proplist[ix].name, property_name)) { + + // Found it! + int value = 0; // proplist[ix].get(IPC3270(user_data)->hSession); + if(value > 0 || errno == 0) { + return g_variant_new_int16((gint16) value); + } + + // Erro! + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + g_strerror(errno) + ); - debug("%s: toggle(%s)=%d", __FUNCTION__, property_name,(int) toggle); + return NULL; + } + + } + + + // Check for toggle + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); if(toggle != (LIB3270_TOGGLE) -1) { // Is a Tn3270 toggle, get it! - return g_variant_new_int16((gint16) lib3270_get_toggle(IPC3270(user_data)->hSession,toggle)); + return g_variant_new_int16((gint16) lib3270_get_toggle( (IPC3270(user_data)->hSession), toggle)); } diff --git a/src/linux/gobject.c b/src/linux/gobject.c index 1701de1..0a68a54 100644 --- a/src/linux/gobject.c +++ b/src/linux/gobject.c @@ -33,7 +33,8 @@ */ #include "gobject.h" -#include +#include +#include #include #include @@ -154,14 +155,22 @@ GObject * ipc3270_new(GtkWidget *window, GtkWidget *terminal) { " " " " " " - " " - " " ); + // Inclui toggles for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) { g_string_append_printf(introspection, " ", lib3270_get_toggle_name((LIB3270_TOGGLE) ix)); } + // Inclui propriedades. + const LIB3270_INT_PROPERTY * proplist = lib3270_get_int_properties_list(); + for(ix = 0; proplist[ix].name; ix++) { + g_string_append_printf(introspection, " ", + proplist[ix].name, + ((proplist[ix].set == NULL) ? "read" : "readwrite") + ); + } + g_string_append(introspection, " " "" diff --git a/src/linux/gobject.h b/src/linux/gobject.h index 786403d..fde75b2 100644 --- a/src/linux/gobject.h +++ b/src/linux/gobject.h @@ -58,7 +58,7 @@ GObject parent; GDBusConnection * connection; guint id; - GtkWidget * hSession; + H3270 * hSession; }; struct _ipc3270Class { diff --git a/src/linux/setproperties.c b/src/linux/setproperties.c index e69bb50..1fb822e 100644 --- a/src/linux/setproperties.c +++ b/src/linux/setproperties.c @@ -33,7 +33,8 @@ */ #include "gobject.h" -#include +#include +#include #include #include @@ -48,6 +49,53 @@ ipc3270_set_property (GDBusConnection *connection, GError **error, gpointer user_data) { + // Check for property + size_t ix; + + const LIB3270_INT_PROPERTY * proplist = lib3270_get_int_properties_list(); + for(ix = 0; proplist[ix].name; ix++) { + + if(proplist[ix].set && !g_ascii_strcasecmp(proplist[ix].name, property_name)) { + + // Found it! + if(proplist[ix].set(IPC3270(user_data)->hSession, (int) g_variant_get_int32(value))) { + + // Erro! + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + g_strerror(errno) + ); + + return FALSE; + } + + return TRUE; + + } + + } + + // Check for toggle + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); + if(toggle != (LIB3270_TOGGLE) -1) { + + // Is a Tn3270 toggle, get it! + if(lib3270_set_toggle(IPC3270(user_data)->hSession,toggle,(int) g_variant_get_int32(value))) { + + // Erro! + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + g_strerror(errno) + ); + + return FALSE; + + } + + return TRUE; + } g_set_error (error, G_IO_ERROR, @@ -55,5 +103,5 @@ ipc3270_set_property (GDBusConnection *connection, "Can't find any property named %s", property_name ); - return *error == NULL; + return FALSE; } -- libgit2 0.21.2