Ejemplo n.º 1
0
static void
catch_resource_group_fetch_cb (GObject      *object,
                               GAsyncResult *result,
                               gpointer      user_data)
{
   CatchResourceGroupPrivate *priv;
   CatchResourceGroup *group;
   GSimpleAsyncResult *simple = user_data;
   gboolean ret = FALSE;
   GError *error = NULL;

   ENTRY;

   g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple));
   group = CATCH_RESOURCE_GROUP(g_async_result_get_source_object(user_data));
   g_return_if_fail(CATCH_IS_RESOURCE_GROUP(group));

   priv = group->priv;

   if (priv->group) {
      ret = gom_resource_group_fetch_finish(GOM_RESOURCE_GROUP(object), result, &error);
   } else {
      g_assert_not_reached();
   }

   if (!ret) {
      g_simple_async_result_take_error(simple, error);
   }

   g_simple_async_result_set_op_res_gboolean(simple, ret);
   g_simple_async_result_complete_in_idle(simple);
   g_object_unref(simple);

   EXIT;
}
Ejemplo n.º 2
0
/**
 * news_parser_parse_finish:
 * @parser: (in): A #NewsParser.
 *
 * Completes an asynchronous request to parse a #NewsFeed from a
 * #GInputStream. If the feed was successfully parsed, then a
 * #NewsFeed will be returned; othrewise %NULL and @error is set.
 *
 * Returns: None.
 */
