示例#1
0
static GcrPrompt *
create_prompt (pinentry_t pe, int confirm)
{
  GcrPrompt *prompt;
  GError *error = NULL;
  char *msg;

  /* Create the prompt.  */
  prompt = GCR_PROMPT (gcr_system_prompt_open (-1, NULL, &error));
  if (! prompt)
    {
      g_warning ("couldn't create prompt for gnupg passphrase: %s",
		 error->message);
      g_error_free (error);
      return NULL;
    }

  /* Set the messages for the various buttons, etc.  */
  if (pe->title)
    {
      msg = pinentry_utf8_validate (pe->title);
      gcr_prompt_set_title (prompt, msg);
      g_free (msg);
    }

  if (pe->description)
    {
      msg = pinentry_utf8_validate (pe->description);
      gcr_prompt_set_description (prompt, msg);
      g_free (msg);
    }

  /* An error occured during the last prompt.  */
  if (pe->error)
    {
      msg = pinentry_utf8_validate (pe->error);
      gcr_prompt_set_warning (prompt, msg);
      g_free (msg);
    }

  if (! pe->prompt && confirm)
    gcr_prompt_set_message (prompt, "Message");
  else if (! pe->prompt && ! confirm)
    gcr_prompt_set_message (prompt, "Enter Passphrase");
  else
    {
      msg = pinentry_utf8_validate (pe->prompt);
      gcr_prompt_set_message (prompt, msg);
      g_free (msg);
    }

  if (! confirm)
    gcr_prompt_set_password_new (prompt, !!pe->repeat_passphrase);

  if (pe->ok || pe->default_ok)
    {
      msg = pinentry_utf8_validate (pe->ok ?: pe->default_ok);
      gcr_prompt_set_continue_label (prompt, msg);
      g_free (msg);
    }
static GcrPrompt *
open_password_prompt (GckSession *session,
                      const gchar *keyid,
                      const gchar *errmsg,
                      const gchar *prompt_text,
                      const gchar *description,
                      gboolean confirm)
{
	GcrPrompt *prompt;
	GError *error = NULL;
	gboolean auto_unlock;
	const gchar *choice;

	g_assert (GCK_IS_SESSION (session));

	prompt = GCR_PROMPT (gcr_system_prompt_open (-1, NULL, &error));
	if (prompt == NULL) {
		g_warning ("couldn't create prompt for gnupg passphrase: %s", egg_error_message (error));
		g_error_free (error);
		return NULL;
	}

	gcr_prompt_set_title (prompt, _("Enter Passphrase"));
	gcr_prompt_set_message (prompt, prompt_text ? prompt_text : _("Enter Passphrase"));
	gcr_prompt_set_description (prompt, description);

	gcr_prompt_set_password_new (prompt, confirm);
	gcr_prompt_set_continue_label (prompt, _("Unlock"));

	if (errmsg)
		gcr_prompt_set_warning (prompt, errmsg);

	if (keyid == NULL) {
		gcr_prompt_set_choice_label (prompt, NULL);

	} else {
		auto_unlock = gkd_login_available (session);

		choice = NULL;
		if (auto_unlock)
			choice = _("Automatically unlock this key, whenever I'm logged in");
		gcr_prompt_set_choice_label (prompt, choice);

		load_unlock_options (prompt);
	}

	return prompt;
}
示例#3
0
static void
setup_unlock_prompt (GkmWrapPrompt *self,
                     CK_ATTRIBUTE_PTR attrs,
                     CK_ULONG n_attrs,
                     gboolean first)
{
	CK_ATTRIBUTE_PTR attr;
	GcrPrompt *prompt;
	const gchar *label = NULL;
	CK_OBJECT_CLASS klass;

	g_assert (GKM_IS_WRAP_PROMPT (self));
	prompt = GCR_PROMPT (self);

	/* Load up the object class */
	if (!gkm_attributes_find_ulong (attrs, n_attrs, CKA_CLASS, &klass))
		klass = (CK_ULONG)-1;

	/* Load up its label */
	attr = gkm_attributes_find (attrs, n_attrs, CKA_LABEL);
	if (attr != NULL)
		label = attr->pValue;

	/* Load up the identifier */
	attr = gkm_attributes_find (attrs, n_attrs, CKA_ID);
	if (attr != NULL && !label)
		label = attr->pValue;

	if (!label)
		label = _("Unnamed");

	if (klass == CKO_G_COLLECTION) {
		if (is_login_keyring (attrs, n_attrs))
			setup_unlock_keyring_login (self);
		else
			setup_unlock_keyring_other (self, label);
	} else {
		setup_unlock_object (self, label, klass);
	}

	if (!first)
		gcr_prompt_set_warning (prompt, _("The unlock password was incorrect"));

	gcr_prompt_set_continue_label (prompt, _("Unlock"));
}