Add pollable input/output streams
[platform/upstream/glib.git] / gio / giotypes.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 __GIO_TYPES_H__
28 #define __GIO_TYPES_H__
29
30 #include <gio/gioenums.h>
31
32 G_BEGIN_DECLS
33
34 typedef struct _GAppLaunchContext             GAppLaunchContext;
35 typedef struct _GAppInfo                      GAppInfo; /* Dummy typedef */
36 typedef struct _GAsyncResult                  GAsyncResult; /* Dummy typedef */
37 typedef struct _GAsyncInitable                GAsyncInitable;
38 typedef struct _GBufferedInputStream          GBufferedInputStream;
39 typedef struct _GBufferedOutputStream         GBufferedOutputStream;
40 typedef struct _GCancellable                  GCancellable;
41 typedef struct _GCharsetConverter             GCharsetConverter;
42 typedef struct _GConverter                    GConverter;
43 typedef struct _GConverterInputStream         GConverterInputStream;
44 typedef struct _GConverterOutputStream        GConverterOutputStream;
45 typedef struct _GDataInputStream              GDataInputStream;
46 typedef struct _GSimplePermission             GSimplePermission;
47 typedef struct _GZlibCompressor               GZlibCompressor;
48 typedef struct _GZlibDecompressor             GZlibDecompressor;
49
50 typedef struct _GSimpleActionGroup            GSimpleActionGroup;
51 typedef struct _GActionGroup                  GActionGroup;
52 typedef struct _GSimpleAction                 GSimpleAction;
53 typedef struct _GAction                       GAction;
54 typedef struct _GApplication                  GApplication;
55 typedef struct _GApplicationCommandLine       GApplicationCommandLine;
56 typedef struct _GSettingsBackend              GSettingsBackend;
57 typedef struct _GSettings                     GSettings;
58 typedef struct _GPermission                   GPermission;
59
60 /**
61  * GDrive:
62  *
63  * Opaque drive object.
64  **/
65 typedef struct _GDrive                        GDrive; /* Dummy typedef */
66 typedef struct _GFileEnumerator               GFileEnumerator;
67 typedef struct _GFileMonitor                  GFileMonitor;
68 typedef struct _GFilterInputStream            GFilterInputStream;
69 typedef struct _GFilterOutputStream           GFilterOutputStream;
70
71 /**
72  * GFile:
73  *
74  * A handle to an object implementing the #GFileIface interface.
75  * Generally stores a location within the file system. Handles do not
76  * necessarily represent files or directories that currently exist.
77  **/
78 typedef struct _GFile                         GFile; /* Dummy typedef */
79 typedef struct _GFileInfo                     GFileInfo;
80
81 /**
82  * GFileAttributeMatcher:
83  *
84  * Determines if a string matches a file attribute.
85  **/
86 typedef struct _GFileAttributeMatcher         GFileAttributeMatcher;
87 typedef struct _GFileAttributeInfo            GFileAttributeInfo;
88 typedef struct _GFileAttributeInfoList        GFileAttributeInfoList;
89 typedef struct _GFileDescriptorBased          GFileDescriptorBased;
90 typedef struct _GFileInputStream              GFileInputStream;
91 typedef struct _GFileOutputStream             GFileOutputStream;
92 typedef struct _GFileIOStream                 GFileIOStream;
93 typedef struct _GFileIcon                     GFileIcon;
94 typedef struct _GFilenameCompleter            GFilenameCompleter;
95
96
97 typedef struct _GIcon                         GIcon; /* Dummy typedef */
98 typedef struct _GInetAddress                  GInetAddress;
99 typedef struct _GInetSocketAddress            GInetSocketAddress;
100 typedef struct _GInputStream                  GInputStream;
101 typedef struct _GInitable                     GInitable;
102 typedef struct _GIOModule                     GIOModule;
103 typedef struct _GIOExtensionPoint             GIOExtensionPoint;
104 typedef struct _GIOExtension                  GIOExtension;
105
106 /**
107  * GIOSchedulerJob:
108  *
109  * Opaque class for definining and scheduling IO jobs.
110  **/
111 typedef struct _GIOSchedulerJob               GIOSchedulerJob;
112 typedef struct _GLoadableIcon                 GLoadableIcon; /* Dummy typedef */
113 typedef struct _GMemoryInputStream            GMemoryInputStream;
114 typedef struct _GMemoryOutputStream           GMemoryOutputStream;
115
116 /**
117  * GMount:
118  *
119  * A handle to an object implementing the #GMountIface interface.
120  **/
121 typedef struct _GMount                        GMount; /* Dummy typedef */
122 typedef struct _GMountOperation               GMountOperation;
123 typedef struct _GNetworkAddress               GNetworkAddress;
124 typedef struct _GNetworkService               GNetworkService;
125 typedef struct _GOutputStream                 GOutputStream;
126 typedef struct _GIOStream                     GIOStream;
127 typedef struct _GPollableInputStream          GPollableInputStream; /* Dummy typedef */
128 typedef struct _GPollableOutputStream         GPollableOutputStream; /* Dummy typedef */
129 typedef struct _GResolver                     GResolver;
130 typedef struct _GSeekable                     GSeekable;
131 typedef struct _GSimpleAsyncResult            GSimpleAsyncResult;
132
133 /**
134  * GSocket:
135  *
136  * A lowlevel network socket object.
137  *
138  * Since: 2.22
139  **/
140 typedef struct _GSocket                       GSocket;
141
142 /**
143  * GSocketControlMessage:
144  *
145  * Base class for socket-type specific control messages that can be sent and
146  * received over #GSocket.
147  **/
148 typedef struct _GSocketControlMessage         GSocketControlMessage;
149 /**
150  * GSocketClient:
151  *
152  * A helper class for network clients to make connections.
153  *
154  * Since: 2.22
155  **/
156 typedef struct _GSocketClient                               GSocketClient;
157 /**
158  * GSocketConnection:
159  *
160  * A socket connection GIOStream object for connection-oriented sockets.
161  *
162  * Since: 2.22
163  **/
164 typedef struct _GSocketConnection                           GSocketConnection;
165 /**
166  * GSocketClient:
167  *
168  * A helper class for network servers to listen for and accept connections.
169  *
170  * Since: 2.22
171  **/
172 typedef struct _GSocketListener                             GSocketListener;
173 /**
174  * GSocketService:
175  *
176  * A helper class for handling accepting incomming connections in the
177  * glib mainloop.
178  *
179  * Since: 2.22
180  **/
181 typedef struct _GSocketService                              GSocketService;
182 typedef struct _GSocketAddress                GSocketAddress;
183 typedef struct _GSocketAddressEnumerator      GSocketAddressEnumerator;
184 typedef struct _GSocketConnectable            GSocketConnectable;
185 typedef struct _GSrvTarget                    GSrvTarget;
186 /**
187  * GTcpConnection:
188  *
189  * A #GSocketConnection for TCP/IP connections.
190  *
191  * Since: 2.22
192  **/
193 typedef struct _GTcpConnection                              GTcpConnection;
194 /**
195  * GThreadedSocketService:
196  *
197  * A helper class for handling accepting incomming connections in the
198  * glib mainloop and handling them in a thread.
199  *
200  * Since: 2.22
201  **/
202 typedef struct _GThreadedSocketService                      GThreadedSocketService;
203 typedef struct _GThemedIcon                   GThemedIcon;
204 typedef struct _GVfs                          GVfs; /* Dummy typedef */
205
206 /**
207  * GProxyResolver:
208  *
209  * A helper class to enumerate proxies base on URI.
210  *
211  * Since: 2.26
212  **/
213 typedef struct _GProxyResolver                GProxyResolver;
214 typedef struct _GProxy                        GProxy;
215 typedef struct _GProxyAddress                 GProxyAddress;
216 typedef struct _GProxyAddressEnumerator       GProxyAddressEnumerator;
217
218 /**
219  * GVolume:
220  *
221  * Opaque mountable volume object.
222  **/
223 typedef struct _GVolume                       GVolume; /* Dummy typedef */
224 typedef struct _GVolumeMonitor                GVolumeMonitor;
225
226 /**
227  * GAsyncReadyCallback:
228  * @source_object: the object the asynchronous operation was started with.
229  * @res: a #GAsyncResult.
230  * @user_data: user data passed to the callback.
231  *
232  * Type definition for a function that will be called back when an asynchronous
233  * operation within GIO has been completed.
234  **/
235 typedef void (*GAsyncReadyCallback) (GObject *source_object,
236                                      GAsyncResult *res,
237                                      gpointer user_data);
238
239 /**
240  * GFileProgressCallback:
241  * @current_num_bytes: the current number of bytes in the operation.
242  * @total_num_bytes: the total number of bytes in the operation.
243  * @user_data: user data passed to the callback.
244  *
245  * When doing file operations that may take a while, such as moving
246  * a file or copying a file, a progress callback is used to pass how
247  * far along that operation is to the application.
248  **/
249 typedef void (*GFileProgressCallback) (goffset current_num_bytes,
250                                        goffset total_num_bytes,
251                                        gpointer user_data);
252
253 /**
254  * GFileReadMoreCallback:
255  * @file_contents: the data as currently read.
256  * @file_size: the size of the data currently read.
257  * @callback_data: data passed to the callback.
258  *
259  * When loading the partial contents of a file with g_file_load_partial_contents_async(),
260  * it may become necessary to determine if any more data from the file should be loaded.
261  * A #GFileReadMoreCallback function facilitates this by returning %TRUE if more data
262  * should be read, or %FALSE otherwise.
263  *
264  * Returns: %TRUE if more data should be read back. %FALSE otherwise.
265  **/
266 typedef gboolean (* GFileReadMoreCallback) (const char *file_contents,
267                                             goffset file_size,
268                                             gpointer callback_data);
269
270
271 /**
272  * GIOSchedulerJobFunc:
273  * @job: a #GIOSchedulerJob.
274  * @cancellable: optional #GCancellable object, %NULL to ignore.
275  * @user_data: the data to pass to callback function
276  *
277  * I/O Job function.
278  *
279  * Note that depending on whether threads are available, the
280  * #GIOScheduler may run jobs in separate threads or in an idle
281  * in the mainloop.
282  *
283  * Long-running jobs should periodically check the @cancellable
284  * to see if they have been cancelled.
285  *
286  * Returns: %TRUE if this function should be called again to
287  *    complete the job, %FALSE if the job is complete (or cancelled)
288  **/
289 typedef gboolean (*GIOSchedulerJobFunc) (GIOSchedulerJob *job,
290                                          GCancellable    *cancellable,
291                                          gpointer         user_data);
292
293 /**
294  * GSimpleAsyncThreadFunc:
295  * @res: a #GSimpleAsyncResult.
296  * @object: a #GObject.
297  * @cancellable: optional #GCancellable object, %NULL to ignore.
298  *
299  * Simple thread function that runs an asynchronous operation and
300  * checks for cancellation.
301  **/
302 typedef void (*GSimpleAsyncThreadFunc) (GSimpleAsyncResult *res,
303                                         GObject *object,
304                                         GCancellable *cancellable);
305
306 /**
307  * GSocketSourceFunc:
308  * @socket: the #GSocket
309  * @condition: the current condition at the source fired.
310  * @user_data: data passed in by the user.
311  *
312  * This is the function type of the callback used for the #GSource
313  * returned by g_socket_create_source().
314  *
315  * Returns: it should return %FALSE if the source should be removed.
316  *
317  * Since: 2.22
318  */
319 typedef gboolean (*GSocketSourceFunc) (GSocket *socket,
320                                        GIOCondition condition,
321                                        gpointer user_data);
322
323 /**
324  * GInputVector:
325  * @buffer: Pointer to a buffer where data will be written.
326  * @size: the available size in @buffer.
327  *
328  * Structure used for scatter/gather data input.
329  * You generally pass in an array of #GInputVector<!-- -->s
330  * and the operation will store the read data starting in the
331  * first buffer, switching to the next as needed.
332  *
333  * Since: 2.22
334  */
335 typedef struct _GInputVector GInputVector;
336
337 struct _GInputVector {
338   gpointer buffer;
339   gsize size;
340 };
341
342 /**
343  * GOutputVector:
344  * @buffer: Pointer to a buffer of data to read.
345  * @size: the size of @buffer.
346  *
347  * Structure used for scatter/gather data output.
348  * You generally pass in an array of #GOutputVector<!-- -->s
349  * and the operation will use all the buffers as if they were
350  * one buffer.
351  *
352  * Since: 2.22
353  */
354 typedef struct _GOutputVector GOutputVector;
355
356 struct _GOutputVector {
357   gconstpointer buffer;
358   gsize size;
359 };
360
361 typedef struct _GCredentials                  GCredentials;
362 typedef struct _GUnixCredentialsMessage       GUnixCredentialsMessage;
363 typedef struct _GUnixFDList                   GUnixFDList;
364 typedef struct _GDBusMessage                  GDBusMessage;
365 typedef struct _GDBusConnection               GDBusConnection;
366 typedef struct _GDBusProxy                    GDBusProxy;
367 typedef struct _GDBusMethodInvocation         GDBusMethodInvocation;
368 typedef struct _GDBusServer                   GDBusServer;
369 typedef struct _GDBusAuthObserver             GDBusAuthObserver;
370 typedef struct _GDBusErrorEntry               GDBusErrorEntry;
371 typedef struct _GDBusInterfaceVTable          GDBusInterfaceVTable;
372 typedef struct _GDBusSubtreeVTable            GDBusSubtreeVTable;
373 typedef struct _GDBusAnnotationInfo           GDBusAnnotationInfo;
374 typedef struct _GDBusArgInfo                  GDBusArgInfo;
375 typedef struct _GDBusMethodInfo               GDBusMethodInfo;
376 typedef struct _GDBusSignalInfo               GDBusSignalInfo;
377 typedef struct _GDBusPropertyInfo             GDBusPropertyInfo;
378 typedef struct _GDBusInterfaceInfo            GDBusInterfaceInfo;
379 typedef struct _GDBusNodeInfo                 GDBusNodeInfo;
380
381 /**
382  * GCancellableSourceFunc:
383  * @cancellable: the #GCancellable
384  * @user_data: data passed in by the user.
385  *
386  * This is the function type of the callback used for the #GSource
387  * returned by g_cancellable_source_new().
388  *
389  * Returns: it should return %FALSE if the source should be removed.
390  *
391  * Since: 2.28
392  */
393 typedef gboolean (*GCancellableSourceFunc) (GCancellable *cancellable,
394                                             gpointer      user_data);
395
396 /**
397  * GPollableSourceFunc:
398  * @pollable_stream: the #GPollableInputStream or #GPollableOutputStream
399  * @user_data: data passed in by the user.
400  *
401  * This is the function type of the callback used for the #GSource
402  * returned by g_pollable_input_stream_create_source() and
403  * g_pollable_output_stream_create_source().
404  *
405  * Returns: it should return %FALSE if the source should be removed.
406  *
407  * Since: 2.28
408  */
409 typedef gboolean (*GPollableSourceFunc) (GObject  *pollable_stream,
410                                          gpointer  user_data);
411
412 G_END_DECLS
413
414 #endif /* __GIO_TYPES_H__ */