NewsFeed *
news_parser_parse_finish (NewsParser    *parser,
                          GAsyncResult  *result,
                          GError       **error)
{
   NewsParserPrivate *priv;
   NewsFeed *feed = NULL;

   ENTRY;

   g_return_val_if_fail(NEWS_IS_PARSER(parser), NULL);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), NULL);

   priv = parser->priv;

   if (!priv->feed) {
      g_simple_async_result_propagate_error(priv->simple, error);
   } else {
      feed = g_object_ref(priv->feed);
   }

   g_clear_object(&priv->simple);

   RETURN(feed);
}
Ejemplo n.º 3
0
static void
mongo_cursor_foreach_query_cb (GObject      *object,
                               GAsyncResult *result,
                               gpointer      user_data)
{
   GSimpleAsyncResult *simple = user_data;
   MongoConnection *connection = (MongoConnection *)object;
   MongoMessageReply *reply;
   GError *error = NULL;

   ENTRY;

   g_assert(MONGO_IS_CONNECTION(connection));
   g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple));

   if (!(reply = mongo_connection_query_finish(connection, result, &error))) {
      g_simple_async_result_take_error(simple, error);
      mongo_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      EXIT;
   }

   mongo_cursor_foreach_dispatch(connection, reply, simple);
   g_object_unref(reply);

   EXIT;
}
Ejemplo n.º 4
0
/* Return a ref on the GdkPixbuf */
GdkPixbuf *
empathy_pixbuf_avatar_from_individual_scaled_finish (
    FolksIndividual *individual,
    GAsyncResult *result,
    GError **error)
{
  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
  gboolean result_valid;
  GdkPixbuf *pixbuf;

  g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL);
  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple), NULL);

  if (g_simple_async_result_propagate_error (simple, error))
    return NULL;

  result_valid = g_simple_async_result_is_valid (result,
      G_OBJECT (individual),
      empathy_pixbuf_avatar_from_individual_scaled_async);

  g_return_val_if_fail (result_valid, NULL);

  pixbuf = g_simple_async_result_get_op_res_gpointer (simple);
  return pixbuf != NULL ? g_object_ref (pixbuf) : NULL;
}
Ejemplo n.º 5
0
static void
gom_repository_find_one_fetch_cb (GObject      *object,
                                  GAsyncResult *result,
                                  gpointer      user_data)
{
   GSimpleAsyncResult *simple = user_data;
   GomResourceGroup *group = (GomResourceGroup *)object;
   GomResource *resource;
   GError *error = NULL;

   g_return_if_fail(GOM_IS_RESOURCE_GROUP(group));
   g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple));

   if (!gom_resource_group_fetch_finish(group, result, &error)) {
      g_simple_async_result_take_error(simple, error);
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      return;
   }

   resource = gom_resource_group_get_index(group, 0);
   g_simple_async_result_set_op_res_gpointer(simple,
                                             g_object_ref(resource),
                                             g_object_unref);
   g_simple_async_result_complete_in_idle(simple);
   g_object_unref(simple);
}
Ejemplo n.º 6
0
static void
gom_resource_save_cb (GomAdapter *adapter,
                      gpointer    user_data)
{
   GSimpleAsyncResult *simple = user_data;
   GomResource *resource;
   gboolean ret;
   GError *error = NULL;
   GAsyncQueue *queue;

   g_return_if_fail(GOM_IS_ADAPTER(adapter));
   g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple));

   resource = GOM_RESOURCE(g_async_result_get_source_object(G_ASYNC_RESULT(simple)));
   g_assert(GOM_IS_RESOURCE(resource));

   queue = g_object_get_data(G_OBJECT(simple), "queue");

   if (!(ret = gom_resource_do_save(resource, adapter, &error))) {
      g_simple_async_result_take_error(simple, error);
   }

   g_simple_async_result_set_op_res_gboolean(simple, ret);
   if (!queue)
      g_simple_async_result_complete_in_idle(simple);
   else
      g_async_queue_push(queue, GINT_TO_POINTER(TRUE));
   g_object_unref(resource);
}
Ejemplo n.º 7
0
static void
news_sync_task_save_cb (GObject      *object,
                        GAsyncResult *result,
                        gpointer      user_data)
{
   NewsSyncTaskPrivate *priv;
   GSimpleAsyncResult *simple = user_data;
   NewsSyncTask *task;
   GomResource *resource = (GomResource *)object;
   GError *error = NULL;

   g_assert(NEWS_IS_FEED(resource));
   g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple));
   task = (NewsSyncTask *)g_async_result_get_source_object(G_ASYNC_RESULT(simple));
   g_assert(NEWS_IS_SYNC_TASK(task));

   priv = task->priv;

   if (!gom_resource_save_finish(resource, result, &error)) {
      g_simple_async_result_take_error(simple, error);
      gom_adapter_sqlite_rollback(GOM_ADAPTER_SQLITE(priv->adapter));
   } else if (!gom_adapter_sqlite_commit(GOM_ADAPTER_SQLITE(priv->adapter),
                                         &error)) {
      g_simple_async_result_take_error(simple, error);
      gom_adapter_sqlite_rollback(GOM_ADAPTER_SQLITE(priv->adapter));
   }

   g_simple_async_result_complete_in_idle(simple);
   g_object_unref(simple);
}
Ejemplo n.º 8
0
static void
gom_repository_find_one_cb (GObject      *object,
                            GAsyncResult *result,
                            gpointer      user_data)
{
   GSimpleAsyncResult *simple = user_data;
   GomResourceGroup *group;
   GomRepository *repository = (GomRepository *)object;
   GError *error = NULL;

   g_return_if_fail(GOM_IS_REPOSITORY(repository));
   g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple));

   if (!(group = gom_repository_find_finish(repository, result, &error))) {
      g_simple_async_result_take_error(simple, error);
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      return;
   }

   if (!gom_resource_group_get_count(group)) {
      g_simple_async_result_set_error(simple, GOM_ERROR,
                                      GOM_ERROR_REPOSITORY_EMPTY_RESULT,
                                      _("No resources were found."));
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      g_object_unref(group);
      return;
   }

   gom_resource_group_fetch_async(group, 0, 1,
                                  gom_repository_find_one_fetch_cb,
                                  simple);
   g_object_unref(group);
}
Ejemplo n.º 9
0
static void
catch_space_get_objects_cb (GObject      *object,
                             GAsyncResult *result,
                             gpointer      user_data)
{
   GomResource *resource = (GomResource *)object;
   GSimpleAsyncResult *simple = user_data;
   GomResourceGroup *group;
   GError *error = NULL;

   ENTRY;

   g_return_if_fail(GOM_IS_RESOURCE(resource));
   g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple));

   if (!(group = gom_resource_fetch_m2m_finish(resource, result, &error))) {
      g_simple_async_result_take_error(simple, error);
   } else {
      g_simple_async_result_set_op_res_gpointer(simple, group, g_object_unref);
   }

   g_simple_async_result_complete_in_idle(simple);
   g_object_unref(simple);

   EXIT;
}
GSocketConnection  *
_client_create_tube_finish (GAsyncResult *result,
    TpChannel **channel,
    GError **error)
{
  GSimpleAsyncResult *simple;
  CreateTubeData *data;

  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);

  simple = G_SIMPLE_ASYNC_RESULT (result);

  if (g_simple_async_result_propagate_error (simple, error))
    return NULL;

  g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL,
      _client_create_tube_finish), NULL);

  data = g_simple_async_result_get_op_res_gpointer (
      G_SIMPLE_ASYNC_RESULT (result));

  if (channel != NULL)
    *channel = g_object_ref (data->channel);

  return g_object_ref (data->connection);
}
Ejemplo n.º 11
0
gboolean
gom_repository_automatic_migrate_finish (GomRepository  *repository,
                                         GAsyncResult   *result,
                                         GError        **error)
{
   g_return_val_if_fail(GOM_IS_REPOSITORY(repository), FALSE);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), FALSE);

   g_object_set_data(G_OBJECT(repository), "object-types", NULL);
   return gom_repository_migrate_finish(repository, result, error);
}
Ejemplo n.º 12
0
static gssize
soup_input_stream_read_finish (GInputStream  *stream,
			       GAsyncResult  *result,
			       GError       **error)
{
  GSimpleAsyncResult *simple;

  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), -1);
  simple = G_SIMPLE_ASYNC_RESULT (result);
  g_return_val_if_fail (g_simple_async_result_get_source_tag (simple) == soup_input_stream_read_async, -1);

  return g_simple_async_result_get_op_res_gssize (simple);
}
Ejemplo n.º 13
0
/**
 * pk_package_sack_merge_generic_finish:
 * @sack: a valid #PkPackageSack instance
 * @res: the #GAsyncResult
 * @error: A #GError or %NULL
 *
 * Gets the result from the asynchronous function.
 *
 * Return value: %TRUE for success
 *
 * Since: 0.5.2
 **/
