Ejemplo n.º 1
0
static void
gkd_secret_create_prompt_ready (GkdSecretPrompt *prompt)
{
	GkdSecretCreate *self = GKD_SECRET_CREATE (prompt);
	GkdSecretSecret *master;

	if (!gku_prompt_has_response (GKU_PROMPT (prompt))) {

		/* Does the alias exist? */
		if (locate_alias_collection_if_exists (self))
			unlock_or_complete_this_prompt (self);

		/* Otherwise we're going to prompt */
		else
			prepare_create_prompt (self);

		return;
	}

	/* Already prompted, create collection */
	g_return_if_fail (gku_prompt_get_response (GKU_PROMPT (prompt)) == GKU_RESPONSE_OK);
	master = gkd_secret_prompt_get_secret (prompt, "password");

	if (master && create_collection_with_secret (self, master))
		gkd_secret_prompt_complete (prompt);
	else
		gkd_secret_prompt_dismiss (prompt);

	gkd_secret_secret_free (master);
}
Ejemplo n.º 2
0
static void
perform_prompting (GkdSecretCreate *self)
{
    GkdSecretPrompt *prompt = GKD_SECRET_PROMPT (self);

    /* Does the alias exist? */
    if (locate_alias_collection_if_exists (self)) {
        unlock_or_complete_this_prompt (self);

        /* Have we gotten a password yet? */
    } else if (self->master == NULL) {
        setup_password_prompt (self);
        gcr_prompt_password_async (GCR_PROMPT (self),
                                   gkd_secret_prompt_get_cancellable (prompt),
                                   on_prompt_password_complete, NULL);

        /* Check that the password is not empty */
    } else if (!self->confirmed) {
        setup_confirmation_prompt (self);
        gcr_prompt_confirm_async (GCR_PROMPT (self),
                                  gkd_secret_prompt_get_cancellable (prompt),
                                  on_prompt_confirmation_complete, NULL);

        /* Actually create the keyring */
    } else  if (create_collection_with_secret (self, self->master)) {
        gkd_secret_prompt_complete (prompt);

        /* Failed */
    } else {
        gkd_secret_prompt_dismiss (prompt);
    }
}