From: Ryan Lortie Date: Mon, 5 Jan 2009 06:57:16 +0000 (+0000) Subject: Add g_simple_async_result_is_valid(). Implementation by Dan Winship. X-Git-Tag: GLIB_2_19_4~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=876f03f8074e4cb4d92b3a74bba465a0e07f2633;p=platform%2Fupstream%2Fglib.git Add g_simple_async_result_is_valid(). Implementation by Dan Winship. 2009-01-05 Ryan Lortie * gio.symbols: * ../docs/reference/gio/gio-sections.txt: * gsimpleasyncresult.h: * gsimpleasyncresult.c: Add g_simple_async_result_is_valid(). Implementation by Dan Winship. Closes #566170. svn path=/trunk/; revision=7766 --- diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index af76e42..b2754bd 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -1002,6 +1002,7 @@ g_simple_async_result_get_op_res_gssize g_simple_async_result_set_op_res_gboolean g_simple_async_result_get_op_res_gboolean g_simple_async_result_get_source_tag +g_simple_async_result_is_valid g_simple_async_result_set_handle_cancellation g_simple_async_result_complete g_simple_async_result_complete_in_idle diff --git a/gio/ChangeLog b/gio/ChangeLog index 499fb17..69bea0e 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,11 @@ +2009-01-05 Ryan Lortie + + * gio.symbols: + * ../docs/reference/gio/gio-sections.txt: + * gsimpleasyncresult.h: + * gsimpleasyncresult.c: Add g_simple_async_result_is_valid(). + Implementation by Dan Winship. Closes #566170. + 2008-12-31 Matthias Clasen * gdesktopappinfo.c: diff --git a/gio/gio.symbols b/gio/gio.symbols index f074ee2..de2268b 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -634,6 +634,7 @@ g_simple_async_result_set_from_error g_simple_async_result_propagate_error g_simple_async_result_set_error g_simple_async_result_set_error_va +g_simple_async_result_is_valid g_simple_async_report_error_in_idle g_simple_async_report_gerror_in_idle #endif diff --git a/gio/gsimpleasyncresult.c b/gio/gsimpleasyncresult.c index c3c1ae0..7664fd3 100644 --- a/gio/gsimpleasyncresult.c +++ b/gio/gsimpleasyncresult.c @@ -693,6 +693,48 @@ g_simple_async_result_run_in_thread (GSimpleAsyncResult *simple, } /** + * g_simple_async_result_is_valid: + * @result: the #GAsyncResult passed to the _finish function. + * @source: the #GObject passed to the _finish function. + * @source_tag: the asynchronous function. + * + * Ensures that the data passed to the _finish function of an async + * operation is consistent. Three checks are performed. + * + * First, @result is checked to ensure that it is really a + * #GSimpleAsyncResult. Second, @source is checked to ensure that it + * matches the source object of @result. Third, @source_tag is + * checked to ensure that it is equal to the source_tag argument given + * to g_simple_async_result_new() (which, by convention, is a pointer + * to the _async function corresponding to the _finish function from + * which this function is called). + * + * Returns: #TRUE if all checks passed or #FALSE if any failed. + **/ +gboolean +g_simple_async_result_is_valid (GAsyncResult *result, + GObject *source, + gpointer source_tag) +{ + GSimpleAsyncResult *simple; + GObject *cmp_source; + + if (!G_IS_SIMPLE_ASYNC_RESULT (result)) + return FALSE; + simple = (GSimpleAsyncResult *)result; + + cmp_source = g_async_result_get_source_object (result); + if (cmp_source != source) + { + g_object_unref (cmp_source); + return FALSE; + } + g_object_unref (cmp_source); + + return source_tag == g_simple_async_result_get_source_tag (simple); +} + +/** * g_simple_async_report_error_in_idle: * @object: a #GObject. * @callback: a #GAsyncReadyCallback. diff --git a/gio/gsimpleasyncresult.h b/gio/gsimpleasyncresult.h index 0d7ea75..7259a97 100644 --- a/gio/gsimpleasyncresult.h +++ b/gio/gsimpleasyncresult.h @@ -102,6 +102,9 @@ void g_simple_async_result_set_error_va (GSimpleAsyncResult gint code, const char *format, va_list args); +gboolean g_simple_async_result_is_valid (GAsyncResult *result, + GObject *source, + gpointer source_tag); void g_simple_async_report_error_in_idle (GObject *object, GAsyncReadyCallback callback,