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.SocketConnectableT;
26 
27 public  import gio.SocketAddressEnumerator;
28 public  import gobject.ObjectG;
29 public  import gtkc.gio;
30 public  import gtkc.giotypes;
31 
32 
33 /**
34  * Objects that describe one or more potential socket endpoints
35  * implement #GSocketConnectable. Callers can then use
36  * g_socket_connectable_enumerate() to get a #GSocketAddressEnumerator
37  * to try out each socket address in turn until one succeeds, as shown
38  * in the sample code below.
39  * 
40  * |[<!-- language="C" -->
41  * MyConnectionType *
42  * connect_to_host (const char    *hostname,
43  * guint16        port,
44  * GCancellable  *cancellable,
45  * GError       **error)
46  * {
47  * MyConnection *conn = NULL;
48  * GSocketConnectable *addr;
49  * GSocketAddressEnumerator *enumerator;
50  * GSocketAddress *sockaddr;
51  * GError *conn_error = NULL;
52  * 
53  * addr = g_network_address_new (hostname, port);
54  * enumerator = g_socket_connectable_enumerate (addr);
55  * g_object_unref (addr);
56  * 
57  * // Try each sockaddr until we succeed. Record the first connection error,
58  * // but not any further ones (since they'll probably be basically the same
59  * // as the first).
60  * while (!conn && (sockaddr = g_socket_address_enumerator_next (enumerator, cancellable, error))
61  * {
62  * conn = connect_to_sockaddr (sockaddr, conn_error ? NULL : &conn_error);
63  * g_object_unref (sockaddr);
64  * }
65  * g_object_unref (enumerator);
66  * 
67  * if (conn)
68  * {
69  * if (conn_error)
70  * {
71  * // We couldn't connect to the first address, but we succeeded
72  * // in connecting to a later address.
73  * g_error_free (conn_error);
74  * }
75  * return conn;
76  * }
77  * else if (error)
78  * {
79  * /// Either initial lookup failed, or else the caller cancelled us.
80  * if (conn_error)
81  * g_error_free (conn_error);
82  * return NULL;
83  * }
84  * else
85  * {
86  * g_error_propagate (error, conn_error);
87  * return NULL;
88  * }
89  * }
90  * ]|
91  */
92 public template SocketConnectableT(TStruct)
93 {
94 	/** Get the main Gtk struct */
95 	public GSocketConnectable* getSocketConnectableStruct()
96 	{
97 		return cast(GSocketConnectable*)getStruct();
98 	}
99 
100 	/**
101 	 */
102 
103 	/**
104 	 * Creates a #GSocketAddressEnumerator for @connectable.
105 	 *
106 	 * Return: a new #GSocketAddressEnumerator.
107 	 *
108 	 * Since: 2.22
109 	 */
110 	public SocketAddressEnumerator enumerate()
111 	{
112 		auto p = g_socket_connectable_enumerate(getSocketConnectableStruct());
113 		
114 		if(p is null)
115 		{
116 			return null;
117 		}
118 		
119 		return ObjectG.getDObject!(SocketAddressEnumerator)(cast(GSocketAddressEnumerator*) p, true);
120 	}
121 
122 	/**
123 	 * Creates a #GSocketAddressEnumerator for @connectable that will
124 	 * return #GProxyAddresses for addresses that you must connect
125 	 * to via a proxy.
126 	 *
127 	 * If @connectable does not implement
128 	 * g_socket_connectable_proxy_enumerate(), this will fall back to
129 	 * calling g_socket_connectable_enumerate().
130 	 *
131 	 * Return: a new #GSocketAddressEnumerator.
132 	 *
133 	 * Since: 2.26
134 	 */
135 	public SocketAddressEnumerator proxyEnumerate()
136 	{
137 		auto p = g_socket_connectable_proxy_enumerate(getSocketConnectableStruct());
138 		
139 		if(p is null)
140 		{
141 			return null;
142 		}
143 		
144 		return ObjectG.getDObject!(SocketAddressEnumerator)(cast(GSocketAddressEnumerator*) p, true);
145 	}
146 }