[PATCH] Re: gupnp-binding-tool



OK, please forget my previous mails. 

By playing around with the GUPnP code I now understand the examples from the tutorial "Writing a GUPnP Service". After reading the tutorial I had the impression that the gupnp-binding-tool generates fully functional skeleton callback handlers. My suggestions go into the direction that the callback handlers should be easily connected in order to get working code.

However, the misunderstanding could have been avoided if the explanation would have been a bit more verbose. I attached a small patch to extend the tutorial with some additional information that hopefully makes it clear, that still manual code must be written after using the gupnp-binding-tool.

Regards,
     Michael


On Sun, Jun 5, 2011 at 11:16 PM, Michael Rumpf <michael rumpf gmail com> wrote:
I forgot one thing.

The autoconnect function does not seem to be able to deal with code that has been generated with a --prefix. When I give the callback functions a "on" prefix I get linker errors because some methods from the 3 services have the same name. There is no way to give a suffix so that I can append "cb" to the end of the function names. The consequence is that the autoconnect magic does not work and I get a "Not Found" message.

Shouldn't there be a "--suffix" parameter for the binding tool so that "cb" can be appended (or make it a default suffix)?
And shouldn't it be possible to pass the "prefix" to the autoconnect magic so that it works with functions that have a prefix?

Regards,
     Michael


On Sun, Jun 5, 2011 at 10:55 PM, Michael Rumpf <michael rumpf gmail com> wrote:
Hi,

I'm very new to gupnp and I might still have some issues understanding the concepts behind it. Here is what I'm trying to do. I use the gupnp-binding-tool in order to generate the server side stub code for 3 service description.xml files.

1. when I #include all the 3 generated files in my code (each one generated with a different prefix) I get a linker error that the function _free_cb_data() has been defined 3 times.

I see 3 possible solutions:
a) Use the --prefix also for the function  _free_cb_data() 
b) Move the function  _free_cb_data() into the gupnp library
c) Use a #ifndef #define #endif sequence in order to define the method only once

Currently I help myself with the following script

../../base/bin/gupnp-binding-tool --prefix renderingcontrol --mode server RenderingControl/description.xml > audio-renderer-renderingcontrol.c1
cat audio-renderer-renderingcontrol.c1 | sed -e 's/_free_cb_data/_renderingcontrol_free_cb_data/g' > audio-renderer-renderingcontrol.c
rm audio-renderer-renderingcontrol.c1

2. The generated code contains methods for connecting the action callback handlers and for the state variable handlers. But the code does not provide a method where all action callback and state variable handlers get connected. I still need to add calls like this

<PREFIX>_<ACTIONNAME>_action_connect(GUPNP_SERVICE (myServiceInfo), G_CALLBACK(<PREFIX>_<ACTIONNAME>_action_set), NULL);
<PREFIX>_<ACTIONNAME>_action_connect(GUPNP_SERVICE (myServiceInfo), G_CALLBACK(<PREFIX>_<ACTIONNAME>_action_get), NULL);

It would be no problem for the gupnp-binding-tool to generate one function like this

action_connect_all (GUPnPService *service)

This would be a dummy implementation where no individual userdata can be passed to the different action_connect functions, but it would save a lot of typing/scripting in order to get a service up and running.

Regards,
     Michael


From 0dfa55397779051e302d266eb538134e49625aed Mon Sep 17 00:00:00 2001
From: Michael Rumpf <michael rumpfonline de>
Date: Tue, 14 Jun 2011 00:11:37 +0200
Subject: [PATCH] Added an explanation about what has been generated and what still needs to be written manually

---
 doc/server-tutorial.xml |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/doc/server-tutorial.xml b/doc/server-tutorial.xml
index e4323ee..e7ad69f 100644
--- a/doc/server-tutorial.xml
+++ b/doc/server-tutorial.xml
@@ -274,6 +274,8 @@ g_signal_connect (service, "query-variable::Status", G_CALLBACK (query_status_cb
     </para>
     <para>
       In the following examples the wrapper has been created with <literal>--mode server --prefix switch</literal>.
+      The code snippet below shows an implementation of two callback handlers (<literal>get_status_cb</literal>
+      and <literal>set_target_cb</literal>), which do invocations of the generated wrapper functions.
     </para>
     <programlisting>static gboolean status;
 
-- 
1.7.4.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]