Commit 2d9339caf7a21800d4964cf25eb9968293f2bc65
1 parent
baa72652
Exists in
master
and in
1 other branch
Fixing bugs on remote attributes.
Showing
7 changed files
with
86 additions
and
10 deletions
Show diff stats
client/src/session/remote/actions.cc
... | ... | @@ -47,6 +47,10 @@ |
47 | 47 | |
48 | 48 | namespace TN3270 { |
49 | 49 | |
50 | + TN3270::Action * IPC::Session::getAction(const LIB3270_ACTION *descriptor) { | |
51 | + return new IPC::Action(this, descriptor); | |
52 | + } | |
53 | + | |
50 | 54 | IPC::Action::Action(Session *session, const LIB3270_ACTION *descriptor) : TN3270::Action(descriptor) { |
51 | 55 | this->session = session; |
52 | 56 | } |
... | ... | @@ -55,10 +59,12 @@ |
55 | 59 | |
56 | 60 | bool rc; |
57 | 61 | |
62 | + debug(__FUNCTION__); | |
58 | 63 | Request(*session,"activatable") |
59 | 64 | .push(descriptor->name) |
60 | 65 | .call() |
61 | 66 | .pop(rc); |
67 | + debug(__FUNCTION__); | |
62 | 68 | |
63 | 69 | return rc; |
64 | 70 | } | ... | ... |
client/src/session/remote/attribute.cc
... | ... | @@ -196,6 +196,61 @@ |
196 | 196 | |
197 | 197 | }; |
198 | 198 | |
199 | + // Toggle attribute | |
200 | + class TN3270_PRIVATE ToggleAttribute : public TemplateAttribute<LIB3270_TOGGLE_ENTRY> { | |
201 | + public: | |
202 | + ToggleAttribute(const IPC::Session *session, const LIB3270_TOGGLE_ENTRY *worker) : TemplateAttribute<LIB3270_TOGGLE_ENTRY>(session, Attribute::Boolean, worker) { | |
203 | + | |
204 | + get.asString = [](const Attribute & attr, const void *worker) { | |
205 | + return attr.getBoolean() ? "true" : "false"; | |
206 | + }; | |
207 | + | |
208 | + get.asInt32 = [](const Attribute & attr, const void *worker) { | |
209 | + return (uint32_t) attr.getBoolean(); | |
210 | + }; | |
211 | + | |
212 | + get.asUint32 = [](const Attribute & attr, const void *worker) { | |
213 | + return (uint32_t) attr.getInt32(); | |
214 | + }; | |
215 | + | |
216 | + get.asBoolean = [](const Attribute & attr, const void *worker) { | |
217 | + | |
218 | + const struct Worker * w = (const struct Worker *) worker; | |
219 | + | |
220 | + bool value; | |
221 | + | |
222 | + IPC::Request(*w->session,false,w->methods->name) | |
223 | + .call() | |
224 | + .pop(value); | |
225 | + | |
226 | + return value; | |
227 | + }; | |
228 | + | |
229 | + set.asInt32 = [](const Attribute & attr, const void *worker, const int32_t value) { | |
230 | + | |
231 | + const struct Worker * w = (const struct Worker *) worker; | |
232 | + | |
233 | + IPC::Request(*w->session,true,w->methods->name) | |
234 | + .push(value) | |
235 | + .call(); | |
236 | + | |
237 | + }; | |
238 | + | |
239 | + set.asBoolean = [](const Attribute & attr, const void *worker, const bool value) { | |
240 | + | |
241 | + const struct Worker * w = (const struct Worker *) worker; | |
242 | + | |
243 | + IPC::Request(*w->session,true,w->methods->name) | |
244 | + .push(value) | |
245 | + .call(); | |
246 | + | |
247 | + }; | |
248 | + | |
249 | + } | |
250 | + | |
251 | + }; | |
252 | + | |
253 | + | |
199 | 254 | // Unsigned int attribute |
200 | 255 | class TN3270_PRIVATE UnsignedIntAttribute : public TemplateAttribute<LIB3270_UINT_PROPERTY> { |
201 | 256 | public: |
... | ... | @@ -367,7 +422,6 @@ |
367 | 422 | |
368 | 423 | // Check for boolean properties |
369 | 424 | { |
370 | - /* | |
371 | 425 | const LIB3270_TOGGLE_ENTRY *toggles = lib3270_get_toggle_list(); |
372 | 426 | for(size_t ix = 0; toggles[ix].name; ix++) { |
373 | 427 | |
... | ... | @@ -376,7 +430,6 @@ |
376 | 430 | } |
377 | 431 | |
378 | 432 | } |
379 | - */ | |
380 | 433 | |
381 | 434 | const LIB3270_INT_PROPERTY * intprop = lib3270_get_boolean_properties_list(); |
382 | 435 | for(size_t ix = 0; intprop[ix].name; ix++) { |
... | ... | @@ -426,12 +479,10 @@ |
426 | 479 | |
427 | 480 | // Add boolean properties |
428 | 481 | { |
429 | - /* | |
430 | 482 | const LIB3270_TOGGLE_ENTRY *toggles = lib3270_get_toggle_list(); |
431 | 483 | for(size_t ix = 0; toggles[ix].name; ix++) { |
432 | 484 | attributes.push_back(ToggleAttribute(this,&toggles[ix])); |
433 | 485 | } |
434 | - */ | |
435 | 486 | |
436 | 487 | const LIB3270_INT_PROPERTY * intprop = lib3270_get_boolean_properties_list(); |
437 | 488 | for(size_t ix = 0; intprop[ix].name; ix++) { | ... | ... |
client/src/session/remote/private.h
... | ... | @@ -105,6 +105,9 @@ |
105 | 105 | virtual ~Session(); |
106 | 106 | |
107 | 107 | // Actions |
108 | + TN3270::Action * getAction(const LIB3270_ACTION *descriptor) override; | |
109 | + | |
110 | + // Actions | |
108 | 111 | void action(const char *action_name) override; |
109 | 112 | void connect(const char *url, int seconds) override; |
110 | 113 | void disconnect() override; | ... | ... |
client/src/testprogram/testprogram.cc
server/src/core/linux/response.c
... | ... | @@ -124,6 +124,16 @@ void ipc3270_response_append_string(GObject *object, const gchar *text) { |
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | +void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
128 | + | |
129 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
130 | + | |
131 | + if(response->value) | |
132 | + g_variant_unref(response->value); | |
133 | + | |
134 | + response->value = g_variant_new_boolean(value); | |
135 | +} | |
136 | + | |
127 | 137 | GVariant * ipc3270_response_steal_value(GObject *object) { |
128 | 138 | |
129 | 139 | ipc3270Response * response = IPC3270_RESPONSE(object); | ... | ... |
server/src/core/methods/action.c
... | ... | @@ -46,21 +46,25 @@ int ipc3270_method_action(GObject *session, GVariant *request, GObject *response |
46 | 46 | return 0; |
47 | 47 | } |
48 | 48 | |
49 | -int ipc3270_method_activatable(GObject *session, GVariant *request, GObject *response, GError G_GNUC_UNUSED(**error)) { | |
49 | +int ipc3270_method_activatable(GObject *session, GVariant *request, GObject *response, GError **error) { | |
50 | 50 | |
51 | 51 | if(g_variant_n_children(request) != 1) { |
52 | 52 | g_message("activatable was called with %u arguments.",(unsigned int) g_variant_n_children(request)); |
53 | - ipc3270_response_append_int32(response, EINVAL); | |
53 | + | |
54 | + if(!*error) | |
55 | + g_set_error_literal(error,g_quark_from_static_string(PACKAGE_NAME),EINVAL,"Unexpected argument number"); | |
56 | + | |
57 | + return 0; | |
54 | 58 | } |
55 | 59 | |
56 | 60 | GVariant *value = g_variant_get_child_value(request,0); |
57 | 61 | |
58 | - LIB3270_ACTION * action = lib3270_action_get_by_name(g_variant_get_string(value,NULL)); | |
62 | + const LIB3270_ACTION * action = lib3270_action_get_by_name(g_variant_get_string(value,NULL)); | |
59 | 63 | |
60 | 64 | if(action) { |
61 | - ipc3270_response_append_int32(response, lib3270_action_is_activatable(action, ipc3270_get_session(session))); | |
65 | + ipc3270_response_append_boolean(response, lib3270_action_is_activatable(action, ipc3270_get_session(session))); | |
62 | 66 | } else { |
63 | - ipc3270_response_append_int32(response, ENOENT); | |
67 | + ipc3270_response_append_boolean(response, FALSE); | |
64 | 68 | } |
65 | 69 | |
66 | 70 | g_variant_unref(value); | ... | ... |
server/src/include/ipc-glib.h
... | ... | @@ -109,6 +109,8 @@ |
109 | 109 | void ipc3270_response_append_int32(GObject *object, gint32 value); |
110 | 110 | void ipc3270_response_append_uint32(GObject *object, guint32 value); |
111 | 111 | void ipc3270_response_append_string(GObject *object, const gchar *text); |
112 | + void ipc3270_response_append_boolean(GObject *object, gboolean value); | |
113 | + | |
112 | 114 | gboolean ipc3270_response_has_values(GObject *object); |
113 | 115 | GVariant * ipc3270_response_steal_value(GObject *object); |
114 | 116 | ... | ... |