Implemented CaptiveParentConnector sandbox restarts handling GInterface.
[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                 const gchar *pathname,GnomeVFSOpenMode mode)
35 {
36 xmlNode *xml_action=NULL;
37 CaptiveVfsParentObject *captive_vfs_parent_object;
38
39         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
40         g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
41
42         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
43
44         if (captive_vfs_parent_object->corba_bug_action) {
45                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_new_open",NULL);
46                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
47                 xmlNewProp(xml_action,"pathname",pathname);
48                 xmlNewProp(xml_action,"mode",captive_printf_alloca("%u",(unsigned)mode));
49                 }
50
51         captive_file_parent_object->corba_File_object=Captive_Vfs_file_new_open(
52                         captive_vfs_parent_object->corba_Vfs_object,pathname,mode,&captive_corba_ev);
53         if (xml_action)
54                 xmlNewProp(xml_action,"result",(captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
55
56         return captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
57 }
58
59
60 GnomeVFSResult captive_sandbox_parent_file_new_create(CaptiveFileParentObject *captive_file_parent_object,
61                 const gchar *pathname,GnomeVFSOpenMode mode,gboolean exclusive,guint perm)
62 {
63 xmlNode *xml_action=NULL;
64 CaptiveVfsParentObject *captive_vfs_parent_object;
65
66         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
67         g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
68
69         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
70
71         if (captive_vfs_parent_object->corba_bug_action) {
72                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_new_create",NULL);
73                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
74                 xmlNewProp(xml_action,"pathname",pathname);
75                 xmlNewProp(xml_action,"mode",captive_printf_alloca("%u",(unsigned)mode));
76                 xmlNewProp(xml_action,"exclusive",captive_printf_alloca("%u",(unsigned)exclusive));
77                 xmlNewProp(xml_action,"perm",captive_printf_alloca("%u",(unsigned)perm));
78                 }
79
80         captive_file_parent_object->corba_File_object=Captive_Vfs_file_new_create(
81                         captive_vfs_parent_object->corba_Vfs_object,pathname,mode,exclusive,perm,&captive_corba_ev);
82         if (xml_action)
83                 xmlNewProp(xml_action,"result",(captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
84
85         return captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
86 }
87
88
89 GnomeVFSResult captive_sandbox_parent_file_close(CaptiveFileParentObject *captive_file_parent_object)
90 {
91 GnomeVFSResult r;
92 xmlNode *xml_action=NULL;
93 CaptiveVfsParentObject *captive_vfs_parent_object;
94
95         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
96
97         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
98
99         if (captive_vfs_parent_object->corba_bug_action) {
100                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_close",NULL);
101                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
102                 }
103
104         Captive_File_shutdown(captive_file_parent_object->corba_File_object,&captive_corba_ev);
105         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
106         if (xml_action)
107                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
108         if (r!=GNOME_VFS_OK)
109                 return r;
110
111         CORBA_Object_release((CORBA_Object)captive_file_parent_object->corba_File_object,&captive_corba_ev);
112         captive_file_parent_object->corba_File_object=CORBA_OBJECT_NIL;
113
114         return captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
115 }
116
117
118 static GnomeVFSResult captive_sandbox_parent_file_seek_slave
119                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset);
120
121 GnomeVFSResult captive_sandbox_parent_file_read(CaptiveFileParentObject *captive_file_parent_object,
122                 gpointer buffer_captive,GnomeVFSFileSize num_bytes,GnomeVFSFileSize *bytes_read_return)
123 {
124 GnomeVFSResult r;
125 Captive_Bytes *buffer_corba;
126 xmlNode *xml_action=NULL;
127 CaptiveVfsParentObject *captive_vfs_parent_object;
128
129         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
130         g_return_val_if_fail(buffer_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
131         g_return_val_if_fail(bytes_read_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
132         g_return_val_if_fail(num_bytes==(ULONG)num_bytes,GNOME_VFS_ERROR_BAD_PARAMETERS);
133
134         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
135
136         *bytes_read_return=0;
137
138         if (captive_vfs_parent_object->corba_bug_action) {
139                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_read",NULL);
140                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
141                 xmlNewProp(xml_action,"num_bytes",captive_printf_alloca("%lu",(unsigned long)num_bytes));
142                 }
143
144         r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
145                         GNOME_VFS_SEEK_START,captive_file_parent_object->offset);
146         if (r==GNOME_VFS_OK) {
147                 Captive_File_read(captive_file_parent_object->corba_File_object,&buffer_corba,num_bytes,&captive_corba_ev);
148                 r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
149                 }
150         if (xml_action)
151                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
152         if (r!=GNOME_VFS_OK)
153                 return r;
154
155         g_return_val_if_fail(buffer_corba->_length<=num_bytes,GNOME_VFS_ERROR_GENERIC);
156         memcpy(buffer_captive,buffer_corba->_buffer,buffer_corba->_length);
157         *bytes_read_return=buffer_corba->_length;
158         captive_file_parent_object->offset+=buffer_corba->_length;
159
160         Captive_Bytes__freekids(buffer_corba,NULL/* 'd'; meaning? */);
161         CORBA_free(buffer_corba);
162
163         if (xml_action)
164                 xmlNewProp(xml_action,"bytes_read_return",captive_printf_alloca("%lu",(unsigned long)*bytes_read_return));
165
166         return GNOME_VFS_OK;
167 }
168
169
170 GnomeVFSResult captive_sandbox_parent_file_write(CaptiveFileParentObject *captive_file_parent_object,
171                 gconstpointer buffer_captive,GnomeVFSFileSize num_bytes,GnomeVFSFileSize *bytes_written_return)
172 {
173 GnomeVFSResult r;
174 Captive_Bytes buffer_corba_local;
175 Captive_GnomeVFSFileSize bytes_written_corba;
176 xmlNode *xml_action=NULL;
177 CaptiveVfsParentObject *captive_vfs_parent_object;
178
179         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
180         g_return_val_if_fail(buffer_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
181         g_return_val_if_fail(bytes_written_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
182         g_return_val_if_fail(num_bytes==(ULONG)num_bytes,GNOME_VFS_ERROR_BAD_PARAMETERS);
183
184         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
185
186         *bytes_written_return=0;
187
188         if (captive_vfs_parent_object->corba_bug_action) {
189                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_write",NULL);
190                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
191                 xmlNewProp(xml_action,"num_bytes",captive_printf_alloca("%lu",(unsigned long)num_bytes));
192                 }
193
194         r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
195                         GNOME_VFS_SEEK_START,captive_file_parent_object->offset);
196         if (r==GNOME_VFS_OK) {
197                 buffer_corba_local._maximum=num_bytes;
198                 buffer_corba_local._length=num_bytes;
199                 buffer_corba_local._buffer=(/* de-const */gpointer)buffer_captive;
200                 buffer_corba_local._release=FALSE;
201
202                 Captive_File_write(captive_file_parent_object->corba_File_object,
203                                 &buffer_corba_local,&bytes_written_corba,&captive_corba_ev);
204                 r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
205                 }
206         if (xml_action)
207                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
208         if (r!=GNOME_VFS_OK)
209                 return r;
210
211         *bytes_written_return=bytes_written_corba;
212         captive_file_parent_object->offset+=bytes_written_corba;
213
214         if (xml_action)
215                 xmlNewProp(xml_action,"bytes_written_return",captive_printf_alloca("%lu",(unsigned long)*bytes_written_return));
216
217         return GNOME_VFS_OK;
218 }
219
220
221 static GnomeVFSResult captive_sandbox_parent_file_seek_slave
222                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset)
223 {
224 GnomeVFSResult r;
225 xmlNode *xml_action=NULL;
226 CaptiveVfsParentObject *captive_vfs_parent_object;
227
228         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
229
230         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
231
232         if (captive_vfs_parent_object->corba_bug_action) {
233                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_seek",NULL);
234                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
235                 xmlNewProp(xml_action,"whence",
236                                 (whence==GNOME_VFS_SEEK_START ? "start" :
237                                         (whence==GNOME_VFS_SEEK_CURRENT ? "current" :
238                                                 (whence==GNOME_VFS_SEEK_END ? "end" : captive_printf_alloca("%lu",(unsigned long)whence)))));
239                 xmlNewProp(xml_action,"offset",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)offset));
240                 }
241
242         Captive_File_seek(captive_file_parent_object->corba_File_object,whence,offset,&captive_corba_ev);
243         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
244         if (xml_action)
245                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
246         if (r!=GNOME_VFS_OK)
247                 return r;
248
249         return GNOME_VFS_OK;
250 }
251
252
253 GnomeVFSResult captive_sandbox_parent_file_seek
254                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSSeekPosition whence,GnomeVFSFileOffset offset)
255 {
256 GnomeVFSResult r;
257 xmlNode *xml_action=NULL;
258 CaptiveVfsParentObject *captive_vfs_parent_object;
259
260         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
261
262         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
263
264         if (captive_vfs_parent_object->corba_bug_action) {
265                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_seek",NULL);
266                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
267                 xmlNewProp(xml_action,"whence",
268                                 (whence==GNOME_VFS_SEEK_START ? "start" :
269                                         (whence==GNOME_VFS_SEEK_CURRENT ? "current" :
270                                                 (whence==GNOME_VFS_SEEK_END ? "end" : captive_printf_alloca("%lu",(unsigned long)whence)))));
271                 xmlNewProp(xml_action,"offset",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)offset));
272                 }
273
274         switch (whence) {
275                 case GNOME_VFS_SEEK_START:
276                         captive_file_parent_object->offset=offset;
277                         break;
278                 case GNOME_VFS_SEEK_CURRENT:
279                         if (0
280                                         || (offset>0 && (captive_file_parent_object->offset+offset)<captive_file_parent_object->offset)
281                                         || (offset<0 && (captive_file_parent_object->offset+offset)>captive_file_parent_object->offset))
282                                 r=GNOME_VFS_ERROR_BAD_PARAMETERS;
283                         else
284                                 captive_file_parent_object->offset+=offset;
285                         break;
286                 case GNOME_VFS_SEEK_END:
287                         g_assert_not_reached(); /* NOT IMPLEMENTED YET */
288                         r=GNOME_VFS_ERROR_GENERIC;
289                         break;
290                 default:
291                         r=GNOME_VFS_ERROR_BAD_PARAMETERS;
292                 }
293
294         if (xml_action)
295                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
296         if (r!=GNOME_VFS_OK)
297                 return r;
298
299         return GNOME_VFS_OK;
300 }
301
302
303 #if 0 /* unused */
304 static GnomeVFSResult captive_sandbox_parent_file_tell_slave
305                 (CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
306 {
307 Captive_GnomeVFSFileOffset offset_corba;
308 GnomeVFSResult r;
309 xmlNode *xml_action=NULL;
310 CaptiveVfsParentObject *captive_vfs_parent_object;
311
312         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
313         g_return_val_if_fail(offset_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
314
315         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
316
317         if (captive_vfs_parent_object->corba_bug_action) {
318                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_tell",NULL);
319                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
320                 }
321
322         Captive_File_tell(captive_file_parent_object->corba_File_object,&offset_corba,&captive_corba_ev);
323         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
324         if (xml_action)
325                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
326         if (r!=GNOME_VFS_OK)
327                 return r;
328
329         *offset_return=offset_corba;
330
331         if (xml_action)
332                 xmlNewProp(xml_action,"offset_return",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)*offset_return));
333
334         return GNOME_VFS_OK;
335 }
336 #endif
337
338
339 GnomeVFSResult captive_sandbox_parent_file_tell(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileOffset *offset_return)
340 {
341 GnomeVFSResult r;
342 xmlNode *xml_action=NULL;
343 CaptiveVfsParentObject *captive_vfs_parent_object;
344
345         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
346         g_return_val_if_fail(offset_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
347
348         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
349
350         if (captive_vfs_parent_object->corba_bug_action) {
351                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_tell",NULL);
352                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
353                 }
354
355         *offset_return=captive_file_parent_object->offset;
356         r=GNOME_VFS_OK;
357         if (xml_action)
358                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
359         if (r!=GNOME_VFS_OK)
360                 return r;
361
362         if (xml_action)
363                 xmlNewProp(xml_action,"offset_return",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)*offset_return));
364
365         return GNOME_VFS_OK;
366 }
367
368
369 GnomeVFSResult captive_sandbox_parent_file_remove(CaptiveFileParentObject *captive_file_parent_object)
370 {
371 GnomeVFSResult r;
372 xmlNode *xml_action=NULL;
373 CaptiveVfsParentObject *captive_vfs_parent_object;
374
375         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
376
377         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
378
379         if (captive_vfs_parent_object->corba_bug_action) {
380                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_remove",NULL);
381                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
382                 }
383
384         Captive_File_remove(captive_file_parent_object->corba_File_object,&captive_corba_ev);
385         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
386         if (xml_action)
387                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
388         if (r!=GNOME_VFS_OK)
389                 return r;
390
391         return GNOME_VFS_OK;
392 }
393
394
395 GnomeVFSResult captive_sandbox_parent_file_file_info_get(CaptiveFileParentObject *captive_file_parent_object,
396                 GnomeVFSFileInfo *file_info_captive)
397 {
398 Captive_GnomeVFSFileInfo *file_info_corba;
399 GnomeVFSResult r;
400 xmlNode *xml_action=NULL;
401 CaptiveVfsParentObject *captive_vfs_parent_object;
402
403         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
404         g_return_val_if_fail(file_info_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
405
406         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
407
408         if (captive_vfs_parent_object->corba_bug_action) {
409                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_file_info_get",NULL);
410                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
411                 }
412
413         Captive_File_file_info_get(captive_file_parent_object->corba_File_object,&file_info_corba,&captive_corba_ev);
414         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
415         if (xml_action)
416                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
417         if (r!=GNOME_VFS_OK)
418                 return r;
419
420         r=captive_sandbox_file_info_corba_to_captive(file_info_captive,file_info_corba);
421         Captive_GnomeVFSFileInfo__freekids(file_info_corba,NULL/* 'd'; meaning? */);
422         CORBA_free(file_info_corba);
423         if (xml_action)
424                 xmlSetProp(xml_action,"result",gnome_vfs_result_to_string(r));
425         if (r!=GNOME_VFS_OK)
426                 return r;
427
428         return GNOME_VFS_OK;
429 }
430
431
432 GnomeVFSResult captive_sandbox_parent_file_file_info_set(CaptiveFileParentObject *captive_file_parent_object,
433     const GnomeVFSFileInfo *file_info_captive,GnomeVFSSetFileInfoMask mask)
434 {
435 Captive_GnomeVFSFileInfo file_info_corba;
436 GnomeVFSResult r;
437 xmlNode *xml_action=NULL;
438 CaptiveVfsParentObject *captive_vfs_parent_object;
439
440         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
441         g_return_val_if_fail(file_info_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
442
443         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
444
445         if (captive_vfs_parent_object->corba_bug_action) {
446                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_file_info_set",NULL);
447                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
448                 xmlNewProp(xml_action,"mask",captive_printf_alloca("%u",(unsigned)mask));
449                 }
450
451         if (GNOME_VFS_OK!=(r=captive_sandbox_file_info_captive_to_corba(&file_info_corba,file_info_captive)))
452                 return r;
453
454         Captive_File_file_info_set(captive_file_parent_object->corba_File_object,&file_info_corba,mask,&captive_corba_ev);
455         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
456         if (xml_action)
457                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
458         if (r!=GNOME_VFS_OK)
459                 return r;
460
461         Captive_GnomeVFSFileInfo__freekids(&file_info_corba,NULL/* 'd'; meaning? */);
462
463         return GNOME_VFS_OK;
464 }
465
466
467 GnomeVFSResult captive_sandbox_parent_file_truncate(CaptiveFileParentObject *captive_file_parent_object,GnomeVFSFileSize file_size)
468 {
469 GnomeVFSResult r;
470 xmlNode *xml_action=NULL;
471 CaptiveVfsParentObject *captive_vfs_parent_object;
472
473         g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
474
475         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
476
477         if (captive_vfs_parent_object->corba_bug_action) {
478                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_truncate",NULL);
479                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
480                 xmlNewProp(xml_action,"file_size",captive_printf_alloca("%" G_GUINT64_FORMAT,(guint64)file_size));
481                 }
482
483         Captive_File_truncate(captive_file_parent_object->corba_File_object,file_size,&captive_corba_ev);
484         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
485         if (xml_action)
486                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
487         if (r!=GNOME_VFS_OK)
488                 return r;
489
490         return GNOME_VFS_OK;
491 }
492
493
494 GnomeVFSResult captive_sandbox_parent_file_move
495                 (CaptiveFileParentObject *captive_file_parent_object_old,const gchar *pathname_new,gboolean force_replace)
496 {
497 GnomeVFSResult r;
498 xmlNode *xml_action=NULL;
499 CaptiveVfsParentObject *captive_vfs_parent_object;
500
501         g_return_val_if_fail(captive_file_parent_object_old!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
502         g_return_val_if_fail(pathname_new!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
503
504         captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object_old)->vfs);
505
506         if (captive_vfs_parent_object->corba_bug_action) {
507                 xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_truncate",NULL);
508                 xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object_old));
509                 xmlNewProp(xml_action,"pathname_new",pathname_new);
510                 xmlNewProp(xml_action,"force_replace",captive_printf_alloca("%u",(unsigned)force_replace));
511                 }
512
513         Captive_File_move(captive_file_parent_object_old->corba_File_object,pathname_new,force_replace,&captive_corba_ev);
514         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
515         if (xml_action)
516                 xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
517         if (r!=GNOME_VFS_OK)
518                 return r;
519
520         return GNOME_VFS_OK;
521 }