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

#region Autogenerated code
	public partial class UnixFDMessage : GLib.SocketControlMessage {

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

		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr g_unix_fd_message_new();

		public UnixFDMessage () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (UnixFDMessage)) {
				CreateNativeObject (new string [0], new GLib.Value[0]);
				return;
			}
			Raw = g_unix_fd_message_new();
		}

		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr g_unix_fd_message_new_with_fd_list(IntPtr fd_list);

		public UnixFDMessage (GLib.UnixFDList fd_list) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (UnixFDMessage)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (fd_list != null) {
					names.Add ("fd_list");
					vals.Add (new GLib.Value (fd_list));
				}
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = g_unix_fd_message_new_with_fd_list(fd_list == null ? IntPtr.Zero : fd_list.Handle);
		}

		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr g_unix_fd_message_get_fd_list(IntPtr raw);

		[GLib.Property ("fd-list")]
		public GLib.UnixFDList FdList {
			get  {
				IntPtr raw_ret = g_unix_fd_message_get_fd_list(Handle);
				GLib.UnixFDList ret = GLib.Object.GetObject(raw_ret) as GLib.UnixFDList;
				return ret;
			}
		}

		[StructLayout (LayoutKind.Sequential)]
		struct GUnixFDMessageClass {
			IntPtr GReserved1;
			IntPtr GReserved2;
		}

		static uint class_offset = ((GLib.GType) typeof (GLib.SocketControlMessage)).GetClassSize ();
		static Dictionary<GLib.GType, GUnixFDMessageClass> class_structs;

		static GUnixFDMessageClass GetClassStruct (GLib.GType gtype, bool use_cache)
		{
			if (class_structs == null)
				class_structs = new Dictionary<GLib.GType, GUnixFDMessageClass> ();

			if (use_cache && class_structs.ContainsKey (gtype))
				return class_structs [gtype];
			else {
				IntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);
				GUnixFDMessageClass class_struct = (GUnixFDMessageClass) Marshal.PtrToStructure (class_ptr, typeof (GUnixFDMessageClass));
				if (use_cache)
					class_structs.Add (gtype, class_struct);
				return class_struct;
			}
		}

		static void OverrideClassStruct (GLib.GType gtype, GUnixFDMessageClass class_struct)
		{
			IntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);
			Marshal.StructureToPtr (class_struct, class_ptr, false);
		}

		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern unsafe bool g_unix_fd_message_append_fd(IntPtr raw, int fd, out IntPtr error);

		public unsafe bool AppendFd(int fd) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_unix_fd_message_append_fd(Handle, fd, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr g_unix_fd_message_get_type();

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

		[DllImport("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern int g_unix_fd_message_steal_fds(IntPtr raw, out int length);

		public int StealFds(out int length) {
			int raw_ret = g_unix_fd_message_steal_fds(Handle, out length);
			int ret = raw_ret;
			return ret;
		}

#endregion
	}
}
