From 4a1c5a1b98aed12308361d7adb6089a9fb171583 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Mon, 19 Jul 2010 15:03:00 -0400 Subject: [PATCH] GDBus: Add GDBusSignalFlags and use it in g_dbus_connection_signal_subscribe() This is currently unused but will probably be useful in the future. For example, we could have a _ARG0_IS_PATH to specify that arg0 should be used for arg0path. This commit breaks API and ABI. Users of g_dbus_connection_signal_subscribe() will need to port to this new version. Signed-off-by: David Zeuthen --- docs/reference/gio/gio-sections.txt | 1 + gio/gdbus-tool.c | 1 + gio/gdbusconnection.c | 2 ++ gio/gdbusconnection.h | 1 + gio/gdbusnameowning.c | 2 ++ gio/gdbusnamewatching.c | 1 + gio/gdbusproxy.c | 3 +++ gio/gio.symbols | 1 + gio/gioenums.h | 13 +++++++++++++ gio/tests/gdbus-connection.c | 21 +++++++++++++-------- gio/tests/gdbus-threading.c | 1 + gio/tests/testapps.c | 1 + 12 files changed, 40 insertions(+), 8 deletions(-) diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index e0d5b8cc9..52cc0f055 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -2379,6 +2379,7 @@ g_dbus_connection_call g_dbus_connection_call_finish g_dbus_connection_call_sync g_dbus_connection_emit_signal +GDBusSignalFlags GDBusSignalCallback g_dbus_connection_signal_subscribe g_dbus_connection_signal_unsubscribe diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c index 9cd504a73..d782bc2c8 100644 --- a/gio/gdbus-tool.c +++ b/gio/gdbus-tool.c @@ -1398,6 +1398,7 @@ monitor_on_name_appeared (GDBusConnection *connection, NULL, /* any member */ opt_monitor_object_path, NULL, /* arg0 */ + G_DBUS_SIGNAL_FLAGS_NONE, monitor_signal_cb, NULL, /* user_data */ NULL); /* user_data destroy notify */ diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 6071da521..aeef800d0 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -2901,6 +2901,7 @@ is_signal_data_for_name_lost_or_acquired (SignalData *signal_data) * @member: D-Bus signal name to match on or %NULL to match on all signals. * @object_path: Object path to match on or %NULL to match on all object paths. * @arg0: Contents of first string argument to match on or %NULL to match on all kinds of arguments. + * @flags: Flags describing how to subscribe to the signal (currently unused). * @callback: Callback to invoke when there is a signal matching the requested data. * @user_data: User data to pass to @callback. * @user_data_free_func: Function to free @user_data with when subscription is removed or %NULL. @@ -2932,6 +2933,7 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection, const gchar *member, const gchar *object_path, const gchar *arg0, + GDBusSignalFlags flags, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func) diff --git a/gio/gdbusconnection.h b/gio/gdbusconnection.h index 898209219..8ef518ed6 100644 --- a/gio/gdbusconnection.h +++ b/gio/gdbusconnection.h @@ -453,6 +453,7 @@ guint g_dbus_connection_signal_subscribe (GDBusConnection const gchar *member, const gchar *object_path, const gchar *arg0, + GDBusSignalFlags flags, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func); diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c index 9356d923a..f50e7f79b 100644 --- a/gio/gdbusnameowning.c +++ b/gio/gdbusnameowning.c @@ -339,6 +339,7 @@ request_name_cb (GObject *source_object, "NameLost", "/org/freedesktop/DBus", client->name, + G_DBUS_SIGNAL_FLAGS_NONE, on_name_lost_or_acquired, client, NULL); @@ -349,6 +350,7 @@ request_name_cb (GObject *source_object, "NameAcquired", "/org/freedesktop/DBus", client->name, + G_DBUS_SIGNAL_FLAGS_NONE, on_name_lost_or_acquired, client, NULL); diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c index 4f15a4c58..d4f70db31 100644 --- a/gio/gdbusnamewatching.c +++ b/gio/gdbusnamewatching.c @@ -447,6 +447,7 @@ has_connection (Client *client) "NameOwnerChanged", /* signal */ "/org/freedesktop/DBus", /* path */ client->name, + G_DBUS_SIGNAL_FLAGS_NONE, on_name_owner_changed, client, NULL); diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index af7638f3d..cbb93c30c 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -1366,6 +1366,7 @@ async_initable_init_first (GAsyncInitable *initable) "PropertiesChanged", proxy->priv->object_path, proxy->priv->interface_name, + G_DBUS_SIGNAL_FLAGS_NONE, on_properties_changed, proxy, NULL); @@ -1381,6 +1382,7 @@ async_initable_init_first (GAsyncInitable *initable) NULL, /* member */ proxy->priv->object_path, NULL, /* arg0 */ + G_DBUS_SIGNAL_FLAGS_NONE, on_signal_received, proxy, NULL); @@ -1395,6 +1397,7 @@ async_initable_init_first (GAsyncInitable *initable) "NameOwnerChanged", /* signal name */ "/org/freedesktop/DBus", /* path */ proxy->priv->name, /* arg0 */ + G_DBUS_SIGNAL_FLAGS_NONE, on_name_owner_changed, proxy, NULL); diff --git a/gio/gio.symbols b/gio/gio.symbols index 62c961d31..53bd35c1e 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -1023,6 +1023,7 @@ g_dbus_message_header_field_get_type G_GNUC_CONST g_dbus_property_info_flags_get_type G_GNUC_CONST g_dbus_subtree_flags_get_type G_GNUC_CONST g_dbus_server_flags_get_type G_GNUC_CONST +g_dbus_signal_flags_get_type G_GNUC_CONST #endif #endif diff --git a/gio/gioenums.h b/gio/gioenums.h index 3c761f33f..25e65ea18 100644 --- a/gio/gioenums.h +++ b/gio/gioenums.h @@ -1139,6 +1139,19 @@ typedef enum G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS = (1<<1) } GDBusServerFlags; +/** + * GDBusSignalFlags: + * @G_DBUS_SIGNAL_FLAGS_NONE: No flags set. + * + * Flags used when subscribing to signals via g_dbus_connection_signal_subscribe(). + * + * Since: 2.26 + */ +typedef enum /*< flags >*/ +{ + G_DBUS_SIGNAL_FLAGS_NONE = 0, +} GDBusSignalFlags; + G_END_DECLS #endif /* __GIO_ENUMS_H__ */ diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c index 417e66cdc..68e0cd195 100644 --- a/gio/tests/gdbus-connection.c +++ b/gio/tests/gdbus-connection.c @@ -415,6 +415,7 @@ test_connection_signals (void) "Foo", "/org/gtk/GDBus/ExampleInterface", NULL, + G_DBUS_SIGNAL_FLAGS_NONE, test_connection_signal_handler, &count_s1, NULL); @@ -424,6 +425,7 @@ test_connection_signals (void) "Foo", "/org/gtk/GDBus/ExampleInterface", NULL, + G_DBUS_SIGNAL_FLAGS_NONE, test_connection_signal_handler, &count_s2, NULL); @@ -433,6 +435,7 @@ test_connection_signals (void) "NameOwnerChanged", /* member */ "/org/freedesktop/DBus", /* path */ NULL, + G_DBUS_SIGNAL_FLAGS_NONE, test_connection_signal_handler, &count_name_owner_changed, NULL); @@ -441,14 +444,15 @@ test_connection_signals (void) * subscriptions instead of just 1 call to each of the N subscriptions. */ s1b = g_dbus_connection_signal_subscribe (c1, - ":1.2", - "org.gtk.GDBus.ExampleInterface", - "Foo", - "/org/gtk/GDBus/ExampleInterface", - NULL, - test_connection_signal_handler, - &count_s1b, - NULL); + ":1.2", + "org.gtk.GDBus.ExampleInterface", + "Foo", + "/org/gtk/GDBus/ExampleInterface", + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + test_connection_signal_handler, + &count_s1b, + NULL); g_assert (s1 != 0); g_assert (s1b != 0); g_assert (s2 != 0); @@ -712,6 +716,7 @@ test_connection_flush (void) "SomeSignal", "/org/gtk/GDBus/FlushObject", NULL, + G_DBUS_SIGNAL_FLAGS_NONE, test_connection_flush_signal_handler, NULL, NULL); diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c index 05c7c86d3..0700ad3fc 100644 --- a/gio/tests/gdbus-threading.c +++ b/gio/tests/gdbus-threading.c @@ -197,6 +197,7 @@ test_delivery_in_thread_func (gpointer _data) "NameOwnerChanged", /* member */ "/org/freedesktop/DBus", /* path */ NULL, + G_DBUS_SIGNAL_FLAGS_NONE, signal_handler, &data, NULL); diff --git a/gio/tests/testapps.c b/gio/tests/testapps.c index 1def17058..ca7e13b7e 100644 --- a/gio/tests/testapps.c +++ b/gio/tests/testapps.c @@ -553,6 +553,7 @@ test_change_action_on_application_appeared (void) "ActionsChanged", "/org/gtk/test/app", NULL, + G_DBUS_SIGNAL_FLAGS_NONE, actions_changed, loop, NULL);