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.SimpleProxyResolver;
26 
27 private import gio.ProxyResolverIF;
28 private import gio.ProxyResolverT;
29 private import gio.c.functions;
30 public  import gio.c.types;
31 private import glib.ConstructionException;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 public  import gtkc.giotypes;
35 
36 
37 /**
38  * #GSimpleProxyResolver is a simple #GProxyResolver implementation
39  * that handles a single default proxy, multiple URI-scheme-specific
40  * proxies, and a list of hosts that proxies should not be used for.
41  * 
42  * #GSimpleProxyResolver is never the default proxy resolver, but it
43  * can be used as the base class for another proxy resolver
44  * implementation, or it can be created and used manually, such as
45  * with g_socket_client_set_proxy_resolver().
46  *
47  * Since: 2.36
48  */
49 public class SimpleProxyResolver : ObjectG, ProxyResolverIF
50 {
51 	/** the main Gtk struct */
52 	protected GSimpleProxyResolver* gSimpleProxyResolver;
53 
54 	/** Get the main Gtk struct */
55 	public GSimpleProxyResolver* getSimpleProxyResolverStruct(bool transferOwnership = false)
56 	{
57 		if (transferOwnership)
58 			ownedRef = false;
59 		return gSimpleProxyResolver;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected override void* getStruct()
64 	{
65 		return cast(void*)gSimpleProxyResolver;
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GSimpleProxyResolver* gSimpleProxyResolver, bool ownedRef = false)
72 	{
73 		this.gSimpleProxyResolver = gSimpleProxyResolver;
74 		super(cast(GObject*)gSimpleProxyResolver, ownedRef);
75 	}
76 
77 	// add the ProxyResolver capabilities
78 	mixin ProxyResolverT!(GSimpleProxyResolver);
79 
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return g_simple_proxy_resolver_get_type();
85 	}
86 
87 	/**
88 	 * Creates a new #GSimpleProxyResolver. See
89 	 * #GSimpleProxyResolver:default-proxy and
90 	 * #GSimpleProxyResolver:ignore-hosts for more details on how the
91 	 * arguments are interpreted.
92 	 *
93 	 * Params:
94 	 *     defaultProxy = the default proxy to use, eg
95 	 *         "socks://192.168.1.1"
96 	 *     ignoreHosts = an optional list of hosts/IP addresses
97 	 *         to not use a proxy for.
98 	 *
99 	 * Returns: a new #GSimpleProxyResolver
100 	 *
101 	 * Since: 2.36
102 	 *
103 	 * Throws: ConstructionException GTK+ fails to create the object.
104 	 */
105 	public this(string defaultProxy, string[] ignoreHosts)
106 	{
107 		auto __p = g_simple_proxy_resolver_new(Str.toStringz(defaultProxy), Str.toStringzArray(ignoreHosts));
108 
109 		if(__p is null)
110 		{
111 			throw new ConstructionException("null returned by new");
112 		}
113 
114 		this(cast(GSimpleProxyResolver*) __p, true);
115 	}
116 
117 	/**
118 	 * Sets the default proxy on @resolver, to be used for any URIs that
119 	 * don't match #GSimpleProxyResolver:ignore-hosts or a proxy set
120 	 * via g_simple_proxy_resolver_set_uri_proxy().
121 	 *
122 	 * If @default_proxy starts with "socks://",
123 	 * #GSimpleProxyResolver will treat it as referring to all three of
124 	 * the socks5, socks4a, and socks4 proxy types.
125 	 *
126 	 * Params:
127 	 *     defaultProxy = the default proxy to use
128 	 *
129 	 * Since: 2.36
130 	 */
131 	public void setDefaultProxy(string defaultProxy)
132 	{
133 		g_simple_proxy_resolver_set_default_proxy(gSimpleProxyResolver, Str.toStringz(defaultProxy));
134 	}
135 
136 	/**
137 	 * Sets the list of ignored hosts.
138 	 *
139 	 * See #GSimpleProxyResolver:ignore-hosts for more details on how the
140 	 * @ignore_hosts argument is interpreted.
141 	 *
142 	 * Params:
143 	 *     ignoreHosts = %NULL-terminated list of hosts/IP addresses
144 	 *         to not use a proxy for
145 	 *
146 	 * Since: 2.36
147 	 */
148 	public void setIgnoreHosts(string[] ignoreHosts)
149 	{
150 		g_simple_proxy_resolver_set_ignore_hosts(gSimpleProxyResolver, Str.toStringzArray(ignoreHosts));
151 	}
152 
153 	/**
154 	 * Adds a URI-scheme-specific proxy to @resolver; URIs whose scheme
155 	 * matches @uri_scheme (and which don't match
156 	 * #GSimpleProxyResolver:ignore-hosts) will be proxied via @proxy.
157 	 *
158 	 * As with #GSimpleProxyResolver:default-proxy, if @proxy starts with
159 	 * "socks://", #GSimpleProxyResolver will treat it
160 	 * as referring to all three of the socks5, socks4a, and socks4 proxy
161 	 * types.
162 	 *
163 	 * Params:
164 	 *     uriScheme = the URI scheme to add a proxy for
165 	 *     proxy = the proxy to use for @uri_scheme
166 	 *
167 	 * Since: 2.36
168 	 */
169 	public void setUriProxy(string uriScheme, string proxy)
170 	{
171 		g_simple_proxy_resolver_set_uri_proxy(gSimpleProxyResolver, Str.toStringz(uriScheme), Str.toStringz(proxy));
172 	}
173 }