implemented plain saving

2001-06-29  Radek Doulik  <rodo@ximian.com>

	* mail-account-gui.c (menu_file_save_cb): implemented plain saving

2001-06-28  Radek Doulik  <rodo@ximian.com>

	* mail-account-gui.c (load_signature): implemented plain load
	(load_signature): use e_msg_composer_get_signature_html

svn path=/trunk/; revision=10580
This commit is contained in:
Radek Doulik
2001-06-28 22:01:10 +00:00
committed by Radek Doulik
parent 47c1ce6660
commit a64e5726cd
2 changed files with 85 additions and 33 deletions

View File

@ -1,3 +1,12 @@
2001-06-29 Radek Doulik <rodo@ximian.com>
* mail-account-gui.c (menu_file_save_cb): implemented plain saving
2001-06-28 Radek Doulik <rodo@ximian.com>
* mail-account-gui.c (load_signature): implemented plain load
(load_signature): use e_msg_composer_get_signature_html
2001-06-28 Peter Williams <peterw@ximian.com>
* mail-ops.c (mail_send_message): Revert fejj's Bcc header removal;

View File

@ -29,6 +29,7 @@
#include <string.h>
#include <bonobo.h>
#include <bonobo/bonobo-stream-memory.h>
#include <gal/widgets/e-unicode.h>
#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;
data = e_msg_composer_get_sig_file_content (editor->filename, editor->html);
/* TODO: send data to control */
g_warning ("TODO: send data to control");
Bonobo_PersistStream pstream_iface;
BonoboStream *stream;
gchar *data, *html;
data = e_msg_composer_get_sig_file_content (editor->filename, FALSE);
html = g_strdup_printf ("<PRE>\n%s", data);
g_free (data);
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);
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);
}
}