summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-common.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-common.c
parent3ace2361ad7c675f843ab7877d70f25613f26585 (diff)
Use permanent connection to SDP server
Diffstat (limited to 'hcid/dbus-common.c')
-rw-r--r--hcid/dbus-common.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c
index 5d6976b5..d21327a9 100644
--- a/hcid/dbus-common.c
+++ b/hcid/dbus-common.c
@@ -67,6 +67,8 @@
static DBusConnection *conn = NULL;
+static sdp_session_t *sess = NULL;
+
static int experimental = 0;
service_handler_func_t find_service_handler(struct service_data *handlers, DBusMessage *msg)
@@ -367,3 +369,34 @@ int hcid_dbus_init(void)
return 0;
}
+
+int register_sdp_record(uint8_t *data, uint32_t size, uint32_t *handle)
+{
+ if (!sess) {
+ sess = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0);
+ if (!sess) {
+ error("Can't connect to SDP daemon:(%s, %d)",
+ strerror(errno), errno);
+ return -1;
+ }
+ }
+
+ return sdp_device_record_register_binary(sess, BDADDR_ANY,
+ data, size, 0, handle);
+}
+
+int unregister_sdp_record(uint32_t handle)
+{
+ if (!sess)
+ return -ENOENT;
+
+ return sdp_device_record_unregister_binary(sess, BDADDR_ANY, handle);
+}
+
+void cleanup_sdp_session(void)
+{
+ if (sess)
+ sdp_close(sess);
+
+ sess = NULL;
+}