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

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

Initial release

File size: 5.5 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.UnixFDMessage;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.SocketControlMessage;
26private import gio.UnixFDList;
27private import glib.ConstructionException;
28private import glib.ErrorG;
29private import glib.GException;
30private import gobject.ObjectG;
31
32
33/**
34 * This #GSocketControlMessage contains a #GUnixFDList.
35 * It may be sent using g_socket_send_message() and received using
36 * g_socket_receive_message() over UNIX sockets (ie: sockets in the
37 * %G_SOCKET_ADDRESS_UNIX family). The file descriptors are copied
38 * between processes by the kernel.
39 *
40 * For an easier way to send and receive file descriptors over
41 * stream-oriented UNIX sockets, see g_unix_connection_send_fd() and
42 * g_unix_connection_receive_fd().
43 *
44 * Note that `<gio/gunixfdmessage.h>` belongs to the UNIX-specific GIO
45 * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
46 * file when using it.
47 */
48public class UnixFDMessage : SocketControlMessage
49{
50        /** the main Gtk struct */
51        protected GUnixFDMessage* gUnixFDMessage;
52
53        /** Get the main Gtk struct */
54        public GUnixFDMessage* getUnixFDMessageStruct()
55        {
56                return gUnixFDMessage;
57        }
58
59        /** the main Gtk struct as a void* */
60        protected override void* getStruct()
61        {
62                return cast(void*)gUnixFDMessage;
63        }
64
65        protected override void setStruct(GObject* obj)
66        {
67                gUnixFDMessage = cast(GUnixFDMessage*)obj;
68                super.setStruct(obj);
69        }
70
71        /**
72         * Sets our main struct and passes it to the parent class.
73         */
74        public this (GUnixFDMessage* gUnixFDMessage, bool ownedRef = false)
75        {
76                this.gUnixFDMessage = gUnixFDMessage;
77                super(cast(GSocketControlMessage*)gUnixFDMessage, ownedRef);
78        }
79
80
81        /** */
82        public static GType getType()
83        {
84                return g_unix_fd_message_get_type();
85        }
86
87        /**
88         * Creates a new #GUnixFDMessage containing an empty file descriptor
89         * list.
90         *
91         * Returns: a new #GUnixFDMessage
92         *
93         * Since: 2.22
94         *
95         * Throws: ConstructionException GTK+ fails to create the object.
96         */
97        public this()
98        {
99                auto p = g_unix_fd_message_new();
100               
101                if(p is null)
102                {
103                        throw new ConstructionException("null returned by new");
104                }
105               
106                this(cast(GUnixFDMessage*) p, true);
107        }
108
109        /**
110         * Creates a new #GUnixFDMessage containing @list.
111         *
112         * Params:
113         *     fdList = a #GUnixFDList
114         *
115         * Returns: a new #GUnixFDMessage
116         *
117         * Since: 2.24
118         *
119         * Throws: ConstructionException GTK+ fails to create the object.
120         */
121        public this(UnixFDList fdList)
122        {
123                auto p = g_unix_fd_message_new_with_fd_list((fdList is null) ? null : fdList.getUnixFDListStruct());
124               
125                if(p is null)
126                {
127                        throw new ConstructionException("null returned by new_with_fd_list");
128                }
129               
130                this(cast(GUnixFDMessage*) p, true);
131        }
132
133        /**
134         * Adds a file descriptor to @message.
135         *
136         * The file descriptor is duplicated using dup(). You keep your copy
137         * of the descriptor and the copy contained in @message will be closed
138         * when @message is finalized.
139         *
140         * A possible cause of failure is exceeding the per-process or
141         * system-wide file descriptor limit.
142         *
143         * Params:
144         *     fd = a valid open file descriptor
145         *
146         * Returns: %TRUE in case of success, else %FALSE (and @error is set)
147         *
148         * Since: 2.22
149         *
150         * Throws: GException on failure.
151         */
152        public bool appendFd(int fd)
153        {
154                GError* err = null;
155               
156                auto p = g_unix_fd_message_append_fd(gUnixFDMessage, fd, &err) != 0;
157               
158                if (err !is null)
159                {
160                        throw new GException( new ErrorG(err) );
161                }
162               
163                return p;
164        }
165
166        /**
167         * Gets the #GUnixFDList contained in @message.  This function does not
168         * return a reference to the caller, but the returned list is valid for
169         * the lifetime of @message.
170         *
171         * Returns: the #GUnixFDList from @message
172         *
173         * Since: 2.24
174         */
175        public UnixFDList getFdList()
176        {
177                auto p = g_unix_fd_message_get_fd_list(gUnixFDMessage);
178               
179                if(p is null)
180                {
181                        return null;
182                }
183               
184                return ObjectG.getDObject!(UnixFDList)(cast(GUnixFDList*) p);
185        }
186
187        /**
188         * Returns the array of file descriptors that is contained in this
189         * object.
190         *
191         * After this call, the descriptors are no longer contained in
192         * @message. Further calls will return an empty list (unless more
193         * descriptors have been added).
194         *
195         * The return result of this function must be freed with g_free().
196         * The caller is also responsible for closing all of the file
197         * descriptors.
198         *
199         * If @length is non-%NULL then it is set to the number of file
200         * descriptors in the returned array. The returned array is also
201         * terminated with -1.
202         *
203         * This function never returns %NULL. In case there are no file
204         * descriptors contained in @message, an empty array is returned.
205         *
206         * Returns: an array of file
207         *     descriptors
208         *
209         * Since: 2.22
210         */
211        public int[] stealFds()
212        {
213                int length;
214               
215                auto p = g_unix_fd_message_steal_fds(gUnixFDMessage, &length);
216               
217                return p[0 .. length];
218        }
219}
Note: See TracBrowser for help on using the repository browser.