C DBus : Fails when calling method returning string
Cant please someone tell me why the code below crashes when executing, (compilation goes OK) it in rotated X environment 90 to left.
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
gchar *name = NULL;
g_type_init ();
//Get the connection and ensure the name is not used yet
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (connection == NULL) {
g_warning ("Failed to make connection to system bus: %s",
error->message);
g_error_free (error);
exit(1);
}
proxy = dbus_g_proxy_new_开发者_StackOverflow中文版for_name (connection,
"to.some.Service",
"/to/some/Object",
"to.some.Interface" );
dbus_g_proxy_call(proxy, "getStatus", &error, G_TYPE_INVALID, G_TYPE_STRING, &name, G_TYPE_INVALID);
printf("Name is: %s\n", name);
return 0;
Got answer. Actually the service is running in Python and the returned value was not string ... as a consequence of not being strong types in python. So returning str(status) but no status solved my problem.
精彩评论