See gupnp_service_proxy_action_get_result(); this version takes a #GHashTable for runtime generated parameter lists.
The out_hash
needs to be pre-initialized with key value pairs denoting the argument
to retrieve and an empty #GValue initialized to hold the wanted type with g_value_init().
action = gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (object),
res,
&error);
if (error != NULL) {
g_print ("Call failed: %s", error->message);
g_clear_error (&error);
return;
}
GValue play_mode = G_VALUE_INIT;
g_value_init(&play_mode, G_TYPE_STRING);
GValue rec_quality_mode = G_VALUE_INIT;
g_value_init(&rec_quality_mode, G_TYPE_STRING);
GHashTable *out_args = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert(out_args, "PlayMode", &play_mode);
g_hash_table_insert(out_args, "RecQualityMode", &rec_quality_mode);
if (!gupnp_service_proxy_action_get_result_hash (action,
out_args,
&error)) {
g_print ("Getting results failed: %s", error->message);
g_clear_error (&error);
return;
}
g_value_unset (&play_mode);
g_value_unset (&rec_quality_mode);
g_hash_table_unref (out_args);
}
A #GHashTable of out parameter name and initialised #GValue pairs
A variant of gupnp_service_proxy_action_get_result() that takes lists of
out-parameter names, types and place-holders for values. The returned list
in out_values
must be freed using #g_list_free and each element in it using
#g_value_unset and #g_free.
action = gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (object),
res,
&error);
if (error != NULL) {
g_print ("Call failed: %s", error->message);
g_clear_error (&error);
return;
}
GList *out_args = NULL;
out_args = g_list_append (out_args, "PlayMode");
out_args = g_list_append (out_args, "RecQualityMode");
GList *out_types = NULL;
out_types = g_list_append (out_types, GSIZE_TO_POINTER (G_TYPE_STRING));
out_types = g_list_append (out_types, GSIZE_TO_POINTER (G_TYPE_STRING));
GList *out_values = NULL;
if (!gupnp_service_proxy_action_get_result_list (action,
out_args,
out_types,
&out_values,
&error)) {
g_print ("Getting results failed: %s", error->message);
g_clear_error (&error);
return;
}
GList *iter = out_values;
while (iter != NULL) {
GValue *value = iter->data;
g_print ("Result: %s\n", g_value_get_string (value));
g_value_unset (value);
g_free (value);
iter = g_list_remove_link (iter, iter);
}
g_list_free (out_values);
}
#GList of 'out' parameter names (as strings)
#GList of types (as #GType) that line up with out_names
Update the value of key
to value
.
key
needs to already exist in action
.
the name of the value to modify
the new value of key
Prepares action action
with parameters in_names
and in_values
to be
sent off to a remote service later with gupnp_service_proxy_call_action() or
gupnp_service_proxy_call_action_async(). This is mainly useful for language
bindings.
After the action call has finished, the results of the call may be
retrived from the #GUPnPServiceProxyAction by using
gupnp_service_proxy_action_get_result(),
gupnp_service_proxy_action_get_result_list() or
gupnp_service_proxy_action_get_result_hash()
GValue instance = G_VALUE_INIT; g_value_set_int (&instance, 0); GValue unit = G_VALUE_INIT; g_value_set_static_string (&unit, "ABS_TIME"); GValue target = G_VALUE_INIT; g_value_set_static_string (&target, "00:00:00.000");
GList *in_values = NULL; in_values = g_list_append (in_values, &instance); in_values = g_list_append (in_values, &unit); in_values = g_list_append (in_values, &target);
GUPnPServiceProxyAction *action = gunp_service_proxy_action_new_from_list ("Seek", in_args, in_values);
GError *error = NULL; gupnp_service_proxy_call_action_async (proxy, action, NULL, on_action_finished, NULL); gupnp_service_proxy_action_unref (action);
An action
#GList of 'in' parameter names (as strings)
#GList of values (as #GValue) that line up with in_names
Opaque structure for holding in-progress action data.