diff options
author | Dan Winship <danw@src.gnome.org> | 2002-02-26 00:36:59 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2002-02-26 00:36:59 +0800 |
commit | c91f7c6b59f1a845bc98797c9d6bae5344136854 (patch) | |
tree | 7d4cd3bc10536913dd6359b3004fe19d47b02629 /composer/e-msg-composer.c | |
parent | 387acacf48126af9f050ba2e81f5aa1ec9456ff2 (diff) | |
download | gsoc2013-evolution-c91f7c6b59f1a845bc98797c9d6bae5344136854.tar.gz gsoc2013-evolution-c91f7c6b59f1a845bc98797c9d6bae5344136854.tar.zst gsoc2013-evolution-c91f7c6b59f1a845bc98797c9d6bae5344136854.zip |
[pulled up from evolution-1-0-branch]
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.
svn path=/trunk/; revision=15833
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r-- | composer/e-msg-composer.c | 60 |
1 files changed, 49 insertions, 11 deletions
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 |