Add g_simple_async_result_is_valid(). Implementation by Dan Winship.
authorRyan Lortie <desrt@desrt.ca>
Mon, 5 Jan 2009 06:57:16 +0000 (06:57 +0000)
committerRyan Lortie <ryanl@src.gnome.org>
Mon, 5 Jan 2009 06:57:16 +0000 (06:57 +0000)
2009-01-05  Ryan Lortie  <desrt@desrt.ca>

        * 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

docs/reference/gio/gio-sections.txt
gio/ChangeLog
gio/gio.symbols
gio/gsimpleasyncresult.c
gio/gsimpleasyncresult.h

index af76e423b51b94eabb04f28b7d603f106ba5fb9a..b2754bdc60273a41e9b662a81720bd270082eb1a 100644 (file)
@@ -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
index 499fb17b204208f6b92803d18513b34a59f23078..69bea0e55bb890ffd4d99ad7714b67c35395ed14 100644 (file)
@@ -1,3 +1,11 @@
+2009-01-05  Ryan Lortie  <desrt@desrt.ca>
+
+       * 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 <mclasen@redhat.com>
 
        * gdesktopappinfo.c:
index f074ee27889e2de86ad78eed21de9234ad475030..de2268be6b5df42a61e631c5231fb6a6ae7fd1c2 100644 (file)
@@ -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
index c3c1ae02f6687956a503d86333a85430cd34fdaa..7664fd3c6dd28ae7a4b74a70e0cdd797388f9a47 100644 (file)
@@ -692,6 +692,48 @@ g_simple_async_result_run_in_thread (GSimpleAsyncResult     *simple,
   g_io_scheduler_push_job (run_in_thread, data, NULL, io_priority, cancellable);
 }
 
+/**
+ * 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.
index 0d7ea7580b3d890615765f0800bbc9aa7f373cf1..7259a9731b0959ccda423229ca2ba87195d7ac9b 100644 (file)
@@ -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,