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(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return cast(GProxyResolver*)getStruct();
54 	}
55 
56 
57 	/**
58 	 * Gets the default #GProxyResolver for the system.
59 	 *
60 	 * Returns: 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 	 * Returns: %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 	 * Returns: 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 retStr = 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 		scope(exit) Str.freeStringArray(retStr);
131 		return Str.toStringArray(retStr);
132 	}
133 
134 	/**
135 	 * Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more
136 	 * details.
137 	 *
138 	 * Params:
139 	 *     uri = a URI representing the destination to connect to
140 	 *     cancellable = a #GCancellable, or %NULL
141 	 *     callback = callback to call after resolution completes
142 	 *     userData = data for @callback
143 	 *
144 	 * Since: 2.26
145 	 */
146 	public void lookupAsync(string uri, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
147 	{
148 		g_proxy_resolver_lookup_async(getProxyResolverStruct(), Str.toStringz(uri), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
149 	}
150 
151 	/**
152 	 * Call this function to obtain the array of proxy URIs when
153 	 * g_proxy_resolver_lookup_async() is complete. See
154 	 * g_proxy_resolver_lookup() for more details.
155 	 *
156 	 * Params:
157 	 *     result = the result passed to your #GAsyncReadyCallback
158 	 *
159 	 * Returns: A
160 	 *     NULL-terminated array of proxy URIs. Must be freed
161 	 *     with g_strfreev().
162 	 *
163 	 * Since: 2.26
164 	 *
165 	 * Throws: GException on failure.
166 	 */
167 	public string[] lookupFinish(AsyncResultIF result)
168 	{
169 		GError* err = null;
170 		
171 		auto retStr = g_proxy_resolver_lookup_finish(getProxyResolverStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err);
172 		
173 		if (err !is null)
174 		{
175 			throw new GException( new ErrorG(err) );
176 		}
177 		
178 		scope(exit) Str.freeStringArray(retStr);
179 		return Str.toStringArray(retStr);
180 	}
181 }