gboolean
pk_package_sack_merge_generic_finish (PkPackageSack *sack, GAsyncResult *res, GError **error)
{
	GSimpleAsyncResult *simple;

	g_return_val_if_fail (PK_IS_PACKAGE_SACK (sack), FALSE);
	g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (res), FALSE);
	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

	simple = G_SIMPLE_ASYNC_RESULT (res);

	if (g_simple_async_result_propagate_error (simple, error))
		return FALSE;

	return g_simple_async_result_get_op_res_gboolean (simple);
}
Ejemplo n.º 14
0
static void
news_sync_task_fetch_cb (GObject      *object,
                         GAsyncResult *result,
                         gpointer      user_data)
{
   NewsSyncTaskPrivate *priv;
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)user_data;
   GInputStream *stream;
   NewsSyncTask *task;
   NewsSource *source = (NewsSource *)object;
   NewsParser *parser;
   GError *error = NULL;

   g_assert(NEWS_IS_SOURCE(source));
   g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple));
   task = (NewsSyncTask *)g_async_result_get_source_object(G_ASYNC_RESULT(simple));
   g_assert(NEWS_IS_SYNC_TASK(task));

   priv = task->priv;

   priv->fraction = 0.333;
   g_object_notify_by_pspec(G_OBJECT(task), gParamSpecs[PROP_FRACTION]);

   if (!(stream = news_source_fetch_finish(source, result, &error))) {
      g_simple_async_result_take_error(simple, error);
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      return;
   }

   if (g_cancellable_is_cancelled(priv->cancellable)) {
      g_simple_async_result_set_error(simple, NEWS_SYNC_TASK_ERROR,
                                      NEWS_SYNC_TASK_ERROR_CANCELLED,
                                      _("The task was cancelled."));
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      return;
   }

   parser = g_object_new(NEWS_TYPE_PARSER,
                         "adapter", priv->adapter,
                         "source", priv->source,
                         NULL);
   news_parser_parse_async(parser, stream, priv->cancellable,
                           news_sync_task_parse_cb, simple);
   g_object_unref(parser);
}
Ejemplo n.º 15
0
/**
 * gom_resource_fetch_m2m_finish:
 * @resource: (in): A #GomResource.
 * @result: (in): A #GAsyncResult.
 * @error: (out): A location for a #GError, or %NULL.
 *
 * Completes the asynchronous request to fetch a group of resources that
 * are related to the resource through a many-to-many table.
 *
 * Returns: (transfer full): A #GomResourceGroup.
 */
