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