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 * Conversion parameters: 26 * inFile = GProxy.html 27 * outPack = gio 28 * outFile = ProxyT 29 * strct = GProxy 30 * realStrct= 31 * ctorStrct= 32 * clss = ProxyT 33 * interf = ProxyIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - g_initable_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.GException 50 * - gio.AsyncResultIF 51 * - gio.Cancellable 52 * - gio.IOStream 53 * - gio.ProxyAddress 54 * structWrap: 55 * - GAsyncResult* -> AsyncResultIF 56 * - GCancellable* -> Cancellable 57 * - GIOStream* -> IOStream 58 * - GProxy* -> ProxyIF 59 * - GProxyAddress* -> ProxyAddress 60 * module aliases: 61 * local aliases: 62 * overrides: 63 */ 64 65 module gio.ProxyT; 66 67 public import gtkc.giotypes; 68 69 public import gtkc.gio; 70 public import glib.ConstructionException; 71 public import gobject.ObjectG; 72 73 74 public import glib.Str; 75 public import glib.ErrorG; 76 public import glib.GException; 77 public import gio.AsyncResultIF; 78 public import gio.Cancellable; 79 public import gio.IOStream; 80 public import gio.ProxyAddress; 81 82 83 84 85 /** 86 * Description 87 * A GProxy handles connecting to a remote host via a given type of 88 * proxy server. It is implemented by the 'gio-proxy' extension point. 89 * The extensions are named after their proxy protocol name. As an 90 * example, a SOCKS5 proxy implementation can be retrieved with the 91 * name 'socks5' using the function 92 * g_io_extension_point_get_extension_by_name(). 93 */ 94 public template ProxyT(TStruct) 95 { 96 97 /** the main Gtk struct */ 98 protected GProxy* gProxy; 99 100 101 public GProxy* getProxyTStruct() 102 { 103 return cast(GProxy*)getStruct(); 104 } 105 106 107 /** 108 */ 109 110 /** 111 * Given connection to communicate with a proxy (eg, a 112 * GSocketConnection that is connected to the proxy server), this 113 * does the necessary handshake to connect to proxy_address, and if 114 * required, wraps the GIOStream to handle proxy payload. 115 * Since 2.26 116 * Params: 117 * proxy = a GProxy 118 * connection = a GIOStream 119 * proxyAddress = a GProxyAddress 120 * cancellable = a GCancellable. [allow-none] 121 * Returns: a GIOStream that will replace connection. This might be the same as connection, in which case a reference will be added. [transfer full] 122 * Throws: GException on failure. 123 */ 124 public IOStream gProxyConnect(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable) 125 { 126 // GIOStream * g_proxy_connect (GProxy *proxy, GIOStream *connection, GProxyAddress *proxy_address, GCancellable *cancellable, GError **error); 127 GError* err = null; 128 129 auto p = g_proxy_connect(getProxyTStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 130 131 if (err !is null) 132 { 133 throw new GException( new ErrorG(err) ); 134 } 135 136 137 if(p is null) 138 { 139 return null; 140 } 141 142 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p); 143 } 144 145 /** 146 * Asynchronous version of g_proxy_connect(). 147 * Since 2.26 148 * Params: 149 * proxy = a GProxy 150 * connection = a GIOStream 151 * proxyAddress = a GProxyAddress 152 * cancellable = a GCancellable. [allow-none] 153 * callback = a GAsyncReadyCallback. [scope async] 154 * userData = callback data. [closure] 155 */ 156 public void gProxyConnectAsync(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 157 { 158 // void g_proxy_connect_async (GProxy *proxy, GIOStream *connection, GProxyAddress *proxy_address, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 159 g_proxy_connect_async(getProxyTStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 160 } 161 162 /** 163 * See g_proxy_connect(). 164 * Since 2.26 165 * Params: 166 * result = a GAsyncRetult 167 * Returns: a GIOStream. [transfer full] 168 * Throws: GException on failure. 169 */ 170 public IOStream gProxyConnectFinish(AsyncResultIF result) 171 { 172 // GIOStream * g_proxy_connect_finish (GProxy *proxy, GAsyncResult *result, GError **error); 173 GError* err = null; 174 175 auto p = g_proxy_connect_finish(getProxyTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err); 176 177 if (err !is null) 178 { 179 throw new GException( new ErrorG(err) ); 180 } 181 182 183 if(p is null) 184 { 185 return null; 186 } 187 188 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p); 189 } 190 191 /** 192 * Lookup "gio-proxy" extension point for a proxy implementation that supports 193 * specified protocol. 194 * Since 2.26 195 * Params: 196 * protocol = the proxy protocol name (e.g. http, socks, etc) 197 * Returns: return a GProxy or NULL if protocol is not supported. [transfer full] 198 */ 199 public static ProxyIF gProxyGetDefaultForProtocol(string protocol) 200 { 201 // GProxy * g_proxy_get_default_for_protocol (const gchar *protocol); 202 auto p = g_proxy_get_default_for_protocol(Str.toStringz(protocol)); 203 204 if(p is null) 205 { 206 return null; 207 } 208 209 return ObjectG.getDObject!(Proxy, ProxyIF)(cast(GProxy*) p); 210 } 211 212 /** 213 * Some proxy protocols expect to be passed a hostname, which they 214 * will resolve to an IP address themselves. Others, like SOCKS4, do 215 * not allow this. This function will return FALSE if proxy is 216 * implementing such a protocol. When FALSE is returned, the caller 217 * should resolve the destination hostname first, and then pass a 218 * GProxyAddress containing the stringified IP address to 219 * g_proxy_connect() or g_proxy_connect_async(). 220 * Since 2.26 221 * Returns: TRUE if hostname resolution is supported. 222 */ 223 public int gProxySupportsHostname() 224 { 225 // gboolean g_proxy_supports_hostname (GProxy *proxy); 226 return g_proxy_supports_hostname(getProxyTStruct()); 227 } 228 }