[evolution/camel-gobject: 4/4] Changes to support Camel's conversion to GObject.



commit 1193d1fed5e90d8d3cc1b6a2080d38fa615fab69
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Oct 9 18:00:31 2009 -0500

    Changes to support Camel's conversion to GObject.
    
    - Adapt to Camel API changes.
    - Convert CamelObject subclasses to GObject.
    - Include Camel's top-level header file only.

 calendar/gui/dialogs/comp-editor.c               |   14 +-
 composer/e-msg-composer.c                        |  147 ++++++++-------
 e-util/e-signature-utils.c                       |    7 +-
 em-format/em-format-quote.c                      |   39 +++--
 em-format/em-format.c                            |   81 +++++----
 em-format/em-stripsig-filter.c                   |   59 +++---
 em-format/em-stripsig-filter.h                   |   39 +++--
 mail/e-mail-reader-utils.c                       |   25 ++-
 mail/e-mail-tag-editor.h                         |    3 +-
 mail/em-composer-utils.c                         |   42 +++--
 mail/em-filter-source-element.c                  |    6 +-
 mail/em-format-html-display.c                    |   16 +-
 mail/em-format-html.c                            |  218 +++++++++++++---------
 mail/em-html-stream.c                            |   55 +++---
 mail/em-html-stream.h                            |   22 ++-
 mail/em-inline-filter.c                          |   83 +++++----
 mail/em-inline-filter.h                          |   39 +++-
 mail/em-sync-stream.c                            |   69 ++++---
 mail/em-sync-stream.h                            |   21 ++-
 mail/em-utils.c                                  |   34 ++--
 mail/mail-autofilter.c                           |    6 +-
 mail/mail-ops.c                                  |   48 +++--
 mail/mail-session.c                              |  106 +++++------
 mail/mail-session.h                              |   37 ++++
 mail/mail-tools.c                                |   86 +++++++--
 mail/mail-tools.h                                |    8 +-
 mail/mail-vfolder.c                              |   14 +-
 modules/calendar/e-cal-attachment-handler.c      |    2 +-
 modules/mail/e-mail-attachment-handler.c         |   12 +-
 modules/mail/e-mail-shell-migrate.c              |   35 ++---
 modules/mail/e-mail-shell-view-private.h         |    1 +
 plugins/audio-inline/audio-inline.c              |    2 +-
 plugins/groupwise-features/camel-gw-listener.c   |    2 +
 plugins/groupwise-features/install-shared.c      |   16 +-
 plugins/hula-account-setup/camel-hula-listener.c |    5 +-
 plugins/hula-account-setup/hula-account-setup.c  |    2 +
 plugins/image-inline/image-inline.c              |   13 +-
 plugins/imap-features/imap-headers.c             |    5 +-
 plugins/itip-formatter/itip-formatter.c          |   18 +-
 plugins/mail-to-task/mail-to-task.c              |   26 ++-
 plugins/prefer-plain/prefer-plain.c              |    4 +-
 plugins/pst-import/pst-importer.c                |    4 +-
 plugins/sa-junk-plugin/em-junk-filter.c          |    1 +
 plugins/templates/templates.c                    |   31 ++-
 plugins/tnef-attachments/tnef-plugin.c           |    6 +-
 plugins/vcard-inline/vcard-inline.c              |    2 +-
 widgets/misc/e-attachment.c                      |   24 ++--
 47 files changed, 897 insertions(+), 638 deletions(-)
---
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 2de3a54..14626db 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -2894,7 +2894,8 @@ comp_editor_get_mime_attach_list (CompEditor *editor)
 		EAttachment *attachment;
 		CamelDataWrapper *wrapper;
 		CamelMimePart *mime_part;
-		CamelStreamMem *mstream;
+		CamelStream *mstream;
+		GByteArray *byte_array;
 		guchar *buffer = NULL;
 		const gchar *desc, *disp;
 		gint column_id;
@@ -2910,16 +2911,17 @@ comp_editor_get_mime_attach_list (CompEditor *editor)
 			continue;
 
 		cal_mime_attach = g_malloc0 (sizeof (struct CalMimeAttach));
-		wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
-		mstream = (CamelStreamMem *) camel_stream_mem_new ();
+		wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
-		camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mstream);
-		buffer = g_memdup (mstream->buffer->data, mstream->buffer->len);
+		byte_array = g_byte_array_new ();
+		mstream = camel_stream_mem_new_with_byte_array (byte_array);
+		camel_data_wrapper_decode_to_stream (wrapper, mstream);
+		buffer = g_memdup (byte_array->data, byte_array->len);
 
 		camel_mime_part_set_content_id (mime_part, NULL);
 
 		cal_mime_attach->encoded_data = (gchar *)buffer;
-		cal_mime_attach->length = mstream->buffer->len;
+		cal_mime_attach->length = byte_array->len;
 		cal_mime_attach->filename = g_strdup (camel_mime_part_get_filename (mime_part));
 		desc = camel_mime_part_get_description (mime_part);
 		if (!desc || *desc == '\0')
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index f73f385..0b3b666 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -185,22 +185,6 @@ emcu_prompt_user (GtkWindow *parent, const gchar *promptkey, const gchar *tag, c
 	return button == GTK_RESPONSE_YES;
 }
 
-/* copy of mail_tool_remove_xevolution_headers */
-static struct _camel_header_raw *
-emcu_remove_xevolution_headers (CamelMimeMessage *message)
-{
-	struct _camel_header_raw *scan, *list = NULL;
-
-	for (scan = ((CamelMimePart *)message)->headers;scan;scan=scan->next)
-		if (!strncmp(scan->name, "X-Evolution", 11))
-			camel_header_raw_append(&list, scan->name, scan->value, scan->offset);
-
-	for (scan=list;scan;scan=scan->next)
-		camel_medium_remove_header((CamelMedium *)message, scan->name);
-
-	return list;
-}
-
 static EDestination**
 destination_list_to_vector_sized (GList *list, gint n)
 {
@@ -653,38 +637,38 @@ build_message (EMsgComposer *composer,
 
 	/* convert the stream to the appropriate charset */
 	if (iconv_charset && g_ascii_strcasecmp (iconv_charset, "UTF-8") != 0) {
-		CamelStreamFilter *filter_stream;
-		CamelMimeFilterCharset *filter;
+		CamelStream *filter_stream;
+		CamelMimeFilter *filter;
 
-		filter_stream = camel_stream_filter_new_with_stream (stream);
+		filter_stream = camel_stream_filter_new (stream);
 		g_object_unref (stream);
 
-		stream = (CamelStream *) filter_stream;
-		filter = camel_mime_filter_charset_new_convert ("UTF-8", iconv_charset);
-		camel_stream_filter_add (filter_stream, (CamelMimeFilter *) filter);
+		stream = filter_stream;
+		filter = camel_mime_filter_charset_new ("UTF-8", iconv_charset);
+		camel_stream_filter_add (
+			CAMEL_STREAM_FILTER (filter_stream), filter);
 		g_object_unref (filter);
 	}
 
 	if (plain_encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE) {
 		/* encode to quoted-printable by ourself, together with
 		   taking care of "\nFrom " text */
-		CamelStreamFilter *filter_stream;
+		CamelStream *filter_stream;
 		CamelMimeFilter *mf, *qp;
 
 		if (!CAMEL_IS_STREAM_FILTER (stream)) {
-			filter_stream = camel_stream_filter_new_with_stream (stream);
-			camel_object_unref (stream);
-
-			stream = (CamelStream *) filter_stream;
+			filter_stream = camel_stream_filter_new (stream);
+			g_object_unref (stream);
+			stream = filter_stream;
 		}
 
-		qp = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_QP_ENC);
+		qp = (CamelMimeFilter *) camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_QP_ENC);
 		camel_stream_filter_add (CAMEL_STREAM_FILTER (stream), qp);
-		camel_object_unref (qp);
+		g_object_unref (qp);
 
 		mf = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_FROM);
 		camel_stream_filter_add (CAMEL_STREAM_FILTER (stream), mf);
-		camel_object_unref (mf);
+		g_object_unref (mf);
 	}
 
 	/* construct the content object */
@@ -726,23 +710,22 @@ build_message (EMsgComposer *composer,
 		if (pre_encode) {
 			/* encode to quoted-printable by ourself, together with
 			   taking care of "\nFrom " text */
-			CamelStreamFilter *filter_stream;
+			CamelStream *filter_stream;
 			CamelMimeFilter *mf, *qp;
 
 			if (!CAMEL_IS_STREAM_FILTER (stream)) {
-				filter_stream = camel_stream_filter_new_with_stream (stream);
-				camel_object_unref (stream);
-
-				stream = (CamelStream *) filter_stream;
+				filter_stream = camel_stream_filter_new (stream);
+				g_object_unref (stream);
+				stream = filter_stream;
 			}
 
-			qp = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_QP_ENC);
+			qp = (CamelMimeFilter *) camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_QP_ENC);
 			camel_stream_filter_add (CAMEL_STREAM_FILTER (stream), qp);
-			camel_object_unref (qp);
+			g_object_unref (qp);
 
 			mf = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_FROM);
 			camel_stream_filter_add (CAMEL_STREAM_FILTER (stream), mf);
-			camel_object_unref (mf);
+			g_object_unref (mf);
 		}
 
 		camel_data_wrapper_construct_from_stream (html, stream);
@@ -761,14 +744,14 @@ build_message (EMsgComposer *composer,
 		camel_multipart_set_boundary (body, NULL);
 
 		part = camel_mime_part_new ();
-		camel_medium_set_content_object (CAMEL_MEDIUM (part), plain);
+		camel_medium_set_content (CAMEL_MEDIUM (part), plain);
 		g_object_unref (plain);
 		camel_mime_part_set_encoding (part, plain_encoding);
 		camel_multipart_add_part (body, part);
 		g_object_unref (part);
 
 		part = camel_mime_part_new ();
-		camel_medium_set_content_object (CAMEL_MEDIUM (part), html);
+		camel_medium_set_content (CAMEL_MEDIUM (part), html);
 		g_object_unref (html);
 		camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE);
 		camel_multipart_add_part (body, part);
