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.ProxyResolverT;
26 
27 public  import gio.AsyncResultIF;
28 public  import gio.Cancellable;
29 public  import gio.ProxyResolver;
30 public  import gio.ProxyResolverIF;
31 public  import glib.ErrorG;
32 public  import glib.GException;
33 public  import glib.Str;
34 public  import gobject.ObjectG;
35 public  import gtkc.gio;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * #GProxyResolver provides synchronous and asynchronous network proxy
41  * resolution. #GProxyResolver is used within #GSocketClient through
42  * the method g_socket_connectable_proxy_enumerate().
43  *
44  * Since: 2.26
45  */
46 public template ProxyResolverT(TStruct)
47 {
48 	/** Get the main Gtk struct */
49 	public GProxyResolver* getProxyResolverStruct()
50 	{
51 		return cast(GProxyResolver*)getStruct();
52 	}
53 
54 
55 	/**
56 	 * Gets the default #GProxyResolver for the system.
57 	 *
58 	 * Return: the default #GProxyResolver.
59 	 *
60 	 * Since: 2.26
61 	 */
62 	public static ProxyResolverIF getDefault()
63 	{
64 		auto p = g_proxy_resolver_get_default();
65 		
66 		if(p is null)
67 		{
68 			return null;
69 		}
70 		
71 		return ObjectG.getDObject!(ProxyResolver, ProxyResolverIF)(cast(GProxyResolver*) p);
72 	}
73 
74 	/**
75 	 * Checks if @resolver can be used on this system. (This is used
76 	 * internally; g_proxy_resolver_get_default() will only return a proxy
77 	 * resolver that returns %TRUE for this method.)
78 	 *
79 	 * Return: %TRUE if @resolver is supported.
80 	 *
81 	 * Since: 2.26
82 	 */
83 	public bool isSupported()
84 	{
85 		return g_proxy_resolver_is_supported(getProxyResolverStruct()) != 0;
86 	}
87 
88 	/**
89 	 * Looks into the system proxy configuration to determine what proxy,
90 	 * if any, to use to connect to @uri. The returned proxy URIs are of
91 	 * the form `<protocol>://[user[:password]@]host:port` or
92 	 * `direct://`, where <protocol> could be http, rtsp, socks
93 	 * or other proxying protocol.
94 	 *
95 	 * If you don't know what network protocol is being used on the
96 	 * socket, you should use `none` as the URI protocol.
97 	 * In this case, the resolver might still return a generic proxy type
98 	 * (such as SOCKS), but would not return protocol-specific proxy types
99 	 * (such as http).
100 	 *
101 	 * `direct://` is used when no proxy is needed.
102 	 * Direct connection should not be attempted unless it is part of the
103 	 * returned array of proxies.
104 	 *
105 	 * Params:
106 	 *     uri = a URI representing the destination to connect to
107 	 *     cancellable = a #GCancellable, or %NULL
108 	 *
109 	 * Return: A
110 	 *     NULL-terminated array of proxy URIs. Must be freed
111 	 *     with g_strfreev().
112 	 *
113 	 * Since: 2.26
114 	 *
115 	 * Throws: GException on failure.
116 	 */
117 	public string[] lookup(string uri, Cancellable cancellable)
118 	{
119 		GError* err = null;
120 		
121 		auto p = g_proxy_resolver_lookup(getProxyResolverStruct(), Str.toStringz(uri), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
122 		
123 		if (err !is null)
124 		{
125 			throw new GException( new ErrorG(err) );
126 		}
127 		
128 		return Str.toStringArray(p);
129 	}
130 
131 	/**
132 	 * Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more
133 	 * details.
134 	 *
135 	 * Params:
136 	 *     uri = a URI representing the destination to connect to
137 	 *     cancellable = a #GCancellable, or %NULL
138 	 *     callback = callback to call after resolution completes
139 	 *     userData = data for @callback
140 	 *
141 	 * Since: 2.26
142 	 */
143 	public void lookupAsync(string uri, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
144 	{
145 		g_proxy_resolver_lookup_async(getProxyResolverStruct(), Str.toStringz(uri), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
146 	}
147 
148 	/**
149 	 * Call this function to obtain the array of proxy URIs when
150 	 * g_proxy_resolver_lookup_async() is complete. See
151 	 * g_proxy_resolver_lookup() for more details.
152 	 *
153 	 * Params:
154 	 *     result = the result passed to your #GAsyncReadyCallback
155 	 *
156 	 * Return: A
157 	 *     NULL-terminated array of proxy URIs. Must be freed
158 	 *     with g_strfreev().
159 	 *
160 	 * Since: 2.26
161 	 *
162 	 * Throws: GException on failure.
163 	 */
164 	public string[] lookupFinish(AsyncResultIF result)
165 	{
166 		GError* err = null;
167 		
168 		auto p = g_proxy_resolver_lookup_finish(getProxyResolverStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err);
169 		
170 		if (err !is null)
171 		{
172 			throw new GException( new ErrorG(err) );
173 		}
174 		
175 		return Str.toStringArray(p);
176 	}
177 }