1/*
2 * Copyright 2015 Collabora Ltd.
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authors: Philip Withnall <philip.withnall@collabora.co.uk>
20 */
21
22#ifndef __G_DATAGRAM_BASED_H__
23#define __G_DATAGRAM_BASED_H__
24
25#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26#error "Only <gio/gio.h> can be included directly."
27#endif
28
29#include <gio/giotypes.h>
30
31G_BEGIN_DECLS
32
33#define G_TYPE_DATAGRAM_BASED (g_datagram_based_get_type ())
34#define G_DATAGRAM_BASED(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
35 G_TYPE_DATAGRAM_BASED, GDatagramBased))
36#define G_IS_DATAGRAM_BASED(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
37 G_TYPE_DATAGRAM_BASED))
38#define G_DATAGRAM_BASED_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), \
39 G_TYPE_DATAGRAM_BASED, \
40 GDatagramBasedInterface))
41#define G_TYPE_IS_DATAGRAM_BASED(type) (g_type_is_a ((type), \
42 G_TYPE_DATAGRAM_BASED))
43
44typedef struct _GDatagramBasedInterface GDatagramBasedInterface;
45
46/**
47 * GDatagramBasedInterface:
48 * @g_iface: The parent interface.
49 * @receive_messages: Virtual method for g_datagram_based_receive_messages().
50 * @send_messages: Virtual method for g_datagram_based_send_messages().
51 * @create_source: Virtual method for g_datagram_based_create_source().
52 * @condition_check: Virtual method for g_datagram_based_condition_check().
53 * @condition_wait: Virtual method for
54 * g_datagram_based_condition_wait().
55 *
56 * Provides an interface for socket-like objects which have datagram semantics,
57 * following the Berkeley sockets API. The interface methods are thin wrappers
58 * around the corresponding virtual methods, and no pre-processing of inputs is
59 * implemented — so implementations of this API must handle all functionality
60 * documented in the interface methods.
61 *
62 * Since: 2.48
63 */
64struct _GDatagramBasedInterface
65{
66 GTypeInterface g_iface;
67
68 /* Virtual table */
69 gint (*receive_messages) (GDatagramBased *datagram_based,
70 GInputMessage *messages,
71 guint num_messages,
72 gint flags,
73 gint64 timeout,
74 GCancellable *cancellable,
75 GError **error);
76 gint (*send_messages) (GDatagramBased *datagram_based,
77 GOutputMessage *messages,
78 guint num_messages,
79 gint flags,
80 gint64 timeout,
81 GCancellable *cancellable,
82 GError **error);
83
84 GSource *(*create_source) (GDatagramBased *datagram_based,
85 GIOCondition condition,
86 GCancellable *cancellable);
87 GIOCondition (*condition_check) (GDatagramBased *datagram_based,
88 GIOCondition condition);
89 gboolean (*condition_wait) (GDatagramBased *datagram_based,
90 GIOCondition condition,
91 gint64 timeout,
92 GCancellable *cancellable,
93 GError **error);
94};
95
96GIO_AVAILABLE_IN_2_48
97GType
98g_datagram_based_get_type (void);
99
100GIO_AVAILABLE_IN_2_48
101gint
102g_datagram_based_receive_messages (GDatagramBased *datagram_based,
103 GInputMessage *messages,
104 guint num_messages,
105 gint flags,
106 gint64 timeout,
107 GCancellable *cancellable,
108 GError **error);
109
110GIO_AVAILABLE_IN_2_48
111gint
112g_datagram_based_send_messages (GDatagramBased *datagram_based,
113 GOutputMessage *messages,
114 guint num_messages,
115 gint flags,
116 gint64 timeout,
117 GCancellable *cancellable,
118 GError **error);
119
120GIO_AVAILABLE_IN_2_48
121GSource *
122g_datagram_based_create_source (GDatagramBased *datagram_based,
123 GIOCondition condition,
124 GCancellable *cancellable);
125GIO_AVAILABLE_IN_2_48
126GIOCondition
127g_datagram_based_condition_check (GDatagramBased *datagram_based,
128 GIOCondition condition);
129GIO_AVAILABLE_IN_2_48
130gboolean
131g_datagram_based_condition_wait (GDatagramBased *datagram_based,
132 GIOCondition condition,
133 gint64 timeout,
134 GCancellable *cancellable,
135 GError **error);
136
137G_END_DECLS
138
139#endif /* __G_DATAGRAM_BASED_H__ */
140