Commit 18cf45f79555e82ecb33ce99b6929359c8a5cd7f
1 parent
64e9837c
Exists in
master
and in
1 other branch
Using string properties table from lib3270.
Showing
3 changed files
with
91 additions
and
24 deletions
Show diff stats
src/linux/getproperties.c
| ... | ... | @@ -53,13 +53,13 @@ ipc3270_get_property (GDBusConnection *connection, |
| 53 | 53 | errno = 0; // Just in case. |
| 54 | 54 | |
| 55 | 55 | // Check for property |
| 56 | - const LIB3270_INT_PROPERTY * proplist = lib3270_get_int_properties_list(); | |
| 57 | - for(ix = 0; proplist[ix].name; ix++) { | |
| 56 | + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
| 57 | + for(ix = 0; intprop[ix].name; ix++) { | |
| 58 | 58 | |
| 59 | - if(proplist[ix].get && !g_ascii_strcasecmp(proplist[ix].name, property_name)) { | |
| 59 | + if(intprop[ix].get && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { | |
| 60 | 60 | |
| 61 | 61 | // Found it! |
| 62 | - int value = proplist[ix].get(IPC3270(user_data)->hSession); | |
| 62 | + int value = intprop[ix].get(IPC3270(user_data)->hSession); | |
| 63 | 63 | |
| 64 | 64 | debug("%s=%d",property_name,value); |
| 65 | 65 | |
| ... | ... | @@ -79,6 +79,30 @@ ipc3270_get_property (GDBusConnection *connection, |
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
| 83 | + for(ix = 0; strprop[ix].name; ix++) { | |
| 84 | + | |
| 85 | + if(strprop[ix].get && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { | |
| 86 | + | |
| 87 | + // Found it! | |
| 88 | + const char * value = strprop[ix].get(IPC3270(user_data)->hSession); | |
| 89 | + | |
| 90 | + if(value) { | |
| 91 | + debug("%s=%s",property_name,value); | |
| 92 | + return g_variant_new_string(value); | |
| 93 | + } | |
| 94 | + | |
| 95 | + // Erro! | |
| 96 | + g_set_error (error, | |
| 97 | + G_IO_ERROR, | |
| 98 | + G_IO_ERROR_FAILED, | |
| 99 | + g_strerror(errno) | |
| 100 | + ); | |
| 101 | + | |
| 102 | + return NULL; | |
| 103 | + } | |
| 104 | + | |
| 105 | + } | |
| 82 | 106 | |
| 83 | 107 | // Check for toggle |
| 84 | 108 | LIB3270_TOGGLE toggle = lib3270_get_toggle_id(property_name); |
| ... | ... | @@ -89,15 +113,6 @@ ipc3270_get_property (GDBusConnection *connection, |
| 89 | 113 | |
| 90 | 114 | } |
| 91 | 115 | |
| 92 | - // Check for pre-defineds | |
| 93 | - if(!g_ascii_strcasecmp("url", property_name)) { | |
| 94 | - return g_variant_new_string(lib3270_get_url(IPC3270(user_data)->hSession)); | |
| 95 | - } | |
| 96 | - | |
| 97 | - if(!g_ascii_strcasecmp("luname", property_name)) { | |
| 98 | - return g_variant_new_string(lib3270_get_luname(IPC3270(user_data)->hSession)); | |
| 99 | - } | |
| 100 | - | |
| 101 | 116 | g_set_error (error, |
| 102 | 117 | G_IO_ERROR, |
| 103 | 118 | G_IO_ERROR_NOT_FOUND, | ... | ... |
src/linux/gobject.c
| ... | ... | @@ -172,17 +172,23 @@ void ipc3270_set_session(GObject *object, H3270 *hSession, const char *name, GEr |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Inclui propriedades. |
| 175 | - const LIB3270_INT_PROPERTY * proplist = lib3270_get_int_properties_list(); | |
| 176 | - for(ix = 0; proplist[ix].name; ix++) { | |
| 175 | + const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); | |
| 176 | + for(ix = 0; int_props[ix].name; ix++) { | |
| 177 | 177 | g_string_append_printf(introspection, " <property type='i' name='%s' access='%s'/>", |
| 178 | - proplist[ix].name, | |
| 179 | - ((proplist[ix].set == NULL) ? "read" : "readwrite") | |
| 178 | + int_props[ix].name, | |
| 179 | + ((int_props[ix].set == NULL) ? "read" : "readwrite") | |
| 180 | + ); | |
| 181 | + } | |
| 182 | + | |
| 183 | + const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list(); | |
| 184 | + for(ix = 0; str_props[ix].name; ix++) { | |
| 185 | + g_string_append_printf(introspection, " <property type='s' name='%s' access='%s'/>", | |
| 186 | + str_props[ix].name, | |
| 187 | + ((str_props[ix].set == NULL) ? "read" : "readwrite") | |
| 180 | 188 | ); |
| 181 | 189 | } |
| 182 | 190 | |
| 183 | 191 | g_string_append(introspection, |
| 184 | - " <property type='s' name='url' access='readwrite'/>" | |
| 185 | - " <property type='s' name='luname' access='read'/>" | |
| 186 | 192 | " </interface>" |
| 187 | 193 | "</node>" |
| 188 | 194 | ); | ... | ... |
src/linux/setproperties.c
| ... | ... | @@ -52,13 +52,37 @@ ipc3270_set_property (GDBusConnection *connection, |
| 52 | 52 | // Check for property |
| 53 | 53 | size_t ix; |
| 54 | 54 | |
| 55 | - const LIB3270_INT_PROPERTY * proplist = lib3270_get_int_properties_list(); | |
| 56 | - for(ix = 0; proplist[ix].name; ix++) { | |
| 55 | + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
| 56 | + for(ix = 0; intprop[ix].name; ix++) { | |
| 57 | 57 | |
| 58 | - if(proplist[ix].set && !g_ascii_strcasecmp(proplist[ix].name, property_name)) { | |
| 58 | + if(intprop[ix].set && !g_ascii_strcasecmp(intprop[ix].name, property_name)) { | |
| 59 | 59 | |
| 60 | 60 | // Found it! |
| 61 | - if(proplist[ix].set(IPC3270(user_data)->hSession, (int) g_variant_get_int32(value))) { | |
| 61 | + if(intprop[ix].set(IPC3270(user_data)->hSession, (int) g_variant_get_int32(value))) { | |
| 62 | + | |
| 63 | + // Erro! | |
| 64 | + g_set_error (error, | |
| 65 | + G_IO_ERROR, | |
| 66 | + G_IO_ERROR_FAILED, | |
| 67 | + g_strerror(errno) | |
| 68 | + ); | |
| 69 | + | |
| 70 | + return FALSE; | |
| 71 | + } | |
| 72 | + | |
| 73 | + return TRUE; | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | + } | |
| 78 | + | |
| 79 | + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
| 80 | + for(ix = 0; strprop[ix].name; ix++) { | |
| 81 | + | |
| 82 | + if(strprop[ix].set && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { | |
| 83 | + | |
| 84 | + // Found it! | |
| 85 | + if(strprop[ix].set(IPC3270(user_data)->hSession, g_variant_get_string(value,NULL))) { | |
| 62 | 86 | |
| 63 | 87 | // Erro! |
| 64 | 88 | g_set_error (error, |
| ... | ... | @@ -97,12 +121,34 @@ ipc3270_set_property (GDBusConnection *connection, |
| 97 | 121 | return TRUE; |
| 98 | 122 | } |
| 99 | 123 | |
| 124 | + /* | |
| 100 | 125 | // Check for pre-defineds |
| 101 | 126 | if(!g_ascii_strcasecmp("url", property_name)) { |
| 102 | - lib3270_set_url(IPC3270(user_data)->hSession,g_variant_get_string(value,NULL)); | |
| 127 | + if(lib3270_set_url(IPC3270(user_data)->hSession,g_variant_get_string(value,NULL))) { | |
| 128 | + g_set_error (error, | |
| 129 | + G_IO_ERROR, | |
| 130 | + G_IO_ERROR_FAILED, | |
| 131 | + g_strerror(errno) | |
| 132 | + ); | |
| 133 | + return FALSE; | |
| 134 | + } | |
| 103 | 135 | return TRUE; |
| 104 | 136 | } |
| 105 | 137 | |
| 138 | + if(!g_ascii_strcasecmp("luname", property_name)) { | |
| 139 | + if(lib3270_set_luname(IPC3270(user_data)->hSession,g_variant_get_string(value,NULL))) { | |
| 140 | + g_set_error (error, | |
| 141 | + G_IO_ERROR, | |
| 142 | + G_IO_ERROR_FAILED, | |
| 143 | + g_strerror(errno) | |
| 144 | + ); | |
| 145 | + return FALSE; | |
| 146 | + } | |
| 147 | + return TRUE; | |
| 148 | + } | |
| 149 | + */ | |
| 150 | + | |
| 151 | + | |
| 106 | 152 | g_set_error (error, |
| 107 | 153 | G_IO_ERROR, |
| 108 | 154 | G_IO_ERROR_NOT_FOUND, | ... | ... |