GomResourceGroup *
gom_resource_fetch_m2m_finish (GomResource   *resource,
                               GAsyncResult  *result,
                               GError       **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   GomResourceGroup *group;

   g_return_val_if_fail(GOM_IS_RESOURCE(resource), NULL);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), NULL);

   if (!(group = g_simple_async_result_get_op_res_gpointer(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   return group ? g_object_ref(group) : NULL;
}
Ejemplo n.º 16
0
static GTlsCertificateFlags
g_tls_database_real_verify_chain_finish (GTlsDatabase          *self,
                                         GAsyncResult          *result,
                                         GError               **error)
{
  AsyncVerifyChain *args;

  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), G_TLS_CERTIFICATE_GENERIC_ERROR);
  g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self),
                        g_tls_database_real_verify_chain_async), FALSE);

  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
    return G_TLS_CERTIFICATE_GENERIC_ERROR;

  args = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result));
  return args->verify_result;
}
Ejemplo n.º 17
0
/**
 * gom_repository_find_one_finish:
 * @repository: (in): A #GomRepository.
 * @result: (in): A #GAsyncResult.
 * @error: (out): A location for a #GError, or %NULL.
 *
 * Completes an asynchronous request to find a single resource in the
 * repository. See gom_repository_find_one_async() for more info.
 *
 * Returns: (transfer full): A #GomResource if successful, otherwise %NULL.
 */
