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