8409319768951a4396a4e6993bf00707c99a3fff
[platform/upstream/glib.git] / gio / gasyncresult.c
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #include <config.h>
24 #include "gasyncresult.h"
25 #include "glibintl.h"
26
27 static void g_async_result_base_init (gpointer g_class);
28 static void g_async_result_class_init (gpointer g_class,
29                                        gpointer class_data);
30
31 GType
32 g_async_result_get_type (void)
33 {
34   static GType async_result_type = 0;
35
36   if (! async_result_type)
37     {
38       static const GTypeInfo async_result_info =
39       {
40         sizeof (GAsyncResultIface), /* class_size */
41         g_async_result_base_init,   /* base_init */
42         NULL,                       /* base_finalize */
43         g_async_result_class_init,
44         NULL,           /* class_finalize */
45         NULL,           /* class_data */
46         0,
47         0,              /* n_preallocs */
48         NULL
49       };
50
51       async_result_type =
52         g_type_register_static (G_TYPE_INTERFACE, I_("GAsyncResult"),
53                                 &async_result_info, 0);
54
55       g_type_interface_add_prerequisite (async_result_type, G_TYPE_OBJECT);
56     }
57
58   return async_result_type;
59 }
60
61 static void
62 g_async_result_class_init (gpointer g_class,
63                            gpointer class_data)
64 {
65 }
66
67 static void
68 g_async_result_base_init (gpointer g_class)
69 {
70 }
71
72 /**
73  * g_async_result_get_user_data:
74  * @res: a #GAsyncResult.
75  * 
76  * Returns: the user data for the given @res, or
77  * %NULL on failure. 
78  **/
79 gpointer
80 g_async_result_get_user_data (GAsyncResult *res)
81 {
82   GAsyncResultIface *iface;
83
84   g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
85
86   iface = G_ASYNC_RESULT_GET_IFACE (res);
87
88   return (* iface->get_user_data) (res);
89 }
90
91 /**
92  * g_async_result_get_source_object:
93  * @res: a #GAsyncResult.
94  * 
95  * Returns: the source object for the @res.
96  **/
97 GObject *
98 g_async_result_get_source_object (GAsyncResult *res)
99 {
100   GAsyncResultIface *iface;
101
102   g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
103
104   iface = G_ASYNC_RESULT_GET_IFACE (res);
105
106   return (* iface->get_source_object) (res);
107 }