GomResource *
gom_repository_find_one_finish (GomRepository  *repository,
                                GAsyncResult   *result,
                                GError        **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   GomResource *ret;

   g_return_val_if_fail(GOM_IS_REPOSITORY(repository), NULL);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple), NULL);

   if (!(ret = g_simple_async_result_get_op_res_gpointer(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   return ret ? g_object_ref(ret) : NULL;
}
Ejemplo n.º 18
0
/**
 * soup_input_stream_send_finish:
 * @stream: a #SoupInputStream
 * @result: a #GAsyncResult.
 * @error: a #GError location to store the error occuring, or %NULL to 
 * ignore.
 *
 * Finishes a soup_input_stream_send_async() operation.
 *
 * Return value: %TRUE if the message was sent successfully and
 * received a successful status code, %FALSE if not.
 **/
gboolean
soup_input_stream_send_finish (GInputStream  *stream,
			       GAsyncResult  *result,
			       GError       **error)
{
  GSimpleAsyncResult *simple;

  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
  simple = G_SIMPLE_ASYNC_RESULT (result);

  g_return_val_if_fail (g_simple_async_result_get_source_tag (simple) == soup_input_stream_send_async, FALSE);

  if (g_simple_async_result_propagate_error (simple, error))
    return FALSE;

  return g_simple_async_result_get_op_res_gboolean (simple);
}
Ejemplo n.º 19
0
static GFile *
_g_find_file_insensitive_finish (GFile        *parent,
                                 GAsyncResult *result,
                                 GError      **error)
{
  GSimpleAsyncResult *simple;
  GFile *file;

  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);

  simple = G_SIMPLE_ASYNC_RESULT (result);

  if (g_simple_async_result_propagate_error (simple, error))
    return NULL;

  file = G_FILE (g_simple_async_result_get_op_res_gpointer (simple));
  return g_object_ref (file);
}
Ejemplo n.º 20
0
gboolean
gom_repository_migrate_finish (GomRepository  *repository,
                               GAsyncResult   *result,
                               GError        **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   gboolean ret;

   g_return_val_if_fail(GOM_IS_REPOSITORY(repository), FALSE);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(result), FALSE);

   if (!(ret = g_simple_async_result_get_op_res_gboolean(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }
   g_object_unref(simple);

   return ret;
}
Ejemplo n.º 21
0
gboolean
cd_sensor_unlock_finish (CdSensor *sensor, GAsyncResult *res, GError **error)
{
	GSimpleAsyncResult *simple;
	gboolean ret = TRUE;

	g_return_val_if_fail (CD_IS_SENSOR (sensor), FALSE);
	g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (res), FALSE);
	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

	simple = G_SIMPLE_ASYNC_RESULT (res);
	if (g_simple_async_result_propagate_error (simple, error)) {
		ret = FALSE;
		goto out;
	}
out:
	return ret;
}
static GbProject *
gb_project_format_real_open_finish (GbProjectFormat  *format,
                                    GAsyncResult     *result,
                                    GError          **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   GbProject *ret = NULL;

   ENTRY;

   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple), NULL);

   if (!(ret = g_simple_async_result_get_op_res_gpointer(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   RETURN(ret ? g_object_ref(ret) : NULL);
}
Ejemplo n.º 23
0
/**
 * g_async_result_legacy_propagate_error:
 * @res: a #GAsyncResult
 * @error: (out): a location to propagate the error to.
 *
 * If @res is a #GSimpleAsyncResult, this is equivalent to
 * g_simple_async_result_propagate_error(). Otherwise it returns
 * %FALSE.
 *
 * This can be used for legacy error handling in async
 * <literal>_finish ()</literal> wrapper functions that traditionally
 * handled #GSimpleAsyncResult error returns themselves rather than
 * calling into the virtual method. This should not be used in new
 * code; #GAsyncResult errors that are set by virtual methods should
 * also be extracted by virtual methods, to enable subclasses to chain
 * up correctly.
 *
 * Returns: %TRUE if @error is has been filled in with an error from
 *   @res, %FALSE if not.
 *
 * Since: 2.34
 **/
gboolean
g_async_result_legacy_propagate_error (GAsyncResult  *res,
                                       GError       **error)
{
    /* This doesn't use a vmethod, because it's only for code that used
     * to use GSimpleAsyncResult. (But it's a GAsyncResult method so
     * that callers don't need to worry about GSimpleAsyncResult
     * deprecation warnings in the future.)
     */

    if (G_IS_SIMPLE_ASYNC_RESULT (res))
    {
        return g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res),
                error);
    }
    else
        return FALSE;
}
Ejemplo n.º 24
0
gboolean
gom_resource_delete_finish (GomResource   *resource,
                            GAsyncResult  *result,
                            GError       **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   gboolean ret;

   g_return_val_if_fail(GOM_IS_RESOURCE(resource), FALSE);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple), FALSE);

   if (!(ret = g_simple_async_result_get_op_res_gboolean(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }
   g_object_unref(simple);

   return ret;
}
Ejemplo n.º 25
0
/**
 * catch_space_get_objects_finish:
 * @space: (in): A #CatchSpace.
 * @result: (in): A #GAsyncResult.
 * @error: (out): A location for a #GError, or %NULL.
 *
 * Completes an asynchronous request to fetch a group of objects.
 *
 * Returns: (transfer full): A #GomResourceGroup.
 */
GomResourceGroup *
catch_space_get_objects_finish (CatchSpace   *space,
                                 GAsyncResult  *result,
                                 GError       **error)
{
   GomResourceGroup *group;
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;

   ENTRY;

   g_return_val_if_fail(CATCH_IS_SPACE(space), NULL);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple), NULL);

   if (!(group = g_simple_async_result_get_op_res_gpointer(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   RETURN(group ? g_object_ref(group) : NULL);
}
/**
 * tp_yts_status_advertise_status_finish:
 * @self: The status proxy
 * @result: The result object passed to the callback
 * @error: If an error occurred, this will be set
 *
 * Complete an asynchronous operation advertise Ytstenut service status.
 *
 * Returns: %TRUE if the operation succeeded.
 */
gboolean
tp_yts_status_advertise_status_finish (TpYtsStatus *self,
    GAsyncResult *result,
    GError **error)
{
  GSimpleAsyncResult *res;

  g_return_val_if_fail (TP_IS_YTS_STATUS (self), FALSE);
  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);

  res = G_SIMPLE_ASYNC_RESULT (result);
  g_return_val_if_fail (g_simple_async_result_is_valid (result,
          G_OBJECT (self), tp_yts_status_advertise_status_async), FALSE);

  if (g_simple_async_result_propagate_error (res, error))
    return FALSE;

  return TRUE;
}
Ejemplo n.º 27
0
/**
 * catch_resource_group_fetch_finish:
 * @group: (in): A #CatchResourceGroup.
 * @result: (in): A #GAsyncResult.
 * @error: (out): A locationf or a #GError, or %NULL.
 *
 * Completes an asynchronous request to catch_resource_group_fetch_async().
 * %TRUE is returned if the resources were loaded, otherwise %FALSE and
 * @error is set.
 *
 * Returns: %TRUE if successful; otherwise %FALSE and @error is set.
 */
gboolean
catch_resource_group_fetch_finish (CatchResourceGroup  *group,
                                   GAsyncResult        *result,
                                   GError             **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   gboolean ret;

   ENTRY;

   g_return_val_if_fail(CATCH_IS_RESOURCE_GROUP(group), FALSE);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple), FALSE);

   if (!(ret = g_simple_async_result_get_op_res_gboolean(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   RETURN(ret);
}
Ejemplo n.º 28
0
static void
news_sync_task_parse_cb (GObject      *object,
                         GAsyncResult *result,
                         gpointer      user_data)
{
   NewsSyncTaskPrivate *priv;
   GSimpleAsyncResult *simple = user_data;
   NewsSyncTask *task;
   NewsParser *parser = (NewsParser *)object;
   GError *error = NULL;

   g_assert(NEWS_IS_PARSER(parser));
   g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple));
   task = (NewsSyncTask *)g_async_result_get_source_object(G_ASYNC_RESULT(simple));
   g_assert(NEWS_IS_SYNC_TASK(task));

   priv = task->priv;

   priv->fraction = 0.666;
   g_object_notify_by_pspec(G_OBJECT(task), gParamSpecs[PROP_FRACTION]);

   if (!(priv->feed = news_parser_parse_finish(parser, result, &error))) {
      g_simple_async_result_take_error(simple, error);
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      return;
   }

   if (g_cancellable_is_cancelled(priv->cancellable)) {
      g_simple_async_result_set_error(simple, NEWS_SYNC_TASK_ERROR,
                                      NEWS_SYNC_TASK_ERROR_CANCELLED,
                                      _("The task was cancelled."));
      g_simple_async_result_complete_in_idle(simple);
      g_object_unref(simple);
      return;
   }

   news_sync_task_prepare_save(task);

   gom_adapter_sqlite_begin(GOM_ADAPTER_SQLITE(priv->adapter));
   gom_resource_save_async(GOM_RESOURCE(priv->feed), priv->cancellable,
                           news_sync_task_save_cb, simple);
}
Ejemplo n.º 29
0
gboolean
push_gcm_client_deliver_finish (PushGcmClient  *client,
                                GAsyncResult   *result,
                                GError        **error)
{
   GSimpleAsyncResult *simple = (GSimpleAsyncResult *)result;
   gboolean ret;

   ENTRY;

   g_return_val_if_fail(PUSH_IS_GCM_CLIENT(client), FALSE);
   g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple), FALSE);

   if (!(ret = g_simple_async_result_get_op_res_gboolean(simple))) {
      g_simple_async_result_propagate_error(simple, error);
   }

   RETURN(ret);
}
/**
 * tp_yts_status_ensure_finish:
 * @account: The Ytstenut enabled account
 * @result: The result object passed to the callback
 * @error: If an error occurred, this will be set
 *
 * Complete an asynchronous operation to create a #TpYtsStatus object.
 *
 * Returns: A new #TpYtsStatus proxy, which you can use to access
 * the Ytstenut Status service. If the operation failed, %NULL will be returned.
 */
TpYtsStatus *
tp_yts_status_ensure_finish (TpAccount *account,
    GAsyncResult *result,
    GError **error)
{
  GSimpleAsyncResult *res;

  g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
  g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);

  res = G_SIMPLE_ASYNC_RESULT (result);
  g_return_val_if_fail (g_simple_async_result_is_valid (result,
          G_OBJECT (account), tp_yts_status_ensure_async), NULL);

  if (g_simple_async_result_propagate_error (res, error))
    return NULL;

  return g_object_ref (g_simple_async_result_get_op_res_gpointer (res));
}