root/trunk/src/gio/UnixFDMessage.d

Revision 938, 6.6 kB (checked in by Mike Wey, 3 months ago)

Update Gio to 2.28.

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