diff options
| author | Marcel Holtmann <marcel@holtmann.org> | 2008-03-15 02:23:02 +0000 | 
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2008-03-15 02:23:02 +0000 | 
| commit | 15884ba98a8ddec4b2ca7fb9fa21a1bc82faa3eb (patch) | |
| tree | 3ce67800acff1ce55f4a1254079eb35937a150b5 /hcid/adapter.c | |
| parent | ea7a10e0084b203f1e414cb163a9b5a998d80a83 (diff) | |
Implement basic support for new service record registration
Diffstat (limited to 'hcid/adapter.c')
| -rw-r--r-- | hcid/adapter.c | 28 | 
1 files changed, 23 insertions, 5 deletions
| diff --git a/hcid/adapter.c b/hcid/adapter.c index 2c4cdc00..b18b054f 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -60,6 +60,7 @@  #include "dbus-helper.h"  #include "dbus-hci.h"  #include "dbus-sdp.h" +#include "dbus-database.h"  #include "dbus-error.h"  #include "error.h"  #include "glib-helper.h" @@ -3767,37 +3768,48 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,  						DBusMessage *msg, void *data)  {  	DBusMessage *reply; -	const char *record; +	const char *sender, *record;  	dbus_uint32_t handle; +	int err;  	if (dbus_message_get_args(msg, NULL,  			DBUS_TYPE_STRING, &record, DBUS_TYPE_INVALID) == FALSE)  		return error_invalid_arguments(conn, msg, NULL); +	sender = dbus_message_get_sender(msg); + +	err = add_xml_record(conn, sender, record, &handle); +	if (err < 0) +		return error_failed_errno(conn, msg, err); +  	reply = dbus_message_new_method_return(msg);  	if (!reply)  		return DBUS_HANDLER_RESULT_NEED_MEMORY; -	handle = 0; -  	dbus_message_append_args(reply, DBUS_TYPE_UINT32, &handle,  							DBUS_TYPE_INVALID);  	return send_message_and_unref(conn, reply);  } -  static DBusHandlerResult update_service_record(DBusConnection *conn,  						DBusMessage *msg, void *data)  {  	DBusMessage *reply;  	dbus_uint32_t handle; -	const char *record; +	const char *sender, *record; +	int err;  	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &handle,  			DBUS_TYPE_STRING, &record, DBUS_TYPE_INVALID) == FALSE)  		return error_invalid_arguments(conn, msg, NULL); +	sender = dbus_message_get_sender(msg); + +	err = update_xml_record(conn, sender, handle, record); +	if (err < 0) +		return error_failed_errno(conn, msg, err); +  	reply = dbus_message_new_method_return(msg);  	if (!reply)  		return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -3810,11 +3822,17 @@ static DBusHandlerResult remove_service_record(DBusConnection *conn,  {  	DBusMessage *reply;  	dbus_uint32_t handle; +	const char *sender;  	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &handle,  						DBUS_TYPE_INVALID) == FALSE)  		return error_invalid_arguments(conn, msg, NULL); +	sender = dbus_message_get_sender(msg); + +	if (remove_record(conn, sender, handle) < 0) +		return error_not_available(conn, msg); +  	reply = dbus_message_new_method_return(msg);  	if (!reply)  		return DBUS_HANDLER_RESULT_NEED_MEMORY; | 
