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 <davidz@redhat.com>
This commit is contained in:
David Zeuthen 2010-07-19 15:03:00 -04:00
parent 1a06bd8d3f
commit 4a1c5a1b98
12 changed files with 40 additions and 8 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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__ */

View File

@ -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);

View File

@ -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);

View File

@ -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);