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

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

Initial release

File size: 6.6 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.UnixSocketAddress;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.SocketAddress;
26private import glib.ConstructionException;
27private import glib.Str;
28private import gobject.ObjectG;
29
30
31/**
32 * Support for UNIX-domain (also known as local) sockets.
33 *
34 * UNIX domain sockets are generally visible in the filesystem.
35 * However, some systems support abstract socket names which are not
36 * visible in the filesystem and not affected by the filesystem
37 * permissions, visibility, etc. Currently this is only supported
38 * under Linux. If you attempt to use abstract sockets on other
39 * systems, function calls may return %G_IO_ERROR_NOT_SUPPORTED
40 * errors. You can use g_unix_socket_address_abstract_names_supported()
41 * to see if abstract names are supported.
42 *
43 * Note that `<gio/gunixsocketaddress.h>` belongs to the UNIX-specific GIO
44 * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config file
45 * when using it.
46 */
47public class UnixSocketAddress : SocketAddress
48{
49        /** the main Gtk struct */
50        protected GUnixSocketAddress* gUnixSocketAddress;
51
52        /** Get the main Gtk struct */
53        public GUnixSocketAddress* getUnixSocketAddressStruct()
54        {
55                return gUnixSocketAddress;
56        }
57
58        /** the main Gtk struct as a void* */
59        protected override void* getStruct()
60        {
61                return cast(void*)gUnixSocketAddress;
62        }
63
64        protected override void setStruct(GObject* obj)
65        {
66                gUnixSocketAddress = cast(GUnixSocketAddress*)obj;
67                super.setStruct(obj);
68        }
69
70        /**
71         * Sets our main struct and passes it to the parent class.
72         */
73        public this (GUnixSocketAddress* gUnixSocketAddress, bool ownedRef = false)
74        {
75                this.gUnixSocketAddress = gUnixSocketAddress;
76                super(cast(GSocketAddress*)gUnixSocketAddress, ownedRef);
77        }
78
79
80        /** */
81        public static GType getType()
82        {
83                return g_unix_socket_address_get_type();
84        }
85
86        /**
87         * Creates a new #GUnixSocketAddress for @path.
88         *
89         * To create abstract socket addresses, on systems that support that,
90         * use g_unix_socket_address_new_abstract().
91         *
92         * Params:
93         *     path = the socket path
94         *
95         * Returns: a new #GUnixSocketAddress
96         *
97         * Since: 2.22
98         *
99         * Throws: ConstructionException GTK+ fails to create the object.
100         */
101        public this(string path)
102        {
103                auto p = g_unix_socket_address_new(Str.toStringz(path));
104               
105                if(p is null)
106                {
107                        throw new ConstructionException("null returned by new");
108                }
109               
110                this(cast(GUnixSocketAddress*) p, true);
111        }
112
113        /**
114         * Creates a new #GUnixSocketAddress of type @type with name @path.
115         *
116         * If @type is %G_UNIX_SOCKET_ADDRESS_PATH, this is equivalent to
117         * calling g_unix_socket_address_new().
118         *
119         * If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT, then @path_len
120         * bytes of @path will be copied to the socket's path, and only those
121         * bytes will be considered part of the name. (If @path_len is -1,
122         * then @path is assumed to be NUL-terminated.) For example, if @path
123         * was "test", then calling g_socket_address_get_native_size() on the
124         * returned socket would return 7 (2 bytes of overhead, 1 byte for the
125         * abstract-socket indicator byte, and 4 bytes for the name "test").
126         *
127         * If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, then
128         * @path_len bytes of @path will be copied to the socket's path, the
129         * rest of the path will be padded with 0 bytes, and the entire
130         * zero-padded buffer will be considered the name. (As above, if
131         * @path_len is -1, then @path is assumed to be NUL-terminated.) In
132         * this case, g_socket_address_get_native_size() will always return
133         * the full size of a `struct sockaddr_un`, although
134         * g_unix_socket_address_get_path_len() will still return just the
135         * length of @path.
136         *
137         * %G_UNIX_SOCKET_ADDRESS_ABSTRACT is preferred over
138         * %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED for new programs. Of course,
139         * when connecting to a server created by another process, you must
140         * use the appropriate type corresponding to how that process created
141         * its listening socket.
142         *
143         * Params:
144         *     path = the name
145         *     pathLen = the length of @path, or -1
146         *     type = a #GUnixSocketAddressType
147         *
148         * Returns: a new #GUnixSocketAddress
149         *
150         * Since: 2.26
151         *
152         * Throws: ConstructionException GTK+ fails to create the object.
153         */
154        public this(string path, GUnixSocketAddressType type)
155        {
156                auto p = g_unix_socket_address_new_with_type(Str.toStringz(path), cast(int)path.length, type);
157               
158                if(p is null)
159                {
160                        throw new ConstructionException("null returned by new_with_type");
161                }
162               
163                this(cast(GUnixSocketAddress*) p, true);
164        }
165
166        /**
167         * Checks if abstract UNIX domain socket names are supported.
168         *
169         * Returns: %TRUE if supported, %FALSE otherwise
170         *
171         * Since: 2.22
172         */
173        public static bool abstractNamesSupported()
174        {
175                return g_unix_socket_address_abstract_names_supported() != 0;
176        }
177
178        /**
179         * Gets @address's type.
180         *
181         * Returns: a #GUnixSocketAddressType
182         *
183         * Since: 2.26
184         */
185        public GUnixSocketAddressType getAddressType()
186        {
187                return g_unix_socket_address_get_address_type(gUnixSocketAddress);
188        }
189
190        /**
191         * Tests if @address is abstract.
192         *
193         * Deprecated: Use g_unix_socket_address_get_address_type()
194         *
195         * Returns: %TRUE if the address is abstract, %FALSE otherwise
196         *
197         * Since: 2.22
198         */
199        public bool getIsAbstract()
200        {
201                return g_unix_socket_address_get_is_abstract(gUnixSocketAddress) != 0;
202        }
203
204        /**
205         * Gets @address's path, or for abstract sockets the "name".
206         *
207         * Guaranteed to be zero-terminated, but an abstract socket
208         * may contain embedded zeros, and thus you should use
209         * g_unix_socket_address_get_path_len() to get the true length
210         * of this string.
211         *
212         * Returns: the path for @address
213         *
214         * Since: 2.22
215         */
216        public string getPath()
217        {
218                return Str.toString(g_unix_socket_address_get_path(gUnixSocketAddress));
219        }
220
221        /**
222         * Gets the length of @address's path.
223         *
224         * For details, see g_unix_socket_address_get_path().
225         *
226         * Returns: the length of the path
227         *
228         * Since: 2.22
229         */
230        public size_t getPathLen()
231        {
232                return g_unix_socket_address_get_path_len(gUnixSocketAddress);
233        }
234}
Note: See TracBrowser for help on using the repository browser.