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 = GUnixFDMessage.html 27 * outPack = gio 28 * outFile = UnixFDMessage 29 * strct = GUnixFDMessage 30 * realStrct= 31 * ctorStrct=GSocketControlMessage 32 * clss = UnixFDMessage 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_unix_fd_message_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.ErrorG 47 * - glib.GException 48 * - gio.UnixFDList 49 * structWrap: 50 * - GUnixFDList* -> UnixFDList 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module gio.UnixFDMessage; 57 58 public import gtkc.giotypes; 59 60 private import gtkc.gio; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 65 private import glib.ErrorG; 66 private import glib.GException; 67 private import gio.UnixFDList; 68 69 70 71 private import gio.SocketControlMessage; 72 73 /** 74 * Description 75 * This GSocketControlMessage contains a GUnixFDList. 76 * It may be sent using g_socket_send_message() and received using 77 * g_socket_receive_message() over UNIX sockets (ie: sockets in the 78 * G_SOCKET_ADDRESS_UNIX family). The file descriptors are copied 79 * between processes by the kernel. 80 * For an easier way to send and receive file descriptors over 81 * stream-oriented UNIX sockets, see g_unix_connection_send_fd() and 82 * g_unix_connection_receive_fd(). 83 * Note that <gio/gunixfdmessage.h> belongs to 84 * the UNIX-specific GIO interfaces, thus you have to use the 85 * gio-unix-2.0.pc pkg-config file when using it. 86 */ 87 public class UnixFDMessage : SocketControlMessage 88 { 89 90 /** the main Gtk struct */ 91 protected GUnixFDMessage* gUnixFDMessage; 92 93 94 public GUnixFDMessage* getUnixFDMessageStruct() 95 { 96 return gUnixFDMessage; 97 } 98 99 100 /** the main Gtk struct as a void* */ 101 protected override void* getStruct() 102 { 103 return cast(void*)gUnixFDMessage; 104 } 105 106 /** 107 * Sets our main struct and passes it to the parent class 108 */ 109 public this (GUnixFDMessage* gUnixFDMessage) 110 { 111 super(cast(GSocketControlMessage*)gUnixFDMessage); 112 this.gUnixFDMessage = gUnixFDMessage; 113 } 114 115 protected override void setStruct(GObject* obj) 116 { 117 super.setStruct(obj); 118 gUnixFDMessage = cast(GUnixFDMessage*)obj; 119 } 120 121 /** 122 */ 123 124 /** 125 * Creates a new GUnixFDMessage containing list. 126 * Since 2.24 127 * Params: 128 * fdList = a GUnixFDList 129 * Throws: ConstructionException GTK+ fails to create the object. 130 */ 131 public this (UnixFDList fdList) 132 { 133 // GSocketControlMessage * g_unix_fd_message_new_with_fd_list (GUnixFDList *fd_list); 134 auto p = g_unix_fd_message_new_with_fd_list((fdList is null) ? null : fdList.getUnixFDListStruct()); 135 if(p is null) 136 { 137 throw new ConstructionException("null returned by g_unix_fd_message_new_with_fd_list((fdList is null) ? null : fdList.getUnixFDListStruct())"); 138 } 139 this(cast(GUnixFDMessage*) p); 140 } 141 142 /** 143 * Creates a new GUnixFDMessage containing an empty file descriptor 144 * list. 145 * Since 2.22 146 * Throws: ConstructionException GTK+ fails to create the object. 147 */ 148 public this () 149 { 150 // GSocketControlMessage * g_unix_fd_message_new (void); 151 auto p = g_unix_fd_message_new(); 152 if(p is null) 153 { 154 throw new ConstructionException("null returned by g_unix_fd_message_new()"); 155 } 156 this(cast(GUnixFDMessage*) p); 157 } 158 159 /** 160 * Gets the GUnixFDList contained in message. This function does not 161 * return a reference to the caller, but the returned list is valid for 162 * the lifetime of message. 163 * Since 2.24 164 * Returns: the GUnixFDList from message. [transfer none] 165 */ 166 public UnixFDList getFdList() 167 { 168 // GUnixFDList * g_unix_fd_message_get_fd_list (GUnixFDMessage *message); 169 auto p = g_unix_fd_message_get_fd_list(gUnixFDMessage); 170 171 if(p is null) 172 { 173 return null; 174 } 175 176 return ObjectG.getDObject!(UnixFDList)(cast(GUnixFDList*) p); 177 } 178 179 /** 180 * Adds a file descriptor to message. 181 * The file descriptor is duplicated using dup(). You keep your copy 182 * of the descriptor and the copy contained in message will be closed 183 * when message is finalized. 184 * A possible cause of failure is exceeding the per-process or 185 * system-wide file descriptor limit. 186 * Since 2.22 187 * Params: 188 * fd = a valid open file descriptor 189 * Returns: TRUE in case of success, else FALSE (and error is set) 190 * Throws: GException on failure. 191 */ 192 public int appendFd(int fd) 193 { 194 // gboolean g_unix_fd_message_append_fd (GUnixFDMessage *message, gint fd, GError **error); 195 GError* err = null; 196 197 auto p = g_unix_fd_message_append_fd(gUnixFDMessage, fd, &err); 198 199 if (err !is null) 200 { 201 throw new GException( new ErrorG(err) ); 202 } 203 204 return p; 205 } 206 207 /** 208 * Returns the array of file descriptors that is contained in this 209 * object. 210 * After this call, the descriptors are no longer contained in 211 * message. Further calls will return an empty list (unless more 212 * descriptors have been added). 213 * The return result of this function must be freed with g_free(). 214 * The caller is also responsible for closing all of the file 215 * descriptors. 216 * If length is non-NULL then it is set to the number of file 217 * descriptors in the returned array. The returned array is also 218 * terminated with -1. 219 * This function never returns NULL. In case there are no file 220 * descriptors contained in message, an empty array is returned. 221 * Since 2.22 222 * Returns: an array of file descriptors. [array length=length][transfer full] 223 */ 224 public int[] stealFds() 225 { 226 // gint * g_unix_fd_message_steal_fds (GUnixFDMessage *message, gint *length); 227 int length; 228 auto p = g_unix_fd_message_steal_fds(gUnixFDMessage, &length); 229 230 if(p is null) 231 { 232 return null; 233 } 234 235 return p[0 .. length]; 236 } 237 }