XML SDP Record Registration
PATCH 1/1 XML SDP Record Registration
Marcel,
Attached is a patch that adds an expat based parser for parsing XML records. I've also added a new API function AddServiceRecordAsXML (does the same thing as AddServiceRecord, but in XML format) to the Manager hierarchy.
I've modified the service-agent example to take a new argument, --xmlfile, which will attempt to register a record stored in an XML format.
Let me know what you think!
Regards,
-Denis
Index: common/sdp-dummy.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-dummy.c,v retrieving revision 1.2
sdp-dummy.c +23 -0
@@ -24,5 +24,28 @@#ifdef HAVE_CONFIG_H #include <config.h> #endif #include "sdp-xml.h" + +sdp_xml_context *sdp_xml_init_context () +{ +return NULL ; +} + +int sdp_xml_parse_chunk (sdp_xml_context * context,const char *data,int size, +int final) +{ +return -1 ; +} + + + +sdp_record_t *sdp_xml_get_record (sdp_xml_context * context) +{ +return NULL ; +} + +void sdp_xml_free_context (sdp_xml_context * context) +{ + +}
Index: common/sdp-expat.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-expat.c,v retrieving revision 1.2
sdp-expat.c +405 -0
410 lines not on this page · raw message
Index: common/sdp-xml.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-xml.c,v
retrieving revision 1.2
sdp-xml.c +345 -1
367 lines not on this page · raw message
Index: common/sdp-xml.h
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-xml.h,v
retrieving revision 1.2
sdp-xml.h +41 -0
50 lines not on this page · raw message
Index: hcid/dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v retrieving revision 1.84
dbus-api.txt +11 -0
@@ -189,10 +189,21 @@ representation of a service record. If the service agent is running the service record will be automatically registered, otherwise the record will be available when the service agent Start method is called. + uint32 AddServiceRecordAsXML(string path, string record) + + Add a new service record to the service agent + and returns the assigned handle. + + The path parameter is the object path of the + service agent. The record parameter is the XML + representation of a service record. If the service + agent is running the service record will be automatically + registered, otherwise the record will be available + when the service agent Start method is called. void RemoveServiceRecord(string path, uint32 handle) Remove a service record from the service agent records list.
Index: hcid/dbus-manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-manager.c,v retrieving revision 1.44
dbus-manager.c +118 -0
148 lines not on this page · raw message
Index: hcid/service-agent.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/service-agent.c,v retrieving revision 1.11
service-agent.c +86 -1
180 lines not on this page · raw message
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Denis,
Quoted 3 lines
Attached is a patch that adds an expat based parser for parsing XML records. I've also added a new API function AddServiceRecordAsXML (does the same thing as AddServiceRecord, but in XML format) to the Manager hierarchy.
looks good to me, but please follow the coding style of BlueZ. In your you have way to many whitespace between function names and pointers etc.
Quoted 2 lines
I've modified the service-agent example to take a new argument, --xmlfile, which will attempt to register a record stored in an XML format.
Nice idea. I like that. The dbus_message_append_args() can actually add more then one argument at a time, this is why it is called "args". And please use mmap() for reading the XML file.
Regards
Marcel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Denis,
Quoted 6 lines
Quoted 2 lines
I've modified the service-agent example to take a new argument, --xmlfile, which will attempt to register a record stored in an XML format.
Nice idea. I like that. The
dbus_message_append_args()can actually add more then one argument at a time, this is why it is called "args". And please usemmap()for reading the XML file.
the code is untested, but I committed a version to the CVS that actually implements your idea.
Regards
Marcel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel,
Here's a fixed up version of the patch.
Your changes to service-agent seem to be working OK.
I've made a script that dumps all profiles that sdptool supports and registers them back using XML and compares the results. It seems to work for all of them, but further testing would be appreciated.
-Denis
Quoted 24 lines · Marcel Holtmann
Hi Denis,
Quoted 4 lines
Attached is a patch that adds an expat based parser for parsing XML records. I've also added a new API function AddServiceRecordAsXML (does the same thing as AddServiceRecord, but in XML format) to the Manager hierarchy.
looks good to me, but please follow the coding style of BlueZ. In your you have way to many whitespace between function names and pointers etc.
Quoted 3 lines
I've modified the service-agent example to take a new argument, --xmlfile, which will attempt to register a record stored in an XML format.
Nice idea. I like that. The
dbus_message_append_args()can actually add more then one argument at a time, this is why it is called "args". And please usemmap()for reading the XML file.Regards
Marcel
Quoted 9 lines
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Index: common/sdp-dummy.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-dummy.c,v retrieving revision 1.2
sdp-dummy.c +23 -0
@@ -24,5 +24,28 @@#ifdef HAVE_CONFIG_H #include <config.h> #endif #include "sdp-xml.h" + +sdp_xml_context *sdp_xml_init_context () +{ +return NULL ; +} + +int sdp_xml_parse_chunk (sdp_xml_context *context,const char *data,int size, +int final) +{ +return -1 ; +} + + + +sdp_record_t *sdp_xml_get_record (sdp_xml_context *context) +{ +return NULL ; +} + +void sdp_xml_free_context (sdp_xml_context *context) +{ + +}
Index: common/sdp-expat.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-expat.c,v retrieving revision 1.2
sdp-expat.c +405 -0
410 lines not on this page · raw message
Index: common/sdp-xml.c
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-xml.c,v
retrieving revision 1.2
sdp-xml.c +350 -7
412 lines not on this page · raw message
Index: common/sdp-xml.h
===================================================================
RCS file: /cvsroot/bluez/utils/common/sdp-xml.h,v
retrieving revision 1.2
sdp-xml.h +41 -0
50 lines not on this page · raw message
Index: hcid/dbus-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-api.txt,v retrieving revision 1.84
dbus-api.txt +11 -0
@@ -189,10 +189,21 @@ representation of a service record. If the service agent is running the service record will be automatically registered, otherwise the record will be available when the service agent Start method is called. + uint32 AddServiceRecordAsXML(string path, string record) + + Add a new service record to the service agent + and returns the assigned handle. + + The path parameter is the object path of the + service agent. The record parameter is the XML + representation of a service record. If the service + agent is running the service record will be automatically + registered, otherwise the record will be available + when the service agent Start method is called. void RemoveServiceRecord(string path, uint32 handle) Remove a service record from the service agent records list.
Index: hcid/dbus-manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-manager.c,v retrieving revision 1.44
dbus-manager.c +118 -0
148 lines not on this page · raw message
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Denis,
Quoted 1 line
Here's a fixed up version of the patch.
not it is not. I spent the last hours to fix your coding style mistakes. I really like the stuff you do, but the more time I have to spent to fix your code, the unlikelier I might include it. Here are some tips:
You are doing way too much casts. Especially all casts for malloc() and free() are totally unneeded. Make sure you include malloc.h and everything will be fine. Check the manual pages for needed includes if you are unsure. Every cast has a potential to hide an error. Please do only casts if you really have to and you are 100% sure it is the only way to make this code working.
Pointer are never initialized with "= 0". Never. If you have to, then it is "= NULL". The same applies to any comparison and I prefer doing this with "!" as NULL check.
In general, the assigned of a variable when declaring it will only hide programming mistakes that a compiler warning might have found. This applies to any compiler warning you see. Don't try to hide. Understand the real cause for it and fix that.
No public function when they are not needed. I prefer you declare everything as static first and then non-static if needed. In this case the compiler also warns you about unused code.
Keep the API simple. All of this is internal stuff and we can change it without breaking any other applications. Having only one function for the XML parsing makes it really simple and you don't have to play any nasty typedef tricks. Speaking of which, typedefs should be avoided whenever possible. Our SDP API is not a good example for that, I know that, but it is too late to change it.
Quoted 3 lines
I've made a script that dumps all profiles that sdptool supports and registers them back using XML and compares the results. It seems to work for all of them, but further testing would be appreciated.
Care to send a patch for sdptool that retrieves SDP records in XML format.
Regards
Marcel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel,
Oof, ouch.
In my defense, I followed the advice given in Linux CodingStyle document. Most of the indentation issues you had a problem with was due to me using 'indent' with the suggested options.
In the future I will happily follow the code style conventions you outline. However, given that this is my first serious submission I cannot be expected to 'guess' the conventions if they are not written down, especially since these are not outlined in the Linux CodingStyle document.
Since it seems that BlueZ has further conventions that developers should be following, which are not outlined in the Linux Coding Style documents, I suggest that you include them on the Coding Style section of the Development page of bluez.org to avoid such problems in the future :)
Regards,
-Denis
Quoted 7 lines
You are doing way too much casts. Especially all casts for
malloc()andfree()are totally unneeded. Make sure you includemalloc.hand everything will be fine. Check the manual pages for needed includes if you are unsure. Every cast has a potential to hide an error. Please do only casts if you really have to and you are 100% sure it is the only way to make this code working.
Quoted 8 lines
Pointer are never initialized with "= 0". Never. If you have to, then it is "= NULL". The same applies to any comparison and I prefer doing this with "!" as NULL check.
In general, the assigned of a variable when declaring it will only hide programming mistakes that a compiler warning might have found. This applies to any compiler warning you see. Don't try to hide. Understand the real cause for it and fix that.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
Marcel Holtmann
maintainerHi Denis,
Quoted 10 lines
Oof, ouch.
In my defense, I followed the advice given in Linux CodingStyle document. Most of the indentation issues you had a problem with was due to me using 'indent' with the suggested options.
In the future I will happily follow the code style conventions you outline. However, given that this is my first serious submission I cannot be expected to 'guess' the conventions if they are not written down, especially since these are not outlined in the Linux CodingStyle document.
I simply have to keep the coding style unique for the whole project, because otherwise patching will become a nightmare. We actually follow the Linux kernel coding style and the best documentation is the paper from Greg KH a couple of years ago. I linked the paper and his talk from this page:
http://www.bluez.org/development.html
And one small piece of advise. Don't use indent. Nothing good comes out of it. Following the kernel coding style also implies to rethink the usage of goto and some other constructs where universities tried to tell you that these are bad. However this is a learning process and when you submit more and more patch you will definitely get a feel for it.
Quoted 4 lines
Since it seems that BlueZ has further conventions that developers should be following, which are not outlined in the Linux Coding Style documents, I suggest that you include them on the Coding Style section of the Development page of bluez.org to avoid such problems in the future :)
I should write something about the extra conventions, but to my shame, I am too lazy.
Regards
Marcel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel