summaryrefslogtreecommitdiff
path: root/gdbus
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:47 -0800
commitde292f5f24f833701d0504a3e63a880c5d7fb434 (patch)
tree55448dd6cfc47d791d7c194ea00c85b3f979c5da /gdbus
parentfcb88e484e8100c168eaa3aeff37de5eb35ded55 (diff)
downloadconnman-de292f5f24f833701d0504a3e63a880c5d7fb434.tar.gz
connman-de292f5f24f833701d0504a3e63a880c5d7fb434.tar.bz2
connman-de292f5f24f833701d0504a3e63a880c5d7fb434.zip
gdbus: Add support for proxy property change notifications
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/client.c23
-rw-r--r--gdbus/gdbus.h11
2 files changed, 30 insertions, 4 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);
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 4caa31da..b0de6d53 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -304,6 +304,13 @@ gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method,
GDBusReturnFunction function, void *user_data,
GDBusDestroyFunction destroy);
+typedef void (* GDBusProxyFunction) (GDBusProxy *proxy, void *user_data);
+typedef void (* GDBusPropertyFunction) (GDBusProxy *proxy, const char *name,
+ DBusMessageIter *iter, void *user_data);
+
+gboolean g_dbus_proxy_set_property_watch(GDBusProxy *proxy,
+ GDBusPropertyFunction function, void *user_data);
+
GDBusClient *g_dbus_client_new(DBusConnection *connection,
const char *service, const char *path);
@@ -317,10 +324,6 @@ gboolean g_dbus_client_set_disconnect_watch(GDBusClient *client,
gboolean g_dbus_client_set_signal_watch(GDBusClient *client,
GDBusMessageFunction function, void *user_data);
-typedef void (* GDBusProxyFunction) (GDBusProxy *proxy, void *user_data);
-typedef void (* GDBusPropertyFunction) (GDBusProxy *proxy, const char *name,
- DBusMessageIter *iter, void *user_data);
-
gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client,
GDBusProxyFunction proxy_added,
GDBusProxyFunction proxy_removed,