// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace WebKit {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	[StructLayout(LayoutKind.Sequential)]
	public partial struct NetworkProxySettings : IEquatable<NetworkProxySettings> {


		public static WebKit.NetworkProxySettings Zero = new WebKit.NetworkProxySettings ();

		public static WebKit.NetworkProxySettings New(IntPtr raw) {
			if (raw == IntPtr.Zero)
				return WebKit.NetworkProxySettings.Zero;
			return (WebKit.NetworkProxySettings) Marshal.PtrToStructure (raw, typeof (WebKit.NetworkProxySettings));
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_network_proxy_settings_new(IntPtr default_proxy_uri, IntPtr[] ignore_hosts);
		static d_webkit_network_proxy_settings_new webkit_network_proxy_settings_new = FuncLoader.LoadFunction<d_webkit_network_proxy_settings_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_network_proxy_settings_new"));

		public static NetworkProxySettings New(string default_proxy_uri, string[] ignore_hosts)
		{
			IntPtr native_default_proxy_uri = GLib.Marshaller.StringToPtrGStrdup (default_proxy_uri);
			int cnt_ignore_hosts = ignore_hosts == null ? 0 : ignore_hosts.Length;
			IntPtr[] native_ignore_hosts = new IntPtr [cnt_ignore_hosts + 1];
			for (int i = 0; i < cnt_ignore_hosts; i++)
				native_ignore_hosts [i] = GLib.Marshaller.StringToPtrGStrdup (ignore_hosts[i]);
			native_ignore_hosts [cnt_ignore_hosts] = IntPtr.Zero;
			NetworkProxySettings result = NetworkProxySettings.New (webkit_network_proxy_settings_new(native_default_proxy_uri, native_ignore_hosts));
			GLib.Marshaller.Free (native_default_proxy_uri);
			for (int i = 0; i < native_ignore_hosts.Length - 1; i++) {
				ignore_hosts [i] = GLib.Marshaller.Utf8PtrToString (native_ignore_hosts[i]);
				GLib.Marshaller.Free (native_ignore_hosts[i]);
			}
			return result;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_network_proxy_settings_get_type();
		static d_webkit_network_proxy_settings_get_type webkit_network_proxy_settings_get_type = FuncLoader.LoadFunction<d_webkit_network_proxy_settings_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_network_proxy_settings_get_type"));

		public static GLib.GType GType { 
			get {
				IntPtr raw_ret = webkit_network_proxy_settings_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_network_proxy_settings_add_proxy_for_scheme(IntPtr raw, IntPtr scheme, IntPtr proxy_uri);
		static d_webkit_network_proxy_settings_add_proxy_for_scheme webkit_network_proxy_settings_add_proxy_for_scheme = FuncLoader.LoadFunction<d_webkit_network_proxy_settings_add_proxy_for_scheme>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_network_proxy_settings_add_proxy_for_scheme"));

		public void AddProxyForScheme(string scheme, string proxy_uri) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.NetworkProxySettings>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr native_scheme = GLib.Marshaller.StringToPtrGStrdup (scheme);
			IntPtr native_proxy_uri = GLib.Marshaller.StringToPtrGStrdup (proxy_uri);
			webkit_network_proxy_settings_add_proxy_for_scheme(this_as_native, native_scheme, native_proxy_uri);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			GLib.Marshaller.Free (native_scheme);
			GLib.Marshaller.Free (native_proxy_uri);
		}

		static void ReadNative (IntPtr native, ref WebKit.NetworkProxySettings target)
		{
			target = New (native);
		}

		public bool Equals (NetworkProxySettings other)
		{
			return true;
		}

		public override bool Equals (object other)
		{
			return other is NetworkProxySettings && Equals ((NetworkProxySettings) other);
		}

		public override int GetHashCode ()
		{
			return this.GetType ().FullName.GetHashCode ();
		}

		public static explicit operator GLib.Value (WebKit.NetworkProxySettings boxed)
		{
			GLib.Value val = GLib.Value.Empty;
			val.Init (WebKit.NetworkProxySettings.GType);
			val.Val = boxed;
			return val;
		}

		public static explicit operator WebKit.NetworkProxySettings (GLib.Value val)
		{
			return (WebKit.NetworkProxySettings) val.Val;
		}
#endregion
	}
}
