public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] No more binary SDP registration in new 4.0 API?
@ 2008-07-07 20:53 Manuel Naranjo
  2008-07-08  3:25 ` [Bluez-devel] [PATCH] " Manuel Naranjo
  2008-07-08 20:41 ` [Bluez-devel] " Marcel Holtmann
  0 siblings, 2 replies; 5+ messages in thread
From: Manuel Naranjo @ 2008-07-07 20:53 UTC (permalink / raw)
  To: BlueZ development

Hello everyone,

I've been asking this the hole weekend on the irc channel, but yet no 
one could tell me if this is a bug or a feature, or what ever.

On Dbus api 3.X you could register binary sdp records over dbus, but new 
api can't I all ready implemented adding records, I need to implement 
the update records. But I would like to know if it makes sense to commit 
this patch or not.

Thanks,
Manuel

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bluez-devel] [PATCH] Re: No more binary SDP registration in new 4.0 API?
  2008-07-07 20:53 [Bluez-devel] No more binary SDP registration in new 4.0 API? Manuel Naranjo
@ 2008-07-08  3:25 ` Manuel Naranjo
  2008-07-08 20:41 ` [Bluez-devel] " Marcel Holtmann
  1 sibling, 0 replies; 5+ messages in thread
From: Manuel Naranjo @ 2008-07-08  3:25 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]


> On Dbus api 3.X you could register binary sdp records over dbus, but 
> new api can't I all ready implemented adding records, I need to 
> implement the update records. But I would like to know if it makes 
> sense to commit this patch or not.
Just in case it makes sense, here's the patch that implements 
AddBinServiceRecord and UpdateBinServiceRecord.

[-- Attachment #2: binrecords.patch --]
[-- Type: text/plain, Size: 8632 bytes --]

Index: doc/adapter-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/doc/adapter-api.txt,v
retrieving revision 1.17
diff -u -r1.17 adapter-api.txt
--- doc/adapter-api.txt	3 Jun 2008 14:29:57 -0000	1.17
+++ doc/adapter-api.txt	8 Jul 2008 03:22:23 -0000
@@ -182,6 +182,25 @@
 			Possible errors: org.bluez.Error.InvalidArguments
 					 org.bluez.Error.NotAvailable
 					 org.bluez.Error.Failed
+		
+		uint32 AddBinServiceRecord(array{byte})
+
+			Adds a new service record from and returns the assigned 
+			record handle.
+
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.Failed
+
+		void UpdateBinServiceRecord(uint32 handle, array{byte})
+
+			Updates a given service record.
+
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.NotAvailable
+					 org.bluez.Error.Failed
+		
+		
+
 
 		void RemoveServiceRecord(uint32 handle)
 
Index: hcid/adapter.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/adapter.c,v
retrieving revision 1.129
diff -u -r1.129 adapter.c
--- hcid/adapter.c	30 Jun 2008 17:26:18 -0000	1.129
+++ hcid/adapter.c	8 Jul 2008 03:22:28 -0000
@@ -4119,6 +4119,8 @@
 	auth->agent = NULL;
 }
 
+
+
 static DBusMessage *register_agent(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
@@ -4180,6 +4182,44 @@
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *add_bin_service_record(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	DBusMessageIter iter, array;
+	DBusMessage *reply;
+	struct adapter *adapter = data;
+	const char *sender;
+	const uint8_t *record;
+	int len = -1, err;
+	dbus_uint32_t handle;
+	bdaddr_t src;
+	
+	dbus_message_iter_init(msg, &iter);
+	dbus_message_iter_recurse(&iter, &array);
+	
+	dbus_message_iter_get_fixed_array(&array, &record, &len);
+	if ( len <= 0)
+	    return NULL;
+	
+	sender = dbus_message_get_sender(msg);
+	
+	str2ba(adapter->address, &src);
+	
+	err = add_bin_record(conn, sender, &src, record, len, &handle);
+	
+	if ( err < 0 )
+	    return failed_strerror(msg, err);
+	
+	reply = dbus_message_new_method_return(msg);
+	if (!reply)
+		return NULL;
+
+	dbus_message_append_args(reply, DBUS_TYPE_UINT32, &handle,
+							DBUS_TYPE_INVALID);
+
+	return reply;	
+}
+
 static DBusMessage *add_service_record(DBusConnection *conn,
 						DBusMessage *msg, void *data)
 {
@@ -4207,7 +4248,20 @@
 	dbus_message_append_args(reply, DBUS_TYPE_UINT32, &handle,
 							DBUS_TYPE_INVALID);
 
-	return reply;
+	return reply;	
+
+
+}
+
+static DBusMessage *update_bin_service_record(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct adapter *adapter = data;
+	bdaddr_t src;
+
+	str2ba(adapter->address, &src);
+
+        return update_bin_service_record(conn, msg, &src);
 }
 
 static DBusMessage *update_service_record(DBusConnection *conn,
@@ -4276,7 +4330,9 @@
 	{ "RegisterAgent",	"os",	"",	register_agent		},
 	{ "UnregisterAgent",	"o",	"",	unregister_agent	},
 	{ "AddServiceRecord",	"s",	"u",	add_service_record	},
+	{ "AddBinServiceRecord","ay",	"u",	add_bin_service_record	},
 	{ "UpdateServiceRecord","us",	"",	update_service_record	},
+	{ "UpdateBinServiceRecord","uay","",	update_bin_service_record},
 	{ "RemoveServiceRecord","u",	"",	remove_service_record	},
 	{ "RequestAuthorization","su",	"",	request_authorization,
 						G_DBUS_METHOD_FLAG_ASYNC},
Index: hcid/dbus-database.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-database.c,v
retrieving revision 1.57
diff -u -r1.57 dbus-database.c
--- hcid/dbus-database.c	24 Jun 2008 00:24:08 -0000	1.57
+++ hcid/dbus-database.c	8 Jul 2008 03:22:28 -0000
@@ -102,59 +102,75 @@
 	return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "Failed");
 }
 
