Re: returning a string to d-bus



Luka Napotnik wrote:
Hello.

I have a D-BUS listener with a GObject method which should send a string
back to D-BUS. My d-bus listener method is:

gboolean
some_object_get_name(GObject *object, gchar *str, GError **error)
{
        str = g_strdup("Hello");
        return TRUE;
}

But when the client connect to this d-bus interface and calls the
get_name() method, the method doesn't return the string. I'm guessing
I'm passing the string the wrong way. Please help.

You probably want:

gboolean
some_object_get_name(GObject *object, gchar **str, GError **error)
{
    *str = g_strdup("Hello");
    return TRUE
}

and call that function this way:

gchar *str = NULL;
if (some_object_get_name(object, &str, &error) == TRUE)
    gprintf("name: %s\n", str);



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