gdm_session_worker_ask_list_of_choices (GdmSessionWorker *worker,
                                        const char       *prompt_message,
                                        GdmChoiceList    *list,
                                        char            **answerp)
{
        GVariantBuilder builder;
        GVariant *choices_as_variant;
        GError *error = NULL;
        gboolean res;
        size_t i;

        g_debug ("GdmSessionWorker: presenting user with list of choices:");

        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));

        for (i = 0; i < list->number_of_items; i++) {
                if (list->items[i].key == NULL) {
                        g_warning ("choice list contains item with NULL key");
                        g_variant_builder_clear (&builder);
                        return FALSE;
                }
                g_debug ("GdmSessionWorker:        choices['%s'] = \"%s\"", list->items[i].key, list->items[i].text);
                g_variant_builder_add (&builder, "{ss}", list->items[i].key, list->items[i].text);
        }
        g_debug ("GdmSessionWorker: (and waiting for reply)");

        choices_as_variant = g_variant_builder_end (&builder);

        res = gdm_dbus_worker_manager_call_choice_list_query_sync (worker->priv->manager,
                                                                    worker->priv->service,
                                                                    prompt_message,
                                                                    choices_as_variant,
                                                                    answerp,
                                                                    NULL,
                                                                    &error);

        if (! res) {
                g_debug ("GdmSessionWorker: list request failed: %s", error->message);
                g_clear_error (&error);
        } else {
                g_debug ("GdmSessionWorker: user selected '%s'", *answerp);
        }

        return res;
}
gdm_session_worker_ask_list_of_choices (GdmSessionWorker *worker,
                                        const char       *prompt_message,
                                        GdmChoiceList    *list,
                                        char            **answerp)
{
        GVariantBuilder builder;
        GVariant *choices_as_variant;
        GError *error = NULL;
        gboolean res;
        size_t i;

        g_debug ("GdmSessionWorker: presenting user with list of choices:");

        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));

        for (i = 0; i < list->number_of_items; i++) {
                if (list->items[i].key == NULL) {
                        g_warning ("choice list contains item with NULL key");
                        g_variant_builder_clear (&builder);
                        return FALSE;
                }
                g_debug ("GdmSessionWorker:        choices['%s'] = \"%s\"", list->items[i].key, list->items[i].text);
                g_variant_builder_add (&builder, "{ss}", list->items[i].key, list->items[i].text);
        }
        g_debug ("GdmSessionWorker: (and waiting for reply)");

        choices_as_variant = g_variant_builder_end (&builder);

        res = gdm_dbus_worker_manager_call_choice_list_query_sync (worker->priv->manager,
                                                                    worker->priv->service,
                                                                    prompt_message,
                                                                    choices_as_variant,
                                                                    answerp,
                                                                    NULL,
                                                                    &error);

        if (! res) {
                g_debug ("GdmSessionWorker: list request failed: %s", error->message);
                g_clear_error (&error);
        } else {
                g_debug ("GdmSessionWorker: user selected '%s'", *answerp);
        }

        return res;
}