From a64e5726cd37d35a02a23db76336df0aa579c4cd Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 28 Jun 2001 22:01:10 +0000 Subject: implemented plain saving 2001-06-29 Radek Doulik * mail-account-gui.c (menu_file_save_cb): implemented plain saving 2001-06-28 Radek Doulik * mail-account-gui.c (load_signature): implemented plain load (load_signature): use e_msg_composer_get_signature_html svn path=/trunk/; revision=10580 --- mail/ChangeLog | 9 ++++ mail/mail-account-gui.c | 107 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 84 insertions(+), 32 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 49c98fa77e..e1344fa1b9 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2001-06-29 Radek Doulik + + * mail-account-gui.c (menu_file_save_cb): implemented plain saving + +2001-06-28 Radek Doulik + + * mail-account-gui.c (load_signature): implemented plain load + (load_signature): use e_msg_composer_get_signature_html + 2001-06-28 Peter Williams * mail-ops.c (mail_send_message): Revert fejj's Bcc header removal; diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 6121affba5..75318d346a 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -29,6 +29,7 @@ #include #include +#include #include #include "shell/evolution-shell-client.h" @@ -811,13 +812,56 @@ destroy_editor (ESignatureEditor *editor) g_free (editor); } +static void +menu_file_save_cb (BonoboUIComponent *uic, + void *data, + const char *path) +{ + ESignatureEditor *editor; + Bonobo_PersistFile pfile_iface; + CORBA_Environment ev; + + editor = E_SIGNATURE_EDITOR (data); + if (editor->html) { + CORBA_exception_init (&ev); + + pfile_iface = bonobo_object_client_query_interface (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)), + "IDL:Bonobo/PersistFile:1.0", NULL); + Bonobo_PersistFile_save (pfile_iface, editor->filename, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("Cannot save."); + CORBA_exception_free (&ev); + } else { + BonoboStream *stream; + CORBA_Environment ev; + Bonobo_PersistStream pstream_iface; + + CORBA_exception_init (&ev); + + stream = bonobo_stream_open (BONOBO_IO_DRIVER_FS, editor->filename, + Bonobo_Storage_WRITE | Bonobo_Storage_CREATE, 0); + pstream_iface = bonobo_object_client_query_interface + (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)), + "IDL:Bonobo/PersistStream:1.0", NULL); + Bonobo_PersistStream_save (pstream_iface, (Bonobo_Stream) bonobo_object_corba_objref (BONOBO_OBJECT (stream)), + "text/plain", &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Exception while saving signature (%s)", + bonobo_exception_get_text (&ev)); + return; + } + + CORBA_exception_free (&ev); + bonobo_object_unref (BONOBO_OBJECT (stream)); + } +} + static void exit_dialog_cb (int reply, ESignatureEditor *editor) { switch (reply) { case REPLY_YES: - /* this has to be done async */ - // save_signature (editor); + menu_file_save_cb (NULL, editor, NULL); destroy_editor (editor); break; case REPLY_NO: @@ -855,31 +899,6 @@ do_exit (ESignatureEditor *editor) destroy_editor (editor); } -static void -menu_file_save_cb (BonoboUIComponent *uic, - void *data, - const char *path) -{ - ESignatureEditor *editor; - Bonobo_PersistFile pfile_iface; - CORBA_Environment ev; - - editor = E_SIGNATURE_EDITOR (data); - if (editor->html) { - CORBA_exception_init (&ev); - - pfile_iface = bonobo_object_client_query_interface (bonobo_widget_get_server (BONOBO_WIDGET (editor->control)), - "IDL:Bonobo/PersistFile:1.0", NULL); - Bonobo_PersistFile_save (pfile_iface, editor->filename, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("Cannot save."); - CORBA_exception_free (&ev); - } else { - /* TODO: save plain version */ - g_warning ("TODO: save plain version"); - } -} - static void menu_file_close_cb (BonoboUIComponent *uic, gpointer data, const gchar *path) { @@ -911,14 +930,38 @@ load_signature (ESignatureEditor *editor) Bonobo_PersistFile_load (pfile_iface, editor->filename, &ev); CORBA_exception_free (&ev); } else { - gchar *data; + Bonobo_PersistStream pstream_iface; + BonoboStream *stream; + gchar *data, *html; - data = e_msg_composer_get_sig_file_content (editor->filename, editor->html); + data = e_msg_composer_get_sig_file_content (editor->filename, FALSE); + html = g_strdup_printf ("
\n%s", data);
+		g_free (data);
 
-		/* TODO: send data to control */
-		g_warning ("TODO: send data to control");
+		pstream_iface = bonobo_object_client_query_interface
+			(bonobo_widget_get_server (BONOBO_WIDGET (editor->control)),
+			 "IDL:Bonobo/PersistStream:1.0", NULL);
+		CORBA_exception_init (&ev);
+		stream = bonobo_stream_mem_create (html, strlen (html), TRUE, FALSE);
 
-		g_free (data);
+		if (stream == NULL) {
+			g_warning ("Couldn't create memory stream\n");
+		} else {
+			BonoboObject *stream_object;
+			Bonobo_Stream corba_stream;
+
+			stream_object = BONOBO_OBJECT (stream);
+			corba_stream = bonobo_object_corba_objref (stream_object);
+			Bonobo_PersistStream_load (pstream_iface, corba_stream,
+						   "text/html", &ev);
+		}
+
+		Bonobo_Unknown_unref (pstream_iface, &ev);
+		CORBA_Object_release (pstream_iface, &ev);
+		CORBA_exception_free (&ev);
+		bonobo_object_unref (BONOBO_OBJECT (stream));
+
+		g_free (html);
 	}
 }
 
-- 
cgit v1.2.3