// 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 WebResource : GLib.Object {

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

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

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

		[GLib.Property ("response")]
		public WebKit.URIResponse Response {
			get  {
				IntPtr raw_ret = webkit_web_resource_get_response(Handle);
				WebKit.URIResponse ret = GLib.Object.GetObject(raw_ret) as WebKit.URIResponse;
				return ret;
			}
		}

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

		[GLib.Property ("uri")]
		public string Uri {
			get  {
				IntPtr raw_ret = webkit_web_resource_get_uri(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
		}

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

		[GLib.Signal("sent-request")]
		public event WebKit.SentRequestHandler SentRequest {
			add {
				this.AddSignalHandler ("sent-request", value, typeof (WebKit.SentRequestArgs));
			}
			remove {
				this.RemoveSignalHandler ("sent-request", value);
			}
		}

		[GLib.Signal("failed")]
		public event WebKit.FailedHandler Failed {
			add {
				this.AddSignalHandler ("failed", value, typeof (WebKit.FailedArgs));
			}
			remove {
				this.RemoveSignalHandler ("failed", value);
			}
		}

		[GLib.Signal("failed-with-tls-errors")]
		public event WebKit.FailedWithTlsErrorsHandler FailedWithTlsErrors {
			add {
				this.AddSignalHandler ("failed-with-tls-errors", value, typeof (WebKit.FailedWithTlsErrorsArgs));
			}
			remove {
				this.RemoveSignalHandler ("failed-with-tls-errors", value);
			}
		}

		[GLib.Signal("received-data")]
		public event WebKit.ReceivedDataHandler ReceivedData {
			add {
				this.AddSignalHandler ("received-data", value, typeof (WebKit.ReceivedDataArgs));
			}
			remove {
				this.RemoveSignalHandler ("received-data", value);
			}
		}

		static FailedNativeDelegate Failed_cb_delegate;
		static FailedNativeDelegate FailedVMCallback {
			get {
				if (Failed_cb_delegate == null)
					Failed_cb_delegate = new FailedNativeDelegate (Failed_cb);
				return Failed_cb_delegate;
			}
		}

		static void OverrideFailed (GLib.GType gtype)
		{
			OverrideFailed (gtype, FailedVMCallback);
		}

		static void OverrideFailed (GLib.GType gtype, FailedNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "failed", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void FailedNativeDelegate (IntPtr inst, IntPtr error);

		static void Failed_cb (IntPtr inst, IntPtr error)
		{
			try {
				WebResource __obj = GLib.Object.GetObject (inst, false) as WebResource;
				__obj.OnFailed (error);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.WebResource), ConnectionMethod="OverrideFailed")]
		protected virtual void OnFailed (IntPtr error)
		{
			InternalFailed (error);
		}

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

		static FailedWithTlsErrorsNativeDelegate FailedWithTlsErrors_cb_delegate;
		static FailedWithTlsErrorsNativeDelegate FailedWithTlsErrorsVMCallback {
			get {
				if (FailedWithTlsErrors_cb_delegate == null)
					FailedWithTlsErrors_cb_delegate = new FailedWithTlsErrorsNativeDelegate (FailedWithTlsErrors_cb);
				return FailedWithTlsErrors_cb_delegate;
			}
		}

		static void OverrideFailedWithTlsErrors (GLib.GType gtype)
		{
			OverrideFailedWithTlsErrors (gtype, FailedWithTlsErrorsVMCallback);
		}

		static void OverrideFailedWithTlsErrors (GLib.GType gtype, FailedWithTlsErrorsNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "failed-with-tls-errors", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void FailedWithTlsErrorsNativeDelegate (IntPtr inst, IntPtr certificate, int errors);

		static void FailedWithTlsErrors_cb (IntPtr inst, IntPtr certificate, int errors)
		{
			try {
				WebResource __obj = GLib.Object.GetObject (inst, false) as WebResource;
				__obj.OnFailedWithTlsErrors (GLib.Object.GetObject(certificate) as GLib.TlsCertificate, (GLib.TlsCertificateFlags) errors);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.WebResource), ConnectionMethod="OverrideFailedWithTlsErrors")]
		protected virtual void OnFailedWithTlsErrors (GLib.TlsCertificate certificate, GLib.TlsCertificateFlags errors)
		{
			InternalFailedWithTlsErrors (certificate, errors);
		}

		private void InternalFailedWithTlsErrors (GLib.TlsCertificate certificate, GLib.TlsCertificateFlags errors)
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (3);
			GLib.Value[] vals = new GLib.Value [3];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			vals [1] = new GLib.Value (certificate);
			inst_and_params.Append (vals [1]);
			vals [2] = new GLib.Value (errors);
			inst_and_params.Append (vals [2]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}

		static FinishedNativeDelegate Finished_cb_delegate;
		static FinishedNativeDelegate FinishedVMCallback {
			get {
				if (Finished_cb_delegate == null)
					Finished_cb_delegate = new FinishedNativeDelegate (Finished_cb);
				return Finished_cb_delegate;
			}
		}

		static void OverrideFinished (GLib.GType gtype)
		{
			OverrideFinished (gtype, FinishedVMCallback);
		}

		static void OverrideFinished (GLib.GType gtype, FinishedNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "finished", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void FinishedNativeDelegate (IntPtr inst);

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

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.WebResource), ConnectionMethod="OverrideFinished")]
		protected virtual void OnFinished ()
		{
			InternalFinished ();
		}

		private void InternalFinished ()
		{
			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 ();
		}

		static ReceivedDataNativeDelegate ReceivedData_cb_delegate;
		static ReceivedDataNativeDelegate ReceivedDataVMCallback {
			get {
				if (ReceivedData_cb_delegate == null)
					ReceivedData_cb_delegate = new ReceivedDataNativeDelegate (ReceivedData_cb);
				return ReceivedData_cb_delegate;
			}
		}

		static void OverrideReceivedData (GLib.GType gtype)
		{
			OverrideReceivedData (gtype, ReceivedDataVMCallback);
		}

		static void OverrideReceivedData (GLib.GType gtype, ReceivedDataNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "received-data", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void ReceivedDataNativeDelegate (IntPtr inst, ulong data_length);

		static void ReceivedData_cb (IntPtr inst, ulong data_length)
		{
			try {
				WebResource __obj = GLib.Object.GetObject (inst, false) as WebResource;
				__obj.OnReceivedData (data_length);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.WebResource), ConnectionMethod="OverrideReceivedData")]
		protected virtual void OnReceivedData (ulong data_length)
		{
			InternalReceivedData (data_length);
		}

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

		static SentRequestNativeDelegate SentRequest_cb_delegate;
		static SentRequestNativeDelegate SentRequestVMCallback {
			get {
				if (SentRequest_cb_delegate == null)
					SentRequest_cb_delegate = new SentRequestNativeDelegate (SentRequest_cb);
				return SentRequest_cb_delegate;
			}
		}

		static void OverrideSentRequest (GLib.GType gtype)
		{
			OverrideSentRequest (gtype, SentRequestVMCallback);
		}

		static void OverrideSentRequest (GLib.GType gtype, SentRequestNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "sent-request", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SentRequestNativeDelegate (IntPtr inst, IntPtr request, IntPtr redirected_response);

		static void SentRequest_cb (IntPtr inst, IntPtr request, IntPtr redirected_response)
		{
			try {
				WebResource __obj = GLib.Object.GetObject (inst, false) as WebResource;
				__obj.OnSentRequest (GLib.Object.GetObject(request) as WebKit.URIRequest, GLib.Object.GetObject(redirected_response) as WebKit.URIResponse);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.WebResource), ConnectionMethod="OverrideSentRequest")]
		protected virtual void OnSentRequest (WebKit.URIRequest request, WebKit.URIResponse redirected_response)
		{
			InternalSentRequest (request, redirected_response);
		}

		private void InternalSentRequest (WebKit.URIRequest request, WebKit.URIResponse redirected_response)
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (3);
			GLib.Value[] vals = new GLib.Value [3];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			vals [1] = new GLib.Value (request);
			inst_and_params.Append (vals [1]);
			vals [2] = new GLib.Value (redirected_response);
			inst_and_params.Append (vals [2]);
			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_web_resource_get_type();
		static d_webkit_web_resource_get_type webkit_web_resource_get_type = FuncLoader.LoadFunction<d_webkit_web_resource_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_web_resource_get_type"));

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

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

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

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


		static WebResource ()
		{
			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
	}
}