-static DBusMessage *add_service_record(DBusConnection *conn,
-						DBusMessage *msg, void *data)
+int add_bin_record(DBusConnection *conn, const char *sender, bdaddr_t *src,
+		    const uint8_t *record, const int len, dbus_uint32_t *handle)
 {
-	DBusMessageIter iter, array;
-	const char *sender;
 	struct record_data *user_record;
 	sdp_record_t *sdp_record;
-	const uint8_t *record;
-	int scanned, len = -1;
-
-	dbus_message_iter_init(msg, &iter);
-	dbus_message_iter_recurse(&iter, &array);
-
-	dbus_message_iter_get_fixed_array(&array, &record, &len);
-	if (len <= 0)
-		return invalid_arguments(msg);
+	int scanned;
 
 	sdp_record = sdp_extract_pdu_safe(record, len, &scanned);
 	if (!sdp_record) {
 		error("Parsing of service record failed");
-		return failed(msg);
+		return -EIO;
 	}
 
 	if (scanned != len) {
 		error("Size mismatch of service record");
 		sdp_record_free(sdp_record);
-		return failed(msg);
+		return -EIO;
 	}
 
-	if (add_record_to_server(BDADDR_ANY, sdp_record) < 0) {
+	if (add_record_to_server(src, sdp_record) < 0) {
 		error("Failed to register service record");
 		sdp_record_free(sdp_record);
-		return failed(msg);
+		return -EIO;
 	}
-
+	
 	user_record = g_new0(struct record_data, 1);
 
 	user_record->handle = sdp_record->handle;
 
-	sender = dbus_message_get_sender(msg);
-
 	user_record->sender = g_strdup(sender);
 
 	records = g_slist_append(records, user_record);
 
 	user_record->listener_id = g_dbus_add_disconnect_watch(conn, sender,
-								exit_callback,
-								user_record,
-								NULL);
+					exit_callback, user_record, NULL);
 
 	debug("listener_id %d", user_record->listener_id);
 
-	return g_dbus_create_reply(msg, DBUS_TYPE_UINT32, &user_record->handle,
+	*handle = user_record->handle;
+	
+	return 0;
+}
+
+
+DBusMessage *add_service_record(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	DBusMessageIter iter, array;
+	const char *sender;
+	const uint8_t *record;
+	int len = -1, err;
+	dbus_uint32_t handle;
+
+	dbus_message_iter_init(msg, &iter);
+	dbus_message_iter_recurse(&iter, &array);
+
+	dbus_message_iter_get_fixed_array(&array, &record, &len);
+	if (len <= 0)
+	    return invalid_arguments(msg);
+	    
+	sender = dbus_message_get_sender(msg);
+
+	err = add_bin_record(conn, sender, BDADDR_ANY, 
+		    record, len, &handle );
+		
+	if ( err < 0 )
+	    return failed(msg);
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_UINT32, &handle,
 							DBUS_TYPE_INVALID);
 }
 
@@ -240,8 +256,8 @@
 	return dbus_message_new_method_return(msg);
 }
 
-static DBusMessage *update_service_record(DBusConnection *conn,
-						DBusMessage *msg, void *data)
+DBusMessage *update_bin_record(DBusConnection *conn,
+				    DBusMessage *msg, bdaddr_t *src)
 {
 	struct record_data *user_record;
 	DBusMessageIter iter, array;
@@ -275,9 +291,15 @@
 		return invalid_arguments(msg);
 	}
 
-	return update_record(conn, msg, BDADDR_ANY, handle, sdp_record);
+	return update_record(conn, msg, src, handle, sdp_record);
+}
+
+DBusMessage *update_service_record(DBusConnection *conn,
+						DBusMessage *msg, void *data){
+	return update_bin_record(conn, msg, BDADDR_ANY);
 }
 
