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