[evolution/webkit] Adapt all plugins to the new EMFormat API



commit e15551a193fbf2f7429ef14430a3208fe0b3db63
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Aug 26 16:23:37 2011 +0200

    Adapt all plugins to the new EMFormat API
    
    The itip-features, mail-to-task, prefer-plain and vcard-inline plugins
    are known to work very well now, though all of them need to be
    thoroughly tested.

 plugins/audio-inline/audio-inline.c       |   53 ++++++++---------
 plugins/external-editor/external-editor.c |    2 +-
 plugins/itip-formatter/itip-formatter.c   |   80 +++++++++++++-------------
 plugins/mail-to-task/mail-to-task.c       |   10 +--
 plugins/prefer-plain/prefer-plain.c       |   87 +++++++++++++++--------------
 plugins/vcard-inline/vcard-inline.c       |   60 ++++++++++----------
 6 files changed, 143 insertions(+), 149 deletions(-)
---
diff --git a/plugins/audio-inline/audio-inline.c b/plugins/audio-inline/audio-inline.c
index 07b1bd6..d89049e 100644
--- a/plugins/audio-inline/audio-inline.c
+++ b/plugins/audio-inline/audio-inline.c
@@ -46,8 +46,10 @@ void org_gnome_audio_inline_format (gpointer ep, EMFormatHookTarget *t);
 
 static volatile gint org_gnome_audio_class_id_counter = 0;
 
