Implemented sub-second W32 filesystem interface by new: CaptiveFileInfoObject
[captive.git] / src / libcaptive / sandbox / parent-File.c
index cf22421..ca062f5 100644 (file)
@@ -43,16 +43,16 @@ Captive_File corba_File_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_new_open",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-               xmlNewProp(xml_action,"pathname",captive_file_parent_object->pathname);
-               xmlNewProp(xml_action,"mode",captive_printf_alloca("%u",(unsigned)captive_file_parent_object->mode));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_new_open",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+               xmlNewProp(xml_action,BAD_CAST "pathname",BAD_CAST captive_file_parent_object->pathname);
+               xmlNewProp(xml_action,BAD_CAST "mode",BAD_CAST captive_printf_alloca("%u",(unsigned)captive_file_parent_object->mode));
                }
 
        corba_File_object=Captive_Vfs_file_new_open(captive_vfs_parent_object->corba_Vfs_object,
                        captive_file_parent_object->pathname,captive_file_parent_object->mode,&captive_corba_ev);
        if (xml_action)
-               xmlNewProp(xml_action,"result",(captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST (captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
        /* If 'r' means failure 'corba_File_object' may not be 'CORBA_OBJECT_NIL'
         * although it is not valid 'CORBA_Object' to be passed to CORBA_Object_release().
         */
@@ -78,18 +78,18 @@ Captive_File corba_File_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_new_create",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-               xmlNewProp(xml_action,"pathname",captive_file_parent_object->pathname);
-               xmlNewProp(xml_action,"mode",captive_printf_alloca("%u",(unsigned)captive_file_parent_object->mode));
-               xmlNewProp(xml_action,"exclusive",captive_printf_alloca("%u",(unsigned)exclusive));
-               xmlNewProp(xml_action,"perm",captive_printf_alloca("%u",(unsigned)perm));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_new_create",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+               xmlNewProp(xml_action,BAD_CAST "pathname",BAD_CAST captive_file_parent_object->pathname);
+               xmlNewProp(xml_action,BAD_CAST "mode",BAD_CAST captive_printf_alloca("%u",(unsigned)captive_file_parent_object->mode));
+               xmlNewProp(xml_action,BAD_CAST "exclusive",BAD_CAST captive_printf_alloca("%u",(unsigned)exclusive));
+               xmlNewProp(xml_action,BAD_CAST "perm",BAD_CAST captive_printf_alloca("%u",(unsigned)perm));
                }
 
        corba_File_object=Captive_Vfs_file_new_create(captive_vfs_parent_object->corba_Vfs_object,
                        captive_file_parent_object->pathname,captive_file_parent_object->mode,exclusive,perm,&captive_corba_ev);
        if (xml_action)
-               xmlNewProp(xml_action,"result",(captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST (captive_corba_ev._major==CORBA_NO_EXCEPTION ? "1" : "0"));
        /* If 'r' means failure 'corba_File_object' may not be 'CORBA_OBJECT_NIL'
         * although it is not valid 'CORBA_Object' to be passed to CORBA_Object_release().
         */
@@ -112,14 +112,14 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_close",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_close",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
                }
 
        Captive_File_shutdown(captive_file_parent_object->corba_File_object,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
 
        /* Always clear 'corba_File_object' even if 'r' means failure. */
        CORBA_Object_release((CORBA_Object)captive_file_parent_object->corba_File_object,&captive_corba_ev);
@@ -150,9 +150,9 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        *bytes_read_return=0;
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_read",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-               xmlNewProp(xml_action,"num_bytes",captive_printf_alloca("%lu",(unsigned long)num_bytes));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_read",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+               xmlNewProp(xml_action,BAD_CAST "num_bytes",BAD_CAST captive_printf_alloca("%lu",(unsigned long)num_bytes));
                }
 
        r=captive_sandbox_parent_file_seek_slave(captive_file_parent_object,
@@ -162,7 +162,7 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
                r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
                }
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;
 
@@ -175,7 +175,7 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        CORBA_free(buffer_corba);
 
        if (xml_action)
-               xmlNewProp(xml_action,"bytes_read_return",captive_printf_alloca("%lu",(unsigned long)*bytes_read_return));
+               xmlNewProp(xml_action,BAD_CAST "bytes_read_return",BAD_CAST captive_printf_alloca("%lu",(unsigned long)*bytes_read_return));
 
        return GNOME_VFS_OK;
 }
@@ -204,9 +204,9 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        if (r==GNOME_VFS_OK) {
 
                if (captive_vfs_parent_object->corba_bug_action) {
-                       xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_write",NULL);
-                       xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-                       xmlNewProp(xml_action,"num_bytes",captive_printf_alloca("%lu",(unsigned long)num_bytes));
+                       xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_write",NULL);
+                       xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+                       xmlNewProp(xml_action,BAD_CAST "num_bytes",BAD_CAST captive_printf_alloca("%lu",(unsigned long)num_bytes));
                        }
 
                buffer_corba_local._maximum=num_bytes;
@@ -218,7 +218,7 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
                                &buffer_corba_local,&bytes_written_corba,&captive_corba_ev);
                r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
                if (xml_action)
-                       xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+                       xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
                }
        if (r!=GNOME_VFS_OK)
                return r;
