* [RFC BlueZ 1/3] gdbus: Add g_dbus_list_interfaces function @ 2012-03-06 12:07 Luiz Augusto von Dentz 2012-03-06 12:07 ` [RFC BlueZ 2/3] core: Add Interfaces property to org.bluez.Adapter Luiz Augusto von Dentz 2012-03-06 12:07 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device Luiz Augusto von Dentz 0 siblings, 2 replies; 9+ messages in thread From: Luiz Augusto von Dentz @ 2012-03-06 12:07 UTC (permalink / raw) To: linux-bluetooth From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> 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(-) diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index a0583e6..26ed6d2 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -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); diff --git a/gdbus/object.c b/gdbus/object.c index 8bc12f5..1701b8f 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -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) -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC BlueZ 2/3] core: Add Interfaces property to org.bluez.Adapter 2012-03-06 12:07 [RFC BlueZ 1/3] gdbus: Add g_dbus_list_interfaces function Luiz Augusto von Dentz @ 2012-03-06 12:07 ` Luiz Augusto von Dentz 2012-03-06 12:07 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device Luiz Augusto von Dentz 1 sibling, 0 replies; 9+ messages in thread From: Luiz Augusto von Dentz @ 2012-03-06 12:07 UTC (permalink / raw) To: linux-bluetooth From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> 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(-) diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt index 20cef03..89688de 100644 --- a/doc/adapter-api.txt +++ b/doc/adapter-api.txt @@ -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. diff --git a/src/adapter.c b/src/adapter.c index c5f4d0d..b6424a1 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -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) -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-06 12:07 [RFC BlueZ 1/3] gdbus: Add g_dbus_list_interfaces function Luiz Augusto von Dentz 2012-03-06 12:07 ` [RFC BlueZ 2/3] core: Add Interfaces property to org.bluez.Adapter Luiz Augusto von Dentz @ 2012-03-06 12:07 ` Luiz Augusto von Dentz 2012-03-06 12:57 ` Anderson Lizardo 1 sibling, 1 reply; 9+ messages in thread From: Luiz Augusto von Dentz @ 2012-03-06 12:07 UTC (permalink / raw) To: linux-bluetooth From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> 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(-) diff --git a/doc/device-api.txt b/doc/device-api.txt index e8fc314..2531d05 100644 --- a/doc/device-api.txt +++ b/doc/device-api.txt @@ -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. diff --git a/src/device.c b/src/device.c index dfc8e59..32527da 100644 --- a/src/device.c +++ b/src/device.c @@ -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) -- 1.7.7.6 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-06 12:07 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device Luiz Augusto von Dentz @ 2012-03-06 12:57 ` Anderson Lizardo 2012-03-06 13:26 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 9+ messages in thread From: Anderson Lizardo @ 2012-03-06 12:57 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: linux-bluetooth Hi Luiz, On Tue, Mar 6, 2012 at 8:07 AM, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > 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, -- Anderson Lizardo Instituto Nokia de Tecnologia - INdT Manaus - Brazil ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-06 12:57 ` Anderson Lizardo @ 2012-03-06 13:26 ` Luiz Augusto von Dentz 2012-03-06 14:35 ` Marcel Holtmann 0 siblings, 1 reply; 9+ messages in thread From: Luiz Augusto von Dentz @ 2012-03-06 13:26 UTC (permalink / raw) To: Anderson Lizardo; +Cc: linux-bluetooth Hi Anderson, On Tue, Mar 6, 2012 at 2:57 PM, Anderson Lizardo <anderson.lizardo@openbossa.org> wrote: > Hi Luiz, > > On Tue, Mar 6, 2012 at 8:07 AM, Luiz Augusto von Dentz > <luiz.dentz@gmail.com> wrote: >> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> >> >> 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() 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. > 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. -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-06 13:26 ` Luiz Augusto von Dentz @ 2012-03-06 14:35 ` Marcel Holtmann 2012-03-07 8:14 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 9+ messages in thread From: Marcel Holtmann @ 2012-03-06 14:35 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: Anderson Lizardo, linux-bluetooth Hi Luiz, > > On Tue, Mar 6, 2012 at 8:07 AM, Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> wrote: > >> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > >> > >> 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() > > 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. > > > 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-06 14:35 ` Marcel Holtmann @ 2012-03-07 8:14 ` Luiz Augusto von Dentz 2012-03-07 14:39 ` Vinicius Costa Gomes 2012-03-07 19:14 ` Marcel Holtmann 0 siblings, 2 replies; 9+ messages in thread From: Luiz Augusto von Dentz @ 2012-03-07 8:14 UTC (permalink / raw) To: Marcel Holtmann; +Cc: Anderson Lizardo, linux-bluetooth Hi Marcel, On Tue, Mar 6, 2012 at 4:35 PM, Marcel Holtmann <marcel@holtmann.org> wrote: > Hi Luiz, > >> > On Tue, Mar 6, 2012 at 8:07 AM, Luiz Augusto von Dentz >> > <luiz.dentz@gmail.com> wrote: >> >> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> >> >> >> >> 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() >> >> 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. >> >> > 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. 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? -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-07 8:14 ` Luiz Augusto von Dentz @ 2012-03-07 14:39 ` Vinicius Costa Gomes 2012-03-07 19:14 ` Marcel Holtmann 1 sibling, 0 replies; 9+ messages in thread From: Vinicius Costa Gomes @ 2012-03-07 14:39 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: Marcel Holtmann, Anderson Lizardo, linux-bluetooth Hi Luiz, On 10:14 Wed 07 Mar, Luiz Augusto von Dentz wrote: > Hi Marcel, > > On Tue, Mar 6, 2012 at 4:35 PM, Marcel Holtmann <marcel@holtmann.org> wrote: > > Hi Luiz, > > > >> > On Tue, Mar 6, 2012 at 8:07 AM, Luiz Augusto von Dentz > >> > <luiz.dentz@gmail.com> wrote: > >> >> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > >> >> > >> >> 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() > >> > >> 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. > >> > >> > 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. > > 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? > > 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 ;-) > > > -- > Luiz Augusto von Dentz > -- > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Cheers, -- Vinicius ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 2012-03-07 8:14 ` Luiz Augusto von Dentz 2012-03-07 14:39 ` Vinicius Costa Gomes @ 2012-03-07 19:14 ` Marcel Holtmann 1 sibling, 0 replies; 9+ messages in thread From: Marcel Holtmann @ 2012-03-07 19:14 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: Anderson Lizardo, linux-bluetooth Hi Luiz, > >> > On Tue, Mar 6, 2012 at 8:07 AM, Luiz Augusto von Dentz > >> > <luiz.dentz@gmail.com> wrote: > >> >> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > >> >> > >> >> 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() > >> > >> 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. > >> > >> > 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. > > 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. > Btw what is ELL? http://git.kernel.org/?p=libs/ell/ell.git Regards Marcel ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-03-07 19:14 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-03-06 12:07 [RFC BlueZ 1/3] gdbus: Add g_dbus_list_interfaces function Luiz Augusto von Dentz 2012-03-06 12:07 ` [RFC BlueZ 2/3] core: Add Interfaces property to org.bluez.Adapter Luiz Augusto von Dentz 2012-03-06 12:07 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device Luiz Augusto von Dentz 2012-03-06 12:57 ` Anderson Lizardo 2012-03-06 13:26 ` Luiz Augusto von Dentz 2012-03-06 14:35 ` Marcel Holtmann 2012-03-07 8:14 ` Luiz Augusto von Dentz 2012-03-07 14:39 ` Vinicius Costa Gomes 2012-03-07 19:14 ` Marcel Holtmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).