From 32d2539295308711ec97b37feb104e1be04ba454 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Thu, 3 Oct 2013 20:26:18 +0200 Subject: [PATCH] GDBusProxy: add flag to control autostarting at construction time Sometimes the application doesn't want to autostart a service when it creates a proxy, but wants the service autostarted when it makes the first method call. Allow that behavior with a new flag. https://bugzilla.gnome.org/show_bug.cgi?id=708828 --- gio/gdbusproxy.c | 15 ++++++++------- gio/gioenums.h | 7 ++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index 60a888188..c870017fd 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -1725,7 +1725,8 @@ async_initable_init_second_async (GAsyncInitable *initable, } else { - if (proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START) + if ((proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START) || + (proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION)) { async_init_call_get_name_owner (data); } @@ -2039,9 +2040,9 @@ initable_iface_init (GInitableIface *initable_iface) * to handle signals from the remote object. * * If @name is a well-known name and the - * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag isn't set and no name - * owner currently exists, the message bus will be requested to launch - * a name owner for the name. + * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION + * flags aren't set and no name owner currently exists, the message bus + * will be requested to launch a name owner for the name. * * This is a failable asynchronous constructor - when the proxy is * ready, @callback will be invoked and you can use @@ -2136,9 +2137,9 @@ g_dbus_proxy_new_finish (GAsyncResult *res, * to handle signals from the remote object. * * If @name is a well-known name and the - * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag isn't set and no name - * owner currently exists, the message bus will be requested to launch - * a name owner for the name. + * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION + * flags aren't set and no name owner currently exists, the message bus + * will be requested to launch a name owner for the name. * * This is a synchronous failable constructor. See g_dbus_proxy_new() * and g_dbus_proxy_new_finish() for the asynchronous version. diff --git a/gio/gioenums.h b/gio/gioenums.h index 4ce0855cb..c8c0e157d 100644 --- a/gio/gioenums.h +++ b/gio/gioenums.h @@ -950,6 +950,10 @@ typedef enum * then request the bus to launch an owner for the name if no-one owns the name. This flag can * only be used in proxies for well-known names. * @G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES: If set, the property value for any invalidated property will be (asynchronously) retrieved upon receiving the PropertiesChanged D-Bus signal and the property will not cause emission of the #GDBusProxy::g-properties-changed signal. When the value is received the #GDBusProxy::g-properties-changed signal is emitted for the property along with the retrieved value. Since 2.32. + * @G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION: If the proxy is for a well-known name, + * do not ask the bus to launch an owner during proxy initialization, but allow it to be + * autostarted by a method call. This flag is only meaningful in proxies for well-known names, + * and only if %G_DBUS_PROXY_FLAGS_DO_NOT_AUTOSTART is not also specified. * * Flags used when constructing an instance of a #GDBusProxy derived class. * @@ -961,7 +965,8 @@ typedef enum G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES = (1<<0), G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS = (1<<1), G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START = (1<<2), - G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES = (1<<3) + G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES = (1<<3), + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION = (1<<4) } GDBusProxyFlags; /**