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.ProxyT;
26 
27 public  import gio.AsyncResultIF;
28 public  import gio.Cancellable;
29 public  import gio.IOStream;
30 public  import gio.ProxyAddress;
31 public  import gio.ProxyIF;
32 public  import gio.c.functions;
33 public  import gio.c.types;
34 public  import glib.ErrorG;
35 public  import glib.GException;
36 public  import glib.Str;
37 public  import gobject.ObjectG;
38 
39 
40 /**
41  * A #GProxy handles connecting to a remote host via a given type of
42  * proxy server. It is implemented by the 'gio-proxy' extension point.
43  * The extensions are named after their proxy protocol name. As an
44  * example, a SOCKS5 proxy implementation can be retrieved with the
45  * name 'socks5' using the function
46  * g_io_extension_point_get_extension_by_name().
47  *
48  * Since: 2.26
49  */
50 public template ProxyT(TStruct)
51 {
52 	/** Get the main Gtk struct */
53 	public GProxy* getProxyStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return cast(GProxy*)getStruct();
58 	}
59 
60 
61 	/**
62 	 * Given @connection to communicate with a proxy (eg, a
63 	 * #GSocketConnection that is connected to the proxy server), this
64 	 * does the necessary handshake to connect to @proxy_address, and if
65 	 * required, wraps the #GIOStream to handle proxy payload.
66 	 *
67 	 * Params:
68 	 *     connection = a #GIOStream
69 	 *     proxyAddress = a #GProxyAddress
70 	 *     cancellable = a #GCancellable
71 	 *
72 	 * Returns: a #GIOStream that will replace @connection. This might
73 	 *     be the same as @connection, in which case a reference
74 	 *     will be added.
75 	 *
76 	 * Since: 2.26
77 	 *
78 	 * Throws: GException on failure.
79 	 */
80 	public IOStream connect(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable)
81 	{
82 		GError* err = null;
83 
84 		auto __p = g_proxy_connect(getProxyStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
85 
86 		if (err !is null)
87 		{
88 			throw new GException( new ErrorG(err) );
89 		}
90 
91 		if(__p is null)
92 		{
93 			return null;
94 		}
95 
96 		return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p, true);
97 	}
98 
99 	/**
100 	 * Asynchronous version of g_proxy_connect().
101 	 *
102 	 * Params:
103 	 *     connection = a #GIOStream
104 	 *     proxyAddress = a #GProxyAddress
105 	 *     cancellable = a #GCancellable
106 	 *     callback = a #GAsyncReadyCallback
107 	 *     userData = callback data
108 	 *
109 	 * Since: 2.26
110 	 */
111 	public void connectAsync(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
112 	{
113 		g_proxy_connect_async(getProxyStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
114 	}
115 
116 	/**
117 	 * See g_proxy_connect().
118 	 *
119 	 * Params:
120 	 *     result = a #GAsyncResult
121 	 *
122 	 * Returns: a #GIOStream.
123 	 *
124 	 * Since: 2.26
125 	 *
126 	 * Throws: GException on failure.
127 	 */
128 	public IOStream connectFinish(AsyncResultIF result)
129 	{
130 		GError* err = null;
131 
132 		auto __p = g_proxy_connect_finish(getProxyStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err);
133 
134 		if (err !is null)
135 		{
136 			throw new GException( new ErrorG(err) );
137 		}
138 
139 		if(__p is null)
140 		{
141 			return null;
142 		}
143 
144 		return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p, true);
145 	}
146 
147 	/**
148 	 * Some proxy protocols expect to be passed a hostname, which they
149 	 * will resolve to an IP address themselves. Others, like SOCKS4, do
150 	 * not allow this. This function will return %FALSE if @proxy is
151 	 * implementing such a protocol. When %FALSE is returned, the caller
152 	 * should resolve the destination hostname first, and then pass a
153 	 * #GProxyAddress containing the stringified IP address to
154 	 * g_proxy_connect() or g_proxy_connect_async().
155 	 *
156 	 * Returns: %TRUE if hostname resolution is supported.
157 	 *
158 	 * Since: 2.26
159 	 */
160 	public bool supportsHostname()
161 	{
162 		return g_proxy_supports_hostname(getProxyStruct()) != 0;
163 	}
164 }