From ae15900672a423ac36ee1830b159a1aa1b5063ed Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 31 May 2000 14:29:24 +0000 Subject: Redo this back to the old way: a single GtkHTML with various things inline * mail-format.c: Redo this back to the old way: a single GtkHTML with various things inline in it. (Gets rid of flicker, simplifies some scrolling, selecting, and printing issues.) (handle_text_enriched, handle_text_html): Use ", xed); + g_free (xed); +} + /* We're maintaining a hashtable of mimetypes -> functions; * Those functions have the following signature... */ typedef void (*mime_handler_fn) (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box); + struct mail_format_data *mfd); static GHashTable *mime_function_table, *mime_fallback_table; @@ -298,8 +310,7 @@ lookup_handler (const char *mime_type, gboolean *generic) } static void -call_handler_function (CamelMimePart *part, CamelMimeMessage *root, - GtkBox *box) +call_handler_function (CamelMimePart *part, struct mail_format_data *mfd) { CamelDataWrapper *wrapper; char *mime_type; @@ -312,9 +323,9 @@ call_handler_function (CamelMimePart *part, CamelMimeMessage *root, handler_function = lookup_handler (mime_type, &generic); if (handler_function) - (*handler_function) (part, mime_type, root, box); + (*handler_function) (part, mime_type, mfd); else - handle_unknown_type (part, mime_type, root, box); + handle_unknown_type (part, mime_type, mfd); g_free (mime_type); } @@ -385,53 +396,39 @@ write_recipients_to_stream (const gchar *recipient_type, static void -write_headers (CamelMimeMessage *mime_message, GtkBox *box) +write_headers (struct mail_format_data *mfd) { const CamelInternetAddress *recipients; - GtkHTML *html; - GtkHTMLStream *stream; - mail_html_new (&html, &stream, mime_message, FALSE); - mail_html_write (html, stream, "%s%s", HTML_HEADER, - "\n"); - - mail_html_write (html, stream, ""); - - /* A few fields will probably be available from the mime_message; - * for each one that's available, write it to the output stream - * with a helper function, 'write_field_to_stream'. - */ + mail_html_write (mfd->html, mfd->stream, + "
" + "
\n"); write_field_to_stream ("From:", - camel_mime_message_get_from (mime_message), - TRUE, html, stream); + camel_mime_message_get_from (mfd->root), + TRUE, mfd->html, mfd->stream); - if (camel_mime_message_get_reply_to (mime_message)) { + if (camel_mime_message_get_reply_to (mfd->root)) { write_field_to_stream ("Reply-To:", - camel_mime_message_get_reply_to (mime_message), - FALSE, html, stream); + camel_mime_message_get_reply_to (mfd->root), + FALSE, mfd->html, mfd->stream); } write_recipients_to_stream ("To:", - camel_mime_message_get_recipients (mime_message, CAMEL_RECIPIENT_TYPE_TO), - FALSE, TRUE, html, stream); + camel_mime_message_get_recipients (mfd->root, CAMEL_RECIPIENT_TYPE_TO), + FALSE, TRUE, mfd->html, mfd->stream); - recipients = camel_mime_message_get_recipients (mime_message, CAMEL_RECIPIENT_TYPE_CC); + recipients = camel_mime_message_get_recipients (mfd->root, CAMEL_RECIPIENT_TYPE_CC); write_recipients_to_stream ("Cc:", recipients, TRUE, TRUE, - html, stream); + mfd->html, mfd->stream); write_field_to_stream ("Subject:", - camel_mime_message_get_subject (mime_message), - TRUE, html, stream); - - mail_html_write (html, stream, "
"); + camel_mime_message_get_subject (mfd->root), + TRUE, mfd->html, mfd->stream); - mail_html_end (html, stream, TRUE, box); + mail_html_write (mfd->html, mfd->stream, "
"); } -#define MIME_TYPE_WHOLE(a) (gmime_content_field_get_mime_type ( \ - camel_mime_part_get_content_type (CAMEL_MIME_PART (a)))) -#define MIME_TYPE_MAIN(a) ((camel_mime_part_get_content_type (CAMEL_MIME_PART (a)))->type) -#define MIME_TYPE_SUB(a) ((camel_mime_part_get_content_type (CAMEL_MIME_PART (a)))->subtype) static char * @@ -459,54 +456,47 @@ get_data_wrapper_text (CamelDataWrapper *data) static void handle_text_plain (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { - GtkHTML *html; - GtkHTMLStream *stream; CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); char *text, *htmltext; GMimeContentField *type; const char *format; - mail_html_new (&html, &stream, root, TRUE); - mail_html_write (html, stream, "\n\n
\n");
-
 	/* Check for RFC 2646 flowed text. */
 	type = camel_mime_part_get_content_type (part);
 	format = gmime_content_field_get_parameter (type, "format");
 	if (format && !g_strcasecmp (format, "flowed")) {
-		handle_text_plain_flowed (part, mime_type, root, box);
+		handle_text_plain_flowed (part, mime_type, mfd);
 		return;
 	}
 
