summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-manager.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-05-30 10:36:03 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-05-30 10:36:03 +0000
commit786cbd0c3e4b70976cf6777eac839d2e4b86641a (patch)
tree137ceb22a47a67d20f9fb76d7edd80c870590892 /hcid/dbus-manager.c
parentbf026c430c11a5bc5e7215cf5937e485663a05f0 (diff)
Add FindAdapter method
Diffstat (limited to 'hcid/dbus-manager.c')
-rw-r--r--hcid/dbus-manager.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index 0a43941d..7db28949 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -77,6 +77,33 @@ static DBusHandlerResult default_adapter(DBusConnection *conn,
return send_reply_and_unref(conn, reply);
}
+static DBusHandlerResult find_adapter(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+ char path[MAX_PATH_LENGTH], *path_ptr = path;
+ const char *pattern;
+ int dev_id;
+
+ dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_INVALID);
+
+ dev_id = hci_devid(pattern);
+ if (dev_id < 0)
+ return error_no_such_adapter(conn, msg);
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, dev_id);
+
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &path_ptr,
+ DBUS_TYPE_INVALID);
+
+ return send_reply_and_unref(conn, reply);
+}
+
static DBusHandlerResult list_adapters(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -160,6 +187,7 @@ static DBusHandlerResult list_services(DBusConnection *conn,
static struct service_data methods[] = {
{ "InterfaceVersion", interface_version },
{ "DefaultAdapter", default_adapter },
+ { "FindAdapter", find_adapter },
{ "ListAdapters", list_adapters },
{ "ListServices", list_services },
{ NULL, NULL }