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.
const gchar *interface_name,
const gchar *member,
const gchar *object_path,
const gchar *interface_name,
const gchar *member,
const gchar *object_path,
+ const gchar *arg0,
+ gboolean negate)
{
GString *rule;
rule = g_string_new ("type='signal'");
{
GString *rule;
rule = g_string_new ("type='signal'");
+ if (negate)
+ g_string_prepend_c (rule, '-');
if (sender != NULL)
g_string_append_printf (rule, ",sender='%s'", sender);
if (interface_name != NULL)
if (sender != NULL)
g_string_append_printf (rule, ",sender='%s'", sender);
if (interface_name != NULL)
GError *error;
GDBusMessage *message;
GError *error;
GDBusMessage *message;
+ if (match_rule[0] == '-')
+ return;
+
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* path */
"org.freedesktop.DBus", /* interface */
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* path */
"org.freedesktop.DBus", /* interface */
GError *error;
GDBusMessage *message;
GError *error;
GDBusMessage *message;
+ if (match_rule[0] == '-')
+ return;
+
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* path */
"org.freedesktop.DBus", /* interface */
message = g_dbus_message_new_method_call ("org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* path */
"org.freedesktop.DBus", /* interface */
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))
sender_unique_name = sender;
if (sender != NULL && (g_dbus_is_unique_name (sender) || g_strcmp0 (sender, "org.freedesktop.DBus") == 0))
sender_unique_name = sender;
/**
* GDBusSignalFlags:
* @G_DBUS_SIGNAL_FLAGS_NONE: No flags set.
/**
* GDBusSignalFlags:
* @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().
*
*/
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)