mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 04:56:14 +01:00
gdbusconnection: Factor out add_signal_data()
No functional changes. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
816da60571
commit
5d7ad6897c
@ -3456,6 +3456,42 @@ is_signal_data_for_name_lost_or_acquired (SignalData *signal_data)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* called in any thread, connection lock is held */
|
||||||
|
static void
|
||||||
|
add_signal_data (GDBusConnection *connection,
|
||||||
|
SignalData *signal_data)
|
||||||
|
{
|
||||||
|
GPtrArray *signal_data_array;
|
||||||
|
|
||||||
|
g_hash_table_insert (connection->map_rule_to_signal_data,
|
||||||
|
signal_data->rule,
|
||||||
|
signal_data);
|
||||||
|
|
||||||
|
/* Add the match rule to the bus...
|
||||||
|
*
|
||||||
|
* Avoid adding match rules for NameLost and NameAcquired messages - the bus will
|
||||||
|
* always send such messages to us.
|
||||||
|
*/
|
||||||
|
if (connection->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION)
|
||||||
|
{
|
||||||
|
if (!is_signal_data_for_name_lost_or_acquired (signal_data))
|
||||||
|
add_match_rule (connection, signal_data->rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
signal_data_array = g_hash_table_lookup (connection->map_sender_unique_name_to_signal_data_array,
|
||||||
|
signal_data->sender_unique_name);
|
||||||
|
if (signal_data_array == NULL)
|
||||||
|
{
|
||||||
|
signal_data_array = g_ptr_array_new ();
|
||||||
|
g_hash_table_insert (connection->map_sender_unique_name_to_signal_data_array,
|
||||||
|
g_strdup (signal_data->sender_unique_name),
|
||||||
|
signal_data_array);
|
||||||
|
}
|
||||||
|
g_ptr_array_add (signal_data_array, signal_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_dbus_connection_signal_subscribe:
|
* g_dbus_connection_signal_subscribe:
|
||||||
* @connection: a #GDBusConnection
|
* @connection: a #GDBusConnection
|
||||||
@ -3545,7 +3581,6 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection,
|
|||||||
gchar *rule;
|
gchar *rule;
|
||||||
SignalData *signal_data;
|
SignalData *signal_data;
|
||||||
SignalSubscriber *subscriber;
|
SignalSubscriber *subscriber;
|
||||||
GPtrArray *signal_data_array;
|
|
||||||
const gchar *sender_unique_name;
|
const gchar *sender_unique_name;
|
||||||
|
|
||||||
/* Right now we abort if AddMatch() fails since it can only fail with the bus being in
|
/* Right now we abort if AddMatch() fails since it can only fail with the bus being in
|
||||||
@ -3611,32 +3646,7 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection,
|
|||||||
g_strdup (arg0),
|
g_strdup (arg0),
|
||||||
flags);
|
flags);
|
||||||
g_ptr_array_add (signal_data->subscribers, subscriber);
|
g_ptr_array_add (signal_data->subscribers, subscriber);
|
||||||
|
add_signal_data (connection, signal_data);
|
||||||
g_hash_table_insert (connection->map_rule_to_signal_data,
|
|
||||||
signal_data->rule,
|
|
||||||
signal_data);
|
|
||||||
|
|
||||||
/* Add the match rule to the bus...
|
|
||||||
*
|
|
||||||
* Avoid adding match rules for NameLost and NameAcquired messages - the bus will
|
|
||||||
* always send such messages to us.
|
|
||||||
*/
|
|
||||||
if (connection->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION)
|
|
||||||
{
|
|
||||||
if (!is_signal_data_for_name_lost_or_acquired (signal_data))
|
|
||||||
add_match_rule (connection, signal_data->rule);
|
|
||||||
}
|
|
||||||
|
|
||||||
signal_data_array = g_hash_table_lookup (connection->map_sender_unique_name_to_signal_data_array,
|
|
||||||
signal_data->sender_unique_name);
|
|
||||||
if (signal_data_array == NULL)
|
|
||||||
{
|
|
||||||
signal_data_array = g_ptr_array_new ();
|
|
||||||
g_hash_table_insert (connection->map_sender_unique_name_to_signal_data_array,
|
|
||||||
g_strdup (signal_data->sender_unique_name),
|
|
||||||
signal_data_array);
|
|
||||||
}
|
|
||||||
g_ptr_array_add (signal_data_array, signal_data);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_hash_table_insert (connection->map_id_to_signal_data,
|
g_hash_table_insert (connection->map_id_to_signal_data,
|
||||||
|
Loading…
Reference in New Issue
Block a user