// 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 Credential : IEquatable<Credential> {


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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_credential_new(IntPtr username, IntPtr password, int persistence);
		static d_webkit_credential_new webkit_credential_new = FuncLoader.LoadFunction<d_webkit_credential_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_credential_new"));

		public static Credential New(string username, string password, WebKit.CredentialPersistence persistence)
		{
			IntPtr native_username = GLib.Marshaller.StringToPtrGStrdup (username);
			IntPtr native_password = GLib.Marshaller.StringToPtrGStrdup (password);
			Credential result = Credential.New (webkit_credential_new(native_username, native_password, (int) persistence));
			GLib.Marshaller.Free (native_username);
			GLib.Marshaller.Free (native_password);
			return result;
		}

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

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

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

		public string Password { 
			get {
				IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.Credential>());
				System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
				IntPtr raw_ret = webkit_credential_get_password(this_as_native);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				ReadNative (this_as_native, ref this);
				System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
				return ret;
			}
		}

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

		public WebKit.CredentialPersistence Persistence { 
			get {
				IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.Credential>());
				System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
				int raw_ret = webkit_credential_get_persistence(this_as_native);
				WebKit.CredentialPersistence ret = (WebKit.CredentialPersistence) raw_ret;
				ReadNative (this_as_native, ref this);
				System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
				return ret;
			}
		}

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

		public string Username { 
			get {
				IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.Credential>());
				System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
				IntPtr raw_ret = webkit_credential_get_username(this_as_native);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				ReadNative (this_as_native, ref this);
				System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
				return ret;
			}
		}

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

		public bool HasPassword { 
			get {
				IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.Credential>());
				System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
				bool raw_ret = webkit_credential_has_password(this_as_native);
				bool ret = raw_ret;
				ReadNative (this_as_native, ref this);
				System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
				return ret;
			}
		}

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

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

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

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

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

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