diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-11-01 22:17:45 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-11-01 22:17:45 +0000 |
commit | f600e97b3bf2e2e2d4cdadcd8c42d0bb17df2d3e (patch) | |
tree | 7034794e8a04f273fa8a0663f35aeb3928d82cfa /hcid/dbus-manager.c | |
parent | d319095eb8b9119db839abde6676a206913f4d3b (diff) |
AddServiceRecord: register the record with the sdpd if the service agent is already running
Diffstat (limited to 'hcid/dbus-manager.c')
-rw-r--r-- | hcid/dbus-manager.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c index 0ae97d06..e86afec8 100644 --- a/hcid/dbus-manager.c +++ b/hcid/dbus-manager.c @@ -337,6 +337,7 @@ static DBusHandlerResult add_service_record(DBusConnection *conn, DBusMessage *reply; sdp_record_t *record; const char *path; + int err; /* Check if it is an array of bytes */ if (strcmp(dbus_message_get_signature(msg), "say")) @@ -368,6 +369,30 @@ static DBusHandlerResult add_service_record(DBusConnection *conn, } record->handle = next_handle++; + + if (agent->running) { + sdp_session_t *sess; + sess = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, 0); + if (!sess) { + err = errno; + error("Can't connect to sdp daemon: %s (%d)", + strerror(err), err); + goto fail; + } + + if (sdp_device_record_register(sess, BDADDR_ANY, record, + SDP_RECORD_PERSIST) < 0) { + err = errno; + sdp_close(sess); + error("Record registration failed: %s (%d)", + strerror(err), err); + goto fail; + } + + sdp_close(sess); + } + + agent->records = slist_append(agent->records, record); dbus_message_append_args(msg, @@ -375,6 +400,10 @@ static DBusHandlerResult add_service_record(DBusConnection *conn, DBUS_TYPE_INVALID; return send_message_and_unref(conn, reply); +fail: + sdp_record_free(record); + dbus_message_unref(reply); + return error_failed(conn, msg, err); } static int sdp_record_cmp(sdp_record_t *a, uint32_t *handle) |