[gupnp/wip/phako/reusable-service-action: 8/11] ServiceProxyAction: Add method to set parameters
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp/wip/phako/reusable-service-action: 8/11] ServiceProxyAction: Add method to set parameters
- Date: Mon, 31 May 2021 17:44:57 +0000 (UTC)
commit 817e9eee6363fec0eb6fcfe74d8b8de1054abed1
Author: Jens Georg <mail jensge org>
Date: Sat May 29 02:20:31 2021 +0200
ServiceProxyAction: Add method to set parameters
libgupnp/gupnp-service-proxy-action.c | 46 +++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
---
diff --git a/libgupnp/gupnp-service-proxy-action.c b/libgupnp/gupnp-service-proxy-action.c
index d2af09b..f603c46 100644
--- a/libgupnp/gupnp-service-proxy-action.c
+++ b/libgupnp/gupnp-service-proxy-action.c
@@ -588,3 +588,49 @@ gupnp_service_proxy_action_get_result_valist (GUPnPServiceProxyAction *action,
return result;
}
+
+gboolean
+gupnp_service_proxy_action_set (GUPnPServiceProxyAction *action,
+ const char *key,
+ const GValue *value,
+ GError **error)
+{
+ g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+ g_return_val_if_fail (error != NULL && *error == NULL, FALSE);
+ gpointer position;
+
+ if (!g_hash_table_lookup_extended (action->arg_map,
+ key,
+ NULL,
+ &position)) {
+ g_propagate_error (error,
+ g_error_new (GUPNP_SERVER_ERROR,
+ GUPNP_SERVER_ERROR_OTHER,
+ "Unknown argument: %s",
+ key));
+
+ return FALSE;
+ }
+
+ ActionArgument *arg =
+ g_ptr_array_index (action->args, GPOINTER_TO_UINT (position));
+
+ if (G_VALUE_TYPE (value) != G_VALUE_TYPE (&arg->value)) {
+ g_propagate_error (
+ error,
+ g_error_new (
+ GUPNP_SERVER_ERROR,
+ GUPNP_SERVER_ERROR_OTHER,
+ "Type mismatch for %s. Expected %s, got %s",
+ key,
+ G_VALUE_TYPE_NAME (&arg->value),
+ G_VALUE_TYPE_NAME (value)));
+
+ return FALSE;
+ }
+
+ g_value_copy (value, &arg->value);
+
+ return TRUE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]