1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GUnixSocketAddress.html
27  * outPack = gio
28  * outFile = UnixSocketAddress
29  * strct   = GUnixSocketAddress
30  * realStrct=
31  * ctorStrct=GSocketAddress
32  * clss    = UnixSocketAddress
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_unix_socket_address_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gio.UnixSocketAddress;
54 
55 public  import gtkc.giotypes;
56 
57 private import gtkc.gio;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 
62 private import glib.Str;
63 
64 
65 
66 private import gio.SocketAddress;
67 
68 /**
69  * Support for UNIX-domain (also known as local) sockets.
70  *
71  * UNIX domain sockets are generally visible in the filesystem.
72  * However, some systems support abstract socket names which are not
73  * visible in the filesystem and not affected by the filesystem
74  * permissions, visibility, etc. Currently this is only supported
75  * under Linux. If you attempt to use abstract sockets on other
76  * systems, function calls may return G_IO_ERROR_NOT_SUPPORTED
77  * errors. You can use g_unix_socket_address_abstract_names_supported()
78  * to see if abstract names are supported.
79  *
80  * Note that <gio/gunixsocketaddress.h> belongs to
81  * the UNIX-specific GIO interfaces, thus you have to use the
82  * gio-unix-2.0.pc pkg-config file when using it.
83  */
84 public class UnixSocketAddress : SocketAddress
85 {
86 	
87 	/** the main Gtk struct */
88 	protected GUnixSocketAddress* gUnixSocketAddress;
89 	
90 	
91 	public GUnixSocketAddress* getUnixSocketAddressStruct()
92 	{
93 		return gUnixSocketAddress;
94 	}
95 	
96 	
97 	/** the main Gtk struct as a void* */
98 	protected override void* getStruct()
99 	{
100 		return cast(void*)gUnixSocketAddress;
101 	}
102 	
103 	/**
104 	 * Sets our main struct and passes it to the parent class
105 	 */
106 	public this (GUnixSocketAddress* gUnixSocketAddress)
107 	{
108 		super(cast(GSocketAddress*)gUnixSocketAddress);
109 		this.gUnixSocketAddress = gUnixSocketAddress;
110 	}
111 	
112 	protected override void setStruct(GObject* obj)
113 	{
114 		super.setStruct(obj);
115 		gUnixSocketAddress = cast(GUnixSocketAddress*)obj;
116 	}
117 	
118 	/**
119 	 */
120 	
121 	/**
122 	 * Creates a new GUnixSocketAddress for path.
123 	 * To create abstract socket addresses, on systems that support that,
124 	 * use g_unix_socket_address_new_abstract().
125 	 * Since 2.22
126 	 * Params:
127 	 * path = the socket path
128 	 * Throws: ConstructionException GTK+ fails to create the object.
129 	 */
130 	public this (string path)
131 	{
132 		// GSocketAddress * g_unix_socket_address_new (const gchar *path);
133 		auto p = g_unix_socket_address_new(Str.toStringz(path));
134 		if(p is null)
135 		{
136 			throw new ConstructionException("null returned by g_unix_socket_address_new(Str.toStringz(path))");
137 		}
138 		this(cast(GUnixSocketAddress*) p);
139 	}
140 	
141 	/**
142 	 * Warning
143 	 * g_unix_socket_address_new_abstract is deprecated and should not be used in newly-written code. Use g_unix_socket_address_new_with_type().
144 	 * Creates a new G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED
145 	 * GUnixSocketAddress for path.
146 	 * Params:
147 	 * path = the abstract name. [array length=path_len][element-type gchar]
148 	 * pathLen = the length of path, or -1
149 	 * Throws: ConstructionException GTK+ fails to create the object.
150 	 */
151 	public this (string path, int pathLen)
152 	{
153 		// GSocketAddress * g_unix_socket_address_new_abstract (const gchar *path,  gint path_len);
154 		auto p = g_unix_socket_address_new_abstract(Str.toStringz(path), pathLen);
155 		if(p is null)
156 		{
157 			throw new ConstructionException("null returned by g_unix_socket_address_new_abstract(Str.toStringz(path), pathLen)");
158 		}
159 		this(cast(GUnixSocketAddress*) p);
160 	}
161 	
162 	/**
163 	 * Creates a new GUnixSocketAddress of type type with name path.
164 	 * If type is G_UNIX_SOCKET_ADDRESS_PATH, this is equivalent to
165 	 * calling g_unix_socket_address_new().
166 	 * If path_type is G_UNIX_SOCKET_ADDRESS_ABSTRACT, then path_len
167 	 * bytes of path will be copied to the socket's path, and only those
168 	 * bytes will be considered part of the name. (If path_len is -1,
169 	 * then path is assumed to be NUL-terminated.) For example, if path
170 	 * was "test", then calling g_socket_address_get_native_size() on the
171 	 * returned socket would return 7 (2 bytes of overhead, 1 byte for the
172 	 * abstract-socket indicator byte, and 4 bytes for the name "test").
173 	 * If path_type is G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, then
174 	 * path_len bytes of path will be copied to the socket's path, the
175 	 * rest of the path will be padded with 0 bytes, and the entire
176 	 * zero-padded buffer will be considered the name. (As above, if
177 	 * path_len is -1, then path is assumed to be NUL-terminated.) In
178 	 * this case, g_socket_address_get_native_size() will always return
179 	 * the full size of a struct sockaddr_un, although
180 	 * g_unix_socket_address_get_path_len() will still return just the
181 	 * length of path.
182 	 * G_UNIX_SOCKET_ADDRESS_ABSTRACT is preferred over
183 	 * G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED for new programs. Of course,
184 	 * when connecting to a server created by another process, you must
185 	 * use the appropriate type corresponding to how that process created
186 	 * its listening socket.
187 	 * Since 2.26
188 	 * Params:
189 	 * path = the name. [array length=path_len][element-type gchar]
190 	 * type = a GUnixSocketAddressType
191 	 * Throws: ConstructionException GTK+ fails to create the object.
192 	 */
193 	public this (string path, GUnixSocketAddressType type)
194 	{
195 		// GSocketAddress * g_unix_socket_address_new_with_type (const gchar *path,  gint path_len,  GUnixSocketAddressType type);
196 		auto p = g_unix_socket_address_new_with_type(cast(char*)path.ptr, cast(int) path.length, type);
197 		if(p is null)
198 		{
199 			throw new ConstructionException("null returned by g_unix_socket_address_new_with_type(cast(char*)path.ptr, cast(int) path.length, type)");
200 		}
201 		this(cast(GUnixSocketAddress*) p);
202 	}
203 	
204 	/**
205 	 * Warning
206 	 * g_unix_socket_address_get_is_abstract is deprecated and should not be used in newly-written code. Use g_unix_socket_address_get_address_type()
207 	 * Tests if address is abstract.
208 	 * Since 2.22
209 	 * Returns: TRUE if the address is abstract, FALSE otherwise
210 	 */
211 	public int getIsAbstract()
212 	{
213 		// gboolean g_unix_socket_address_get_is_abstract  (GUnixSocketAddress *address);
214 		return g_unix_socket_address_get_is_abstract(gUnixSocketAddress);
215 	}
216 	
217 	/**
218 	 * Gets address's type.
219 	 * Since 2.26
220 	 * Returns: a GUnixSocketAddressType
221 	 */
222 	public GUnixSocketAddressType getAddressType()
223 	{
224 		// GUnixSocketAddressType g_unix_socket_address_get_address_type  (GUnixSocketAddress *address);
225 		return g_unix_socket_address_get_address_type(gUnixSocketAddress);
226 	}
227 	
228 	/**
229 	 * Gets address's path, or for abstract sockets the "name".
230 	 * Guaranteed to be zero-terminated, but an abstract socket
231 	 * may contain embedded zeros, and thus you should use
232 	 * g_unix_socket_address_get_path_len() to get the true length
233 	 * of this string.
234 	 * Since 2.22
235 	 * Returns: the path for address
236 	 */
237 	public string getPath()
238 	{
239 		// const char * g_unix_socket_address_get_path (GUnixSocketAddress *address);
240 		return Str.toString(g_unix_socket_address_get_path(gUnixSocketAddress));
241 	}
242 	
243 	/**
244 	 * Gets the length of address's path.
245 	 * For details, see g_unix_socket_address_get_path().
246 	 * Since 2.22
247 	 * Returns: the length of the path
248 	 */
249 	public gsize getPathLen()
250 	{
251 		// gsize g_unix_socket_address_get_path_len (GUnixSocketAddress *address);
252 		return g_unix_socket_address_get_path_len(gUnixSocketAddress);
253 	}
254 	
255 	/**
256 	 * Checks if abstract UNIX domain socket names are supported.
257 	 * Since 2.22
258 	 * Returns: TRUE if supported, FALSE otherwise
259 	 */
260 	public static int abstractNamesSupported()
261 	{
262 		// gboolean g_unix_socket_address_abstract_names_supported  (void);
263 		return g_unix_socket_address_abstract_names_supported();
264 	}
265 }