diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-06-10 22:24:46 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-06-10 22:24:46 +0000 |
commit | a6f07d2bf12942854072c37c3c42d7447921beee (patch) | |
tree | c5f35ec2ba0b6914d3473017e2cd004195e75bd3 | |
parent | ee47b8948cf78f2dd3f9c1ee94916cec5387481d (diff) |
Use the pattern parameter in DiscoverServices()
-rw-r--r-- | hcid/adapter.c | 2 | ||||
-rw-r--r-- | hcid/dbus-hci.c | 3 | ||||
-rw-r--r-- | hcid/device.c | 28 | ||||
-rw-r--r-- | hcid/device.h | 2 |
4 files changed, 27 insertions, 8 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index f3472256..94eaa25a 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -3895,7 +3895,7 @@ static DBusMessage *create_device(DBusConnection *conn, device->temporary = FALSE; - device_browse(device, conn, msg, FALSE); + device_browse(device, conn, msg, FALSE, 0); adapter->devices = g_slist_append(adapter->devices, device); diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 89ab956d..c7be87e3 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -1263,7 +1263,8 @@ proceed: dbus_message_unref(reply); } else { device->temporary = FALSE; - device_browse(device, bonding->conn, bonding->msg, FALSE); + device_browse(device, bonding->conn, + bonding->msg, FALSE, 0); } } diff --git a/hcid/device.c b/hcid/device.c index 500a401c..a9a937c6 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -76,6 +76,7 @@ struct browse_req { struct device *device; int search_uuid; gboolean update; + gboolean browse; }; struct hci_peer { @@ -1030,12 +1031,22 @@ static DBusMessage *discover_services(DBusConnection *conn, { struct device *device = user_data; const char *pattern; + uint16_t search; if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern, DBUS_TYPE_INVALID) == FALSE) return NULL; - device_browse(device, conn, msg, TRUE); + if (strlen(pattern) == 0) { + device_browse(device, conn, msg, TRUE, 0); + return NULL; + } + + search = sdp_str2svclass(pattern); + if (!search) + return invalid_args(msg); + + device_browse(device, conn, msg, TRUE, search); return NULL; } @@ -1295,8 +1306,8 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data) DBUS_TYPE_ARRAY, &uuids); g_free(uuids); - /* Public browsing was succesful */ - if (!req->search_uuid && recs) + /* Public browsing successful or Single record requested */ + if (req->browse == FALSE || (!req->search_uuid && recs)) goto probe; if (uuid_list[++req->search_uuid]) { @@ -1377,7 +1388,7 @@ fail: } int device_browse(struct device *device, DBusConnection *conn, - DBusMessage *msg, gboolean update) + DBusMessage *msg, gboolean update, uint16_t search) { struct adapter *adapter = device->adapter; struct browse_req *req; @@ -1392,7 +1403,14 @@ int device_browse(struct device *device, DBusConnection *conn, str2ba(adapter->address, &src); str2ba(device->address, &dst); - sdp_uuid16_create(&uuid, uuid_list[req->search_uuid]); + + if (search) { + sdp_uuid16_create(&uuid, search); + req->browse = FALSE; + } else { + sdp_uuid16_create(&uuid, uuid_list[req->search_uuid]); + req->browse = TRUE; + } return bt_search_service(&src, &dst, &uuid, browse_cb, req, NULL); } diff --git a/hcid/device.h b/hcid/device.h index a3d5c903..985a7b46 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -47,7 +47,7 @@ struct device *device_create(DBusConnection *conn, struct adapter *adapter, void device_remove(DBusConnection *conn, struct device *device); gint device_address_cmp(struct device *device, const gchar *address); int device_browse(struct device *device, DBusConnection *conn, - DBusMessage *msg, gboolean update); + DBusMessage *msg, gboolean update, uint16_t search); void device_probe_drivers(struct device *device); #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) |