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  * Description
70  * Support for UNIX-domain (also known as local) sockets.
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  * Note that <gio/gunixsocketaddress.h> belongs to
80  * the UNIX-specific GIO interfaces, thus you have to use the
81  * gio-unix-2.0.pc pkg-config file when using it.
82  */
83 public class UnixSocketAddress : SocketAddress
84 {
85 	
86 	/** the main Gtk struct */
87 	protected GUnixSocketAddress* gUnixSocketAddress;
88 	
89 	
90 	public GUnixSocketAddress* getUnixSocketAddressStruct()
91 	{
92 		return gUnixSocketAddress;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected override void* getStruct()
98 	{
99 		return cast(void*)gUnixSocketAddress;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (GUnixSocketAddress* gUnixSocketAddress)
106 	{
107 		super(cast(GSocketAddress*)gUnixSocketAddress);
108 		this.gUnixSocketAddress = gUnixSocketAddress;
109 	}
110 	
111 	protected override void setStruct(GObject* obj)
112 	{
113 		super.setStruct(obj);
114 		gUnixSocketAddress = cast(GUnixSocketAddress*)obj;
115 	}
116 	
117 	/**
118 	 */
119 	
120 	/**
121 	 * Creates a new GUnixSocketAddress for path.
122 	 * To create abstract socket addresses, on systems that support that,
123 	 * use g_unix_socket_address_new_abstract().
124 	 * Since 2.22
125 	 * Params:
126 	 * path = the socket path
127 	 * Throws: ConstructionException GTK+ fails to create the object.
128 	 */
129 	public this (string path)
130 	{
131 		// GSocketAddress * g_unix_socket_address_new (const gchar *path);
132 		auto p = g_unix_socket_address_new(Str.toStringz(path));
133 		if(p is null)
134 		{
135 			throw new ConstructionException("null returned by g_unix_socket_address_new(Str.toStringz(path))");
136 		}
137 		this(cast(GUnixSocketAddress*) p);
138 	}
139 	
140 	/**
141 	 * Warning
142 	 * 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().
143 	 * Creates a new G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED
144 	 * GUnixSocketAddress for path.
145 	 * Params:
146 	 * path = the abstract name. [array length=path_len][element-type gchar]
147 	 * pathLen = the length of path, or -1
148 	 * Throws: ConstructionException GTK+ fails to create the object.
149 	 */
150 	public this (string path, int pathLen)
151 	{
152 		// GSocketAddress * g_unix_socket_address_new_abstract (const gchar *path,  gint path_len);
153 		auto p = g_unix_socket_address_new_abstract(Str.toStringz(path), pathLen);
154 		if(p is null)
155 		{
156 			throw new ConstructionException("null returned by g_unix_socket_address_new_abstract(Str.toStringz(path), pathLen)");
157 		}
158 		this(cast(GUnixSocketAddress*) p);
159 	}
160 	
161 	/**
162 	 * Creates a new GUnixSocketAddress of type type with name path.
163 	 * If type is G_UNIX_SOCKET_ADDRESS_PATH, this is equivalent to
164 	 * calling g_unix_socket_address_new().
165 	 * If path_type is G_UNIX_SOCKET_ADDRESS_ABSTRACT, then path_len
166 	 * bytes of path will be copied to the socket's path, and only those
167 	 * bytes will be considered part of the name. (If path_len is -1,
168 	 * then path is assumed to be NUL-terminated.) For example, if path
169 	 * was "test", then calling g_socket_address_get_native_size() on the
170 	 * returned socket would return 7 (2 bytes of overhead, 1 byte for the
171 	 * abstract-socket indicator byte, and 4 bytes for the name "test").
172 	 * If path_type is G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, then
173 	 * path_len bytes of path will be copied to the socket's path, the
174 	 * rest of the path will be padded with 0 bytes, and the entire
175 	 * zero-padded buffer will be considered the name. (As above, if
176 	 * path_len is -1, then path is assumed to be NUL-terminated.) In
177 	 * this case, g_socket_address_get_native_size() will always return
178 	 * the full size of a struct sockaddr_un, although
179 	 * g_unix_socket_address_get_path_len() will still return just the
180 	 * length of path.
181 	 * G_UNIX_SOCKET_ADDRESS_ABSTRACT is preferred over
182 	 * G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED for new programs. Of course,
183 	 * when connecting to a server created by another process, you must
184 	 * use the appropriate type corresponding to how that process created
185 	 * its listening socket.
186 	 * Since 2.26
187 	 * Params:
188 	 * path = the name. [array length=path_len][element-type gchar]
189 	 * type = a GUnixSocketAddressType
190 	 * Throws: ConstructionException GTK+ fails to create the object.
191 	 */
192 	public this (string path, GUnixSocketAddressType type)
193 	{
194 		// GSocketAddress * g_unix_socket_address_new_with_type (const gchar *path,  gint path_len,  GUnixSocketAddressType type);
195 		auto p = g_unix_socket_address_new_with_type(cast(char*)path.ptr, cast(int) path.length, type);
196 		if(p is null)
197 		{
198 			throw new ConstructionException("null returned by g_unix_socket_address_new_with_type(cast(char*)path.ptr, cast(int) path.length, type)");
199 		}
200 		this(cast(GUnixSocketAddress*) p);
201 	}
202 	
203 	/**
204 	 * Warning
205 	 * 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()
206 	 * Tests if address is abstract.
207 	 * Since 2.22
208 	 * Returns: TRUE if the address is abstract, FALSE otherwise
209 	 */
210 	public int getIsAbstract()
211 	{
212 		// gboolean g_unix_socket_address_get_is_abstract  (GUnixSocketAddress *address);
213 		return g_unix_socket_address_get_is_abstract(gUnixSocketAddress);
214 	}
215 	
216 	/**
217 	 * Gets address's type.
218 	 * Since 2.26
219 	 * Returns: a GUnixSocketAddressType
220 	 */
221 	public GUnixSocketAddressType getAddressType()
222 	{
223 		// GUnixSocketAddressType g_unix_socket_address_get_address_type  (GUnixSocketAddress *address);
224 		return g_unix_socket_address_get_address_type(gUnixSocketAddress);
225 	}
226 	
227 	/**
228 	 * Gets address's path, or for abstract sockets the "name".
229 	 * Guaranteed to be zero-terminated, but an abstract socket
230 	 * may contain embedded zeros, and thus you should use
231 	 * g_unix_socket_address_get_path_len() to get the true length
232 	 * of this string.
233 	 * Since 2.22
234 	 * Returns: the path for address
235 	 */
236 	public string getPath()
237 	{
238 		// const char * g_unix_socket_address_get_path (GUnixSocketAddress *address);
239 		return Str.toString(g_unix_socket_address_get_path(gUnixSocketAddress));
240 	}
241 	
242 	/**
243 	 * Gets the length of address's path.
244 	 * For details, see g_unix_socket_address_get_path().
245 	 * Since 2.22
246 	 * Returns: the length of the path
247 	 */
248 	public gsize getPathLen()
249 	{
250 		// gsize g_unix_socket_address_get_path_len (GUnixSocketAddress *address);
251 		return g_unix_socket_address_get_path_len(gUnixSocketAddress);
252 	}
253 	
254 	/**
255 	 * Checks if abstract unix domain socket names are supported.
256 	 * Since 2.22
257 	 * Returns: TRUE if supported, FALSE otherwise
258 	 */
259 	public static int abstractNamesSupported()
260 	{
261 		// gboolean g_unix_socket_address_abstract_names_supported  (void);
262 		return g_unix_socket_address_abstract_names_supported();
263 	}
264 }