Implemented sub-second W32 filesystem interface by new: CaptiveFileInfoObject
[captive.git] / src / libcaptive / sandbox / parent-File.c
1 /* $Id$
2  * CORBA/ORBit client side of File object of sandbox_parent()
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "parent-File.h"        /* self */
23 #include <glib/gmessages.h>
24 #include "split.h"
25 #include "sandbox.h"
26 #include "../client/file.h"
27 #include "../client/vfs.h"
28 #include "FileInfo.h"
29 #include "captive/macros.h"
30 #include "reactos/ntos/types.h" /* for ULONG */
31
32
33 GnomeVFSResult captive_sandbox_parent_file_new_open(CaptiveFileParentObject *captive_file_parent_object)
34 {
35 xmlNode *xml_action=NULL;
36 CaptiveVfsParentObject *captive_vfs_parent_object;
37 GnomeVFSResult r;
38 Captive_File corba_File_object;
39
40         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
41         g_return_val_if_fail(captive_file_parent_object->pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
42
43         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
44
45         if (captive_vfs_parent_object->corba_bug_action) {
46                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_new_open",NULL);
47                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
48                 xmlNewProp(xml_action,BAD_CAST "pathname",BAD_CAST captive_file_parent_object->pathname);
49                 xmlNewProp(xml_action,BAD_CAST "mode",BAD_CAST captive_printf_alloca("%u",(unsigned)captive_file_parent_object->mode));
50                 }
51
52         corba_File_object=Captive_Vfs_file_new_open(captive_vfs_parent_object->corba_Vfs_object,
53                         captive_file_parent_object->pathname,captive_file_parent_object->mode,&captive_corba_ev);
54         if (xml_action)
55                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST (captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
56         /* If 'r' means failure 'corba_File_object' may not be 'CORBA_OBJECT_NIL'
57          * although it is not valid 'CORBA_Object' to be passed to CORBA_Object_release().
58          */
59         if (GNOME_VFS_OK!=(r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object)))
60                 return r;
61
62         captive_file_parent_object->corba_File_object=corba_File_object;
63         return GNOME_VFS_OK;
64 }
65
66
67 GnomeVFSResult captive_sandbox_parent_file_new_create(CaptiveFileParentObject *captive_file_parent_object,
68                 gboolean exclusive,guint perm)
69 {
70 xmlNode *xml_action=NULL;
71 CaptiveVfsParentObject *captive_vfs_parent_object;
72 GnomeVFSResult r;
73 Captive_File corba_File_object;
74
75         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
76         g_return_val_if_fail(captive_file_parent_object->pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
77
78         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
79
80         if (captive_vfs_parent_object->corba_bug_action) {
81                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_new_create",NULL);
82                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
83                 xmlNewProp(xml_action,BAD_CAST "pathname",BAD_CAST captive_file_parent_object->pathname);
84                 xmlNewProp(xml_action,BAD_CAST "mode",BAD_CAST captive_printf_alloca("%u",(unsigned)captive_file_parent_object->mode));
85                 xmlNewProp(xml_action,BAD_CAST "exclusive",BAD_CAST captive_printf_alloca("%u",(unsigned)exclusive));
86                 xmlNewProp(xml_action,BAD_CAST "perm",BAD_CAST captive_printf_alloca("%u",(unsigned)perm));
87                 }
88
89         corba_File_object=Captive_Vfs_file_new_create(captive_vfs_parent_object->corba_Vfs_object,
90                         captive_file_parent_object->pathname,captive_file_parent_object->mode,exclusive,perm,&captive_corba_ev);
91         if (xml_action)
92                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST (captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
93         /* If 'r' means failure 'corba_File_object' may not be 'CORBA_OBJECT_NIL'
94          * although it is not valid 'CORBA_Object' to be passed to CORBA_Object_release().
95          */
96         if (GNOME_VFS_OK!=(r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object)))
97                 return r;
98
99         captive_file_parent_object->corba_File_object=corba_File_object;
100         return GNOME_VFS_OK;
101 }
102
103
104 GnomeVFSResult captive_sandbox_parent_file_close(CaptiveFileParentObject *captive_file_parent_object)
105 {
106 GnomeVFSResult r;
107 xmlNode *xml_action=NULL;
108 CaptiveVfsParentObject *captive_vfs_parent_object;
109
110         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
111
112         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
113
114         if (captive_vfs_parent_object->corba_bug_action) {
115                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_close",NULL);
116                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
117                 }
118
119         Captive_File_shutdown(captive_file_parent_object->corba_File_object,&captive_corba_ev);
120         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
121         if (xml_action)
122                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
123
124         /* Always clear 'corba_File_object' even if 'r' means failure. */
125         CORBA_Object_release((CORBA_Object)captive_file_parent_object->corba_File_object,&captive_corba_ev);
126         captive_file_parent_object->corba_File_object=CORBA_OBJECT_NIL;
127
128         return r;
129 }
130
131
132 static GnomeVFSResult captive_sandbox_parent_file_seek_slave
133                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset);
134
135 GnomeVFSResult captive_sandbox_parent_file_read(CaptiveFileParentObject *captive_file_parent_object,
136                 gpointer buffer_captive,GnomeVFSFileSize num_bytes,GnomeVFSFileSize *bytes_read_return)
137 {
138 GnomeVFSResult r;
139 Captive_Bytes *buffer_corba;
140 xmlNode *xml_action=NULL;
141 CaptiveVfsParentObject *captive_vfs_parent_object;
142
143         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
144         g_return_val_if_fail(buffer_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
145         g_return_val_if_fail(bytes_read_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
146         g_return_val_if_fail(num_bytes==(ULONG)num_bytes,GNOME_VFS_ERROR_BAD_PARAMETERS);
147
148         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
149
150         *bytes_read_return=0;
151
152         if (captive_vfs_parent_object->corba_bug_action) {
153                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_read",NULL);
154                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
155                 xmlNewProp(xml_action,BAD_CAST "num_bytes",BAD_CAST captive_printf_alloca("%lu",(unsigned long)num_bytes));
156                 }
157
158         r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
159                         GNOME_VFS_SEEK_START,captive_file_parent_object->offset);
160         if (r==GNOME_VFS_OK) {
161                 Captive_File_read(captive_file_parent_object->corba_File_object,&buffer_corba,num_bytes,&captive_corba_ev);
162                 r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
163                 }
164         if (xml_action)
165                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
166         if (r!=GNOME_VFS_OK)
167                 return r;
168
169         g_return_val_if_fail(buffer_corba->_length<=num_bytes,GNOME_VFS_ERROR_GENERIC);
170         memcpy(buffer_captive,buffer_corba->_buffer,buffer_corba->_length);
171         *bytes_read_return=buffer_corba->_length;
172         captive_file_parent_object->offset+=buffer_corba->_length;
173
174         Captive_Bytes__freekids(buffer_corba,NULL/* 'd'; meaning? */);
175         CORBA_free(buffer_corba);
176
177         if (xml_action)
178                 xmlNewProp(xml_action,BAD_CAST "bytes_read_return",BAD_CAST captive_printf_alloca("%lu",(unsigned long)*bytes_read_return));
179
180         return GNOME_VFS_OK;
181 }
182
183
184 GnomeVFSResult captive_sandbox_parent_file_write(CaptiveFileParentObject *captive_file_parent_object,
185                 gconstpointer buffer_captive,GnomeVFSFileSize num_bytes,GnomeVFSFileSize *bytes_written_return)
186 {
187 GnomeVFSResult r;
188 Captive_Bytes buffer_corba_local;
189 Captive_GnomeVFSFileSize bytes_written_corba;
190 xmlNode *xml_action=NULL;
191 CaptiveVfsParentObject *captive_vfs_parent_object;
192
193         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
194         g_return_val_if_fail(buffer_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
195         g_return_val_if_fail(bytes_written_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
196         g_return_val_if_fail(num_bytes==(ULONG)num_bytes,GNOME_VFS_ERROR_BAD_PARAMETERS);
197
198         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
199
200         *bytes_written_return=0;
201
202         r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
203                         GNOME_VFS_SEEK_START,captive_file_parent_object->offset);
204         if (r==GNOME_VFS_OK) {
205
206                 if (captive_vfs_parent_object->corba_bug_action) {
207                         xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_write",NULL);
208                         xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
209                         xmlNewProp(xml_action,BAD_CAST "num_bytes",BAD_CAST captive_printf_alloca("%lu",(unsigned long)num_bytes));
210                         }
211
212                 buffer_corba_local._maximum=num_bytes;
213                 buffer_corba_local._length=num_bytes;
214                 buffer_corba_local._buffer=(/* de-const */gpointer)buffer_captive;
215                 buffer_corba_local._release=FALSE;
216
217                 Captive_File_write(captive_file_parent_object->corba_File_object,
218                                 &buffer_corba_local,&bytes_written_corba,&captive_corba_ev);
219                 r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
220                 if (xml_action)
221                         xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
222                 }
223         if (r!=GNOME_VFS_OK)
224                 return r;
225
226         *bytes_written_return=bytes_written_corba;
227         captive_file_parent_object->offset+=bytes_written_corba;
228
229         if (xml_action)
230                 xmlNewProp(xml_action,BAD_CAST "bytes_written_return",BAD_CAST captive_printf_alloca("%lu",(unsigned long)*bytes_written_return));
231
232         return GNOME_VFS_OK;
233 }
234
235
236 static GnomeVFSResult captive_sandbox_parent_file_seek_slave
237                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset)
238 {
239 GnomeVFSResult r;
240 xmlNode *xml_action=NULL;
241 CaptiveVfsParentObject *captive_vfs_parent_object;
242
243         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
244
245         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
246
247         if (captive_vfs_parent_object->corba_bug_action) {
248                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_seek",NULL);
249                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
250                 xmlNewProp(xml_action,BAD_CAST "whence",BAD_CAST
251                                 (whence==GNOME_VFS_SEEK_START ? "start" :
252                                         (whence==GNOME_VFS_SEEK_CURRENT ? "current" :
253                                                 (whence==GNOME_VFS_SEEK_END ? "end" : captive_printf_alloca("%lu",(unsigned long)whence)))));
254                 xmlNewProp(xml_action,BAD_CAST "offset",BAD_CAST captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)offset));
255                 }
256
257         Captive_File_seek(captive_file_parent_object->corba_File_object,whence,offset,&captive_corba_ev);
258         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
259         if (xml_action)
260                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
261         if (r!=GNOME_VFS_OK)
262                 return r;
263
264         return GNOME_VFS_OK;
265 }
266
267
268 GnomeVFSResult captive_sandbox_parent_file_seek
269                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset)
270 {
271 GnomeVFSResult r;
272 CaptiveVfsParentObject *captive_vfs_parent_object;
273
274         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
275
276         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
277
278         /* Do not produce 'xml_action' here as we use only 'slave' point of view
279          * for captive-bug-replay(1).
280          */
281
282         switch (whence) {
283                 case GNOME_VFS_SEEK_START:
284                         captive_file_parent_object->offset=offset;
285                         r=GNOME_VFS_OK;
286                         break;
287                 case GNOME_VFS_SEEK_CURRENT:
288                         if (0
289                                         || (offset>0 && (captive_file_parent_object->offset+offset)<captive_file_parent_object->offset)
290                                         || (offset<0 && (captive_file_parent_object->offset+offset)>captive_file_parent_object->offset))
291                                 r=GNOME_VFS_ERROR_BAD_PARAMETERS;
292                         else {
293                                 captive_file_parent_object->offset+=offset;
294                                 r=GNOME_VFS_OK;
295                                 }
296                         break;
297                 case GNOME_VFS_SEEK_END:
298                         g_assert_not_reached(); /* NOT IMPLEMENTED YET */
299                         r=GNOME_VFS_ERROR_GENERIC;
300                         break;
301                 default:
302                         r=GNOME_VFS_ERROR_BAD_PARAMETERS;
303                 }
304
305         if (r!=GNOME_VFS_OK)
306                 return r;
307
308         return GNOME_VFS_OK;
309 }
310
311
312 #if 0 /* unused */
313 static GnomeVFSResult captive_sandbox_parent_file_tell_slave
314                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
315 {
316 Captive_GnomeVFSFileOffset offset_corba;
317 GnomeVFSResult r;
318 xmlNode *xml_action=NULL;
319 CaptiveVfsParentObject *captive_vfs_parent_object;
320
321         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
322         g_return_val_if_fail(offset_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
323
324         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
325
326         if (captive_vfs_parent_object->corba_bug_action) {
327                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_tell",NULL);
328                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
329                 }
330
331         Captive_File_tell(captive_file_parent_object->corba_File_object,&offset_corba,&captive_corba_ev);
332         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
333         if (xml_action)
334                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
335         if (r!=GNOME_VFS_OK)
336                 return r;
337
338         *offset_return=offset_corba;
339
340         if (xml_action)
341                 xmlNewProp(xml_action,"offset_return",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)*offset_return));
342
343         return GNOME_VFS_OK;
344 }
345 #endif
346
347
348 GnomeVFSResult captive_sandbox_parent_file_tell(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
349 {
350 GnomeVFSResult r;
351 CaptiveVfsParentObject *captive_vfs_parent_object;
352
353         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
354         g_return_val_if_fail(offset_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
355
356         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
357
358         /* Do not produce 'xml_action' here as we use only 'slave' point of view
359          * for captive-bug-replay(1).
360          */
361
362         *offset_return=captive_file_parent_object->offset;
363         r=GNOME_VFS_OK;
364
365         if (r!=GNOME_VFS_OK)
366                 return r;
367
368         return GNOME_VFS_OK;
369 }
370
371
372 GnomeVFSResult captive_sandbox_parent_file_remove(CaptiveFileParentObject *captive_file_parent_object)
373 {
374 GnomeVFSResult r;
375 xmlNode *xml_action=NULL;
376 CaptiveVfsParentObject *captive_vfs_parent_object;
377
378         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
379
380         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
381
382         if (captive_vfs_parent_object->corba_bug_action) {
383                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_remove",NULL);
384                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
385                 }
386
387         Captive_File_remove(captive_file_parent_object->corba_File_object,&captive_corba_ev);
388         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
389         if (xml_action)
390                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
391         if (r!=GNOME_VFS_OK)
392                 return r;
393
394         return GNOME_VFS_OK;
395 }
396
397
398 GnomeVFSResult captive_sandbox_parent_file_file_info_get(CaptiveFileParentObject *captive_file_parent_object,
399                 CaptiveFileInfoObject **captive_file_info_object_return)
400 {
401 Captive_CaptiveFileInfoObject *file_info_corba;
402 GnomeVFSResult r;
403 xmlNode *xml_action=NULL;
404 CaptiveVfsParentObject *captive_vfs_parent_object;
405 CaptiveFileInfoObject *captive_file_info_object;
406
407         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
408         g_return_val_if_fail(captive_file_info_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
409
410         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
411
412         if (captive_vfs_parent_object->corba_bug_action) {
413                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_file_info_get",NULL);
414                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
415                 }
416
417         Captive_File_file_info_get(captive_file_parent_object->corba_File_object,&file_info_corba,&captive_corba_ev);
418         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
419         if (xml_action)
420                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
421         if (r!=GNOME_VFS_OK)
422                 return r;
423
424         r=captive_file_info_object_new(&captive_file_info_object);
425         if (xml_action)
426                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
427         if (r!=GNOME_VFS_OK) {
428                 Captive_CaptiveFileInfoObject__freekids(file_info_corba,NULL/* 'd'; meaning? */);
429                 CORBA_free(file_info_corba);
430                 return r;
431                 }
432
433         r=captive_sandbox_file_info_corba_to_captive(captive_file_info_object,file_info_corba);
434         Captive_CaptiveFileInfoObject__freekids(file_info_corba,NULL/* 'd'; meaning? */);
435         CORBA_free(file_info_corba);
436         if (xml_action)
437                 xmlSetProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
438         if (r!=GNOME_VFS_OK) {
439                 g_object_unref(captive_file_info_object);
440                 return r;
441                 }
442
443         *captive_file_info_object_return=captive_file_info_object;
444         return GNOME_VFS_OK;
445 }
446
447
448 GnomeVFSResult captive_sandbox_parent_file_file_info_set(CaptiveFileParentObject *captive_file_parent_object,
449     CaptiveFileInfoObject *file_info_captive,GnomeVFSSetFileInfoMask mask)
450 {
451 Captive_CaptiveFileInfoObject file_info_corba;
452 GnomeVFSResult r;
453 xmlNode *xml_action=NULL;
454 CaptiveVfsParentObject *captive_vfs_parent_object;
455
456         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
457         g_return_val_if_fail(file_info_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
458
459         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
460
461         if (captive_vfs_parent_object->corba_bug_action) {
462                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_file_info_set",NULL);
463                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
464                 xmlNewProp(xml_action,BAD_CAST "mask",BAD_CAST captive_printf_alloca("%u",(unsigned)mask));
465                 }
466
467         if (GNOME_VFS_OK!=(r=captive_sandbox_file_info_set_mask_captive_to_corba(&file_info_corba,file_info_captive,mask)))
468                 return r;
469
470         Captive_File_file_info_set(captive_file_parent_object->corba_File_object,&file_info_corba,mask,&captive_corba_ev);
471         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
472         if (xml_action)
473                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
474         if (r!=GNOME_VFS_OK)
475                 return r;
476
477         Captive_CaptiveFileInfoObject__freekids(&file_info_corba,NULL/* 'd'; meaning? */);
478
479         return GNOME_VFS_OK;
480 }
481
482
483 GnomeVFSResult captive_sandbox_parent_file_truncate(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileSize file_size)
484 {
485 GnomeVFSResult r;
486 xmlNode *xml_action=NULL;
487 CaptiveVfsParentObject *captive_vfs_parent_object;
488
489         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
490
491         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
492
493         if (captive_vfs_parent_object->corba_bug_action) {
494                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_truncate",NULL);
495                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
496                 xmlNewProp(xml_action,BAD_CAST "file_size",BAD_CAST captive_printf_alloca("%" G_GUINT64_FORMAT,(guint64)file_size));
497                 }
498
499         Captive_File_truncate(captive_file_parent_object->corba_File_object,file_size,&captive_corba_ev);
500         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
501         if (xml_action)
502                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
503         if (r!=GNOME_VFS_OK)
504                 return r;
505
506         return GNOME_VFS_OK;
507 }
508
509
510 GnomeVFSResult captive_sandbox_parent_file_move
511                 (CaptiveFileParentObject *captive_file_parent_object_old,const gchar *pathname_new,gboolean force_replace)
512 {
513 GnomeVFSResult r;
514 xmlNode *xml_action=NULL;
515 CaptiveVfsParentObject *captive_vfs_parent_object;
516
517         g_return_val_if_fail(captive_file_parent_object_old!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
518         g_return_val_if_fail(pathname_new!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
519
520         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object_old)->vfs);
521
522         if (captive_vfs_parent_object->corba_bug_action) {
523                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_move",NULL);
524                 xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object_old));
525                 xmlNewProp(xml_action,BAD_CAST "pathname_new",BAD_CAST pathname_new);
526                 xmlNewProp(xml_action,BAD_CAST "force_replace",BAD_CAST captive_printf_alloca("%u",(unsigned)force_replace));
527                 }
528
529         Captive_File_move(captive_file_parent_object_old->corba_File_object,pathname_new,force_replace,&captive_corba_ev);
530         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
531         if (xml_action)
532                 xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
533         if (r!=GNOME_VFS_OK)
534                 return r;
535
536         return GNOME_VFS_OK;
537 }