コード例 #1
0
ファイル: gdata-access-handler.c プロジェクト: GNOME/libgdata
static void
get_rules_thread (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable)
{
	GDataAccessHandler *access_handler = GDATA_ACCESS_HANDLER (source_object);
	GDataAccessHandlerIface *iface;
	g_autoptr(GError) error = NULL;
	g_autoptr(GDataFeed) feed = NULL;
	GetRulesAsyncData *data = task_data;

	/* Execute the query and return */
	iface = GDATA_ACCESS_HANDLER_GET_IFACE (access_handler);
	g_assert (iface->get_rules != NULL);

	feed = iface->get_rules (access_handler, data->service,
	                         cancellable, data->progress_callback,
	                         data->progress_user_data, &error);

	if (feed == NULL && error != NULL)
		g_task_return_error (task, g_steal_pointer (&error));
	else
		g_task_return_pointer (task, g_steal_pointer (&feed), g_object_unref);

	if (data->destroy_progress_user_data != NULL) {
		data->destroy_progress_user_data (data->progress_user_data);
	}
}
コード例 #2
0
ファイル: gdata-access-handler.c プロジェクト: GNOME/libgdata
/**
 * gdata_access_handler_get_rules:
 * @self: a #GDataAccessHandler
 * @service: a #GDataService
 * @cancellable: (allow-none): optional #GCancellable object, or %NULL
 * @progress_callback: (allow-none) (scope call) (closure progress_user_data): a #GDataQueryProgressCallback to call when a rule is loaded, or %NULL
 * @progress_user_data: (closure): data to pass to the @progress_callback function
 * @error: a #GError, or %NULL
 *
 * Retrieves a #GDataFeed containing all the access rules which apply to the given #GDataAccessHandler. Only the owner of a #GDataAccessHandler may
 * view its rule feed.
 *
 * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread.
 * If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
 *
 * A %GDATA_SERVICE_ERROR_PROTOCOL_ERROR will be returned if the server indicates there is a problem with the query.
 *
 * For each rule in the response feed, @progress_callback will be called in the main thread. If there was an error parsing the XML response,
 * a #GDataParserError will be returned.
 *
 * Return value: (transfer full): a #GDataFeed of access control rules, or %NULL; unref with g_object_unref()
 *
 * Since: 0.3.0
 */
GDataFeed *
gdata_access_handler_get_rules (GDataAccessHandler *self, GDataService *service, GCancellable *cancellable,
                                GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GError **error)
{
	GDataAccessHandlerIface *iface;

	g_return_val_if_fail (GDATA_IS_ACCESS_HANDLER (self), NULL);
	g_return_val_if_fail (GDATA_IS_SERVICE (service), NULL);
	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);

	iface = GDATA_ACCESS_HANDLER_GET_IFACE (self);
	g_assert (iface->get_rules != NULL);

	return iface->get_rules (self, service, cancellable, progress_callback,
	                         progress_user_data, error);
}
コード例 #3
0
static void
get_rules_thread (GSimpleAsyncResult *result, GDataAccessHandler *access_handler, GCancellable *cancellable)
{
	GDataAccessHandlerIface *iface;
	GError *error = NULL;
	GetRulesAsyncData *data = g_simple_async_result_get_op_res_gpointer (result);

	/* Execute the query and return */
	iface = GDATA_ACCESS_HANDLER_GET_IFACE (access_handler);
	g_assert (iface->get_rules != NULL);

	data->feed = iface->get_rules (access_handler, data->service,
	                               cancellable, data->progress_callback,
	                               data->progress_user_data, &error);

	if (data->feed == NULL && error != NULL) {
		g_simple_async_result_set_from_error (result, error);
		g_error_free (error);
	}

	if (data->destroy_progress_user_data != NULL) {
		data->destroy_progress_user_data (data->progress_user_data);
	}
}