// 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;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class CookieManager : GLib.Object {

		public CookieManager (IntPtr raw) : base(raw) {}

		protected CookieManager() : base(IntPtr.Zero)
		{
			CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
		}

		[GLib.Signal("changed")]
		public event System.EventHandler Changed {
			add {
				this.AddSignalHandler ("changed", value);
			}
			remove {
				this.RemoveSignalHandler ("changed", value);
			}
		}

		static ChangedNativeDelegate Changed_cb_delegate;
		static ChangedNativeDelegate ChangedVMCallback {
			get {
				if (Changed_cb_delegate == null)
					Changed_cb_delegate = new ChangedNativeDelegate (Changed_cb);
				return Changed_cb_delegate;
			}
		}

		static void OverrideChanged (GLib.GType gtype)
		{
			OverrideChanged (gtype, ChangedVMCallback);
		}

		static void OverrideChanged (GLib.GType gtype, ChangedNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "changed", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void ChangedNativeDelegate (IntPtr inst);

		static void Changed_cb (IntPtr inst)
		{
			try {
				CookieManager __obj = GLib.Object.GetObject (inst, false) as CookieManager;
				__obj.OnChanged ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.CookieManager), ConnectionMethod="OverrideChanged")]
		protected virtual void OnChanged ()
		{
			InternalChanged ();
		}

		private void InternalChanged ()
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (1);
			GLib.Value[] vals = new GLib.Value [1];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("_webkit_reserved0"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // _webkit_reserved0
							, null
							, "_webkit_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved1
							, "_webkit_reserved0"
							, "_webkit_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved2
							, "_webkit_reserved1"
							, "_webkit_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved3
							, "_webkit_reserved2"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_webkit_cookie_manager_add_cookie_finish(IntPtr raw, IntPtr _result, out IntPtr error);
		static d_webkit_cookie_manager_add_cookie_finish webkit_cookie_manager_add_cookie_finish = FuncLoader.LoadFunction<d_webkit_cookie_manager_add_cookie_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_add_cookie_finish"));

		public unsafe bool AddCookieFinish(GLib.IAsyncResult _result) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = webkit_cookie_manager_add_cookie_finish(Handle, _result == null ? IntPtr.Zero : ((_result is GLib.Object) ? (_result as GLib.Object).Handle : (_result as GLib.AsyncResultAdapter).Handle), out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

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

		[Obsolete]
		public void DeleteAllCookies() {
			webkit_cookie_manager_delete_all_cookies(Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_webkit_cookie_manager_delete_cookie_finish(IntPtr raw, IntPtr _result, out IntPtr error);
		static d_webkit_cookie_manager_delete_cookie_finish webkit_cookie_manager_delete_cookie_finish = FuncLoader.LoadFunction<d_webkit_cookie_manager_delete_cookie_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_delete_cookie_finish"));

		public unsafe bool DeleteCookieFinish(GLib.IAsyncResult _result) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = webkit_cookie_manager_delete_cookie_finish(Handle, _result == null ? IntPtr.Zero : ((_result is GLib.Object) ? (_result as GLib.Object).Handle : (_result as GLib.AsyncResultAdapter).Handle), out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_cookie_manager_delete_cookies_for_domain(IntPtr raw, IntPtr domain);
		static d_webkit_cookie_manager_delete_cookies_for_domain webkit_cookie_manager_delete_cookies_for_domain = FuncLoader.LoadFunction<d_webkit_cookie_manager_delete_cookies_for_domain>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_delete_cookies_for_domain"));

		[Obsolete]
		public void DeleteCookiesForDomain(string domain) {
			IntPtr native_domain = GLib.Marshaller.StringToPtrGStrdup (domain);
			webkit_cookie_manager_delete_cookies_for_domain(Handle, native_domain);
			GLib.Marshaller.Free (native_domain);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_cookie_manager_get_accept_policy(IntPtr raw, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_webkit_cookie_manager_get_accept_policy webkit_cookie_manager_get_accept_policy = FuncLoader.LoadFunction<d_webkit_cookie_manager_get_accept_policy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_get_accept_policy"));

		public void GetAcceptPolicy(GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			webkit_cookie_manager_get_accept_policy(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		public void GetAcceptPolicy() {
			GetAcceptPolicy (null, null);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_webkit_cookie_manager_get_accept_policy_finish(IntPtr raw, IntPtr _result, out IntPtr error);
		static d_webkit_cookie_manager_get_accept_policy_finish webkit_cookie_manager_get_accept_policy_finish = FuncLoader.LoadFunction<d_webkit_cookie_manager_get_accept_policy_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_get_accept_policy_finish"));

		public unsafe WebKit.CookieAcceptPolicy GetAcceptPolicyFinish(GLib.IAsyncResult _result) {
			IntPtr error = IntPtr.Zero;
			int raw_ret = webkit_cookie_manager_get_accept_policy_finish(Handle, _result == null ? IntPtr.Zero : ((_result is GLib.Object) ? (_result as GLib.Object).Handle : (_result as GLib.AsyncResultAdapter).Handle), out error);
			WebKit.CookieAcceptPolicy ret = (WebKit.CookieAcceptPolicy) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_cookie_manager_get_cookies(IntPtr raw, IntPtr uri, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_webkit_cookie_manager_get_cookies webkit_cookie_manager_get_cookies = FuncLoader.LoadFunction<d_webkit_cookie_manager_get_cookies>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_get_cookies"));

		public void GetCookies(string uri, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			webkit_cookie_manager_get_cookies(Handle, native_uri, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (native_uri);
		}

		public void GetCookies(string uri) {
			GetCookies (uri, null, null);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_cookie_manager_get_cookies_finish(IntPtr raw, IntPtr _result, out IntPtr error);
		static d_webkit_cookie_manager_get_cookies_finish webkit_cookie_manager_get_cookies_finish = FuncLoader.LoadFunction<d_webkit_cookie_manager_get_cookies_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_get_cookies_finish"));

		public unsafe GLib.List[] GetCookiesFinish(GLib.IAsyncResult _result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = webkit_cookie_manager_get_cookies_finish(Handle, _result == null ? IntPtr.Zero : ((_result is GLib.Object) ? (_result as GLib.Object).Handle : (_result as GLib.AsyncResultAdapter).Handle), out error);
			GLib.List[] ret = GLib.Marshaller.ListPtrToArray<GLib.List, GLib.List> (raw_ret, true, true);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_cookie_manager_get_domains_with_cookies(IntPtr raw, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_webkit_cookie_manager_get_domains_with_cookies webkit_cookie_manager_get_domains_with_cookies = FuncLoader.LoadFunction<d_webkit_cookie_manager_get_domains_with_cookies>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_get_domains_with_cookies"));

		[Obsolete]
		public void GetDomainsWithCookies(GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			webkit_cookie_manager_get_domains_with_cookies(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		public void GetDomainsWithCookies() {
			GetDomainsWithCookies (null, null);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_cookie_manager_get_domains_with_cookies_finish(IntPtr raw, IntPtr _result, out IntPtr error);
		static d_webkit_cookie_manager_get_domains_with_cookies_finish webkit_cookie_manager_get_domains_with_cookies_finish = FuncLoader.LoadFunction<d_webkit_cookie_manager_get_domains_with_cookies_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_get_domains_with_cookies_finish"));

		[Obsolete]
		public unsafe string[] GetDomainsWithCookiesFinish(GLib.IAsyncResult _result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = webkit_cookie_manager_get_domains_with_cookies_finish(Handle, _result == null ? IntPtr.Zero : ((_result is GLib.Object) ? (_result as GLib.Object).Handle : (_result as GLib.AsyncResultAdapter).Handle), out error);
			string[] ret = GLib.Marshaller.NullTermPtrToStringArray (raw_ret, true);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_cookie_manager_set_accept_policy(IntPtr raw, int policy);
		static d_webkit_cookie_manager_set_accept_policy webkit_cookie_manager_set_accept_policy = FuncLoader.LoadFunction<d_webkit_cookie_manager_set_accept_policy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_set_accept_policy"));

		public void SetAcceptPolicy(WebKit.CookieAcceptPolicy policy) {
			webkit_cookie_manager_set_accept_policy(Handle, (int) policy);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_cookie_manager_set_persistent_storage(IntPtr raw, IntPtr filename, int storage);
		static d_webkit_cookie_manager_set_persistent_storage webkit_cookie_manager_set_persistent_storage = FuncLoader.LoadFunction<d_webkit_cookie_manager_set_persistent_storage>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_cookie_manager_set_persistent_storage"));

		public void SetPersistentStorage(string filename, WebKit.CookiePersistentStorage storage) {
			IntPtr native_filename = GLib.Marshaller.StringToPtrGStrdup (filename);
			webkit_cookie_manager_set_persistent_storage(Handle, native_filename, (int) storage);
			GLib.Marshaller.Free (native_filename);
		}


		static CookieManager ()
		{
			GtkSharp.WebkitGtkSharp.ObjectManager.Initialize ();
		}

		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, GLib.Object.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
