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 module gio.SocketClient;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import gio.IOStream;
30 private import gio.ProxyResolver;
31 private import gio.ProxyResolverIF;
32 private import gio.SocketAddress;
33 private import gio.SocketConnectable;
34 private import gio.SocketConnectableIF;
35 private import gio.SocketConnection;
36 private import glib.ConstructionException;
37 private import glib.ErrorG;
38 private import glib.GException;
39 private import glib.Str;
40 private import gobject.ObjectG;
41 private import gobject.Signals;
42 public  import gtkc.gdktypes;
43 private import gtkc.gio;
44 public  import gtkc.giotypes;
45 
46 
47 /**
48  * #GSocketClient is a lightweight high-level utility class for connecting to
49  * a network host using a connection oriented socket type.
50  * 
51  * You create a #GSocketClient object, set any options you want, and then
52  * call a sync or async connect operation, which returns a #GSocketConnection
53  * subclass on success.
54  * 
55  * The type of the #GSocketConnection object returned depends on the type of
56  * the underlying socket that is in use. For instance, for a TCP/IP connection
57  * it will be a #GTcpConnection.
58  * 
59  * As #GSocketClient is a lightweight object, you don't need to cache it. You
60  * can just create a new one any time you need one.
61  *
62  * Since: 2.22
63  */
64 public class SocketClient : ObjectG
65 {
66 	/** the main Gtk struct */
67 	protected GSocketClient* gSocketClient;
68 
69 	/** Get the main Gtk struct */
70 	public GSocketClient* getSocketClientStruct()
71 	{
72 		return gSocketClient;
73 	}
74 
75 	/** the main Gtk struct as a void* */
76 	protected override void* getStruct()
77 	{
78 		return cast(void*)gSocketClient;
79 	}
80 
81 	protected override void setStruct(GObject* obj)
82 	{
83 		gSocketClient = cast(GSocketClient*)obj;
84 		super.setStruct(obj);
85 	}
86 
87 	/**
88 	 * Sets our main struct and passes it to the parent class.
89 	 */
90 	public this (GSocketClient* gSocketClient, bool ownedRef = false)
91 	{
92 		this.gSocketClient = gSocketClient;
93 		super(cast(GObject*)gSocketClient, ownedRef);
94 	}
95 
96 
97 	/** */
98 	public static GType getType()
99 	{
100 		return g_socket_client_get_type();
101 	}
102 
103 	/**
104 	 * Creates a new #GSocketClient with the default options.
105 	 *
106 	 * Return: a #GSocketClient.
107 	 *     Free the returned object with g_object_unref().
108 	 *
109 	 * Since: 2.22
110 	 *
111 	 * Throws: ConstructionException GTK+ fails to create the object.
112 	 */
113 	public this()
114 	{
115 		auto p = g_socket_client_new();
116 		
117 		if(p is null)
118 		{
119 			throw new ConstructionException("null returned by new");
120 		}
121 		
122 		this(cast(GSocketClient*) p, true);
123 	}
124 
125 	/**
126 	 * Enable proxy protocols to be handled by the application. When the
127 	 * indicated proxy protocol is returned by the #GProxyResolver,
128 	 * #GSocketClient will consider this protocol as supported but will
129 	 * not try to find a #GProxy instance to handle handshaking. The
130 	 * application must check for this case by calling
131 	 * g_socket_connection_get_remote_address() on the returned
132 	 * #GSocketConnection, and seeing if it's a #GProxyAddress of the
133 	 * appropriate type, to determine whether or not it needs to handle
134 	 * the proxy handshaking itself.
135 	 *
136 	 * This should be used for proxy protocols that are dialects of
137 	 * another protocol such as HTTP proxy. It also allows cohabitation of
138 	 * proxy protocols that are reused between protocols. A good example
139 	 * is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also
140 	 * be use as generic socket proxy through the HTTP CONNECT method.
141 	 *
142 	 * When the proxy is detected as being an application proxy, TLS handshake
143 	 * will be skipped. This is required to let the application do the proxy
144 	 * specific handshake.
145 	 *
146 	 * Params:
147 	 *     protocol = The proxy protocol
148 	 */
149 	public void addApplicationProxy(string protocol)
150 	{
151 		g_socket_client_add_application_proxy(gSocketClient, Str.toStringz(protocol));
152 	}
153 
154 	/**
155 	 * Tries to resolve the @connectable and make a network connection to it.
156 	 *
157 	 * Upon a successful connection, a new #GSocketConnection is constructed
158 	 * and returned.  The caller owns this new object and must drop their
159 	 * reference to it when finished with it.
160 	 *
161 	 * The type of the #GSocketConnection object returned depends on the type of
162 	 * the underlying socket that is used. For instance, for a TCP/IP connection
163 	 * it will be a #GTcpConnection.
164 	 *
165 	 * The socket created will be the same family as the address that the
166 	 * @connectable resolves to, unless family is set with g_socket_client_set_family()
167 	 * or indirectly via g_socket_client_set_local_address(). The socket type
168 	 * defaults to %G_SOCKET_TYPE_STREAM but can be set with
169 	 * g_socket_client_set_socket_type().
170 	 *
171 	 * If a local address is specified with g_socket_client_set_local_address() the
172 	 * socket will be bound to this address before connecting.
173 	 *
174 	 * Params:
175 	 *     connectable = a #GSocketConnectable specifying the remote address.
176 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
177 	 *
178 	 * Return: a #GSocketConnection on success, %NULL on error.
179 	 *
180 	 * Since: 2.22
181 	 *
182 	 * Throws: GException on failure.
183 	 */
184 	public SocketConnection connect(SocketConnectableIF connectable, Cancellable cancellable)
185 	{
186 		GError* err = null;
187 		
188 		auto p = g_socket_client_connect(gSocketClient, (connectable is null) ? null : connectable.getSocketConnectableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
189 		
190 		if (err !is null)
191 		{
192 			throw new GException( new ErrorG(err) );
193 		}
194 		
195 		if(p is null)
196 		{
197 			return null;
198 		}
199 		
200 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
201 	}
202 
203 	/**
204 	 * This is the asynchronous version of g_socket_client_connect().
205 	 *
206 	 * When the operation is finished @callback will be
207 	 * called. You can then call g_socket_client_connect_finish() to get
208 	 * the result of the operation.
209 	 *
210 	 * Params:
211 	 *     connectable = a #GSocketConnectable specifying the remote address.
212 	 *     cancellable = a #GCancellable, or %NULL
213 	 *     callback = a #GAsyncReadyCallback
214 	 *     userData = user data for the callback
215 	 *
216 	 * Since: 2.22
217 	 */
218 	public void connectAsync(SocketConnectableIF connectable, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
219 	{
220 		g_socket_client_connect_async(gSocketClient, (connectable is null) ? null : connectable.getSocketConnectableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
221 	}
222 
223 	/**
224 	 * Finishes an async connect operation. See g_socket_client_connect_async()
225 	 *
226 	 * Params:
227 	 *     result = a #GAsyncResult.
228 	 *
229 	 * Return: a #GSocketConnection on success, %NULL on error.
230 	 *
231 	 * Since: 2.22
232 	 *
233 	 * Throws: GException on failure.
234 	 */
235 	public SocketConnection connectFinish(AsyncResultIF result)
236 	{
237 		GError* err = null;
238 		
239 		auto p = g_socket_client_connect_finish(gSocketClient, (result is null) ? null : result.getAsyncResultStruct(), &err);
240 		
241 		if (err !is null)
242 		{
243 			throw new GException( new ErrorG(err) );
244 		}
245 		
246 		if(p is null)
247 		{
248 			return null;
249 		}
250 		
251 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
252 	}
253 
254 	/**
255 	 * This is a helper function for g_socket_client_connect().
256 	 *
257 	 * Attempts to create a TCP connection to the named host.
258 	 *
259 	 * @host_and_port may be in any of a number of recognized formats; an IPv6
260 	 * address, an IPv4 address, or a domain name (in which case a DNS
261 	 * lookup is performed).  Quoting with [] is supported for all address
262 	 * types.  A port override may be specified in the usual way with a
263 	 * colon.  Ports may be given as decimal numbers or symbolic names (in
264 	 * which case an /etc/services lookup is performed).
265 	 *
266 	 * If no port override is given in @host_and_port then @default_port will be
267 	 * used as the port number to connect to.
268 	 *
269 	 * In general, @host_and_port is expected to be provided by the user (allowing
270 	 * them to give the hostname, and a port override if necessary) and
271 	 * @default_port is expected to be provided by the application.
272 	 *
273 	 * In the case that an IP address is given, a single connection
274 	 * attempt is made.  In the case that a name is given, multiple
275 	 * connection attempts may be made, in turn and according to the
276 	 * number of address records in DNS, until a connection succeeds.
277 	 *
278 	 * Upon a successful connection, a new #GSocketConnection is constructed
279 	 * and returned.  The caller owns this new object and must drop their
280 	 * reference to it when finished with it.
281 	 *
282 	 * In the event of any failure (DNS error, service not found, no hosts
283 	 * connectable) %NULL is returned and @error (if non-%NULL) is set
284 	 * accordingly.
285 	 *
286 	 * Params:
287 	 *     hostAndPort = the name and optionally port of the host to connect to
288 	 *     defaultPort = the default port to connect to
289 	 *     cancellable = a #GCancellable, or %NULL
290 	 *
291 	 * Return: a #GSocketConnection on success, %NULL on error.
292 	 *
293 	 * Since: 2.22
294 	 *
295 	 * Throws: GException on failure.
296 	 */
297 	public SocketConnection connectToHost(string hostAndPort, ushort defaultPort, Cancellable cancellable)
298 	{
299 		GError* err = null;
300 		
301 		auto p = g_socket_client_connect_to_host(gSocketClient, Str.toStringz(hostAndPort), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
302 		
303 		if (err !is null)
304 		{
305 			throw new GException( new ErrorG(err) );
306 		}
307 		
308 		if(p is null)
309 		{
310 			return null;
311 		}
312 		
313 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
314 	}
315 
316 	/**
317 	 * This is the asynchronous version of g_socket_client_connect_to_host().
318 	 *
319 	 * When the operation is finished @callback will be
320 	 * called. You can then call g_socket_client_connect_to_host_finish() to get
321 	 * the result of the operation.
322 	 *
323 	 * Params:
324 	 *     hostAndPort = the name and optionally the port of the host to connect to
325 	 *     defaultPort = the default port to connect to
326 	 *     cancellable = a #GCancellable, or %NULL
327 	 *     callback = a #GAsyncReadyCallback
328 	 *     userData = user data for the callback
329 	 *
330 	 * Since: 2.22
331 	 */
332 	public void connectToHostAsync(string hostAndPort, ushort defaultPort, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
333 	{
334 		g_socket_client_connect_to_host_async(gSocketClient, Str.toStringz(hostAndPort), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
335 	}
336 
337 	/**
338 	 * Finishes an async connect operation. See g_socket_client_connect_to_host_async()
339 	 *
340 	 * Params:
341 	 *     result = a #GAsyncResult.
342 	 *
343 	 * Return: a #GSocketConnection on success, %NULL on error.
344 	 *
345 	 * Since: 2.22
346 	 *
347 	 * Throws: GException on failure.
348 	 */
349 	public SocketConnection connectToHostFinish(AsyncResultIF result)
350 	{
351 		GError* err = null;
352 		
353 		auto p = g_socket_client_connect_to_host_finish(gSocketClient, (result is null) ? null : result.getAsyncResultStruct(), &err);
354 		
355 		if (err !is null)
356 		{
357 			throw new GException( new ErrorG(err) );
358 		}
359 		
360 		if(p is null)
361 		{
362 			return null;
363 		}
364 		
365 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
366 	}
367 
368 	/**
369 	 * Attempts to create a TCP connection to a service.
370 	 *
371 	 * This call looks up the SRV record for @service at @domain for the
372 	 * "tcp" protocol.  It then attempts to connect, in turn, to each of
373 	 * the hosts providing the service until either a connection succeeds
374 	 * or there are no hosts remaining.
375 	 *
376 	 * Upon a successful connection, a new #GSocketConnection is constructed
377 	 * and returned.  The caller owns this new object and must drop their
378 	 * reference to it when finished with it.
379 	 *
380 	 * In the event of any failure (DNS error, service not found, no hosts
381 	 * connectable) %NULL is returned and @error (if non-%NULL) is set
382 	 * accordingly.
383 	 *
384 	 * Params:
385 	 *     domain = a domain name
386 	 *     service = the name of the service to connect to
387 	 *     cancellable = a #GCancellable, or %NULL
388 	 *
389 	 * Return: a #GSocketConnection if successful, or %NULL on error
390 	 *
391 	 * Throws: GException on failure.
392 	 */
393 	public SocketConnection connectToService(string domain, string service, Cancellable cancellable)
394 	{
395 		GError* err = null;
396 		
397 		auto p = g_socket_client_connect_to_service(gSocketClient, Str.toStringz(domain), Str.toStringz(service), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
398 		
399 		if (err !is null)
400 		{
401 			throw new GException( new ErrorG(err) );
402 		}
403 		
404 		if(p is null)
405 		{
406 			return null;
407 		}
408 		
409 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
410 	}
411 
412 	/**
413 	 * This is the asynchronous version of
414 	 * g_socket_client_connect_to_service().
415 	 *
416 	 * Params:
417 	 *     domain = a domain name
418 	 *     service = the name of the service to connect to
419 	 *     cancellable = a #GCancellable, or %NULL
420 	 *     callback = a #GAsyncReadyCallback
421 	 *     userData = user data for the callback
422 	 *
423 	 * Since: 2.22
424 	 */
425 	public void connectToServiceAsync(string domain, string service, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
426 	{
427 		g_socket_client_connect_to_service_async(gSocketClient, Str.toStringz(domain), Str.toStringz(service), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
428 	}
429 
430 	/**
431 	 * Finishes an async connect operation. See g_socket_client_connect_to_service_async()
432 	 *
433 	 * Params:
434 	 *     result = a #GAsyncResult.
435 	 *
436 	 * Return: a #GSocketConnection on success, %NULL on error.
437 	 *
438 	 * Since: 2.22
439 	 *
440 	 * Throws: GException on failure.
441 	 */
442 	public SocketConnection connectToServiceFinish(AsyncResultIF result)
443 	{
444 		GError* err = null;
445 		
446 		auto p = g_socket_client_connect_to_service_finish(gSocketClient, (result is null) ? null : result.getAsyncResultStruct(), &err);
447 		
448 		if (err !is null)
449 		{
450 			throw new GException( new ErrorG(err) );
451 		}
452 		
453 		if(p is null)
454 		{
455 			return null;
456 		}
457 		
458 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
459 	}
460 
461 	/**
462 	 * This is a helper function for g_socket_client_connect().
463 	 *
464 	 * Attempts to create a TCP connection with a network URI.
465 	 *
466 	 * @uri may be any valid URI containing an "authority" (hostname/port)
467 	 * component. If a port is not specified in the URI, @default_port
468 	 * will be used. TLS will be negotiated if #GSocketClient:tls is %TRUE.
469 	 * (#GSocketClient does not know to automatically assume TLS for
470 	 * certain URI schemes.)
471 	 *
472 	 * Using this rather than g_socket_client_connect() or
473 	 * g_socket_client_connect_to_host() allows #GSocketClient to
474 	 * determine when to use application-specific proxy protocols.
475 	 *
476 	 * Upon a successful connection, a new #GSocketConnection is constructed
477 	 * and returned.  The caller owns this new object and must drop their
478 	 * reference to it when finished with it.
479 	 *
480 	 * In the event of any failure (DNS error, service not found, no hosts
481 	 * connectable) %NULL is returned and @error (if non-%NULL) is set
482 	 * accordingly.
483 	 *
484 	 * Params:
485 	 *     uri = A network URI
486 	 *     defaultPort = the default port to connect to
487 	 *     cancellable = a #GCancellable, or %NULL
488 	 *
489 	 * Return: a #GSocketConnection on success, %NULL on error.
490 	 *
491 	 * Since: 2.26
492 	 *
493 	 * Throws: GException on failure.
494 	 */
495 	public SocketConnection connectToUri(string uri, ushort defaultPort, Cancellable cancellable)
496 	{
497 		GError* err = null;
498 		
499 		auto p = g_socket_client_connect_to_uri(gSocketClient, Str.toStringz(uri), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
500 		
501 		if (err !is null)
502 		{
503 			throw new GException( new ErrorG(err) );
504 		}
505 		
506 		if(p is null)
507 		{
508 			return null;
509 		}
510 		
511 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
512 	}
513 
514 	/**
515 	 * This is the asynchronous version of g_socket_client_connect_to_uri().
516 	 *
517 	 * When the operation is finished @callback will be
518 	 * called. You can then call g_socket_client_connect_to_uri_finish() to get
519 	 * the result of the operation.
520 	 *
521 	 * Params:
522 	 *     uri = a network uri
523 	 *     defaultPort = the default port to connect to
524 	 *     cancellable = a #GCancellable, or %NULL
525 	 *     callback = a #GAsyncReadyCallback
526 	 *     userData = user data for the callback
527 	 *
528 	 * Since: 2.26
529 	 */
530 	public void connectToUriAsync(string uri, ushort defaultPort, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
531 	{
532 		g_socket_client_connect_to_uri_async(gSocketClient, Str.toStringz(uri), defaultPort, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
533 	}
534 
535 	/**
536 	 * Finishes an async connect operation. See g_socket_client_connect_to_uri_async()
537 	 *
538 	 * Params:
539 	 *     result = a #GAsyncResult.
540 	 *
541 	 * Return: a #GSocketConnection on success, %NULL on error.
542 	 *
543 	 * Since: 2.26
544 	 *
545 	 * Throws: GException on failure.
546 	 */
547 	public SocketConnection connectToUriFinish(AsyncResultIF result)
548 	{
549 		GError* err = null;
550 		
551 		auto p = g_socket_client_connect_to_uri_finish(gSocketClient, (result is null) ? null : result.getAsyncResultStruct(), &err);
552 		
553 		if (err !is null)
554 		{
555 			throw new GException( new ErrorG(err) );
556 		}
557 		
558 		if(p is null)
559 		{
560 			return null;
561 		}
562 		
563 		return ObjectG.getDObject!(SocketConnection)(cast(GSocketConnection*) p, true);
564 	}
565 
566 	/**
567 	 * Gets the proxy enable state; see g_socket_client_set_enable_proxy()
568 	 *
569 	 * Return: whether proxying is enabled
570 	 *
571 	 * Since: 2.26
572 	 */
573 	public bool getEnableProxy()
574 	{
575 		return g_socket_client_get_enable_proxy(gSocketClient) != 0;
576 	}
577 
578 	/**
579 	 * Gets the socket family of the socket client.
580 	 *
581 	 * See g_socket_client_set_family() for details.
582 	 *
583 	 * Return: a #GSocketFamily
584 	 *
585 	 * Since: 2.22
586 	 */
587 	public GSocketFamily getFamily()
588 	{
589 		return g_socket_client_get_family(gSocketClient);
590 	}
591 
592 	/**
593 	 * Gets the local address of the socket client.
594 	 *
595 	 * See g_socket_client_set_local_address() for details.
596 	 *
597 	 * Return: a #GSocketAddress or %NULL. Do not free.
598 	 *
599 	 * Since: 2.22
600 	 */
601 	public SocketAddress getLocalAddress()
602 	{
603 		auto p = g_socket_client_get_local_address(gSocketClient);
604 		
605 		if(p is null)
606 		{
607 			return null;
608 		}
609 		
610 		return ObjectG.getDObject!(SocketAddress)(cast(GSocketAddress*) p);
611 	}
612 
613 	/**
614 	 * Gets the protocol name type of the socket client.
615 	 *
616 	 * See g_socket_client_set_protocol() for details.
617 	 *
618 	 * Return: a #GSocketProtocol
619 	 *
620 	 * Since: 2.22
621 	 */
622 	public GSocketProtocol getProtocol()
623 	{
624 		return g_socket_client_get_protocol(gSocketClient);
625 	}
626 
627 	/**
628 	 * Gets the #GProxyResolver being used by @client. Normally, this will
629 	 * be the resolver returned by g_proxy_resolver_get_default(), but you
630 	 * can override it with g_socket_client_set_proxy_resolver().
631 	 *
632 	 * Return: The #GProxyResolver being used by
633 	 *     @client.
634 	 *
635 	 * Since: 2.36
636 	 */
637 	public ProxyResolverIF getProxyResolver()
638 	{
639 		auto p = g_socket_client_get_proxy_resolver(gSocketClient);
640 		
641 		if(p is null)
642 		{
643 			return null;
644 		}
645 		
646 		return ObjectG.getDObject!(ProxyResolver, ProxyResolverIF)(cast(GProxyResolver*) p);
647 	}
648 
649 	/**
650 	 * Gets the socket type of the socket client.
651 	 *
652 	 * See g_socket_client_set_socket_type() for details.
653 	 *
654 	 * Return: a #GSocketFamily
655 	 *
656 	 * Since: 2.22
657 	 */
658 	public GSocketType getSocketType()
659 	{
660 		return g_socket_client_get_socket_type(gSocketClient);
661 	}
662 
663 	/**
664 	 * Gets the I/O timeout time for sockets created by @client.
665 	 *
666 	 * See g_socket_client_set_timeout() for details.
667 	 *
668 	 * Return: the timeout in seconds
669 	 *
670 	 * Since: 2.26
671 	 */
672 	public uint getTimeout()
673 	{
674 		return g_socket_client_get_timeout(gSocketClient);
675 	}
676 
677 	/**
678 	 * Gets whether @client creates TLS connections. See
679 	 * g_socket_client_set_tls() for details.
680 	 *
681 	 * Return: whether @client uses TLS
682 	 *
683 	 * Since: 2.28
684 	 */
685 	public bool getTls()
686 	{
687 		return g_socket_client_get_tls(gSocketClient) != 0;
688 	}
689 
690 	/**
691 	 * Gets the TLS validation flags used creating TLS connections via
692 	 * @client.
693 	 *
694 	 * Return: the TLS validation flags
695 	 *
696 	 * Since: 2.28
697 	 */
698 	public GTlsCertificateFlags getTlsValidationFlags()
699 	{
700 		return g_socket_client_get_tls_validation_flags(gSocketClient);
701 	}
702 
703 	/**
704 	 * Sets whether or not @client attempts to make connections via a
705 	 * proxy server. When enabled (the default), #GSocketClient will use a
706 	 * #GProxyResolver to determine if a proxy protocol such as SOCKS is
707 	 * needed, and automatically do the necessary proxy negotiation.
708 	 *
709 	 * See also g_socket_client_set_proxy_resolver().
710 	 *
711 	 * Params:
712 	 *     enable = whether to enable proxies
713 	 *
714 	 * Since: 2.26
715 	 */
716 	public void setEnableProxy(bool enable)
717 	{
718 		g_socket_client_set_enable_proxy(gSocketClient, enable);
719 	}
720 
721 	/**
722 	 * Sets the socket family of the socket client.
723 	 * If this is set to something other than %G_SOCKET_FAMILY_INVALID
724 	 * then the sockets created by this object will be of the specified
725 	 * family.
726 	 *
727 	 * This might be useful for instance if you want to force the local
728 	 * connection to be an ipv4 socket, even though the address might
729 	 * be an ipv6 mapped to ipv4 address.
730 	 *
731 	 * Params:
732 	 *     family = a #GSocketFamily
733 	 *
734 	 * Since: 2.22
735 	 */
736 	public void setFamily(GSocketFamily family)
737 	{
738 		g_socket_client_set_family(gSocketClient, family);
739 	}
740 
741 	/**
742 	 * Sets the local address of the socket client.
743 	 * The sockets created by this object will bound to the
744 	 * specified address (if not %NULL) before connecting.
745 	 *
746 	 * This is useful if you want to ensure that the local
747 	 * side of the connection is on a specific port, or on
748 	 * a specific interface.
749 	 *
750 	 * Params:
751 	 *     address = a #GSocketAddress, or %NULL
752 	 *
753 	 * Since: 2.22
754 	 */
755 	public void setLocalAddress(SocketAddress address)
756 	{
757 		g_socket_client_set_local_address(gSocketClient, (address is null) ? null : address.getSocketAddressStruct());
758 	}
759 
760 	/**
761 	 * Sets the protocol of the socket client.
762 	 * The sockets created by this object will use of the specified
763 	 * protocol.
764 	 *
765 	 * If @protocol is %0 that means to use the default
766 	 * protocol for the socket family and type.
767 	 *
768 	 * Params:
769 	 *     protocol = a #GSocketProtocol
770 	 *
771 	 * Since: 2.22
772 	 */
773 	public void setProtocol(GSocketProtocol protocol)
774 	{
775 		g_socket_client_set_protocol(gSocketClient, protocol);
776 	}
777 
778 	/**
779 	 * Overrides the #GProxyResolver used by @client. You can call this if
780 	 * you want to use specific proxies, rather than using the system
781 	 * default proxy settings.
782 	 *
783 	 * Note that whether or not the proxy resolver is actually used
784 	 * depends on the setting of #GSocketClient:enable-proxy, which is not
785 	 * changed by this function (but which is %TRUE by default)
786 	 *
787 	 * Params:
788 	 *     proxyResolver = a #GProxyResolver, or %NULL for the
789 	 *         default.
790 	 *
791 	 * Since: 2.36
792 	 */
793 	public void setProxyResolver(ProxyResolverIF proxyResolver)
794 	{
795 		g_socket_client_set_proxy_resolver(gSocketClient, (proxyResolver is null) ? null : proxyResolver.getProxyResolverStruct());
796 	}
797 
798 	/**
799 	 * Sets the socket type of the socket client.
800 	 * The sockets created by this object will be of the specified
801 	 * type.
802 	 *
803 	 * It doesn't make sense to specify a type of %G_SOCKET_TYPE_DATAGRAM,
804 	 * as GSocketClient is used for connection oriented services.
805 	 *
806 	 * Params:
807 	 *     type = a #GSocketType
808 	 *
809 	 * Since: 2.22
810 	 */
811 	public void setSocketType(GSocketType type)
812 	{
813 		g_socket_client_set_socket_type(gSocketClient, type);
814 	}
815 
816 	/**
817 	 * Sets the I/O timeout for sockets created by @client. @timeout is a
818 	 * time in seconds, or 0 for no timeout (the default).
819 	 *
820 	 * The timeout value affects the initial connection attempt as well,
821 	 * so setting this may cause calls to g_socket_client_connect(), etc,
822 	 * to fail with %G_IO_ERROR_TIMED_OUT.
823 	 *
824 	 * Params:
825 	 *     timeout = the timeout
826 	 *
827 	 * Since: 2.26
828 	 */
829 	public void setTimeout(uint timeout)
830 	{
831 		g_socket_client_set_timeout(gSocketClient, timeout);
832 	}
833 
834 	/**
835 	 * Sets whether @client creates TLS (aka SSL) connections. If @tls is
836 	 * %TRUE, @client will wrap its connections in a #GTlsClientConnection
837 	 * and perform a TLS handshake when connecting.
838 	 *
839 	 * Note that since #GSocketClient must return a #GSocketConnection,
840 	 * but #GTlsClientConnection is not a #GSocketConnection, this
841 	 * actually wraps the resulting #GTlsClientConnection in a
842 	 * #GTcpWrapperConnection when returning it. You can use
843 	 * g_tcp_wrapper_connection_get_base_io_stream() on the return value
844 	 * to extract the #GTlsClientConnection.
845 	 *
846 	 * If you need to modify the behavior of the TLS handshake (eg, by
847 	 * setting a client-side certificate to use, or connecting to the
848 	 * #GTlsConnection::accept-certificate signal), you can connect to
849 	 * @client's #GSocketClient::event signal and wait for it to be
850 	 * emitted with %G_SOCKET_CLIENT_TLS_HANDSHAKING, which will give you
851 	 * a chance to see the #GTlsClientConnection before the handshake
852 	 * starts.
853 	 *
854 	 * Params:
855 	 *     tls = whether to use TLS
856 	 *
857 	 * Since: 2.28
858 	 */
859 	public void setTls(bool tls)
860 	{
861 		g_socket_client_set_tls(gSocketClient, tls);
862 	}
863 
864 	/**
865 	 * Sets the TLS validation flags used when creating TLS connections
866 	 * via @client. The default value is %G_TLS_CERTIFICATE_VALIDATE_ALL.
867 	 *
868 	 * Params:
869 	 *     flags = the validation flags
870 	 *
871 	 * Since: 2.28
872 	 */
873 	public void setTlsValidationFlags(GTlsCertificateFlags flags)
874 	{
875 		g_socket_client_set_tls_validation_flags(gSocketClient, flags);
876 	}
877 
878 	int[string] connectedSignals;
879 
880 	void delegate(GSocketClientEvent, SocketConnectableIF, IOStream, SocketClient)[] onListeners;
881 	/**
882 	 * Emitted when @client's activity on @connectable changes state.
883 	 * Among other things, this can be used to provide progress
884 	 * information about a network connection in the UI. The meanings of
885 	 * the different @event values are as follows:
886 	 *
887 	 * - %G_SOCKET_CLIENT_RESOLVING: @client is about to look up @connectable
888 	 * in DNS. @connection will be %NULL.
889 	 *
890 	 * - %G_SOCKET_CLIENT_RESOLVED:  @client has successfully resolved
891 	 * @connectable in DNS. @connection will be %NULL.
892 	 *
893 	 * - %G_SOCKET_CLIENT_CONNECTING: @client is about to make a connection
894 	 * to a remote host; either a proxy server or the destination server
895 	 * itself. @connection is the #GSocketConnection, which is not yet
896 	 * connected.  Since GLib 2.40, you can access the remote
897 	 * address via g_socket_connection_get_remote_address().
898 	 *
899 	 * - %G_SOCKET_CLIENT_CONNECTED: @client has successfully connected
900 	 * to a remote host. @connection is the connected #GSocketConnection.
901 	 *
902 	 * - %G_SOCKET_CLIENT_PROXY_NEGOTIATING: @client is about to negotiate
903 	 * with a proxy to get it to connect to @connectable. @connection is
904 	 * the #GSocketConnection to the proxy server.
905 	 *
906 	 * - %G_SOCKET_CLIENT_PROXY_NEGOTIATED: @client has negotiated a
907 	 * connection to @connectable through a proxy server. @connection is
908 	 * the stream returned from g_proxy_connect(), which may or may not
909 	 * be a #GSocketConnection.
910 	 *
911 	 * - %G_SOCKET_CLIENT_TLS_HANDSHAKING: @client is about to begin a TLS
912 	 * handshake. @connection is a #GTlsClientConnection.
913 	 *
914 	 * - %G_SOCKET_CLIENT_TLS_HANDSHAKED: @client has successfully completed
915 	 * the TLS handshake. @connection is a #GTlsClientConnection.
916 	 *
917 	 * - %G_SOCKET_CLIENT_COMPLETE: @client has either successfully connected
918 	 * to @connectable (in which case @connection is the #GSocketConnection
919 	 * that it will be returning to the caller) or has failed (in which
920 	 * case @connection is %NULL and the client is about to return an error).
921 	 *
922 	 * Each event except %G_SOCKET_CLIENT_COMPLETE may be emitted
923 	 * multiple times (or not at all) for a given connectable (in
924 	 * particular, if @client ends up attempting to connect to more than
925 	 * one address). However, if @client emits the #GSocketClient::event
926 	 * signal at all for a given connectable, that it will always emit
927 	 * it with %G_SOCKET_CLIENT_COMPLETE when it is done.
928 	 *
929 	 * Note that there may be additional #GSocketClientEvent values in
930 	 * the future; unrecognized @event values should be ignored.
931 	 *
932 	 * Params:
933 	 *     event = the event that is occurring
934 	 *     connectable = the #GSocketConnectable that @event is occurring on
935 	 *     connection = the current representation of the connection
936 	 *
937 	 * Since: 2.32
938 	 */
939 	void addOn(void delegate(GSocketClientEvent, SocketConnectableIF, IOStream, SocketClient) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
940 	{
941 		if ( "event" !in connectedSignals )
942 		{
943 			Signals.connectData(
944 				this,
945 				"event",
946 				cast(GCallback)&callBack,
947 				cast(void*)this,
948 				null,
949 				connectFlags);
950 			connectedSignals["event"] = 1;
951 		}
952 		onListeners ~= dlg;
953 	}
954 	extern(C) static void callBack(GSocketClient* socketclientStruct, GSocketClientEvent event, GSocketConnectable* connectable, GIOStream* connection, SocketClient _socketclient)
955 	{
956 		foreach ( void delegate(GSocketClientEvent, SocketConnectableIF, IOStream, SocketClient) dlg; _socketclient.onListeners )
957 		{
958 			dlg(event, ObjectG.getDObject!(SocketConnectable, SocketConnectableIF)(connectable), ObjectG.getDObject!(IOStream)(connection), _socketclient);
959 		}
960 	}
961 }