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

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

Initial release

File size: 9.1 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.UnixConnection;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.AsyncResultIF;
26private import gio.Cancellable;
27private import gio.Credentials;
28private import gio.SocketConnection;
29private import glib.ErrorG;
30private import glib.GException;
31private import gobject.ObjectG;
32
33
34/**
35 * This is the subclass of #GSocketConnection that is created
36 * for UNIX domain sockets.
37 *
38 * It contains functions to do some of the UNIX socket specific
39 * functionality like passing file descriptors.
40 *
41 * Note that `<gio/gunixconnection.h>` belongs to the UNIX-specific
42 * GIO interfaces, thus you have to use the `gio-unix-2.0.pc`
43 * pkg-config file when using it.
44 */
45public class UnixConnection : SocketConnection
46{
47        /** the main Gtk struct */
48        protected GUnixConnection* gUnixConnection;
49
50        /** Get the main Gtk struct */
51        public GUnixConnection* getUnixConnectionStruct()
52        {
53                return gUnixConnection;
54        }
55
56        /** the main Gtk struct as a void* */
57        protected override void* getStruct()
58        {
59                return cast(void*)gUnixConnection;
60        }
61
62        protected override void setStruct(GObject* obj)
63        {
64                gUnixConnection = cast(GUnixConnection*)obj;
65                super.setStruct(obj);
66        }
67
68        /**
69         * Sets our main struct and passes it to the parent class.
70         */
71        public this (GUnixConnection* gUnixConnection, bool ownedRef = false)
72        {
73                this.gUnixConnection = gUnixConnection;
74                super(cast(GSocketConnection*)gUnixConnection, ownedRef);
75        }
76
77
78        /** */
79        public static GType getType()
80        {
81                return g_unix_connection_get_type();
82        }
83
84        /**
85         * Receives credentials from the sending end of the connection.  The
86         * sending end has to call g_unix_connection_send_credentials() (or
87         * similar) for this to work.
88         *
89         * As well as reading the credentials this also reads (and discards) a
90         * single byte from the stream, as this is required for credentials
91         * passing to work on some implementations.
92         *
93         * Other ways to exchange credentials with a foreign peer includes the
94         * #GUnixCredentialsMessage type and g_socket_get_credentials() function.
95         *
96         * Params:
97         *     cancellable = A #GCancellable or %NULL.
98         *
99         * Returns: Received credentials on success (free with
100         *     g_object_unref()), %NULL if @error is set.
101         *
102         * Since: 2.26
103         *
104         * Throws: GException on failure.
105         */
106        public Credentials receiveCredentials(Cancellable cancellable)
107        {
108                GError* err = null;
109               
110                auto p = g_unix_connection_receive_credentials(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
111               
112                if (err !is null)
113                {
114                        throw new GException( new ErrorG(err) );
115                }
116               
117                if(p is null)
118                {
119                        return null;
120                }
121               
122                return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p, true);
123        }
124
125        /**
126         * Asynchronously receive credentials.
127         *
128         * For more details, see g_unix_connection_receive_credentials() which is
129         * the synchronous version of this call.
130         *
131         * When the operation is finished, @callback will be called. You can then call
132         * g_unix_connection_receive_credentials_finish() to get the result of the operation.
133         *
134         * Params:
135         *     cancellable = optional #GCancellable object, %NULL to ignore.
136         *     callback = a #GAsyncReadyCallback to call when the request is satisfied
137         *     userData = the data to pass to callback function
138         *
139         * Since: 2.32
140         */
141        public void receiveCredentialsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
142        {
143                g_unix_connection_receive_credentials_async(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
144        }
145
146        /**
147         * Finishes an asynchronous receive credentials operation started with
148         * g_unix_connection_receive_credentials_async().
149         *
150         * Params:
151         *     result = a #GAsyncResult.
152         *
153         * Returns: a #GCredentials, or %NULL on error.
154         *     Free the returned object with g_object_unref().
155         *
156         * Since: 2.32
157         *
158         * Throws: GException on failure.
159         */
160        public Credentials receiveCredentialsFinish(AsyncResultIF result)
161        {
162                GError* err = null;
163               
164                auto p = g_unix_connection_receive_credentials_finish(gUnixConnection, (result is null) ? null : result.getAsyncResultStruct(), &err);
165               
166                if (err !is null)
167                {
168                        throw new GException( new ErrorG(err) );
169                }
170               
171                if(p is null)
172                {
173                        return null;
174                }
175               
176                return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p, true);
177        }
178
179        /**
180         * Receives a file descriptor from the sending end of the connection.
181         * The sending end has to call g_unix_connection_send_fd() for this
182         * to work.
183         *
184         * As well as reading the fd this also reads a single byte from the
185         * stream, as this is required for fd passing to work on some
186         * implementations.
187         *
188         * Params:
189         *     cancellable = optional #GCancellable object, %NULL to ignore
190         *
191         * Returns: a file descriptor on success, -1 on error.
192         *
193         * Since: 2.22
194         *
195         * Throws: GException on failure.
196         */
197        public int receiveFd(Cancellable cancellable)
198        {
199                GError* err = null;
200               
201                auto p = g_unix_connection_receive_fd(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
202               
203                if (err !is null)
204                {
205                        throw new GException( new ErrorG(err) );
206                }
207               
208                return p;
209        }
210
211        /**
212         * Passes the credentials of the current user the receiving side
213         * of the connection. The receiving end has to call
214         * g_unix_connection_receive_credentials() (or similar) to accept the
215         * credentials.
216         *
217         * As well as sending the credentials this also writes a single NUL
218         * byte to the stream, as this is required for credentials passing to
219         * work on some implementations.
220         *
221         * Other ways to exchange credentials with a foreign peer includes the
222         * #GUnixCredentialsMessage type and g_socket_get_credentials() function.
223         *
224         * Params:
225         *     cancellable = A #GCancellable or %NULL.
226         *
227         * Returns: %TRUE on success, %FALSE if @error is set.
228         *
229         * Since: 2.26
230         *
231         * Throws: GException on failure.
232         */
233        public bool sendCredentials(Cancellable cancellable)
234        {
235                GError* err = null;
236               
237                auto p = g_unix_connection_send_credentials(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
238               
239                if (err !is null)
240                {
241                        throw new GException( new ErrorG(err) );
242                }
243               
244                return p;
245        }
246
247        /**
248         * Asynchronously send credentials.
249         *
250         * For more details, see g_unix_connection_send_credentials() which is
251         * the synchronous version of this call.
252         *
253         * When the operation is finished, @callback will be called. You can then call
254         * g_unix_connection_send_credentials_finish() to get the result of the operation.
255         *
256         * Params:
257         *     cancellable = optional #GCancellable object, %NULL to ignore.
258         *     callback = a #GAsyncReadyCallback to call when the request is satisfied
259         *     userData = the data to pass to callback function
260         *
261         * Since: 2.32
262         */
263        public void sendCredentialsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
264        {
265                g_unix_connection_send_credentials_async(gUnixConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
266        }
267
268        /**
269         * Finishes an asynchronous send credentials operation started with
270         * g_unix_connection_send_credentials_async().
271         *
272         * Params:
273         *     result = a #GAsyncResult.
274         *
275         * Returns: %TRUE if the operation was successful, otherwise %FALSE.
276         *
277         * Since: 2.32
278         *
279         * Throws: GException on failure.
280         */
281        public bool sendCredentialsFinish(AsyncResultIF result)
282        {
283                GError* err = null;
284               
285                auto p = g_unix_connection_send_credentials_finish(gUnixConnection, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
286               
287                if (err !is null)
288                {
289                        throw new GException( new ErrorG(err) );
290                }
291               
292                return p;
293        }
294
295        /**
296         * Passes a file descriptor to the receiving side of the
297         * connection. The receiving end has to call g_unix_connection_receive_fd()
298         * to accept the file descriptor.
299         *
300         * As well as sending the fd this also writes a single byte to the
301         * stream, as this is required for fd passing to work on some
302         * implementations.
303         *
304         * Params:
305         *     fd = a file descriptor
306         *     cancellable = optional #GCancellable object, %NULL to ignore.
307         *
308         * Returns: a %TRUE on success, %NULL on error.
309         *
310         * Since: 2.22
311         *
312         * Throws: GException on failure.
313         */
314        public bool sendFd(int fd, Cancellable cancellable)
315        {
316                GError* err = null;
317               
318                auto p = g_unix_connection_send_fd(gUnixConnection, fd, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
319               
320                if (err !is null)
321                {
322                        throw new GException( new ErrorG(err) );
323                }
324               
325                return p;
326        }
327}
Note: See TracBrowser for help on using the repository browser.