diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2012-12-29 12:29:50 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-29 14:49:47 -0800 |
commit | de292f5f24f833701d0504a3e63a880c5d7fb434 (patch) | |
tree | 55448dd6cfc47d791d7c194ea00c85b3f979c5da /gdbus/client.c | |
parent | fcb88e484e8100c168eaa3aeff37de5eb35ded55 (diff) | |
download | connman-de292f5f24f833701d0504a3e63a880c5d7fb434.tar.gz connman-de292f5f24f833701d0504a3e63a880c5d7fb434.tar.bz2 connman-de292f5f24f833701d0504a3e63a880c5d7fb434.zip |
gdbus: Add support for proxy property change notifications
Diffstat (limited to 'gdbus/client.c')
-rw-r--r-- | gdbus/client.c | 23 |
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); |