summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-14 19:48:06 +0100
committerMarcel Holtmann <marcel@holtmann.org>2012-12-19 03:49:11 +0100
commit6c2dc5d1598a0f29f044a481f71666f0ee292c91 (patch)
tree5fcae401719377ab7d42f04674e48410df4f6bc5 /gdbus
parente4287dc177e57721649fa180a79ca5260c50582c (diff)
downloadconnman-6c2dc5d1598a0f29f044a481f71666f0ee292c91.tar.gz
connman-6c2dc5d1598a0f29f044a481f71666f0ee292c91.tar.bz2
connman-6c2dc5d1598a0f29f044a481f71666f0ee292c91.zip
gdbus: Add callback support for handling property changes
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/client.c33
-rw-r--r--gdbus/gdbus.h8
2 files changed, 31 insertions, 10 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index c0e9ecbc..e32cefed 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -46,7 +46,8 @@ struct GDBusClient {
void *signal_data;
GDBusProxyFunction proxy_added;
GDBusProxyFunction proxy_removed;
- void *proxy_data;
+ GDBusPropertyFunction property_changed;
+ void *user_data;
GList *proxy_list;
};
@@ -230,7 +231,7 @@ static void proxy_free(gpointer data)
GDBusClient *client = proxy->client;
if (client->proxy_removed)
- client->proxy_removed(proxy, client->proxy_data);
+ client->proxy_removed(proxy, client->user_data);
modify_match(client->dbus_conn, "RemoveMatch",
proxy->match_rule);
@@ -433,7 +434,16 @@ static void add_property(GDBusProxy *proxy, const char *name,
prop = g_hash_table_lookup(proxy->prop_list, name);
if (prop != NULL) {
+ GDBusClient *client = proxy->client;
+
prop_entry_update(prop, &value);
+
+ if (client == NULL)
+ return;
+
+ if (client->property_changed)
+ client->property_changed(proxy, name, &value,
+ client->user_data);
return;
}
@@ -518,6 +528,10 @@ static void properties_changed(GDBusClient *client, const char *path,
g_hash_table_remove(proxy->prop_list, name);
+ if (client->property_changed)
+ client->property_changed(proxy, name, NULL,
+ client->user_data);
+
dbus_message_iter_next(&entry);
}
}
@@ -540,7 +554,7 @@ static void parse_properties(GDBusClient *client, const char *path,
update_properties(proxy, iter);
if (client->proxy_added)
- client->proxy_added(proxy, client->proxy_data);
+ client->proxy_added(proxy, client->user_data);
client->proxy_list = g_list_append(client->proxy_list, proxy);
}
@@ -994,15 +1008,18 @@ gboolean g_dbus_client_set_signal_watch(GDBusClient *client,
}
gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client,
- GDBusProxyFunction added,
- GDBusProxyFunction removed, void *user_data)
+ GDBusProxyFunction proxy_added,
+ GDBusProxyFunction proxy_removed,
+ GDBusPropertyFunction property_changed,
+ void *user_data)
{
if (client == NULL)
return FALSE;
- client->proxy_added = added;
- client->proxy_removed = removed;
- client->proxy_data = user_data;
+ client->proxy_added = proxy_added;
+ client->proxy_removed = proxy_removed;
+ client->property_changed = property_changed;
+ client->user_data = user_data;
return TRUE;
}
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index fa978db6..57c2685a 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -302,10 +302,14 @@ 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 added,
- GDBusProxyFunction removed, void *user_data);
+ GDBusProxyFunction proxy_added,
+ GDBusProxyFunction proxy_removed,
+ GDBusPropertyFunction property_changed,
+ void *user_data);
#ifdef __cplusplus
}