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