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  = GProxy.html
27  * outPack = gio
28  * outFile = ProxyT
29  * strct   = GProxy
30  * realStrct=
31  * ctorStrct=
32  * clss    = ProxyT
33  * interf  = ProxyIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_initable_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gio.AsyncResultIF
51  * 	- gio.Cancellable
52  * 	- gio.IOStream
53  * 	- gio.ProxyAddress
54  * structWrap:
55  * 	- GAsyncResult* -> AsyncResultIF
56  * 	- GCancellable* -> Cancellable
57  * 	- GIOStream* -> IOStream
58  * 	- GProxy* -> ProxyIF
59  * 	- GProxyAddress* -> ProxyAddress
60  * module aliases:
61  * local aliases:
62  * overrides:
63  */
64 
65 module gio.ProxyT;
66 
67 public  import gtkc.giotypes;
68 
69 public import gtkc.gio;
70 public import glib.ConstructionException;
71 public import gobject.ObjectG;
72 
73 public import glib.Str;
74 public import glib.ErrorG;
75 public import glib.GException;
76 public import gio.AsyncResultIF;
77 public import gio.Cancellable;
78 public import gio.IOStream;
79 public import gio.ProxyAddress;
80 
81 
82 
83 /**
84  * A GProxy handles connecting to a remote host via a given type of
85  * proxy server. It is implemented by the 'gio-proxy' extension point.
86  * The extensions are named after their proxy protocol name. As an
87  * example, a SOCKS5 proxy implementation can be retrieved with the
88  * name 'socks5' using the function
89  * g_io_extension_point_get_extension_by_name().
90  */
91 public template ProxyT(TStruct)
92 {
93 	
94 	/** the main Gtk struct */
95 	protected GProxy* gProxy;
96 	
97 	
98 	/** Get the main Gtk struct */
99 	public GProxy* getProxyTStruct()
100 	{
101 		return cast(GProxy*)getStruct();
102 	}
103 	
104 	
105 	/**
106 	 */
107 	
108 	/**
109 	 * Given connection to communicate with a proxy (eg, a
110 	 * GSocketConnection that is connected to the proxy server), this
111 	 * does the necessary handshake to connect to proxy_address, and if
112 	 * required, wraps the GIOStream to handle proxy payload.
113 	 * Since 2.26
114 	 * Params:
115 	 * proxy = a GProxy
116 	 * connection = a GIOStream
117 	 * proxyAddress = a GProxyAddress
118 	 * cancellable = a GCancellable. [allow-none]
119 	 * Returns: a GIOStream that will replace connection. This might be the same as connection, in which case a reference will be added. [transfer full]
120 	 * Throws: GException on failure.
121 	 */
122 	public IOStream gProxyConnect(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable)
123 	{
124 		// GIOStream * g_proxy_connect (GProxy *proxy,  GIOStream *connection,  GProxyAddress *proxy_address,  GCancellable *cancellable,  GError **error);
125 		GError* err = null;
126 		
127 		auto p = g_proxy_connect(getProxyTStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
128 		
129 		if (err !is null)
130 		{
131 			throw new GException( new ErrorG(err) );
132 		}
133 		
134 		
135 		if(p is null)
136 		{
137 			return null;
138 		}
139 		
140 		return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p);
141 	}
142 	
143 	/**
144 	 * Asynchronous version of g_proxy_connect().
145 	 * Since 2.26
146 	 * Params:
147 	 * proxy = a GProxy
148 	 * connection = a GIOStream
149 	 * proxyAddress = a GProxyAddress
150 	 * cancellable = a GCancellable. [allow-none]
151 	 * callback = a GAsyncReadyCallback. [scope async]
152 	 * userData = callback data. [closure]
153 	 */
154 	public void gProxyConnectAsync(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
155 	{
156 		// void g_proxy_connect_async (GProxy *proxy,  GIOStream *connection,  GProxyAddress *proxy_address,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
157 		g_proxy_connect_async(getProxyTStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
158 	}
159 	
160 	/**
161 	 * See g_proxy_connect().
162 	 * Since 2.26
163 	 * Params:
164 	 * result = a GAsyncResult
165 	 * Returns: a GIOStream. [transfer full]
166 	 * Throws: GException on failure.
167 	 */
168 	public IOStream gProxyConnectFinish(AsyncResultIF result)
169 	{
170 		// GIOStream * g_proxy_connect_finish (GProxy *proxy,  GAsyncResult *result,  GError **error);
171 		GError* err = null;
172 		
173 		auto p = g_proxy_connect_finish(getProxyTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
174 		
175 		if (err !is null)
176 		{
177 			throw new GException( new ErrorG(err) );
178 		}
179 		
180 		
181 		if(p is null)
182 		{
183 			return null;
184 		}
185 		
186 		return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p);
187 	}
188 	
189 	/**
190 	 * Lookup "gio-proxy" extension point for a proxy implementation that supports
191 	 * specified protocol.
192 	 * Since 2.26
193 	 * Params:
194 	 * protocol = the proxy protocol name (e.g. http, socks, etc)
195 	 * Returns: return a GProxy or NULL if protocol is not supported. [transfer full]
196 	 */
197 	public static ProxyIF gProxyGetDefaultForProtocol(string protocol)
198 	{
199 		// GProxy * g_proxy_get_default_for_protocol (const gchar *protocol);
200 		auto p = g_proxy_get_default_for_protocol(Str.toStringz(protocol));
201 		
202 		if(p is null)
203 		{
204 			return null;
205 		}
206 		
207 		return ObjectG.getDObject!(Proxy, ProxyIF)(cast(GProxy*) p);
208 	}
209 	
210 	/**
211 	 * Some proxy protocols expect to be passed a hostname, which they
212 	 * will resolve to an IP address themselves. Others, like SOCKS4, do
213 	 * not allow this. This function will return FALSE if proxy is
214 	 * implementing such a protocol. When FALSE is returned, the caller
215 	 * should resolve the destination hostname first, and then pass a
216 	 * GProxyAddress containing the stringified IP address to
217 	 * g_proxy_connect() or g_proxy_connect_async().
218 	 * Since 2.26
219 	 * Returns: TRUE if hostname resolution is supported.
220 	 */
221 	public int gProxySupportsHostname()
222 	{
223 		// gboolean g_proxy_supports_hostname (GProxy *proxy);
224 		return g_proxy_supports_hostname(getProxyTStruct());
225 	}
226 }