Commit 2ca8303e authored by Christian Kellner's avatar Christian Kellner

proxy: async dbus prop setter (GParamSpec, GValue)

Async version of a pair of new variant for the property setter that
is based on GValue and GPramSpec instead of GVariant and property
name. Uses the BoltWireConv to convert the value for the wire.
parent d2036f11
......@@ -653,3 +653,62 @@ bolt_proxy_set (BoltProxy *proxy,
return res != NULL;
}
void
bolt_proxy_set_async (BoltProxy *proxy,
GParamSpec *spec,
const GValue *value,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr(GVariant) val = NULL;
GError *err;
BoltWireConv *conv;
const char *name;
const char *iface;
g_return_if_fail (BOLT_IS_PROXY (proxy));
g_return_if_fail (G_IS_PARAM_SPEC (spec));
g_return_if_fail (G_IS_VALUE (value));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
conv = bolt_proxy_get_wire_conv (proxy, spec, &err);
if (conv != NULL)
val = bolt_wire_conv_to_wire (conv, value, &err);
if (val == NULL)
{
g_task_report_error (proxy, callback, user_data, NULL, err);
return;
}
name = g_param_spec_get_nick (spec);
iface = g_dbus_proxy_get_interface_name (G_DBUS_PROXY (proxy));
g_dbus_proxy_call (G_DBUS_PROXY (proxy),
"org.freedesktop.DBus.Properties.Set",
g_variant_new ("(ssv)",
iface,
name,
val),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
callback,
user_data);
}
gboolean
bolt_proxy_set_finish (GAsyncResult *res,
GError **error)
{
g_autoptr(GVariant) val = NULL;
BoltProxy *proxy;
proxy = (BoltProxy *) g_async_result_get_source_object (res);
val = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
return val != NULL;
}
......@@ -115,4 +115,14 @@ gboolean bolt_proxy_set (BoltProxy *proxy,
GCancellable *cancellable,
GError **error);
void bolt_proxy_set_async (BoltProxy *proxy,
GParamSpec *spec,
const GValue *value,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean bolt_proxy_set_finish (GAsyncResult *res,
GError **error);
G_END_DECLS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment