Use g_set_error_literal where appropriate. Patch from bug #535947.
[platform/upstream/glib.git] / gio / gsimpleasyncresult.h
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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #ifndef __G_SIMPLE_ASYNC_RESULT_H__
28 #define __G_SIMPLE_ASYNC_RESULT_H__
29
30 #include <gio/gasyncresult.h>
31 #include <gio/gcancellable.h>
32
33 G_BEGIN_DECLS
34
35 #define G_TYPE_SIMPLE_ASYNC_RESULT         (g_simple_async_result_get_type ())
36 #define G_SIMPLE_ASYNC_RESULT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResult))
37 #define G_SIMPLE_ASYNC_RESULT_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass))
38 #define G_IS_SIMPLE_ASYNC_RESULT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SIMPLE_ASYNC_RESULT))
39 #define G_IS_SIMPLE_ASYNC_RESULT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SIMPLE_ASYNC_RESULT))
40 #define G_SIMPLE_ASYNC_RESULT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass))
41
42 /**
43  * GSimpleAsyncResult:
44  * 
45  * A simple implementation of #GAsyncResult.
46  **/
47 typedef struct _GSimpleAsyncResult        GSimpleAsyncResult;
48 typedef struct _GSimpleAsyncResultClass   GSimpleAsyncResultClass;
49
50 /**
51  * GSimpleAsyncThreadFunc:
52  * @res: a #GSimpleAsyncResult. 
53  * @object: a #GObject.
54  * @cancellable: optional #GCancellable object, %NULL to ignore.
55  * 
56  * Simple thread function that runs an asynchronous operation and 
57  * checks for cancellation.
58  **/
59 typedef void (*GSimpleAsyncThreadFunc) (GSimpleAsyncResult *res,
60                                         GObject *object,
61                                         GCancellable *cancellable);
62
63
64 GType g_simple_async_result_get_type (void) G_GNUC_CONST;
65   
66 GSimpleAsyncResult *g_simple_async_result_new              (GObject                 *source_object,
67                                                             GAsyncReadyCallback      callback,
68                                                             gpointer                 user_data,
69                                                             gpointer                 source_tag);
70 GSimpleAsyncResult *g_simple_async_result_new_error        (GObject                 *source_object,
71                                                             GAsyncReadyCallback      callback,
72                                                             gpointer                 user_data,
73                                                             GQuark                   domain,
74                                                             gint                     code,
75                                                             const char              *format,
76                                                             ...) G_GNUC_PRINTF (6, 7);
77 GSimpleAsyncResult *g_simple_async_result_new_from_error   (GObject                 *source_object,
78                                                             GAsyncReadyCallback      callback,
79                                                             gpointer                 user_data,
80                                                             GError                  *error);
81
82 void                g_simple_async_result_set_op_res_gpointer (GSimpleAsyncResult      *simple,
83                                                                gpointer                 op_res,
84                                                                GDestroyNotify           destroy_op_res);
85 gpointer            g_simple_async_result_get_op_res_gpointer (GSimpleAsyncResult      *simple);
86
87 void                g_simple_async_result_set_op_res_gssize   (GSimpleAsyncResult      *simple,
88                                                                gssize                   op_res);
89 gssize              g_simple_async_result_get_op_res_gssize   (GSimpleAsyncResult      *simple);
90
91 void                g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult      *simple,
92                                                                gboolean                 op_res);
93 gboolean            g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult      *simple);
94
95
96
97 gpointer            g_simple_async_result_get_source_tag   (GSimpleAsyncResult      *simple);
98 void                g_simple_async_result_set_handle_cancellation (GSimpleAsyncResult      *simple,
99                                                                    gboolean          handle_cancellation);
100 void                g_simple_async_result_complete         (GSimpleAsyncResult      *simple);
101 void                g_simple_async_result_complete_in_idle (GSimpleAsyncResult      *simple);
102 void                g_simple_async_result_run_in_thread    (GSimpleAsyncResult      *simple,
103                                                             GSimpleAsyncThreadFunc   func,
104                                                             int                      io_priority,
105                                                             GCancellable            *cancellable);
106 void                g_simple_async_result_set_from_error   (GSimpleAsyncResult      *simple,
107                                                             GError                  *error);
108 gboolean            g_simple_async_result_propagate_error  (GSimpleAsyncResult      *simple,
109                                                             GError                 **dest);
110 void                g_simple_async_result_set_error        (GSimpleAsyncResult      *simple,
111                                                             GQuark                   domain,
112                                                             gint                     code,
113                                                             const char              *format,
114                                                             ...) G_GNUC_PRINTF (4, 5);
115 void                g_simple_async_result_set_error_va     (GSimpleAsyncResult      *simple,
116                                                             GQuark                   domain,
117                                                             gint                     code,
118                                                             const char              *format,
119                                                             va_list                  args);
120
121 void g_simple_async_report_error_in_idle  (GObject *object,
122                                            GAsyncReadyCallback callback,
123                                            gpointer user_data,
124                                            GQuark         domain,
125                                            gint           code,
126                                            const char    *format,
127                                            ...);
128 void g_simple_async_report_gerror_in_idle (GObject *object,
129                                            GAsyncReadyCallback callback,
130                                            gpointer user_data,
131                                            GError *error);
132
133 G_END_DECLS
134
135
136   
137 #endif /* __G_SIMPLE_ASYNC_RESULT_H__ */