]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/gtkmathview-bonobo/src/persist-stream.c
* a few adjustments and debugging messages added
[helm.git] / helm / gtkmathview-bonobo / src / persist-stream.c
index 815606bde487a2764884bea46b79bcc4edea2f80..6367f7453f1de7035557eb90751f02c418fc32eb 100644 (file)
@@ -33,8 +33,7 @@ static void finalize(GObject *object)
 static Bonobo_Persist_ContentTypeList *
 get_content_types(BonoboPersist *persist,CORBA_Environment *ev)
 {
-       //FIXME:il tipo di dato non e` noto
-       return bonobo_persist_generate_content_types(0);
+  return bonobo_persist_generate_content_types(2, "application/mathml+xml", "text/mathml");
 }
 
 static void 
@@ -108,12 +107,13 @@ create_tmp_file(GtkMathViewPersistStream *persist)
     FILE *tmpfile;
     int fd;
     
-    persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/ggvXXXXXX", NULL);
+    persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/gmvXXXXXX", NULL);
     if((fd = mkstemp(persist->tmp_path_name)) < 0) {
         g_free(persist->tmp_path_name),
         persist->tmp_path_name = NULL;
         return NULL;
     }
+    printf("salvo nel file %s\n", persist->tmp_path_name);
     tmpfile = fdopen(fd, "w");
     if(!tmpfile) {
         close(fd);
@@ -140,6 +140,8 @@ load_implementation(PortableServer_Servant servant,
     printf("persist stream loading\n");
 #endif
     
+    printf("type = %s\n", type);
+
     if (strcmp (type, "application/mathml+xml") != 0) {
         CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                      ex_Bonobo_Persist_WrongDataType, NULL);
@@ -150,20 +152,23 @@ load_implementation(PortableServer_Servant servant,
     do {
         Bonobo_Stream_read (stream, 4096, &buffer, ev);
         
-        if (ev->_major != CORBA_NO_EXCEPTION || buffer->_length <= 0) {
-            CORBA_free (buffer);
-            goto clean;
-            }
+        if (ev->_major != CORBA_NO_EXCEPTION) {
+         printf("*** eccezione 1\n");
+         goto clean;
+       }
 
         len_read = buffer->_length;
+       printf("letti %d bytes\n", len_read);
+
         if (buffer->_buffer && len_read)
             if(fwrite(buffer->_buffer, 1, len_read, tmpfile) != len_read) {
                 CORBA_free (buffer);
+         printf("*** eccezione 2\n");
                 goto clean;
         }
         
         CORBA_free (buffer);
-    } while (1);
+    } while (len_read > 0);
 
     fclose(tmpfile);
     result = gtk_math_view_load_uri(persist->math_view,persist->tmp_path_name);