[BlueZ v2 03/14] gdbus/client: add g_dbus_proxy_set_read_watch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adds a new gdbus utility function which will set a function to be called
after the properties of a proxy are updated.

This enables using GDBusClient for objects without the ObjectManager
interface as long as you know in advance the object path using
g_dbus_proxy_new
---
 gdbus/client.c | 17 +++++++++++++++++
 gdbus/gdbus.h  |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/gdbus/client.c b/gdbus/client.c
index fe0c0db..c913773 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -76,6 +76,8 @@ struct GDBusProxy {
 	void *prop_data;
 	GDBusProxyFunction removed_func;
 	void *removed_data;
+	GDBusProxyFunction read_func;
+	void *read_data;
 };
 
 struct prop_entry {
@@ -297,6 +299,9 @@ static void get_all_properties_reply(DBusPendingCall *call, void *user_data)
 
 	update_properties(proxy, &iter, FALSE);
 
+	if (proxy->read_func)
+		proxy->read_func(proxy, proxy->read_data);
+
 done:
 	if (g_list_find(client->proxy_list, proxy) == NULL) {
 		if (client->proxy_added)
@@ -914,6 +919,18 @@ gboolean g_dbus_proxy_set_removed_watch(GDBusProxy *proxy,
 	return TRUE;
 }
 
+gboolean g_dbus_proxy_set_read_watch(GDBusProxy *proxy,
+				GDBusProxyFunction function, void *user_data)
+{
+	if (proxy == NULL)
+		return FALSE;
+
+	proxy->read_func = function;
+	proxy->read_data = user_data;
+
+	return TRUE;
+}
+
 static void refresh_properties(GDBusClient *client)
 {
 	GList *list;
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 9814838..ae281d9 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -353,6 +353,9 @@ gboolean g_dbus_proxy_set_property_watch(GDBusProxy *proxy,
 gboolean g_dbus_proxy_set_removed_watch(GDBusProxy *proxy,
 			GDBusProxyFunction destroy, void *user_data);
 
+gboolean g_dbus_proxy_set_read_watch(GDBusProxy *proxy,
+			GDBusProxyFunction ready, void *user_data);
+
 GDBusClient *g_dbus_client_new(DBusConnection *connection,
 					const char *service, const char *path);
 GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux