/* ---------------------------------------------------------------------------------------------------- */
+static void
+add_signal_data_kdbus (GDBusConnection *connection,
+ SignalData *signal_data,
+ const char *sender_unique_name)
+{
+#ifdef G_OS_UNIX
+#ifdef KDBUS
+
+ if (!connection->kdbus_worker)
+ return;
+
+ gboolean special_rule = FALSE;
+ /* rule for special message */
+ if (!sender_unique_name || g_strcmp0 (sender_unique_name, "org.freedesktop.DBus") == 0)
+ {
+ if (sender_unique_name) /* So, this is org.freedesktop.DBus */
+ special_rule = TRUE;
+
+ if (!signal_data->object_path || g_strcmp0 (signal_data->object_path, "/org/freedesktop/DBus") == 0)
+ {
+ if (!signal_data->interface_name || g_strcmp0 (signal_data->interface_name, "org.freedesktop.DBus") == 0)
+ {
+ /* By https://dbus.freedesktop.org/doc/dbus-specification.html, org.freedesktop.DBus
+ * has three signal types: NameAcquired, NameLost, NameOwnerChanged (all covered below).
+ *
+ * 1. if sender is NULL and other parameters are matched with special rule, add BOTH special and standard,
+ * - (NULL, NULL or DBUS, NULL or DBUS, NULL or Special Name)
+ *
+ * if other parameters are NOT matched with special rule, add standard rule
+ * - (NULL, X, X, "NotSpecial")
+ *
+ * 2. if sender is 'org.freedesktop.DBus' and other parameters are matched with special rule, add special rule
+ * - (org.freedesktop.DBus, NULL or DBUS, NULL or DBUS, NULL or Special Name)
+ *
+ * if other parameters are NOT matched with special rule, then ignore
+ * - (org.freedesktop.DBus, X, X, "NotSpecial")
+ *
+ * for every other cases, add standard rule,
+ */
+ if (g_strcmp0 (signal_data->member, "NameAcquired") == 0)
+ _g_kdbus_subscribe_name_acquired (connection->kdbus_worker, signal_data->rule, signal_data->arg0, NULL);
+ else if (g_strcmp0 (signal_data->member, "NameLost") == 0)
+ _g_kdbus_subscribe_name_lost (connection->kdbus_worker, signal_data->rule, signal_data->arg0, NULL);
+ else if (!signal_data->member || g_strcmp0 (signal_data->member, "NameOwnerChanged") == 0)
+ _g_kdbus_subscribe_name_owner_changed (connection->kdbus_worker, signal_data->rule, signal_data->arg0, NULL);
+ }
+ }
+ }
+
+ /* standard rule */
+ if (!special_rule)
+ _g_kdbus_AddMatch (connection->kdbus_worker, signal_data->rule, NULL);
+
+#endif
+#endif
+}
+
/* called in any thread, connection lock is held */
static void
add_signal_data (GDBusConnection *connection,
*/
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);
- }
-#ifdef G_OS_UNIX
-#ifdef KDBUS
- else if (connection->kdbus_worker)
- {
- gboolean special_rule = FALSE;
- /* rule for special message */
- if (!sender_unique_name || g_strcmp0 (sender_unique_name, "org.freedesktop.DBus") == 0)
+ if (connection->worker)
{
- if (sender_unique_name) /* So, this is org.freedesktop.DBus */
- special_rule = TRUE;
- if (!signal_data->object_path || g_strcmp0 (signal_data->object_path, "/org/freedesktop/DBus") == 0)
- {
- if (!signal_data->interface_name || g_strcmp0 (signal_data->interface_name, "org.freedesktop.DBus") == 0)
- {
- /* By https://dbus.freedesktop.org/doc/dbus-specification.html, org.freedesktop.DBus
- * has three signal types: NameAcquired, NameLost, NameOwnerChanged (all covered below).
- *
- * 1. if sender is NULL and other parameters are matched with special rule, add BOTH special and standard,
- * - (NULL, NULL or DBUS, NULL or DBUS, NULL or Special Name)
- *
- * if other parameters are NOT matched with special rule, add standard rule
- * - (NULL, X, X, "NotSpecial")
- *
- * 2. if sender is 'org.freedesktop.DBus' and other parameters are matched with special rule, add special rule
- * - (org.freedesktop.DBus, NULL or DBUS, NULL or DBUS, NULL or Special Name)
- *
- * if other parameters are NOT matched with special rule, then ignore
- * - (org.freedesktop.DBus, X, X, "NotSpecial")
- *
- * for every other cases, add standard rule,
- */
- if (g_strcmp0 (signal_data->member, "NameAcquired") == 0)
- _g_kdbus_subscribe_name_acquired (connection->kdbus_worker, signal_data->rule, signal_data->arg0, NULL);
- else if (g_strcmp0 (signal_data->member, "NameLost") == 0)
- _g_kdbus_subscribe_name_lost (connection->kdbus_worker, signal_data->rule, signal_data->arg0, NULL);
- else if (!signal_data->member || g_strcmp0 (signal_data->member, "NameOwnerChanged") == 0)
- _g_kdbus_subscribe_name_owner_changed (connection->kdbus_worker, signal_data->rule, signal_data->arg0, NULL);
- }
- }
+ if (!is_signal_data_for_name_lost_or_acquired (signal_data))
+ add_match_rule (connection, signal_data->rule);
}
- /* standard rule */
- if (!special_rule)
- _g_kdbus_AddMatch (connection->kdbus_worker, signal_data->rule, NULL);
+ else
+ add_signal_data_kdbus(connection, signal_data, sender_unique_name);
}
-#endif
-#endif
signal_data_array = g_hash_table_lookup (connection->map_sender_unique_name_to_signal_data_array,
sender_unique_name);