summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-09-05 20:45:13 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-09-05 20:45:13 +0200
commit9ab6fa037c8c3e72ad0c789c379d3310eafc225f (patch)
treec5cb950fd498c5c8f7d99b5fbcc8f5ff310c6528
parentc92239969b9487bc33ba2b6eb85e81ae7a6afeb4 (diff)
parent681e50c618d246483728bca6628a18c1c44c5b36 (diff)
Merge branch 'for-upstream' of git://gitorious.org/bluez/vudentzs-clone
-rw-r--r--src/device.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/device.c b/src/device.c
index 2bc50711..1cf260ec 100644
--- a/src/device.c
+++ b/src/device.c
@@ -87,6 +87,7 @@ struct browse_req {
struct btd_device *device;
GSList *uuids_added;
GSList *uuids_removed;
+ sdp_list_t *records;
int search_uuid;
gboolean browse;
};
@@ -776,6 +777,7 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
for (seq = recs; seq; seq = seq->next) {
sdp_record_t *rec = (sdp_record_t *) seq->data;
+ sdp_buf_t pdu;
sdp_list_t *svcclass = NULL;
gchar *uuid_str;
GSList *l;
@@ -792,6 +794,16 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
if (!uuid_str)
continue;
+ /* Copy record */
+ if (sdp_gen_record_pdu(rec, &pdu) == 0) {
+ sdp_record_t *record;
+ int scanned;
+
+ record = sdp_extract_pdu(pdu.data, pdu.data_size,
+ &scanned);
+ req->records = sdp_list_append(req->records, record);
+ }
+
l = g_slist_find_custom(device->uuids, uuid_str,
(GCompareFunc) strcmp);
if (!l)
@@ -837,8 +849,11 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
DBusMessage *reply;
const gchar *source = adapter_get_address(adapter);
- if (err < 0)
+ if (err < 0) {
+ error("%s: error updating services: %s (%d)",
+ device->path, strerror(-err), -err);
goto proceed;
+ }
update_services(req, recs);
@@ -856,27 +871,30 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
probe:
- if (!req->uuids_added && !req->uuids_removed)
+ if (!req->uuids_added && !req->uuids_removed) {
+ debug("%s: No service found", device->path);
goto proceed;
+ }
/* Probe matching drivers for services added */
if (req->uuids_added)
- device_probe_drivers(device, req->uuids_added, recs);
+ device_probe_drivers(device, req->uuids_added, req->records);
/* Remove drivers for services removed */
if (req->uuids_removed)
- device_remove_drivers(device, req->uuids_removed, recs);
-
- /* Store the device's profiles in the filesystem */
- store(device);
+ device_remove_drivers(device, req->uuids_removed, req->records);
/* Propagate services changes */
services_changed(req);
proceed:
+
+ /* Store the device's profiles in the filesystem */
+ store(device);
+
if (dbus_message_is_method_call(req->msg, DEVICE_INTERFACE,
"DiscoverServices")) {
- discover_device_reply(req, recs);
+ discover_device_reply(req, req->records);
goto cleanup;
}
@@ -910,6 +928,8 @@ cleanup:
dbus_connection_unref(req->conn);
g_slist_free(req->uuids_added);
g_slist_free(req->uuids_removed);
+ if (req->records)
+ sdp_list_free(req->records, (sdp_free_func_t) sdp_record_free);
g_free(req);
}