Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/6] gdbus: Add g_dbus_add_properties_watch function
@ 2012-11-27 12:51 Luiz Augusto von Dentz
  2012-11-27 12:51 ` [PATCH BlueZ 2/6] audio: Convert controller MediaPlayer interface to use D-Bus Properties Luiz Augusto von Dentz
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-27 12:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Convenient function to create watches for D-Bus properties.
---
 gdbus/gdbus.h |  5 +++++
 gdbus/watch.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index ba49621..8b6dfe5 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -243,6 +243,11 @@ guint g_dbus_add_signal_watch(DBusConnection *connection,
 				const char *interface, const char *member,
 				GDBusSignalFunction function, void *user_data,
 				GDBusDestroyFunction destroy);
+guint g_dbus_add_properties_watch(DBusConnection *connection,
+				const char *sender, const char *path,
+				const char *interface,
+				GDBusSignalFunction function, void *user_data,
+				GDBusDestroyFunction destroy);
 gboolean g_dbus_remove_watch(DBusConnection *connection, guint tag);
 void g_dbus_remove_all_watches(DBusConnection *connection);
 
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 1cd1211..9e4f994 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -752,6 +752,34 @@ guint g_dbus_add_signal_watch(DBusConnection *connection,
 	return cb->id;
 }
 
+guint g_dbus_add_properties_watch(DBusConnection *connection,
+				const char *sender, const char *path,
+				const char *interface,
+				GDBusSignalFunction function, void *user_data,
+				GDBusDestroyFunction destroy)
+{
+	struct filter_data *data;
+	struct filter_callback *cb;
+
+	data = filter_data_get(connection, signal_filter, sender, path,
+				DBUS_INTERFACE_PROPERTIES, "PropertiesChanged",
+				interface);
+	if (data == NULL)
+		return 0;
+
+	cb = filter_data_add_callback(data, NULL, NULL, function, destroy,
+					user_data);
+	if (cb == NULL)
+		return 0;
+
+	if (data->name != NULL && data->name_watch == 0)
+		data->name_watch = g_dbus_add_service_watch(connection,
+							data->name, NULL,
+							NULL, NULL, NULL);
+
+	return cb->id;
+}
+
 gboolean g_dbus_remove_watch(DBusConnection *connection, guint id)
 {
 	struct filter_data *data;
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-11-30  8:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 12:51 [PATCH BlueZ 1/6] gdbus: Add g_dbus_add_properties_watch function Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 2/6] audio: Convert controller MediaPlayer interface to use D-Bus Properties Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 3/6] media: Convert target " Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 4/6] media-api: Update documentation of MediaPlayer interface Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 5/6] test: Convert mpris-player to use DBus properties interface Luiz Augusto von Dentz
2012-11-27 12:51 ` [PATCH BlueZ 6/6] test: Convert simple-player " Luiz Augusto von Dentz
2012-11-29  8:52 ` [PATCH BlueZ 1/6] gdbus: Add g_dbus_add_properties_watch function Luiz Augusto von Dentz
2012-11-29 13:10   ` Lucas De Marchi
2012-11-30  8:31 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox