static GObject* seahorse_pkcs11_refresher_constructor (GType type, guint n_props, GObjectConstructParam *props) { SeahorsePkcs11Refresher *self = SEAHORSE_PKCS11_REFRESHER (G_OBJECT_CLASS (seahorse_pkcs11_refresher_parent_class)->constructor(type, n_props, props)); GP11Slot *slot; GList *objects, *l; gulong handle; g_return_val_if_fail (self, NULL); g_return_val_if_fail (self->source, NULL); objects = seahorse_context_get_objects (NULL, SEAHORSE_SOURCE (self->source)); for (l = objects; l; l = g_list_next (l)) { if (g_object_class_find_property (G_OBJECT_GET_CLASS (l->data), "pkcs11-handle")) { g_object_get (l->data, "pkcs11-handle", &handle, NULL); g_hash_table_insert (self->checks, g_memdup (&handle, sizeof (handle)), g_object_ref (l->data)); } } g_list_free (objects); /* Step 1. Load the session */ slot = seahorse_pkcs11_source_get_slot (self->source); gp11_slot_open_session_async (slot, CKF_RW_SESSION, NULL, NULL, self->cancellable, (GAsyncReadyCallback)on_open_session, self); seahorse_operation_mark_start (SEAHORSE_OPERATION (self)); return G_OBJECT (self); }
static void require_session_async (GP11Object *self, GP11Call *call, gulong flags, GCancellable *cancellable) { GP11ObjectData *data = GP11_OBJECT_GET_DATA (self); GP11Session *session; g_assert (GP11_IS_OBJECT (self)); session = gp11_object_get_session (self); if (session) { run_call_with_session (call, session); g_object_unref (session); } else { gp11_slot_open_session_async (data->slot, flags, NULL, NULL, cancellable, opened_session, call); } }
static void state_open_session (GcrImporter *self, gboolean async) { GP11Session *session; GError *error = NULL; if (!self->pv->slot) { g_set_error (&self->pv->error, GCR_DATA_ERROR, GCR_ERROR_FAILURE, _("No location available to import to")); next_state (self, state_failure); } else { if (async) { gp11_slot_open_session_async (self->pv->slot, CKF_RW_SESSION, NULL, NULL, self->pv->cancel, on_open_session, self); } else { session = gp11_slot_open_session_full (self->pv->slot, CKF_RW_SESSION, NULL, NULL, self->pv->cancel, &error); complete_open_session (self, session, error); } } }