From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device
Date: Tue, 6 Mar 2012 14:07:38 +0200 [thread overview]
Message-ID: <1331035658-10000-3-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1331035658-10000-1-git-send-email-luiz.dentz@gmail.com>
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
next prev parent reply other threads:[~2012-03-06 12:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2012-03-06 12:57 ` [RFC BlueZ 3/3] core: Add Interfaces property to org.bluez.Device 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331035658-10000-3-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).