/** * gcr_certificate_request_complete_async: * @self: a certificate request * @cancellable: a cancellation object * @callback: called when the operation completes * @user_data: data to pass to the callback * * Asynchronously complete and sign a certificate request, so that it can * be encoded and sent to a certificate authority. * * This call will return immediately and complete later. */ void gcr_certificate_request_complete_async (GcrCertificateRequest *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *res; CompleteClosure *closure; g_return_if_fail (GCR_IS_CERTIFICATE_REQUEST (self)); g_return_if_fail (cancellable == NULL || G_CANCELLABLE (cancellable)); res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, gcr_certificate_request_complete_async); closure = g_new0 (CompleteClosure, 1); closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL; closure->session = gck_object_get_session (self->private_key); closure->request = g_object_ref (self); g_simple_async_result_set_op_res_gpointer (res, closure, complete_closure_free); _gcr_subject_public_key_load_async (self->private_key, cancellable, on_subject_public_key_loaded, g_object_ref (res)); g_object_unref (res); }
static void on_login_conn_closed (EvdConnection *conn, gpointer user_data) { GCancellable *cancellable = G_CANCELLABLE (user_data); g_cancellable_cancel (cancellable); g_object_unref (cancellable); }
static void g_cancellable_finalize (GObject *object) { GCancellable *cancellable = G_CANCELLABLE (object); g_cancellable_close_pipe (cancellable); G_OBJECT_CLASS (g_cancellable_parent_class)->finalize (object); }
static void g_cancellable_finalize (GObject *object) { GCancellable *cancellable = G_CANCELLABLE (object); if (cancellable->priv->wakeup) GLIB_PRIVATE_CALL (g_wakeup_free) (cancellable->priv->wakeup); G_OBJECT_CLASS (g_cancellable_parent_class)->finalize (object); }
/** * g_cancellable_get_current: * * Gets the top cancellable from the stack. * * Returns: (transfer none): a #GCancellable from the top of the stack, or %NULL * if the stack is empty. **/ GCancellable * g_cancellable_get_current (void) { GSList *l; l = g_private_get (¤t_cancellable); if (l == NULL) return NULL; return G_CANCELLABLE (l->data); }
static void grl_optical_media_source_cancel (GrlSource *source, guint operation_id) { GCancellable *cancellable; cancellable = G_CANCELLABLE (grl_operation_get_data (operation_id)); if (cancellable) { g_cancellable_cancel (cancellable); } }
static gboolean pbar_update (gpointer user_data) { GCancellable *cancellable = G_CANCELLABLE (user_data); gtk_progress_bar_pulse ((GtkProgressBar *) pbar); gtk_progress_bar_set_text ((GtkProgressBar *) pbar, txt); /* Return TRUE to reschedule the timeout. */ return !g_cancellable_is_cancelled (cancellable); }
static gint cover_thumbnailer_check_progress (gpointer user_data, gdouble dltotal, gdouble dlnow, gdouble ultotal, gdouble ulnow) { GCancellable *cancellable = G_CANCELLABLE (user_data); g_return_val_if_fail (G_IS_CANCELLABLE (cancellable), 1); /* return 1 to stop the download, 0 continue */ return g_cancellable_is_cancelled (cancellable); }
/** * gcr_certificate_request_complete: * @self: a certificate request * @cancellable: a cancellation object * @error: location to place an error on failure * * Complete and sign a certificate request, so that it can be encoded * and sent to a certificate authority. * * This call may block as it signs the request using the private key. * * Returns: whether certificate request was successfully completed or not */ gboolean gcr_certificate_request_complete (GcrCertificateRequest *self, GCancellable *cancellable, GError **error) { GNode *subject_public_key; const gulong *mechanisms; gsize n_mechanisms; GckMechanism mechanism = { 0, }; GQuark algorithm = 0; GBytes *tbs; GckSession *session; guchar *signature; gsize n_signature; gboolean ret; g_return_val_if_fail (GCR_IS_CERTIFICATE_REQUEST (self), FALSE); g_return_val_if_fail (cancellable == NULL || G_CANCELLABLE (cancellable), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); subject_public_key = _gcr_subject_public_key_load (self->private_key, cancellable, error); if (subject_public_key == NULL) return FALSE; ret = prepare_subject_public_key_and_mechanisms (self, subject_public_key, &algorithm, &mechanisms, &n_mechanisms, error); if (!ret) { egg_asn1x_destroy (subject_public_key); return FALSE; } /* Figure out which mechanism to use */ mechanism.type = _gcr_key_mechanisms_check (self->private_key, mechanisms, n_mechanisms, CKA_SIGN, cancellable, NULL); if (mechanism.type == GCK_INVALID) { egg_asn1x_destroy (subject_public_key); g_set_error (error, GCK_ERROR, CKR_KEY_TYPE_INCONSISTENT, _("The key cannot be used to sign the request")); return FALSE; } tbs = prepare_to_be_signed (self, &mechanism); session = gck_object_get_session (self->private_key); signature = gck_session_sign_full (session, self->private_key, &mechanism, g_bytes_get_data (tbs, NULL), g_bytes_get_size (tbs), &n_signature, cancellable, error); g_object_unref (session); g_bytes_unref (tbs); if (!signature) { egg_asn1x_destroy (subject_public_key); return FALSE; } encode_take_signature_into_request (self, algorithm, subject_public_key, signature, n_signature); egg_asn1x_destroy (subject_public_key); return TRUE; }