-struct _org_gnome_audio_inline_pobject {
-	EMFormatHTMLPObject object;
+typedef struct _EMFormatInlineAudioPURI EMFormatInlineAudioPURI;
+
+struct _EMFormatInlineAudioPURI {
+	EMFormatPURI puri;
 
 	CamelMimePart *part;
 	gchar *filename;
@@ -60,9 +62,9 @@ struct _org_gnome_audio_inline_pobject {
 };
 
 static void
-org_gnome_audio_inline_pobject_free (EMFormatHTMLPObject *o)
+org_gnome_audio_inline_pobject_free (EMFormatPURI *o)
 {
-	struct _org_gnome_audio_inline_pobject *po = (struct _org_gnome_audio_inline_pobject *) o;
+	EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) o;
 
 	d(printf ("audio inline formatter: pobject free\n"));
 
@@ -104,9 +106,9 @@ org_gnome_audio_inline_pobject_free (EMFormatHTMLPObject *o)
 }
 
 static void
-org_gnome_audio_inline_pause_clicked (GtkWidget *button, EMFormatHTMLPObject *pobject)
+org_gnome_audio_inline_pause_clicked (GtkWidget *button, EMFormatPURI *puri)
 {
-	struct _org_gnome_audio_inline_pobject *po = (struct _org_gnome_audio_inline_pobject *) pobject;
+	EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri;
 
 	if (po->playbin) {
 		/* pause playing */
@@ -115,9 +117,9 @@ org_gnome_audio_inline_pause_clicked (GtkWidget *button, EMFormatHTMLPObject *po
 }
 
 static void
-org_gnome_audio_inline_stop_clicked (GtkWidget *button, EMFormatHTMLPObject *pobject)
+org_gnome_audio_inline_stop_clicked (GtkWidget *button, EMFormatPURI *puri)
 {
-	struct _org_gnome_audio_inline_pobject *po = (struct _org_gnome_audio_inline_pobject *) pobject;
+	EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri;
 
 	if (po->playbin) {
 		/* ready to play */
@@ -145,7 +147,7 @@ org_gnome_audio_inline_set_audiosink (GstElement *playbin)
 static gboolean
 org_gnome_audio_inline_gst_callback (GstBus * bus, GstMessage * message, gpointer data)
 {
-	struct _org_gnome_audio_inline_pobject *po = (struct _org_gnome_audio_inline_pobject *) data;
+	EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) data;
 	GstMessageType msg_type;
 
 	g_return_val_if_fail (po != NULL, TRUE);
@@ -189,9 +191,9 @@ org_gnome_audio_inline_gst_callback (GstBus * bus, GstMessage * message, gpointe
 }
 
 static void
-org_gnome_audio_inline_play_clicked (GtkWidget *button, EMFormatHTMLPObject *pobject)
+org_gnome_audio_inline_play_clicked (GtkWidget *button, EMFormatPURI *puri)
 {
-	struct _org_gnome_audio_inline_pobject *po = (struct _org_gnome_audio_inline_pobject *) pobject;
+	EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri;
 	GstState cur_state;
 
 	d(printf ("audio inline formatter: play\n"));
@@ -271,11 +273,13 @@ org_gnome_audio_inline_add_button (GtkWidget *box, const gchar *stock_icon, GCal
 	return button;
 }
 
-static gboolean
-org_gnome_audio_inline_button_panel (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject)
+static GtkWidget*
+org_gnome_audio_inline_button_panel (EMFormat *emf,
+									 EMFormatPURI *puri,
+									 GCancellable *cancellable)
 {
 	GtkWidget *box;
-	struct _org_gnome_audio_inline_pobject *po = (struct _org_gnome_audio_inline_pobject *) pobject;
+	EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri;
 
 	/* it is OK to call UI functions here, since we are called from UI thread */
 
@@ -285,17 +289,15 @@ org_gnome_audio_inline_button_panel (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMF
 	po->stop_button = g_object_ref (org_gnome_audio_inline_add_button (box, GTK_STOCK_MEDIA_STOP, G_CALLBACK (org_gnome_audio_inline_stop_clicked), po, FALSE));
 
 	gtk_widget_show (box);
-	gtk_container_add ((GtkContainer *) eb, box);
 
-	return TRUE;
+	return box;
 }
 
 void
 org_gnome_audio_inline_format (gpointer ep, EMFormatHookTarget *t)
 {
-	struct _org_gnome_audio_inline_pobject *pobj;
+	EMFormatInlineAudioPURI *pobj;
 	gchar *classid;
-	gchar *content;
 
 	classid = g_strdup_printf (
 		"org-gnome-audio-inline-button-panel-%d",
@@ -305,21 +307,16 @@ org_gnome_audio_inline_format (gpointer ep, EMFormatHookTarget *t)
 
 	d(printf ("audio inline formatter: format classid %s\n", classid));
 
-	pobj = (struct _org_gnome_audio_inline_pobject *)
-		em_format_html_add_pobject (
-			(EMFormatHTML *) t->format, sizeof (*pobj), classid,
-			t->part, org_gnome_audio_inline_button_panel);
-	pobj->part = g_object_ref (t->part);
+	pobj = (EMFormatInlineAudioPURI *)	em_format_puri_new (
+			t->format, sizeof (EMFormatInlineAudioPURI), t->part, classid);
+	pobj->puri.widget_func = org_gnome_audio_inline_button_panel;
+	pobj->puri.part = g_object_ref (t->part);
 	pobj->filename = NULL;
 	pobj->playbin = NULL;
 	pobj->play_button = NULL;
 	pobj->stop_button = NULL;
 	pobj->pause_button = NULL;
 	pobj->bus_id = 0;
-	pobj->object.free = org_gnome_audio_inline_pobject_free;
+	pobj->puri.free = org_gnome_audio_inline_pobject_free;
 	pobj->target_state = GST_STATE_NULL;
-
-	content = g_strdup_printf ("<object classid=%s></object>\n", classid);
-	camel_stream_write_string (t->stream, content, NULL, NULL);
-	g_free (content);
 }
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index 9382159..e88df45 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -467,7 +467,7 @@ gboolean
 e_plugin_ui_init (GtkUIManager *manager, EMsgComposer *composer)
 {
 	GtkhtmlEditor *editor;
-	EWebView *web_view;
+	EWebViewGtkHTML *web_view;
 
 	editor = GTKHTML_EDITOR (composer);
 
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index 9296254..7031c39 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -50,7 +50,7 @@
 #include "itip-view.h"
 #include <misc/e-attachment.h>
 
-#define CLASSID "itip://"
+#define CLASSID "mail://itip."
 #define GCONF_KEY_DELETE "/apps/evolution/itip/delete_processed"
 
 #define d(x)
@@ -1791,7 +1791,7 @@ save_vcalendar_cb (GtkWidget *button, struct _itip_puri *pitip)
 }
 
 static GtkWidget *
-set_itip_error (struct _itip_puri *pitip, GtkContainer *container, const gchar *primary, const gchar *secondary)
+set_itip_error (struct _itip_puri *pitip, GtkWidget *container, const gchar *primary, const gchar *secondary)
 {
 	GtkWidget *vbox, *label;
 	gchar *message;
@@ -1812,13 +1812,13 @@ set_itip_error (struct _itip_puri *pitip, GtkContainer *container, const gchar *
 	gtk_widget_show (label);
 	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
 
-	gtk_container_add (container, vbox);
+	gtk_container_add (GTK_CONTAINER (container), vbox);
 
 	return vbox;
 }
 
-static gboolean
-extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *have_alarms)
+static GtkWidget*
+extract_itip_data (struct _itip_puri *pitip, gboolean *have_alarms)
 {
 	EShell *shell;
 	EShellSettings *shell_settings;
@@ -1830,16 +1830,19 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 	icalcompiter alarm_iter;
 	ECalComponent *comp;
 	gboolean use_default_reminder;
+	GtkWidget *container;
 
 	shell = e_shell_get_default ();
 	shell_settings = e_shell_get_shell_settings (shell);
 
+	container = gtk_vbox_new (FALSE, 5);
+
 	if (!pitip->vcalendar) {
 		set_itip_error (pitip, container,
 				_("The calendar attached is not valid"),
 				_("The message claims to contain a calendar, but the calendar is not a valid iCalendar."));
 
-		return FALSE;
+		return container;
 	}
 
 	pitip->top_level = e_cal_util_new_top_level ();
@@ -1855,7 +1858,7 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 			pitip->main_comp = NULL;
 		}
 
-		return FALSE;
+		return container;
 	}
 
 	prop = icalcomponent_get_first_property (pitip->main_comp, ICAL_METHOD_PROPERTY);
@@ -1891,7 +1894,7 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 				_("The item in the calendar is not valid"),
 				_("The message does contain a calendar, but the calendar contains no events, tasks or free/busy information"));
 
-		return FALSE;
+		return container;
 	}
 
 	switch (icalcomponent_isa (pitip->ical_comp)) {
@@ -1918,7 +1921,7 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 		set_itip_error (pitip, container,
 				_("The item in the calendar is not valid"),
 				_("The message does contain a calendar, but the calendar contains no events, tasks or free/busy information"));
-		return FALSE;
+		return container;
 	}
 
 	pitip->total = icalcomponent_count_components (pitip->main_comp, ICAL_VEVENT_COMPONENT);
@@ -1945,7 +1948,7 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 		gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
 		g_signal_connect (save, "clicked", G_CALLBACK (save_vcalendar_cb), pitip);
-		return FALSE;
+		return container;
 	} if (pitip->total > 0) {
 		pitip->current = 1;
 	} else {
@@ -2028,7 +2031,7 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 				_("The item in the calendar is not valid"),
 				_("The message does contain a calendar, but the calendar contains no events, tasks or free/busy information"));
 
-		return FALSE;
+		return container;
 	};
 
 	/* Add default reminder if the config says so */
@@ -2079,7 +2082,9 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *
 	find_from_address (pitip, pitip->ical_comp);
 	find_to_address (pitip, pitip->ical_comp, NULL);
 
-	return TRUE;
+	gtk_widget_destroy (container);
+
+	return NULL;
 }
 
 struct _opencal_msg {
@@ -2432,7 +2437,9 @@ in_proper_folder (CamelFolder *folder)
 }
 
 static GtkWidget*
-format_itip_object (EMFormatHTML *efh, EMFormatHTMLPObject *pobject)
+format_itip_object (EMFormat *emf,
+		    EMFormatPURI *puri,
+		    GCancellable *cancellable)
 {
 	EShell *shell;
 	EShellSettings *shell_settings;
@@ -2448,11 +2455,13 @@ format_itip_object (EMFormatHTML *efh, EMFormatHTMLPObject *pobject)
 	gint i;
 	gboolean response_enabled;
 	gboolean have_alarms = FALSE;
+	GtkWidget *err_widget;
+	EMFormatHTML *efh = (EMFormatHTML *) emf;
 
 	shell = e_shell_get_default ();
 	shell_settings = e_shell_get_shell_settings (shell);
 
-	info = (struct _itip_puri *) em_format_find_puri ((EMFormat *) efh, pobject->classid);
+	info = (struct _itip_puri *) puri;
 
 	/* Accounts */
 	info->accounts = e_get_account_list ();
@@ -2468,10 +2477,8 @@ format_itip_object (EMFormatHTML *efh, EMFormatHTMLPObject *pobject)
 	}
 
 	/* FIXME Handle multiple VEVENTS with the same UID, ie detached instances */
-#if 0  /* WEBKIT - FIXME!! */
-	if (!extract_itip_data (info, GTK_CONTAINER (eb), &have_alarms))
-		return TRUE;
-#endif
+	if ((err_widget = extract_itip_data (info, &have_alarms)) != NULL)
+		return err_widget;
 
 	info->view = itip_view_new ();
 	gtk_widget_show (info->view);
@@ -2815,34 +2822,34 @@ void
 format_itip (EPlugin *ep, EMFormatHookTarget *target)
 {
 	GConfClient *gconf;
-	gchar *classid;
 	struct _itip_puri *puri;
 	CamelDataWrapper *content;
 	CamelStream *stream;
 	GByteArray *byte_array;
-	gchar *string;
+	gint len;
 
-	classid = g_strdup_printf("itip:///%s", ((EMFormat *) target->format)->part_id->str);
+	len = target->part_id->len;
+	g_string_append_printf (target->part_id, ".itip");
 
 	/* mark message as containing calendar, thus it will show the icon in message list now on */
-	if (target->format->uid && target->format->folder &&
-	    !camel_folder_get_message_user_flag (target->format->folder, target->format->uid, "$has_cal"))
-		camel_folder_set_message_user_flag (target->format->folder, target->format->uid, "$has_cal", TRUE);
-
-	puri = (struct _itip_puri *) em_format_add_puri (target->format, sizeof (struct _itip_puri), classid, target->part, itip_attachment_frame);
-
-	em_format_html_add_pobject ((EMFormatHTML *) target->format, sizeof (EMFormatHTMLPObject), classid, target->part, format_itip_object);
+	if (target->format->message_uid && target->format->folder &&
+	    !camel_folder_get_message_user_flag (target->format->folder, target->format->message_uid, "$has_cal"))
+		camel_folder_set_message_user_flag (target->format->folder, target->format->message_uid, "$has_cal", TRUE);
 
 	gconf = gconf_client_get_default ();
+
+	puri = (struct _itip_puri *) em_format_puri_new (target->format, sizeof (struct _itip_puri), target->part, target->part_id->str);
+	puri->puri.widget_func = format_itip_object;
+	puri->puri.free = puri_free;
 	puri->delete_message = gconf_client_get_bool (gconf, GCONF_KEY_DELETE, NULL);
 	puri->has_organizer = FALSE;
 	puri->no_reply_wanted = FALSE;
 	puri->folder = ((EMFormat *) target->format)->folder;
-	puri->uid = g_strdup (((EMFormat *) target->format)->uid);
+	puri->uid = g_strdup (((EMFormat *) target->format)->message_uid);
 	puri->msg = ((EMFormat *) target->format)->message;
 	puri->part = target->part;
 	puri->cancellable = g_cancellable_new ();
-	puri->puri.free = puri_free;
+	em_format_add_puri (target->format, (EMFormatPURI *) puri);
 
 	g_object_unref (gconf);
 
@@ -2860,16 +2867,7 @@ format_itip (EPlugin *ep, EMFormatHookTarget *target)
 			(gchar *) byte_array->data, byte_array->len);
 
 	g_object_unref (stream);
-
-	string = g_strdup_printf (
-		"<table border=0 width=\"100%%\" cellpadding=3><tr>"
-		"<td valign=top><object classid=\"%s\"></object></td>"
-		"<td width=100%% valign=top></td></tr></table>",
-		classid);
-	camel_stream_write_string (target->stream, string, NULL, NULL);
-	g_free (string);
-
-	g_free (classid);
+	g_string_truncate (target->part_id, len);
 }
 
 static void
@@ -3036,6 +3034,7 @@ itip_attachment_frame (EMFormat *emf,
                        EMFormatPURI *puri,
                        GCancellable *cancellable)
 {
+	/* FIXME WEBKIT: I have no idea what these _frame functions are supposed to do
 	struct _itip_puri *info = (struct _itip_puri *) puri;
 
 	info->handle->handler (
@@ -3043,5 +3042,6 @@ itip_attachment_frame (EMFormat *emf,
 		info->handle, cancellable, FALSE);
 
 	camel_stream_close (stream, cancellable, NULL);
+	*/
 }
 
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 1ac7652..b9083bb 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -1003,18 +1003,16 @@ text_contains_nonwhitespace (const gchar *text, gint len)
 static gchar *
 get_selected_text (EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 	gchar *text = NULL;
 	gint len;
 
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 
-	if (!e_web_view_is_selection_active (web_view))
+	if (!e_mail_display_is_selection_active (display))
 		return NULL;
 
-	text = gtk_html_get_selection_plain_text (GTK_HTML (web_view), &len);
+	text = e_mail_display_get_selection_plain_text (display, &len);
 
 	if (text == NULL || !text_contains_nonwhitespace (text, len)) {
 		g_free (text);
diff --git a/plugins/prefer-plain/prefer-plain.c b/plugins/prefer-plain/prefer-plain.c
index ce51ffe..4fe69bd 100644
--- a/plugins/prefer-plain/prefer-plain.c
+++ b/plugins/prefer-plain/prefer-plain.c
@@ -49,12 +49,13 @@ static gint epp_mode = -1;
 static gboolean epp_show_suppressed = TRUE;
 
 static void
-make_part_attachment (EMFormat *format, CamelStream *stream, CamelMimePart *part, gint i)
+make_part_attachment (EMFormat *format,
+		      CamelMimePart *part,
+		      GString *part_id,
+		      gboolean force_html,
+		      GCancellable *cancellable)
 {
-	gint partidlen = format->part_id->len;
-
-	if (i != -1)
-		g_string_append_printf (format->part_id, ".alternative-prefer-plain.%d", i);
+	EMFormatParserInfo info = {0};
 
 	if (camel_content_type_is (camel_mime_part_get_content_type (part), "text", "html")) {
 		/* always show HTML as attachments and not inline */
@@ -66,11 +67,9 @@ make_part_attachment (EMFormat *format, CamelStream *stream, CamelMimePart *part
 			g_free (str);
 		}
 
-		/* FIXME Not passing a GCancellable here. */
-		em_format_part_as (
-			format, stream, part,
-			"application/octet-stream", NULL);
-	} else if (i == -1 && CAMEL_IS_MIME_MESSAGE (part)) {
+		em_format_parse_part_as (
+			format, part, part_id, &info, "application/octet-stream", cancellable);
+	} else if (force_html && CAMEL_IS_MIME_MESSAGE (part)) {
 		/* message was asked to be formatted as text/html;
 		   might be for cases where message itself is a text/html part */
 		CamelMimePart *new_part;
@@ -82,15 +81,13 @@ make_part_attachment (EMFormat *format, CamelStream *stream, CamelMimePart *part
 		new_part = camel_mime_part_new ();
 		camel_medium_set_content (CAMEL_MEDIUM (new_part), content);
 
-		em_format_part (format, stream, new_part, NULL);
+		em_format_parse_part (format, new_part, part_id, &info, cancellable);
 
 		g_object_unref (new_part);
 	} else {
 		/* FIXME Not passing a GCancellable here. */
-		em_format_part (format, stream, part, NULL);
+		em_format_parse_part (format, part, part_id, &info, cancellable);
 	}
-
-	g_string_truncate (format->part_id, partidlen);
 }
 
 void
@@ -98,25 +95,27 @@ org_gnome_prefer_plain_text_html (gpointer ep, EMFormatHookTarget *t)
 {
 	/* In text-only mode, all html output is suppressed for the first processing */
 	if (epp_mode != EPP_TEXT
-	    || strstr (t->format->part_id->str, ".alternative-prefer-plain.") != NULL
-	    || em_format_is_inline (t->format, t->format->part_id->str, t->part, &(t->item->handler)))
+	    || strstr (t->part_id->str, ".alternative-prefer-plain.") != NULL
+	    || em_format_is_inline (t->format, t->part_id->str, t->part, t->info->handler)) {
 		/* FIXME Not passing a GCancellable here. */
-		t->item->handler.old->handler (
-			t->format, t->stream, t->part,
-			t->item->handler.old, NULL, FALSE);
-	else if (epp_show_suppressed)
-		make_part_attachment (t->format, t->stream, t->part, -1);
+		t->info->handler->old->parse_func (
+			t->format, t->part, t->part_id,
+			t->info, NULL);
+	} else if (epp_show_suppressed)
+		make_part_attachment (t->format, t->part, t->part_id, TRUE, NULL);
 }
 
 static void
-export_as_attachments (CamelMultipart *mp, EMFormat *format, CamelStream *stream, CamelMimePart *except)
+export_as_attachments (CamelMultipart *mp, EMFormat *format, CamelMimePart *except, GString *part_id)
 {
 	gint i, nparts;
 	CamelMimePart *part;
+	gint len;
 
 	if (!mp || !CAMEL_IS_MULTIPART (mp))
 		return;
 
+	len = part_id->len;
 	nparts = camel_multipart_get_number (mp);
 	for (i = 0; i < nparts; i++) {
 		part = camel_multipart_get_part (mp, i);
@@ -124,11 +123,13 @@ export_as_attachments (CamelMultipart *mp, EMFormat *format, CamelStream *stream
 		if (part != except) {
 			CamelMultipart *multipart = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) part);
 
+			g_string_append_printf (part_id, ".aleternative-prefer-plain.%d", i);
 			if (CAMEL_IS_MULTIPART (multipart)) {
-				export_as_attachments (multipart, format, stream, except);
+				export_as_attachments (multipart, format, except, part_id);
 			} else {
-				make_part_attachment (format, stream, part, i);
+				make_part_attachment (format, part, part_id, FALSE, NULL);
 			}
+			g_string_truncate (part_id, len);
 		}
 	}
 }
@@ -141,7 +142,7 @@ org_gnome_prefer_plain_multipart_alternative (gpointer ep, EMFormatHookTarget *t
 	gint i, nparts, partidlen, displayid = 0, calendarid = 0;
 
 	/* FIXME: this part-id stuff is poking private data, needs api */
-	partidlen = t->format->part_id->len;
+	partidlen = t->part_id->len;
 
 	if (epp_mode == EPP_NORMAL) {
 		gboolean have_plain = FALSE;
@@ -177,21 +178,20 @@ org_gnome_prefer_plain_multipart_alternative (gpointer ep, EMFormatHookTarget *t
 		}
 
 		if (display_part && have_plain && nparts == 2) {
-			g_string_append_printf (t->format->part_id, ".alternative-prefer-plain.%d", displayid);
+			g_string_append_printf (t->part_id, ".alternative-prefer-plain.%d", displayid);
 			/* FIXME Not passing a GCancellable here. */
-			em_format_part_as (
-				t->format, t->stream,
-				display_part, "text/html", NULL);
-			g_string_truncate (t->format->part_id, partidlen);
+			em_format_parse_part_as (
+				t->format, display_part, t->part_id, t->info, "text/html", NULL);
+			g_string_truncate (t->part_id, partidlen);
 		} else {
 			/* FIXME Not passing a GCancellable here. */
-			t->item->handler.old->handler (
-				t->format, t->stream, t->part,
-				t->item->handler.old, NULL, FALSE);
+			t->info->handler->old->parse_func (
+				t->format, display_part, t->part_id,
+				t->info, NULL);
 		}
 		return;
 	} else if (!CAMEL_IS_MULTIPART (mp)) {
-		em_format_format_source (t->format, t->stream, t->part, NULL);
+		em_format_parse_part_as (t->format, t->part, t->part_id, t->info, "x-evolution/message/source", NULL);
 		return;
 	}
 
@@ -216,21 +216,22 @@ org_gnome_prefer_plain_multipart_alternative (gpointer ep, EMFormatHookTarget *t
 
 	/* if we found a text part, show it */
 	if (display_part) {
-		g_string_append_printf(t->format->part_id, ".alternative-prefer-plain.%d", displayid);
+		g_string_append_printf(t->part_id, ".alternative-prefer-plain.%d", displayid);
 		/* FIXME Not passing a GCancellable here. */
-		em_format_part_as (
-			t->format, t->stream,
-			display_part, "text/plain", NULL);
-		g_string_truncate (t->format->part_id, partidlen);
+		em_format_parse_part_as (
+			t->format, display_part, t->part_id, t->info, "text/plain", NULL);
+		g_string_truncate (t->part_id, partidlen);
 	}
 
 	/* all other parts are attachments */
 	if (epp_show_suppressed)
-		export_as_attachments (mp, t->format, t->stream, display_part);
-	else if (calendar_part)
-		make_part_attachment (t->format, t->stream, calendar_part, calendarid);
+		export_as_attachments (mp, t->format, display_part, t->part_id);
+	else if (calendar_part) {
+		g_string_append_printf(t->part_id, ".alternative-prefer-plain.%d", calendarid);
+		make_part_attachment (t->format, calendar_part, t->part_id, FALSE, NULL);
+	}
 
-	g_string_truncate (t->format->part_id, partidlen);
+	g_string_truncate (t->part_id, partidlen);
 }
 
 static struct {
diff --git a/plugins/vcard-inline/vcard-inline.c b/plugins/vcard-inline/vcard-inline.c
index 78818f3..e9341f8 100644
--- a/plugins/vcard-inline/vcard-inline.c
+++ b/plugins/vcard-inline/vcard-inline.c
@@ -36,10 +36,10 @@
 
 #define d(x)
 
-typedef struct _VCardInlinePObject VCardInlinePObject;
+typedef struct _VCardInlinePURI VCardInlinePURI;
 
-struct _VCardInlinePObject {
-	EMFormatHTMLPObject object;
+struct _VCardInlinePURI {
+	EMFormatPURI puri;
 
 	GSList *contact_list;
 	ESourceList *source_list;
@@ -60,11 +60,11 @@ e_plugin_lib_enable (EPlugin *ep, gint enable)
 }
 
 static void
-org_gnome_vcard_inline_pobject_free (EMFormatHTMLPObject *object)
+org_gnome_vcard_inline_pobject_free (EMFormatPURI *object)
 {
-	VCardInlinePObject *vcard_object;
+	VCardInlinePURI *vcard_object;
 
-	vcard_object = (VCardInlinePObject *) object;
+	vcard_object = (VCardInlinePURI *) object;
 
 	e_client_util_free_object_slist (vcard_object->contact_list);
 	vcard_object->contact_list = NULL;
@@ -86,7 +86,7 @@ org_gnome_vcard_inline_pobject_free (EMFormatHTMLPObject *object)
 }
 
 static void
-org_gnome_vcard_inline_decode (VCardInlinePObject *vcard_object,
+org_gnome_vcard_inline_decode (VCardInlinePURI *vcard_object,
                                CamelMimePart *mime_part)
 {
 	CamelDataWrapper *data_wrapper;
@@ -151,7 +151,7 @@ org_gnome_vcard_inline_client_loaded_cb (GObject *source_object, GAsyncResult *r
 }
 
 static void
-org_gnome_vcard_inline_save_cb (VCardInlinePObject *vcard_object)
+org_gnome_vcard_inline_save_cb (VCardInlinePURI *vcard_object)
 {
 	ESource *source;
 	GSList *contact_list;
@@ -184,7 +184,7 @@ org_gnome_vcard_inline_save_cb (VCardInlinePObject *vcard_object)
 }
 
 static void
-org_gnome_vcard_inline_toggle_cb (VCardInlinePObject *vcard_object,
+org_gnome_vcard_inline_toggle_cb (VCardInlinePURI *vcard_object,
                                   GtkButton *button)
 {
 	EABContactDisplay *contact_display;
@@ -207,19 +207,20 @@ org_gnome_vcard_inline_toggle_cb (VCardInlinePObject *vcard_object,
 	gtk_button_set_label (button, label);
 }
 
-static gboolean
-org_gnome_vcard_inline_embed (EMFormatHTML *format,
-                              GtkHTMLEmbedded *embedded,
-                              EMFormatHTMLPObject *object)
+static GtkWidget*
+org_gnome_vcard_inline_embed (EMFormat *emf,
+                              EMFormatPURI *object,
+                              GCancellable *cancellable)
 {
-	VCardInlinePObject *vcard_object;
+	VCardInlinePURI *vcard_object;
 	GtkWidget *button_box;
 	GtkWidget *container;
 	GtkWidget *widget;
+	GtkWidget *layout;
 	EContact *contact;
 	guint length;
 
-	vcard_object = (VCardInlinePObject *) object;
+	vcard_object = (VCardInlinePURI *) object;
 	length = g_slist_length (vcard_object->contact_list);
 
 	if (vcard_object->contact_list != NULL)
@@ -227,13 +228,10 @@ org_gnome_vcard_inline_embed (EMFormatHTML *format,
 	else
 		contact = NULL;
 
-	container = GTK_WIDGET (embedded);
+	layout = gtk_vbox_new (FALSE, 0);
+	gtk_widget_show (layout);
 
-	widget = gtk_vbox_new (FALSE, 0);
-	gtk_container_add (GTK_CONTAINER (container), widget);
-	gtk_widget_show (widget);
-
-	container = widget;
+	container = layout;
 
 	widget = gtk_hbutton_box_new ();
 	gtk_button_box_set_layout (
@@ -305,13 +303,13 @@ org_gnome_vcard_inline_embed (EMFormatHTML *format,
 		G_CALLBACK (org_gnome_vcard_inline_save_cb),
 		vcard_object);
 
-	return TRUE;
+	return layout;
 }
 
 void
 org_gnome_vcard_inline_format (gpointer ep, EMFormatHookTarget *target)
 {
-	VCardInlinePObject *vcard_object;
+	VCardInlinePURI *vcard_object;
 	gchar *classid;
 	gchar *content;
 
@@ -319,23 +317,23 @@ org_gnome_vcard_inline_format (gpointer ep, EMFormatHookTarget *target)
 		"org-gnome-vcard-inline-display-%d",
 		org_gnome_vcard_inline_classid++);
 
-	vcard_object = (VCardInlinePObject *)
-		em_format_html_add_pobject (
-			EM_FORMAT_HTML (target->format),
-			sizeof (VCardInlinePObject),
-			classid, target->part,
-			org_gnome_vcard_inline_embed);
+	vcard_object = (VCardInlinePURI *) em_format_puri_new (
+			target->format, sizeof(VCardInlinePURI), target->part, classid);
+	vcard_object->puri.widget_func = org_gnome_vcard_inline_embed;
+	vcard_object->puri.free = org_gnome_vcard_inline_pobject_free;
 
-	g_object_ref (target->part);
+	em_format_add_puri (target->format, (EMFormatPURI *) vcard_object);
 
-	vcard_object->object.free = org_gnome_vcard_inline_pobject_free;
+	g_object_ref (target->part);
 	org_gnome_vcard_inline_decode (vcard_object, target->part);
 
 	e_book_client_get_sources (&vcard_object->source_list, NULL);
 
+	/* FIXME WEBKIT: No streams, right?
 	content = g_strdup_printf ("<object classid=%s></object>", classid);
 	camel_stream_write_string (target->stream, content, NULL, NULL);
 	g_free (content);
+	*/
 
 	g_free (classid);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]