Пример #1
0
/* Returns id of renewed subscription or new id */
gint
pp_cups_renew_subscription_finish (PpCups       *cups,
                                   GAsyncResult *result)
{
  g_return_val_if_fail (g_task_is_valid (result, cups), FALSE);

  return g_task_propagate_int (G_TASK (result), NULL);
}
gssize
nul_sparql_query_util_load_int_finish (GAsyncResult  *const result,
                                       GError       **const error)
{

  g_autoptr(GTask) task = G_TASK (result);

  return g_task_propagate_int (task, error);

}
Пример #3
0
static GTlsInteractionResult
g_tls_console_interaction_ask_password_finish (GTlsInteraction    *interaction,
                                               GAsyncResult       *result,
                                               GError            **error)
{
  GTlsInteractionResult ret;

  g_return_val_if_fail (g_task_is_valid (result, interaction),
                        G_TLS_INTERACTION_FAILED);

  ret = g_task_propagate_int (G_TASK (result), error);
  if (ret == (GTlsInteractionResult)-1)
    return G_TLS_INTERACTION_FAILED;
  else
    return ret;
}
Пример #4
0
static void
save_snapshot_splice_cb (CamelDataWrapper *data_wrapper,
                         GAsyncResult *result,
                         GSimpleAsyncResult *simple)
{
	GError *local_error = NULL;

	g_return_if_fail (CAMEL_IS_DATA_WRAPPER (data_wrapper));
	g_return_if_fail (g_task_is_valid (result, data_wrapper));

	g_task_propagate_int (G_TASK (result), &local_error);

	if (local_error != NULL)
		g_simple_async_result_take_error (simple, local_error);

	g_simple_async_result_complete (simple);
	g_object_unref (simple);
}
static gssize gvir_input_stream_read_finish(GInputStream *stream,
                                            GAsyncResult *result,
                                            GError **error)
{
    GVirInputStream *input_stream = GVIR_INPUT_STREAM(stream);
    virStreamPtr handle;
    gssize count;

    g_return_val_if_fail(GVIR_IS_INPUT_STREAM(stream), -1);
    g_return_val_if_fail(g_task_is_valid(result, stream), -1);
    g_return_val_if_fail(error == NULL || *error == NULL, -1);
    g_object_get(input_stream->priv->stream, "handle", &handle, NULL);

    count = g_task_propagate_int(G_TASK(result), error);

    virStreamFree(handle);

    return count;
}
Пример #6
0
/**
 * g_tls_interaction_ask_password_finish:
 * @interaction: a #GTlsInteraction object
 * @result: the result passed to the callback
 * @error: an optional location to place an error on failure
 *
 * Complete an ask password user interaction request. This should be once
 * the g_tls_interaction_ask_password_async() completion callback is called.
 *
 * If %G_TLS_INTERACTION_HANDLED is returned, then the #GTlsPassword passed
 * to g_tls_interaction_ask_password() will have its password filled in.
 *
 * If the interaction is cancelled by the cancellation object, or by the
 * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
 * contains a %G_IO_ERROR_CANCELLED error code.
 *
 * Returns: The status of the ask password interaction.
 *
 * Since: 2.30
 */
GTlsInteractionResult
g_tls_interaction_ask_password_finish (GTlsInteraction    *interaction,
                                       GAsyncResult       *result,
                                       GError            **error)
{
  GTlsInteractionClass *klass;

  g_return_val_if_fail (G_IS_TLS_INTERACTION (interaction), G_TLS_INTERACTION_UNHANDLED);
  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), G_TLS_INTERACTION_UNHANDLED);

  klass = G_TLS_INTERACTION_GET_CLASS (interaction);
  if (klass->ask_password_finish)
    {
      g_return_val_if_fail (klass->ask_password_async != NULL, G_TLS_INTERACTION_UNHANDLED);

      return (klass->ask_password_finish) (interaction, result, error);
    }
  else
    {
      g_return_val_if_fail (g_async_result_is_tagged (result, g_tls_interaction_ask_password_async), G_TLS_INTERACTION_UNHANDLED);

      return g_task_propagate_int (G_TASK (result), error);
    }
}
Пример #7
0
static void abrt_p2_task_finish_gtask(GObject *source_object,
           GAsyncResult *result,
           gpointer user_data)
{
    AbrtP2Task *task = ABRT_P2_TASK(source_object);

    if (!g_task_is_valid(result, task))
    {
        error_msg("BUG:%s:%s: invalid GTask", __FILE__, __func__);
        return;
    }

    GError *error = NULL;
    const gint32 code = g_task_propagate_int(G_TASK(result), &error);

    if (code == ABRT_P2_TASK_CODE_STOP)
    {
        log_debug("Task stopped");

        abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_STOPPED);
    }
    else if (code >= ABRT_P2_TASK_CODE_DONE)
    {
        log_debug("Task done");

        task->pv->p2t_code = code - ABRT_P2_TASK_CODE_DONE;
        abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_DONE);
    }
    else if (abrt_p2_task_is_cancelled(task))
    {
        if (error != NULL)
        {
            log_debug("Task canceled with error: %s", error->message);

            g_error_free(error);
            error = NULL;
        }
        else
            log_debug("Task canceled");

        ABRT_P2_TASK_VIRTUAL_CANCEL(task, &error);
        abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_CANCELED);
    }
    else
    {
        GVariantDict response;
        g_variant_dict_init(&response, NULL);

        if (error != NULL)
        {
            log_debug("Task failed with error: %s", error->message);

            g_variant_dict_insert(&response,
                                  "Error.Message",
                                  "s",
                                  error->message);

            g_error_free(error);
        }
        else if (code == ABRT_P2_TASK_CODE_ERROR)
        {
            log_debug("Task failed without error message");

            g_variant_dict_insert(&response,
                                  "Error.Message",
                                  "s",
                                  "Task failed");
        }
        else
        {
            error_msg("BUG:%s:%s: unknown Task return code: %d",
                      __FILE__,
                      __func__,
                      code);

            g_variant_dict_insert(&response,
                                  "Error.Message",
                                  "s",
                                  "Internal error: Invalid Task return code");
        }

        abrt_p2_task_set_response(task, g_variant_dict_end(&response));
        abrt_p2_task_change_status(task, ABRT_P2_TASK_STATUS_FAILED);
    }

    g_object_unref(task->pv->p2t_cancellable);
    task->pv->p2t_cancellable = NULL;
}