gdbus: Add g_dbus_list_interfaces function
Luiz Augusto von Dentz
maintainerRFC 1/3 gdbus: Add g_dbus_list_interfaces function
From: Luiz Augusto von Dentz <[email protected]>
This function can be used to list interfaces registered in a given path
--- gdbus/gdbus.h | 2 ++ gdbus/object.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-)
gdbus/gdbus.h +2 -0
@@ -119,6 +119,8 @@ gboolean g_dbus_register_interface(DBusConnection *connection, GDBusDestroyFunction destroy);gboolean g_dbus_unregister_interface (DBusConnection *connection,const char *path,const char *name); +char **g_dbus_list_interfaces (DBusConnection *connection,const char *path, +int *num);gboolean g_dbus_register_security (const GDBusSecurityTable *security);gboolean g_dbus_unregister_security (const GDBusSecurityTable *security);
gdbus/object.c +34 -0
@@ -723,6 +723,40 @@ gboolean g_dbus_unregister_interface(DBusConnection *connection,return TRUE; } +char **g_dbus_list_interfaces (DBusConnection *connection,const char *path, +int *num) +{ +struct generic_data *data; +GSList *l; +char **array; +int i, n; + +if (!dbus_connection_get_object_path_data (connection, path, + (void *) &data)) +return NULL ; + +if (data->interfaces ==NULL ) +return NULL ; + + n =g_slist_length (data->interfaces); + array = g_new0(char *, n + 1); + +for (i =0 , l = data->interfaces; l; l = l->next) { +struct interface_data *iface = l->data; + +if (g_strcmp0 (iface->name, +DBUS_INTERFACE_INTROSPECTABLE ) ==0 ) +continue ; + + array[i++] =g_strdup (iface->name); + } + +if (num) + *num = i; + +return array; +} +gboolean g_dbus_register_security (const GDBusSecurityTable *security) {if (security_table !=NULL )
Signature · 1 line
1.7.7.6
Luiz Augusto von Dentz
maintainerRFC 2/3 core: Add Interfaces property to org.bluez.Adapter
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when some specific such as org.bluez.Media is available so they don't have to guess based on UUIDs.
--- doc/adapter-api.txt | 4 ++++ src/adapter.c | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
doc/adapter-api.txt +4 -0
@@ -284,3 +284,7 @@ Properties string Address [readonly] List of 128-bit UUIDs that represents the available local services. + + array{string} Interfaces [readonly] + + List of supported interface by the object.
src/adapter.c +19 -2
@@ -1077,7 +1077,7 @@ static DBusMessage *get_properties(DBusConnection *conn,DBusMessageIter dict;char srcaddr[18 ];gboolean value; -char **devices, **uuids; +char **devices, **uuids, **ifaces;int i;GSList *l;sdp_list_t *list;
@@ -1162,6 +1162,14 @@ static DBusMessage *get_properties(DBusConnection *conn,g_strfreev (uuids); +/* Interfaces */ + ifaces =g_dbus_list_interfaces (connection, adapter->path, &i); +if (ifaces !=NULL ) { +dict_append_array (&dict,"Interfaces" ,DBUS_TYPE_STRING , + &ifaces, i); +g_strfreev (ifaces); + } +dbus_message_iter_close_container (&iter, &dict);return reply;
@@ -2023,7 +2031,8 @@ static void clear_blocked(struct btd_adapter *adapter)static void probe_driver (struct btd_adapter *adapter,gpointer user_data) {struct btd_adapter_driver *driver = user_data; -int err; +int err, count; +char **ifaces;if (!adapter->up)return ;
@@ -2039,6 +2048,14 @@ static void probe_driver(struct btd_adapter *adapter, gpointer user_data) adapter->loaded_drivers =g_slist_prepend (adapter->loaded_drivers, driver); + + ifaces =g_dbus_list_interfaces (connection, adapter->path, &count); +if (ifaces !=NULL ) { +emit_array_property_changed (connection, adapter->path, +ADAPTER_INTERFACE ,"Interfaces" , +DBUS_TYPE_STRING , &ifaces, count); +g_strfreev (ifaces); + } }static void load_drivers (struct btd_adapter *adapter)
Signature · 1 line
1.7.7.6
Luiz Augusto von Dentz
maintainerRFC 3/3 core: Add Interfaces property to org.bluez.Device
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
--- doc/device-api.txt | 4 ++++ src/device.c | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)
doc/device-api.txt +4 -0
@@ -209,3 +209,7 @@ Properties string Address [readonly] Note that this property can exhibit false-positives in the case of Bluetooth 2.1 (or newer) devices that have disabled Extended Inquiry Response support. + + array{string} Interfaces [readonly] + + List of supported interface by the object.
src/device.c +22 -5
@@ -410,6 +410,14 @@ static DBusMessage *get_properties(DBusConnection *conn,dict_append_array (&dict,"UUIDs" ,DBUS_TYPE_STRING , &str, i);g_free (str); +/* Interfaces */ + str =g_dbus_list_interfaces (conn, device->path, &i); +if (str !=NULL ) { +dict_append_array (&dict,"Interfaces" ,DBUS_TYPE_STRING , &str, + i); +g_strfreev (str); + } +/* Services */ str = g_new0(char *, g_slist_length(device->services) + 1);for (i =0 , l = device->services; l; l = l->next, i++)
@@ -1379,18 +1387,27 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)static void services_changed (struct btd_device *device) {DBusConnection *conn =get_dbus_connection (); -char **uuids; +char **array;GSList *l;int i; - uuids = g_new0(char *, g_slist_length(device->uuids) + 1); + array = g_new0(char *, g_slist_length(device->uuids) + 1);for (i =0 , l = device->uuids; l; l = l->next, i++) - uuids[i] = l->data; + array[i] = l->data;emit_array_property_changed (conn, device->path,DEVICE_INTERFACE , -"UUIDs" ,DBUS_TYPE_STRING , &uuids, i); +"UUIDs" ,DBUS_TYPE_STRING , &array, i); + +g_free (array); + + array =g_dbus_list_interfaces (conn, device->path, &i); +if (array ==NULL ) +return ; -g_free (uuids); +emit_array_property_changed (conn, device->path, +DEVICE_INTERFACE ,"Interfaces" , +DBUS_TYPE_STRING , &array, i); +g_strfreev (array); }static int rec_cmp (const void *a,const void *b)
Signature · 1 line
1.7.7.6
Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
Hi Luiz,
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
---
doc/device-api.txt | 4 ++++
src/device.c | 27 ++++++++++++++++++++++-----2 files changed, 26 insertions(+), 5 deletions(-)
I thought it was possible to achieve this by using D-Bus listeners? E.g. similar to g_dbus_add_service_watch()
What happens when the interface is unregistered with g_dbus_unregister_interface() ?
Best Regards,
Signature · 3 lines
Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil
Luiz Augusto von Dentz
maintainerRe: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
Hi Anderson,
Quoted 13 lines · Anderson Lizardo
Hi Luiz,
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
---
doc/device-api.txt | 4 ++++
src/device.c | 27 ++++++++++++++++++++++-----2 files changed, 26 insertions(+), 5 deletions(-)
Quoted 2 lines
I thought it was possible to achieve this by using D-Bus listeners? E.g. similar to
g_dbus_add_service_watch()
Afaik there is no such thing as introspection data changed or anything like that, we could in theory have local listeners, but at least in BlueZ there is no much use for them since it is not really dynamic after drivers are loaded, but perhaps for oFono and others it could be useful to have some way to watch when interfaces changes.
In case of oFono it does that by having e.g. ofono_modem_add_interface/ofono_modem_remove_interface.
Quoted 2 lines
What happens when the interface is unregistered with
g_dbus_unregister_interface()?
This should only be the case when removing the object so the driver .remove is called which then calls g_dbus_unregister_interface.
Signature · 1 line
Luiz Augusto von Dentz
Marcel Holtmann
maintainerRe: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
Hi Luiz,
Quoted 20 lines
Quoted 11 lines
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
--- doc/device-api.txt | 4 ++++ src/device.c | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)Quoted 2 lines
I thought it was possible to achieve this by using D-Bus listeners? E.g. similar to
g_dbus_add_service_watch()Afaik there is no such thing as introspection data changed or anything like that, we could in theory have local listeners, but at least in BlueZ there is no much use for them since it is not really dynamic after drivers are loaded, but perhaps for oFono and others it could be useful to have some way to watch when interfaces changes.
Quoted 8 lines
In case of oFono it does that by having e.g. ofono_modem_add_interface/ofono_modem_remove_interface.
Quoted 2 lines
What happens when the interface is unregistered with
g_dbus_unregister_interface()?This should only be the case when removing the object so the driver .remove is called which then calls
g_dbus_unregister_interface.
I was not planning to add this to our gdbus code and focus on getting this right for ELL. However look into the D-Bus ObjectManager specification since that is what you want actually.
Regards
Marcel
Luiz Augusto von Dentz
maintainerRe: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
Hi Marcel,
Quoted 28 lines · Marcel Holtmann
Hi Luiz,
Quoted 26 lines
Quoted 11 lines
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
---
doc/device-api.txt | 4 ++++
src/device.c | 27 ++++++++++++++++++++++-----2 files changed, 26 insertions(+), 5 deletions(-)Quoted 2 lines
I thought it was possible to achieve this by using D-Bus listeners? E.g. similar to
g_dbus_add_service_watch()Afaik there is no such thing as introspection data changed or anything like that, we could in theory have local listeners, but at least in BlueZ there is no much use for them since it is not really dynamic after drivers are loaded, but perhaps for oFono and others it could be useful to have some way to watch when interfaces changes.
In case of oFono it does that by having e.g. ofono_modem_add_interface/ofono_modem_remove_interface.
Quoted 2 lines
What happens when the interface is unregistered with
g_dbus_unregister_interface()?
Quoted 6 lines
Quoted 2 lines
This should only be the case when removing the object so the driver .remove is called which then calls
g_dbus_unregister_interface.I was not planning to add this to our gdbus code and focus on getting this right for ELL. However look into the D-Bus ObjectManager specification since that is what you want actually.
So the way forward is to implement ObjectManager? We could have that without breaking any API, but I guess it would make sense to change API such as the manager to take advantage of the ObjectManager.
Btw what is ELL?
Signature · 1 line
Luiz Augusto von Dentz
Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
Hi Luiz,
Quoted 34 lines · Luiz Augusto von Dentz
Hi Marcel,
Quoted 31 lines · Marcel Holtmann
Hi Luiz,
Quoted 28 lines
Quoted 11 lines
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
---
doc/device-api.txt | 4 ++++
src/device.c | 27 ++++++++++++++++++++++-----2 files changed, 26 insertions(+), 5 deletions(-)Quoted 2 lines
I thought it was possible to achieve this by using D-Bus listeners? E.g. similar to
g_dbus_add_service_watch()Afaik there is no such thing as introspection data changed or anything like that, we could in theory have local listeners, but at least in BlueZ there is no much use for them since it is not really dynamic after drivers are loaded, but perhaps for oFono and others it could be useful to have some way to watch when interfaces changes.
In case of oFono it does that by having e.g. ofono_modem_add_interface/ofono_modem_remove_interface.
Quoted 2 lines
What happens when the interface is unregistered with
g_dbus_unregister_interface()?This should only be the case when removing the object so the driver .remove is called which then calls
g_dbus_unregister_interface.
Quoted 7 lines
Quoted 3 lines
I was not planning to add this to our gdbus code and focus on getting this right for ELL. However look into the D-Bus ObjectManager specification since that is what you want actually.
So the way forward is to implement ObjectManager? We could have that without breaking any API, but I guess it would make sense to change API such as the manager to take advantage of the ObjectManager.
Yeah, if we use ObjectManager there wouldn't be much use for our "Devices" and "Adapters" properties.
I think that the only question is: is using ObjectManager as confortable from python (for example) as with our properties?
Quoted 2 lines
Btw what is ELL?
Disclaimer, I have only taken a quick look at the code, but I would define it as eglib reborn, only without the glib part ;-)
Quoted 8 lines
Signature · 6 lines
-- Luiz Augusto von Dentz -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
Signature · 1 line
Vinicius
Marcel Holtmann
maintainerRe: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
In reply to Luiz Augusto von DentzHi Luiz,
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Quoted 11 lines
Quoted 8 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables applications to be able to detect when an interface is enabled/disabled without depending on UUIDs.
--- doc/device-api.txt | 4 ++++ src/device.c | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)Quoted 2 lines
I thought it was possible to achieve this by using D-Bus listeners? E.g. similar to
g_dbus_add_service_watch()Afaik there is no such thing as introspection data changed or anything like that, we could in theory have local listeners, but at least in BlueZ there is no much use for them since it is not really dynamic after drivers are loaded, but perhaps for oFono and others it could be useful to have some way to watch when interfaces changes.
In case of oFono it does that by having e.g. ofono_modem_add_interface/ofono_modem_remove_interface.
Quoted 2 lines
What happens when the interface is unregistered with
g_dbus_unregister_interface()?This should only be the case when removing the object so the driver .remove is called which then calls
g_dbus_unregister_interface.
Quoted 7 lines
Quoted 3 lines
I was not planning to add this to our gdbus code and focus on getting this right for ELL. However look into the D-Bus ObjectManager specification since that is what you want actually.
So the way forward is to implement ObjectManager? We could have that without breaking any API, but I guess it would make sense to change API such as the manager to take advantage of the ObjectManager.
have a look at ObjectManager and how much it takes for us to use it. I know that the properties will be a bit of problem, but maybe still worth it to start supporting it.
Quoted 1 line
Btw what is ELL?
http://git.kernel.org/?p=libs/ell/ell.git
Regards
Marcel