aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/ChangeLog22
-rw-r--r--composer/Evolution-Composer.idl22
-rw-r--r--composer/e-msg-composer.c60
-rw-r--r--composer/e-msg-composer.h7
-rw-r--r--composer/evolution-composer.c26
5 files changed, 112 insertions, 25 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index f279adf966..56d6a60b79 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,25 @@
+2002-02-25 Dan Winship <danw@ximian.com>
+
+ Mailer side of 14705.
+
+ * Evolution-Composer.idl (setBody): Change setBodyText to setBody
+ and take a MIME type as well.
+ (show): Add an exception.
+
+ * evolution-composer.c (impl_Composer_set_body, etc): Update for
+ IDL change. While I'm here, fix this to DTRT with both plaintext
+ and HTML bodies. (It claimed to take plain text before, but then
+ passed it to the composer as HTML.)
+ (impl_Composer_show): Raise an exception if setBody has been
+ called, since the composer window will not display the real data
+ in that case.
+
+ * e-msg-composer.c (e_msg_composer_set_body): interface for
+ impl_Composer_set_body.
+ (build_message): If e_msg_composer_set_body has been called, use
+ the body and MIME type supplied to it rather than the contents of
+ the HTML editor.
+
2002-02-14 Radek Doulik <rodo@ximian.com>
* e-msg-composer.c (delete_old_signature): don't insert paragraph
diff --git a/composer/Evolution-Composer.idl b/composer/Evolution-Composer.idl
index dcf52b57e1..543e6edd2d 100644
--- a/composer/Evolution-Composer.idl
+++ b/composer/Evolution-Composer.idl
@@ -48,11 +48,11 @@ module Evolution {
* Sets the kind of multipart message that is being
* created.
*
- * If @type is MIXED (the default), setBodyText()
+ * If @type is MIXED (the default), setBody()
* will create the body, and attachMIME() and
* attachData() will create attachments.
*
- * If @type is ALTERNATIVE, setBodyText() will create
+ * If @type is ALTERNATIVE, setBody() will create
* text/plain alternative, and each following
* attachMIME() or attachData() call will create
* another alternative.
@@ -63,13 +63,19 @@ module Evolution {
void setMultipartType (in MultipartType type);
/**
- * setBodyText:
+ * setBody:
* @body: the body
+ * @mime_type: the MIME type of @body
*
- * Sets the text in the body of the composer to
- * the given UTF-8 plain text.
+ * Sets the body of the composer to @body. If
+ * @mime_type is something other than "text/plain" or
+ * "text/html", the composer will not be editable
+ * (calling show() will raise an exception), and the
+ * composer will not attempt to assign a non-UTF8
+ * character set to the data. However, @mime_type may
+ * include parameters in that case.
**/
- void setBodyText (in string body);
+ void setBody (in string body, in string mime_type);
/**
* attachMIME:
@@ -117,7 +123,9 @@ module Evolution {
* Shows the composer and lets the user edit things
* and send the message.
**/
- void show ();
+ exception CannotShow {};
+ void show ()
+ raises (CannotShow);
/**
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e540f4579f..5a40fd0f27 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -336,19 +336,32 @@ build_message (EMsgComposer *composer)
composer->extra_hdr_values->pdata[i]);
}
- data = get_text (composer->persist_stream_interface, "text/plain");
- if (!data) {
- /* The component has probably died */
- camel_object_unref (CAMEL_OBJECT (new));
- return NULL;
+ if (composer->mime_body) {
+ plain_encoding = CAMEL_MIME_PART_ENCODING_7BIT;
+ for (i = 0; composer->mime_body[i]; i++) {
+ if ((unsigned char)composer->mime_body[i] > 127) {
+ plain_encoding = CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE;
+ break;
+ }
+ }
+ data = g_byte_array_new ();
+ g_byte_array_append (data, composer->mime_body, i);
+ type = header_content_type_decode (composer->mime_type);
+ } else {
+ data = get_text (composer->persist_stream_interface, "text/plain");
+ if (!data) {
+ /* The component has probably died */
+ camel_object_unref (CAMEL_OBJECT (new));
+ return NULL;
+ }
+
+ /* FIXME: we may want to do better than this... */
+ charset = best_charset (data, composer->charset, &plain_encoding);
+ type = header_content_type_new ("text", "plain");
+ if (charset)
+ header_content_type_set_param (type, "charset", charset);
}
- /* FIXME: we may want to do better than this... */
- charset = best_charset (data, composer->charset, &plain_encoding);
- type = header_content_type_new ("text", "plain");
- if (charset)
- header_content_type_set_param (type, "charset", charset);
-
plain = camel_data_wrapper_new ();
stream = camel_stream_mem_new_with_byte_array (data);
camel_data_wrapper_construct_from_stream (plain, stream);
@@ -2053,6 +2066,8 @@ destroy (GtkObject *object)
g_hash_table_destroy (composer->inline_images_by_url);
g_free (composer->charset);
+ g_free (composer->mime_type);
+ g_free (composer->mime_body);
CORBA_exception_init (&ev);
@@ -3206,6 +3221,29 @@ e_msg_composer_set_body_text (EMsgComposer *composer, const char *text)
/**
+ * e_msg_composer_set_body:
+ * @composer: a composer object
+ * @body: the data to initialize the composer with
+ * @mime_type: the MIME type of data
+ *
+ * Loads the given data into the composer as the message body.
+ * This function should only be used by the CORBA composer factory.
+ **/
+void
+e_msg_composer_set_body (EMsgComposer *composer, const char *body,
+ const char *mime_type)
+{
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ g_free (composer->mime_body);
+ composer->mime_body = g_strdup (body);
+ g_free (composer->mime_type);
+ composer->mime_type = g_strdup (mime_type);
+ composer->send_html = FALSE;
+}
+
+
+/**
* e_msg_composer_add_header:
* @composer: a composer object
* @name: the header name
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index cb679107b8..100760f87e 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -75,8 +75,8 @@ struct _EMsgComposer {
Bonobo_ConfigDatabase config_db;
- char *charset;
-
+ char *mime_type, *mime_body, *charset;
+
char *autosave_file;
int autosave_fd;
@@ -126,6 +126,9 @@ void e_msg_composer_set_headers (EMsgCo
const char *subject);
void e_msg_composer_set_body_text (EMsgComposer *composer,
const char *text);
+void e_msg_composer_set_body (EMsgComposer *composer,
+ const char *body,
+ const char *mime_type);
void e_msg_composer_add_header (EMsgComposer *composer,
const char *name,
const char *value);
diff --git a/composer/evolution-composer.c b/composer/evolution-composer.c
index cf99f86e8b..1630d97ce3 100644
--- a/composer/evolution-composer.c
+++ b/composer/evolution-composer.c
@@ -33,6 +33,7 @@
#include <camel/camel.h>
#include "evolution-composer.h"
#include "mail/mail-config.h"
+#include "e-util/e-html-utils.h"
#define PARENT_TYPE BONOBO_OBJECT_TYPE
static BonoboObjectClass *parent_class = NULL;
@@ -115,9 +116,10 @@ impl_Composer_set_multipart_type (PortableServer_Servant servant,
}
static void
-impl_Composer_set_body_text (PortableServer_Servant servant,
- const CORBA_char *text,
- CORBA_Environment *ev)
+impl_Composer_set_body (PortableServer_Servant servant,
+ const CORBA_char *body,
+ const CORBA_char *mime_type,
+ CORBA_Environment *ev)
{
BonoboObject *bonobo_object;
EvolutionComposer *composer;
@@ -125,7 +127,14 @@ impl_Composer_set_body_text (PortableServer_Servant servant,
bonobo_object = bonobo_object_from_servant (servant);
composer = EVOLUTION_COMPOSER (bonobo_object);
- e_msg_composer_set_body_text (composer->composer, text);
+ if (!g_strcasecmp (mime_type, "text/plain")) {
+ char *htmlbody = e_text_to_html (body, E_TEXT_TO_HTML_PRE);
+ e_msg_composer_set_body_text (composer->composer, htmlbody);
+ g_free (htmlbody);
+ } else if (!g_strcasecmp (mime_type, "text/html"))
+ e_msg_composer_set_body_text (composer->composer, body);
+ else
+ e_msg_composer_set_body (composer->composer, body, mime_type);
}
static void
@@ -200,6 +209,13 @@ impl_Composer_show (PortableServer_Servant servant,
bonobo_object = bonobo_object_from_servant (servant);
composer = EVOLUTION_COMPOSER (bonobo_object);
+ if (composer->composer->mime_body) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Composer_CannotShow,
+ NULL);
+ return;
+ }
+
gtk_widget_show (GTK_WIDGET (composer->composer));
}
@@ -224,7 +240,7 @@ evolution_composer_get_epv (void)
epv = g_new0 (POA_GNOME_Evolution_Composer__epv, 1);
epv->setHeaders = impl_Composer_set_headers;
epv->setMultipartType = impl_Composer_set_multipart_type;
- epv->setBodyText = impl_Composer_set_body_text;
+ epv->setBody = impl_Composer_set_body;
epv->attachMIME = impl_Composer_attach_MIME;
epv->attachData = impl_Composer_attach_data;
epv->show = impl_Composer_show;