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

namespace GLib {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_tls_password_new(int flags, IntPtr description);
		static d_g_tls_password_new g_tls_password_new = FuncLoader.LoadFunction<d_g_tls_password_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_new"));

		public TlsPassword (GLib.TlsPasswordFlags flags, string description) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (TlsPassword)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("flags");
				vals.Add (new GLib.Value (flags));
				names.Add ("description");
				vals.Add (new GLib.Value (description));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			IntPtr native_description = GLib.Marshaller.StringToPtrGStrdup (description);
			Raw = g_tls_password_new((int) flags, native_description);
			GLib.Marshaller.Free (native_description);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_tls_password_set_flags(IntPtr raw, int flags);
		static d_g_tls_password_set_flags g_tls_password_set_flags = FuncLoader.LoadFunction<d_g_tls_password_set_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_set_flags"));

		[GLib.Property ("flags")]
		public GLib.TlsPasswordFlags Flags {
			get  {
				int raw_ret = g_tls_password_get_flags(Handle);
				GLib.TlsPasswordFlags ret = (GLib.TlsPasswordFlags) raw_ret;
				return ret;
			}
			set  {
				g_tls_password_set_flags(Handle, (int) value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_tls_password_set_description(IntPtr raw, IntPtr description);
		static d_g_tls_password_set_description g_tls_password_set_description = FuncLoader.LoadFunction<d_g_tls_password_set_description>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_set_description"));

		[GLib.Property ("description")]
		public string Description {
			get  {
				IntPtr raw_ret = g_tls_password_get_description(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				g_tls_password_set_description(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_tls_password_set_warning(IntPtr raw, IntPtr warning);
		static d_g_tls_password_set_warning g_tls_password_set_warning = FuncLoader.LoadFunction<d_g_tls_password_set_warning>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_set_warning"));

		[GLib.Property ("warning")]
		public string Warning {
			get  {
				IntPtr raw_ret = g_tls_password_get_warning(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				g_tls_password_set_warning(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

		static GetValueNativeDelegate GetValue_cb_delegate;
		static GetValueNativeDelegate GetValueVMCallback {
			get {
				if (GetValue_cb_delegate == null)
					GetValue_cb_delegate = new GetValueNativeDelegate (GetValue_cb);
				return GetValue_cb_delegate;
			}
		}

		static void OverrideGetValue (GLib.GType gtype)
		{
			OverrideGetValue (gtype, GetValueVMCallback);
		}

		static void OverrideGetValue (GLib.GType gtype, GetValueNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_value"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate byte GetValueNativeDelegate (IntPtr inst, out UIntPtr length);

		static byte GetValue_cb (IntPtr inst, out UIntPtr length)
		{
			try {
				TlsPassword __obj = GLib.Object.GetObject (inst, false) as TlsPassword;
				byte __result;
				ulong mylength;
				__result = __obj.OnGetValue (out mylength);
				length = new UIntPtr (mylength);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.TlsPassword), ConnectionMethod="OverrideGetValue")]
		protected virtual byte OnGetValue (out ulong length)
		{
			return InternalGetValue (out length);
		}

		private byte InternalGetValue (out ulong length)
		{
			GetValueNativeDelegate unmanaged = class_abi.BaseOverride<GetValueNativeDelegate>(this.LookupGType(), "get_value");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			UIntPtr native_length;
			byte __result = unmanaged (this.Handle, out native_length);
			length = (ulong) native_length;
			return __result;
		}

		static SetValueNativeDelegate SetValue_cb_delegate;
		static SetValueNativeDelegate SetValueVMCallback {
			get {
				if (SetValue_cb_delegate == null)
					SetValue_cb_delegate = new SetValueNativeDelegate (SetValue_cb);
				return SetValue_cb_delegate;
			}
		}

		static void OverrideSetValue (GLib.GType gtype)
		{
			OverrideSetValue (gtype, SetValueVMCallback);
		}

		static void OverrideSetValue (GLib.GType gtype, SetValueNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("set_value"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetValueNativeDelegate (IntPtr inst, out byte value, IntPtr length, GLib.DestroyNotify destroy);

		static void SetValue_cb (IntPtr inst, out byte value, IntPtr length, GLib.DestroyNotify destroy)
		{
			try {
				TlsPassword __obj = GLib.Object.GetObject (inst, false) as TlsPassword;
				__obj.OnSetValue (out value, (long) length, destroy);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.TlsPassword), ConnectionMethod="OverrideSetValue")]
		protected virtual void OnSetValue (out byte value, long length, GLib.DestroyNotify destroy)
		{
			InternalSetValue (out value, length, destroy);
		}

		private void InternalSetValue (out byte value, long length, GLib.DestroyNotify destroy)
		{
			SetValueNativeDelegate unmanaged = class_abi.BaseOverride<SetValueNativeDelegate>(this.LookupGType(), "set_value");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			unmanaged (this.Handle, out value, new IntPtr (length), destroy);
		}

		static GetDefaultWarningNativeDelegate GetDefaultWarning_cb_delegate;
		static GetDefaultWarningNativeDelegate GetDefaultWarningVMCallback {
			get {
				if (GetDefaultWarning_cb_delegate == null)
					GetDefaultWarning_cb_delegate = new GetDefaultWarningNativeDelegate (GetDefaultWarning_cb);
				return GetDefaultWarning_cb_delegate;
			}
		}

		static void OverrideGetDefaultWarning (GLib.GType gtype)
		{
			OverrideGetDefaultWarning (gtype, GetDefaultWarningVMCallback);
		}

		static void OverrideGetDefaultWarning (GLib.GType gtype, GetDefaultWarningNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_default_warning"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetDefaultWarningNativeDelegate (IntPtr inst);

		static IntPtr GetDefaultWarning_cb (IntPtr inst)
		{
			try {
				TlsPassword __obj = GLib.Object.GetObject (inst, false) as TlsPassword;
				string __result;
				__result = __obj.OnGetDefaultWarning ();
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.TlsPassword), ConnectionMethod="OverrideGetDefaultWarning")]
		protected virtual string OnGetDefaultWarning ()
		{
			return InternalGetDefaultWarning ();
		}

		private string InternalGetDefaultWarning ()
		{
			GetDefaultWarningNativeDelegate unmanaged = class_abi.BaseOverride<GetDefaultWarningNativeDelegate>(this.LookupGType(), "get_default_warning");
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle);
			return GLib.Marshaller.PtrToStringGFree(__result);
		}


		// 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("get_value"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // get_value
							, null
							, "set_value"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("set_value"
							, -1
							, (uint) sizeof( IntPtr ) // set_value
							, "get_value"
							, "get_default_warning"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_default_warning"
							, -1
							, (uint) sizeof( IntPtr ) // get_default_warning
							, "set_value"
							, "padding"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("padding"
							, -1
							, (uint) sizeof( IntPtr ) * 4 // padding
							, "get_default_warning"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_tls_password_get_type();
		static d_g_tls_password_get_type g_tls_password_get_type = FuncLoader.LoadFunction<d_g_tls_password_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_get_type"));

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate byte d_g_tls_password_get_value(IntPtr raw, out UIntPtr length);
		static d_g_tls_password_get_value g_tls_password_get_value = FuncLoader.LoadFunction<d_g_tls_password_get_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_get_value"));

		public byte GetValue(out ulong length) {
			UIntPtr native_length;
			byte raw_ret = g_tls_password_get_value(Handle, out native_length);
			byte ret = raw_ret;
			length = (ulong) native_length;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_tls_password_set_value(IntPtr raw, out byte value, IntPtr length);
		static d_g_tls_password_set_value g_tls_password_set_value = FuncLoader.LoadFunction<d_g_tls_password_set_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_set_value"));

		public byte SetValue(long length) {
			byte value;
			g_tls_password_set_value(Handle, out value, new IntPtr (length));
			return value;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_tls_password_set_value_full(IntPtr raw, out byte value, IntPtr length, GLib.DestroyNotify destroy);
		static d_g_tls_password_set_value_full g_tls_password_set_value_full = FuncLoader.LoadFunction<d_g_tls_password_set_value_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_tls_password_set_value_full"));

		public byte SetValueFull(long length, GLib.DestroyNotify destroy) {
			byte value;
			g_tls_password_set_value_full(Handle, out value, new IntPtr (length), destroy);
			return value;
		}


		// 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
	}
}
