From 8283c1b985ac672797f0b567bc19302f90399470 Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Fri, 1 Aug 2003 10:15:57 +0000 Subject: [PATCH] * a few adjustments and debugging messages added * works as a component in mozilla --- .../src/GNOME_GtkMathView.server.in.in | 3 +- helm/gtkmathview-bonobo/src/Makefile.am | 2 +- helm/gtkmathview-bonobo/src/persist-file.c | 44 ++++++++++--------- helm/gtkmathview-bonobo/src/persist-stream.c | 21 +++++---- helm/gtkmathview-bonobo/test/main.c | 15 ++++--- 5 files changed, 50 insertions(+), 35 deletions(-) diff --git a/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in b/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in index 28254bc09..5d4919470 100644 --- a/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in +++ b/helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in @@ -15,8 +15,8 @@ - + @@ -26,6 +26,7 @@ + diff --git a/helm/gtkmathview-bonobo/src/Makefile.am b/helm/gtkmathview-bonobo/src/Makefile.am index 0a887c22e..3abccce7c 100644 --- a/helm/gtkmathview-bonobo/src/Makefile.am +++ b/helm/gtkmathview-bonobo/src/Makefile.am @@ -12,7 +12,7 @@ libgtkmathview_bonobo_la_LDFLAGS = -version-info @GTKMATHVIEW_CONTROL_VERSION_IN libgtkmathview_bonobo_la_SOURCES = \ control-factory.c \ - persist-file.c \ + persist-file.c \ persist-stream.c pkginclude_HEADERS = \ diff --git a/helm/gtkmathview-bonobo/src/persist-file.c b/helm/gtkmathview-bonobo/src/persist-file.c index 36b4536a4..5380ec42c 100644 --- a/helm/gtkmathview-bonobo/src/persist-file.c +++ b/helm/gtkmathview-bonobo/src/persist-file.c @@ -27,8 +27,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(3, "application/mathml+xml", "text/mathml", "text/plain"); } @@ -83,32 +82,37 @@ gtk_math_view_persist_file_get_type(void) BonoboObject * gtk_math_view_persist_file_new(GtkMathView *math_view) { - BonoboObject *file; + BonoboObject *file; - printf("persist file new\n"); - file = g_object_new(gtk_math_view_persist_file_get_type(),NULL); - bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID); + printf("persist file new\n"); + file = g_object_new(gtk_math_view_persist_file_get_type(),NULL); + bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID); - g_object_ref(math_view); - GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view; + g_object_ref(math_view); + GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view; - return file; + printf("OK\n"); + + return file; } static void load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev) { - gboolean result; - GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant)); - //fd = open(path, O_RDONLY); - - result = gtk_math_view_load_uri(file->math_view,path); - if(!result) - { - CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); - } - bonobo_object_unref(BONOBO_OBJECT(file)); - return ; + gboolean result; + GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant)); + //fd = open(path, O_RDONLY); + + printf("passing from here LOAD\n"); + + result = gtk_math_view_load_uri(file->math_view,path); + if(!result) + { + printf("exception here!\n"); + CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); + } + bonobo_object_unref(BONOBO_OBJECT(file)); + return ; } static void diff --git a/helm/gtkmathview-bonobo/src/persist-stream.c b/helm/gtkmathview-bonobo/src/persist-stream.c index 815606bde..6367f7453 100644 --- a/helm/gtkmathview-bonobo/src/persist-stream.c +++ b/helm/gtkmathview-bonobo/src/persist-stream.c @@ -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); diff --git a/helm/gtkmathview-bonobo/test/main.c b/helm/gtkmathview-bonobo/test/main.c index fc9715e6d..dccb6e63a 100644 --- a/helm/gtkmathview-bonobo/test/main.c +++ b/helm/gtkmathview-bonobo/test/main.c @@ -46,14 +46,19 @@ load_through_persist_stream(const gchar *filename, CORBA_Environment ev; CORBA_exception_init (&ev); +#if 0 + stream = bonobo_stream_open ("fs", filename, + Bonobo_Storage_READ, 0); +#endif + /*if (stream == NULL) { g_warning ("Couldn't load `%s'\n", filename); } else*/ { Bonobo_Stream corba_stream; - //corba_stream = bonobo_object_corba_objref (stream); - //Bonobo_Stream_truncate (corba_stream, 0, &ev); - Bonobo_PersistStream_load (pstream, corba_stream,"",&ev); + corba_stream = bonobo_object_corba_objref (stream); + Bonobo_Stream_truncate (corba_stream, 0, &ev); + Bonobo_PersistStream_load (pstream, corba_stream, "application/mathml+xml", &ev); } Bonobo_Unknown_unref (pstream, &ev); CORBA_Object_release (pstream, &ev); @@ -90,8 +95,8 @@ file_selection_ok_cb (GtkWidget *widget, (GTK_FILE_SELECTION (file_selection_info.widget)); switch (file_selection_info.Operations) { case LOAD_STREAM: - load_through_persist_stream (fname, interface); - break; + load_through_persist_stream (fname, interface); + break; case LOAD_FILE: load_through_persist_file (fname, interface); break; -- 2.39.2