summaryrefslogtreecommitdiffstats
path: root/gdbus/client.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-29 12:29:50 -0800
committerMarcel Holtmann <marcel@holtmann.org>2012-12-29 14:49:38 -0800
commit816c028a94325800476da364c970a8b7a8201003 (patch)
tree96a0c7ce7eb8220abb564b5da15f6dcf84e56c1d /gdbus/client.c
parentd3899c7af6518b71b6d3f4aa21d6f983fc551e57 (diff)
downloadofono-816c028a94325800476da364c970a8b7a8201003.tar.bz2
gdbus: Add support for proxy property change notifications
Diffstat (limited to 'gdbus/client.c')
-rw-r--r--gdbus/client.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index b46d5e41..4c3bad6e 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -60,6 +60,8 @@ struct GDBusProxy {
char *interface;
GHashTable *prop_list;
char *match_rule;
+ GDBusPropertyFunction prop_func;
+ void *prop_data;
};
struct prop_entry {
@@ -215,6 +217,9 @@ static void add_property(GDBusProxy *proxy, const char *name,
prop_entry_update(prop, &value);
+ if (proxy->prop_func)
+ proxy->prop_func(proxy, name, &value, proxy->prop_data);
+
if (client == NULL)
return;
@@ -229,6 +234,9 @@ static void add_property(GDBusProxy *proxy, const char *name,
return;
g_hash_table_replace(proxy->prop_list, prop->name, prop);
+
+ if (proxy->prop_func)
+ proxy->prop_func(proxy, name, &value, proxy->prop_data);
}
static void update_properties(GDBusProxy *proxy, DBusMessageIter *iter)
@@ -655,6 +663,18 @@ gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method,
return TRUE;
}
+gboolean g_dbus_proxy_set_property_watch(GDBusProxy *proxy,
+ GDBusPropertyFunction function, void *user_data)
+{
+ if (proxy == NULL)
+ return FALSE;
+
+ proxy->prop_func = function;
+ proxy->prop_data = user_data;
+
+ return TRUE;
+}
+
static void properties_changed(GDBusClient *client, const char *path,
DBusMessage *msg)
{
@@ -702,6 +722,9 @@ static void properties_changed(GDBusClient *client, const char *path,
g_hash_table_remove(proxy->prop_list, name);
+ if (proxy->prop_func)
+ proxy->prop_func(proxy, name, NULL, proxy->prop_data);
+
if (client->property_changed)
client->property_changed(proxy, name, NULL,
client->user_data);