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.ProxyT; 26 27 public import gio.AsyncResultIF; 28 public import gio.Cancellable; 29 public import gio.IOStream; 30 public import gio.ProxyAddress; 31 public import gio.ProxyIF; 32 public import gio.c.functions; 33 public import gio.c.types; 34 public import glib.ErrorG; 35 public import glib.GException; 36 public import glib.Str; 37 public import gobject.ObjectG; 38 public import gtkc.giotypes; 39 40 41 /** 42 * A #GProxy handles connecting to a remote host via a given type of 43 * proxy server. It is implemented by the 'gio-proxy' extension point. 44 * The extensions are named after their proxy protocol name. As an 45 * example, a SOCKS5 proxy implementation can be retrieved with the 46 * name 'socks5' using the function 47 * g_io_extension_point_get_extension_by_name(). 48 * 49 * Since: 2.26 50 */ 51 public template ProxyT(TStruct) 52 { 53 /** Get the main Gtk struct */ 54 public GProxy* getProxyStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return cast(GProxy*)getStruct(); 59 } 60 61 62 /** 63 * Given @connection to communicate with a proxy (eg, a 64 * #GSocketConnection that is connected to the proxy server), this 65 * does the necessary handshake to connect to @proxy_address, and if 66 * required, wraps the #GIOStream to handle proxy payload. 67 * 68 * Params: 69 * connection = a #GIOStream 70 * proxyAddress = a #GProxyAddress 71 * cancellable = a #GCancellable 72 * 73 * Returns: a #GIOStream that will replace @connection. This might 74 * be the same as @connection, in which case a reference 75 * will be added. 76 * 77 * Since: 2.26 78 * 79 * Throws: GException on failure. 80 */ 81 public IOStream connect(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable) 82 { 83 GError* err = null; 84 85 auto __p = g_proxy_connect(getProxyStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 86 87 if (err !is null) 88 { 89 throw new GException( new ErrorG(err) ); 90 } 91 92 if(__p is null) 93 { 94 return null; 95 } 96 97 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p, true); 98 } 99 100 /** 101 * Asynchronous version of g_proxy_connect(). 102 * 103 * Params: 104 * connection = a #GIOStream 105 * proxyAddress = a #GProxyAddress 106 * cancellable = a #GCancellable 107 * callback = a #GAsyncReadyCallback 108 * userData = callback data 109 * 110 * Since: 2.26 111 */ 112 public void connectAsync(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 113 { 114 g_proxy_connect_async(getProxyStruct(), (connection is null) ? null : connection.getIOStreamStruct(), (proxyAddress is null) ? null : proxyAddress.getProxyAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 115 } 116 117 /** 118 * See g_proxy_connect(). 119 * 120 * Params: 121 * result = a #GAsyncResult 122 * 123 * Returns: a #GIOStream. 124 * 125 * Since: 2.26 126 * 127 * Throws: GException on failure. 128 */ 129 public IOStream connectFinish(AsyncResultIF result) 130 { 131 GError* err = null; 132 133 auto __p = g_proxy_connect_finish(getProxyStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 134 135 if (err !is null) 136 { 137 throw new GException( new ErrorG(err) ); 138 } 139 140 if(__p is null) 141 { 142 return null; 143 } 144 145 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p, true); 146 } 147 148 /** 149 * Some proxy protocols expect to be passed a hostname, which they 150 * will resolve to an IP address themselves. Others, like SOCKS4, do 151 * not allow this. This function will return %FALSE if @proxy is 152 * implementing such a protocol. When %FALSE is returned, the caller 153 * should resolve the destination hostname first, and then pass a 154 * #GProxyAddress containing the stringified IP address to 155 * g_proxy_connect() or g_proxy_connect_async(). 156 * 157 * Returns: %TRUE if hostname resolution is supported. 158 * 159 * Since: 2.26 160 */ 161 public bool supportsHostname() 162 { 163 return g_proxy_supports_hostname(getProxyStruct()) != 0; 164 } 165 }