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