+
 DBusMessage *update_xml_record(DBusConnection *conn,
 				DBusMessage *msg, bdaddr_t *src)
 {
@@ -362,7 +384,7 @@
 static GDBusMethodTable database_methods[] = {
 	{ "AddServiceRecord",		"ay",  "u",	add_service_record		},
 	{ "AddServiceRecordFromXML",	"s",   "u",	add_service_record_from_xml	},
-	{ "UpdateServiceRecord",	"uay", "",	update_service_record		},
+	{ "UpdateServiceRecord",	"uay", "",	update_service_record  		},
 	{ "UpdateServiceRecordFromXML",	"us",  "",	update_service_record_from_xml	},
 	{ "RemoveServiceRecord",	"u",   "",	remove_service_record		},
 	{ }
Index: hcid/dbus-database.h
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-database.h,v
retrieving revision 1.12
diff -u -r1.12 dbus-database.h
--- hcid/dbus-database.h	3 Jun 2008 17:47:44 -0000	1.12
+++ hcid/dbus-database.h	8 Jul 2008 03:22:28 -0000
@@ -27,9 +27,13 @@
 dbus_bool_t database_init(DBusConnection *conn, const char *path);
 void database_cleanup(DBusConnection *conn, const char *path);
 
+int add_bin_record(DBusConnection *conn, const char *sender, bdaddr_t *src,
+		const uint8_t *record, const int len, dbus_uint32_t *handle);
 int add_xml_record(DBusConnection *conn, const char *sender, bdaddr_t *src,
 				const char *record, dbus_uint32_t *handle);
 DBusMessage *update_xml_record(DBusConnection *conn,
 				DBusMessage *msg, bdaddr_t *src);
+DBusMessage *update_bin_record(DBusConnection *conn,
+                                DBusMessage *msg, bdaddr_t *src);
 int remove_record(DBusConnection *conn, const char *sender,
 						dbus_uint32_t handle);

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] No more binary SDP registration in new 4.0 API?
  2008-07-08 20:41 ` [Bluez-devel] " Marcel Holtmann
@ 2008-07-08 19:10   ` Manuel Naranjo
  2008-07-09  0:26     ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Naranjo @ 2008-07-08 19:10 UTC (permalink / raw)
  To: BlueZ development

Hi Marcel,
> the idea is not to use binary SDP records at all anymore. Also we wanna
> move the record registration and service authorization into a plugin and
> don't have this in the Adapter interface anymore.
>   
Ok got it. So then to work with binary records you should use bluelib 
right? Or this is going to be deprecated too?.

Thing is that in cases like BIP you wanna work with binary stuff, 
embedding xml records in your code might not be a good idea at all.

In fact the patch I created was to start making obex-data-server use the 
new API, but this was some how a boomer. What shall we do? Use sdplib, 
or go with xml strings?

Thanks,
Manuel

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] No more binary SDP registration in new 4.0 API?
  2008-07-07 20:53 [Bluez-devel] No more binary SDP registration in new 4.0 API? Manuel Naranjo
  2008-07-08  3:25 ` [Bluez-devel] [PATCH] " Manuel Naranjo
@ 2008-07-08 20:41 ` Marcel Holtmann
  2008-07-08 19:10   ` Manuel Naranjo
  1 sibling, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2008-07-08 20:41 UTC (permalink / raw)
  To: BlueZ development

Hi Manuel,

> I've been asking this the hole weekend on the irc channel, but yet no 
> one could tell me if this is a bug or a feature, or what ever.
> 
> On Dbus api 3.X you could register binary sdp records over dbus, but new 
> api can't I all ready implemented adding records, I need to implement 
> the update records. But I would like to know if it makes sense to commit 
> this patch or not.

the idea is not to use binary SDP records at all anymore. Also we wanna
move the record registration and service authorization into a plugin and
don't have this in the Adapter interface anymore.

Regards

Marcel



-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] No more binary SDP registration in new 4.0 API?
  2008-07-08 19:10   ` Manuel Naranjo
@ 2008-07-09  0:26     ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2008-07-09  0:26 UTC (permalink / raw)
  To: BlueZ development

Hi Manuel,

> > the idea is not to use binary SDP records at all anymore. Also we wanna
> > move the record registration and service authorization into a plugin and
> > don't have this in the Adapter interface anymore.
> >   
> Ok got it. So then to work with binary records you should use bluelib 
> right? Or this is going to be deprecated too?.

yes, the access via SDP Unix socket will also go away.

> Thing is that in cases like BIP you wanna work with binary stuff, 
> embedding xml records in your code might not be a good idea at all.
> 
> In fact the patch I created was to start making obex-data-server use the 
> new API, but this was some how a boomer. What shall we do? Use sdplib, 
> or go with xml strings?

I think the best is to move this all into a plugin and then we could
have a plugin that provides binary record registration. However I am not
a big fan of doing SDP without XML anymore. Building the record with the
current C function is painful and leads to errors or memory leaks.

Regards

Marcel



-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-09  0:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-07 20:53 [Bluez-devel] No more binary SDP registration in new 4.0 API? Manuel Naranjo
2008-07-08  3:25 ` [Bluez-devel] [PATCH] " Manuel Naranjo
2008-07-08 20:41 ` [Bluez-devel] " Marcel Holtmann
2008-07-08 19:10   ` Manuel Naranjo
2008-07-09  0:26     ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox