1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GSocketControlMessage.html
27  * outPack = gio
28  * outFile = SocketControlMessage
29  * strct   = GSocketControlMessage
30  * realStrct=
31  * ctorStrct=
32  * clss    = SocketControlMessage
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_socket_control_message_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * 	- GSocketControlMessage* -> SocketControlMessage
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gio.SocketControlMessage;
54 
55 public  import gtkc.giotypes;
56 
57 private import gtkc.gio;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 
62 
63 private import gobject.ObjectG;
64 
65 /**
66  * A GSocketControlMessage is a special-purpose utility message that
67  * can be sent to or received from a GSocket. These types of
68  * messages are often called "ancillary data".
69  *
70  * The message can represent some sort of special instruction to or
71  * information from the socket or can represent a special kind of
72  * transfer to the peer (for example, sending a file description over
73  * a UNIX socket).
74  *
75  * These messages are sent with g_socket_send_message() and received
76  * with g_socket_receive_message().
77  *
78  * To extend the set of control message that can be sent, subclass this
79  * class and override the get_size, get_level, get_type and serialize
80  * methods.
81  *
82  * To extend the set of control messages that can be received, subclass
83  * this class and implement the deserialize method. Also, make sure your
84  * class is registered with the GType typesystem before calling
85  * g_socket_receive_message() to read such a message.
86  */
87 public class SocketControlMessage : ObjectG
88 {
89 	
90 	/** the main Gtk struct */
91 	protected GSocketControlMessage* gSocketControlMessage;
92 	
93 	
94 	/** Get the main Gtk struct */
95 	public GSocketControlMessage* getSocketControlMessageStruct()
96 	{
97 		return gSocketControlMessage;
98 	}
99 	
100 	
101 	/** the main Gtk struct as a void* */
102 	protected override void* getStruct()
103 	{
104 		return cast(void*)gSocketControlMessage;
105 	}
106 	
107 	/**
108 	 * Sets our main struct and passes it to the parent class
109 	 */
110 	public this (GSocketControlMessage* gSocketControlMessage)
111 	{
112 		super(cast(GObject*)gSocketControlMessage);
113 		this.gSocketControlMessage = gSocketControlMessage;
114 	}
115 	
116 	protected override void setStruct(GObject* obj)
117 	{
118 		super.setStruct(obj);
119 		gSocketControlMessage = cast(GSocketControlMessage*)obj;
120 	}
121 	
122 	/**
123 	 */
124 	
125 	/**
126 	 * Tries to deserialize a socket control message of a given
127 	 * level and type. This will ask all known (to GType) subclasses
128 	 * of GSocketControlMessage if they can understand this kind
129 	 * of message and if so deserialize it into a GSocketControlMessage.
130 	 * If there is no implementation for this kind of control message, NULL
131 	 * will be returned.
132 	 * Since 2.22
133 	 * Params:
134 	 * level = a socket level
135 	 * type = a socket control message type for the given level
136 	 * size = the size of the data in bytes
137 	 * data = pointer to the message data. [array length=size][element-type guint8]
138 	 * Returns: the deserialized message or NULL. [transfer full]
139 	 */
140 	public static SocketControlMessage deserialize(int level, int type, gsize size, void* data)
141 	{
142 		// GSocketControlMessage * g_socket_control_message_deserialize  (int level,  int type,  gsize size,  gpointer data);
143 		auto p = g_socket_control_message_deserialize(level, type, size, data);
144 		
145 		if(p is null)
146 		{
147 			return null;
148 		}
149 		
150 		return ObjectG.getDObject!(SocketControlMessage)(cast(GSocketControlMessage*) p);
151 	}
152 	
153 	/**
154 	 * Returns the "level" (i.e. the originating protocol) of the control message.
155 	 * This is often SOL_SOCKET.
156 	 * Since 2.22
157 	 * Returns: an integer describing the level
158 	 */
159 	public int getLevel()
160 	{
161 		// int g_socket_control_message_get_level (GSocketControlMessage *message);
162 		return g_socket_control_message_get_level(gSocketControlMessage);
163 	}
164 	
165 	/**
166 	 * Returns the protocol specific type of the control message.
167 	 * For instance, for UNIX fd passing this would be SCM_RIGHTS.
168 	 * Since 2.22
169 	 * Returns: an integer describing the type of control message
170 	 */
171 	public int getMsgType()
172 	{
173 		// int g_socket_control_message_get_msg_type  (GSocketControlMessage *message);
174 		return g_socket_control_message_get_msg_type(gSocketControlMessage);
175 	}
176 	
177 	/**
178 	 * Returns the space required for the control message, not including
179 	 * headers or alignment.
180 	 * Since 2.22
181 	 * Returns: The number of bytes required.
182 	 */
183 	public gsize getSize()
184 	{
185 		// gsize g_socket_control_message_get_size (GSocketControlMessage *message);
186 		return g_socket_control_message_get_size(gSocketControlMessage);
187 	}
188 	
189 	/**
190 	 * Converts the data in the message to bytes placed in the
191 	 * message.
192 	 * data is guaranteed to have enough space to fit the size
193 	 * returned by g_socket_control_message_get_size() on this
194 	 * object.
195 	 * Since 2.22
196 	 * Params:
197 	 * data = A buffer to write data to
198 	 */
199 	public void serialize(void* data)
200 	{
201 		// void g_socket_control_message_serialize (GSocketControlMessage *message,  gpointer data);
202 		g_socket_control_message_serialize(gSocketControlMessage, data);
203 	}
204 }