From 80fffd093013bd250c98e1a05591de1a0b029f5a Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Mon, 29 Oct 2001 23:30:25 +0000 Subject: add GList to hold the current images. 2001-10-29 Larry Ewing * e-msg-composer.h: add GList to hold the current images. * listener.c (resolve_image_url): keep track of the images that the editor is currently uses in current_images as well as storing the images in the hash. * e-msg-composer.c (clear_current_images): clear the list of images actually in the message. (add_inlined_images): use the current image list rather than the hash tables. (build_message): clear the current image list when appropriate. (init): initialize current_images. svn path=/trunk/; revision=14379 --- composer/ChangeLog | 15 +++++++++++++++ composer/e-msg-composer.c | 33 +++++++++++++++++++++++---------- composer/e-msg-composer.h | 1 + composer/listener.c | 5 +++++ 4 files changed, 44 insertions(+), 10 deletions(-) (limited to 'composer') diff --git a/composer/ChangeLog b/composer/ChangeLog index 52599f878c..8f5e7af594 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,18 @@ +2001-10-29 Larry Ewing + + * e-msg-composer.h: add GList to hold the current images. + + * listener.c (resolve_image_url): keep track of the images that + the editor is currently uses in current_images as well as storing + the images in the hash. + + * e-msg-composer.c (clear_current_images): clear the list of + images actually in the message. + (add_inlined_images): use the current image list rather than the + hash tables. + (build_message): clear the current image list when appropriate. + (init): initialize current_images. + 2001-10-24 Jeffrey Stedfast * e-msg-composer.c (add_attachments_from_multipart): New function diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 6ec023bb43..50c4e608c8 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -245,6 +245,13 @@ clear_inline_images (gpointer key, gpointer value, gpointer user_data) return TRUE; } +static void +clear_current_images (EMsgComposer *composer) +{ + g_list_free (composer->current_images); + composer->current_images = NULL; +} + static gboolean clear_url (gpointer key, gpointer value, gpointer user_data) { @@ -260,16 +267,17 @@ e_msg_composer_clear_inlined_table (EMsgComposer *composer) g_hash_table_foreach_remove (composer->inline_images_by_url, clear_url, NULL); } -static void -add_inlined_image (gpointer key, gpointer part, gpointer multipart) -{ - camel_multipart_add_part (multipart, part); -} - static void add_inlined_images (EMsgComposer *composer, CamelMultipart *multipart) { - g_hash_table_foreach (composer->inline_images, add_inlined_image, multipart); + GList *d = composer->current_images; + + while (d) { + CamelMimePart *part = d->data; + + camel_multipart_add_part (multipart, part); + d = d->next; + } } /* This functions builds a CamelMimeMessage for the message that the user has @@ -325,7 +333,9 @@ build_message (EMsgComposer *composer) header_content_type_unref (type); if (composer->send_html) { - data = get_text (composer->persist_stream_interface, "text/html"); + clear_current_images (composer); + + data = get_text (composer->persist_stream_interface, "text/html"); if (!data) { /* The component has probably died */ camel_object_unref (CAMEL_OBJECT (new)); @@ -361,7 +371,7 @@ build_message (EMsgComposer *composer) * multipart/related containing the * multipart/alternative and the images. */ - if (g_hash_table_size (composer->inline_images)) { + if (composer->current_images) { CamelMultipart *html_with_images; html_with_images = camel_multipart_new (); @@ -377,6 +387,8 @@ build_message (EMsgComposer *composer) camel_object_unref (CAMEL_OBJECT (part)); add_inlined_images (composer, html_with_images); + clear_current_images (composer); + current = CAMEL_DATA_WRAPPER (html_with_images); } else current = CAMEL_DATA_WRAPPER (body); @@ -2136,7 +2148,8 @@ init (EMsgComposer *composer) composer->editor_engine = CORBA_OBJECT_NIL; composer->inline_images = g_hash_table_new (g_str_hash, g_str_equal); composer->inline_images_by_url = g_hash_table_new (g_str_hash, g_str_equal); - + composer->current_images = NULL; + composer->attachment_bar_visible = FALSE; composer->send_html = FALSE; composer->pgp_sign = FALSE; diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 7467e9457e..941834d120 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -71,6 +71,7 @@ struct _EMsgComposer { GNOME_GtkHTML_Editor_Engine editor_engine; BonoboObject *editor_listener; GHashTable *inline_images, *inline_images_by_url; + GList *current_images; Bonobo_ConfigDatabase config_db; diff --git a/composer/listener.c b/composer/listener.c index 2cd3dbb63d..d85f27aa8a 100644 --- a/composer/listener.c +++ b/composer/listener.c @@ -60,9 +60,14 @@ resolve_image_url (EditorListener *l, gchar *url) part = e_msg_composer_add_inline_image_from_file (l->composer, url + 5); } + if (!part && !strncmp (url, "cid:", 4)) { + part = g_hash_table_lookup (l->composer->inline_images, url); + } if (!part) return NULL; + l->composer->current_images = g_list_prepend (l->composer->current_images, part); + cid = camel_mime_part_get_content_id (part); if (!cid) return NULL; -- cgit v1.2.3