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