1 /* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2006-2007 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Author: Alexander Larsson <alexl@redhat.com>
21 */
22
23 #ifndef __GIO_TYPES_H__
24 #define __GIO_TYPES_H__
25
26 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27 #error "Only <gio/gio.h> can be included directly."
28 #endif
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 _GDatagramBased GDatagramBased;
46 typedef struct _GDataInputStream GDataInputStream;
47 typedef struct _GSimplePermission GSimplePermission;
48 typedef struct _GZlibCompressor GZlibCompressor;
49 typedef struct _GZlibDecompressor GZlibDecompressor;
50
51 typedef struct _GSimpleActionGroup GSimpleActionGroup;
52 typedef struct _GRemoteActionGroup GRemoteActionGroup;
53 typedef struct _GDBusActionGroup GDBusActionGroup;
54 typedef struct _GActionMap GActionMap;
55 typedef struct _GActionGroup GActionGroup;
56 typedef struct _GPropertyAction GPropertyAction;
57 typedef struct _GSimpleAction GSimpleAction;
58 typedef struct _GAction GAction;
59 typedef struct _GApplication GApplication;
60 typedef struct _GApplicationCommandLine GApplicationCommandLine;
61 typedef struct _GSettingsBackend GSettingsBackend;
62 typedef struct _GSettings GSettings;
63 typedef struct _GPermission GPermission;
64
65 typedef struct _GMenuModel GMenuModel;
66 typedef struct _GNotification GNotification;
67
68 typedef struct _GDrive GDrive; /* Dummy typedef */
69 typedef struct _GFileEnumerator GFileEnumerator;
70 typedef struct _GFileMonitor GFileMonitor;
71 typedef struct _GFilterInputStream GFilterInputStream;
72 typedef struct _GFilterOutputStream GFilterOutputStream;
73
74 typedef struct _GFile GFile; /* Dummy typedef */
75 typedef struct _GFileInfo GFileInfo;
76
77 /**
78 * GFileAttributeMatcher:
79 *
80 * Determines if a string matches a file attribute.
81 **/
82 typedef struct _GFileAttributeMatcher GFileAttributeMatcher;
83 typedef struct _GFileAttributeInfo GFileAttributeInfo;
84 typedef struct _GFileAttributeInfoList GFileAttributeInfoList;
85 typedef struct _GFileDescriptorBased GFileDescriptorBased;
86 typedef struct _GFileInputStream GFileInputStream;
87 typedef struct _GFileOutputStream GFileOutputStream;
88 typedef struct _GFileIOStream GFileIOStream;
89 typedef struct _GFileIcon GFileIcon;
90 typedef struct _GFilenameCompleter GFilenameCompleter;
91
92
93 typedef struct _GIcon GIcon; /* Dummy typedef */
94 typedef struct _GInetAddress GInetAddress;
95 typedef struct _GInetAddressMask GInetAddressMask;
96 typedef struct _GInetSocketAddress GInetSocketAddress;
97 typedef struct _GNativeSocketAddress GNativeSocketAddress;
98 typedef struct _GInputStream GInputStream;
99 typedef struct _GInitable GInitable;
100 typedef struct _GIOModule GIOModule;
101 typedef struct _GIOExtensionPoint GIOExtensionPoint;
102 typedef struct _GIOExtension GIOExtension;
103
104 /**
105 * GIOSchedulerJob:
106 *
107 * Opaque class for defining and scheduling IO jobs.
108 *
109 * Deprecated: 2.36: Use [struct@GLib.ThreadPool] or
110 * [method@Gio.Task.run_in_thread]
111 **/
112 typedef struct _GIOSchedulerJob GIOSchedulerJob;
113 typedef struct _GIOStreamAdapter GIOStreamAdapter;
114 typedef struct _GLoadableIcon GLoadableIcon; /* Dummy typedef */
115 typedef struct _GBytesIcon GBytesIcon;
116 typedef struct _GMemoryInputStream GMemoryInputStream;
117 typedef struct _GMemoryOutputStream GMemoryOutputStream;
118
119 typedef struct _GMount GMount; /* Dummy typedef */
120 typedef struct _GMountOperation GMountOperation;
121 typedef struct _GNetworkAddress GNetworkAddress;
122 typedef struct _GNetworkMonitor GNetworkMonitor;
123 typedef struct _GNetworkService GNetworkService;
124 typedef struct _GOutputStream GOutputStream;
125 typedef struct _GIOStream GIOStream;
126 typedef struct _GSimpleIOStream GSimpleIOStream;
127 typedef struct _GPollableInputStream GPollableInputStream; /* Dummy typedef */
128 typedef struct _GPollableOutputStream GPollableOutputStream; /* Dummy typedef */
129 typedef struct _GResolver GResolver;
130
131 typedef struct _GResource GResource;
132 typedef struct _GSeekable GSeekable;
133 typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
134
135 typedef struct _GSocket GSocket;
136
137 typedef struct _GSocketControlMessage GSocketControlMessage;
138 typedef struct _GSocketClient GSocketClient;
139 typedef struct _GSocketConnection GSocketConnection;
140 typedef struct _GSocketListener GSocketListener;
141 typedef struct _GSocketService GSocketService;
142 typedef struct _GSocketAddress GSocketAddress;
143 typedef struct _GSocketAddressEnumerator GSocketAddressEnumerator;
144 typedef struct _GSocketConnectable GSocketConnectable;
145 typedef struct _GSrvTarget GSrvTarget;
146 typedef struct _GTask GTask;
147 typedef struct _GTcpConnection GTcpConnection;
148 typedef struct _GTcpWrapperConnection GTcpWrapperConnection;
149 typedef struct _GThreadedSocketService GThreadedSocketService;
150 typedef struct _GDtlsConnection GDtlsConnection;
151 typedef struct _GDtlsClientConnection GDtlsClientConnection; /* Dummy typedef */
152 typedef struct _GDtlsServerConnection GDtlsServerConnection; /* Dummy typedef */
153 typedef struct _GThemedIcon GThemedIcon;
154 typedef struct _GTlsCertificate GTlsCertificate;
155 typedef struct _GTlsClientConnection GTlsClientConnection; /* Dummy typedef */
156 typedef struct _GTlsConnection GTlsConnection;
157 typedef struct _GTlsDatabase GTlsDatabase;
158 typedef struct _GTlsFileDatabase GTlsFileDatabase;
159 typedef struct _GTlsInteraction GTlsInteraction;
160 typedef struct _GTlsPassword GTlsPassword;
161 typedef struct _GTlsServerConnection GTlsServerConnection; /* Dummy typedef */
162 typedef struct _GVfs GVfs; /* Dummy typedef */
163
164 typedef struct _GProxyResolver GProxyResolver;
165 typedef struct _GProxy GProxy;
166 typedef struct _GProxyAddress GProxyAddress;
167 typedef struct _GProxyAddressEnumerator GProxyAddressEnumerator;
168
169 typedef struct _GVolume GVolume; /* Dummy typedef */
170 typedef struct _GVolumeMonitor GVolumeMonitor;
171
172 /**
173 * GAsyncReadyCallback:
174 * @source_object: (nullable): the object the asynchronous operation was started with.
175 * @res: a #GAsyncResult.
176 * @data: user data passed to the callback.
177 *
178 * Type definition for a function that will be called back when an asynchronous
179 * operation within GIO has been completed. #GAsyncReadyCallback
180 * callbacks from #GTask are guaranteed to be invoked in a later
181 * iteration of the
182 * [thread-default main context][g-main-context-push-thread-default]
183 * where the #GTask was created. All other users of
184 * #GAsyncReadyCallback must likewise call it asynchronously in a
185 * later iteration of the main context.
186 *
187 * The asynchronous operation is guaranteed to have held a reference to
188 * @source_object from the time when the `*_async()` function was called, until
189 * after this callback returns.
190 **/
191 typedef void (*GAsyncReadyCallback) (GObject *source_object,
192 GAsyncResult *res,
193 gpointer data);
194
195 /**
196 * GFileProgressCallback:
197 * @current_num_bytes: the current number of bytes in the operation.
198 * @total_num_bytes: the total number of bytes in the operation.
199 * @data: user data passed to the callback.
200 *
201 * When doing file operations that may take a while, such as moving
202 * a file or copying a file, a progress callback is used to pass how
203 * far along that operation is to the application.
204 **/
205 typedef void (*GFileProgressCallback) (goffset current_num_bytes,
206 goffset total_num_bytes,
207 gpointer data);
208
209 /**
210 * GFileReadMoreCallback:
211 * @file_contents: the data as currently read.
212 * @file_size: the size of the data currently read.
213 * @callback_data: data passed to the callback.
214 *
215 * When loading the partial contents of a file with g_file_load_partial_contents_async(),
216 * it may become necessary to determine if any more data from the file should be loaded.
217 * A #GFileReadMoreCallback function facilitates this by returning %TRUE if more data
218 * should be read, or %FALSE otherwise.
219 *
220 * Returns: %TRUE if more data should be read back. %FALSE otherwise.
221 **/
222 typedef gboolean (* GFileReadMoreCallback) (const char *file_contents,
223 goffset file_size,
224 gpointer callback_data);
225
226 /**
227 * GFileMeasureProgressCallback:
228 * @reporting: %TRUE if more reports will come
229 * @current_size: the current cumulative size measurement
230 * @num_dirs: the number of directories visited so far
231 * @num_files: the number of non-directory files encountered
232 * @data: the data passed to the original request for this callback
233 *
234 * This callback type is used by g_file_measure_disk_usage() to make
235 * periodic progress reports when measuring the amount of disk spaced
236 * used by a directory.
237 *
238 * These calls are made on a best-effort basis and not all types of
239 * #GFile will support them. At the minimum, however, one call will
240 * always be made immediately.
241 *
242 * In the case that there is no support, @reporting will be set to
243 * %FALSE (and the other values undefined) and no further calls will be
244 * made. Otherwise, the @reporting will be %TRUE and the other values
245 * all-zeros during the first (immediate) call. In this way, you can
246 * know which type of progress UI to show without a delay.
247 *
248 * For g_file_measure_disk_usage() the callback is made directly. For
249 * g_file_measure_disk_usage_async() the callback is made via the
250 * default main context of the calling thread (ie: the same way that the
251 * final async result would be reported).
252 *
253 * @current_size is in the same units as requested by the operation (see
254 * %G_FILE_MEASURE_APPARENT_SIZE).
255 *
256 * The frequency of the updates is implementation defined, but is
257 * ideally about once every 200ms.
258 *
259 * The last progress callback may or may not be equal to the final
260 * result. Always check the async result to get the final value.
261 *
262 * Since: 2.38
263 **/
264 typedef void (* GFileMeasureProgressCallback) (gboolean reporting,
265 guint64 current_size,
266 guint64 num_dirs,
267 guint64 num_files,
268 gpointer data);
269
270 /**
271 * GIOSchedulerJobFunc:
272 * @job: a #GIOSchedulerJob.
273 * @cancellable: optional #GCancellable object, %NULL to ignore.
274 * @data: data passed to the callback function
275 *
276 * I/O Job function.
277 *
278 * Long-running jobs should periodically check the @cancellable
279 * to see if they have been cancelled.
280 *
281 * Returns: %TRUE if this function should be called again to
282 * complete the job, %FALSE if the job is complete (or cancelled)
283 * Deprecated: 2.36: Use [struct@GLib.ThreadPool] or
284 * [method@Gio.Task.run_in_thread]
285 **/
286 typedef gboolean (*GIOSchedulerJobFunc) (GIOSchedulerJob *job,
287 GCancellable *cancellable,
288 gpointer data);
289
290 /**
291 * GSimpleAsyncThreadFunc:
292 * @res: a #GSimpleAsyncResult.
293 * @object: a #GObject.
294 * @cancellable: optional #GCancellable object, %NULL to ignore.
295 *
296 * Simple thread function that runs an asynchronous operation and
297 * checks for cancellation.
298 **/
299 typedef void (*GSimpleAsyncThreadFunc) (GSimpleAsyncResult *res,
300 GObject *object,
301 GCancellable *cancellable);
302
303 /**
304 * GSocketSourceFunc:
305 * @socket: the #GSocket
306 * @condition: the current condition at the source fired.
307 * @data: data passed in by the user.
308 *
309 * This is the function type of the callback used for the #GSource
310 * returned by g_socket_create_source().
311 *
312 * Returns: it should return %FALSE if the source should be removed.
313 *
314 * Since: 2.22
315 */
316 typedef gboolean (*GSocketSourceFunc) (GSocket *socket,
317 GIOCondition condition,
318 gpointer data);
319
320 /**
321 * GDatagramBasedSourceFunc:
322 * @datagram_based: the #GDatagramBased
323 * @condition: the current condition at the source fired
324 * @data: data passed in by the user
325 *
326 * This is the function type of the callback used for the #GSource
327 * returned by g_datagram_based_create_source().
328 *
329 * Returns: %G_SOURCE_REMOVE if the source should be removed,
330 * %G_SOURCE_CONTINUE otherwise
331 *
332 * Since: 2.48
333 */
334 typedef gboolean (*GDatagramBasedSourceFunc) (GDatagramBased *datagram_based,
335 GIOCondition condition,
336 gpointer data);
337
338 /**
339 * GInputVector:
340 * @buffer: Pointer to a buffer where data will be written.
341 * @size: the available size in @buffer.
342 *
343 * Structure used for scatter/gather data input.
344 * You generally pass in an array of #GInputVectors
345 * and the operation will store the read data starting in the
346 * first buffer, switching to the next as needed.
347 *
348 * Since: 2.22
349 */
350 typedef struct _GInputVector GInputVector;
351
352 struct _GInputVector {
353 gpointer buffer;
354 gsize size;
355 };
356
357 /**
358 * GInputMessage:
359 * @address: (optional) (out) (transfer full): return location
360 * for a #GSocketAddress, or %NULL
361 * @vectors: (array length=num_vectors) (out): pointer to an
362 * array of input vectors
363 * @num_vectors: the number of input vectors pointed to by @vectors
364 * @bytes_received: (out): will be set to the number of bytes that have been
365 * received
366 * @flags: (out): collection of #GSocketMsgFlags for the received message,
367 * outputted by the call
368 * @control_messages: (array length=num_control_messages) (optional)
369 * (out) (transfer full): return location for a
370 * caller-allocated array of #GSocketControlMessages, or %NULL
371 * @num_control_messages: (out) (optional): return location for the number of
372 * elements in @control_messages
373 *
374 * Structure used for scatter/gather data input when receiving multiple
375 * messages or packets in one go. You generally pass in an array of empty
376 * #GInputVectors and the operation will use all the buffers as if they
377 * were one buffer, and will set @bytes_received to the total number of bytes
378 * received across all #GInputVectors.
379 *
380 * This structure closely mirrors `struct mmsghdr` and `struct msghdr` from
381 * the POSIX sockets API (see `man 2 recvmmsg`).
382 *
383 * If @address is non-%NULL then it is set to the source address the message
384 * was received from, and the caller must free it afterwards.
385 *
386 * If @control_messages is non-%NULL then it is set to an array of control
387 * messages received with the message (if any), and the caller must free it
388 * afterwards. @num_control_messages is set to the number of elements in
389 * this array, which may be zero.
390 *
391 * Flags relevant to this message will be returned in @flags. For example,
392 * `MSG_EOR` or `MSG_TRUNC`.
393 *
394 * Since: 2.48
395 */
396 typedef struct _GInputMessage GInputMessage;
397
398 struct _GInputMessage {
399 GSocketAddress **address;
400
401 GInputVector *vectors;
402 guint num_vectors;
403
404 gsize bytes_received;
405 gint flags;
406
407 GSocketControlMessage ***control_messages;
408 guint *num_control_messages;
409 };
410
411 /**
412 * GOutputVector:
413 * @buffer: Pointer to a buffer of data to read.
414 * @size: the size of @buffer.
415 *
416 * Structure used for scatter/gather data output.
417 * You generally pass in an array of #GOutputVectors
418 * and the operation will use all the buffers as if they were
419 * one buffer.
420 *
421 * Since: 2.22
422 */
423 typedef struct _GOutputVector GOutputVector;
424
425 struct _GOutputVector {
426 gconstpointer buffer;
427 gsize size;
428 };
429
430 /**
431 * GOutputMessage:
432 * @address: (nullable): a #GSocketAddress, or %NULL
433 * @vectors: pointer to an array of output vectors
434 * @num_vectors: the number of output vectors pointed to by @vectors.
435 * @bytes_sent: initialize to 0. Will be set to the number of bytes
436 * that have been sent
437 * @control_messages: (array length=num_control_messages) (nullable): a pointer
438 * to an array of #GSocketControlMessages, or %NULL.
439 * @num_control_messages: number of elements in @control_messages.
440 *
441 * Structure used for scatter/gather data output when sending multiple
442 * messages or packets in one go. You generally pass in an array of
443 * #GOutputVectors and the operation will use all the buffers as if they
444 * were one buffer.
445 *
446 * If @address is %NULL then the message is sent to the default receiver
447 * (as previously set by g_socket_connect()).
448 *
449 * Since: 2.44
450 */
451 typedef struct _GOutputMessage GOutputMessage;
452
453 struct _GOutputMessage {
454 GSocketAddress *address;
455
456 GOutputVector *vectors;
457 guint num_vectors;
458
459 guint bytes_sent;
460
461 GSocketControlMessage **control_messages;
462 guint num_control_messages;
463 };
464
465 typedef struct _GCredentials GCredentials;
466 typedef struct _GUnixCredentialsMessage GUnixCredentialsMessage;
467 typedef struct _GUnixFDList GUnixFDList;
468 typedef struct _GDBusMessage GDBusMessage;
469 typedef struct _GDBusConnection GDBusConnection;
470 typedef struct _GDBusProxy GDBusProxy;
471 typedef struct _GDBusMethodInvocation GDBusMethodInvocation;
472 typedef struct _GDBusServer GDBusServer;
473 typedef struct _GDBusAuthObserver GDBusAuthObserver;
474 typedef struct _GDBusErrorEntry GDBusErrorEntry;
475 typedef struct _GDBusInterfaceVTable GDBusInterfaceVTable;
476 typedef struct _GDBusSubtreeVTable GDBusSubtreeVTable;
477 typedef struct _GDBusAnnotationInfo GDBusAnnotationInfo;
478 typedef struct _GDBusArgInfo GDBusArgInfo;
479 typedef struct _GDBusMethodInfo GDBusMethodInfo;
480 typedef struct _GDBusSignalInfo GDBusSignalInfo;
481 typedef struct _GDBusPropertyInfo GDBusPropertyInfo;
482 typedef struct _GDBusInterfaceInfo GDBusInterfaceInfo;
483 typedef struct _GDBusNodeInfo GDBusNodeInfo;
484
485 /**
486 * GCancellableSourceFunc:
487 * @cancellable: the #GCancellable
488 * @data: data passed in by the user.
489 *
490 * This is the function type of the callback used for the #GSource
491 * returned by g_cancellable_source_new().
492 *
493 * Returns: it should return %FALSE if the source should be removed.
494 *
495 * Since: 2.28
496 */
497 typedef gboolean (*GCancellableSourceFunc) (GCancellable *cancellable,
498 gpointer data);
499
500 /**
501 * GPollableSourceFunc:
502 * @pollable_stream: the #GPollableInputStream or #GPollableOutputStream
503 * @data: data passed in by the user.
504 *
505 * This is the function type of the callback used for the #GSource
506 * returned by g_pollable_input_stream_create_source() and
507 * g_pollable_output_stream_create_source().
508 *
509 * Returns: it should return %FALSE if the source should be removed.
510 *
511 * Since: 2.28
512 */
513 typedef gboolean (*GPollableSourceFunc) (GObject *pollable_stream,
514 gpointer data);
515
516 typedef struct _GDBusInterface GDBusInterface; /* Dummy typedef */
517 typedef struct _GDBusInterfaceSkeleton GDBusInterfaceSkeleton;
518 typedef struct _GDBusObject GDBusObject; /* Dummy typedef */
519 typedef struct _GDBusObjectSkeleton GDBusObjectSkeleton;
520 typedef struct _GDBusObjectProxy GDBusObjectProxy;
521 typedef struct _GDBusObjectManager GDBusObjectManager; /* Dummy typedef */
522 typedef struct _GDBusObjectManagerClient GDBusObjectManagerClient;
523 typedef struct _GDBusObjectManagerServer GDBusObjectManagerServer;
524
525 /**
526 * GDBusProxyTypeFunc:
527 * @manager: A #GDBusObjectManagerClient.
528 * @object_path: The object path of the remote object.
529 * @interface_name: (nullable): The interface name of the remote object or %NULL if a #GDBusObjectProxy #GType is requested.
530 * @data: data passed in by the user.
531 *
532 * Function signature for a function used to determine the #GType to
533 * use for an interface proxy (if @interface_name is not %NULL) or
534 * object proxy (if @interface_name is %NULL).
535 *
536 * This function is called in the
537 * [thread-default main loop][g-main-context-push-thread-default]
538 * that @manager was constructed in.
539 *
540 * Returns: A #GType to use for the remote object. The returned type
541 * must be a #GDBusProxy or #GDBusObjectProxy -derived
542 * type.
543 *
544 * Since: 2.30
545 */
546 typedef GType (*GDBusProxyTypeFunc) (GDBusObjectManagerClient *manager,
547 const gchar *object_path,
548 const gchar *interface_name,
549 gpointer data);
550
551 typedef struct _GTestDBus GTestDBus;
552
553 typedef struct _GSubprocess GSubprocess;
554 typedef struct _GSubprocessLauncher GSubprocessLauncher;
555
556 G_END_DECLS
557
558 #endif /* __GIO_TYPES_H__ */