Commit bb2bf4613c85e22b3c08e684be5d61a454ee119c
1 parent
18cf45f7
Exists in
master
and in
1 other branch
Updating boolean properties.
Showing
3 changed files
with
72 additions
and
3 deletions
Show diff stats
src/linux/getproperties.c
| ... | ... | @@ -52,7 +52,34 @@ ipc3270_get_property (GDBusConnection *connection, |
| 52 | 52 | |
| 53 | 53 | errno = 0; // Just in case. |
| 54 | 54 | |
| 55 | - // Check for property | |
| 55 | + // Boolean properties | |
| 56 | + const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); | |
| 57 | + for(ix = 0; boolprop[ix].name; ix++) { | |
| 58 | + | |
| 59 | + if(boolprop[ix].get && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) { | |
| 60 | + | |
| 61 | + // Found it! | |
| 62 | + int value = boolprop[ix].get(IPC3270(user_data)->hSession); | |
| 63 | + | |
| 64 | + debug("%s=%d",property_name,value); | |
| 65 | + | |
| 66 | + if(value > 0 || errno == 0) { | |
| 67 | + return g_variant_new_int16((gint16) value); | |
| 68 | + } | |
| 69 | + | |
| 70 | + // Erro! | |
| 71 | + g_set_error (error, | |
| 72 | + G_IO_ERROR, | |
| 73 | + G_IO_ERROR_FAILED, | |
| 74 | + g_strerror(errno) | |
| 75 | + ); | |
| 76 | + | |
| 77 | + return NULL; | |
| 78 | + } | |
| 79 | + | |
| 80 | + } | |
| 81 | + | |
| 82 | + // int properties | |
| 56 | 83 | const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); |
| 57 | 84 | for(ix = 0; intprop[ix].name; ix++) { |
| 58 | 85 | |
| ... | ... | @@ -79,6 +106,7 @@ ipc3270_get_property (GDBusConnection *connection, |
| 79 | 106 | |
| 80 | 107 | } |
| 81 | 108 | |
| 109 | + // String properties | |
| 82 | 110 | const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); |
| 83 | 111 | for(ix = 0; strprop[ix].name; ix++) { |
| 84 | 112 | ... | ... |
src/linux/gobject.c
| ... | ... | @@ -166,12 +166,22 @@ void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GEr |
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - // Inclui toggles | |
| 169 | + // Toggle properties | |
| 170 | 170 | for(ix = 0; ix < (int) LIB3270_TOGGLE_COUNT; ix++) { |
| 171 | 171 | g_string_append_printf(introspection, " <property type='i' name='%s' access='readwrite'/>", lib3270_get_toggle_name((LIB3270_TOGGLE) ix)); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - // Inclui propriedades. | |
| 174 | + // Boolean properties | |
| 175 | + const LIB3270_INT_PROPERTY * bol_props = lib3270_get_boolean_properties_list(); | |
| 176 | + for(ix = 0; bol_props[ix].name; ix++) { | |
| 177 | + debug("Boolean(%s)",bol_props[ix].name); | |
| 178 | + g_string_append_printf(introspection, " <property type='b' name='%s' access='%s'/>", | |
| 179 | + bol_props[ix].name, | |
| 180 | + ((bol_props[ix].set == NULL) ? "read" : "readwrite") | |
| 181 | + ); | |
| 182 | + } | |
| 183 | + | |
| 184 | + // Integer properties | |
| 175 | 185 | const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); |
| 176 | 186 | for(ix = 0; int_props[ix].name; ix++) { |
| 177 | 187 | g_string_append_printf(introspection, " <property type='i' name='%s' access='%s'/>", |
| ... | ... | @@ -180,6 +190,7 @@ void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GEr |
| 180 | 190 | ); |
| 181 | 191 | } |
| 182 | 192 | |
| 193 | + // String properties | |
| 183 | 194 | const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); |
| 184 | 195 | for(ix = 0; str_props[ix].name; ix++) { |
| 185 | 196 | g_string_append_printf(introspection, " <property type='s' name='%s' access='%s'/>", |
| ... | ... | @@ -194,6 +205,9 @@ void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GEr |
| 194 | 205 | ); |
| 195 | 206 | |
| 196 | 207 | gchar * introspection_xml = g_string_free(introspection,FALSE); |
| 208 | + | |
| 209 | + debug("\n%s\n",introspection_xml); | |
| 210 | + | |
| 197 | 211 | GDBusNodeInfo * introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); |
| 198 | 212 | |
| 199 | 213 | // Register object-id | ... | ... |
src/linux/setproperties.c
| ... | ... | @@ -52,6 +52,32 @@ ipc3270_set_property (GDBusConnection *connection, |
| 52 | 52 | // Check for property |
| 53 | 53 | size_t ix; |
| 54 | 54 | |
| 55 | + // Boolean properties | |
| 56 | + const LIB3270_INT_PROPERTY * boolprop = lib3270_get_boolean_properties_list(); | |
| 57 | + for(ix = 0; boolprop[ix].name; ix++) { | |
| 58 | + | |
| 59 | + if(boolprop[ix].set && !g_ascii_strcasecmp(boolprop[ix].name, property_name)) { | |
| 60 | + | |
| 61 | + // Found it! | |
| 62 | + if(boolprop[ix].set(IPC3270(user_data)->hSession, (int) g_variant_get_int32(value))) { | |
| 63 | + | |
| 64 | + // Erro! | |
| 65 | + g_set_error (error, | |
| 66 | + G_IO_ERROR, | |
| 67 | + G_IO_ERROR_FAILED, | |
| 68 | + g_strerror(errno) | |
| 69 | + ); | |
| 70 | + | |
| 71 | + return FALSE; | |
| 72 | + } | |
| 73 | + | |
| 74 | + return TRUE; | |
| 75 | + | |
| 76 | + } | |
| 77 | + | |
| 78 | + } | |
| 79 | + | |
| 80 | + // Integer properties | |
| 55 | 81 | const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); |
| 56 | 82 | for(ix = 0; intprop[ix].name; ix++) { |
| 57 | 83 | |
| ... | ... | @@ -76,6 +102,7 @@ ipc3270_set_property (GDBusConnection *connection, |
| 76 | 102 | |
| 77 | 103 | } |
| 78 | 104 | |
| 105 | + // String properties | |
| 79 | 106 | const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); |
| 80 | 107 | for(ix = 0; strprop[ix].name; ix++) { |
| 81 | 108 | ... | ... |