summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-11-01 01:17:12 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-11-01 01:17:12 +0100
commit063167c27c3e2cf9ac647a617abf345451de0787 (patch)
tree4d3785ccadef402b42770d0a07135ced49b96a57 /src
parent81a1e13f79d3e6e7b2044e9d35592e490b01e65b (diff)
Make FindAdapter return the any object if present
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c5
-rw-r--r--src/adapter.h2
-rw-r--r--src/manager.c14
3 files changed, 17 insertions, 4 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 0c28ac5e..0997c1ee 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3401,6 +3401,11 @@ void adapter_update_devices(struct btd_adapter *adapter)
static gchar *adapter_any_path = NULL;
static int adapter_any_refcount = 0;
+const char *adapter_any_get_path(void)
+{
+ return adapter_any_path;
+}
+
const char *btd_adapter_any_request_path(void)
{
if (adapter_any_refcount > 0)
diff --git a/src/adapter.h b/src/adapter.h
index e5312685..7d666a5b 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -180,5 +180,7 @@ int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
const char *uuid, service_auth_cb cb, void *user_data);
int btd_cancel_authorization(const bdaddr_t *src, const bdaddr_t *dst);
+const char *adapter_any_get_path(void);
+
const char *btd_adapter_any_request_path(void);
void btd_adapter_any_release_path(void);
diff --git a/src/manager.c b/src/manager.c
index c43ef5b8..3b3f52df 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -189,7 +189,12 @@ static DBusMessage *find_adapter(DBusConnection *conn,
/* hci_devid() would make sense to use here, except it
is restricted to devices which are up */
- if (!strncmp(pattern, "hci", 3) && strlen(pattern) >= 4)
+ if (!strcmp(pattern, "any") || !strcmp(pattern, "00:00:00:00:00:00")) {
+ path = adapter_any_get_path();
+ if (path != NULL)
+ goto done;
+ dev_id = -1;
+ } if (!strncmp(pattern, "hci", 3) && strlen(pattern) >= 4)
dev_id = atoi(pattern + 3);
else
dev_id = find_by_address(pattern);
@@ -207,14 +212,15 @@ static DBusMessage *find_adapter(DBusConnection *conn,
if (!adapter)
return no_such_adapter(msg);
+ path = adapter_get_path(adapter);
+
+done:
reply = dbus_message_new_method_return(msg);
if (!reply)
return NULL;
- path = adapter_get_path(adapter);
-
dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_INVALID);
return reply;
}