static void imported_object (GckObject *object, const gchar *destination) { gulong attr_types[3]; GckAttributes *attrs; const GckAttribute *id; CK_OBJECT_CLASS klass; const gchar *message; GError *err = NULL; gchar *label, *hex; attr_types[0] = CKA_LABEL; attr_types[1] = CKA_CLASS; attr_types[2] = CKA_ID; attrs = gck_object_get_full (object, attr_types, G_N_ELEMENTS (attr_types), NULL, &err); if (attrs == NULL) { gkr_tool_handle_error (&err, "couldn't get imported object info"); return; } if (!gck_attributes_find_string (attrs, CKA_LABEL, &label)) label = g_strdup ("unknown"); if (!gck_attributes_find_ulong (attrs, CKA_CLASS, &klass)) klass = CKO_DATA; id = gck_attributes_find (attrs, CKA_ID); switch (klass) { case CKO_CERTIFICATE: message = "%s: imported certificate: %s\n"; break; case CKO_DATA: message = "%s: imported data: %s\n"; break; case CKO_PRIVATE_KEY: message = "%s: imported private key: %s\n"; break; case CKO_PUBLIC_KEY: message = "%s: imported public key: %s\n"; break; case CKO_SECRET_KEY: message = "%s: imported secret key: %s\n"; break; default: message = "%s: imported object: %s\n"; break; }; g_print (message, destination, label); if (id) { hex = egg_hex_encode (id->value, id->length); g_print ("\tidentifier: %s\n", hex); g_free (hex); } gck_attributes_unref (attrs); g_free (label); }
static void prepare_create_prompt (GkdSecretCreate *self) { GkuPrompt *prompt; gchar *label; gchar *text; g_assert (GKD_SECRET_IS_CREATE (self)); g_assert (self->pkcs11_attrs); prompt = GKU_PROMPT (self); if (!gck_attributes_find_string (self->pkcs11_attrs, CKA_LABEL, &label)) label = g_strdup (_("Unnamed")); gku_prompt_reset (prompt, TRUE); gku_prompt_set_title (prompt, _("New Keyring Password")); gku_prompt_set_primary_text (prompt, _("Choose password for new keyring")); text = g_markup_printf_escaped (_("An application wants to create a new keyring called '%s'. " "Choose the password you want to use for it."), label); gku_prompt_set_secondary_text (prompt, text); g_free (text); gku_prompt_show_widget (prompt, "password_area"); gku_prompt_show_widget (prompt, "confirm_area"); g_free (label); }
static gchar* calculate_label (GcrKeyRenderer *self) { gchar *label; if (self->pv->label) return g_strdup (self->pv->label); if (self->pv->attributes) { if (gck_attributes_find_string (self->pv->attributes, CKA_LABEL, &label)) return label; } return g_strdup (_("Key")); }
static void setup_password_prompt (GkdSecretCreate *self) { gchar *label; gchar *text; if (!gck_attributes_find_string (self->attributes, CKA_LABEL, &label)) label = g_strdup (_("Unnamed")); text = g_strdup_printf (_("An application wants to create a new keyring called '%s'. " "Choose the password you want to use for it."), label); g_free (label); gcr_prompt_set_message (GCR_PROMPT (self), _("Choose password for new keyring")); gcr_prompt_set_description (GCR_PROMPT (self), text); gcr_prompt_set_password_new (GCR_PROMPT (self), TRUE); g_free (text); }