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