summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-service.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-11-17 22:36:47 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-11-17 22:36:47 +0000
commitfdd685636fc68c13758084bdfe1232c0d636308d (patch)
tree75d0528a6236b66f9f020022b6ef289e50c73385 /hcid/dbus-service.c
parent3ace2361ad7c675f843ab7877d70f25613f26585 (diff)
Use permanent connection to SDP server
Diffstat (limited to 'hcid/dbus-service.c')
-rw-r--r--hcid/dbus-service.c49
1 files changed, 8 insertions, 41 deletions
diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c
index 208dd160..324ac681 100644
--- a/hcid/dbus-service.c
+++ b/hcid/dbus-service.c
@@ -30,9 +30,6 @@
#include <unistd.h>
#include <stdlib.h>
-#include <bluetooth/sdp.h>
-#include <bluetooth/sdp_lib.h>
-
#include <dbus/dbus.h>
#include "hcid.h"
@@ -43,7 +40,6 @@
#include "dbus-manager.h"
#include "dbus-service.h"
-
static struct slist *services = NULL;
struct binary_record *binary_record_new()
@@ -208,73 +204,44 @@ mem_fail:
int register_agent_records(struct slist *lrecords)
{
- sdp_session_t *sess;
- struct binary_record *rec;
- uint32_t handle;
- int err;
-
- /* FIXME: attach to a specific adapter */
- sess = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
- if (!sess) {
- error("Can't connect to sdp daemon:(%s, %d)", strerror(errno), errno);
- return -1;
- }
-
while (lrecords) {
- rec = lrecords->data;
+ struct binary_record *rec = lrecords->data;
lrecords = lrecords->next;
+ uint32_t handle = 0;
if (!rec || !rec->buf || rec->handle != 0xffffffff)
continue;
- handle = 0;
- if (sdp_device_record_register_binary(sess, BDADDR_ANY, rec->buf->data,
- rec->buf->data_size, SDP_RECORD_PERSIST, &handle) < 0) {
+ if (register_sdp_record(rec->buf->data, rec->buf->data_size, &handle) < 0) {
/* FIXME: If just one of the service record registration fails */
error("Service Record registration failed:(%s, %d)",
strerror(errno), errno);
}
+
rec->handle = handle;
}
- err = errno;
- sdp_close(sess);
- errno = err;
-
return 0;
}
static int unregister_agent_records(struct slist *lrecords)
{
- sdp_session_t *sess;
- struct binary_record *rec;
- int err;
-
- /* FIXME: attach to a specific adapter */
- sess = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
- if (!sess) {
- error("Can't connect to sdp daemon:(%s, %d)", strerror(errno), errno);
- return -1;
- }
-
while (lrecords) {
- rec = lrecords->data;
+ struct binary_record *rec = lrecords->data;
lrecords = lrecords->next;
+
if (!rec || rec->handle == 0xffffffff)
continue;
- if (sdp_device_record_unregister_binary(sess, BDADDR_ANY, rec->handle) < 0) {
+ if (unregister_sdp_record(rec->handle) < 0) {
/* FIXME: If just one of the service record registration fails */
error("Service Record unregistration failed:(%s, %d)",
strerror(errno), errno);
}
+
rec->handle = 0xffffffff;
}
- err = errno;
- sdp_close(sess);
- errno = err;
-
return 0;
}