dbus_g_proxy_call

pete-c pcwhizzkid at hotmail.com
Wed May 13 06:49:59 PDT 2009



Colin Walters wrote:
> 
> 
> I haven't looked at this in detail, but I will say G_TYPE_STRV is
> intended for an array of strings, but you seem to only want
> G_TYPE_STRING.
> 
> 

Thanks for that, that has helped me work out why I was getting an error
during some of my tests.

I've since found a helpful example at
http://folks.o-hand.com/iain/single-instance-with-dbus/making-single-instance-programs-with-dbus.html
(turns out I do need the introspection), which has helped me to successfully
implement a test method that returns an integer value. The essential core
code of this is:

client side:
...
// Initialise the variables to pass
guint input = 5;
guint *ret;
// Call the remote method
org_peter_PeterTestIFace_test_method(proxy, input, (guint*)&ret, &error);
...

server side:
...
extern gboolean
peter_test_test_method(PeterTest *self, guint input, guint *res, GError
**err)
{
        *res = input + 10;
        return TRUE;
}
...

I have tested, and this works to send the initial value, and return the
result. 
I now want it to send a string back in response to a call, so I have
modified the code: 

client side: 
...
// Initialise our pointer to a string
gchar **ret = NULL;
// Call the remote method
org_peter_PeterTestIFace_get_name(proxy, ret, &error);
...

server side:
...
extern gboolean
peter_test_test_method(PeterTest *self, gchar **res, GError **err)
{
   gchar *str = "hello\0";
   res = &str;
   return TRUE;
}
...

I have used any combination of pointer syntax that I can think of. The
method will get the call, and seem to perform the assignment, but it will
not send the result back to the client, and I end up with a null pointer.
Does anyone know what is going on? I've been puzzling over this for several
hours, and advice would be greatly appreciated.

Pete.
-- 
View this message in context: http://www.nabble.com/dbus_g_proxy_call-tp23408901p23522136.html
Sent from the Free Desktop - dbus mailing list archive at Nabble.com.



More information about the dbus mailing list