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
This commit is contained in:
Giovanni Campagna 2013-10-03 20:26:18 +02:00
parent c8e1dbb106
commit 32d2539295
2 changed files with 14 additions and 8 deletions

View File

@ -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.

View File

@ -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 <emphasis>invalidated property</emphasis> will be (asynchronously) retrieved upon receiving the <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties">PropertiesChanged</ulink> 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;
/**