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 
64 
65 private import gobject.ObjectG;
66 
67 /**
68  * A GSocketControlMessage is a special-purpose utility message that
69  * can be sent to or received from a GSocket. These types of
70  * messages are often called "ancillary data".
71  *
72  * The message can represent some sort of special instruction to or
73  * information from the socket or can represent a special kind of
74  * transfer to the peer (for example, sending a file description over
75  * a UNIX socket).
76  *
77  * These messages are sent with g_socket_send_message() and received
78  * with g_socket_receive_message().
79  *
80  * To extend the set of control message that can be sent, subclass this
81  * class and override the get_size, get_level, get_type and serialize
82  * methods.
83  *
84  * To extend the set of control messages that can be received, subclass
85  * this class and implement the deserialize method. Also, make sure your
86  * class is registered with the GType typesystem before calling
87  * g_socket_receive_message() to read such a message.
88  */
89 public class SocketControlMessage : ObjectG
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GSocketControlMessage* gSocketControlMessage;
94 	
95 	
96 	public GSocketControlMessage* getSocketControlMessageStruct()
97 	{
98 		return gSocketControlMessage;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected override void* getStruct()
104 	{
105 		return cast(void*)gSocketControlMessage;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GSocketControlMessage* gSocketControlMessage)
112 	{
113 		super(cast(GObject*)gSocketControlMessage);
114 		this.gSocketControlMessage = gSocketControlMessage;
115 	}
116 	
117 	protected override void setStruct(GObject* obj)
118 	{
119 		super.setStruct(obj);
120 		gSocketControlMessage = cast(GSocketControlMessage*)obj;
121 	}
122 	
123 	/**
124 	 */
125 	
126 	/**
127 	 * Tries to deserialize a socket control message of a given
128 	 * level and type. This will ask all known (to GType) subclasses
129 	 * of GSocketControlMessage if they can understand this kind
130 	 * of message and if so deserialize it into a GSocketControlMessage.
131 	 * If there is no implementation for this kind of control message, NULL
132 	 * will be returned.
133 	 * Since 2.22
134 	 * Params:
135 	 * level = a socket level
136 	 * type = a socket control message type for the given level
137 	 * size = the size of the data in bytes
138 	 * data = pointer to the message data. [array length=size][element-type guint8]
139 	 * Returns: the deserialized message or NULL. [transfer full]
140 	 */
141 	public static SocketControlMessage deserialize(int level, int type, gsize size, void* data)
142 	{
143 		// GSocketControlMessage * g_socket_control_message_deserialize  (int level,  int type,  gsize size,  gpointer data);
144 		auto p = g_socket_control_message_deserialize(level, type, size, data);
145 		
146 		if(p is null)
147 		{
148 			return null;
149 		}
150 		
151 		return ObjectG.getDObject!(SocketControlMessage)(cast(GSocketControlMessage*) p);
152 	}
153 	
154 	/**
155 	 * Returns the "level" (i.e. the originating protocol) of the control message.
156 	 * This is often SOL_SOCKET.
157 	 * Since 2.22
158 	 * Returns: an integer describing the level
159 	 */
160 	public int getLevel()
161 	{
162 		// int g_socket_control_message_get_level (GSocketControlMessage *message);
163 		return g_socket_control_message_get_level(gSocketControlMessage);
164 	}
165 	
166 	/**
167 	 * Returns the protocol specific type of the control message.
168 	 * For instance, for UNIX fd passing this would be SCM_RIGHTS.
169 	 * Since 2.22
170 	 * Returns: an integer describing the type of control message
171 	 */
172 	public int getMsgType()
173 	{
174 		// int g_socket_control_message_get_msg_type  (GSocketControlMessage *message);
175 		return g_socket_control_message_get_msg_type(gSocketControlMessage);
176 	}
177 	
178 	/**
179 	 * Returns the space required for the control message, not including
180 	 * headers or alignment.
181 	 * Since 2.22
182 	 * Returns: The number of bytes required.
183 	 */
184 	public gsize getSize()
185 	{
186 		// gsize g_socket_control_message_get_size (GSocketControlMessage *message);
187 		return g_socket_control_message_get_size(gSocketControlMessage);
188 	}
189 	
190 	/**
191 	 * Converts the data in the message to bytes placed in the
192 	 * message.
193 	 * data is guaranteed to have enough space to fit the size
194 	 * returned by g_socket_control_message_get_size() on this
195 	 * object.
196 	 * Since 2.22
197 	 * Params:
198 	 * data = A buffer to write data to
199 	 */
200 	public void serialize(void* data)
201 	{
202 		// void g_socket_control_message_serialize (GSocketControlMessage *message,  gpointer data);
203 		g_socket_control_message_serialize(gSocketControlMessage, data);
204 	}
205 }