mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 00:48:53 +02:00
Add G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE
If specified, the signal subscription is setup client-side but the match rule is not sent to the server. This allows the caller to manually register more detailed match rules.
This commit is contained in:
@@ -2977,11 +2977,14 @@ args_to_rule (const gchar *sender,
|
|||||||
const gchar *interface_name,
|
const gchar *interface_name,
|
||||||
const gchar *member,
|
const gchar *member,
|
||||||
const gchar *object_path,
|
const gchar *object_path,
|
||||||
const gchar *arg0)
|
const gchar *arg0,
|
||||||
|
gboolean negate)
|
||||||
{
|
{
|
||||||
GString *rule;
|
GString *rule;
|
||||||
|
|
||||||
rule = g_string_new ("type='signal'");
|
rule = g_string_new ("type='signal'");
|
||||||
|
if (negate)
|
||||||
|
g_string_prepend_c (rule, '-');
|
||||||
if (sender != NULL)
|
if (sender != NULL)
|
||||||
g_string_append_printf (rule, ",sender='%s'", sender);
|
g_string_append_printf (rule, ",sender='%s'", sender);
|
||||||
if (interface_name != NULL)
|
if (interface_name != NULL)
|
||||||
@@ -3010,6 +3013,9 @@ add_match_rule (GDBusConnection *connection,
|
|||||||
GError *error;
|
GError *error;
|
||||||
GDBusMessage *message;
|
GDBusMessage *message;
|
||||||
|
|
||||||
|
if (match_rule[0] == '-')
|
||||||
|
return;
|
||||||
|
|
||||||
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
||||||
"/org/freedesktop/DBus", /* path */
|
"/org/freedesktop/DBus", /* path */
|
||||||
"org.freedesktop.DBus", /* interface */
|
"org.freedesktop.DBus", /* interface */
|
||||||
@@ -3038,6 +3044,9 @@ remove_match_rule (GDBusConnection *connection,
|
|||||||
GError *error;
|
GError *error;
|
||||||
GDBusMessage *message;
|
GDBusMessage *message;
|
||||||
|
|
||||||
|
if (match_rule[0] == '-')
|
||||||
|
return;
|
||||||
|
|
||||||
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
|
||||||
"/org/freedesktop/DBus", /* path */
|
"/org/freedesktop/DBus", /* path */
|
||||||
"org.freedesktop.DBus", /* interface */
|
"org.freedesktop.DBus", /* interface */
|
||||||
@@ -3141,7 +3150,16 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection,
|
|||||||
|
|
||||||
CONNECTION_LOCK (connection);
|
CONNECTION_LOCK (connection);
|
||||||
|
|
||||||
rule = args_to_rule (sender, interface_name, member, object_path, arg0);
|
/* If G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE was specified, we will end up
|
||||||
|
* with a '-' character to prefix the rule (which will otherwise be
|
||||||
|
* normal).
|
||||||
|
*
|
||||||
|
* This allows us to hash the rule and do our lifecycle tracking in
|
||||||
|
* the usual way, but the '-' prevents the match rule from ever
|
||||||
|
* actually being send to the bus (either for add or remove).
|
||||||
|
*/
|
||||||
|
rule = args_to_rule (sender, interface_name, member, object_path, arg0,
|
||||||
|
(flags & G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE) != 0);
|
||||||
|
|
||||||
if (sender != NULL && (g_dbus_is_unique_name (sender) || g_strcmp0 (sender, "org.freedesktop.DBus") == 0))
|
if (sender != NULL && (g_dbus_is_unique_name (sender) || g_strcmp0 (sender, "org.freedesktop.DBus") == 0))
|
||||||
sender_unique_name = sender;
|
sender_unique_name = sender;
|
||||||
|
@@ -1157,6 +1157,9 @@ typedef enum
|
|||||||
/**
|
/**
|
||||||
* GDBusSignalFlags:
|
* GDBusSignalFlags:
|
||||||
* @G_DBUS_SIGNAL_FLAGS_NONE: No flags set.
|
* @G_DBUS_SIGNAL_FLAGS_NONE: No flags set.
|
||||||
|
* @G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE: Don't actually send the AddMatch
|
||||||
|
* DBus call for this signal subscription. This gives you more control
|
||||||
|
* over which match rules you add (but you must add them manually).
|
||||||
*
|
*
|
||||||
* Flags used when subscribing to signals via g_dbus_connection_signal_subscribe().
|
* Flags used when subscribing to signals via g_dbus_connection_signal_subscribe().
|
||||||
*
|
*
|
||||||
@@ -1164,7 +1167,8 @@ typedef enum
|
|||||||
*/
|
*/
|
||||||
typedef enum /*< flags >*/
|
typedef enum /*< flags >*/
|
||||||
{
|
{
|
||||||
G_DBUS_SIGNAL_FLAGS_NONE = 0
|
G_DBUS_SIGNAL_FLAGS_NONE = 0,
|
||||||
|
G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE = (1<<0)
|
||||||
} GDBusSignalFlags;
|
} GDBusSignalFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user