source: appstream-generator/build/girepo/gio/SocketControlMessage.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.9 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software 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
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.SocketControlMessage;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gobject.ObjectG;
26
27
28/**
29 * A #GSocketControlMessage is a special-purpose utility message that
30 * can be sent to or received from a #GSocket. These types of
31 * messages are often called "ancillary data".
32 *
33 * The message can represent some sort of special instruction to or
34 * information from the socket or can represent a special kind of
35 * transfer to the peer (for example, sending a file descriptor over
36 * a UNIX socket).
37 *
38 * These messages are sent with g_socket_send_message() and received
39 * with g_socket_receive_message().
40 *
41 * To extend the set of control message that can be sent, subclass this
42 * class and override the get_size, get_level, get_type and serialize
43 * methods.
44 *
45 * To extend the set of control messages that can be received, subclass
46 * this class and implement the deserialize method. Also, make sure your
47 * class is registered with the GType typesystem before calling
48 * g_socket_receive_message() to read such a message.
49 */
50public class SocketControlMessage : ObjectG
51{
52        /** the main Gtk struct */
53        protected GSocketControlMessage* gSocketControlMessage;
54
55        /** Get the main Gtk struct */
56        public GSocketControlMessage* getSocketControlMessageStruct()
57        {
58                return gSocketControlMessage;
59        }
60
61        /** the main Gtk struct as a void* */
62        protected override void* getStruct()
63        {
64                return cast(void*)gSocketControlMessage;
65        }
66
67        protected override void setStruct(GObject* obj)
68        {
69                gSocketControlMessage = cast(GSocketControlMessage*)obj;
70                super.setStruct(obj);
71        }
72
73        /**
74         * Sets our main struct and passes it to the parent class.
75         */
76        public this (GSocketControlMessage* gSocketControlMessage, bool ownedRef = false)
77        {
78                this.gSocketControlMessage = gSocketControlMessage;
79                super(cast(GObject*)gSocketControlMessage, ownedRef);
80        }
81
82
83        /** */
84        public static GType getType()
85        {
86                return g_socket_control_message_get_type();
87        }
88
89        /**
90         * Tries to deserialize a socket control message of a given
91         * @level and @type. This will ask all known (to GType) subclasses
92         * of #GSocketControlMessage if they can understand this kind
93         * of message and if so deserialize it into a #GSocketControlMessage.
94         *
95         * If there is no implementation for this kind of control message, %NULL
96         * will be returned.
97         *
98         * Params:
99         *     level = a socket level
100         *     type = a socket control message type for the given @level
101         *     size = the size of the data in bytes
102         *     data = pointer to the message data
103         *
104         * Returns: the deserialized message or %NULL
105         *
106         * Since: 2.22
107         */
108        public static SocketControlMessage deserialize(int level, int type, ubyte[] data)
109        {
110                auto p = g_socket_control_message_deserialize(level, type, cast(size_t)data.length, data.ptr);
111               
112                if(p is null)
113                {
114                        return null;
115                }
116               
117                return ObjectG.getDObject!(SocketControlMessage)(cast(GSocketControlMessage*) p, true);
118        }
119
120        /**
121         * Returns the "level" (i.e. the originating protocol) of the control message.
122         * This is often SOL_SOCKET.
123         *
124         * Returns: an integer describing the level
125         *
126         * Since: 2.22
127         */
128        public int getLevel()
129        {
130                return g_socket_control_message_get_level(gSocketControlMessage);
131        }
132
133        /**
134         * Returns the protocol specific type of the control message.
135         * For instance, for UNIX fd passing this would be SCM_RIGHTS.
136         *
137         * Returns: an integer describing the type of control message
138         *
139         * Since: 2.22
140         */
141        public int getMsgType()
142        {
143                return g_socket_control_message_get_msg_type(gSocketControlMessage);
144        }
145
146        /**
147         * Returns the space required for the control message, not including
148         * headers or alignment.
149         *
150         * Returns: The number of bytes required.
151         *
152         * Since: 2.22
153         */
154        public size_t getSize()
155        {
156                return g_socket_control_message_get_size(gSocketControlMessage);
157        }
158
159        /**
160         * Converts the data in the message to bytes placed in the
161         * message.
162         *
163         * @data is guaranteed to have enough space to fit the size
164         * returned by g_socket_control_message_get_size() on this
165         * object.
166         *
167         * Params:
168         *     data = A buffer to write data to
169         *
170         * Since: 2.22
171         */
172        public void serialize(void* data)
173        {
174                g_socket_control_message_serialize(gSocketControlMessage, data);
175        }
176}
Note: See TracBrowser for help on using the repository browser.