dbus-proxy: Add sloppy-names mode

In this mode all clients get NameOwnerChanged events for all
unique names. This means you can track lifetimes of these, even if
you can't talk to them. This is useful on the a11y bus, because
we want to track when there are any listeners to a particular event,
and this is done my listing unique id:s and tracking them.
This commit is contained in:
Alexander Larsson
2017-09-01 15:34:40 +02:00
parent ec902a08fa
commit fa29b40fad
3 changed files with 18 additions and 1 deletions

View File

@@ -144,6 +144,12 @@ start_proxy (int n_args, const char *args[])
{
flatpak_proxy_set_filter (proxy, TRUE);
}
else if (g_str_equal (args[n], "--sloppy-names"))
{
/* This means we're reporing the name changes for all unique names,
which is needed for the a11y bus */
flatpak_proxy_set_sloppy_names (proxy, TRUE);
}
else
{
int res = parse_generic_args (n_args - n, &args[n]);

View File

@@ -289,6 +289,7 @@ struct FlatpakProxy
char *dbus_address;
gboolean filter;
gboolean sloppy_names;
GHashTable *wildcard_policy;
GHashTable *policy;
@@ -467,6 +468,13 @@ flatpak_proxy_set_filter (FlatpakProxy *proxy,
proxy->filter = filter;
}
void
flatpak_proxy_set_sloppy_names (FlatpakProxy *proxy,
gboolean sloppy_names)
{
proxy->sloppy_names = sloppy_names;
}
void
flatpak_proxy_set_log_messages (FlatpakProxy *proxy,
gboolean log)
@@ -1729,7 +1737,8 @@ should_filter_name_owner_changed (FlatpakProxyClient *client, Buffer *buffer)
old = g_variant_get_string (arg1, NULL);
new = g_variant_get_string (arg2, NULL);
if (flatpak_proxy_client_get_policy (client, name) >= FLATPAK_POLICY_SEE)
if (flatpak_proxy_client_get_policy (client, name) >= FLATPAK_POLICY_SEE ||
(client->proxy->sloppy_names && name[0] == ':'))
{
if (name[0] != ':')
{

View File

@@ -48,6 +48,8 @@ void flatpak_proxy_set_log_messages (FlatpakProxy *proxy,
gboolean log);
void flatpak_proxy_set_filter (FlatpakProxy *proxy,
gboolean filter);
void flatpak_proxy_set_sloppy_names (FlatpakProxy *proxy,
gboolean sloppy_names);
void flatpak_proxy_add_policy (FlatpakProxy *proxy,
const char *name,
FlatpakPolicy policy);