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