@@ -788,7 +771,7 @@ build_message (EMsgComposer *composer,
 			camel_multipart_set_boundary (html_with_images, NULL);
 
 			part = camel_mime_part_new ();
-			camel_medium_set_content_object (CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER (body));
+			camel_medium_set_content (CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER (body));
 			g_object_unref (body);
 			camel_multipart_add_part (html_with_images, part);
 			g_object_unref (part);
@@ -814,7 +797,7 @@ build_message (EMsgComposer *composer,
 		camel_multipart_set_boundary (multipart, NULL);
 
 		part = camel_mime_part_new ();
-		camel_medium_set_content_object (CAMEL_MEDIUM (part), current);
+		camel_medium_set_content (CAMEL_MEDIUM (part), current);
 		if (current == plain)
 			camel_mime_part_set_encoding (part, plain_encoding);
 		g_object_unref (current);
@@ -877,7 +860,7 @@ build_message (EMsgComposer *composer,
 		EAccount *account;
 
 		part = camel_mime_part_new ();
-		camel_medium_set_content_object (CAMEL_MEDIUM (part), current);
+		camel_medium_set_content (CAMEL_MEDIUM (part), current);
 		if (current == plain)
 			camel_mime_part_set_encoding (part, plain_encoding);
 		g_object_unref (current);
@@ -945,7 +928,7 @@ build_message (EMsgComposer *composer,
 		if (from)
 			g_object_unref (from);
 
-		current = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+		current = camel_medium_get_content (CAMEL_MEDIUM (part));
 		g_object_ref (current);
 		g_object_unref (part);
 	}
@@ -956,7 +939,7 @@ build_message (EMsgComposer *composer,
 		CamelCipherContext *cipher;
 
 		part = camel_mime_part_new ();
-		camel_medium_set_content_object ((CamelMedium *)part, current);
+		camel_medium_set_content ((CamelMedium *)part, current);
 		if (current == plain)
 			camel_mime_part_set_encoding (part, plain_encoding);
 		g_object_unref (current);
@@ -1027,14 +1010,14 @@ build_message (EMsgComposer *composer,
 			g_object_unref (part);
 			goto skip_content;
 		} else {
-			current = camel_medium_get_content_object ((CamelMedium *)part);
+			current = camel_medium_get_content ((CamelMedium *)part);
 			g_object_ref (current);
 			g_object_unref (part);
 		}
 	}
 #endif /* HAVE_NSS */
 
-	camel_medium_set_content_object (CAMEL_MEDIUM (new), current);
+	camel_medium_set_content (CAMEL_MEDIUM (new), current);
 	if (current == plain)
 		camel_mime_part_set_encoding (CAMEL_MIME_PART (new), plain_encoding);
 	g_object_unref (current);
@@ -2044,7 +2027,7 @@ msg_composer_uri_requested (GtkhtmlEditor *editor,
 
 	array = g_byte_array_new ();
 	camel_stream = camel_stream_mem_new_with_byte_array (array);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (part));
 	camel_data_wrapper_decode_to_stream (wrapper, camel_stream);
 
 	gtk_html_write (
@@ -2340,7 +2323,7 @@ add_attachments_handle_mime_part (EMsgComposer *composer,
 		return;
 
 	content_type = camel_mime_part_get_content_type (mime_part);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	if (CAMEL_IS_MULTIPART (wrapper)) {
 		/* another layer of multipartness... */
@@ -2412,7 +2395,7 @@ e_msg_composer_add_message_attachments (EMsgComposer *composer,
 {
 	CamelDataWrapper *wrapper;
 
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (message));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (message));
 	if (!CAMEL_IS_MULTIPART (wrapper))
 		return;
 
@@ -2450,7 +2433,7 @@ handle_multipart_signed (EMsgComposer *composer,
 
 	content_type = camel_mime_part_get_content_type (mime_part);
 
-	content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	if (CAMEL_IS_MULTIPART (content)) {
 		multipart = CAMEL_MULTIPART (content);
@@ -2525,7 +2508,7 @@ handle_multipart_encrypted (EMsgComposer *composer,
 
 	content_type = camel_mime_part_get_content_type (mime_part);
 
-	content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	if (CAMEL_IS_MULTIPART (content)) {
 		CamelMultipart *content_multipart = CAMEL_MULTIPART (content);
@@ -2583,7 +2566,7 @@ handle_multipart_alternative (EMsgComposer *composer,
 			continue;
 
 		content_type = camel_mime_part_get_content_type (mime_part);
-		content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+		content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 		if (CAMEL_IS_MULTIPART (content)) {
 			CamelMultipart *mp;
@@ -2643,7 +2626,7 @@ handle_multipart (EMsgComposer *composer,
 			continue;
 
 		content_type = camel_mime_part_get_content_type (mime_part);
-		content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+		content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 		if (CAMEL_IS_MULTIPART (content)) {
 			CamelMultipart *mp;
@@ -2729,20 +2712,36 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
 	EDestination **Tov, **Ccv, **Bccv;
 	GHashTable *auto_cc, *auto_bcc;
 	CamelContentType *content_type;
-	struct _camel_header_raw *headers;
 	CamelDataWrapper *content;
+	CamelMimePart *mime_part;
 	EAccount *account = NULL;
 	gchar *account_name;
 	EMsgComposer *composer;
 	EMsgComposerPrivate *priv;
 	EComposerHeaderTable *table;
 	GtkToggleAction *action;
-	struct _camel_header_raw *xev;
+	GQueue *header_queue;
+	GQueue trash;
+	GList *link;
 	gint len, i;
 
-	for (headers = CAMEL_MIME_PART (message)->headers;headers;headers = headers->next) {
-		if (!strcmp (headers->name, "X-Evolution-PostTo"))
-			postto = g_list_append (postto, g_strstrip (g_strdup (headers->value)));
+	mime_part = CAMEL_MIME_PART (message);
+	header_queue = camel_mime_part_get_raw_headers (mime_part);
+
+	link = g_queue_peek_head_link (header_queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *raw_header = link->data;
+		const gchar *name, *value;
+
+		name = camel_header_raw_get_name (raw_header);
+		value = camel_header_raw_get_value (raw_header);
+
+		if (strcmp (name, "X-Evolution-PostTo") == 0)
+			postto = g_list_append (
+				postto, g_strstrip (g_strdup (value)));
+
+		link = g_list_next (link);
 	}
 
 	composer = e_msg_composer_new ();
@@ -2930,8 +2929,9 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
 	}
 
 	/* Remove any other X-Evolution-* headers that may have been set */
-	xev = emcu_remove_xevolution_headers (message);
-	camel_header_raw_clear (&xev);
+	g_queue_init (&trash);
+	camel_header_raw_extract_prefix (header_queue, &trash, "X-Evolution");
+	camel_header_raw_clear (&trash);
 
 	/* Check for receipt request */
 	if (camel_medium_get_header (CAMEL_MEDIUM (message), "Disposition-Notification-To")) {
@@ -2946,23 +2946,30 @@ e_msg_composer_new_with_message (CamelMimeMessage *message)
 	}
 
 	/* set extra headers */
-	headers = CAMEL_MIME_PART (message)->headers;
-	while (headers) {
-		if (g_ascii_strcasecmp (headers->name, "References") == 0 ||
-		    g_ascii_strcasecmp (headers->name, "In-Reply-To") == 0) {
+	link = g_queue_peek_head_link (header_queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *raw_header = link->data;
+		const gchar *name, *value;
+
+		name = camel_header_raw_get_name (raw_header);
+		value = camel_header_raw_get_value (raw_header);
+
+		if (g_ascii_strcasecmp (name, "References") == 0 ||
+		    g_ascii_strcasecmp (name, "In-Reply-To") == 0) {
 			g_ptr_array_add (
 				composer->priv->extra_hdr_names,
-				g_strdup (headers->name));
+				g_strdup (name));
 			g_ptr_array_add (
 				composer->priv->extra_hdr_values,
-				g_strdup (headers->value));
+				g_strdup (value));
 		}
 
-		headers = headers->next;
+		link = g_list_next (link);
 	}
 
 	/* Restore the attachments and body text */
-	content = camel_medium_get_content_object (CAMEL_MEDIUM (message));
+	content = camel_medium_get_content (CAMEL_MEDIUM (message));
 	if (CAMEL_IS_MULTIPART (content)) {
 		CamelMultipart *multipart;
 
@@ -3552,7 +3559,7 @@ e_msg_composer_add_inline_image_from_file (EMsgComposer *composer,
 	g_free (mime_type);
 
 	part = camel_mime_part_new ();
-	camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
+	camel_medium_set_content (CAMEL_MEDIUM (part), wrapper);
 	g_object_unref (wrapper);
 
 	cid = camel_header_msgid_generate ();
diff --git a/e-util/e-signature-utils.c b/e-util/e-signature-utils.c
index f1c5282..5077dfc 100644
--- a/e-util/e-signature-utils.c
+++ b/e-util/e-signature-utils.c
@@ -171,7 +171,7 @@ e_read_signature_file (ESignature *signature,
 	input_stream = camel_stream_fs_new_with_fd (fd);
 
 	if (!is_html && convert_to_html) {
-		CamelStreamFilter *filtered_stream;
+		CamelStream *filtered_stream;
 		CamelMimeFilter *filter;
 		gint32 flags;
 
@@ -184,10 +184,11 @@ e_read_signature_file (ESignature *signature,
 			CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES |
 			CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES;
 		filter = camel_mime_filter_tohtml_new (flags, 0);
-		camel_stream_filter_add (filtered_stream, filter);
+		camel_stream_filter_add (
+			CAMEL_STREAM_FILTER (filtered_stream), filter);
 		g_object_unref (filter);
 
-		input_stream = (CamelStream *) filtered_stream;
+		input_stream = filtered_stream;
 	}
 
 	buffer = g_byte_array_new ();
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index 0162206..5ab39a5 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -433,17 +433,18 @@ emfq_format_message(EMFormat *emf, CamelStream *stream, CamelMimePart *part, con
 static void
 emfq_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart *part)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *html_filter;
 
-	filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream);
+	filtered_stream = camel_stream_filter_new ((CamelStream *) stream);
 	html_filter = camel_mime_filter_tohtml_new (CAMEL_MIME_FILTER_TOHTML_CONVERT_NL
 						    | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES
 						    | CAMEL_MIME_FILTER_TOHTML_ESCAPE_8BIT, 0);
-	camel_stream_filter_add(filtered_stream, html_filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), html_filter);
 	g_object_unref(html_filter);
 
-	em_format_format_text(emf, (CamelStream *)filtered_stream, (CamelDataWrapper *)part);
+	em_format_format_text(emf, filtered_stream, (CamelDataWrapper *)part);
 	g_object_unref(filtered_stream);
 }
 
@@ -472,7 +473,7 @@ emfq_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part,
 static void
 emfq_text_plain(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *html_filter;
 	CamelMimeFilter *sig_strip;
 	CamelMimeFilter *wrap_filter;
@@ -492,36 +493,39 @@ emfq_text_plain(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, E
 	    && !g_ascii_strcasecmp(format, "flowed"))
 		flags |= CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED;
 
-	filtered_stream = camel_stream_filter_new_with_stream(stream);
+	filtered_stream = camel_stream_filter_new (stream);
 
 	if ((emfq->flags & EM_FORMAT_QUOTE_KEEP_SIG) == 0) {
 		sig_strip = em_stripsig_filter_new ();
-		camel_stream_filter_add (filtered_stream, sig_strip);
+		camel_stream_filter_add (
+			CAMEL_STREAM_FILTER (filtered_stream), sig_strip);
 		g_object_unref (sig_strip);
 	}
 
 	wrap_filter = camel_mime_filter_linewrap_new (70, 70, 0, CAMEL_MIME_FILTER_LINEWRAP_WORD);
-	camel_stream_filter_add (filtered_stream, wrap_filter);
-	camel_object_unref (wrap_filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), wrap_filter);
+	g_object_unref (wrap_filter);
 
 	html_filter = camel_mime_filter_tohtml_new(flags, rgb);
-	camel_stream_filter_add(filtered_stream, html_filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), html_filter);
 	g_object_unref(html_filter);
 
-	em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, (CamelDataWrapper *)part);
-	camel_stream_flush((CamelStream *)filtered_stream);
+	em_format_format_text((EMFormat *)emfq, filtered_stream, (CamelDataWrapper *)part);
+	camel_stream_flush(filtered_stream);
 	g_object_unref(filtered_stream);
 }
 
 static void
 emfq_text_enriched(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *enriched;
 	CamelDataWrapper *dw;
 	guint32 flags = 0;
 
-	dw = camel_medium_get_content_object((CamelMedium *)part);
+	dw = camel_medium_get_content((CamelMedium *)part);
 
 	if (!strcmp(info->mime_type, "text/richtext")) {
 		flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
@@ -531,12 +535,13 @@ emfq_text_enriched(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part
 	}
 
 	enriched = camel_mime_filter_enriched_new(flags);
-	filtered_stream = camel_stream_filter_new_with_stream (stream);
-	camel_stream_filter_add(filtered_stream, enriched);
+	filtered_stream = camel_stream_filter_new (stream);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), enriched);
 	g_object_unref(enriched);
 
 	camel_stream_write_string(stream, "<br><hr><br>");
-	em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, (CamelDataWrapper *)part);
+	em_format_format_text((EMFormat *)emfq, filtered_stream, (CamelDataWrapper *)part);
 	g_object_unref(filtered_stream);
 }
 
diff --git a/em-format/em-format.c b/em-format/em-format.c
index fb13c0d..ac2c6ee 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -572,7 +572,7 @@ emf_clear_puri_node (GNode *node)
 		g_free(pn->cid);
 		g_free(pn->part_id);
 		if (pn->part)
-			camel_object_unref(pn->part);
+			g_object_unref(pn->part);
 		g_free(pn);
 	}
 
@@ -684,7 +684,7 @@ em_format_part(EMFormat *emf, CamelStream *stream, CamelMimePart *part)
 	gchar *mime_type;
 	CamelDataWrapper *dw;
 
-	dw = camel_medium_get_content_object((CamelMedium *)part);
+	dw = camel_medium_get_content((CamelMedium *)part);
 	mime_type = camel_data_wrapper_get_mime_type(dw);
 	if (mime_type) {
 		camel_strdown(mime_type);
@@ -1011,7 +1011,7 @@ void em_format_add_header(EMFormat *emf, const gchar *name, guint32 flags)
 gint em_format_is_attachment(EMFormat *emf, CamelMimePart *part)
 {
 	/*CamelContentType *ct = camel_mime_part_get_content_type(part);*/
-	CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)part);
+	CamelDataWrapper *dw = camel_medium_get_content((CamelMedium *)part);
 
 	if (!dw)
 		return 0;
@@ -1192,7 +1192,7 @@ em_format_busy (EMFormat *emf)
 void
 em_format_format_content(EMFormat *emf, CamelStream *stream, CamelMimePart *part)
 {
-	CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)part);
+	CamelDataWrapper *dw = camel_medium_get_content((CamelMedium *)part);
 
 	if (camel_content_type_is (dw->mime_type, "text", "*"))
 		em_format_format_text(emf, stream, (CamelDataWrapper *)part);
@@ -1211,8 +1211,8 @@ em_format_format_content(EMFormat *emf, CamelStream *stream, CamelMimePart *part
 void
 em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
 {
-	CamelStreamFilter *filter_stream;
-	CamelMimeFilterCharset *filter;
+	CamelStream *filter_stream;
+	CamelMimeFilter *filter;
 	const gchar *charset = NULL;
 	CamelMimeFilterWindows *windows = NULL;
 	CamelStream *mem_stream = NULL;
@@ -1233,14 +1233,16 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
 		 * before we move on... */
 
 		null = camel_stream_null_new();
-		filter_stream = camel_stream_filter_new_with_stream(null);
+		filter_stream = camel_stream_filter_new (null);
 		g_object_unref(null);
 
 		windows = (CamelMimeFilterWindows *)camel_mime_filter_windows_new(charset);
-		camel_stream_filter_add(filter_stream, (CamelMimeFilter *)windows);
+		camel_stream_filter_add (
+			CAMEL_STREAM_FILTER (filter_stream),
+			(CamelMimeFilter *)windows);
 
-		camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filter_stream);
-		camel_stream_flush((CamelStream *)filter_stream);
+		camel_data_wrapper_decode_to_stream(dw, filter_stream);
+		camel_stream_flush(filter_stream);
 		g_object_unref(filter_stream);
 
 		charset = camel_mime_filter_windows_real_charset (windows);
@@ -1249,10 +1251,11 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
 	}
 
 	mem_stream = (CamelStream *)camel_stream_mem_new ();
-	filter_stream = camel_stream_filter_new_with_stream(mem_stream);
+	filter_stream = camel_stream_filter_new (mem_stream);
 
-	if ((filter = camel_mime_filter_charset_new_convert(charset, "UTF-8"))) {
-		camel_stream_filter_add(filter_stream, (CamelMimeFilter *) filter);
+	if ((filter = camel_mime_filter_charset_new (charset, "UTF-8"))) {
+		camel_stream_filter_add (
+			CAMEL_STREAM_FILTER (filter_stream), filter);
 		g_object_unref(filter);
 	}
 
@@ -1266,9 +1269,9 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
 	}
 	g_object_unref (gconf);
 
-	size = camel_data_wrapper_decode_to_stream(emf->mode == EM_FORMAT_SOURCE ? (CamelDataWrapper *)dw: camel_medium_get_content_object((CamelMedium *)dw), (CamelStream *)filter_stream);
-	camel_stream_flush((CamelStream *)filter_stream);
-	g_object_unref(filter_stream);
+	size = camel_data_wrapper_decode_to_stream(emf->mode == EM_FORMAT_SOURCE ? (CamelDataWrapper *)dw: camel_medium_get_content((CamelMedium *)dw), filter_stream);
+	camel_stream_flush (filter_stream);
+	g_object_unref (filter_stream);
 	camel_stream_reset (mem_stream);
 
 	if (max == -1 || size == -1 || size < (max * 1024) || emf->composer) {
@@ -1381,7 +1384,7 @@ emf_application_xpkcs7mime(EMFormat *emf, CamelStream *stream, CamelMimePart *pa
 static void
 emf_multipart_appledouble(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
 {
-	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
+	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content((CamelMedium *)part);
 	CamelMimePart *mime_part;
 	gint len;
 
@@ -1406,7 +1409,7 @@ emf_multipart_appledouble(EMFormat *emf, CamelStream *stream, CamelMimePart *par
 static void
 emf_multipart_mixed(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
 {
-	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
+	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content((CamelMedium *)part);
 	gint i, nparts, len;
 
 	if (!CAMEL_IS_MULTIPART(mp)) {
@@ -1428,7 +1431,7 @@ emf_multipart_mixed(EMFormat *emf, CamelStream *stream, CamelMimePart *part, con
 static void
 emf_multipart_alternative(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
 {
-	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
+	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content((CamelMedium *)part);
 	gint i, nparts, bestid = 0;
 	CamelMimePart *best = NULL;
 
@@ -1494,7 +1497,7 @@ emf_multipart_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *part,
 		return;
 	}
 
-	mpe = (CamelMultipartEncrypted*)camel_medium_get_content_object((CamelMedium *)part);
+	mpe = (CamelMultipartEncrypted*)camel_medium_get_content((CamelMedium *)part);
 	if (!CAMEL_IS_MULTIPART_ENCRYPTED(mpe)) {
 		em_format_format_error(emf, stream, _("Could not parse MIME message. Displaying as source."));
 		em_format_format_source(emf, stream, part);
@@ -1548,7 +1551,7 @@ emf_write_related(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
 static void
 emf_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
 {
-	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
+	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content((CamelMedium *)part);
 	CamelMimePart *body_part, *display_part = NULL;
 	CamelContentType *content_type;
 	const gchar *start;
@@ -1655,7 +1658,7 @@ emf_multipart_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *part, co
 		return;
 	}
 
-	mps = (CamelMultipartSigned *)camel_medium_get_content_object((CamelMedium *)part);
+	mps = (CamelMultipartSigned *)camel_medium_get_content((CamelMedium *)part);
 	if (!CAMEL_IS_MULTIPART_SIGNED(mps)
 	    || (cpart = camel_multipart_get_part((CamelMultipart *)mps, CAMEL_MULTIPART_SIGNED_CONTENT)) == NULL) {
 		em_format_format_error(emf, stream, _("Could not parse MIME message. Displaying as source."));
@@ -1780,7 +1783,7 @@ emf_application_mbox (EMFormat *emf,
 static void
 emf_message_rfc822(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
 {
-	CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)part);
+	CamelDataWrapper *dw = camel_medium_get_content((CamelMedium *)part);
 	const EMFormatHandler *handle;
 	gint len;
 
@@ -1808,7 +1811,7 @@ emf_message_deliverystatus(EMFormat *emf, CamelStream *stream, CamelMimePart *pa
 static void
 emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilterPgp *pgp_filter;
 	CamelContentType *content_type;
 	CamelCipherContext *cipher;
@@ -1843,17 +1846,19 @@ emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, E
 
 	/* Setup output stream */
 	ostream = camel_stream_mem_new();
-	filtered_stream = camel_stream_filter_new_with_stream(ostream);
+	filtered_stream = camel_stream_filter_new (ostream);
 
 	/* Add PGP header / footer filter */
 	pgp_filter = (CamelMimeFilterPgp *)camel_mime_filter_pgp_new();
-	camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)pgp_filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream),
+		(CamelMimeFilter *)pgp_filter);
 	g_object_unref(pgp_filter);
 
 	/* Pass through the filters that have been setup */
-	dw = camel_medium_get_content_object((CamelMedium *)ipart);
-	camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filtered_stream);
-	camel_stream_flush((CamelStream *)filtered_stream);
+	dw = camel_medium_get_content((CamelMedium *)ipart);
+	camel_data_wrapper_decode_to_stream(dw, filtered_stream);
+	camel_stream_flush(filtered_stream);
 	g_object_unref(filtered_stream);
 
 	/* Create a new text/plain MIME part containing the signed content preserving the original part's Content-Type params */
@@ -1875,7 +1880,7 @@ emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, E
 	g_free (type);
 
 	opart = camel_mime_part_new ();
-	camel_medium_set_content_object ((CamelMedium *) opart, dw);
+	camel_medium_set_content ((CamelMedium *) opart, dw);
 	camel_data_wrapper_set_mime_type_field ((CamelDataWrapper *) opart, dw->mime_type);
 
 	add_validity_found (emf, valid);
@@ -1919,7 +1924,7 @@ emf_inlinepgp_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart
 		return;
 	}
 
-	dw = camel_medium_get_content_object ((CamelMedium *)opart);
+	dw = camel_medium_get_content ((CamelMedium *)opart);
 	mime_type = camel_data_wrapper_get_mime_type (dw);
 
 	/* this ensures to show the 'opart' as inlined, if possible */
@@ -2000,19 +2005,23 @@ em_format_snoop_type (CamelMimePart *part)
 	if (filename != NULL)
 		name_type = e_util_guess_mime_type (filename, FALSE);
 
-	dw = camel_medium_get_content_object((CamelMedium *)part);
+	dw = camel_medium_get_content((CamelMedium *)part);
 	if (!camel_data_wrapper_is_offline(dw)) {
-		CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new();
+		CamelStream *stream;
+		GByteArray *buffer;
 
-		if (camel_data_wrapper_decode_to_stream(dw, (CamelStream *)mem) > 0) {
-			gchar *ct = g_content_type_guess (filename, mem->buffer->data, mem->buffer->len, NULL);
+		buffer = g_byte_array_new ();
+		stream = camel_stream_mem_new_with_byte_array (buffer);
+
+		if (camel_data_wrapper_decode_to_stream(dw, stream) > 0) {
+			gchar *ct = g_content_type_guess (filename, buffer->data, buffer->len, NULL);
 
 			if (ct)
 				magic_type = g_content_type_get_mime_type (ct);
 
 			g_free (ct);
 		}
-		g_object_unref(mem);
+		g_object_unref(stream);
 	}
 
 	d(printf("snooped part, magic_type '%s' name_type '%s'\n", magic_type, name_type));
diff --git a/em-format/em-stripsig-filter.c b/em-format/em-stripsig-filter.c
index 42d8247..9afbc51 100644
--- a/em-format/em-stripsig-filter.c
+++ b/em-format/em-stripsig-filter.c
@@ -30,54 +30,51 @@
 
 #include "em-stripsig-filter.h"
 
-static void em_stripsig_filter_class_init (EMStripSigFilterClass *klass);
-static void em_stripsig_filter_init (EMStripSigFilter *filter, EMStripSigFilterClass *klass);
-
 static void filter_filter (CamelMimeFilter *filter, const gchar *in, gsize len, gsize prespace,
 			   gchar **out, gsize *outlen, gsize *outprespace);
 static void filter_complete (CamelMimeFilter *filter, const gchar *in, gsize len, gsize prespace,
 			     gchar **out, gsize *outlen, gsize *outprespace);
 static void filter_reset (CamelMimeFilter *filter);
 
-static CamelMimeFilterClass *parent_class = NULL;
-
-CamelType
-em_stripsig_filter_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_mime_filter_get_type (),
-					    "EMStripSigFilter",
-					    sizeof (EMStripSigFilter),
-					    sizeof (EMStripSigFilterClass),
-					    (CamelObjectClassInitFunc) em_stripsig_filter_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) em_stripsig_filter_init,
-					    NULL);
-	}
-
-	return type;
-}
+static gpointer parent_class;
 
 static void
-em_stripsig_filter_class_init (EMStripSigFilterClass *klass)
+stripsig_filter_class_init (EMStripSigFilterClass *class)
 {
-	CamelMimeFilterClass *filter_class = (CamelMimeFilterClass *) klass;
+	CamelMimeFilterClass *mime_filter_class;
 
-	parent_class = CAMEL_MIME_FILTER_CLASS (camel_type_get_global_classfuncs (camel_mime_filter_get_type ()));
+	parent_class = g_type_class_peek_parent (class);
 
-	filter_class->reset = filter_reset;
-	filter_class->filter = filter_filter;
-	filter_class->complete = filter_complete;
+	mime_filter_class = CAMEL_MIME_FILTER_CLASS (class);
+	mime_filter_class->reset = filter_reset;
+	mime_filter_class->filter = filter_filter;
+	mime_filter_class->complete = filter_complete;
 }
 
 static void
-em_stripsig_filter_init (EMStripSigFilter *filter, EMStripSigFilterClass *klass)
+stripsig_filter_init (EMStripSigFilter *filter)
 {
 	filter->midline = FALSE;
 }
 
+GType
+em_stripsig_filter_get_type (void)
+{
+	static GType type = G_TYPE_INVALID;
+
+	if (type == G_TYPE_INVALID)
+		type = g_type_register_static_simple (
+			CAMEL_TYPE_MIME_FILTER,
+			"EMStripSigFilter",
+			sizeof (EMStripSigFilterClass),
+			(GClassInitFunc) stripsig_filter_class_init,
+			sizeof (EMStripSigFilter),
+			(GInstanceInitFunc) stripsig_filter_init,
+			0);
+
+	return type;
+}
+
 static void
 strip_signature (CamelMimeFilter *filter, const gchar *in, gsize len, gsize prespace,
 		 gchar **out, gsize *outlen, gsize *outprespace, gint flush)
@@ -160,5 +157,5 @@ filter_reset (CamelMimeFilter *filter)
 CamelMimeFilter *
 em_stripsig_filter_new (void)
 {
-	return (CamelMimeFilter *) camel_object_new (EM_TYPE_STRIPSIG_FILTER);
+	return g_object_new (EM_TYPE_STRIPSIG_FILTER, NULL);
 }
diff --git a/em-format/em-stripsig-filter.h b/em-format/em-stripsig-filter.h
index 25ea239..2fce5f8 100644
--- a/em-format/em-stripsig-filter.h
+++ b/em-format/em-stripsig-filter.h
@@ -20,19 +20,31 @@
  *
  */
 
-#ifndef __EM_STRIPSIG_FILTER_H__
-#define __EM_STRIPSIG_FILTER_H__
+#ifndef EM_STRIPSIG_FILTER_H
+#define EM_STRIPSIG_FILTER_H
 
 #include <camel/camel.h>
 
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define EM_TYPE_STRIPSIG_FILTER \
+	(em_stripsig_filter_get_type ())
+#define EM_STRIPSIG_FILTER(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), EM_TYPE_STRIPSIG_FILTER, EMStripSigFilter))
+#define EM_STRIPSIG_FILTER_CLASS(cls) \
+	(G_TYPE_CHEKC_CLASS_CAST \
+	((cls), EM_TYPE_STRIPSIG_FILTER, EMStripSigFilterClass))
+#define EM_IS_STRIPSIG_FILTER(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), EM_TYPE_STRIPSIG_FILTER))
+#define EM_IS_STRIPSIG_FILTER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), EM_TYPE_STRIPSIG_FILTER))
+#define EM_STRIPSIG_FILTER_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), EM_TYPE_STRIPSIG_FILTER, EMStripSigFilterClass))
 
-#define EM_TYPE_STRIPSIG_FILTER            (em_stripsig_filter_get_type ())
-#define EM_STRIPSIG_FILTER(obj)            (CAMEL_CHECK_CAST ((obj), EM_TYPE_STRIPSIG_FILTER, EMStripSigFilter))
-#define EM_STRIPSIG_FILTER_CLASS(klass)    (CAMEL_CHECK_CLASS_CAST ((klass), EM_TYPE_STRIPSIG_FILTER, EMStripSigFilterClass))
-#define EM_IS_STRIPSIG_FILTER(obj)         (CAMEL_CHECK_TYPE ((obj), EM_TYPE_STRIPSIG_FILTER))
-#define EM_IS_STRIPSIG_FILTER_CLASS(klass) (CAMEL_CHECK_CLASS_TYPE ((klass), EM_TYPE_STRIPSIG_FILTER))
-#define EM_STRIPSIG_FILTER_GET_CLASS(obj)  (CAMEL_CHECK_GET_CLASS ((obj), EM_TYPE_STRIPSIG_FILTER, EMStripSigFilterClass))
+G_BEGIN_DECLS
 
 typedef struct _EMStripSigFilter EMStripSigFilter;
 typedef struct _EMStripSigFilterClass EMStripSigFilterClass;
@@ -45,13 +57,12 @@ struct _EMStripSigFilter {
 
 struct _EMStripSigFilterClass {
 	CamelMimeFilterClass parent_class;
-
 };
 
-CamelType em_stripsig_filter_get_type (void);
-
-CamelMimeFilter *em_stripsig_filter_new (void);
+GType		em_stripsig_filter_get_type	(void);
+CamelMimeFilter *
+		em_stripsig_filter_new		(void);
 
 G_END_DECLS
 
-#endif /* __EM_STRIPSIG_FILTER_H__ */
+#endif /* EM_STRIPSIG_FILTER_H */
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 7ef1c43..60e2350 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -378,7 +378,8 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 	CamelFolder *folder;
 	GtkWindow *window;
 	GtkHTML *html;
-	struct _camel_header_raw *header;
+	GQueue *queue;
+	GList *link;
 	const gchar *uid;
 	gchar *selection = NULL;
 	gint length;
@@ -413,15 +414,23 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 		CAMEL_MIME_MESSAGE (((EMFormat *) html_display)->message);
 	new_message = camel_mime_message_new ();
 
-	/* Filter out "content-*" headers. */
-	header = CAMEL_MIME_PART (src_message)->headers;
-	while (header != NULL) {
-		if (g_ascii_strncasecmp (header->name, "content-", 8) != 0)
+	/* Filter out "Content-*" headers. */
+	queue = camel_mime_part_get_raw_headers (
+		CAMEL_MIME_PART (src_message));
+	link = g_queue_peek_head_link (queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *raw_header = link->data;
+		const gchar *name, *value;
+
+		name = camel_header_raw_get_name (raw_header);
+		value = camel_header_raw_get_value (raw_header);
+
+		if (g_ascii_strncasecmp (name, "Content-", 8) != 0)
 			camel_medium_add_header (
-				CAMEL_MEDIUM (new_message),
-				header->name, header->value);
+				CAMEL_MEDIUM (new_message), name, value);
 
-		header = header->next;
+		link = g_list_next (link);
 	}
 
 	camel_mime_part_set_encoding (
diff --git a/mail/e-mail-tag-editor.h b/mail/e-mail-tag-editor.h
index b28674c..fe2365c 100644
--- a/mail/e-mail-tag-editor.h
+++ b/mail/e-mail-tag-editor.h
@@ -25,8 +25,7 @@
 #define E_MAIL_TAG_EDITOR_H
 
 #include <gtk/gtk.h>
-#include <camel/camel-folder.h>
-#include <camel/camel-folder-summary.h>
+#include <camel/camel.h>
 
 /* Standard GObject macros */
 #define E_TYPE_MAIL_TAG_EDITOR \
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 6874491..d751a5f 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -916,11 +916,12 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont
 		}
 	} else if (CAMEL_IS_MIME_PART (content)) {
 		CamelMimePart *part = CAMEL_MIME_PART (content);
+		GByteArray *byte_array;
 		CamelContentType *type;
 		CamelStream *mem;
 		gchar *str;
 
-		content = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+		content = camel_medium_get_content (CAMEL_MEDIUM (part));
 		if (!content)
 			return;
 
@@ -933,17 +934,20 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont
 		if (!camel_content_type_is (type, "text", "*"))
 			return;
 
-		mem = camel_stream_mem_new ();
+		byte_array = g_byte_array_new ();
+		mem = camel_stream_mem_new_with_byte_array (byte_array);
 		camel_data_wrapper_decode_to_stream (content, mem);
 
-		str = g_strndup ((const gchar *)((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len);
-		camel_object_unref (mem);
+		str = g_strndup (
+			(const gchar *) byte_array->data,
+			byte_array->len);
+		g_object_unref (mem);
 
 		if (replace_variables (clues, message, &str)) {
 			mem = camel_stream_mem_new_with_buffer (str, strlen (str));
 			camel_stream_reset (mem);
 			camel_data_wrapper_construct_from_stream (content, mem);
-			camel_object_unref (mem);
+			g_object_unref (mem);
 		}
 
 		g_free (str);
@@ -967,7 +971,7 @@ edit_message (CamelMimeMessage *message, CamelFolder *drafts, const gchar *uid)
 		clue_list = gconf_client_get_list ( gconf, GCONF_KEY_TEMPLATE_PLACEHOLDERS, GCONF_VALUE_STRING, NULL );
 		g_object_unref (gconf);
 
-		traverse_parts (clue_list, message, camel_medium_get_content_object (CAMEL_MEDIUM (message)));
+		traverse_parts (clue_list, message, camel_medium_get_content (CAMEL_MEDIUM (message)));
 
 		g_slist_foreach (clue_list, (GFunc) g_free, NULL);
 		g_slist_free (clue_list);
@@ -1216,7 +1220,7 @@ forward_non_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages,
 			composer = create_new_composer (subject, fromuri, FALSE);
 
 			if (composer) {
-				if (CAMEL_IS_MULTIPART(camel_medium_get_content_object((CamelMedium *)message)))
+				if (CAMEL_IS_MULTIPART(camel_medium_get_content((CamelMedium *)message)))
 					e_msg_composer_add_message_attachments(composer, message, FALSE);
 
 				e_msg_composer_set_body_text (composer, text, len);
@@ -1562,7 +1566,7 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message)
 	g_object_unref (stream);
 
 	part = camel_mime_part_new ();
-	camel_medium_set_content_object (CAMEL_MEDIUM (part), receipt_text);
+	camel_medium_set_content (CAMEL_MEDIUM (part), receipt_text);
 	camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE);
 	g_object_unref (receipt_text);
 	camel_multipart_add_part (body, part);
@@ -1593,14 +1597,14 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message)
 	g_free (recipient);
 	g_free (fake_msgid);
 
-	camel_medium_set_content_object (CAMEL_MEDIUM (part), receipt_data);
+	camel_medium_set_content (CAMEL_MEDIUM (part), receipt_data);
 	camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_7BIT);
 	g_object_unref (receipt_data);
 	camel_multipart_add_part (body, part);
 	g_object_unref (part);
 
 	/* Finish creating the message */
-	camel_medium_set_content_object (CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body));
+	camel_medium_set_content (CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body));
 	g_object_unref (body);
 
 	receipt_subject = g_strdup_printf ("Delivery Notification for: \"%s\"", message_subject);
@@ -1656,11 +1660,11 @@ em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, co
 {
 	EAccount *account;
 	CamelMimeMessage *forward;
-	CamelStream *mem;
+	CamelStream *stream;
 	CamelInternetAddress *addr;
 	CamelFolder *out_folder;
 	CamelMessageInfo *info;
-	struct _camel_header_raw *xev;
+	GQueue trash = G_QUEUE_INIT;
 	gchar *subject;
 
 	g_return_if_fail (folder != NULL);
@@ -1681,11 +1685,11 @@ em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, co
 	forward = camel_mime_message_new ();
 
 	/* make copy of the message, because we are going to modify it */
-	mem = camel_stream_mem_new ();
-	camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, mem);
-	camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (mem), 0, CAMEL_STREAM_SET);
-	camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, mem);
-	g_object_unref (mem);
+	stream = camel_stream_mem_new ();
+	camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, stream);
+	camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (stream), 0, CAMEL_STREAM_SET);
+	camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, stream);
+	g_object_unref (stream);
 
 	/* clear previous recipients */
 	camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_TO, NULL);
@@ -1703,8 +1707,8 @@ em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, co
 		camel_medium_remove_header (CAMEL_MEDIUM (forward), "Delivered-To");
 
 	/* remove any X-Evolution-* headers that may have been set */
-	xev = mail_tool_remove_xevolution_headers (forward);
-	camel_header_raw_clear (&xev);
+	mail_tool_remove_xevolution_headers (forward, &trash);
+	camel_header_raw_clear (&trash);
 
 	/* from */
 	addr = camel_internet_address_new ();
diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c
index 432227c..bf185ce 100644
--- a/mail/em-filter-source-element.c
+++ b/mail/em-filter-source-element.c
@@ -44,7 +44,7 @@ static gint source_eq(EFilterElement *fe, EFilterElement *cm);
 static void xml_create(EFilterElement *fe, xmlNodePtr node);
 static xmlNodePtr xml_encode(EFilterElement *fe);
 static gint xml_decode(EFilterElement *fe, xmlNodePtr node);
-static EFilterElement *clone(EFilterElement *fe);
+static EFilterElement *filter_clone(EFilterElement *fe);
 static GtkWidget *get_widget(EFilterElement *fe);
 static void build_code(EFilterElement *fe, GString *out, EFilterPart *ff);
 static void format_sexp(EFilterElement *, GString *);
@@ -106,7 +106,7 @@ em_filter_source_element_class_init(EMFilterSourceElementClass *klass)
 	fe_class->xml_create = xml_create;
 	fe_class->xml_encode = xml_encode;
 	fe_class->xml_decode = xml_decode;
-	fe_class->clone = clone;
+	fe_class->clone = filter_clone;
 	fe_class->get_widget = get_widget;
 	fe_class->build_code = build_code;
 	fe_class->format_sexp = format_sexp;
@@ -212,7 +212,7 @@ xml_decode(EFilterElement *fe, xmlNodePtr node)
 }
 
 static EFilterElement *
-clone(EFilterElement *fe)
+filter_clone(EFilterElement *fe)
 {
 	EMFilterSourceElement *fs = (EMFilterSourceElement *)fe;
 	EMFilterSourceElement *cpy = em_filter_source_element_new();
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 08d2e18..8fb063b 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -464,11 +464,13 @@ efhd_format_optional (EMFormat *emf,
 {
 	gchar *classid, *html;
 	struct _attach_puri *info;
-	CamelStream *stream;
+	CamelStream *stream = NULL;
 
-	if (CAMEL_IS_STREAM_FILTER (fstream) && ((CamelStreamFilter *) fstream)->source)
-		stream = ((CamelStreamFilter *) fstream)->source;
-	else
+	if (CAMEL_IS_STREAM_FILTER (fstream))
+		stream = camel_stream_filter_get_source (
+			CAMEL_STREAM_FILTER (fstream));
+
+	if (stream == NULL)
 		stream = fstream;
 
 	classid = g_strdup_printf ("optional%s", emf->part_id->str);
@@ -669,7 +671,7 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc)
 static void
 efhd_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
 {
-	CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)puri->part);
+	CamelDataWrapper *dw = camel_medium_get_content((CamelMedium *)puri->part);
 
 	/* TODO: identical to efh_write_image */
 	d(printf("writing image '%s'\n", puri->cid));
@@ -933,6 +935,7 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb
 	AtkObject *a11y;
 	GtkWidget *view;
 	GtkTextBuffer *buffer;
+	GByteArray *byte_array;
 
 	/* FIXME: handle default shown case */
 	d(printf("adding attachment button/content for optional rendering\n"));
@@ -990,7 +993,8 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb
 	gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
 	gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
 	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (view));
-	gtk_text_buffer_set_text (buffer, (gchar *)info->mstream->buffer->data, info->mstream->buffer->len);
+	byte_array = camel_stream_mem_get_byte_array (info->mstream);
+	gtk_text_buffer_set_text (buffer, (gchar *)byte_array->data, byte_array->len);
 	g_object_unref(info->mstream);
 	info->mstream = NULL;
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index a84f808..cc3c7d2 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -668,21 +668,22 @@ efh_format_source (EMFormat *emf,
                    CamelStream *stream,
                    CamelMimePart *part)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *filter;
 	CamelDataWrapper *dw = (CamelDataWrapper *) part;
 
-	filtered_stream = camel_stream_filter_new_with_stream (stream);
+	filtered_stream = camel_stream_filter_new (stream);
 
 	filter = camel_mime_filter_tohtml_new (
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
 		CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT, 0);
-	camel_stream_filter_add (filtered_stream, filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), filter);
 	g_object_unref (filter);
 
 	camel_stream_write_string (stream, "<table><tr><td><tt>");
-	em_format_format_text (emf, (CamelStream *) filtered_stream, dw);
+	em_format_format_text (emf, filtered_stream, dw);
 	g_object_unref (filtered_stream);
 
 	camel_stream_write_string(stream, "</tt></td></tr></table>");
@@ -882,7 +883,7 @@ efh_class_init (EMFormatHTMLClass *class)
 	/* cache expiry - 2 hour access, 1 day max */
 	pathname = g_build_filename (
 		e_get_user_data_dir (), "cache", NULL);
-	emfh_http_cache = camel_data_cache_new (pathname, 0, NULL);
+	emfh_http_cache = camel_data_cache_new (pathname, NULL);
 	if (emfh_http_cache) {
 		camel_data_cache_set_expire_age(emfh_http_cache, 24*60*60);
 		camel_data_cache_set_expire_access(emfh_http_cache, 2*60*60);
@@ -1181,7 +1182,7 @@ em_format_html_file_part(EMFormatHTML *efh, const gchar *mime_type, const gchar
 	if (mime_type)
 		camel_data_wrapper_set_mime_type(dw, mime_type);
 	part = camel_mime_part_new();
-	camel_medium_set_content_object((CamelMedium *)part, dw);
+	camel_medium_set_content((CamelMedium *)part, dw);
 	g_object_unref(dw);
 	basename = g_path_get_basename (filename);
 	camel_mime_part_set_filename(part, basename);
@@ -1370,7 +1371,7 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, gint cancelled)
 		camel_operation_start(NULL, _("Retrieving `%s'"), job->u.uri);
 		tmp_stream = (CamelHttpStream *)instream;
 		content_type = camel_http_stream_get_content_type(tmp_stream);
-		length = camel_header_raw_find(&tmp_stream->headers, "Content-Length", NULL);
+		length = camel_header_raw_find(tmp_stream->raw_headers, "Content-Length", NULL);
 		d(printf("  Content-Length: %s\n", length));
 		if (length != NULL)
 			total = atoi(length);
@@ -1440,7 +1441,7 @@ efh_url_requested(GtkHTML *html, const gchar *url, GtkHTMLStream *handle, EMForm
 
 	puri = em_format_find_visible_puri((EMFormat *)efh, url);
 	if (puri) {
-		CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)puri->part);
+		CamelDataWrapper *dw = camel_medium_get_content((CamelMedium *)puri->part);
 		CamelContentType *ct = dw?dw->mime_type:NULL;
 
 		/* GtkHTML only handles text and images.
@@ -1591,7 +1592,7 @@ efh_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, Camel
 static void
 efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *html_filter;
 	CamelMultipart *mp;
 	CamelDataWrapper *dw;
@@ -1610,7 +1611,7 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
 	is_fallback = meta != NULL;
 	g_free (meta);
 
-	dw = camel_medium_get_content_object((CamelMedium *)part);
+	dw = camel_medium_get_content ((CamelMedium *)part);
 
 	/* Check for RFC 2646 flowed text. */
 	if (camel_content_type_is(dw->mime_type, "text", "plain")
@@ -1644,12 +1645,14 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
 		}
 
 		null = camel_stream_null_new();
-		filtered_stream = camel_stream_filter_new_with_stream(null);
+		filtered_stream = camel_stream_filter_new (null);
 		g_object_unref(null);
 		inline_filter = em_inline_filter_new(camel_mime_part_get_encoding(part), ct);
-		camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)inline_filter);
-		camel_data_wrapper_write_to_stream(dw, (CamelStream *)filtered_stream);
-		camel_stream_close((CamelStream *)filtered_stream);
+		camel_stream_filter_add (
+			CAMEL_STREAM_FILTER (filtered_stream),
+			(CamelMimeFilter *)inline_filter);
+		camel_data_wrapper_write_to_stream(dw, filtered_stream);
+		camel_stream_close(filtered_stream);
 		g_object_unref(filtered_stream);
 
 		mp = em_inline_filter_get_multipart(inline_filter);
@@ -1663,9 +1666,10 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
 
 	rgb = e_color_to_value (
 		&efh->priv->colors[EM_FORMAT_HTML_COLOR_CITATION]);
-	filtered_stream = camel_stream_filter_new_with_stream(stream);
+	filtered_stream = camel_stream_filter_new (stream);
 	html_filter = camel_mime_filter_tohtml_new(flags, rgb);
-	camel_stream_filter_add(filtered_stream, html_filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), html_filter);
 	g_object_unref(html_filter);
 
 	/* We handle our made-up multipart here, so we don't recursively call ourselves */
@@ -1692,8 +1696,8 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
 					&efh->priv->colors[
 					EM_FORMAT_HTML_COLOR_TEXT]));
 			camel_stream_write_string(stream, "<tt>\n" EFH_MESSAGE_START);
-			em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)newpart);
-			camel_stream_flush((CamelStream *)filtered_stream);
+			em_format_format_text((EMFormat *)efh, filtered_stream, (CamelDataWrapper *)newpart);
+			camel_stream_flush(filtered_stream);
 			camel_stream_write_string(stream, "</tt>\n");
 			camel_stream_write_string(stream, "</div>\n");
 		} else {
@@ -1709,12 +1713,12 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
 static void
 efh_text_enriched(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *enriched;
 	CamelDataWrapper *dw;
 	guint32 flags = 0;
 
-	dw = camel_medium_get_content_object((CamelMedium *)part);
+	dw = camel_medium_get_content((CamelMedium *)part);
 
 	if (!strcmp(info->mime_type, "text/richtext")) {
 		flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
@@ -1724,8 +1728,9 @@ efh_text_enriched(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, E
 	}
 
 	enriched = camel_mime_filter_enriched_new(flags);
-	filtered_stream = camel_stream_filter_new_with_stream (stream);
-	camel_stream_filter_add(filtered_stream, enriched);
+	filtered_stream = camel_stream_filter_new (stream);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), enriched);
 	g_object_unref(enriched);
 
 	camel_stream_printf (
@@ -1740,7 +1745,7 @@ efh_text_enriched(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, E
 			&efh->priv->colors[
 			EM_FORMAT_HTML_COLOR_TEXT]));
 
-	em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)part);
+	em_format_format_text((EMFormat *)efh, filtered_stream, (CamelDataWrapper *)part);
 
 	g_object_unref(filtered_stream);
 	camel_stream_write_string(stream, "</div>");
