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  = GProxyResolver.html
27  * outPack = gio
28  * outFile = ProxyResolverT
29  * strct   = GProxyResolver
30  * realStrct=
31  * ctorStrct=
32  * clss    = ProxyResolverT
33  * interf  = ProxyResolverIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_proxy_resolver_
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.ProxyResolver
53  * 	- gio.ProxyResolverIF
54  * structWrap:
55  * 	- GAsyncResult* -> AsyncResultIF
56  * 	- GCancellable* -> Cancellable
57  * 	- GProxyResolver* -> ProxyResolverIF
58  * module aliases:
59  * local aliases:
60  * overrides:
61  */
62 
63 module gio.ProxyResolverT;
64 
65 public  import gtkc.giotypes;
66 
67 public import gtkc.gio;
68 public import glib.ConstructionException;
69 public import gobject.ObjectG;
70 
71 public import glib.Str;
72 public import glib.ErrorG;
73 public import glib.GException;
74 public import gio.AsyncResultIF;
75 public import gio.Cancellable;
76 public import gio.ProxyResolver;
77 public import gio.ProxyResolverIF;
78 
79 
80 
81 /**
82  * GProxyResolver provides synchronous and asynchronous network proxy
83  * resolution. GProxyResolver is used within GSocketClient through
84  * the method g_socket_connectable_proxy_enumerate().
85  */
86 public template ProxyResolverT(TStruct)
87 {
88 	
89 	/** the main Gtk struct */
90 	protected GProxyResolver* gProxyResolver;
91 	
92 	
93 	/** Get the main Gtk struct */
94 	public GProxyResolver* getProxyResolverTStruct()
95 	{
96 		return cast(GProxyResolver*)getStruct();
97 	}
98 	
99 	
100 	/**
101 	 */
102 	
103 	/**
104 	 * Gets the default GProxyResolver for the system.
105 	 * Since 2.26
106 	 * Returns: the default GProxyResolver. [transfer none]
107 	 */
108 	public static ProxyResolverIF getDefault()
109 	{
110 		// GProxyResolver * g_proxy_resolver_get_default (void);
111 		auto p = g_proxy_resolver_get_default();
112 		
113 		if(p is null)
114 		{
115 			return null;
116 		}
117 		
118 		return ObjectG.getDObject!(ProxyResolver, ProxyResolverIF)(cast(GProxyResolver*) p);
119 	}
120 	
121 	/**
122 	 * Checks if resolver can be used on this system. (This is used
123 	 * internally; g_proxy_resolver_get_default() will only return a proxy
124 	 * resolver that returns TRUE for this method.)
125 	 * Since 2.26
126 	 * Returns: TRUE if resolver is supported.
127 	 */
128 	public int isSupported()
129 	{
130 		// gboolean g_proxy_resolver_is_supported (GProxyResolver *resolver);
131 		return g_proxy_resolver_is_supported(getProxyResolverTStruct());
132 	}
133 	
134 	/**
135 	 * Looks into the system proxy configuration to determine what proxy,
136 	 * if any, to use to connect to uri. The returned proxy URIs are of the
137 	 * form <protocol>://[user[:password]@]host:port
138 	 * or direct://, where <protocol> could be
139 	 * http, rtsp, socks or other proxying protocol.
140 	 * If you don't know what network protocol is being used on the
141 	 * socket, you should use none as the URI protocol.
142 	 * In this case, the resolver might still return a generic proxy type
143 	 * (such as SOCKS), but would not return protocol-specific proxy types
144 	 * (such as http).
145 	 * direct:// is used when no proxy is needed.
146 	 * Direct connection should not be attempted unless it is part of the
147 	 * returned array of proxies.
148 	 * Since 2.26
149 	 * Params:
150 	 * uri = a URI representing the destination to connect to
151 	 * cancellable = a GCancellable, or NULL. [allow-none]
152 	 * Returns: A NULL-terminated array of proxy URIs. Must be freed with g_strfreev(). [transfer full][array zero-terminated=1]
153 	 * Throws: GException on failure.
154 	 */
155 	public string[] lookup(string uri, Cancellable cancellable)
156 	{
157 		// gchar ** g_proxy_resolver_lookup (GProxyResolver *resolver,  const gchar *uri,  GCancellable *cancellable,  GError **error);
158 		GError* err = null;
159 		
160 		auto p = g_proxy_resolver_lookup(getProxyResolverTStruct(), Str.toStringz(uri), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
161 		
162 		if (err !is null)
163 		{
164 			throw new GException( new ErrorG(err) );
165 		}
166 		
167 		return Str.toStringArray(p);
168 	}
169 	
170 	/**
171 	 * Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more
172 	 * details.
173 	 * Since 2.26
174 	 * Params:
175 	 * uri = a URI representing the destination to connect to
176 	 * cancellable = a GCancellable, or NULL. [allow-none]
177 	 * callback = callback to call after resolution completes. [scope async]
178 	 * userData = data for callback. [closure]
179 	 */
180 	public void lookupAsync(string uri, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
181 	{
182 		// void g_proxy_resolver_lookup_async (GProxyResolver *resolver,  const gchar *uri,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
183 		g_proxy_resolver_lookup_async(getProxyResolverTStruct(), Str.toStringz(uri), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
184 	}
185 	
186 	/**
187 	 * Call this function to obtain the array of proxy URIs when
188 	 * g_proxy_resolver_lookup_async() is complete. See
189 	 * g_proxy_resolver_lookup() for more details.
190 	 * Since 2.26
191 	 * Params:
192 	 * result = the result passed to your GAsyncReadyCallback
193 	 * Returns: A NULL-terminated array of proxy URIs. Must be freed with g_strfreev(). [transfer full][array zero-terminated=1]
194 	 * Throws: GException on failure.
195 	 */
196 	public string[] lookupFinish(AsyncResultIF result)
197 	{
198 		// gchar ** g_proxy_resolver_lookup_finish (GProxyResolver *resolver,  GAsyncResult *result,  GError **error);
199 		GError* err = null;
200 		
201 		auto p = g_proxy_resolver_lookup_finish(getProxyResolverTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
202 		
203 		if (err !is null)
204 		{
205 			throw new GException( new ErrorG(err) );
206 		}
207 		
208 		return Str.toStringArray(p);
209 	}
210 }