+	mail_html_write (mfd->html, mfd->stream,
+			 "\n\n
\n");
+
 	text = get_data_wrapper_text (wrapper);
 	if (text && *text) {
 		htmltext = e_text_to_html (text, E_TEXT_TO_HTML_CONVERT_URLS);
-		mail_html_write (html, stream, "%s", htmltext);
+		mail_html_write (mfd->html, mfd->stream, "%s", htmltext);
 		g_free (htmltext);
-	} else
-		mail_html_write (html, stream, "(empty)");
+	}
 	g_free (text);
 
-	mail_html_write (html, stream, "
\n"); - mail_html_end (html, stream, TRUE, box); + mail_html_write (mfd->html, mfd->stream, "
\n"); } static void handle_text_plain_flowed (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { - GtkHTML *html; - GtkHTMLStream *stream; CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); char *buf, *text, *line, *eol, *p; int prevquoting = 0, quoting, len; gboolean br_pending = FALSE; - mail_html_new (&html, &stream, root, TRUE); - mail_html_write (html, stream, + mail_html_write (mfd->html, mfd->stream, "\n\n\n"); buf = get_data_wrapper_text (wrapper); @@ -520,21 +510,22 @@ handle_text_plain_flowed (CamelMimePart *part, const char *mime_type, for (p = line; *p == '>'; p++) quoting++; if (quoting != prevquoting) { - mail_html_write (html, stream, "%s\n", + mail_html_write (mfd->html, mfd->stream, "%s\n", prevquoting == 0 ? "\n" : ""); while (quoting > prevquoting) { - mail_html_write (html, stream, "
"); + mail_html_write (mfd->html, mfd->stream, + "
"); prevquoting++; } while (quoting < prevquoting) { - mail_html_write (html, stream, + mail_html_write (mfd->html, mfd->stream, "
"); prevquoting--; } - mail_html_write (html, stream, "%s\n", + mail_html_write (mfd->html, mfd->stream, "%s\n", prevquoting == 0 ? "
\n" : ""); } else if (br_pending) { - mail_html_write (html, stream, "
\n"); + mail_html_write (mfd->html, mfd->stream, "
\n"); br_pending = FALSE; } @@ -545,7 +536,7 @@ handle_text_plain_flowed (CamelMimePart *part, const char *mime_type, text = e_text_to_html (p, E_TEXT_TO_HTML_CONVERT_SPACES | E_TEXT_TO_HTML_CONVERT_URLS); if (text && *text) - mail_html_write (html, stream, "%s", text); + mail_html_write (mfd->html, mfd->stream, "%s", text); g_free (text); len = strlen (p); @@ -557,20 +548,18 @@ handle_text_plain_flowed (CamelMimePart *part, const char *mime_type, } g_free (buf); - mail_html_write (html, stream, "
\n"); - mail_html_end (html, stream, TRUE, box); + mail_html_write (mfd->html, mfd->stream, "\n"); } /* text/enriched (RFC 1896) or text/richtext (included in RFC 1341) */ static void handle_text_enriched (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { static GHashTable *translations = NULL; - GtkHTML *html; - GtkHTMLStream *stream; CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + GString *string; CamelStream *memstream; GByteArray *ba; char *p; @@ -610,13 +599,14 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, g_hash_table_insert (translations, "np", "
"); } - mail_html_new (&html, &stream, root, TRUE); if (!g_strcasecmp (mime_type, "text/richtext")) { enriched = FALSE; - mail_html_write (html, stream, "\n\n"); + mail_html_write (mfd->html, mfd->stream, + "\n\n"); } else { enriched = TRUE; - mail_html_write (html, stream, "\n\n"); + mail_html_write (mfd->html, mfd->stream, + "\n\n"); } ba = g_byte_array_new (); @@ -625,11 +615,12 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, g_byte_array_append (ba, "", 1); p = ba->data; + string = g_string_sized_new (2 * strlen (p)); while (p) { len = strcspn (p, " <>&\n"); if (len) - gtk_html_write (html, stream, p, len); + g_string_sprintfa (string, "%.*s", len, p); p += len; if (!*p) @@ -638,44 +629,44 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, switch (*p++) { case ' ': while (*p == ' ') { - mail_html_write (html, stream, " "); + g_string_append (string, " "); p++; } - mail_html_write (html, stream, " "); + g_string_append (string, " "); break; case '\n': - mail_html_write (html, stream, " "); + g_string_append (string, " "); if (enriched && nofill <= 0) { while (*p == '\n') { - mail_html_write (html, stream, "
"); + g_string_append (string, "
"); p++; } } break; case '>': - mail_html_write (html, stream, ">"); + g_string_append (string, ">"); break; case '&': - mail_html_write (html, stream, "&"); + g_string_append (string, "&"); break; case '<': if (enriched) { if (*p == '<') { - mail_html_write (html, stream, "<"); + g_string_append (string, "<"); p++; break; } } else { if (strncmp (p, "lt>", 3) == 0) { - mail_html_write (html, stream, "<"); + g_string_append (string, "<"); p += 3; break; } else if (strncmp (p, "nl>", 3) == 0) { - mail_html_write (html, stream, "
"); + g_string_append (string, "
"); p += 3; break; } @@ -683,10 +674,10 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, if (strncmp (p, "nofill>", 7) == 0) { nofill++; - mail_html_write (html, stream, "
");
+				g_string_append (string, "
");
 			} else if (strncmp (p, "/nofill>", 8) == 0) {
 				nofill--;
-				mail_html_write (html, stream, "
"); + g_string_append (string, "
"); } else { char *copy, *match; @@ -695,10 +686,8 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, match = g_hash_table_lookup (translations, copy); g_free (copy); - if (match) { - mail_html_write (html, stream, "%s", - match); - } + if (match) + g_string_append (string, match); } p = strchr (p, '>'); @@ -706,48 +695,40 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, p++; } } + gtk_object_unref (GTK_OBJECT (memstream)); - mail_html_end (html, stream, TRUE, box); + write_iframe_string (part, mfd, string->str); + g_string_free (string, FALSE); } static void handle_text_html (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { - GtkHTML *html; - GtkHTMLStream *stream; CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); char *text; - mail_html_new (&html, &stream, root, FALSE); - mail_html_write (html, stream, "\n\n"); + mail_html_write (mfd->html, mfd->stream, "\n\n"); text = get_data_wrapper_text (wrapper); - mail_html_write (html, stream, "%s", text); - g_free (text); - - mail_html_end (html, stream, FALSE, box); + write_iframe_string (part, mfd, text); } static void handle_image (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { - GtkHTML *html; - GtkHTMLStream *stream; char *cid; - cid = get_cid (part, root); - mail_html_new (&html, &stream, root, TRUE); - mail_html_write (html, stream, "", cid); - mail_html_end (html, stream, TRUE, box); + cid = get_cid (part, mfd->root); + mail_html_write (mfd->html, mfd->stream, "", cid); g_free (cid); } static void handle_multipart_mixed (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -759,16 +740,19 @@ handle_multipart_mixed (CamelMimePart *part, const char *mime_type, nparts = camel_multipart_get_number (mp); for (i = 0; i < nparts; i++) { + if (i != 0) + mail_html_write (mfd->html, mfd->stream, "
\n"); + part = camel_multipart_get_part (mp, i); - call_handler_function (part, root, box); + call_handler_function (part, mfd); } } /* As seen in RFC 2387! */ static void handle_multipart_related (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -807,7 +791,7 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, if (!display_part) { /* Oops. Hrmph. */ - handle_multipart_mixed (part, mime_type, root, box); + handle_multipart_mixed (part, mime_type, mfd); } } else { /* No start parameter, so it defaults to the first part. */ @@ -816,18 +800,15 @@ handle_multipart_related (CamelMimePart *part, const char *mime_type, /* Record the Content-IDs of any non-displayed parts. */ for (i = 0; i < nparts; i++) { - char *cid; - body_part = camel_multipart_get_part (mp, i); if (body_part == display_part) continue; - cid = get_cid (body_part, root); - g_free (cid); + g_free (get_cid (body_part, mfd->root)); } /* Now, display the displayed part. */ - call_handler_function (display_part, root, box); + call_handler_function (display_part, mfd); } /* RFC 2046 says "display the last part that you are able to display". */ @@ -856,7 +837,7 @@ find_preferred_alternative (CamelMultipart *multipart) static void handle_multipart_alternative (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -868,15 +849,15 @@ handle_multipart_alternative (CamelMimePart *part, const char *mime_type, mime_part = find_preferred_alternative (multipart); if (mime_part) - call_handler_function (mime_part, root, box); + call_handler_function (mime_part, mfd); else - handle_unknown_type (part, mime_type, root, box); + handle_unknown_type (part, mime_type, mfd); } /* RFC 1740 */ static void handle_multipart_appledouble (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -890,43 +871,43 @@ handle_multipart_appledouble (CamelMimePart *part, const char *mime_type, * likely it's application/octet-stream though. */ part = camel_multipart_get_part (multipart, 1); - call_handler_function (part, root, box); + call_handler_function (part, mfd); } static void -handle_mystery (CamelMimePart *part, CamelMimeMessage *root, GtkBox *box, +handle_mystery (CamelMimePart *part, struct mail_format_data *mfd, const char *url, const char *icon_name, const char *id, const char *action) { - GtkHTML *html; - GtkHTMLStream *stream; const char *info; char *htmlinfo; GMimeContentField *content_type; - mail_html_new (&html, &stream, root, TRUE); - mail_html_write (html, stream, "
"); + mail_html_write (mfd->html, mfd->stream, "
"); /* Draw the icon, surrounded by an if we have a URL, * or a plain inactive border if not. */ + if (url) { + mail_html_write (mfd->html, mfd->stream, + "", url); + } else { + mail_html_write (mfd->html, mfd->stream, + "
"); + } + mail_html_write (mfd->html, mfd->stream, + "", icon_name); if (url) - mail_html_write (html, stream, "", url); - else - mail_html_write (html, stream, "
"); - mail_html_write (html, stream, "", - icon_name); - if (url) - mail_html_write (html, stream, ""); + mail_html_write (mfd->html, mfd->stream, ""); else - mail_html_write (html, stream, "
"); - mail_html_write (html, stream, "
%s
", id); + mail_html_write (mfd->html, mfd->stream, "
"); + mail_html_write (mfd->html, mfd->stream, "
%s
", id); /* Write a description, if we have one. */ info = camel_mime_part_get_description (part); if (info) { htmlinfo = e_text_to_html (info, E_TEXT_TO_HTML_CONVERT_URLS); - mail_html_write (html, stream, "Description: %s
", + mail_html_write (mfd->html, mfd->stream, "Description: %s
", htmlinfo); g_free (htmlinfo); } @@ -938,26 +919,25 @@ handle_mystery (CamelMimePart *part, CamelMimeMessage *root, GtkBox *box, info = camel_mime_part_get_filename (part); if (info) { htmlinfo = e_text_to_html (info, 0); - mail_html_write (html, stream, "Name: %s
", + mail_html_write (mfd->html, mfd->stream, "Name: %s
", htmlinfo); g_free (htmlinfo); } /* Describe the click action, if any. */ if (action) { - mail_html_write (html, stream, + mail_html_write (mfd->html, mfd->stream, "
Click on the icon to %s.", action); } - mail_html_write (html, stream, "
"); - mail_html_end (html, stream, TRUE, box); + mail_html_write (mfd->html, mfd->stream, "
"); } static void handle_audio (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { - char *id, *cid; + char *id, *cid, *cidstr; const char *desc; desc = gnome_mime_get_value (mime_type, "description"); @@ -967,38 +947,34 @@ handle_audio (CamelMimePart *part, const char *mime_type, id = g_strdup_printf ("Audio data in \"%s\" format.", mime_type); } - cid = g_strdup_printf ("cid:%s", get_cid (part, root)); - handle_mystery (part, root, box, cid, "gnome-audio2.png", - id, "play it"); + cid = get_cid (part, mfd->root); + cidstr = g_strdup_printf ("cid:%s", cid); g_free (cid); + handle_mystery (part, mfd, cid, "gnome-audio2.png", + id, "play it"); + g_free (cidstr); g_free (id); } static void handle_message_rfc822 (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { CamelDataWrapper *wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - GtkWidget *subbox, *frame; g_return_if_fail (CAMEL_IS_MIME_MESSAGE (wrapper)); - subbox = gtk_vbox_new (FALSE, 2); + mail_html_write (mfd->html, mfd->stream, "
" + "
"); mail_format_mime_message (CAMEL_MIME_MESSAGE (wrapper), - GTK_BOX (subbox)); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_container_set_border_width (GTK_CONTAINER (frame), 8); - gtk_box_pack_start (box, frame, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), subbox); - gtk_widget_show_all (frame); + mfd->html, mfd->stream, mfd->root); + mail_html_write (mfd->html, mfd->stream, "
"); } static void handle_message_external_body (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { GMimeContentField *type; const char *access_type; @@ -1097,7 +1073,7 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type, desc = g_strdup ("Malformed external-body part."); } - handle_mystery (part, root, box, url, "gnome-globe.png", desc, + handle_mystery (part, mfd, url, "gnome-globe.png", desc, url ? "open it in a browser" : NULL); g_free (desc); @@ -1106,26 +1082,28 @@ handle_message_external_body (CamelMimePart *part, const char *mime_type, static void handle_undisplayable (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { const char *desc; - char *id, *cid; + char *id, *cid, *cidstr; desc = gnome_mime_get_value (mime_type, "description"); if (desc) id = g_strdup (desc); else id = g_strdup_printf ("Data of type \"%s\".", mime_type); - cid = g_strdup_printf ("cid:%s", get_cid (part, root)); - handle_mystery (part, root, box, cid, "gnome-question.png", id, - "save it to disk"); + cid = get_cid (part, mfd->root); + cidstr = g_strdup_printf ("cid:%s", cid); g_free (cid); + handle_mystery (part, mfd, cid, "gnome-question.png", id, + "save it to disk"); + g_free (cidstr); g_free (id); } static void handle_unknown_type (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { char *type; @@ -1138,7 +1116,7 @@ handle_unknown_type (CamelMimePart *part, const char *mime_type, handler_function = lookup_handler (type, &generic); if (handler_function && handler_function != handle_unknown_type) { - (*handler_function) (part, type, root, box); + (*handler_function) (part, type, mfd); g_free (type); return; } @@ -1146,118 +1124,31 @@ handle_unknown_type (CamelMimePart *part, const char *mime_type, type = g_strdup (mime_type); /* OK. Give up. */ - handle_undisplayable (part, type, root, box); + handle_undisplayable (part, type, mfd); g_free (type); } -static void -embeddable_destroy_cb (GtkObject *obj, gpointer user_data) -{ - BonoboWidget *be; /* bonobo embeddable */ - BonoboViewFrame *vf; /* the embeddable view frame */ - BonoboObjectClient* server; - CORBA_Environment ev; - - be = BONOBO_WIDGET (obj); - server = bonobo_widget_get_server (be); - - vf = bonobo_widget_get_view_frame (be); - bonobo_control_frame_control_deactivate ( - BONOBO_CONTROL_FRAME (vf)); - /* w = bonobo_control_frame_get_widget (BONOBO_CONTROL_FRAME (vf)); */ - - /* gtk_widget_destroy (w); */ - - CORBA_exception_init (&ev); - Bonobo_Unknown_unref ( - bonobo_object_corba_objref (BONOBO_OBJECT(server)), &ev); - CORBA_Object_release ( - bonobo_object_corba_objref (BONOBO_OBJECT(server)), &ev); - - CORBA_exception_free (&ev); - bonobo_object_unref (BONOBO_OBJECT (vf)); -} - static void handle_via_bonobo (CamelMimePart *part, const char *mime_type, - CamelMimeMessage *root, GtkBox *box) + struct mail_format_data *mfd) { - CamelDataWrapper *wrapper = - camel_medium_get_content_object (CAMEL_MEDIUM (part)); - const char *goad_id; - GtkWidget *embedded; - BonoboObjectClient *server; - Bonobo_PersistStream persist; - CORBA_Environment ev; - GByteArray *ba; - CamelStream *cstream; - BonoboStream *bstream; - - goad_id = gnome_mime_get_value (mime_type, "bonobo-goad-id"); - - if (!goad_id) { - char *main_type = g_strndup (mime_type, - strcspn (mime_type, "/")); - - goad_id = gnome_mime_get_value (main_type, - "bonobo-goad-id"); - g_free (main_type); - } - if (!goad_id) { - handle_undisplayable (part, mime_type, root, box); - return; - } - - embedded = bonobo_widget_new_subdoc (goad_id, NULL); - if (!embedded) { - handle_undisplayable (part, mime_type, root, box); - return; - } - server = bonobo_widget_get_server (BONOBO_WIDGET (embedded)); + char *cid; - persist = (Bonobo_PersistStream) bonobo_object_client_query_interface ( - server, "IDL:Bonobo/PersistStream:1.0", NULL); - if (persist == CORBA_OBJECT_NIL) { - bonobo_object_unref (BONOBO_OBJECT (embedded)); - handle_undisplayable (part, mime_type, root, box); - return; - } + cid = get_cid (part, mfd->root); + mail_html_write (mfd->html, mfd->stream, + "", + cid, mime_type); + g_free (cid); - /* Write the data to a CamelStreamMem... */ - ba = g_byte_array_new (); - cstream = camel_stream_mem_new_with_byte_array (ba); - camel_data_wrapper_write_to_stream (wrapper, cstream); - - /* ...convert the CamelStreamMem to a BonoboStreamMem... */ - bstream = bonobo_stream_mem_create (ba->data, ba->len, TRUE, FALSE); - gtk_object_unref (GTK_OBJECT (cstream)); - - /* ...and hydrate the PersistStream from the BonoboStream. */ - CORBA_exception_init (&ev); - Bonobo_PersistStream_load (persist, - bonobo_object_corba_objref ( - BONOBO_OBJECT (bstream)), - mime_type, &ev); - bonobo_object_unref (BONOBO_OBJECT (bstream)); - Bonobo_Unknown_unref (persist, &ev); - CORBA_Object_release (persist, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - bonobo_object_unref (BONOBO_OBJECT (embedded)); - CORBA_exception_free (&ev); - handle_undisplayable (part, mime_type, root, box); - return; - } - CORBA_exception_free (&ev); + /* Call handle_undisplayable to output its HTML inside the + * ... . It will only be displayed if the + * object loading fails. + */ + handle_undisplayable (part, mime_type, mfd); - /* Embed the widget. */ - gtk_widget_show (embedded); - gtk_box_pack_start (box, embedded, FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (embedded), "destroy", - embeddable_destroy_cb, NULL); + mail_html_write (mfd->html, mfd->stream, ""); } - static char * reply_body (CamelDataWrapper *data, gboolean *html) { -- cgit v1.2.3