summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-05 15:37:54 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-05 15:37:54 -0300
commit681e50c618d246483728bca6628a18c1c44c5b36 (patch)
treebaf742700cad7341580d6e2e9f8fdffa690b833d
parentae4b865375b5d521f6c2e51815f7e1eb6f0a7638 (diff)
Fix problem which prevents drivers from being probed.
-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);
}