@@ -1757,7 +1762,7 @@ efh_write_text_html(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
 	fd = dup(STDOUT_FILENO);
 	out = camel_stream_fs_new_with_fd(fd);
 	printf("writing text content to frame '%s'\n", puri->cid);
-	dw = camel_medium_get_content_object(puri->part);
+	dw = camel_medium_get_content(puri->part);
 	if (dw)
 		camel_data_wrapper_write_to_stream(dw, out);
 	g_object_unref(out);
@@ -1916,7 +1921,7 @@ fail:
 static void
 efh_message_deliverystatus(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
 {
-	CamelStreamFilter *filtered_stream;
+	CamelStream *filtered_stream;
 	CamelMimeFilter *html_filter;
 	guint32 rgb = 0x737373;
 
@@ -1933,14 +1938,15 @@ efh_message_deliverystatus(EMFormatHTML *efh, CamelStream *stream, CamelMimePart
 			&efh->priv->colors[
 			EM_FORMAT_HTML_COLOR_TEXT]));
 
-	filtered_stream = camel_stream_filter_new_with_stream(stream);
+	filtered_stream = camel_stream_filter_new (stream);
 	html_filter = camel_mime_filter_tohtml_new(efh->text_html_flags, rgb);
-	camel_stream_filter_add(filtered_stream, html_filter);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), html_filter);
 	g_object_unref(html_filter);
 
 	camel_stream_write_string(stream, "<tt>\n" EFH_MESSAGE_START);
