Re: [RFC v1 03/16] manager: Extend FindAdapter with "default" pattern
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2012-11-16 13:29:00
Hi Mikel, On Thu, Nov 15, 2012 at 5:09 PM, Mikel Astiz [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Mikel Astiz <redacted> Extend the supported values in the given pattern in order to return the default adapter if "default" is given. --- doc/manager-api.txt | 1 + src/manager.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)diff --git a/doc/manager-api.txt b/doc/manager-api.txt index 8497141..b0d534d 100644 --- a/doc/manager-api.txt +++ b/doc/manager-api.txt@@ -27,6 +27,7 @@ Object path / patterns are "hci0" or "00:11:22:33:44:55". Other supported values are: "any" + "default" Possible errors: org.bluez.Error.InvalidArguments org.bluez.Error.NoSuchAdapterdiff --git a/src/manager.c b/src/manager.c index 3088dd9..79d049b 100644 --- a/src/manager.c +++ b/src/manager.c@@ -110,7 +110,9 @@ static DBusMessage *find_adapter(DBusConnection *conn, } else if (!strncmp(pattern, "hci", 3) && strlen(pattern) >= 4) { dev_id = atoi(pattern + 3); adapter = manager_find_adapter_by_id(dev_id); - } else { + } else if (!strcmp(pattern, "default")) + adapter = manager_find_adapter_by_id(default_adapter_id); + else { bdaddr_t bdaddr; str2ba(pattern, &bdaddr); adapter = manager_find_adapter(&bdaddr); --1.7.11.7
Hmm, I though we would have a property e.g. DefaultAdapter because with ObjectManager you also get the properties so once you do GetManagedObjects you discover what is the default one. It could also be a property of the Adapter interface e.g. boolean Default but if it changes we actually have to emit 2 signals so it would no be an atomic operation as it should be. -- Luiz Augusto von Dentz