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