gdbus: Use symbolic constants to subscribe to message bus signals

Unlike the various functions to call D-Bus methods, these sort their
arguments in a non-obvious order (bus name, interface, signal, path),
presumably aiming to sort the most-likely-to-be-used arguments first.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2024-05-13 12:45:29 +01:00 committed by Philip Withnall
parent fe14968c0d
commit 19223803f5
5 changed files with 24 additions and 24 deletions

View File

@ -511,10 +511,10 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
if (app_flags & G_APPLICATION_ALLOW_REPLACEMENT) if (app_flags & G_APPLICATION_ALLOW_REPLACEMENT)
{ {
impl->name_lost_signal = g_dbus_connection_signal_subscribe (impl->session_bus, impl->name_lost_signal = g_dbus_connection_signal_subscribe (impl->session_bus,
"org.freedesktop.DBus", DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", DBUS_INTERFACE_DBUS,
"NameLost", "NameLost",
"/org/freedesktop/DBus", DBUS_PATH_DBUS,
impl->bus_name, impl->bus_name,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
name_lost, name_lost,

View File

@ -419,10 +419,10 @@ has_connection (Client *client)
* ensure that the user callbacks get called an appropriate number of times. */ * ensure that the user callbacks get called an appropriate number of times. */
client->name_lost_subscription_id = client->name_lost_subscription_id =
g_dbus_connection_signal_subscribe (client->connection, g_dbus_connection_signal_subscribe (client->connection,
"org.freedesktop.DBus", DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", DBUS_INTERFACE_DBUS,
"NameLost", "NameLost",
"/org/freedesktop/DBus", DBUS_PATH_DBUS,
client->name, client->name,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
on_name_lost_or_acquired, on_name_lost_or_acquired,
@ -430,10 +430,10 @@ has_connection (Client *client)
(GDestroyNotify) client_unref); (GDestroyNotify) client_unref);
client->name_acquired_subscription_id = client->name_acquired_subscription_id =
g_dbus_connection_signal_subscribe (client->connection, g_dbus_connection_signal_subscribe (client->connection,
"org.freedesktop.DBus", DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", DBUS_INTERFACE_DBUS,
"NameAcquired", "NameAcquired",
"/org/freedesktop/DBus", DBUS_PATH_DBUS,
client->name, client->name,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
on_name_lost_or_acquired, on_name_lost_or_acquired,

View File

@ -504,10 +504,10 @@ has_connection (Client *client)
/* start listening to NameOwnerChanged messages immediately */ /* start listening to NameOwnerChanged messages immediately */
client->name_owner_changed_subscription_id = g_dbus_connection_signal_subscribe (client->connection, client->name_owner_changed_subscription_id = g_dbus_connection_signal_subscribe (client->connection,
"org.freedesktop.DBus", /* name */ DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", /* if */ DBUS_INTERFACE_DBUS,
"NameOwnerChanged", /* signal */ "NameOwnerChanged", /* signal */
"/org/freedesktop/DBus", /* path */ DBUS_PATH_DBUS,
client->name, client->name,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
on_name_owner_changed, on_name_owner_changed,

View File

@ -1719,10 +1719,10 @@ async_initable_init_first (GAsyncInitable *initable)
{ {
proxy->priv->name_owner_changed_subscription_id = proxy->priv->name_owner_changed_subscription_id =
g_dbus_connection_signal_subscribe (proxy->priv->connection, g_dbus_connection_signal_subscribe (proxy->priv->connection,
"org.freedesktop.DBus", /* name */ DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", /* interface */ DBUS_INTERFACE_DBUS,
"NameOwnerChanged", /* signal name */ "NameOwnerChanged", /* signal name */
"/org/freedesktop/DBus", /* path */ DBUS_PATH_DBUS,
proxy->priv->name, /* arg0 */ proxy->priv->name, /* arg0 */
signal_flags, signal_flags,
on_name_owner_changed, on_name_owner_changed,

View File

@ -214,10 +214,10 @@ test_connection_life_cycle (void)
/* signal registration */ /* signal registration */
g_atomic_int_set (&on_signal_registration_freed_called, FALSE); g_atomic_int_set (&on_signal_registration_freed_called, FALSE);
g_dbus_connection_signal_subscribe (c2, g_dbus_connection_signal_subscribe (c2,
"org.freedesktop.DBus", /* bus name */ DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", /* interface */ DBUS_INTERFACE_DBUS,
"NameOwnerChanged", /* member */ "NameOwnerChanged", /* member */
"/org/freedesktop/DBus", /* path */ DBUS_PATH_DBUS,
NULL, /* arg0 */ NULL, /* arg0 */
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
on_name_owner_changed, on_name_owner_changed,
@ -619,10 +619,10 @@ test_connection_signals (void)
&count_s2, &count_s2,
NULL); NULL);
s3 = g_dbus_connection_signal_subscribe (c1, s3 = g_dbus_connection_signal_subscribe (c1,
"org.freedesktop.DBus", /* sender */ DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", /* interface */ DBUS_INTERFACE_DBUS,
"NameOwnerChanged", /* member */ "NameOwnerChanged", /* member */
"/org/freedesktop/DBus", /* path */ DBUS_PATH_DBUS,
NULL, NULL,
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
test_connection_signal_handler, test_connection_signal_handler,
@ -1115,10 +1115,10 @@ test_connection_filter (void)
/* wait for service to be available */ /* wait for service to be available */
signal_handler_id = g_dbus_connection_signal_subscribe (c, signal_handler_id = g_dbus_connection_signal_subscribe (c,
"org.freedesktop.DBus", /* sender */ DBUS_SERVICE_DBUS,
"org.freedesktop.DBus", DBUS_INTERFACE_DBUS,
"NameOwnerChanged", "NameOwnerChanged",
"/org/freedesktop/DBus", DBUS_PATH_DBUS,
NULL, /* arg0 */ NULL, /* arg0 */
G_DBUS_SIGNAL_FLAGS_NONE, G_DBUS_SIGNAL_FLAGS_NONE,
test_connection_filter_name_owner_changed_signal_handler, test_connection_filter_name_owner_changed_signal_handler,