-	em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)part);
-	camel_stream_flush((CamelStream *)filtered_stream);
+	em_format_format_text((EMFormat *)efh, filtered_stream, (CamelDataWrapper *)part);
+	camel_stream_flush(filtered_stream);
 	camel_stream_write_string(stream, "</tt>\n");
 
 	camel_stream_write_string(stream, "</div>");
@@ -1999,7 +2005,7 @@ emfh_multipart_related_check(struct _EMFormatHTMLJob *job, gint cancelled)
 static void
 efh_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
 {
-	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
+	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content((CamelMedium *)part);
 	CamelMimePart *body_part, *display_part = NULL;
 	CamelContentType *content_type;
 	const gchar *start;
@@ -2074,7 +2080,7 @@ efh_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c
 static void
 efh_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
 {
-	CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)puri->part);
+	CamelDataWrapper *dw = camel_medium_get_content((CamelMedium *)puri->part);
 
 	d(printf("writing image '%s'\n", puri->cid));
 	camel_data_wrapper_decode_to_stream(dw, stream);
@@ -2203,7 +2209,7 @@ static const gchar *addrspec_hdrs[] = {
 };
 
 static gchar *
-efh_format_address (EMFormatHTML *efh, GString *out, struct _camel_header_address *a, gchar *field)
+efh_format_address (EMFormatHTML *efh, GString *out, struct _camel_header_address *a, const gchar *field)
 {
 	guint32 flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES;
 	gchar *name, *mailto, *addr;
@@ -2336,17 +2342,27 @@ canon_header_name (gchar *name)
 }
 
 static void
-efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct _camel_header_raw *header, guint32 flags, const gchar *charset)
+efh_format_header (EMFormat *emf,
+                   CamelStream *stream,
+                   CamelMedium *part,
+                   CamelHeaderRaw *raw_header,
+                   guint32 flags,
+                   const gchar *charset)
 {
 	EMFormatHTML *efh = (EMFormatHTML *)emf;
 	gchar *name, *buf, *value = NULL;
 	const gchar *label, *txt;
+	const gchar *header_name;
+	const gchar *header_value;
 	gboolean addrspec = FALSE;
 	gchar *str_field = NULL;
 	gint i;
 
-	name = alloca(strlen(header->name)+1);
-	strcpy(name, header->name);
+	header_name = camel_header_raw_get_name (raw_header);
+	header_value = camel_header_raw_get_value (raw_header);
+
+	name = alloca(strlen(header_name)+1);
+	strcpy(name, header_name);
 	canon_header_name (name);
 
 	for (i = 0; addrspec_hdrs[i]; i++) {
@@ -2363,7 +2379,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
 		GString *html;
 		gchar *img;
 
-		buf = camel_header_unfold (header->value);
+		buf = camel_header_unfold (header_value);
 		if (!(addrs = camel_header_address_decode (buf, emf->charset ? emf->charset : emf->default_charset))) {
 			g_free (buf);
 			return;
@@ -2387,7 +2403,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
 
 		flags |= EM_FORMAT_HEADER_BOLD | EM_FORMAT_HTML_HEADER_HTML;
 	} else if (!strcmp (name, "Subject")) {
-		buf = camel_header_unfold (header->value);
+		buf = camel_header_unfold (header_value);
 		txt = value = camel_header_decode_string (buf, charset);
 		g_free (buf);
 
@@ -2395,7 +2411,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
 	} else if (!strcmp(name, "X-evolution-mailer")) {
 		/* pseudo-header */
 		label = _("Mailer");
-		txt = value = camel_header_format_ctext (header->value, charset);
+		txt = value = camel_header_format_ctext (header_value, charset);
 		flags |= EM_FORMAT_HEADER_BOLD;
 	} else if (!strcmp (name, "Date") || !strcmp (name, "Resent-Date")) {
 		gint msg_offset, local_tz;
@@ -2406,7 +2422,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
 
 		hide_real_date = !em_format_html_get_show_real_date (efh);
 
-		txt = header->value;
+		txt = header_value;
 		while (*txt == ' ' || *txt == '\t')
 			txt++;
 
@@ -2446,7 +2462,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
 		struct _camel_header_newsgroup *ng, *scan;
 		GString *html;
 
-		buf = camel_header_unfold (header->value);
+		buf = camel_header_unfold (header_value);
 
 		if (!(ng = camel_header_newsgroups_decode (buf))) {
 			g_free (buf);
@@ -2471,10 +2487,10 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
 		flags |= EM_FORMAT_HEADER_BOLD|EM_FORMAT_HTML_HEADER_HTML;
 	} else if (!strcmp (name, "Received") || !strncmp (name, "X-", 2)) {
 		/* don't unfold Received nor extension headers */
-		txt = value = camel_header_decode_string(header->value, charset);
+		txt = value = camel_header_decode_string(header_value, charset);
 	} else {
 		/* don't unfold Received nor extension headers */
-		buf = camel_header_unfold (header->value);
+		buf = camel_header_unfold (header_value);
 		txt = value = camel_header_decode_string (buf, charset);
 		g_free (buf);
 	}
@@ -2491,10 +2507,12 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
 	EMFormat *emf = (EMFormat *) efh;
 	const gchar *charset;
 	CamelContentType *ct;
-	struct _camel_header_raw *header;
 	gboolean have_icon = FALSE;
 	const gchar *photo_name = NULL;
 	CamelInternetAddress *cia = NULL;
+	CamelMimePart *mime_part;
+	GQueue *header_queue;
+	GList *link;
 	gboolean face_decoded  = FALSE, contact_has_photo = FALSE;
 	guchar *face_header_value = NULL;
 	gsize face_header_len = 0;
@@ -2502,6 +2520,8 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
 	gboolean mail_from_delegate = FALSE;
 	const gchar *hdr_charset;
 
+	/* FIXME For crying out loud, break this function up! */
+
 	if (!part)
 		return;
 
@@ -2519,43 +2539,53 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
 
 	hdr_charset = emf->charset ? emf->charset : emf->default_charset;
 
-	header = ((CamelMimePart *)part)->headers;
-	while (header) {
-		if (!g_ascii_strcasecmp (header->name, "Sender")) {
+	mime_part = CAMEL_MIME_PART (part);
+	header_queue = camel_mime_part_get_raw_headers (mime_part);
+	link = g_queue_peek_head_link (header_queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *raw_header = link->data;
+		const gchar *header_name;
+		const gchar *header_value;
+
+		header_name = camel_header_raw_get_name (raw_header);
+		header_value = camel_header_raw_get_value (raw_header);
+
+		if (!g_ascii_strcasecmp (header_name, "Sender")) {
 			struct _camel_header_address *addrs;
 			GString *html;
 
-			if (!(addrs = camel_header_address_decode (header->value, hdr_charset)))
+			if (!(addrs = camel_header_address_decode (header_value, hdr_charset)))
 				break;
 
 			html = g_string_new("");
-			name = efh_format_address(efh, html, addrs, header->name);
+			name = efh_format_address(efh, html, addrs, header_name);
 
 			header_sender = html->str;
 			camel_header_address_unref(addrs);
 
 			g_string_free(html, FALSE);
 			g_free (name);
-		} else if (!g_ascii_strcasecmp (header->name, "From")) {
+		} else if (!g_ascii_strcasecmp (header_name, "From")) {
 			struct _camel_header_address *addrs;
 			GString *html;
 
-			if (!(addrs = camel_header_address_decode (header->value, hdr_charset)))
+			if (!(addrs = camel_header_address_decode (header_value, hdr_charset)))
 				break;
 
 			html = g_string_new("");
-			name = efh_format_address(efh, html, addrs, header->name);
+			name = efh_format_address(efh, html, addrs, header_name);
 
 			header_from = html->str;
 			camel_header_address_unref(addrs);
 
 			g_string_free(html, FALSE);
 			g_free(name);
-		} else if (!g_ascii_strcasecmp (header->name, "X-Evolution-Mail-From-Delegate")) {
+		} else if (!g_ascii_strcasecmp (header_name, "X-Evolution-Mail-From-Delegate")) {
 			mail_from_delegate = TRUE;
 		}
 
-		header = header->next;
+		link = g_list_next (link);
 	}
 
 	if (header_sender && header_from && mail_from_delegate) {
@@ -2581,10 +2611,12 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
 
 	/* dump selected headers */
 	if (emf->mode == EM_FORMAT_ALLHEADERS) {
-		header = ((CamelMimePart *)part)->headers;
-		while (header) {
-			efh_format_header(emf, stream, part, header, EM_FORMAT_HTML_HEADER_NOCOLUMNS, charset);
-			header = header->next;
+		link = g_queue_peek_head_link (header_queue);
+		while (link != NULL) {
+			efh_format_header(
+				emf, stream, part, link->data,
+				EM_FORMAT_HTML_HEADER_NOCOLUMNS, charset);
+			link = g_list_next (link);
 		}
 	} else {
 		GList *link;
@@ -2596,44 +2628,62 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
 			EMFormatHeader *h = link->data;
 			gint mailer, face;
 
-			header = ((CamelMimePart *)part)->headers;
+			link = g_queue_peek_head_link (header_queue);
+
 			mailer = !g_ascii_strcasecmp (h->name, "X-Evolution-Mailer");
 			face = !g_ascii_strcasecmp (h->name, "Face");
 
-			while (header) {
+			while (link != NULL) {
+				CamelHeaderRaw *raw_header = link->data;
+				const gchar *header_name;
+				const gchar *header_value;
+
+				header_name = camel_header_raw_get_name (raw_header);
+				header_value = camel_header_raw_get_value (raw_header);
+
 				if (em_format_html_get_show_sender_photo (efh) &&
-					!photo_name && !g_ascii_strcasecmp (header->name, "From"))
-					photo_name = header->value;
-
-				if (!mailer_shown && mailer && (!g_ascii_strcasecmp (header->name, "X-Mailer") ||
-								!g_ascii_strcasecmp (header->name, "User-Agent") ||
-								!g_ascii_strcasecmp (header->name, "X-Newsreader") ||
-								!g_ascii_strcasecmp (header->name, "X-MimeOLE"))) {
-					struct _camel_header_raw xmailer, *use_header = NULL;
-
-					if (!g_ascii_strcasecmp (header->name, "X-MimeOLE")) {
-						for (use_header = header->next; use_header; use_header = use_header->next) {
-							if (!g_ascii_strcasecmp (use_header->name, "X-Mailer") ||
-							    !g_ascii_strcasecmp (use_header->name, "User-Agent") ||
-							    !g_ascii_strcasecmp (use_header->name, "X-Newsreader")) {
+					!photo_name && !g_ascii_strcasecmp (header_name, "From"))
+					photo_name = header_value;
+
+				if (!mailer_shown && mailer && (!g_ascii_strcasecmp (header_name, "X-Mailer") ||
+								!g_ascii_strcasecmp (header_name, "User-Agent") ||
+								!g_ascii_strcasecmp (header_name, "X-Newsreader") ||
+								!g_ascii_strcasecmp (header_name, "X-MimeOLE"))) {
+					CamelHeaderRaw *mailer_header;
+					GQueue mailer_queue = G_QUEUE_INIT;
+					GList *mailer_link = NULL;
+					const gchar *mailer_value;
+
+					if (!g_ascii_strcasecmp (header_name, "X-MimeOLE")) {
+						for (mailer_link = link->next; mailer_link != NULL; mailer_link = mailer_link->next) {
+							CamelHeaderRaw *mailer_header = mailer_link->data;
+							const gchar *mailer_name;
+
+							mailer_name = camel_header_raw_get_name (mailer_header);
+
+							if (!g_ascii_strcasecmp (mailer_name, "X-Mailer") ||
+							    !g_ascii_strcasecmp (mailer_name, "User-Agent") ||
+							    !g_ascii_strcasecmp (mailer_name, "X-Newsreader")) {
 								/* even we have X-MimeOLE, then use rather the standard one, when available */
 								break;
 							}
 						}
 					}
 
-					if (!use_header)
-						use_header = header;
+					if (mailer_link == NULL)
+						mailer_link = link;
 
-					xmailer.name = (gchar *) "X-Evolution-Mailer";
-					xmailer.value = use_header->value;
+					mailer_header = mailer_link->data;
+					mailer_value = camel_header_raw_get_value (mailer_header);
+					camel_header_raw_append (&mailer_queue, "X-Evolution-Mailer", mailer_value, -1);
 					mailer_shown = TRUE;
 
-					efh_format_header (emf, stream, part, &xmailer, h->flags, charset);
-					if (strstr(use_header->value, "Evolution"))
+					efh_format_header (emf, stream, part, mailer_header, h->flags, charset);
+					if (strstr(mailer_value, "Evolution"))
 						have_icon = TRUE;
-				} else if (!face_decoded && face && !g_ascii_strcasecmp (header->name, "Face")) {
-					gchar *cp = header->value;
+					camel_header_raw_clear (&mailer_queue);
+				} else if (!face_decoded && face && !g_ascii_strcasecmp (header_name, "Face")) {
+					const gchar *cp = header_value;
 
 					/* Skip over spaces */
 					while (*cp == ' ')
@@ -2644,11 +2694,11 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
 					face_header_value[face_header_len] = 0;
 					face_decoded = TRUE;
 				/* Showing an encoded "Face" header makes little sense */
-				} else if (!g_ascii_strcasecmp (header->name, h->name) && !face) {
-					efh_format_header(emf, stream, part, header, h->flags, charset);
+				} else if (!g_ascii_strcasecmp (header_name, h->name) && !face) {
+					efh_format_header(emf, stream, part, raw_header, h->flags, charset);
 				}
 
-				header = header->next;
+				link = g_list_next (link);
 			}
 
 			link = g_list_next (link);
diff --git a/mail/em-html-stream.c b/mail/em-html-stream.c
index cc3c795..d2f5770 100644
--- a/mail/em-html-stream.c
+++ b/mail/em-html-stream.c
@@ -56,6 +56,20 @@ emhs_gtkhtml_destroy (GtkHTML *html,
 	emhs_cleanup (emhs);
 }
 
+static void
+em_html_stream_dispose (GObject *object)
+{
+	EMHTMLStream *emhs = EM_HTML_STREAM (object);
+
+	if (emhs->html_stream != NULL) {
+		/* set 'in finalise' flag */
+		camel_stream_close (CAMEL_STREAM (emhs));
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
 static gssize
 emhs_sync_write (CamelStream *stream,
                  const gchar *buffer,
@@ -105,9 +119,13 @@ emhs_sync_close (CamelStream *stream)
 static void
 em_html_stream_class_init (EMHTMLStreamClass *class)
 {
+	GObjectClass *object_class;
 	EMSyncStreamClass *sync_stream_class;
 
-	parent_class = (EMSyncStreamClass *)em_sync_stream_get_type();
+	parent_class = g_type_class_peek_parent (class);
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = em_html_stream_dispose;
 
 	sync_stream_class = EM_SYNC_STREAM_CLASS (class);
 	sync_stream_class->sync_write = emhs_sync_write;
@@ -115,35 +133,20 @@ em_html_stream_class_init (EMHTMLStreamClass *class)
 	sync_stream_class->sync_close = emhs_sync_close;
 }
 
-static void
-em_html_stream_init (EMHTMLStream *emhs)
-{
-}
-
-static void
-em_html_stream_finalize (EMHTMLStream *emhs)
-{
-	if (emhs->html_stream) {
-		/* set 'in finalise' flag */
-		camel_stream_close (CAMEL_STREAM (emhs));
-	}
-}
-
-CamelType
+GType
 em_html_stream_get_type (void)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
+	static GType type = G_TYPE_INVALID;
 
-	if (G_UNLIKELY (type == CAMEL_INVALID_TYPE)) {
-		type = camel_type_register (
-			em_sync_stream_get_type(),
+	if (G_UNLIKELY (type == G_TYPE_INVALID)) {
+		type = g_type_register_static_simple (
+			EM_TYPE_SYNC_STREAM,
 			"EMHTMLStream",
-			sizeof (EMHTMLStream),
 			sizeof (EMHTMLStreamClass),
-			(CamelObjectClassInitFunc) em_html_stream_class_init,
-			NULL,
-			(CamelObjectInitFunc) em_html_stream_init,
-			(CamelObjectFinalizeFunc) em_html_stream_finalize);
+			(GClassInitFunc) em_html_stream_class_init,
+			sizeof (EMHTMLStream),
+			(GInstanceInitFunc) NULL,
+			0);
 	}
 
 	return type;
@@ -159,7 +162,7 @@ em_html_stream_new (GtkHTML *html,
 
 	g_return_val_if_fail (GTK_IS_HTML (html), NULL);
 
-	new = EM_HTML_STREAM (camel_object_new (EM_HTML_STREAM_TYPE));
+	new = g_object_new (EM_TYPE_HTML_STREAM, NULL);
 	new->html_stream = html_stream;
 	new->html = g_object_ref (html);
 	new->flags = 0;
diff --git a/mail/em-html-stream.h b/mail/em-html-stream.h
index 7bf7947..a712d87 100644
--- a/mail/em-html-stream.h
+++ b/mail/em-html-stream.h
@@ -28,17 +28,23 @@
 #include <gtkhtml/gtkhtml-stream.h>
 #include <mail/em-sync-stream.h>
 
-#define EM_HTML_STREAM_TYPE \
+#define EM_TYPE_HTML_STREAM \
 	(em_html_stream_get_type ())
 #define EM_HTML_STREAM(obj) \
-	(CAMEL_CHECK_CAST \
-	((obj), EM_HTML_STREAM_TYPE, EMHTMLStream))
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), EM_TYPE_HTML_STREAM, EMHTMLStream))
 #define EM_HTML_STREAM_CLASS(cls) \
-	(CAMEL_CHECK_CLASS_CAST \
-	((cls), EM_HTML_STREAM_TYPE, EMHTMLStreamClass))
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), EM_TYPE_HTML_STREAM, EMHTMLStreamClass))
 #define EM_IS_HTML_STREAM(obj) \
-	(CAMEL_CHECK_TYPE \
-	((obj), EM_HTML_STREAM_TYPE))
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), EM_TYPE_HTML_STREAM))
+#define EM_IS_HTML_STREAM_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), EM_TYPE_HTML_STREAM))
+#define EM_HTML_STREAM_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), EM_TYPE_HTML_STREAM, EMHTMLStreamClass))
 
 G_BEGIN_DECLS
 
@@ -59,7 +65,7 @@ struct _EMHTMLStreamClass {
 
 };
 
-CamelType	em_html_stream_get_type		(void);
+GType		em_html_stream_get_type		(void);
 CamelStream *	em_html_stream_new		(GtkHTML *html,
 						 GtkHTMLStream *html_stream);
 void		em_html_stream_set_flags	(EMHTMLStream *emhs,
diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c
index 1b2e590..835a022 100644
--- a/mail/em-inline-filter.c
+++ b/mail/em-inline-filter.c
@@ -34,64 +34,67 @@
 
 #define d(x)
 
-static void em_inline_filter_class_init (EMInlineFilterClass *klass);
-static void em_inline_filter_init (CamelObject *object);
-static void em_inline_filter_finalize (CamelObject *object);
-
 static void emif_filter(CamelMimeFilter *f, const gchar *in, gsize len, gsize prespace, gchar **out, gsize *outlen, gsize *outprespace);
 static void emif_complete(CamelMimeFilter *f, const gchar *in, gsize len, gsize prespace, gchar **out, gsize *outlen, gsize *outprespace);
 static void emif_reset(CamelMimeFilter *f);
 
-static CamelMimeFilterClass *parent_class = NULL;
+static gpointer parent_class;
 
-CamelType
-em_inline_filter_get_type (void)
+static void
+em_inline_filter_finalize (GObject *object)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		parent_class = (CamelMimeFilterClass *)camel_mime_filter_get_type();
-
-		type = camel_type_register(camel_mime_filter_get_type(),
-					   "EMInlineFilter",
-					   sizeof (EMInlineFilter),
-					   sizeof (EMInlineFilterClass),
-					   (CamelObjectClassInitFunc) em_inline_filter_class_init,
-					   NULL,
-					   (CamelObjectInitFunc) em_inline_filter_init,
-					   (CamelObjectFinalizeFunc) em_inline_filter_finalize);
-	}
+	EMInlineFilter *emif = EM_INLINE_FILTER (object);
 
-	return type;
+	if (emif->base_type)
+		camel_content_type_unref(emif->base_type);
+
+	emif_reset (CAMEL_MIME_FILTER (emif));
+	g_byte_array_free (emif->data, TRUE);
+	g_free (emif->filename);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static void
-em_inline_filter_class_init (EMInlineFilterClass *klass)
+em_inline_filter_class_init (EMInlineFilterClass *class)
 {
-	((CamelMimeFilterClass *)klass)->filter = emif_filter;
-	((CamelMimeFilterClass *)klass)->complete = emif_complete;
-	((CamelMimeFilterClass *)klass)->reset = emif_reset;
+	GObjectClass *object_class;
+	CamelMimeFilterClass *mime_filter_class;
+
+	parent_class = g_type_class_peek_parent (class);
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = em_inline_filter_finalize;
+
+	mime_filter_class = CAMEL_MIME_FILTER_CLASS (class);
+	mime_filter_class->filter = emif_filter;
+	mime_filter_class->complete = emif_complete;
+	mime_filter_class->reset = emif_reset;
 }
 
 static void
-em_inline_filter_init (CamelObject *object)
+em_inline_filter_init (EMInlineFilter *emif)
 {
-	EMInlineFilter *emif = (EMInlineFilter *)object;
-
 	emif->data = g_byte_array_new();
 }
 
-static void
-em_inline_filter_finalize (CamelObject *object)
+GType
+em_inline_filter_get_type (void)
 {
-	EMInlineFilter *emif = (EMInlineFilter *)object;
+	static GType type = G_TYPE_INVALID;
+
+	if (type == G_TYPE_INVALID)
+		type = g_type_register_static_simple (
+			CAMEL_TYPE_MIME_FILTER,
+			"EMInlineFilter",
+			sizeof (EMInlineFilterClass),
+			(GClassInitFunc) em_inline_filter_class_init,
+			sizeof (EMInlineFilter),
+			(GInstanceInitFunc) em_inline_filter_init,
+			0);
 
-	if (emif->base_type)
-		camel_content_type_unref(emif->base_type);
-
-	emif_reset((CamelMimeFilter *)emif);
-	g_byte_array_free(emif->data, TRUE);
-	g_free(emif->filename);
+	return type;
 }
 
 enum {
@@ -165,7 +168,7 @@ emif_add_part(EMInlineFilter *emif, const gchar *data, gint len)
 	dw->encoding = encoding;
 
 	part = camel_mime_part_new();
-	camel_medium_set_content_object((CamelMedium *)part, dw);
+	camel_medium_set_content((CamelMedium *)part, dw);
 	camel_mime_part_set_encoding(part, encoding);
 	g_object_unref(dw);
 
@@ -391,7 +394,7 @@ em_inline_filter_new(CamelTransferEncoding base_encoding, CamelContentType *base
 {
 	EMInlineFilter *emif;
 
-	emif = (EMInlineFilter *)camel_object_new(em_inline_filter_get_type());
+	emif = g_object_new (EM_TYPE_INLINE_FILTER, NULL);
 	emif->base_encoding = base_encoding;
 	if (base_type) {
 		emif->base_type = base_type;
diff --git a/mail/em-inline-filter.h b/mail/em-inline-filter.h
index 11aaa7f..2acefad 100644
--- a/mail/em-inline-filter.h
+++ b/mail/em-inline-filter.h
@@ -26,14 +26,30 @@
 
 #include <camel/camel.h>
 
-#define EM_INLINE_FILTER_TYPE     (em_inline_filter_get_type ())
-#define EM_INLINE_FILTER(obj)     (CAMEL_CHECK_CAST((obj), EM_INLINE_FILTER_TYPE, EMInlineFilter))
-#define EM_INLINE_FILTER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), EM_INLINE_FILTER_TYPE, EMInlineFilterClass))
-#define EM_IS_INLINE_FILTER(o)    (CAMEL_CHECK_TYPE((o), EM_INLINE_FILTER_TYPE))
+#define EM_TYPE_INLINE_FILTER \
+	(em_inline_filter_get_type ())
+#define EM_INLINE_FILTER(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), EM_TYPE_INLINE_FILTER, EMInlineFilter))
+#define EM_INLINE_FILTER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), EM_TYPE_INLINE_FILTER, EMInlineFilterClass))
+#define EM_IS_INLINE_FILTER(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), EM_TYPE_INLINE_FILTER))
+#define EM_IS_INLINE_FILTER_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), EM_TYPE_INLINE_FILTER))
+#define EM_INLINE_FILTER_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), EM_TYPE_INLINE_FILTER, EMInlineFilterClass))
 
 G_BEGIN_DECLS
 
-typedef struct _EMInlineFilter {
+typedef struct _EMInlineFilter EMInlineFilter;
+typedef struct _EMInlineFilterClass EMInlineFilterClass;
+
+struct _EMInlineFilter {
 	CamelMimeFilter filter;
 
 	gint state;
@@ -44,15 +60,16 @@ typedef struct _EMInlineFilter {
 	GByteArray *data;
 	gchar *filename;
 	GSList *parts;
-} EMInlineFilter;
+};
 
-typedef struct _EMInlineFilterClass {
+struct _EMInlineFilterClass {
 	CamelMimeFilterClass filter_class;
-} EMInlineFilterClass;
+};
 
-CamelType    em_inline_filter_get_type(void);
-EMInlineFilter *em_inline_filter_new(CamelTransferEncoding base_encoding, CamelContentType *type);
-CamelMultipart *em_inline_filter_get_multipart(EMInlineFilter *emif);
+GType		em_inline_filter_get_type	(void);
+EMInlineFilter *em_inline_filter_new		(CamelTransferEncoding base_encoding,
+						 CamelContentType *type);
+CamelMultipart *em_inline_filter_get_multipart	(EMInlineFilter *emif);
 
 G_END_DECLS
 
diff --git a/mail/em-sync-stream.c b/mail/em-sync-stream.c
index 7786977..988f7b7 100644
--- a/mail/em-sync-stream.c
+++ b/mail/em-sync-stream.c
@@ -34,8 +34,6 @@
 
 #include "mail-mt.h"
 
-#define EMSS_CLASS(x) ((EMSyncStreamClass *)(((CamelObject *)(x))->klass))
-
 enum _write_msg_t {
 	EMSS_WRITE,
 	EMSS_FLUSH,
@@ -52,7 +50,7 @@ struct _write_msg {
 	gsize len;
 };
 
-static CamelStreamClass *parent_class = NULL;
+static gpointer parent_class;
 
 static gboolean
 emss_process_message (struct _write_msg *msg)
@@ -68,7 +66,7 @@ emss_process_message (struct _write_msg *msg)
 
 	/* Force out any pending data before doing anything else. */
 	if (emss->buffer != NULL && emss->buffer->len > 0) {
-		EMSS_CLASS (emss)->sync_write (
+		EM_SYNC_STREAM_GET_CLASS (emss)->sync_write (
 			CAMEL_STREAM (emss), emss->buffer->str,
 			emss->buffer->len);
 		g_string_set_size (emss->buffer, 0);
@@ -76,15 +74,15 @@ emss_process_message (struct _write_msg *msg)
 
 	switch (msg->op) {
 		case EMSS_WRITE:
-			EMSS_CLASS (emss)->sync_write (
+			EM_SYNC_STREAM_GET_CLASS (emss)->sync_write (
 				CAMEL_STREAM (emss), msg->string, msg->len);
 			break;
 		case EMSS_FLUSH:
-			EMSS_CLASS (emss)->sync_flush (
+			EM_SYNC_STREAM_GET_CLASS (emss)->sync_flush (
 				CAMEL_STREAM (emss));
 			break;
 		case EMSS_CLOSE:
-			EMSS_CLASS (emss)->sync_close (
+			EM_SYNC_STREAM_GET_CLASS (emss)->sync_close (
 				CAMEL_STREAM (emss));
 			break;
 	}
@@ -119,6 +117,20 @@ emss_sync_op (EMSyncStream *emss, enum _write_msg_t op,
 	g_object_unref (emss);
 }
 
+static void
+em_sync_stream_finalize (GObject *object)
+{
+	EMSyncStream *emss = EM_SYNC_STREAM (object);
+
+	if (emss->buffer != NULL)
+		g_string_free (emss->buffer, TRUE);
+	if (emss->idle_id)
+		g_source_remove (emss->idle_id);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
 static gssize
 emss_stream_write (CamelStream *stream, const gchar *string, gsize len)
 {
@@ -128,7 +140,7 @@ emss_stream_write (CamelStream *stream, const gchar *string, gsize len)
 		return -1;
 
 	if (mail_in_main_thread ()) {
-		EMSS_CLASS (emss)->sync_write (stream, string, len);
+		EM_SYNC_STREAM_GET_CLASS (emss)->sync_write (stream, string, len);
 	} else if (emss->buffer != NULL) {
 		if (len < (emss->buffer->allocated_len - emss->buffer->len))
 			g_string_append_len (emss->buffer, string, len);
@@ -150,7 +162,7 @@ emss_stream_flush (CamelStream *stream)
 		return -1;
 
 	if (mail_in_main_thread ())
-		return EMSS_CLASS (emss)->sync_flush (stream);
+		return EM_SYNC_STREAM_GET_CLASS (emss)->sync_flush (stream);
 	else
 		emss_sync_op (emss, EMSS_FLUSH, NULL, 0);
 
@@ -168,7 +180,7 @@ emss_stream_close (CamelStream *stream)
 	emss->idle_id = 0;
 
 	if (mail_in_main_thread ())
-		return EMSS_CLASS (emss)->sync_close (stream);
+		return EM_SYNC_STREAM_GET_CLASS (emss)->sync_close (stream);
 	else
 		emss_sync_op (emss, EMSS_CLOSE, NULL, 0);
 
@@ -178,39 +190,34 @@ emss_stream_close (CamelStream *stream)
 static void
 em_sync_stream_class_init (EMSyncStreamClass *class)
 {
-	CamelStreamClass *stream_class = CAMEL_STREAM_CLASS (class);
+	GObjectClass *object_class;
+	CamelStreamClass *stream_class;
 
-	parent_class = (CamelStreamClass *) CAMEL_STREAM_TYPE;
+	parent_class = g_type_class_peek_parent (class);
 
+	object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = em_sync_stream_finalize;
+
+	stream_class = CAMEL_STREAM_CLASS (class);
 	stream_class->write = emss_stream_write;
 	stream_class->flush = emss_stream_flush;
 	stream_class->close = emss_stream_close;
 }
 
-static void
-em_sync_stream_finalize (EMSyncStream *emss)
-{
-	if (emss->buffer != NULL)
-		g_string_free (emss->buffer, TRUE);
-	if (emss->idle_id)
-		g_source_remove (emss->idle_id);
-}
-
-CamelType
+GType
 em_sync_stream_get_type (void)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
+	static GType type = G_TYPE_INVALID;
 
-	if (G_UNLIKELY (type == CAMEL_INVALID_TYPE))
-		type = camel_type_register (
-			CAMEL_STREAM_TYPE,
+	if (G_UNLIKELY (type == G_TYPE_INVALID))
+		type = g_type_register_static_simple (
+			CAMEL_TYPE_STREAM,
 			"EMSyncStream",
-			sizeof (EMSyncStream),
 			sizeof (EMSyncStreamClass),
-			(CamelObjectClassInitFunc) em_sync_stream_class_init,
-			NULL,
-			(CamelObjectInitFunc) NULL,
-			(CamelObjectFinalizeFunc) em_sync_stream_finalize);
+			(GClassInitFunc) em_sync_stream_class_init,
+			sizeof (EMSyncStream),
+			(GInstanceInitFunc) NULL,
+			0);
 
 	return type;
 }
diff --git a/mail/em-sync-stream.h b/mail/em-sync-stream.h
index 2c35f2a..261b39a 100644
--- a/mail/em-sync-stream.h
+++ b/mail/em-sync-stream.h
@@ -32,16 +32,23 @@ requests are always handled in the main gui thread in the correct order.
 
 #include <camel/camel.h>
 
-#define EM_SYNC_STREAM_TYPE \
+#define EM_TYPE_SYNC_STREAM \
 	(em_sync_stream_get_type ())
 #define EM_SYNC_STREAM(obj) \
-	(CAMEL_CHECK_CAST \
-	((obj), EM_SYNC_STREAM_TYPE, EMSyncStream))
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), EM_TYPE_SYNC_STREAM, EMSyncStream))
 #define EM_SYNC_STREAM_CLASS(cls) \
-	(CAMEL_CHECK_CLASS_CAST \
-	((cls), EM_SYNC_STREAM_TYPE, EMSyncStreamClass))
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), EM_TYPE_SYNC_STREAM, EMSyncStreamClass))
 #define EM_IS_SYNC_STREAM(obj) \
-	(CAMEL_CHECK_TYPE ((obj), EM_SYNC_STREAM_TYPE))
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), EM_TYPE_SYNC_STREAM))
+#define EM_IS_SYNC_STREAM_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), EM_TYPE_SYNC_STREAM))
+#define EM_SYNC_STREAM_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), EM_TYPE_SYNC_STREAM, EMSyncStreamClass))
 
 G_BEGIN_DECLS
 
@@ -65,7 +72,7 @@ struct _EMSyncStreamClass {
 	gint		(*sync_flush)		(CamelStream *stream);
 };
 
-CamelType	em_sync_stream_get_type		(void);
+GType		em_sync_stream_get_type		(void);
 void		em_sync_stream_set_buffer_size	(EMSyncStream *stream,
 						 gsize size);
 
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 13c06e3..8675cc0 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -535,13 +535,14 @@ em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GP
 static gint
 em_utils_write_messages_to_stream(CamelFolder *folder, GPtrArray *uids, CamelStream *stream)
 {
-	CamelStreamFilter *filtered_stream;
-	CamelMimeFilterFrom *from_filter;
+	CamelStream *filtered_stream;
+	CamelMimeFilter *from_filter;
 	gint i, res = 0;
 
 	from_filter = camel_mime_filter_from_new();
-	filtered_stream = camel_stream_filter_new_with_stream(stream);
-	camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)from_filter);
+	filtered_stream = camel_stream_filter_new (stream);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), from_filter);
 	g_object_unref(from_filter);
 
 	for (i=0; i<uids->len; i++) {
@@ -559,8 +560,8 @@ em_utils_write_messages_to_stream(CamelFolder *folder, GPtrArray *uids, CamelStr
 
 		if (camel_stream_write_string(stream, from) == -1
 		    || camel_stream_flush(stream) == -1
-		    || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, (CamelStream *)filtered_stream) == -1
-		    || camel_stream_flush((CamelStream *)filtered_stream) == -1)
+		    || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, filtered_stream) == -1
+		    || camel_stream_flush(filtered_stream) == -1)
 			res = -1;
 
 		g_free(from);
@@ -625,17 +626,22 @@ em_utils_read_messages_from_stream(CamelFolder *folder, CamelStream *stream)
  * Warning: This could block the ui for an extended period.
  **/
 void
-em_utils_selection_set_mailbox(GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids)
+em_utils_selection_set_mailbox (GtkSelectionData *data,
+                                CamelFolder *folder,
+                                GPtrArray *uids)
 {
 	CamelStream *stream;
+	GByteArray *buffer;
 
-	stream = camel_stream_mem_new();
-	if (em_utils_write_messages_to_stream(folder, uids, stream) == 0)
-		gtk_selection_data_set(data, data->target, 8,
-				       ((CamelStreamMem *)stream)->buffer->data,
-				       ((CamelStreamMem *)stream)->buffer->len);
+	buffer = g_byte_array_new ();
+	stream = camel_stream_mem_new_with_byte_array (buffer);
 
-	g_object_unref(stream);
+	if (em_utils_write_messages_to_stream (folder, uids, stream) == 0)
+		gtk_selection_data_set (
+			data, data->target, 8,
+			buffer->data, buffer->len);
+
+	g_object_unref (stream);
 }
 
 /**
@@ -1932,7 +1938,7 @@ emu_remove_from_mail_cache (const GSList *addresses)
 		}
 	}
 
-	camel_object_unref (cia);
+	g_object_unref (cia);
 }
 
 void
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index c78a850..e614131 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -282,9 +282,13 @@ rule_from_message (EFilterRule *rule, ERuleContext *context, CamelMimeMessage *m
 			rule_match_recipients (context, rule, addr);
 	}
 	if (flags & AUTO_MLIST) {
+		CamelMimePart *mime_part;
+		GQueue *header_queue;
 		gchar *name, *mlist;
 
-		mlist = camel_header_raw_check_mailing_list (&((CamelMimePart *)msg)->headers);
+		mime_part = CAMEL_MIME_PART (msg);
+		header_queue = camel_mime_part_get_raw_headers (mime_part);
+		mlist = camel_header_raw_check_mailing_list (header_queue);
 		if (mlist) {
 			rule_match_mlist(context, rule, mlist);
 			name = g_strdup_printf (_("%s mailing list"), mlist);
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 740e42c..b1eb71a 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -470,8 +470,9 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 	const gchar *resent_from, *tmp;
 	CamelFolder *folder = NULL;
 	GString *err = NULL;
-	struct _camel_header_raw *xev, *header;
 	CamelMimeMessage *message;
+	GQueue evo_headers = G_QUEUE_INIT;
+	GList *link;
 	gint i;
 
 	message = camel_folder_get_message(queue, uid, ex);
@@ -481,9 +482,9 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 	camel_medium_set_header (CAMEL_MEDIUM (message), "X-Mailer", x_mailer);
 
 	err = g_string_new("");
-	xev = mail_tool_remove_xevolution_headers (message);
+	mail_tool_remove_xevolution_headers (message, &evo_headers);
 
-	tmp = camel_header_raw_find(&xev, "X-Evolution-Account", NULL);
+	tmp = camel_header_raw_find (&evo_headers, "X-Evolution-Account", NULL);
 	if (tmp) {
 		gchar *name;
 
@@ -501,11 +502,11 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 
 	if (!account) {
 		/* default back to these headers */
-		tmp = camel_header_raw_find(&xev, "X-Evolution-Transport", NULL);
+		tmp = camel_header_raw_find (&evo_headers, "X-Evolution-Transport", NULL);
 		if (tmp)
 			transport_url = g_strstrip(g_strdup(tmp));
 
-		tmp = camel_header_raw_find(&xev, "X-Evolution-Fcc", NULL);
+		tmp = camel_header_raw_find (&evo_headers, "X-Evolution-Fcc", NULL);
 		if (tmp)
 			sent_folder_uri = g_strstrip(g_strdup(tmp));
 	}
@@ -553,16 +554,22 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 	camel_message_info_set_flags(info, CAMEL_MESSAGE_SEEN, ~0);
 	camel_mime_message_set_date(message, CAMEL_MESSAGE_DATE_CURRENT, 0);
 
-	for (header = xev;header;header=header->next) {
+	link = g_queue_peek_head (&evo_headers);
+	for (; link != NULL; link = g_list_next (link)) {
+		CamelHeaderRaw *raw_header = link->data;
+		const gchar *name, *value;
 		gchar *uri;
 
-		if (strcmp(header->name, "X-Evolution-PostTo") != 0)
+		name = camel_header_raw_get_name (raw_header);
+		value = camel_header_raw_get_value (raw_header);
+
+		if (strcmp (name, "X-Evolution-PostTo") != 0)
 			continue;
 
 		/* TODO: don't lose errors */
 
-		uri = g_strstrip(g_strdup(header->value));
-		folder = mail_tool_uri_to_folder(uri, 0, NULL);
+		uri = g_strstrip (g_strdup (value));
+		folder = mail_tool_uri_to_folder (uri, 0, NULL);
 		if (folder) {
 			camel_folder_append_message(folder, message, info, NULL, NULL);
 			g_object_unref(folder);
@@ -572,7 +579,7 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u
 	}
 
 	/* post process */
-	mail_tool_restore_xevolution_headers (message, xev);
+	mail_tool_restore_xevolution_headers (message, &evo_headers);
 
 	if (driver) {
 		camel_filter_driver_filter_message (driver, message, info,
@@ -668,7 +675,7 @@ exit:
 		g_object_unref(xport);
 	g_free(sent_folder_uri);
 	g_free(transport_url);
-	camel_header_raw_clear(&xev);
+	camel_header_raw_clear(&evo_headers);
 	g_string_free(err, TRUE);
 	g_object_unref(message);
 
@@ -1189,7 +1196,7 @@ do_build_attachment (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages,
 			g_object_unref(part);
 		}
 		part = camel_mime_part_new();
-		camel_medium_set_content_object(CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER(multipart));
+		camel_medium_set_content(CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER(multipart));
 		g_object_unref(multipart);
 
 		camel_mime_part_set_description(part, _("Forwarded messages"));
@@ -2050,7 +2057,7 @@ save_prepare_part (CamelMimePart *mime_part)
 	CamelDataWrapper *wrapper;
 	gint parts, i;
 
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 	if (!wrapper)
 		return;
 
@@ -2079,8 +2086,8 @@ save_prepare_part (CamelMimePart *mime_part)
 static void
 save_messages_exec (struct _save_messages_msg *m)
 {
-	CamelStreamFilter *filtered_stream;
-	CamelMimeFilterFrom *from_filter;
+	CamelStream *filtered_stream;
+	CamelMimeFilter *from_filter;
 	CamelStream *stream;
 	gint i;
 	gchar *from, *path;
@@ -2092,8 +2099,9 @@ save_messages_exec (struct _save_messages_msg *m)
 
 	stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE);
 	from_filter = camel_mime_filter_from_new();
-	filtered_stream = camel_stream_filter_new_with_stream(stream);
-	camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)from_filter);
+	filtered_stream = camel_stream_filter_new (stream);
+	camel_stream_filter_add (
+		CAMEL_STREAM_FILTER (filtered_stream), from_filter);
 	g_object_unref(from_filter);
 
 	if (path != m->path)
@@ -2114,8 +2122,8 @@ save_messages_exec (struct _save_messages_msg *m)
 		from = camel_mime_message_build_mbox_from(message);
 		if (camel_stream_write_string(stream, from) == -1
 		    || camel_stream_flush(stream) == -1
-		    || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, (CamelStream *)filtered_stream) == -1
-		    || camel_stream_flush((CamelStream *)filtered_stream) == -1
+		    || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, filtered_stream) == -1
+		    || camel_stream_flush(filtered_stream) == -1
 		    || camel_stream_write_string(stream, "\n") == -1
 		    || camel_stream_flush(stream) == -1) {
 			camel_exception_setv(&m->base.ex, CAMEL_EXCEPTION_SYSTEM,
@@ -2226,7 +2234,7 @@ save_part_exec (struct _save_part_msg *m)
 	if (path != m->path)
 		g_free (path);
 
-	content = camel_medium_get_content_object (CAMEL_MEDIUM (m->part));
+	content = camel_medium_get_content (CAMEL_MEDIUM (m->part));
 
 	if (camel_data_wrapper_decode_to_stream (content, stream) == -1
 	    || camel_stream_flush (stream) == -1)
diff --git a/mail/mail-session.c b/mail/mail-session.c
index cf8a968..0018c3f 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -28,6 +28,7 @@
 
 #include <glib.h>
 #include <glib/gstdio.h>
+#include <glib/gi18n-lib.h>
 
 #include <gtk/gtk.h>
 
@@ -52,7 +53,6 @@
 #include "em-filter-rule.h"
 #include "em-utils.h"
 #include "mail-config.h"
-#include "mail-mt.h"
 #include "mail-ops.h"
 #include "mail-session.h"
 #include "mail-tools.h"
@@ -62,28 +62,8 @@
 CamelSession *session;
 static gint session_check_junk_notify_id = -1;
 
-#define MAIL_SESSION_TYPE     (mail_session_get_type ())
-#define MAIL_SESSION(obj)     (CAMEL_CHECK_CAST((obj), MAIL_SESSION_TYPE, MailSession))
-#define MAIL_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), MAIL_SESSION_TYPE, MailSessionClass))
-#define MAIL_IS_SESSION(o)    (CAMEL_CHECK_TYPE((o), MAIL_SESSION_TYPE))
-
-typedef struct _MailSession {
-	CamelSession parent_object;
-
-	gboolean interactive;
-	FILE *filter_logfile;
-	GList *junk_plugins;
-
-	MailAsyncEvent *async;
-} MailSession;
-
-typedef struct _MailSessionClass {
-	CamelSessionClass parent_class;
-
-} MailSessionClass;
-
 static EShellBackend *session_shell_backend;
-static CamelSessionClass *ms_parent_class;
+static gpointer parent_class;
 
 static gchar *get_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *prompt, const gchar *item, guint32 flags, CamelException *ex);
 static void forget_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *item, CamelException *ex);
@@ -97,57 +77,65 @@ static void ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m);
 static void ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *message, const gchar *address, CamelException *ex);
 
 static void
-init (MailSession *session)
+session_finalize (GObject *object)
 {
-	session->async = mail_async_event_new();
-	session->junk_plugins = NULL;
-}
+	MailSession *session = MAIL_SESSION (object);
 
-static void
-finalise (MailSession *session)
-{
 	if (session_check_junk_notify_id != -1)
 		gconf_client_notify_remove (mail_config_get_gconf_client (), session_check_junk_notify_id);
 
-	mail_async_event_destroy(session->async);
+	mail_async_event_destroy (session->async);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static void
-class_init (MailSessionClass *mail_session_class)
+session_class_init (MailSessionClass *class)
 {
-	CamelSessionClass *camel_session_class = CAMEL_SESSION_CLASS (mail_session_class);
+	GObjectClass *object_class;
+	CamelSessionClass *session_class;
 
-	/* virtual method override */
-	camel_session_class->get_password = get_password;
-	camel_session_class->forget_password = forget_password;
-	camel_session_class->alert_user = alert_user;
-	camel_session_class->get_filter_driver = get_filter_driver;
-	camel_session_class->lookup_addressbook = lookup_addressbook;
-	camel_session_class->thread_msg_new = ms_thread_msg_new;
-	camel_session_class->thread_msg_free = ms_thread_msg_free;
-	camel_session_class->thread_status = ms_thread_status;
-	camel_session_class->forward_to = ms_forward_to;
+	parent_class = g_type_class_peek_parent (class);
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = session_finalize;
+
+	session_class = CAMEL_SESSION_CLASS (class);
+	session_class->get_password = get_password;
+	session_class->forget_password = forget_password;
+	session_class->alert_user = alert_user;
+	session_class->get_filter_driver = get_filter_driver;
+	session_class->lookup_addressbook = lookup_addressbook;
+	session_class->thread_msg_new = ms_thread_msg_new;
+	session_class->thread_msg_free = ms_thread_msg_free;
+	session_class->thread_status = ms_thread_status;
+	session_class->forward_to = ms_forward_to;
+}
+
+static void
+session_init (MailSession *session)
+{
+	session->async = mail_async_event_new ();
+	session->junk_plugins = NULL;
 }
 
-static CamelType
+GType
 mail_session_get_type (void)
 {
-	static CamelType mail_session_type = CAMEL_INVALID_TYPE;
+	static GType type = G_TYPE_INVALID;
 
-	if (mail_session_type == CAMEL_INVALID_TYPE) {
-		ms_parent_class = (CamelSessionClass *)camel_session_get_type();
-		mail_session_type = camel_type_register (
-			camel_session_get_type (),
+	if (type == G_TYPE_INVALID)
+		type = g_type_register_static_simple (
+			CAMEL_TYPE_SESSION,
 			"MailSession",
-			sizeof (MailSession),
 			sizeof (MailSessionClass),
-			(CamelObjectClassInitFunc) class_init,
-			NULL,
-			(CamelObjectInitFunc) init,
-			(CamelObjectFinalizeFunc) finalise);
-	}
+			(GClassInitFunc) session_class_init,
+			sizeof (MailSession),
+			(GInstanceInitFunc) session_init,
+			0);
 
-	return mail_session_type;
+	return type;
 }
 
 static gchar *
@@ -599,7 +587,7 @@ static MailMsgInfo ms_thread_info_dummy = { sizeof (MailMsg) };
 
 static gpointer ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, guint size)
 {
-	CamelSessionThreadMsg *msg = ms_parent_class->thread_msg_new(session, ops, size);
+	CamelSessionThreadMsg *msg = CAMEL_SESSION_CLASS (parent_class)->thread_msg_new(session, ops, size);
 
 	/* We create a dummy mail_msg, and then copy its cancellation port over to ours, so
 	   we get cancellation and progress in common with hte existing mail code, for free */
@@ -618,7 +606,7 @@ static gpointer ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *
 static void ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m)
 {
 	mail_msg_unref(m->data);
-	ms_parent_class->thread_msg_free(session, m);
+	CAMEL_SESSION_CLASS (parent_class)->thread_msg_free (session, m);
 }
 
 static void ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const gchar *text, gint pc)
@@ -727,7 +715,7 @@ mail_session_init (EShellBackend *shell_backend)
 
 	camel_provider_init();
 
-	session = CAMEL_SESSION (camel_object_new (MAIL_SESSION_TYPE));
+	session = g_object_new (MAIL_TYPE_SESSION, NULL);
 	e_account_combo_box_set_session (session);  /* XXX Don't ask... */
 	e_account_writable(NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD); /* Init the EAccount Setup */
 
diff --git a/mail/mail-session.h b/mail/mail-session.h
index 20a5da2..c89f9a2 100644
--- a/mail/mail-session.h
+++ b/mail/mail-session.h
@@ -26,9 +26,46 @@
 #include <glib.h>
 #include <camel/camel.h>
 #include <shell/e-shell-backend.h>
+#include <mail/mail-mt.h>
+
+#define MAIL_TYPE_SESSION \
+	(mail_session_get_type ())
+#define MAIL_SESSION(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), MAIL_TYPE_SESSION, MailSession))
+#define MAIL_SESSION_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), MAIL_TYPE_SESSION, MailSessionClass))
+#define MAIL_IS_SESSION(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), MAIL_TYPE_SESSION))
+#define MAIL_IS_SESSION_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), MAIL_TYPE_SESSION))
+#define MAIL_SESSION_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), MAIL_TYPE_SESSION, MailSessionClass))
 
 G_BEGIN_DECLS
 
+typedef struct _MailSession MailSession;
+typedef struct _MailSessionClass MailSessionClass;
+
+struct _MailSession {
+	CamelSession parent;
+
+	gboolean interactive;
+	FILE *filter_logfile;
+	GList *junk_plugins;
+
+	MailAsyncEvent *async;
+};
+
+struct _MailSessionClass {
+	CamelSessionClass parent_class;
+};
+
+GType mail_session_get_type (void);
 void mail_session_init (EShellBackend *shell_backend);
 void mail_session_shutdown (void);
 gboolean mail_session_get_interactive (void);
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 60f02ec..1ea73dd 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -233,34 +233,86 @@ mail_tool_generate_forward_subject (CamelMimeMessage *msg)
 	return fwd_subj;
 }
 
-struct _camel_header_raw *
-mail_tool_remove_xevolution_headers (CamelMimeMessage *message)
+void
+mail_tool_remove_xevolution_headers (CamelMimeMessage *message,
+                                     GQueue *destination_queue)
 {
-	struct _camel_header_raw *scan, *list = NULL;
+	CamelMedium *medium;
+	CamelMimePart *mime_part;
+	GQueue *header_queue;
+	GList *list = NULL;
+	GList *link;
+
+	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
+	g_return_if_fail (destination_queue != NULL);
+
+	medium = CAMEL_MEDIUM (message);
+	mime_part = CAMEL_MIME_PART (message);
+
+	header_queue = camel_mime_part_get_raw_headers (mime_part);
+	link = g_queue_peek_head_link (header_queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *header = link->data;
+		const gchar *name;
 
-	for (scan = ((CamelMimePart *)message)->headers;scan;scan=scan->next)
-		if (!strncmp(scan->name, "X-Evolution", 11))
-			camel_header_raw_append(&list, scan->name, scan->value, scan->offset);
+		name = camel_header_raw_get_name (header);
 
-	for (scan=list;scan;scan=scan->next)
-		camel_medium_remove_header((CamelMedium *)message, scan->name);
+		if (strncmp (name, "X-Evolution", 11) == 0) {
+			camel_header_raw_append (
+				destination_queue,
+				camel_header_raw_get_name (header),
+				camel_header_raw_get_value (header),
+				camel_header_raw_get_offset (header));
+			list = g_list_prepend (list, g_strdup (name));
+		}
 
-	return list;
+		link = g_list_next (link);
+	}
+
+	while (list != NULL) {
+		gchar *name = link->data;
+		camel_medium_remove_header (medium, name);
+		list = g_list_delete_link (list, list);
+		g_free (name);
+	}
 }
 
 void
-mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *xev)
+mail_tool_restore_xevolution_headers (CamelMimeMessage *message,
+                                      GQueue *source_queue)
 {
-	for (;xev;xev=xev->next)
-		camel_medium_add_header((CamelMedium *)message, xev->name, xev->value);
+	CamelMedium *medium;
+	GList *link;
+
+	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
+	g_return_if_fail (source_queue != NULL);
+
+	medium = CAMEL_MEDIUM (message);
+
+	link = g_queue_peek_head (source_queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *header = link->data;
+		const gchar *name, *value;
+
+		name = camel_header_raw_get_name (header);
+		value = camel_header_raw_get_value (header);
+
+		camel_medium_add_header (medium, name, value);
+
+		link = g_list_next (link);
+	}
+
+	camel_header_raw_clear (source_queue);
 }
 
 CamelMimePart *
 mail_tool_make_message_attachment (CamelMimeMessage *message)
 {
 	CamelMimePart *part;
+	GQueue trash = G_QUEUE_INIT;
 	const gchar *subject;
-	struct _camel_header_raw *xev;
 	gchar *desc;
 
 	subject = camel_mime_message_get_subject (message);
@@ -270,8 +322,8 @@ mail_tool_make_message_attachment (CamelMimeMessage *message)
 		desc = g_strdup (_("Forwarded message"));
 
 	/* rip off the X-Evolution headers */
-	xev = mail_tool_remove_xevolution_headers (message);
-	camel_header_raw_clear(&xev);
+	mail_tool_remove_xevolution_headers (message, &trash);
+	camel_header_raw_clear (&trash);
 
 	/* remove Bcc headers */
 	camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc");
@@ -279,7 +331,7 @@ mail_tool_make_message_attachment (CamelMimeMessage *message)
 	part = camel_mime_part_new ();
 	camel_mime_part_set_disposition (part, "inline");
 	camel_mime_part_set_description (part, desc);
-	camel_medium_set_content_object (CAMEL_MEDIUM (part),
+	camel_medium_set_content (CAMEL_MEDIUM (part),
 					 CAMEL_DATA_WRAPPER (message));
 	camel_mime_part_set_content_type (part, "message/rfc822");
 	g_free (desc);
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index 74f07e4..5d2498a 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -35,8 +35,12 @@ CamelFolder *mail_tool_get_trash (const gchar *url, gint connect, CamelException
  * and returns the path to the new movemail folder that was created. which shoudl be freed later */
 gchar *mail_tool_do_movemail (const gchar *source_url, CamelException *ex);
 
-struct _camel_header_raw *mail_tool_remove_xevolution_headers (CamelMimeMessage *message);
-void mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *);
+void		mail_tool_remove_xevolution_headers
+						(CamelMimeMessage *message,
+						 GQueue *destination_queue);
+void		mail_tool_restore_xevolution_headers
+						(CamelMimeMessage *message,
+						 GQueue *source_queue);
 
 /* Generates the subject for a message forwarding @msg */
 gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index c3425f1..c752377 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -63,7 +63,7 @@ static GList *source_folders_local;	/* list of source folder uri's - local ones
 static GHashTable *vfolder_hash;
 /* This is a slightly hacky solution to shutting down, we poll this variable in various
    loops, and just quit processing if it is set. */
-static volatile gint shutdown;		/* are we shutting down? */
+static volatile gint vfolder_shutdown;		/* are we shutting down? */
 /* more globals ... */
 extern CamelSession *session;
 
@@ -97,7 +97,7 @@ vfolder_setup_exec (struct _setup_msg *m)
 	camel_vee_folder_set_expression((CamelVeeFolder *)m->folder, m->query);
 
 	l = m->sources_uri;
-	while (l && !shutdown) {
+	while (l && !vfolder_shutdown) {
 		d(printf(" Adding uri: %s\n", (gchar *)l->data));
 
 		folder = mail_tool_uri_to_folder (l->data, 0, &m->base.ex);
@@ -111,14 +111,14 @@ vfolder_setup_exec (struct _setup_msg *m)
 	}
 
 	l = m->sources_folder;
-	while (l && !shutdown) {
+	while (l && !vfolder_shutdown) {
 		d(printf(" Adding folder: %s\n", ((CamelFolder *)l->data)->full_name));
 		g_object_ref(l->data);
 		list = g_list_append(list, l->data);
 		l = l->next;
 	}
 
-	if (!shutdown)
+	if (!vfolder_shutdown)
 		camel_vee_folder_set_folders((CamelVeeFolder *)m->folder, list);
 
 	l = list;
@@ -245,7 +245,7 @@ vfolder_adduri_exec (struct _adduri_msg *m)
 	GList *l;
 	CamelFolder *folder = NULL;
 
-	if (shutdown)
+	if (vfolder_shutdown)
 		return;
 
 	d(printf("%s uri to vfolder: %s\n", m->remove?"Removing":"Adding", m->uri));
@@ -262,7 +262,7 @@ vfolder_adduri_exec (struct _adduri_msg *m)
 
 	if (folder != NULL) {
 		l = m->folders;
-		while (l && !shutdown) {
+		while (l && !vfolder_shutdown) {
 			if (m->remove)
 				camel_vee_folder_remove_folder((CamelVeeFolder *)l->data, folder);
 			else
@@ -1222,7 +1222,7 @@ vfolder_foreach_cb (gpointer key, gpointer data, gpointer user_data)
 void
 mail_vfolder_shutdown (void)
 {
-	shutdown = 1;
+	vfolder_shutdown = 1;
 
 	if (vfolder_hash) {
 		g_hash_table_foreach (vfolder_hash, vfolder_foreach_cb, NULL);
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c
index cf8e1d5..c18795f 100644
--- a/modules/calendar/e-cal-attachment-handler.c
+++ b/modules/calendar/e-cal-attachment-handler.c
@@ -79,7 +79,7 @@ attachment_handler_get_component (EAttachment *attachment)
 	buffer = g_byte_array_new ();
 	stream = camel_stream_mem_new ();
 	camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 	camel_data_wrapper_decode_to_stream (wrapper, stream);
 	g_object_unref (stream);
 
diff --git a/modules/mail/e-mail-attachment-handler.c b/modules/mail/e-mail-attachment-handler.c
index 55fb8b7..92233fc 100644
--- a/modules/mail/e-mail-attachment-handler.c
+++ b/modules/mail/e-mail-attachment-handler.c
@@ -70,7 +70,7 @@ mail_attachment_handler_forward (GtkAction *action,
 
 	attachment = E_ATTACHMENT (selected->data);
 	mime_part = e_attachment_get_mime_part (attachment);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	em_utils_forward_message (CAMEL_MIME_MESSAGE (wrapper), NULL);
 
@@ -92,7 +92,7 @@ mail_attachment_handler_reply_all (GtkAction *action,
 
 	attachment = E_ATTACHMENT (selected->data);
 	mime_part = e_attachment_get_mime_part (attachment);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	em_utils_reply_to_message (
 		NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
@@ -116,7 +116,7 @@ mail_attachment_handler_reply_sender (GtkAction *action,
 
 	attachment = E_ATTACHMENT (selected->data);
 	mime_part = e_attachment_get_mime_part (attachment);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	em_utils_reply_to_message (
 		NULL, NULL, CAMEL_MIME_MESSAGE (wrapper),
@@ -317,7 +317,7 @@ mail_attachment_handler_x_uid_list (EAttachmentView *view,
 		mime_part = camel_mime_part_new ();
 		wrapper = CAMEL_DATA_WRAPPER (message);
 		camel_mime_part_set_disposition (mime_part, "inline");
-		camel_medium_set_content_object (
+		camel_medium_set_content (
 			CAMEL_MEDIUM (mime_part), wrapper);
 		camel_mime_part_set_content_type (mime_part, "message/rfc822");
 		camel_multipart_add_part (multipart, mime_part);
@@ -328,7 +328,7 @@ mail_attachment_handler_x_uid_list (EAttachmentView *view,
 
 	mime_part = camel_mime_part_new ();
 	wrapper = CAMEL_DATA_WRAPPER (multipart);
-	camel_medium_set_content_object (CAMEL_MEDIUM (mime_part), wrapper);
+	camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
 
 	/* Translators: This is only for multiple messages. */
 	description = g_strdup_printf (_("%d attached messages"), uids->len);
@@ -400,7 +400,7 @@ mail_attachment_handler_update_actions (EAttachmentView *view)
 	if (!CAMEL_IS_MIME_PART (mime_part))
 		goto exit;
 
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	visible = CAMEL_IS_MIME_MESSAGE (wrapper);
 
diff --git a/modules/mail/e-mail-shell-migrate.c b/modules/mail/e-mail-shell-migrate.c
index ba7840c..2e0b73b 100644
--- a/modules/mail/e-mail-shell-migrate.c
+++ b/modules/mail/e-mail-shell-migrate.c
@@ -1028,10 +1028,8 @@ em_migrate_1_2(const gchar *data_dir, xmlDocPtr config_xmldb, xmlDocPtr filters,
 
 /* 1.4 upgrade functions */
 
-#define EM_MIGRATE_SESSION_TYPE     (em_migrate_session_get_type ())
-#define EM_MIGRATE_SESSION(obj)     (CAMEL_CHECK_CAST((obj), EM_MIGRATE_SESSION_TYPE, EMMigrateSession))
-#define EM_MIGRATE_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), EM_MIGRATE_SESSION_TYPE, EMMigrateSessionClass))
-#define EM_MIGRATE_IS_SESSION(o)    (CAMEL_CHECK_TYPE((o), EM_MIGRATE_SESSION_TYPE))
+#define EM_TYPE_MIGRATE_SESSION \
+	(em_migrate_session_get_type ())
 
 typedef struct _EMMigrateSession {
 	CamelSession parent_object;
@@ -1045,30 +1043,23 @@ typedef struct _EMMigrateSessionClass {
 
 } EMMigrateSessionClass;
 
-static CamelType em_migrate_session_get_type (void);
+static GType em_migrate_session_get_type (void);
 static CamelSession *em_migrate_session_new (const gchar *path);
 
-static void
-class_init (EMMigrateSessionClass *klass)
-{
-	;
-}
-
-static CamelType
+static GType
 em_migrate_session_get_type (void)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
+	static GType type = G_TYPE_INVALID;
 
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (
-			camel_session_get_type (),
+	if (type == G_TYPE_INVALID) {
+		type = g_type_register_static_simple (
+			CAMEL_TYPE_SESSION,
 			"EMMigrateSession",
-			sizeof (EMMigrateSession),
 			sizeof (EMMigrateSessionClass),
-			(CamelObjectClassInitFunc) class_init,
-			NULL,
-			NULL,
-			NULL);
+			(GClassInitFunc) NULL,
+			sizeof (EMMigrateSession),
+			(GInstanceInitFunc) NULL,
+			0);
 	}
 
 	return type;
@@ -1079,7 +1070,7 @@ em_migrate_session_new (const gchar *path)
 {
 	CamelSession *session;
 
-	session = CAMEL_SESSION (camel_object_new (EM_MIGRATE_SESSION_TYPE));
+	session = g_object_new (EM_TYPE_MIGRATE_SESSION, NULL);
 
 	camel_session_construct (session, path);
 
diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h
index 7d995da..049d49a 100644
--- a/modules/mail/e-mail-shell-view-private.h
+++ b/modules/mail/e-mail-shell-view-private.h
@@ -27,6 +27,7 @@
 #include <glib/gi18n.h>
 #include <camel/camel.h>
 #include <gtkhtml/gtkhtml.h>
+#include <camel/camel-search-private.h>
 
 #include "e-util/e-util.h"
 #include "e-util/e-binding.h"
diff --git a/plugins/audio-inline/audio-inline.c b/plugins/audio-inline/audio-inline.c
index 7ef7df5..af78668 100644
--- a/plugins/audio-inline/audio-inline.c
+++ b/plugins/audio-inline/audio-inline.c
@@ -203,7 +203,7 @@ org_gnome_audio_inline_play_clicked (GtkWidget *button, EMFormatHTMLPObject *pob
 		d(printf ("audio inline formatter: write to temp file %s\n", po->filename));
 
 		stream = camel_stream_fs_new_with_name (po->filename, O_RDWR | O_CREAT | O_TRUNC, 0600);
-		data = camel_medium_get_content_object (CAMEL_MEDIUM (po->part));
+		data = camel_medium_get_content (CAMEL_MEDIUM (po->part));
 		camel_data_wrapper_decode_to_stream (data, stream);
 		camel_stream_flush (stream);
 		g_object_unref (stream);
diff --git a/plugins/groupwise-features/camel-gw-listener.c b/plugins/groupwise-features/camel-gw-listener.c
index 88d2ae3..ea79bc7 100644
--- a/plugins/groupwise-features/camel-gw-listener.c
+++ b/plugins/groupwise-features/camel-gw-listener.c
@@ -24,6 +24,8 @@
 #include <config.h>
 #endif
 
+#include <glib/gi18n-lib.h>
+
 #include "camel-gw-listener.h"
 #include <string.h>
 #include <e-gw-connection.h>
diff --git a/plugins/groupwise-features/install-shared.c b/plugins/groupwise-features/install-shared.c
index a44540a..c8df77b 100644
--- a/plugins/groupwise-features/install-shared.c
+++ b/plugins/groupwise-features/install-shared.c
@@ -187,8 +187,9 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
 	const gchar *name;
 	const gchar *email;
 	CamelMimeMessage *msg = (CamelMimeMessage *) target->message;
-	CamelStreamMem *content;
+	CamelStream *content;
 	CamelDataWrapper *dw;
+	GByteArray *byte_array;
 	gchar *start_message;
 
 	if (!msg)
@@ -197,18 +198,19 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
 	if (((gchar *)camel_medium_get_header (CAMEL_MEDIUM(msg),"X-notification")) == NULL
 	    || (from_addr = camel_mime_message_get_from ((CamelMimeMessage *)target->message)) == NULL
 	    || !camel_internet_address_get(from_addr, 0, &name, &email)
-	    || (dw = camel_medium_get_content_object (CAMEL_MEDIUM (msg))) == NULL) {
+	    || (dw = camel_medium_get_content (CAMEL_MEDIUM (msg))) == NULL) {
 		return;
 	} else {
 		if (CAMEL_IS_MULTIPART (dw)) {
-			dw = camel_medium_get_content_object((CamelMedium *)camel_multipart_get_part((CamelMultipart *)dw, 0));
+			dw = camel_medium_get_content((CamelMedium *)camel_multipart_get_part((CamelMultipart *)dw, 0));
 			if (dw == NULL)
 				return;
 		}
 
-		content = (CamelStreamMem *)camel_stream_mem_new();
-		camel_data_wrapper_write_to_stream(dw, (CamelStream *)content);
-		camel_stream_write((CamelStream *)content, "", 1);
+		byte_array = g_byte_array_new ();
+		content = camel_stream_mem_new_with_byte_array (byte_array);
+		camel_data_wrapper_write_to_stream(dw, content);
+		camel_stream_write(content, "", 1);
 
 		from_addr = camel_mime_message_get_from ((CamelMimeMessage *)target->message);
 		if (from_addr && camel_internet_address_get(from_addr, 0, &name, &email)) {
@@ -219,7 +221,7 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
 							   "Message from '%s'\n\n\n"
 							   "%s\n\n\n"
 							   "Click 'Apply' to install the shared folder\n\n"),
-							   name, name, content->buffer->data);
+							   name, name, byte_array->data);
 
 			page = gtk_label_new (start_message);
 			gtk_label_set_line_wrap (GTK_LABEL (page), TRUE);
diff --git a/plugins/hula-account-setup/camel-hula-listener.c b/plugins/hula-account-setup/camel-hula-listener.c
index 7593d45..ce3cc24 100644
--- a/plugins/hula-account-setup/camel-hula-listener.c
+++ b/plugins/hula-account-setup/camel-hula-listener.c
@@ -24,11 +24,14 @@
 #include <config.h>
 #endif
 
+#include "camel-hula-listener.h"
+
 #include <string.h>
-#include <camel/camel.h>
+#include <glib/gi18n-lib.h>
 #include <libedataserverui/e-passwords.h>
 #include <e-util/e-error.h>
 #include <libedataserver/e-account.h>
+#include <gconf/gconf-client.h>
 
 static	GList *hula_accounts = NULL;
 
diff --git a/plugins/hula-account-setup/hula-account-setup.c b/plugins/hula-account-setup/hula-account-setup.c
index 5a62195..df5bc37 100644
--- a/plugins/hula-account-setup/hula-account-setup.c
+++ b/plugins/hula-account-setup/hula-account-setup.c
@@ -25,6 +25,8 @@
 #include <camel/camel.h>
 #include "mail/em-config.h"
 
+#include "camel-hula-listener.h"
+
 static CamelHulaListener *config_listener = NULL;
 
 gint e_plugin_lib_enable (EPlugin *ep, gint enable);
diff --git a/plugins/image-inline/image-inline.c b/plugins/image-inline/image-inline.c
index 688a7d7..9574eea 100644
--- a/plugins/image-inline/image-inline.c
+++ b/plugins/image-inline/image-inline.c
@@ -25,9 +25,8 @@
 
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
-#include <camel/camel-medium.h>
-#include <camel/camel-mime-part.h>
-#include <camel/camel-stream-mem.h>
+
+#include <camel/camel.h>
 #include <gtkhtml/gtkhtml-embedded.h>
 #include <gtkimageview/gtkimagescrollwin.h>
 
@@ -189,7 +188,7 @@ org_gnome_image_inline_pobject_free (EMFormatHTMLPObject *object)
 	image_object = (ImageInlinePObject *) object;
 
 	if (image_object->mime_part != NULL) {
-		camel_object_unref (image_object->mime_part);
+		g_object_unref (image_object->mime_part);
 		image_object->mime_part = NULL;
 	}
 
@@ -222,7 +221,7 @@ org_gnome_image_inline_decode (ImageInlinePObject *image_object)
 
 	/* Stream takes ownership of the byte array. */
 	stream = camel_stream_mem_new_with_byte_array (array);
-	data_wrapper = camel_medium_get_content_object (medium);
+	data_wrapper = camel_medium_get_content (medium);
 	camel_data_wrapper_decode_to_stream (data_wrapper, stream);
 
 	/* Don't trust the content type in the MIME part.  It could
@@ -250,7 +249,7 @@ org_gnome_image_inline_decode (ImageInlinePObject *image_object)
 	}
 
 exit:
-	camel_object_unref (stream);
+	g_object_unref (stream);
 	g_object_unref (loader);
 }
 
@@ -315,7 +314,7 @@ org_gnome_image_inline_format (gpointer ep, EMFormatHookTarget *target)
 			classid, target->part,
 			org_gnome_image_inline_embed);
 
-	camel_object_ref (target->part);
+	g_object_ref (target->part);
 	image_object->mime_part = target->part;
 
 	image_object->object.free = org_gnome_image_inline_pobject_free;
diff --git a/plugins/imap-features/imap-headers.c b/plugins/imap-features/imap-headers.c
index 1a3d35f..e5eafd7 100644
--- a/plugins/imap-features/imap-headers.c
+++ b/plugins/imap-features/imap-headers.c
@@ -28,11 +28,12 @@
 
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
+#include <camel/camel.h>
 
 #include <e-util/e-util.h>
 #include <e-util/e-account-utils.h>
-
-#include <camel/camel.h>
+#include <mail/em-config.h>
+#include <mail/mail-config.h>
 
 typedef struct _epif_data EPImapFeaturesData;
 struct _epif_data {
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index 1909cea..fb7f81e 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -966,7 +966,7 @@ message_foreach_part (CamelMimePart *part, GSList **part_list)
 
 	*part_list = g_slist_append (*part_list, part);
 
-	containee = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+	containee = camel_medium_get_content (CAMEL_MEDIUM (part));
 
 	if (containee == NULL)
 		return;
@@ -2503,7 +2503,8 @@ format_itip (EPlugin *ep, EMFormatHookTarget *target)
 	gchar *classid;
 	struct _itip_puri *puri;
 	CamelDataWrapper *content;
-	CamelStream *mem;
+	CamelStream *stream;
+	GByteArray *byte_array;
 
 	classid = g_strdup_printf("itip:///%s", ((EMFormat *) target->format)->part_id->str);
 
@@ -2528,15 +2529,16 @@ format_itip (EPlugin *ep, EMFormatHookTarget *target)
 	g_object_unref (gconf);
 
 	/* This is non-gui thread. Download the part for using in the main thread */
-	content = camel_medium_get_content_object ((CamelMedium *) target->part);
-	mem = camel_stream_mem_new ();
-	camel_data_wrapper_decode_to_stream (content, mem);
+	content = camel_medium_get_content ((CamelMedium *) target->part);
+	byte_array = g_byte_array_new ();
+	stream = camel_stream_mem_new_with_byte_array (byte_array);
+	camel_data_wrapper_decode_to_stream (content, stream);
 
-	if (((CamelStreamMem *) mem)->buffer->len == 0)
+	if (byte_array->len == 0)
 		puri->vcalendar = NULL;
 	else
-		puri->vcalendar = g_strndup ((gchar *)((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len);
-	g_object_unref (mem);
+		puri->vcalendar = g_strndup ((gchar *)byte_array->data, byte_array->len);
+	g_object_unref (stream);
 
 	camel_stream_printf (target->stream, "<table border=0 width=\"100%%\" cellpadding=3><tr>");
 	camel_stream_printf (target->stream, "<td valign=top><object classid=\"%s\"></object></td><td width=100%% valign=top>", classid);
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 8229b8b..b1fa388 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -171,16 +171,17 @@ static void
 set_description (ECalComponent *comp, CamelMimeMessage *message)
 {
 	CamelDataWrapper *content;
-	CamelStream *mem;
+	CamelStream *stream;
 	CamelContentType *type;
 	CamelMimePart *mime_part = CAMEL_MIME_PART (message);
 	ECalComponentText text;
+	GByteArray *byte_array;
 	GSList sl;
 	gchar *str, *convert_str = NULL;
 	gsize bytes_read, bytes_written;
 	gint count = 2;
 
-	content = camel_medium_get_content_object ((CamelMedium *) message);
+	content = camel_medium_get_content ((CamelMedium *) message);
 	if (!content)
 		return;
 
@@ -189,7 +190,7 @@ set_description (ECalComponent *comp, CamelMimeMessage *message)
 	 */
 	while (CAMEL_IS_MULTIPART (content) && count > 0) {
 		mime_part = camel_multipart_get_part (CAMEL_MULTIPART (content), 0);
-		content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+		content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 		count--;
 	}
 
@@ -200,11 +201,12 @@ set_description (ECalComponent *comp, CamelMimeMessage *message)
 	if (!camel_content_type_is (type, "text", "plain"))
 		return;
 
-	mem = camel_stream_mem_new ();
-	camel_data_wrapper_decode_to_stream (content, mem);
+	byte_array = g_byte_array_new ();
+	stream = camel_stream_mem_new_with_byte_array (byte_array);
+	camel_data_wrapper_decode_to_stream (content, stream);
 
-	str = g_strndup ((const gchar *)((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len);
-	g_object_unref (mem);
+	str = g_strndup ((const gchar *)byte_array->data, byte_array->len);
+	g_object_unref (stream);
 
 	/* convert to UTF-8 string */
 	if (str && content->mime_type->params && content->mime_type->params->value) {
@@ -311,7 +313,7 @@ set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message)
 		gboolean done;
 	} status;
 
-	content = camel_medium_get_content_object ((CamelMedium *) message);
+	content = camel_medium_get_content ((CamelMedium *) message);
 	if (!content || !CAMEL_IS_MULTIPART (content))
 		return;
 
@@ -385,14 +387,16 @@ set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message)
 }
 
 static void
-set_priority (ECalComponent *comp, CamelMimePart *part)
+set_priority (ECalComponent *comp, CamelMimePart *mime_part)
 {
+	GQueue *raw_headers;
 	const gchar *prio;
 
 	g_return_if_fail (comp != NULL);
-	g_return_if_fail (part != NULL);
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
 
-	prio = camel_header_raw_find (& (part->headers), "X-Priority", NULL);
+	raw_headers = camel_mime_part_get_raw_headers (mime_part);
+	prio = camel_header_raw_find (raw_headers, "X-Priority", NULL);
 	if (prio && atoi (prio) > 0) {
 		gint priority = 1;
 
diff --git a/plugins/prefer-plain/prefer-plain.c b/plugins/prefer-plain/prefer-plain.c
index f203407..77cf072 100644
--- a/plugins/prefer-plain/prefer-plain.c
+++ b/plugins/prefer-plain/prefer-plain.c
@@ -101,7 +101,7 @@ export_as_attachments (CamelMultipart *mp, EMFormat *format, CamelStream *stream
 		part = camel_multipart_get_part (mp, i);
 
 		if (part != except) {
-			CamelMultipart *multipart = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
+			CamelMultipart *multipart = (CamelMultipart *)camel_medium_get_content((CamelMedium *)part);
 
 			if (CAMEL_IS_MULTIPART (multipart)) {
 				export_as_attachments (multipart, format, stream, except);
@@ -115,7 +115,7 @@ export_as_attachments (CamelMultipart *mp, EMFormat *format, CamelStream *stream
 void
 org_gnome_prefer_plain_multipart_alternative(gpointer ep, EMFormatHookTarget *t)
 {
-	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)t->part);
+	CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content((CamelMedium *)t->part);
 	CamelMimePart *part, *display_part = NULL;
 	gint i, nparts, partidlen, displayid = 0;
 
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index ad9ee0c..c745ae2 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -889,7 +889,7 @@ pst_process_email (PstImporter *m, pst_item *item)
 	/*camel_mime_message_dump (msg, TRUE);*/
 
 	if (item->email->htmlbody.str || item->attach) {
-		camel_medium_set_content_object (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (mp));
+		camel_medium_set_content (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (mp));
 	} else if (item->body.str) {
 		camel_mime_part_set_content (CAMEL_MIME_PART (msg), item->body.str, strlen (item->body.str), "text/plain");
 	} else {
@@ -1232,7 +1232,7 @@ set_cal_attachments (ECal *cal, ECalComponent *ec, PstImporter *m, pst_item_atta
 			continue;
 		}
 
-		content = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+		content = camel_medium_get_content (CAMEL_MEDIUM (part));
 
 		if (camel_data_wrapper_decode_to_stream (content, stream) == -1
 			|| camel_stream_flush (stream) == -1)
diff --git a/plugins/sa-junk-plugin/em-junk-filter.c b/plugins/sa-junk-plugin/em-junk-filter.c
index 94d3109..9256405 100644
--- a/plugins/sa-junk-plugin/em-junk-filter.c
+++ b/plugins/sa-junk-plugin/em-junk-filter.c
@@ -36,6 +36,7 @@
 
 #include <gtk/gtk.h>
 #include <camel/camel.h>
+#include <glib/gi18n-lib.h>
 
 #include <mail/em-junk.h>
 #include <mail/em-utils.h>
diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c
index a8e98d6..8421967 100644
--- a/plugins/templates/templates.c
+++ b/plugins/templates/templates.c
@@ -470,8 +470,11 @@ create_new_message (CamelFolder *folder, const gchar *uid, CamelMimeMessage *mes
 {
 	GtkAction *action = data;
 	CamelMimeMessage *new, *template;
-	struct _camel_header_raw *header;
+	CamelMimePart *mime_part;
 	CamelStream *mem;
+	GQueue *header_queue;
+	GList *link;
+	gchar *cont;
 
 	g_return_if_fail (data != NULL);
 	g_return_if_fail (message != NULL);
@@ -488,18 +491,26 @@ create_new_message (CamelFolder *folder, const gchar *uid, CamelMimeMessage *mes
 	camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (template), mem);
 	camel_stream_reset (mem);
 	camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (new), mem);
-	camel_object_unref (mem);
+	g_object_unref (mem);
 
 	/* Add the headers from the message we are replying to, so CC and that
 	 * stuff is preserved. */
-	header = ((CamelMimePart *)message)->headers;
-	while (header) {
-		if (g_ascii_strncasecmp (header->name, "content-", 8) != 0) {
-			camel_medium_add_header((CamelMedium *) new,
-					header->name,
-					header->value);
-		}
-		header = header->next;
+	mime_part = CAMEL_MIME_PART (message);
+	header_queue = camel_mime_part_get_raw_headers (mime_part);
+	link = g_queue_peek_head_link (header_queue);
+
+	while (link != NULL) {
+		CamelHeaderRaw *raw_header = link->data;
+		const gchar *name, *value;
+
+		name = camel_header_raw_get_name (raw_header);
+		value = camel_header_raw_get_value (raw_header);
+
+		if (g_ascii_strncasecmp (name, "Content-", 8) != 0)
+			camel_medium_add_header (
+				CAMEL_MEDIUM (new), name, value);
+
+		link = g_list_next (link);
 	}
 
 	/* Set the To: field to the same To: field of the message we are replying to. */
diff --git a/plugins/tnef-attachments/tnef-plugin.c b/plugins/tnef-attachments/tnef-plugin.c
index 764347e..cc03dfd 100644
--- a/plugins/tnef-attachments/tnef-plugin.c
+++ b/plugins/tnef-attachments/tnef-plugin.c
@@ -96,7 +96,7 @@ org_gnome_format_tnef(gpointer ep, EMFormatHookTarget *t)
 	out = camel_stream_fs_new_with_name(name, O_RDWR|O_CREAT, 0666);
 	if (out == NULL)
 	    goto fail;
-	content = camel_medium_get_content_object((CamelMedium *)t->part);
+	content = camel_medium_get_content((CamelMedium *)t->part);
 	if (content == NULL)
 		goto fail;
 	if (camel_data_wrapper_decode_to_stream(content, out) == -1
@@ -127,7 +127,7 @@ org_gnome_format_tnef(gpointer ep, EMFormatHookTarget *t)
 	camel_data_wrapper_set_mime_type((CamelDataWrapper *)mp, "multipart/mixed");
 	camel_multipart_set_boundary(mp, NULL);
 
-	camel_medium_set_content_object((CamelMedium *)mainpart, (CamelDataWrapper *)mp);
+	camel_medium_set_content((CamelMedium *)mainpart, (CamelDataWrapper *)mp);
 
 	while ((d = readdir(dir))) {
 		CamelMimePart *part;
@@ -151,7 +151,7 @@ org_gnome_format_tnef(gpointer ep, EMFormatHookTarget *t)
 		part = camel_mime_part_new();
 		camel_mime_part_set_encoding(part, CAMEL_TRANSFER_ENCODING_BINARY);
 
-		camel_medium_set_content_object((CamelMedium *)part, content);
+		camel_medium_set_content((CamelMedium *)part, content);
 		g_object_unref(content);
 
 		type = em_format_snoop_type(part);
diff --git a/plugins/vcard-inline/vcard-inline.c b/plugins/vcard-inline/vcard-inline.c
index a5a46b0..478a65c 100644
--- a/plugins/vcard-inline/vcard-inline.c
+++ b/plugins/vcard-inline/vcard-inline.c
@@ -92,7 +92,7 @@ org_gnome_vcard_inline_decode (VCardInlinePObject *vcard_object,
 
 	/* Stream takes ownership of the byte array. */
 	stream = camel_stream_mem_new_with_byte_array (array);
-	data_wrapper = camel_medium_get_content_object (medium);
+	data_wrapper = camel_medium_get_content (medium);
 	camel_data_wrapper_decode_to_stream (data_wrapper, stream);
 
 	/* because the result is not NULL-terminated */
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index 39ce9d8..6dbf94e 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -777,7 +777,7 @@ attachment_class_init (EAttachmentClass *class)
 	g_object_class_install_property (
 		object_class,
 		PROP_MIME_PART,
-		g_param_spec_boxed (
+		g_param_spec_object (
 			"mime-part",
 			"MIME Part",
 			NULL,
@@ -987,7 +987,7 @@ e_attachment_new_for_message (CamelMimeMessage *message)
 	g_string_free (description, TRUE);
 
 	wrapper = CAMEL_DATA_WRAPPER (message);
-	camel_medium_set_content_object (CAMEL_MEDIUM (mime_part), wrapper);
+	camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
 	camel_mime_part_set_content_type (mime_part, "message/rfc822");
 
 	attachment = e_attachment_new ();
@@ -1017,7 +1017,7 @@ e_attachment_add_to_multipart (EAttachment *attachment,
 		return;
 
 	content_type = camel_mime_part_get_content_type (mime_part);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 
 	if (CAMEL_IS_MULTIPART (wrapper))
 		goto exit;
@@ -1025,8 +1025,8 @@ e_attachment_add_to_multipart (EAttachment *attachment,
 	/* For text content, determine the best encoding and character set. */
 	if (camel_content_type_is (content_type, "text", "*")) {
 		CamelTransferEncoding encoding;
-		CamelStreamFilter *filtered_stream;
-		CamelMimeFilterBestenc *filter;
+		CamelStream *filtered_stream;
+		CamelMimeFilter *filter;
 		CamelStream *stream;
 		const gchar *charset;
 
@@ -1035,19 +1035,19 @@ e_attachment_add_to_multipart (EAttachment *attachment,
 		/* Determine the best encoding by writing the MIME
 		 * part to a NULL stream with a "bestenc" filter. */
 		stream = camel_stream_null_new ();
-		filtered_stream = camel_stream_filter_new_with_stream (stream);
+		filtered_stream = camel_stream_filter_new (stream);
 		filter = camel_mime_filter_bestenc_new (
 			CAMEL_BESTENC_GET_ENCODING);
 		camel_stream_filter_add (
-			filtered_stream, CAMEL_MIME_FILTER (filter));
-		camel_data_wrapper_decode_to_stream (
-			wrapper, CAMEL_STREAM (filtered_stream));
+			CAMEL_STREAM_FILTER (filtered_stream), filter);
+		camel_data_wrapper_decode_to_stream (wrapper, filtered_stream);
 		g_object_unref (filtered_stream);
 		g_object_unref (stream);
 
 		/* Retrieve the best encoding from the filter. */
 		encoding = camel_mime_filter_bestenc_get_best_encoding (
-			filter, CAMEL_BESTENC_8BIT);
+			CAMEL_MIME_FILTER_BESTENC (filter),
+			CAMEL_BESTENC_8BIT);
 		camel_mime_part_set_encoding (mime_part, encoding);
 		g_object_unref (filter);
 
@@ -1526,7 +1526,7 @@ attachment_load_finish (LoadContext *load_context)
 	g_object_unref (stream);
 
 	mime_part = camel_mime_part_new ();
-	camel_medium_set_content_object (CAMEL_MEDIUM (mime_part), wrapper);
+	camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
 
 	g_object_unref (wrapper);
 	g_free (mime_type);
@@ -2457,7 +2457,7 @@ attachment_save_got_output_stream (SaveContext *save_context)
 	buffer = g_byte_array_new ();
 	stream = camel_stream_mem_new ();
 	camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer);
-	wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
+	wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
 	camel_data_wrapper_decode_to_stream (wrapper, stream);
 	g_object_unref (stream);
 



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