Add reply / signal utilities to g_dbus_util
PATCH 1/2 Add reply / signal utilities to g_dbus_util
Connman/BlueZ/oFono share the same API structure and thus share the same basic code to build GetProperties() replies and PropertyChanged signal emissions. These utilities are duplicated across projects.
This patch adds the three most commonly used utilities for building the GetProperties dictionaries and PropertyChanged signal emissions.
--- Makefile.am | 3 +- gdbus/gdbus.h | 31 ++++++++ gdbus/util.c | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 259 insertions(+), 1 deletions(-) create mode 100644 gdbus/util.c
Makefile.am +2 -1
@@ -39,7 +39,8 @@ builtin_sources = builtin_libadd = builtin_cflags = -gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/object.c gdbus/watch.c +gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/object.c gdbus/watch.c \ + gdbus/util.c gisi_sources = gisi/phonet.h gisi/modem.h gisi/netlink.h gisi/netlink.c \ gisi/socket.h gisi/socket.c gisi/client.h gisi/client.c \
gdbus/gdbus.h +31 -0
@@ -135,6 +135,37 @@ guint g_dbus_add_signal_watch(DBusConnection *connection,gboolean g_dbus_remove_watch (DBusConnection *connection,guint tag);void g_dbus_remove_all_watches (DBusConnection *connection); +gboolean g_dbus_properties_dict_append_basic (DBusMessageIter *dict, +const char *key, +int type,void *value); + +gboolean g_dbus_properties_dict_append_string_array (DBusMessageIter *dict, +const char *key,int type,char **val); + +gboolean g_dbus_properties_dict_append_fixed_array (DBusMessageIter *dict, +const char *key, +int type,void *val, +int len); + +gboolean g_dbus_emit_property_changed_basic (DBusConnection *conn, +const char *path, +const char *interface, +const char *name, +int type,void *value); + +gboolean g_dbus_emit_property_changed_string_array (DBusConnection *conn, +const char *path, +const char *interface, +const char *name, +int type, +char **values); + +gboolean g_dbus_emit_property_changed_fixed_array (DBusConnection *conn, +const char *path, +const char *interface, +const char *name, +int type,void *value, +int len); #ifdef __cplusplus }#endif
gdbus/util.c new file +226 -0
226 lines not on this page · raw message
Signature · 1 line
1.6.4.4
PATCH 2/2 Add a helper method for setting basic properties
Several plugins have code for setting properties using the BlueZ/ConnMan/oFono style API. The code for this is duplicated unnecessarily. The properties tend to be e.g. booleans for Powered or simple String states.
Here we create a convenience function that will send the set property request and call the user-provided callback function.
--- gdbus/gdbus.h | 8 ++++++++ gdbus/util.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 0 deletions(-)
gdbus/gdbus.h +8 -0
@@ -166,6 +166,14 @@ gboolean g_dbus_emit_property_changed_fixed_array(DBusConnection *conn,const char *name, int type, void *value, int len); + +gboolean g_dbus_set_property_basic (DBusConnection *conn,const char *service, +const char *path,const char *interface, +const char *property, +int type,void *value, +DBusPendingCallNotifyFunction cb, +void *user_data, +DBusFreeFunction free_func); #ifdef __cplusplus }#endif
gdbus/util.c +45 -0
48 lines not on this page · raw message
Signature · 1 line
1.6.4.4