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