Commit 251421de78e8e46b954e5f2fbf128d4bf0e8d141
1 parent
73c2260f
Exists in
master
and in
1 other branch
Updating properties.
Showing
3 changed files
with
67 additions
and
6 deletions
Show diff stats
server/src/core/getproperties.c
| ... | ... | @@ -77,12 +77,37 @@ GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GEr |
| 77 | 77 | if(intprop[ix].get && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { |
| 78 | 78 | |
| 79 | 79 | // Found it! |
| 80 | + errno = 0; // Reset errno | |
| 80 | 81 | int value = intprop[ix].get(hSession); |
| 81 | 82 | |
| 82 | 83 | debug("%s=%d",property_name,value); |
| 83 | 84 | |
| 84 | - if(value > 0 || errno == 0) { | |
| 85 | - return g_variant_new_int16((gint16) value); | |
| 85 | + if(errno == 0) { | |
| 86 | + return g_variant_new_int32((gint32) value); | |
| 87 | + } | |
| 88 | + | |
| 89 | + // Erro! | |
| 90 | + ipc3270_set_error(object,errno,error); | |
| 91 | + return NULL; | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + // Unsigned int properties | |
| 98 | + const LIB3270_UINT_PROPERTY * uintprop = lib3270_get_unsigned_properties_list(); | |
| 99 | + for(ix = 0; uintprop[ix].name; ix++) { | |
| 100 | + | |
| 101 | + if(uintprop[ix].get && !g_ascii_strcasecmp(uintprop[ix].name, property_name)) { | |
| 102 | + | |
| 103 | + // Found it! | |
| 104 | + errno = 0; // Reset errno. | |
| 105 | + unsigned int value = uintprop[ix].get(hSession); | |
| 106 | + | |
| 107 | + debug("%s=%d",property_name,value); | |
| 108 | + | |
| 109 | + if(errno == 0) { | |
| 110 | + return g_variant_new_uint32((guint32) value); | |
| 86 | 111 | } |
| 87 | 112 | |
| 88 | 113 | // Erro! | ... | ... |
server/src/core/linux/gobject.c
| ... | ... | @@ -174,7 +174,7 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 174 | 174 | |
| 175 | 175 | // Toggle properties |
| 176 | 176 | for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) { |
| 177 | - g_string_append_printf(introspection, " <property type='i' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix)); | |
| 177 | + g_string_append_printf(introspection, " <property type='b' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix)); | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Boolean properties |
| ... | ... | @@ -196,6 +196,15 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 196 | 196 | ); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | + // Unsigned integer properties | |
| 200 | + const LIB3270_UINT_PROPERTY * uint_props = lib3270_get_unsigned_properties_list(); | |
| 201 | + for(ix = 0; uint_props[ix].name; ix++) { | |
| 202 | + g_string_append_printf(introspection, " <property type='u' name='%s' access='%s'/>", | |
| 203 | + uint_props[ix].name, | |
| 204 | + ((uint_props[ix].set == NULL) ? "read" : "readwrite") | |
| 205 | + ); | |
| 206 | + } | |
| 207 | + | |
| 199 | 208 | // String properties |
| 200 | 209 | const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); |
| 201 | 210 | for(ix = 0; str_props[ix].name; ix++) { | ... | ... |
server/src/core/setproperties.c
| ... | ... | @@ -45,7 +45,7 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari |
| 45 | 45 | H3270 * hSession = ipc3270_get_session(object); |
| 46 | 46 | |
| 47 | 47 | if(!value) { |
| 48 | - g_set_error(&error,ipc3270_get_error_domain(object),EINVAL,"Set property method requires an argument"); | |
| 48 | + g_set_error(error,ipc3270_get_error_domain(object),EINVAL,"Set property method requires an argument"); | |
| 49 | 49 | return FALSE; |
| 50 | 50 | } |
| 51 | 51 | |
| ... | ... | @@ -83,7 +83,7 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari |
| 83 | 83 | if(intprop[ix].set && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { |
| 84 | 84 | |
| 85 | 85 | // Found it! |
| 86 | - if(intprop[ix].set(hSession, (int) (g_variant_get_boolean(value) ? 1 : 0))) { | |
| 86 | + if(intprop[ix].set(hSession, (int) g_variant_get_int32(value))) { | |
| 87 | 87 | |
| 88 | 88 | // Erro! |
| 89 | 89 | g_set_error_literal( |
| ... | ... | @@ -102,6 +102,33 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari |
| 102 | 102 | |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | + // Unsigned int properties | |
| 106 | + const LIB3270_UINT_PROPERTY * uintprop = lib3270_get_unsigned_properties_list(); | |
| 107 | + for(ix = 0; uintprop[ix].name; ix++) { | |
| 108 | + | |
| 109 | + if(uintprop[ix].set && !g_ascii_strcasecmp(uintprop[ix].name, property_name)) { | |
| 110 | + | |
| 111 | + // Found it! | |
| 112 | + if(uintprop[ix].set(hSession, (unsigned int) g_variant_get_uint32(value) ? 1 : 0)) { | |
| 113 | + | |
| 114 | + // Erro! | |
| 115 | + g_set_error_literal( | |
| 116 | + error, | |
| 117 | + G_IO_ERROR, | |
| 118 | + G_IO_ERROR_FAILED, | |
| 119 | + g_strerror(errno) | |
| 120 | + ); | |
| 121 | + | |
| 122 | + return FALSE; | |
| 123 | + } | |
| 124 | + | |
| 125 | + return TRUE; | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + } | |
| 130 | + | |
| 131 | + | |
| 105 | 132 | // String properties |
| 106 | 133 | const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); |
| 107 | 134 | for(ix = 0; strprop[ix].name; ix++) { |
| ... | ... | @@ -132,7 +159,7 @@ gboolean ipc3270_set_property(GObject *object, const gchar *property_name, GVari |
| 132 | 159 | if(toggle != (LIB3270_TOGGLE) -1) { |
| 133 | 160 | |
| 134 | 161 | // Is a Tn3270 toggle, get it! |
| 135 | - if(lib3270_set_toggle(hSession,toggle,(int) g_variant_get_int32(value))) { | |
| 162 | + if(lib3270_set_toggle(hSession,toggle,(int) (g_variant_get_boolean(value) ? 1 : 0))) { | |
| 136 | 163 | |
| 137 | 164 | // Erro! |
| 138 | 165 | g_set_error_literal(error, | ... | ... |