mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
GMenuExporter: Allow NULL bus name for peer-to-peer connection
https://bugzilla.gnome.org/show_bug.cgi?id=720380
This commit is contained in:
parent
d37af2bd04
commit
f29065c315
@ -525,7 +525,9 @@ g_menu_exporter_remote_free (gpointer data)
|
|||||||
g_menu_exporter_group_unsubscribe (group, GPOINTER_TO_INT (val));
|
g_menu_exporter_group_unsubscribe (group, GPOINTER_TO_INT (val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remote->watch_id > 0)
|
||||||
g_bus_unwatch_name (remote->watch_id);
|
g_bus_unwatch_name (remote->watch_id);
|
||||||
|
|
||||||
g_hash_table_unref (remote->watches);
|
g_hash_table_unref (remote->watches);
|
||||||
|
|
||||||
g_slice_free (GMenuExporterRemote, remote);
|
g_slice_free (GMenuExporterRemote, remote);
|
||||||
@ -556,6 +558,7 @@ struct _GMenuExporter
|
|||||||
guint next_group_id;
|
guint next_group_id;
|
||||||
|
|
||||||
GMenuExporterMenu *root;
|
GMenuExporterMenu *root;
|
||||||
|
GMenuExporterRemote *peer_remote;
|
||||||
GHashTable *remotes;
|
GHashTable *remotes;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -582,9 +585,14 @@ g_menu_exporter_subscribe (GMenuExporter *exporter,
|
|||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
guint32 id;
|
guint32 id;
|
||||||
|
|
||||||
|
if (sender != NULL)
|
||||||
remote = g_hash_table_lookup (exporter->remotes, sender);
|
remote = g_hash_table_lookup (exporter->remotes, sender);
|
||||||
|
else
|
||||||
|
remote = exporter->peer_remote;
|
||||||
|
|
||||||
if (remote == NULL)
|
if (remote == NULL)
|
||||||
|
{
|
||||||
|
if (sender != NULL)
|
||||||
{
|
{
|
||||||
guint watch_id;
|
guint watch_id;
|
||||||
|
|
||||||
@ -593,6 +601,10 @@ g_menu_exporter_subscribe (GMenuExporter *exporter,
|
|||||||
remote = g_menu_exporter_remote_new (exporter, watch_id);
|
remote = g_menu_exporter_remote_new (exporter, watch_id);
|
||||||
g_hash_table_insert (exporter->remotes, g_strdup (sender), remote);
|
g_hash_table_insert (exporter->remotes, g_strdup (sender), remote);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
remote = exporter->peer_remote =
|
||||||
|
g_menu_exporter_remote_new (exporter, 0);
|
||||||
|
}
|
||||||
|
|
||||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a(uuaa{sv}))"));
|
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a(uuaa{sv}))"));
|
||||||
|
|
||||||
@ -616,7 +628,10 @@ g_menu_exporter_unsubscribe (GMenuExporter *exporter,
|
|||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
guint32 id;
|
guint32 id;
|
||||||
|
|
||||||
|
if (sender != NULL)
|
||||||
remote = g_hash_table_lookup (exporter->remotes, sender);
|
remote = g_hash_table_lookup (exporter->remotes, sender);
|
||||||
|
else
|
||||||
|
remote = exporter->peer_remote;
|
||||||
|
|
||||||
if (remote == NULL)
|
if (remote == NULL)
|
||||||
return;
|
return;
|
||||||
@ -626,7 +641,12 @@ g_menu_exporter_unsubscribe (GMenuExporter *exporter,
|
|||||||
g_menu_exporter_remote_unsubscribe (remote, id);
|
g_menu_exporter_remote_unsubscribe (remote, id);
|
||||||
|
|
||||||
if (!g_menu_exporter_remote_has_subscriptions (remote))
|
if (!g_menu_exporter_remote_has_subscriptions (remote))
|
||||||
|
{
|
||||||
|
if (sender != NULL)
|
||||||
g_hash_table_remove (exporter->remotes, sender);
|
g_hash_table_remove (exporter->remotes, sender);
|
||||||
|
else
|
||||||
|
g_clear_pointer (&exporter->peer_remote, g_menu_exporter_remote_free);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -691,6 +711,7 @@ g_menu_exporter_free (gpointer user_data)
|
|||||||
GMenuExporter *exporter = user_data;
|
GMenuExporter *exporter = user_data;
|
||||||
|
|
||||||
g_menu_exporter_menu_free (exporter->root);
|
g_menu_exporter_menu_free (exporter->root);
|
||||||
|
g_clear_pointer (&exporter->peer_remote, g_menu_exporter_remote_free);
|
||||||
g_hash_table_unref (exporter->remotes);
|
g_hash_table_unref (exporter->remotes);
|
||||||
g_hash_table_unref (exporter->groups);
|
g_hash_table_unref (exporter->groups);
|
||||||
g_object_unref (exporter->connection);
|
g_object_unref (exporter->connection);
|
||||||
|
Loading…
Reference in New Issue
Block a user