@@ -227,7 +227,7 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_file_parent_object->offset+=bytes_written_corba;
 
        if (xml_action)
-               xmlNewProp(xml_action,"bytes_written_return",captive_printf_alloca("%lu",(unsigned long)*bytes_written_return));
+               xmlNewProp(xml_action,BAD_CAST "bytes_written_return",BAD_CAST captive_printf_alloca("%lu",(unsigned long)*bytes_written_return));
 
        return GNOME_VFS_OK;
 }
@@ -245,19 +245,19 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_seek",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-               xmlNewProp(xml_action,"whence",
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_seek",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+               xmlNewProp(xml_action,BAD_CAST "whence",BAD_CAST
                                (whence==GNOME_VFS_SEEK_START ? "start" :
                                        (whence==GNOME_VFS_SEEK_CURRENT ? "current" :
                                                (whence==GNOME_VFS_SEEK_END ? "end" : captive_printf_alloca("%lu",(unsigned long)whence)))));
-               xmlNewProp(xml_action,"offset",captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)offset));
+               xmlNewProp(xml_action,BAD_CAST "offset",BAD_CAST captive_printf_alloca("%" G_GINT64_FORMAT,(gint64)offset));
                }
 
        Captive_File_seek(captive_file_parent_object->corba_File_object,whence,offset,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;
 
@@ -380,14 +380,14 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_remove",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_remove",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
                }
 
        Captive_File_remove(captive_file_parent_object->corba_File_object,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;
 
@@ -396,46 +396,59 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
 
 
 GnomeVFSResult captive_sandbox_parent_file_file_info_get(CaptiveFileParentObject *captive_file_parent_object,
-               GnomeVFSFileInfo *file_info_captive)
+               CaptiveFileInfoObject **captive_file_info_object_return)
 {
-Captive_GnomeVFSFileInfo *file_info_corba;
+Captive_CaptiveFileInfoObject *file_info_corba;
 GnomeVFSResult r;
 xmlNode *xml_action=NULL;
 CaptiveVfsParentObject *captive_vfs_parent_object;
+CaptiveFileInfoObject *captive_file_info_object;
 
        g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_parent_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
-       g_return_val_if_fail(file_info_captive!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
+       g_return_val_if_fail(captive_file_info_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
 
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_file_info_get",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_file_info_get",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
                }
 
        Captive_File_file_info_get(captive_file_parent_object->corba_File_object,&file_info_corba,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;
 
-       r=captive_sandbox_file_info_corba_to_captive(file_info_captive,file_info_corba);
-       Captive_GnomeVFSFileInfo__freekids(file_info_corba,NULL/* 'd'; meaning? */);
+       r=captive_file_info_object_new(&captive_file_info_object);
+       if (xml_action)
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
+       if (r!=GNOME_VFS_OK) {
+               Captive_CaptiveFileInfoObject__freekids(file_info_corba,NULL/* 'd'; meaning? */);
+               CORBA_free(file_info_corba);
+               return r;
+               }
+
+       r=captive_sandbox_file_info_corba_to_captive(captive_file_info_object,file_info_corba);
+       Captive_CaptiveFileInfoObject__freekids(file_info_corba,NULL/* 'd'; meaning? */);
        CORBA_free(file_info_corba);
        if (xml_action)
-               xmlSetProp(xml_action,"result",gnome_vfs_result_to_string(r));
-       if (r!=GNOME_VFS_OK)
+               xmlSetProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
+       if (r!=GNOME_VFS_OK) {
+               g_object_unref(captive_file_info_object);
                return r;
+               }
 
+       *captive_file_info_object_return=captive_file_info_object;
        return GNOME_VFS_OK;
 }
 
 
 GnomeVFSResult captive_sandbox_parent_file_file_info_set(CaptiveFileParentObject *captive_file_parent_object,
-    const GnomeVFSFileInfo *file_info_captive,GnomeVFSSetFileInfoMask mask)
+    CaptiveFileInfoObject *file_info_captive,GnomeVFSSetFileInfoMask mask)
 {
-Captive_GnomeVFSFileInfo file_info_corba;
+Captive_CaptiveFileInfoObject file_info_corba;
 GnomeVFSResult r;
 xmlNode *xml_action=NULL;
 CaptiveVfsParentObject *captive_vfs_parent_object;
@@ -446,9 +459,9 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_file_info_set",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-               xmlNewProp(xml_action,"mask",captive_printf_alloca("%u",(unsigned)mask));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_file_info_set",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+               xmlNewProp(xml_action,BAD_CAST "mask",BAD_CAST captive_printf_alloca("%u",(unsigned)mask));
                }
 
        if (GNOME_VFS_OK!=(r=captive_sandbox_file_info_set_mask_captive_to_corba(&file_info_corba,file_info_captive,mask)))
@@ -457,11 +470,11 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        Captive_File_file_info_set(captive_file_parent_object->corba_File_object,&file_info_corba,mask,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;
 
-       Captive_GnomeVFSFileInfo__freekids(&file_info_corba,NULL/* 'd'; meaning? */);
+       Captive_CaptiveFileInfoObject__freekids(&file_info_corba,NULL/* 'd'; meaning? */);
 
        return GNOME_VFS_OK;
 }
@@ -478,15 +491,15 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_truncate",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object));
-               xmlNewProp(xml_action,"file_size",captive_printf_alloca("%" G_GUINT64_FORMAT,(guint64)file_size));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_truncate",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object));
+               xmlNewProp(xml_action,BAD_CAST "file_size",BAD_CAST captive_printf_alloca("%" G_GUINT64_FORMAT,(guint64)file_size));
                }
 
        Captive_File_truncate(captive_file_parent_object->corba_File_object,file_size,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;
 
@@ -507,16 +520,16 @@ CaptiveVfsParentObject *captive_vfs_parent_object;
        captive_vfs_parent_object=CAPTIVE_VFS_PARENT_OBJECT(CAPTIVE_FILE_OBJECT(captive_file_parent_object_old)->vfs);
 
        if (captive_vfs_parent_object->corba_bug_action) {
-               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,"file_truncate",NULL);
-               xmlNewProp(xml_action,"object",captive_printf_alloca("%p",captive_file_parent_object_old));
-               xmlNewProp(xml_action,"pathname_new",pathname_new);
-               xmlNewProp(xml_action,"force_replace",captive_printf_alloca("%u",(unsigned)force_replace));
+               xml_action=xmlNewTextChild(captive_vfs_parent_object->corba_bug_action,NULL,BAD_CAST "file_move",NULL);
+               xmlNewProp(xml_action,BAD_CAST "object",BAD_CAST captive_printf_alloca("%p",captive_file_parent_object_old));
+               xmlNewProp(xml_action,BAD_CAST "pathname_new",BAD_CAST pathname_new);
+               xmlNewProp(xml_action,BAD_CAST "force_replace",BAD_CAST captive_printf_alloca("%u",(unsigned)force_replace));
                }
 
        Captive_File_move(captive_file_parent_object_old->corba_File_object,pathname_new,force_replace,&captive_corba_ev);
        r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev,captive_vfs_parent_object);
        if (xml_action)
-               xmlNewProp(xml_action,"result",gnome_vfs_result_to_string(r));
+               xmlNewProp(xml_action,BAD_CAST "result",BAD_CAST gnome_vfs_result_to_string(r));
        if (r!=GNOME_VFS_OK)
                return r;