// 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 SocketService : GLib.SocketListener {

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

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

		public SocketService () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (SocketService)) {
				CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
				return;
			}
			Raw = g_socket_service_new();
		}

		[GLib.Property ("active")]
		public bool Active {
			get {
				GLib.Value val = GetProperty ("active");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("active", val);
				val.Dispose ();
			}
		}

		[GLib.Signal("incoming")]
		public event GLib.IncomingHandler Incoming {
			add {
				this.AddSignalHandler ("incoming", value, typeof (GLib.IncomingArgs));
			}
			remove {
				this.RemoveSignalHandler ("incoming", value);
			}
		}

		static IncomingNativeDelegate Incoming_cb_delegate;
		static IncomingNativeDelegate IncomingVMCallback {
			get {
				if (Incoming_cb_delegate == null)
					Incoming_cb_delegate = new IncomingNativeDelegate (Incoming_cb);
				return Incoming_cb_delegate;
			}
		}

		static void OverrideIncoming (GLib.GType gtype)
		{
			OverrideIncoming (gtype, IncomingVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool IncomingNativeDelegate (IntPtr inst, IntPtr connection, IntPtr source_object);

		static bool Incoming_cb (IntPtr inst, IntPtr connection, IntPtr source_object)
		{
			try {
				SocketService __obj = GLib.Object.GetObject (inst, false) as SocketService;
				bool __result;
				__result = __obj.OnIncoming (GLib.Object.GetObject(connection) as GLib.SocketConnection, GLib.Object.GetObject (source_object));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketService), ConnectionMethod="OverrideIncoming")]
		protected virtual bool OnIncoming (GLib.SocketConnection connection, GLib.Object source_object)
		{
			return InternalIncoming (connection, source_object);
		}

		private bool InternalIncoming (GLib.SocketConnection connection, GLib.Object source_object)
		{
			IncomingNativeDelegate unmanaged = class_abi.BaseOverride<IncomingNativeDelegate>(this.LookupGType(), "incoming");
			if (unmanaged == null) return false;

			bool __result = unmanaged (this.Handle, connection == null ? IntPtr.Zero : connection.Handle, source_object == null ? IntPtr.Zero : source_object.Handle);
			return __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("incoming"
							, GLib.SocketListener.class_abi.Fields
							, (uint) sizeof( IntPtr ) // incoming
							, null
							, "_g_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved1
							, "incoming"
							, "_g_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved2
							, "_g_reserved1"
							, "_g_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved3
							, "_g_reserved2"
							, "_g_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved4
							, "_g_reserved3"
							, "_g_reserved5"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved5"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved5
							, "_g_reserved4"
							, "_g_reserved6"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved6"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved6
							, "_g_reserved5"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

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

		public bool IsActive { 
			get {
				bool raw_ret = g_socket_service_is_active(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

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

		public void Start() {
			g_socket_service_start(Handle);
		}

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

		public void Stop() {
			g_socket_service_stop(Handle);
		}


		// 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.SocketListener.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
