static void rb_metadata_dbus_get_saveable_types (GVariant *parameters, GDBusMethodInvocation *invocation, ServiceData *svc) { char **saveable_types; saveable_types = rb_metadata_get_saveable_types (svc->metadata); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(^as)", saveable_types)); g_strfreev (saveable_types); }
static int test_saveable_types () { RBMetaData *md; char **saveable; int i; md = rb_metadata_new (); saveable = rb_metadata_get_saveable_types (md); g_object_unref (md); for (i = 0; saveable[i] != NULL; i++) { g_print ("%s\n", saveable[i]); } g_strfreev (saveable); return 0; }
static DBusHandlerResult rb_metadata_dbus_get_saveable_types (DBusConnection *connection, DBusMessage *message, ServiceData *svc) { DBusMessageIter iter; DBusMessage *reply; char **saveable_types; /* construct reply */ reply = dbus_message_new_method_return (message); if (!reply) { rb_debug ("out of memory creating return message"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } dbus_message_iter_init_append (reply, &iter); saveable_types = rb_metadata_get_saveable_types (svc->metadata); if (!rb_metadata_dbus_add_strv (&iter, saveable_types)) { rb_debug ("out of memory adding saveable types to return message"); g_strfreev (saveable_types); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } g_strfreev (saveable_types); if (!dbus_connection_send (connection, reply, NULL)) { rb_debug ("failed to send return message"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } dbus_message_unref (reply); return DBUS_HANDLER_RESULT_HANDLED; }