source: appstream-generator/build/girepo/gio/ProxyT.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 5.2 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.ProxyT;
22
23public  import gi.gio;
24public  import gi.giotypes;
25public  import gio.AsyncResultIF;
26public  import gio.Cancellable;
27public  import gio.IOStream;
28public  import gio.Proxy;
29public  import gio.ProxyAddress;
30public  import gio.ProxyIF;
31public  import glib.ErrorG;
32public  import glib.GException;
33public  import glib.Str;
34public  import gobject.ObjectG;
35
36
37/**
38 * A #GProxy handles connecting to a remote host via a given type of
39 * proxy server. It is implemented by the 'gio-proxy' extension point.
40 * The extensions are named after their proxy protocol name. As an
41 * example, a SOCKS5 proxy implementation can be retrieved with the
42 * name 'socks5' using the function
43 * g_io_extension_point_get_extension_by_name().
44 *
45 * Since: 2.26
46 */
47public template ProxyT(TStruct)
48{
49        /** Get the main Gtk struct */
50        public GProxy* getProxyStruct()
51        {
52                return cast(GProxy*)getStruct();
53        }
54
55
56        /**
57         * Lookup "gio-proxy" extension point for a proxy implementation that supports
58         * specified protocol.
59         *
60         * Params:
61         *     protocol = the proxy protocol name (e.g. http, socks, etc)
62         *
63         * Returns: return a #GProxy or NULL if protocol
64         *     is not supported.
65         *
66         * Since: 2.26
67         */
68        public static ProxyIF getDefaultForProtocol(string protocol)
69        {
70                auto p = g_proxy_get_default_for_protocol(Str.toStringz(protocol));
71               
72                if(p is null)
73                {
74                        return null;
75                }
76               
77                return ObjectG.getDObject!(Proxy, ProxyIF)(cast(GProxy*) p, true);
78        }
79
80        /**
81         * Given @connection to communicate with a proxy (eg, a
82         * #GSocketConnection that is connected to the proxy server), this
83         * does the necessary handshake to connect to @proxy_address, and if
84         * required, wraps the #GIOStream to handle proxy payload.
85         *
86         * Params:
87         *     connection = a #GIOStream
88         *     proxyAddress = a #GProxyAddress
89         *     cancellable = a #GCancellable
90         *
91         * Returns: a #GIOStream that will replace @connection. This might
92         *     be the same as @connection, in which case a reference
93         *     will be added.
94         *
95         * Since: 2.26
96         *
97         * Throws: GException on failure.
98         */
99        public IOStream connect(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable)
100        {
101                GError* err = null;
102               
103                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);
104               
105                if (err !is null)
106                {
107                        throw new GException( new ErrorG(err) );
108                }
109               
110                if(p is null)
111                {
112                        return null;
113                }
114               
115                return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p, true);
116        }
117
118        /**
119         * Asynchronous version of g_proxy_connect().
120         *
121         * Params:
122         *     connection = a #GIOStream
123         *     proxyAddress = a #GProxyAddress
124         *     cancellable = a #GCancellable
125         *     callback = a #GAsyncReadyCallback
126         *     userData = callback data
127         *
128         * Since: 2.26
129         */
130        public void connectAsync(IOStream connection, ProxyAddress proxyAddress, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
131        {
132                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);
133        }
134
135        /**
136         * See g_proxy_connect().
137         *
138         * Params:
139         *     result = a #GAsyncResult
140         *
141         * Returns: a #GIOStream.
142         *
143         * Since: 2.26
144         *
145         * Throws: GException on failure.
146         */
147        public IOStream connectFinish(AsyncResultIF result)
148        {
149                GError* err = null;
150               
151                auto p = g_proxy_connect_finish(getProxyStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err);
152               
153                if (err !is null)
154                {
155                        throw new GException( new ErrorG(err) );
156                }
157               
158                if(p is null)
159                {
160                        return null;
161                }
162               
163                return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p, true);
164        }
165
166        /**
167         * Some proxy protocols expect to be passed a hostname, which they
168         * will resolve to an IP address themselves. Others, like SOCKS4, do
169         * not allow this. This function will return %FALSE if @proxy is
170         * implementing such a protocol. When %FALSE is returned, the caller
171         * should resolve the destination hostname first, and then pass a
172         * #GProxyAddress containing the stringified IP address to
173         * g_proxy_connect() or g_proxy_connect_async().
174         *
175         * Returns: %TRUE if hostname resolution is supported.
176         *
177         * Since: 2.26
178         */
179        public bool supportsHostname()
180        {
181                return g_proxy_supports_hostname(getProxyStruct()) != 0;
182        }
183}
Note: See TracBrowser for help on using the repository browser.