[evolution-data-server] Merge some cleanup bits from camel-gobject.



commit ea9cc0df049d8c7240b83e2a9b11b12095f9430f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Apr 10 18:27:39 2010 -0400

    Merge some cleanup bits from camel-gobject.

 camel/camel-folder-search.c                        |   15 +-
 camel/camel-http-stream.c                          |  436 ++++++++--------
 camel/camel-multipart-signed.c                     |    8 +-
 camel/camel-seekable-stream.c                      |  123 +++---
 camel/camel-seekable-stream.h                      |    2 +
 camel/camel-seekable-substream.c                   |  238 +++++-----
 camel/camel-stream-buffer.c                        |  552 +++++++++++---------
 camel/camel-stream-buffer.h                        |   16 +-
 camel/camel-stream-filter.c                        |  455 +++++++++--------
 camel/camel-stream-filter.h                        |    4 +-
 camel/camel-stream-fs.c                            |  302 ++++++-----
 camel/camel-stream-fs.h                            |    5 +-
 camel/camel-stream-mem.c                           |  354 +++++++------
 camel/camel-stream-mem.h                           |    7 +-
 camel/camel-stream-null.c                          |   53 ++-
 camel/camel-stream-process.c                       |  152 +++---
 camel/camel-stream-vfs.c                           |  219 ++++----
 camel/camel-stream-vfs.h                           |    2 -
 camel/camel-stream.c                               |  133 ++++--
 camel/camel-stream.h                               |    4 +-
 camel/camel-tcp-stream-raw.c                       |  304 +++++------
 camel/camel-tcp-stream-ssl.c                       |  389 +++++++-------
 camel/camel-tcp-stream.c                           |  104 ++---
 camel/camel-tcp-stream.h                           |    7 +-
 camel/providers/groupwise/camel-groupwise-utils.c  |   22 +-
 camel/providers/imapx/camel-imapx-server.c         |   17 +-
 camel/providers/local/camel-mbox-folder.c          |    6 +-
 camel/providers/nntp/camel-nntp-store.c            |    8 +-
 docs/reference/camel/tmpl/camel-address.sgml       |    3 +
 docs/reference/camel/tmpl/camel-block-file.sgml    |   19 +
 docs/reference/camel/tmpl/camel-certdb.sgml        |   10 +
 .../reference/camel/tmpl/camel-cipher-context.sgml |    7 +-
 docs/reference/camel/tmpl/camel-data-cache.sgml    |    7 +-
 docs/reference/camel/tmpl/camel-data-wrapper.sgml  |    6 +
 docs/reference/camel/tmpl/camel-disco-diary.sgml   |    5 +
 docs/reference/camel/tmpl/camel-disco-folder.sgml  |    2 +
 docs/reference/camel/tmpl/camel-disco-store.sgml   |    3 +
 docs/reference/camel/tmpl/camel-filter-driver.sgml |    2 +
 docs/reference/camel/tmpl/camel-folder-search.sgml |   10 +
 .../reference/camel/tmpl/camel-folder-summary.sgml |   27 +
 docs/reference/camel/tmpl/camel-folder.sgml        |   10 +
 docs/reference/camel/tmpl/camel-gpg-context.sgml   |    7 +-
 docs/reference/camel/tmpl/camel-html-parser.sgml   |    2 +
 docs/reference/camel/tmpl/camel-http-stream.sgml   |   14 +
 docs/reference/camel/tmpl/camel-index.sgml         |   17 +
 .../camel/tmpl/camel-internet-address.sgml         |    2 +
 docs/reference/camel/tmpl/camel-medium.sgml        |    7 +-
 .../camel/tmpl/camel-mime-filter-basic.sgml        |    2 +
 .../camel/tmpl/camel-mime-filter-bestenc.sgml      |    2 +
 .../camel/tmpl/camel-mime-filter-canon.sgml        |    2 +
 .../camel/tmpl/camel-mime-filter-charset.sgml      |    2 +
 .../camel/tmpl/camel-mime-filter-crlf.sgml         |    2 +
 .../camel/tmpl/camel-mime-filter-enriched.sgml     |    2 +
 .../camel/tmpl/camel-mime-filter-from.sgml         |    2 +
 .../camel/tmpl/camel-mime-filter-gzip.sgml         |    2 +
 .../camel/tmpl/camel-mime-filter-html.sgml         |    2 +
 .../camel/tmpl/camel-mime-filter-index.sgml        |    2 +
 .../camel/tmpl/camel-mime-filter-linewrap.sgml     |    2 +
 .../camel/tmpl/camel-mime-filter-pgp.sgml          |    2 +
 .../camel/tmpl/camel-mime-filter-progress.sgml     |    2 +
 .../camel/tmpl/camel-mime-filter-save.sgml         |    2 +
 .../camel/tmpl/camel-mime-filter-tohtml.sgml       |    2 +
 .../camel/tmpl/camel-mime-filter-windows.sgml      |    2 +
 .../camel/tmpl/camel-mime-filter-yenc.sgml         |    2 +
 docs/reference/camel/tmpl/camel-mime-filter.sgml   |   10 +
 docs/reference/camel/tmpl/camel-mime-message.sgml  |   10 +
 docs/reference/camel/tmpl/camel-mime-parser.sgml   |    2 +
 docs/reference/camel/tmpl/camel-mime-part.sgml     |   29 +-
 .../camel/tmpl/camel-multipart-encrypted.sgml      |    5 +
 .../camel/tmpl/camel-multipart-signed.sgml         |   10 +
 docs/reference/camel/tmpl/camel-multipart.sgml     |    4 +
 docs/reference/camel/tmpl/camel-nntp-address.sgml  |    2 +
 docs/reference/camel/tmpl/camel-object.sgml        |    7 +
 .../reference/camel/tmpl/camel-offline-folder.sgml |    2 +
 .../camel/tmpl/camel-offline-journal.sgml          |    4 +
 docs/reference/camel/tmpl/camel-offline-store.sgml |    2 +
 .../camel/tmpl/camel-partition-table.sgml          |   13 +
 .../reference/camel/tmpl/camel-sasl-anonymous.sgml |    3 +
 docs/reference/camel/tmpl/camel-sasl-cram-md5.sgml |    2 +
 .../camel/tmpl/camel-sasl-digest-md5.sgml          |    2 +
 docs/reference/camel/tmpl/camel-sasl-gssapi.sgml   |    2 +
 docs/reference/camel/tmpl/camel-sasl-login.sgml    |    2 +
 docs/reference/camel/tmpl/camel-sasl-ntlm.sgml     |    2 +
 docs/reference/camel/tmpl/camel-sasl-plain.sgml    |    2 +
 .../reference/camel/tmpl/camel-sasl-popb4smtp.sgml |    2 +
 docs/reference/camel/tmpl/camel-sasl.sgml          |   22 +-
 .../camel/tmpl/camel-seekable-stream.sgml          |    4 +
 .../camel/tmpl/camel-seekable-substream.sgml       |    2 +
 docs/reference/camel/tmpl/camel-service.sgml       |    7 +
 docs/reference/camel/tmpl/camel-session.sgml       |    7 +
 docs/reference/camel/tmpl/camel-smime-context.sgml |    2 +
 docs/reference/camel/tmpl/camel-store-summary.sgml |   12 +
 docs/reference/camel/tmpl/camel-store.sgml         |    8 +
 docs/reference/camel/tmpl/camel-stream-buffer.sgml |   10 +
 docs/reference/camel/tmpl/camel-stream-filter.sgml |    3 +
 docs/reference/camel/tmpl/camel-stream-fs.sgml     |    2 +
 docs/reference/camel/tmpl/camel-stream-mem.sgml    |    4 +
 docs/reference/camel/tmpl/camel-stream-null.sgml   |    2 +
 .../reference/camel/tmpl/camel-stream-process.sgml |    3 +
 docs/reference/camel/tmpl/camel-stream-vfs.sgml    |    2 +
 docs/reference/camel/tmpl/camel-stream.sgml        |    2 +
 .../reference/camel/tmpl/camel-tcp-stream-raw.sgml |    3 +
 .../reference/camel/tmpl/camel-tcp-stream-ssl.sgml |    2 +
 docs/reference/camel/tmpl/camel-tcp-stream.sgml    |    1 +
 docs/reference/camel/tmpl/camel-text-index.sgml    |    8 +
 docs/reference/camel/tmpl/camel-transport.sgml     |    2 +
 docs/reference/camel/tmpl/camel-unused.sgml        |   72 +++
 docs/reference/camel/tmpl/camel-vee-folder.sgml    |   10 +
 docs/reference/camel/tmpl/camel-vee-store.sgml     |    3 +
 docs/reference/camel/tmpl/camel-vee-summary.sgml   |    3 +
 docs/reference/camel/tmpl/camel-vtrash-folder.sgml |    3 +
 111 files changed, 2537 insertions(+), 1910 deletions(-)
---
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index 4692ab8..5d53e8e 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -35,7 +35,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-exception.h"
@@ -1396,14 +1395,18 @@ match_words_1message (CamelDataWrapper *object, struct _camel_search_words *word
 		truth = match_words_1message((CamelDataWrapper *)containee, words, mask);
 	} else if (camel_content_type_is(CAMEL_DATA_WRAPPER (containee)->mime_type, "text", "*")) {
 		/* for all other text parts, we look inside, otherwise we dont care */
-		CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new ();
+		CamelStream *stream;
+		GByteArray *byte_array;
+
+		byte_array = g_byte_array_new ();
+		stream = camel_stream_mem_new_with_byte_array (byte_array);
 
 		/* FIXME: The match should be part of a stream op */
-		camel_data_wrapper_decode_to_stream (containee, CAMEL_STREAM (mem));
-		camel_stream_write (CAMEL_STREAM (mem), "", 1);
+		camel_data_wrapper_decode_to_stream (containee, stream);
+		camel_stream_write (stream, "", 1);
 		for (i=0;i<words->len;i++) {
 			/* FIXME: This is horridly slow, and should use a real search algorithm */
-			if (camel_ustrstrcase((const gchar *) mem->buffer->data, words->words[i]->word) != NULL) {
+			if (camel_ustrstrcase((const gchar *) byte_array->data, words->words[i]->word) != NULL) {
 				*mask |= (1<<i);
 				/* shortcut a match */
 				if (*mask == (1<<(words->len))-1)
@@ -1411,7 +1414,7 @@ match_words_1message (CamelDataWrapper *object, struct _camel_search_words *word
 			}
 		}
 
-		camel_object_unref (mem);
+		camel_object_unref (stream);
 	}
 
 	return truth;
diff --git a/camel/camel-http-stream.c b/camel/camel-http-stream.c
index 456e9a1..f51dce9 100644
--- a/camel/camel-http-stream.c
+++ b/camel/camel-http-stream.c
@@ -43,6 +43,8 @@
 #include "camel-tcp-stream-ssl.h"
 #endif
 
+#define SSL_FLAGS (CAMEL_TCP_STREAM_SSL_ENABLE_SSL2 | CAMEL_TCP_STREAM_SSL_ENABLE_SSL3)
+
 #ifdef G_OS_WIN32
 #include <winsock2.h>
 #include <ws2tcpip.h>
@@ -52,131 +54,11 @@
 
 static CamelStreamClass *parent_class = NULL;
 
-static gssize stream_read (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write (CamelStream *stream, const gchar *buffer, gsize n);
-static gint stream_flush  (CamelStream *stream);
-static gint stream_close  (CamelStream *stream);
-static gint stream_reset  (CamelStream *stream);
-
-static void
-camel_http_stream_class_init (CamelHttpStreamClass *camel_http_stream_class)
-{
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_http_stream_class);
-
-	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
-
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
-	camel_stream_class->reset = stream_reset;
-}
-
-static void
-camel_http_stream_init (gpointer object, gpointer klass)
-{
-	CamelHttpStream *http = CAMEL_HTTP_STREAM (object);
-
-	http->parser = NULL;
-	http->content_type = NULL;
-	http->headers = NULL;
-	http->session = NULL;
-	http->url = NULL;
-	http->proxy = NULL;
-	http->authrealm = NULL;
-	http->authpass = NULL;
-	http->statuscode = 0;
-	http->raw = NULL;
-}
-
-static void
-camel_http_stream_finalize (CamelObject *object)
-{
-	CamelHttpStream *http = CAMEL_HTTP_STREAM (object);
-
-	if (http->parser)
-		camel_object_unref(http->parser);
-
-	if (http->content_type)
-		camel_content_type_unref (http->content_type);
-
-	if (http->headers)
-		camel_header_raw_clear (&http->headers);
-
-	if (http->session)
-		camel_object_unref(http->session);
-
-	if (http->url)
-		camel_url_free (http->url);
-
-	if (http->proxy)
-		camel_url_free (http->proxy);
-
-	g_free (http->authrealm);
-	g_free (http->authpass);
-
-	if (http->raw)
-		camel_object_unref(http->raw);
-	if (http->read)
-		camel_object_unref(http->read);
-}
-
-CamelType
-camel_http_stream_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_stream_get_type (),
-					    "CamelHttpStream",
-					    sizeof (CamelHttpStream),
-					    sizeof (CamelHttpStreamClass),
-					    (CamelObjectClassInitFunc) camel_http_stream_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_http_stream_init,
-					    (CamelObjectFinalizeFunc) camel_http_stream_finalize);
-	}
-
-	return type;
-}
-
-/**
- * camel_http_stream_new:
- * @method: HTTP method
- * @session: active session
- * @url: URL to act upon
- *
- * Returns: a http stream
- **/
-CamelStream *
-camel_http_stream_new (CamelHttpMethod method, struct _CamelSession *session, CamelURL *url)
-{
-	CamelHttpStream *stream;
-	gchar *str;
-
-	g_return_val_if_fail(CAMEL_IS_SESSION(session), NULL);
-	g_return_val_if_fail(url != NULL, NULL);
-
-	stream = CAMEL_HTTP_STREAM (camel_object_new (camel_http_stream_get_type ()));
-
-	stream->method = method;
-	stream->session = session;
-	camel_object_ref(session);
-
-	str = camel_url_to_string (url, 0);
-	stream->url = camel_url_new (str, NULL);
-	g_free (str);
-
-	return (CamelStream *)stream;
-}
-
-#define SSL_FLAGS (CAMEL_TCP_STREAM_SSL_ENABLE_SSL2 | CAMEL_TCP_STREAM_SSL_ENABLE_SSL3)
-
 static CamelStream *
-http_connect (CamelHttpStream *http, CamelURL *url)
+http_connect (CamelHttpStream *http,
+              CamelURL *url)
 {
+	CamelTcpStream *tcp_stream;
 	CamelStream *stream = NULL;
 	struct addrinfo *ai, hints = { 0 };
 	gint errsave;
@@ -211,7 +93,9 @@ http_connect (CamelHttpStream *http, CamelURL *url)
 		return NULL;
 	}
 
-	if (camel_tcp_stream_connect (CAMEL_TCP_STREAM (stream), ai) == -1) {
+	tcp_stream = CAMEL_TCP_STREAM (stream);
+
+	if (camel_tcp_stream_connect (tcp_stream, ai) == -1) {
 		errsave = errno;
 		camel_object_unref (stream);
 		camel_freeaddrinfo(ai);
@@ -228,59 +112,97 @@ http_connect (CamelHttpStream *http, CamelURL *url)
 }
 
 static void
-http_disconnect(CamelHttpStream *http)
+http_disconnect (CamelHttpStream *http)
 {
 	if (http->raw) {
-		camel_object_unref(http->raw);
+		camel_object_unref (http->raw);
 		http->raw = NULL;
 	}
 
 	if (http->read) {
-		camel_object_unref(http->read);
+		camel_object_unref (http->read);
 		http->read = NULL;
 	}
 
 	if (http->parser) {
-		camel_object_unref(http->parser);
+		camel_object_unref (http->parser);
 		http->parser = NULL;
 	}
 }
 
-static const gchar *
-http_next_token (const guchar *in)
+static gint
+http_method_invoke (CamelHttpStream *http)
 {
-	const guchar *inptr = in;
+	const gchar *method = NULL, *use_url;
+	gchar *url;
 
-	while (*inptr && !isspace ((gint) *inptr))
-		inptr++;
+	switch (http->method) {
+	case CAMEL_HTTP_METHOD_GET:
+		method = "GET";
+		break;
+	case CAMEL_HTTP_METHOD_HEAD:
+		method = "HEAD";
+		break;
+	default:
+		g_assert_not_reached ();
+	}
 
-	while (*inptr && isspace ((gint) *inptr))
-		inptr++;
+	url = camel_url_to_string (http->url, 0);
 
-	return (const gchar *) inptr;
-}
+	if (http->proxy) {
+		use_url = url;
+	} else if (http->url->host && *http->url->host) {
+		use_url = strstr (url, http->url->host) + strlen (http->url->host);
+	} else {
+		use_url = http->url->path;
+	}
 
-static gint
-http_get_statuscode (CamelHttpStream *http)
-{
-	const gchar *token;
-	gchar buffer[4096];
+	d(printf("HTTP Stream Sending: %s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
+		 method,
+		 use_url,
+		 http->user_agent ? http->user_agent : "CamelHttpStream/1.0",
+		 http->url->host));
+	if (camel_stream_printf (
+		http->raw,
+		"%s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
+		method, use_url, http->user_agent ? http->user_agent :
+		"CamelHttpStream/1.0", http->url->host) == -1) {
+		http_disconnect(http);
+		g_free (url);
+		return -1;
+	}
+	g_free (url);
+
+	if (http->authrealm) {
+		d(printf("HTTP Stream Sending: WWW-Authenticate: %s\n", http->authrealm));
+	}
 
-	if (camel_stream_buffer_gets ((CamelStreamBuffer *)http->read, buffer, sizeof (buffer)) <= 0)
+	if (http->authrealm && camel_stream_printf (
+		http->raw, "WWW-Authenticate: %s\r\n",
+		http->authrealm) == -1) {
+		http_disconnect(http);
 		return -1;
+	}
 
-	d(printf("HTTP Status: %s\n", buffer));
+	if (http->authpass && http->proxy) {
+		d(printf("HTTP Stream Sending: Proxy-Aurhorization: Basic %s\n", http->authpass));
+	}
 
-	/* parse the HTTP status code */
-	if (!g_ascii_strncasecmp (buffer, "HTTP/", 5)) {
-		token = http_next_token ((const guchar *) buffer);
-		http->statuscode = camel_header_decode_int (&token);
-		return http->statuscode;
+	if (http->authpass && http->proxy && camel_stream_printf (
+		http->raw, "Proxy-Authorization: Basic %s\r\n",
+		http->authpass) == -1) {
+		http_disconnect(http);
+		return -1;
 	}
 
-	http_disconnect(http);
+	/* end the headers */
+	if (camel_stream_write (http->raw, "\r\n", 2) == -1 ||
+		camel_stream_flush (http->raw) == -1) {
+		http_disconnect(http);
+		return -1;
+	}
 
-	return -1;
+	return 0;
 }
 
 static gint
@@ -352,79 +274,80 @@ http_get_headers (CamelHttpStream *http)
 	return -1;
 }
 
-static gint
-http_method_invoke (CamelHttpStream *http)
+static const gchar *
+http_next_token (const guchar *in)
 {
-	const gchar *method = NULL, *use_url;
-	gchar *url;
+	const guchar *inptr = in;
 
-	switch (http->method) {
-	case CAMEL_HTTP_METHOD_GET:
-		method = "GET";
-		break;
-	case CAMEL_HTTP_METHOD_HEAD:
-		method = "HEAD";
-		break;
-	default:
-		g_assert_not_reached ();
-	}
+	while (*inptr && !isspace ((gint) *inptr))
+		inptr++;
 
-	url = camel_url_to_string (http->url, 0);
+	while (*inptr && isspace ((gint) *inptr))
+		inptr++;
 
-	if (http->proxy) {
-		use_url = url;
-	} else if (http->url->host && *http->url->host) {
-		use_url = strstr (url, http->url->host) + strlen (http->url->host);
-	} else {
-		use_url = http->url->path;
-	}
+	return (const gchar *) inptr;
+}
 
-	d(printf("HTTP Stream Sending: %s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
-		 method,
-		 use_url,
-		 http->user_agent ? http->user_agent : "CamelHttpStream/1.0",
-		 http->url->host));
-	if (camel_stream_printf (http->raw, "%s %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\n",
-				 method,
-				 use_url,
-				 http->user_agent ? http->user_agent : "CamelHttpStream/1.0",
-				 http->url->host) == -1) {
-		http_disconnect(http);
-		g_free (url);
+static gint
+http_get_statuscode (CamelHttpStream *http)
+{
+	const gchar *token;
+	gchar buffer[4096];
+
+	if (camel_stream_buffer_gets (
+		CAMEL_STREAM_BUFFER (http->read),
+		buffer, sizeof (buffer)) <= 0)
 		return -1;
-	}
-	g_free (url);
 
-	if (http->authrealm) {
-		d(printf("HTTP Stream Sending: WWW-Authenticate: %s\n", http->authrealm));
-	}
+	d(printf("HTTP Status: %s\n", buffer));
 
-	if (http->authrealm && camel_stream_printf (http->raw, "WWW-Authenticate: %s\r\n", http->authrealm) == -1) {
-		http_disconnect(http);
-		return -1;
+	/* parse the HTTP status code */
+	if (!g_ascii_strncasecmp (buffer, "HTTP/", 5)) {
+		token = http_next_token ((const guchar *) buffer);
+		http->statuscode = camel_header_decode_int (&token);
+		return http->statuscode;
 	}
 
-	if (http->authpass && http->proxy) {
-		d(printf("HTTP Stream Sending: Proxy-Aurhorization: Basic %s\n", http->authpass));
-	}
+	http_disconnect(http);
 
-	if (http->authpass && http->proxy && camel_stream_printf (http->raw, "Proxy-Authorization: Basic %s\r\n",
-								  http->authpass) == -1) {
-		http_disconnect(http);
-		return -1;
-	}
+	return -1;
+}
 
-	/* end the headers */
-	if (camel_stream_write (http->raw, "\r\n", 2) == -1 || camel_stream_flush (http->raw) == -1) {
-		http_disconnect(http);
-		return -1;
-	}
+static void
+http_stream_finalize (CamelHttpStream *http)
+{
+	if (http->parser)
+		camel_object_unref(http->parser);
 
-	return 0;
+	if (http->content_type)
+		camel_content_type_unref (http->content_type);
+
+	if (http->headers)
+		camel_header_raw_clear (&http->headers);
+
+	if (http->session != NULL)
+		camel_object_unref (http->session);
+
+	if (http->url != NULL)
+		camel_url_free (http->url);
+
+	if (http->proxy)
+		camel_url_free (http->proxy);
+
+	g_free (http->authrealm);
+	g_free (http->authpass);
+
+	if (http->raw != NULL)
+		camel_object_unref (http->raw);
+
+	if (http->read != NULL)
+		camel_object_unref (http->read);
 }
 
 static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
+http_stream_read (CamelStream *stream,
+                  gchar *buffer,
+                  gsize n)
 {
 	CamelHttpStream *http = CAMEL_HTTP_STREAM (stream);
 	const gchar *parser_buf;
@@ -438,7 +361,9 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
  redirect:
 
 	if (!http->raw) {
-		if (http_connect (http, http->proxy ? http->proxy : http->url) == NULL)
+		if (http_connect (
+			http, http->proxy ? http->proxy :
+			http->url) == NULL)
 			return -1;
 
 		if (http_method_invoke (http) == -1) {
@@ -517,13 +442,15 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
 }
 
 static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+http_stream_write (CamelStream *stream,
+                   const gchar *buffer,
+                   gsize n)
 {
 	return -1;
 }
 
 static gint
-stream_flush (CamelStream *stream)
+http_stream_flush (CamelStream *stream)
 {
 	CamelHttpStream *http = (CamelHttpStream *) stream;
 
@@ -534,7 +461,7 @@ stream_flush (CamelStream *stream)
 }
 
 static gint
-stream_close (CamelStream *stream)
+http_stream_close (CamelStream *stream)
 {
 	CamelHttpStream *http = (CamelHttpStream *) stream;
 
@@ -549,7 +476,7 @@ stream_close (CamelStream *stream)
 }
 
 static gint
-stream_reset (CamelStream *stream)
+http_stream_reset (CamelStream *stream)
 {
 	CamelHttpStream *http = CAMEL_HTTP_STREAM (stream);
 
@@ -559,13 +486,94 @@ stream_reset (CamelStream *stream)
 	return 0;
 }
 
+static void
+camel_http_stream_class_init (CamelHttpStreamClass *class)
+{
+	CamelStreamClass *stream_class;
+
+	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = http_stream_read;
+	stream_class->write = http_stream_write;
+	stream_class->flush = http_stream_flush;
+	stream_class->close = http_stream_close;
+	stream_class->reset = http_stream_reset;
+}
+
+static void
+camel_http_stream_init (CamelHttpStream *http)
+{
+	http->parser = NULL;
+	http->content_type = NULL;
+	http->headers = NULL;
+	http->session = NULL;
+	http->url = NULL;
+	http->proxy = NULL;
+	http->authrealm = NULL;
+	http->authpass = NULL;
+	http->statuscode = 0;
+	http->raw = NULL;
+}
+
+CamelType
+camel_http_stream_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (camel_stream_get_type (),
+					    "CamelHttpStream",
+					    sizeof (CamelHttpStream),
+					    sizeof (CamelHttpStreamClass),
+					    (CamelObjectClassInitFunc) camel_http_stream_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_http_stream_init,
+					    (CamelObjectFinalizeFunc) http_stream_finalize);
+	}
+
+	return type;
+}
+
+/**
+ * camel_http_stream_new:
+ * @method: HTTP method
+ * @session: active session
+ * @url: URL to act upon
+ *
+ * Returns: a http stream
+ **/
+CamelStream *
+camel_http_stream_new (CamelHttpMethod method, struct _CamelSession *session, CamelURL *url)
+{
+	CamelHttpStream *stream;
+	gchar *str;
+
+	g_return_val_if_fail(CAMEL_IS_SESSION(session), NULL);
+	g_return_val_if_fail(url != NULL, NULL);
+
+	stream = CAMEL_HTTP_STREAM (camel_object_new (camel_http_stream_get_type ()));
+
+	stream->method = method;
+	stream->session = session;
+	camel_object_ref(session);
+
+	str = camel_url_to_string (url, 0);
+	stream->url = camel_url_new (str, NULL);
+	g_free (str);
+
+	return (CamelStream *)stream;
+}
+
 CamelContentType *
 camel_http_stream_get_content_type (CamelHttpStream *http_stream)
 {
 	g_return_val_if_fail (CAMEL_IS_HTTP_STREAM (http_stream), NULL);
 
 	if (!http_stream->content_type && !http_stream->raw) {
-		if (stream_read (CAMEL_STREAM (http_stream), NULL, 0) == -1)
+		CamelStream *stream = CAMEL_STREAM (http_stream);
+
+		if (http_stream_read (stream, NULL, 0) == -1)
 			return NULL;
 	}
 
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index c8ad7e6..cdc871e 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -265,11 +265,15 @@ parse_content(CamelMultipartSigned *mps)
 		if (mps->start1 == -1) {
 			mps->start1 = camel_mime_parser_tell_start_headers(cmp);
 		} else if (mps->start2 == -1) {
+			GByteArray *buffer;
+
+			buffer = camel_stream_mem_get_byte_array (
+				CAMEL_STREAM_MEM (mem));
 			mps->start2 = camel_mime_parser_tell_start_headers(cmp);
 			mps->end1 = camel_mime_parser_tell_start_boundary(cmp);
-			if (mps->end1 > mps->start1 && mem->buffer->data[mps->end1-1] == '\n')
+			if (mps->end1 > mps->start1 && buffer->data[mps->end1-1] == '\n')
 				mps->end1--;
-			if (mps->end1 > mps->start1 && mem->buffer->data[mps->end1-1] == '\r')
+			if (mps->end1 > mps->start1 && buffer->data[mps->end1-1] == '\r')
 				mps->end1--;
 		} else {
 			g_warning("multipart/signed has more than 2 parts, remaining parts ignored");
diff --git a/camel/camel-seekable-stream.c b/camel/camel-seekable-stream.c
index 1d6001e..1e86002 100644
--- a/camel/camel-seekable-stream.c
+++ b/camel/camel-seekable-stream.c
@@ -29,37 +29,57 @@
 
 static CamelStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelSeekableStream */
-#define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static gint
+seekable_stream_reset (CamelStream *stream)
+{
+	CamelSeekableStream *seekable_stream;
+
+	seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
+
+	return camel_seekable_stream_seek (
+		seekable_stream, seekable_stream->bound_start,
+		CAMEL_STREAM_SET);
+}
+
+static off_t
+seekable_stream_tell (CamelSeekableStream *stream)
+{
+	return stream->position;
+}
+
+static gint
+seekable_stream_set_bounds (CamelSeekableStream *stream,
+                            off_t start,
+                            off_t end)
+{
+	/* store the bounds */
+	stream->bound_start = start;
+	stream->bound_end = end;
 
-static off_t seek        (CamelSeekableStream *stream, off_t offset,
-			  CamelStreamSeekPolicy policy);
-static off_t stream_tell (CamelSeekableStream *stream);
-static gint   reset       (CamelStream *stream);
-static gint   set_bounds  (CamelSeekableStream *stream, off_t start, off_t end);
+	if (start > stream->position)
+		return camel_seekable_stream_seek (
+			stream, start, CAMEL_STREAM_SET);
+
+	return 0;
+}
 
 static void
-camel_seekable_stream_class_init (CamelSeekableStreamClass *camel_seekable_stream_class)
+camel_seekable_stream_class_init (CamelSeekableStreamClass *class)
 {
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_seekable_stream_class);
+	CamelStreamClass *stream_class;
 
 	parent_class = CAMEL_STREAM_CLASS( camel_type_get_global_classfuncs( CAMEL_STREAM_TYPE ) );
 
-	/* seekable stream methods */
-	camel_seekable_stream_class->seek = seek;
-	camel_seekable_stream_class->tell = stream_tell;
-	camel_seekable_stream_class->set_bounds = set_bounds;
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->reset = seekable_stream_reset;
 
-	/* camel stream methods overload */
-	camel_stream_class->reset = reset;
+	class->tell = seekable_stream_tell;
+	class->set_bounds = seekable_stream_set_bounds;
 }
 
 static void
-camel_seekable_stream_init (gpointer o)
+camel_seekable_stream_init (CamelSeekableStream *stream)
 {
-	CamelSeekableStream *stream = (CamelSeekableStream *)o;
-
 	stream->bound_start = 0;
 	stream->bound_end = CAMEL_STREAM_UNBOUND;
 }
@@ -83,15 +103,6 @@ camel_seekable_stream_get_type (void)
 	return camel_seekable_stream_type;
 }
 
-static off_t
-seek (CamelSeekableStream *stream, off_t offset,
-      CamelStreamSeekPolicy policy)
-{
-	g_warning ("CamelSeekableStream::seek called on default "
-		   "implementation\n");
-	return -1;
-}
-
 /**
  * camel_seekable_stream_seek:
  * @stream: a #CamelStream object
@@ -115,18 +126,18 @@ seek (CamelSeekableStream *stream, off_t offset,
  * Returns: new position, %-1 if operation failed.
  **/
 off_t
-camel_seekable_stream_seek (CamelSeekableStream *stream, off_t offset,
-			    CamelStreamSeekPolicy policy)
+camel_seekable_stream_seek (CamelSeekableStream *stream,
+                            off_t offset,
+                            CamelStreamSeekPolicy policy)
 {
+	CamelSeekableStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (stream), -1);
 
-	return CSS_CLASS (stream)->seek (stream, offset, policy);
-}
+	class = CAMEL_SEEKABLE_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->seek != NULL, -1);
 
-static off_t
-stream_tell (CamelSeekableStream *stream)
-{
-	return stream->position;
+	return class->seek (stream, offset, policy);
 }
 
 /**
@@ -140,22 +151,14 @@ stream_tell (CamelSeekableStream *stream)
 off_t
 camel_seekable_stream_tell (CamelSeekableStream *stream)
 {
-	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (stream), -1);
+	CamelSeekableStreamClass *class;
 
-	return CSS_CLASS (stream)->tell (stream);
-}
-
-static gint
-set_bounds (CamelSeekableStream *stream, off_t start, off_t end)
-{
-	/* store the bounds */
-	stream->bound_start = start;
-	stream->bound_end = end;
+	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (stream), -1);
 
-	if (start > stream->position)
-		return camel_seekable_stream_seek (stream, start, CAMEL_STREAM_SET);
+	class = CAMEL_SEEKABLE_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->tell != NULL, -1);
 
-	return 0;
+	return class->tell (stream);
 }
 
 /**
@@ -172,24 +175,16 @@ set_bounds (CamelSeekableStream *stream, off_t start, off_t end)
  **/
 gint
 camel_seekable_stream_set_bounds (CamelSeekableStream *stream,
-				  off_t start, off_t end)
+                                  off_t start,
+                                  off_t end)
 {
+	CamelSeekableStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (stream), -1);
 	g_return_val_if_fail (end == CAMEL_STREAM_UNBOUND || end >= start, -1);
 
-	return CSS_CLASS (stream)->set_bounds (stream, start, end);
-}
+	class = CAMEL_SEEKABLE_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->set_bounds != NULL, -1);
 
-/* a default implementation of reset for seekable streams */
-static gint
-reset (CamelStream *stream)
-{
-	CamelSeekableStream *seekable_stream;
-
-	seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
-
-	return camel_seekable_stream_seek (seekable_stream,
-					   seekable_stream->bound_start,
-					   CAMEL_STREAM_SET);
+	return class->set_bounds (stream, start, end);
 }
-
diff --git a/camel/camel-seekable-stream.h b/camel/camel-seekable-stream.h
index 9a5f4ea..b09915c 100644
--- a/camel/camel-seekable-stream.h
+++ b/camel/camel-seekable-stream.h
@@ -37,6 +37,8 @@
 #define CAMEL_SEEKABLE_STREAM(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStream))
 #define CAMEL_SEEKABLE_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStreamClass))
 #define CAMEL_IS_SEEKABLE_STREAM(o)    (CAMEL_CHECK_TYPE((o), CAMEL_SEEKABLE_STREAM_TYPE))
+#define CAMEL_SEEKABLE_STREAM_GET_CLASS(obj) \
+	((CamelSeekableStreamClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c
index 13f08ff..43e0dd6 100644
--- a/camel/camel-seekable-substream.c
+++ b/camel/camel-seekable-substream.c
@@ -29,120 +29,31 @@
 
 static CamelSeekableStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelSeekableSubStream */
-#define CSS_CLASS(so) CAMEL_SEEKABLE_SUBSTREAM_CLASS (CAMEL_OBJECT(so)->klass)
-
-static	gssize	 stream_read  (CamelStream *stream, gchar *buffer, gsize n);
-static	gssize	 stream_write (CamelStream *stream, const gchar *buffer, gsize n);
-static	gint	 stream_flush (CamelStream *stream);
-static	gint	 stream_close (CamelStream *stream);
-static	gboolean eos	      (CamelStream *stream);
-static	off_t	 stream_seek  (CamelSeekableStream *stream, off_t offset,
-			       CamelStreamSeekPolicy policy);
-
-static void
-camel_seekable_substream_class_init (CamelSeekableSubstreamClass *camel_seekable_substream_class)
+static gboolean
+seekable_substream_parent_reset (CamelSeekableSubstream *seekable_substream,
+                                 CamelSeekableStream *parent)
 {
-	CamelSeekableStreamClass *camel_seekable_stream_class =
-		CAMEL_SEEKABLE_STREAM_CLASS (camel_seekable_substream_class);
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_seekable_substream_class);
-
-	parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ()));
-
-	/* virtual method definition */
-
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
-	camel_stream_class->eos = eos;
+	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (seekable_substream);
 
-	camel_seekable_stream_class->seek = stream_seek;
+	if (camel_seekable_stream_tell (parent) == seekable_stream->position)
+		return TRUE;
 
+	return camel_seekable_stream_seek (
+		parent, (off_t) seekable_stream->position,
+		CAMEL_STREAM_SET) == seekable_stream->position;
 }
 
 static void
-camel_seekable_substream_finalize (CamelObject *object)
+camel_seekable_substream_finalize (CamelSeekableSubstream *seekable_substream)
 {
-	CamelSeekableSubstream *seekable_substream =
-		CAMEL_SEEKABLE_SUBSTREAM (object);
-
-	if (seekable_substream->parent_stream)
+	if (seekable_substream->parent_stream != NULL)
 		camel_object_unref (seekable_substream->parent_stream);
 }
 
-CamelType
-camel_seekable_substream_get_type (void)
-{
-	static CamelType camel_seekable_substream_type = CAMEL_INVALID_TYPE;
-
-	if (camel_seekable_substream_type == CAMEL_INVALID_TYPE) {
-		camel_seekable_substream_type = camel_type_register (camel_seekable_stream_get_type (), "CamelSeekableSubstream",
-								     sizeof (CamelSeekableSubstream),
-								     sizeof (CamelSeekableSubstreamClass),
-								     (CamelObjectClassInitFunc) camel_seekable_substream_class_init,
-								     NULL,
-								     NULL,
-								     (CamelObjectFinalizeFunc) camel_seekable_substream_finalize);
-	}
-
-	return camel_seekable_substream_type;
-}
-
-/**
- * camel_seekable_substream_new:
- * @parent_stream: a #CamelSeekableStream object
- * @start: a lower bound
- * @end: an upper bound
- *
- * Creates a new CamelSeekableSubstream that references the portion
- * of @parent_stream from @inf_bound to @sup_bound. (If @sup_bound is
- * #CAMEL_STREAM_UNBOUND, it references to the end of stream, even if
- * the stream grows.)
- *
- * While the substream is open, the caller cannot assume anything about
- * the current position of @parent_stream. After the substream has been
- * closed, @parent_stream will stabilize again.
- *
- * Returns: the substream
- **/
-CamelStream *
-camel_seekable_substream_new(CamelSeekableStream *parent_stream, off_t start, off_t end)
-{
-	CamelSeekableSubstream *seekable_substream;
-
-	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (parent_stream), NULL);
-
-	/* Create the seekable substream. */
-	seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (camel_object_new (camel_seekable_substream_get_type ()));
-
-	/* Initialize it. */
-	seekable_substream->parent_stream = parent_stream;
-	camel_object_ref (parent_stream);
-
-	/* Set the bound of the substream. We can ignore any possible error
-	 * here, because if we fail to seek now, it will try again later.
-	 */
-	camel_seekable_stream_set_bounds ((CamelSeekableStream *)seekable_substream, start, end);
-
-	return CAMEL_STREAM (seekable_substream);
-}
-
-static gboolean
-parent_reset (CamelSeekableSubstream *seekable_substream, CamelSeekableStream *parent)
-{
-	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (seekable_substream);
-
-	if (camel_seekable_stream_tell (parent) == seekable_stream->position)
-		return TRUE;
-
-	return camel_seekable_stream_seek (parent, (off_t) seekable_stream->position, CAMEL_STREAM_SET) == seekable_stream->position;
-}
-
 static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
+seekable_substream_read (CamelStream *stream,
+                         gchar *buffer,
+                         gsize n)
 {
 	CamelSeekableStream *parent;
 	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
@@ -155,7 +66,7 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
 	parent = seekable_substream->parent_stream;
 
 	/* Go to our position in the parent stream. */
-	if (!parent_reset (seekable_substream, parent)) {
+	if (!seekable_substream_parent_reset (seekable_substream, parent)) {
 		stream->eos = TRUE;
 		return 0;
 	}
@@ -179,7 +90,9 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
 }
 
 static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+seekable_substream_write (CamelStream *stream,
+                          const gchar *buffer,
+                          gsize n)
 {
 	CamelSeekableStream *parent;
 	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM(stream);
@@ -192,7 +105,7 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 	parent = seekable_substream->parent_stream;
 
 	/* Go to our position in the parent stream. */
-	if (!parent_reset (seekable_substream, parent)) {
+	if (!seekable_substream_parent_reset (seekable_substream, parent)) {
 		stream->eos = TRUE;
 		return 0;
 	}
@@ -206,7 +119,7 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 		return 0;
 	}
 
-	v = camel_stream_write((CamelStream *)parent, buffer, n);
+	v = camel_stream_write (CAMEL_STREAM (parent), buffer, n);
 
 	/* ignore <0 - it's an error, let the caller deal */
 	if (v > 0)
@@ -217,22 +130,22 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 }
 
 static gint
-stream_flush (CamelStream *stream)
+seekable_substream_flush (CamelStream *stream)
 {
 	CamelSeekableSubstream *sus = (CamelSeekableSubstream *)stream;
 
-	return camel_stream_flush(CAMEL_STREAM(sus->parent_stream));
+	return camel_stream_flush (CAMEL_STREAM (sus->parent_stream));
 }
 
 static gint
-stream_close (CamelStream *stream)
+seekable_substream_close (CamelStream *stream)
 {
 	/* we dont really want to close the substream ... */
 	return 0;
 }
 
 static gboolean
-eos (CamelStream *stream)
+seekable_substream_eos (CamelStream *stream)
 {
 	CamelSeekableSubstream *seekable_substream = CAMEL_SEEKABLE_SUBSTREAM(stream);
 	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM(stream);
@@ -243,7 +156,7 @@ eos (CamelStream *stream)
 		eos = TRUE;
 	else {
 		parent = seekable_substream->parent_stream;
-		if (!parent_reset (seekable_substream, parent))
+		if (!seekable_substream_parent_reset (seekable_substream, parent))
 			return TRUE;
 
 		eos = camel_stream_eos (CAMEL_STREAM (parent));
@@ -256,13 +169,17 @@ eos (CamelStream *stream)
 }
 
 static off_t
-stream_seek (CamelSeekableStream *seekable_stream, off_t offset,
-	     CamelStreamSeekPolicy policy)
+seekable_substream_seek (CamelSeekableStream *seekable_stream,
+                         off_t offset,
+                         CamelStreamSeekPolicy policy)
 {
-	CamelSeekableSubstream *seekable_substream = CAMEL_SEEKABLE_SUBSTREAM(seekable_stream);
-	CamelStream *stream = CAMEL_STREAM(seekable_stream);
+	CamelStream *stream;
+	CamelSeekableSubstream *seekable_substream;
 	off_t real_offset = 0;
 
+	stream = CAMEL_STREAM (seekable_stream);
+	seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (seekable_stream);
+
 	stream->eos = FALSE;
 
 	switch (policy) {
@@ -276,9 +193,9 @@ stream_seek (CamelSeekableStream *seekable_stream, off_t offset,
 
 	case CAMEL_STREAM_END:
 		if (seekable_stream->bound_end == CAMEL_STREAM_UNBOUND) {
-			real_offset = camel_seekable_stream_seek(seekable_substream->parent_stream,
-								 offset,
-								 CAMEL_STREAM_END);
+			real_offset = camel_seekable_stream_seek (
+				seekable_substream->parent_stream,
+				offset, CAMEL_STREAM_END);
 			if (real_offset != -1) {
 				if (real_offset<seekable_stream->bound_start)
 					real_offset = seekable_stream->bound_start;
@@ -297,5 +214,88 @@ stream_seek (CamelSeekableStream *seekable_stream, off_t offset,
 		real_offset = seekable_stream->bound_start;
 
 	seekable_stream->position = real_offset;
+
 	return real_offset;
 }
+
+static void
+camel_seekable_substream_class_init (CamelSeekableSubstreamClass *class)
+{
+	CamelStreamClass *stream_class;
+	CamelSeekableStreamClass *seekable_stream_class;
+
+	parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = seekable_substream_read;
+	stream_class->write = seekable_substream_write;
+	stream_class->flush = seekable_substream_flush;
+	stream_class->close = seekable_substream_close;
+	stream_class->eos = seekable_substream_eos;
+
+	seekable_stream_class = CAMEL_SEEKABLE_STREAM_CLASS (class);
+	seekable_stream_class->seek = seekable_substream_seek;
+}
+
+static void
+camel_seekable_substream_init (CamelSeekableSubstream *seekable_substream)
+{
+}
+
+CamelType
+camel_seekable_substream_get_type (void)
+{
+	static CamelType camel_seekable_substream_type = CAMEL_INVALID_TYPE;
+
+	if (camel_seekable_substream_type == CAMEL_INVALID_TYPE) {
+		camel_seekable_substream_type = camel_type_register (camel_seekable_stream_get_type (), "CamelSeekableSubstream",
+								     sizeof (CamelSeekableSubstream),
+								     sizeof (CamelSeekableSubstreamClass),
+								     (CamelObjectClassInitFunc) camel_seekable_substream_class_init,
+								     NULL,
+								     (CamelObjectInitFunc) camel_seekable_substream_init,
+								     (CamelObjectFinalizeFunc) camel_seekable_substream_finalize);
+	}
+
+	return camel_seekable_substream_type;
+}
+
+/**
+ * camel_seekable_substream_new:
+ * @parent_stream: a #CamelSeekableStream object
+ * @start: a lower bound
+ * @end: an upper bound
+ *
+ * Creates a new CamelSeekableSubstream that references the portion
+ * of @parent_stream from @inf_bound to @sup_bound. (If @sup_bound is
+ * #CAMEL_STREAM_UNBOUND, it references to the end of stream, even if
+ * the stream grows.)
+ *
+ * While the substream is open, the caller cannot assume anything about
+ * the current position of @parent_stream. After the substream has been
+ * closed, @parent_stream will stabilize again.
+ *
+ * Returns: the substream
+ **/
+CamelStream *
+camel_seekable_substream_new(CamelSeekableStream *parent_stream, off_t start, off_t end)
+{
+	CamelSeekableSubstream *seekable_substream;
+
+	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (parent_stream), NULL);
+
+	/* Create the seekable substream. */
+	seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (camel_object_new (camel_seekable_substream_get_type ()));
+
+	/* Initialize it. */
+	seekable_substream->parent_stream = parent_stream;
+	camel_object_ref (parent_stream);
+
+	/* Set the bound of the substream. We can ignore any possible error
+	 * here, because if we fail to seek now, it will try again later. */
+	camel_seekable_stream_set_bounds (
+		CAMEL_SEEKABLE_STREAM (seekable_substream),
+		start, end);
+
+	return CAMEL_STREAM (seekable_substream);
+}
diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c
index 34ea168..4bf8752 100644
--- a/camel/camel-stream-buffer.c
+++ b/camel/camel-stream-buffer.c
@@ -35,235 +35,138 @@
 
 static CamelStreamClass *parent_class = NULL;
 
-enum {
-	BUF_USER = 1<<0	/* user-supplied buffer, do not free */
-};
-
-#define BUF_SIZE 1024
-
-static gssize stream_read (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write (CamelStream *stream, const gchar *buffer, gsize n);
-static gint stream_flush (CamelStream *stream);
-static gint stream_close (CamelStream *stream);
-static gboolean stream_eos (CamelStream *stream);
+struct _CamelStreamBufferPrivate {
 
-static void init_vbuf(CamelStreamBuffer *sbf, CamelStream *s, CamelStreamBufferMode mode, gchar *buf, guint32 size);
-static void init(CamelStreamBuffer *sbuf, CamelStream *s, CamelStreamBufferMode mode);
+	CamelStream *stream;
 
-static void
-camel_stream_buffer_class_init (CamelStreamBufferClass *camel_stream_buffer_class)
-{
-	CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_buffer_class);
+	guchar *buf, *ptr, *end;
+	gint size;
 
-	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
+	guchar *linebuf;	/* for reading lines at a time */
+	gint linesize;
 
-	/* virtual method definition */
-	camel_stream_buffer_class->init = init;
-	camel_stream_buffer_class->init_vbuf = init_vbuf;
+	CamelStreamBufferMode mode;
+	guint flags;
+};
 
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
-	camel_stream_class->eos = stream_eos;
-}
+enum {
+	BUF_USER = 1<<0	/* user-supplied buffer, do not free */
+};
 
-static void
-camel_stream_buffer_init (gpointer object, gpointer klass)
-{
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (object);
-
-	sbf->flags = 0;
-	sbf->size = BUF_SIZE;
-	sbf->buf = g_malloc(BUF_SIZE);
-	sbf->ptr = sbf->buf;
-	sbf->end = sbf->buf;
-	sbf->mode = CAMEL_STREAM_BUFFER_READ | CAMEL_STREAM_BUFFER_BUFFER;
-	sbf->stream = NULL;
-	sbf->linesize = 80;
-	sbf->linebuf = g_malloc(sbf->linesize);
-}
+#define BUF_SIZE 1024
 
-static void
-camel_stream_buffer_finalize (CamelObject *object)
+/* only returns the number passed in, or -1 on an error */
+static gssize
+stream_write_all (CamelStream *stream,
+                  const gchar *buffer,
+                  gsize n)
 {
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (object);
+	gsize left = n, w;
 
-	if (!(sbf->flags & BUF_USER)) {
-		g_free(sbf->buf);
+	while (left > 0) {
+		w = camel_stream_write (stream, buffer, left);
+		if (w == -1)
+			return -1;
+		left -= w;
+		buffer += w;
 	}
-	if (sbf->stream)
-		camel_object_unref (sbf->stream);
 
-	g_free(sbf->linebuf);
+	return n;
 }
 
-CamelType
-camel_stream_buffer_get_type (void)
+static void
+set_vbuf (CamelStreamBuffer *stream,
+          gchar *buf,
+          CamelStreamBufferMode mode,
+          gint size)
 {
-	static CamelType camel_stream_buffer_type = CAMEL_INVALID_TYPE;
+	CamelStreamBufferPrivate *priv;
 
-	if (camel_stream_buffer_type == CAMEL_INVALID_TYPE)	{
-		camel_stream_buffer_type = camel_type_register (camel_stream_get_type (), "CamelStreamBuffer",
-								sizeof (CamelStreamBuffer),
-								sizeof (CamelStreamBufferClass),
-								(CamelObjectClassInitFunc) camel_stream_buffer_class_init,
-								NULL,
-								(CamelObjectInitFunc) camel_stream_buffer_init,
-								(CamelObjectFinalizeFunc) camel_stream_buffer_finalize);
-	}
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
 
-	return camel_stream_buffer_type;
-}
+	if (priv->buf && !(priv->flags & BUF_USER))
+		g_free (priv->buf);
 
-static void
-set_vbuf(CamelStreamBuffer *sbf, gchar *buf, CamelStreamBufferMode mode, gint size)
-{
-	if (sbf->buf && !(sbf->flags & BUF_USER)) {
-		g_free(sbf->buf);
-	}
 	if (buf) {
-		sbf->buf = (guchar *) buf;
-		sbf->flags |= BUF_USER;
+		priv->buf = (guchar *) buf;
+		priv->flags |= BUF_USER;
 	} else {
-		sbf->buf = g_malloc(size);
-		sbf->flags &= ~BUF_USER;
+		priv->buf = g_malloc (size);
+		priv->flags &= ~BUF_USER;
 	}
 
-	sbf->ptr = sbf->buf;
-	sbf->end = sbf->buf;
-	sbf->size = size;
-	sbf->mode = mode;
+	priv->ptr = priv->buf;
+	priv->end = priv->buf;
+	priv->size = size;
+	priv->mode = mode;
 }
 
 static void
-init_vbuf(CamelStreamBuffer *sbf, CamelStream *s, CamelStreamBufferMode mode, gchar *buf, guint32 size)
+stream_buffer_finalize (CamelStreamBuffer *stream_buffer)
 {
-	set_vbuf(sbf, buf, mode, size);
-	if (sbf->stream)
-		camel_object_unref (sbf->stream);
-	sbf->stream = s;
-	camel_object_ref (sbf->stream);
-}
+	CamelStreamBufferPrivate *priv = stream_buffer->priv;
 
-static void
-init(CamelStreamBuffer *sbuf, CamelStream *s, CamelStreamBufferMode mode)
-{
-	init_vbuf(sbuf, s, mode, NULL, BUF_SIZE);
-}
+	if (!(priv->flags & BUF_USER))
+		g_free (priv->buf);
 
-/**
- * camel_stream_buffer_new:
- * @stream: a #CamelStream object to buffer
- * @mode: Operational mode of buffered stream.
- *
- * Create a new buffered stream of another stream.  A default
- * buffer size (1024 bytes), automatically managed will be used
- * for buffering.
- *
- * See #camel_stream_buffer_new_with_vbuf for details on the
- * @mode parameter.
- *
- * Returns: a newly created buffered stream.
- **/
-CamelStream *
-camel_stream_buffer_new (CamelStream *stream, CamelStreamBufferMode mode)
-{
-	CamelStreamBuffer *sbf;
+	if (priv->stream)
+		camel_object_unref (priv->stream);
 
-	sbf = CAMEL_STREAM_BUFFER (camel_object_new (camel_stream_buffer_get_type ()));
-	CAMEL_STREAM_BUFFER_CLASS (CAMEL_OBJECT_GET_CLASS(sbf))->init (sbf, stream, mode);
+	g_free (priv->linebuf);
 
-	return CAMEL_STREAM (sbf);
-}
-
-/**
- * camel_stream_buffer_new_with_vbuf:
- * @stream: An existing stream to buffer.
- * @mode: Mode to buffer in.
- * @buf: Memory to use for buffering.
- * @size: Size of buffer to use.
- *
- * Create a new stream which buffers another stream, @stream.
- *
- * The following values are available for @mode:
- *
- * #CAMEL_STREAM_BUFFER_BUFFER, Buffer the input/output in blocks.
- * #CAMEL_STREAM_BUFFER_NEWLINE, Buffer on newlines (for output).
- * #CAMEL_STREAM_BUFFER_NONE, Perform no buffering.
- *
- * Note that currently this is ignored and #CAMEL_STREAM_BUFFER_BUFFER
- * is always used.
- *
- * In addition, one of the following mode options should be or'd
- * together with the buffering mode:
- *
- * #CAMEL_STREAM_BUFFER_WRITE, Buffer in write mode.
- * #CAMEL_STREAM_BUFFER_READ, Buffer in read mode.
- *
- * Buffering can only be done in one direction for any
- * buffer instance.
- *
- * If @buf is non-NULL, then use the memory pointed to
- * (for upto @size bytes) as the buffer for all buffering
- * operations.  It is upto the application to free this buffer.
- * If @buf is NULL, then allocate and manage @size bytes
- * for all buffering.
- *
- * Returns: A new stream with buffering applied.
- **/
-CamelStream *
-camel_stream_buffer_new_with_vbuf (CamelStream *stream, CamelStreamBufferMode mode, gchar *buf, guint32 size)
-{
-	CamelStreamBuffer *sbf;
-	sbf = CAMEL_STREAM_BUFFER (camel_object_new (camel_stream_buffer_get_type ()));
-	CAMEL_STREAM_BUFFER_CLASS (CAMEL_OBJECT_GET_CLASS(sbf))->init_vbuf (sbf, stream, mode, buf, size);
-
-	return CAMEL_STREAM (sbf);
+	g_free (priv);
 }
 
 static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
+stream_buffer_read (CamelStream *stream,
+                    gchar *buffer,
+                    gsize n)
 {
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
+	CamelStreamBufferPrivate *priv;
 	gssize bytes_read = 1;
 	gssize bytes_left;
 	gchar *bptr = buffer;
 
-	g_return_val_if_fail( (sbf->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_READ, 0);
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
+
+	g_return_val_if_fail (
+		(priv->mode & CAMEL_STREAM_BUFFER_MODE) ==
+		CAMEL_STREAM_BUFFER_READ, 0);
 
 	while (n && bytes_read > 0) {
-		bytes_left = sbf->end - sbf->ptr;
+		bytes_left = priv->end - priv->ptr;
 		if (bytes_left < n) {
 			if (bytes_left > 0) {
-				memcpy(bptr, sbf->ptr, bytes_left);
+				memcpy(bptr, priv->ptr, bytes_left);
 				n -= bytes_left;
 				bptr += bytes_left;
-				sbf->ptr += bytes_left;
+				priv->ptr += bytes_left;
 			}
 			/* if we are reading a lot, then read directly to the destination buffer */
-			if (n >= sbf->size/3) {
-				bytes_read = camel_stream_read(sbf->stream, bptr, n);
+			if (n >= priv->size/3) {
+				bytes_read = camel_stream_read (
+					priv->stream, bptr, n);
 				if (bytes_read>0) {
 					n -= bytes_read;
 					bptr += bytes_read;
 				}
 			} else {
-				bytes_read = camel_stream_read(sbf->stream, (gchar *) sbf->buf, sbf->size);
+				bytes_read = camel_stream_read (
+					priv->stream, (gchar *)
+					priv->buf, priv->size);
 				if (bytes_read>0) {
 					gsize bytes_used = bytes_read > n ? n : bytes_read;
-					sbf->ptr = sbf->buf;
-					sbf->end = sbf->buf+bytes_read;
-					memcpy(bptr, sbf->ptr, bytes_used);
-					sbf->ptr += bytes_used;
+					priv->ptr = priv->buf;
+					priv->end = priv->buf+bytes_read;
+					memcpy(bptr, priv->ptr, bytes_used);
+					priv->ptr += bytes_used;
 					bptr += bytes_used;
 					n -= bytes_used;
 				}
 			}
 		} else {
-			memcpy(bptr, sbf->ptr, n);
-			sbf->ptr += n;
+			memcpy(bptr, priv->ptr, n);
+			priv->ptr += n;
 			bptr += n;
 			n = 0;
 		}
@@ -272,57 +175,49 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
 	return (gssize)(bptr - buffer);
 }
 
-/* only returns the number passed in, or -1 on an error */
-static gssize
-stream_write_all(CamelStream *stream, const gchar *buffer, gsize n)
-{
-	gsize left = n, w;
-
-	while (left > 0) {
-		w = camel_stream_write(stream, buffer, left);
-		if (w == -1)
-			return -1;
-		left -= w;
-		buffer += w;
-	}
-
-	return n;
-}
-
 static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+stream_buffer_write (CamelStream *stream,
+                     const gchar *buffer,
+                     gsize n)
 {
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
+	CamelStreamBufferPrivate *priv;
 	gssize total = n;
 	gssize left, todo;
 
-	g_return_val_if_fail( (sbf->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_WRITE, 0);
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
+
+	g_return_val_if_fail (
+		(priv->mode & CAMEL_STREAM_BUFFER_MODE) ==
+		CAMEL_STREAM_BUFFER_WRITE, 0);
 
 	/* first, copy as much as we can */
-	left = sbf->size - (sbf->ptr-sbf->buf);
+	left = priv->size - (priv->ptr - priv->buf);
 	todo = MIN(left, n);
 
-	memcpy(sbf->ptr, buffer, todo);
+	memcpy(priv->ptr, buffer, todo);
 	n -= todo;
 	buffer += todo;
-	sbf->ptr += todo;
+	priv->ptr += todo;
 
 	/* if we've filled the buffer, write it out, reset buffer */
 	if (left == todo) {
-		if (stream_write_all(sbf->stream, (const gchar *) sbf->buf, sbf->size) == -1)
+		if (stream_write_all (
+			priv->stream, (gchar *) priv->buf,
+			priv->size) == -1)
 			return -1;
 
-		sbf->ptr = sbf->buf;
+		priv->ptr = priv->buf;
 	}
 
 	/* if we still have more, write directly, or copy to buffer */
 	if (n > 0) {
-		if (n >= sbf->size/3) {
-			if (stream_write_all(sbf->stream, buffer, n) == -1)
+		if (n >= priv->size/3) {
+			if (stream_write_all (
+				priv->stream, buffer, n) == -1)
 				return -1;
 		} else {
-			memcpy(sbf->ptr, buffer, n);
-			sbf->ptr += n;
+			memcpy(priv->ptr, buffer, n);
+			priv->ptr += n;
 		}
 	}
 
@@ -330,40 +225,220 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 }
 
 static gint
-stream_flush (CamelStream *stream)
+stream_buffer_flush (CamelStream *stream)
 {
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
+	CamelStreamBufferPrivate *priv;
+
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
 
-	if ((sbf->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_WRITE) {
-		gsize len = sbf->ptr - sbf->buf;
+	if ((priv->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_WRITE) {
+		gsize len = priv->ptr - priv->buf;
 
-		if (camel_stream_write (sbf->stream, (const gchar *) sbf->buf, len) == -1)
+		if (camel_stream_write (
+			priv->stream, (gchar *) priv->buf, len) == -1)
 			return -1;
 
-		sbf->ptr = sbf->buf;
+		priv->ptr = priv->buf;
 	} else {
 		/* nothing to do for read mode 'flush' */
 	}
 
-	return camel_stream_flush(sbf->stream);
+	return camel_stream_flush (priv->stream);
 }
 
 static gint
-stream_close (CamelStream *stream)
+stream_buffer_close (CamelStream *stream)
 {
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
+	CamelStreamBufferPrivate *priv;
 
-	if (stream_flush(stream) == -1)
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
+
+	if (stream_buffer_flush (stream) == -1)
 		return -1;
-	return camel_stream_close(sbf->stream);
+
+	return camel_stream_close (priv->stream);
 }
 
 static gboolean
-stream_eos (CamelStream *stream)
+stream_buffer_eos (CamelStream *stream)
+{
+	CamelStreamBufferPrivate *priv;
+
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
+
+	return camel_stream_eos(priv->stream) && priv->ptr == priv->end;
+}
+
+static void
+stream_buffer_init_vbuf (CamelStreamBuffer *stream,
+                         CamelStream *other_stream,
+                         CamelStreamBufferMode mode,
+                         gchar *buf,
+                         guint32 size)
+{
+	CamelStreamBufferPrivate *priv;
+
+	priv = CAMEL_STREAM_BUFFER (stream)->priv;
+
+	set_vbuf (stream, buf, mode, size);
+
+	if (priv->stream)
+		camel_object_unref (priv->stream);
+
+	priv->stream = other_stream;
+	camel_object_ref (priv->stream);
+}
+
+static void
+stream_buffer_init_method (CamelStreamBuffer *stream,
+                           CamelStream *other_stream,
+                           CamelStreamBufferMode mode)
+{
+	stream_buffer_init_vbuf (stream, other_stream, mode, NULL, BUF_SIZE);
+}
+
+static void
+camel_stream_buffer_class_init (CamelStreamBufferClass *class)
+{
+	CamelStreamClass *stream_class;
+
+	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = stream_buffer_read;
+	stream_class->write = stream_buffer_write;
+	stream_class->flush = stream_buffer_flush;
+	stream_class->close = stream_buffer_close;
+	stream_class->eos = stream_buffer_eos;
+
+	class->init = stream_buffer_init_method;
+	class->init_vbuf = stream_buffer_init_vbuf;
+}
+
+static void
+camel_stream_buffer_init (CamelStreamBuffer *stream)
+{
+	stream->priv = g_new0 (CamelStreamBufferPrivate, 1);
+
+	stream->priv->flags = 0;
+	stream->priv->size = BUF_SIZE;
+	stream->priv->buf = g_malloc(BUF_SIZE);
+	stream->priv->ptr = stream->priv->buf;
+	stream->priv->end = stream->priv->buf;
+	stream->priv->mode =
+		CAMEL_STREAM_BUFFER_READ |
+		CAMEL_STREAM_BUFFER_BUFFER;
+	stream->priv->stream = NULL;
+	stream->priv->linesize = 80;
+	stream->priv->linebuf = g_malloc (stream->priv->linesize);
+}
+
+CamelType
+camel_stream_buffer_get_type (void)
 {
-	CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
+	static CamelType camel_stream_buffer_type = CAMEL_INVALID_TYPE;
 
-	return camel_stream_eos(sbf->stream) && sbf->ptr == sbf->end;
+	if (camel_stream_buffer_type == CAMEL_INVALID_TYPE)	{
+		camel_stream_buffer_type = camel_type_register (camel_stream_get_type (), "CamelStreamBuffer",
+								sizeof (CamelStreamBuffer),
+								sizeof (CamelStreamBufferClass),
+								(CamelObjectClassInitFunc) camel_stream_buffer_class_init,
+								NULL,
+								(CamelObjectInitFunc) camel_stream_buffer_init,
+								(CamelObjectFinalizeFunc) stream_buffer_finalize);
+	}
+
+	return camel_stream_buffer_type;
+}
+
+/**
+ * camel_stream_buffer_new:
+ * @stream: a #CamelStream object to buffer
+ * @mode: Operational mode of buffered stream.
+ *
+ * Create a new buffered stream of another stream.  A default
+ * buffer size (1024 bytes), automatically managed will be used
+ * for buffering.
+ *
+ * See #camel_stream_buffer_new_with_vbuf for details on the
+ * @mode parameter.
+ *
+ * Returns: a newly created buffered stream.
+ **/
+CamelStream *
+camel_stream_buffer_new (CamelStream *stream,
+                         CamelStreamBufferMode mode)
+{
+	CamelStreamBuffer *sbf;
+	CamelStreamBufferClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
+
+	sbf = CAMEL_STREAM_BUFFER (camel_object_new (camel_stream_buffer_get_type ()));
+
+	class = CAMEL_STREAM_BUFFER_GET_CLASS (sbf);
+	g_return_val_if_fail (class->init != NULL, NULL);
+
+	class->init (sbf, stream, mode);
+
+	return CAMEL_STREAM (sbf);
+}
+
+/**
+ * camel_stream_buffer_new_with_vbuf:
+ * @stream: An existing stream to buffer.
+ * @mode: Mode to buffer in.
+ * @buf: Memory to use for buffering.
+ * @size: Size of buffer to use.
+ *
+ * Create a new stream which buffers another stream, @stream.
+ *
+ * The following values are available for @mode:
+ *
+ * #CAMEL_STREAM_BUFFER_BUFFER, Buffer the input/output in blocks.
+ * #CAMEL_STREAM_BUFFER_NEWLINE, Buffer on newlines (for output).
+ * #CAMEL_STREAM_BUFFER_NONE, Perform no buffering.
+ *
+ * Note that currently this is ignored and #CAMEL_STREAM_BUFFER_BUFFER
+ * is always used.
+ *
+ * In addition, one of the following mode options should be or'd
+ * together with the buffering mode:
+ *
+ * #CAMEL_STREAM_BUFFER_WRITE, Buffer in write mode.
+ * #CAMEL_STREAM_BUFFER_READ, Buffer in read mode.
+ *
+ * Buffering can only be done in one direction for any
+ * buffer instance.
+ *
+ * If @buf is non-NULL, then use the memory pointed to
+ * (for upto @size bytes) as the buffer for all buffering
+ * operations.  It is upto the application to free this buffer.
+ * If @buf is NULL, then allocate and manage @size bytes
+ * for all buffering.
+ *
+ * Returns: A new stream with buffering applied.
+ **/
+CamelStream *
+camel_stream_buffer_new_with_vbuf (CamelStream *stream,
+                                   CamelStreamBufferMode mode,
+                                   gchar *buf,
+                                   guint32 size)
+{
+	CamelStreamBuffer *sbf;
+	CamelStreamBufferClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
+	g_return_val_if_fail (buf != NULL, NULL);
+
+	sbf = CAMEL_STREAM_BUFFER (camel_object_new (camel_stream_buffer_get_type ()));
+
+	class = CAMEL_STREAM_BUFFER_GET_CLASS (sbf);
+	g_return_val_if_fail (class->init_vbuf != NULL, NULL);
+
+	class->init_vbuf (sbf, stream, mode, buf, size);
+
+	return CAMEL_STREAM (sbf);
 }
 
 /**
@@ -382,14 +457,16 @@ stream_eos (CamelStream *stream)
  * and %-1 on error.
  **/
 gint
-camel_stream_buffer_gets(CamelStreamBuffer *sbf, gchar *buf, guint max)
+camel_stream_buffer_gets (CamelStreamBuffer *sbf,
+                          gchar *buf,
+                          guint max)
 {
 	register gchar *outptr, *inptr, *inend, c, *outend;
 	gint bytes_read;
 
 	outptr = buf;
-	inptr = (gchar *) sbf->ptr;
-	inend = (gchar *) sbf->end;
+	inptr = (gchar *) sbf->priv->ptr;
+	inend = (gchar *) sbf->priv->end;
 	outend = buf+max-1;	/* room for NUL */
 
 	do {
@@ -398,34 +475,36 @@ camel_stream_buffer_gets(CamelStreamBuffer *sbf, gchar *buf, guint max)
 			*outptr++ = c;
 			if (c == '\n') {
 				*outptr = 0;
-				sbf->ptr = (guchar *) inptr;
+				sbf->priv->ptr = (guchar *) inptr;
 				return outptr-buf;
 			}
 		}
 		if (outptr == outend)
 			break;
 
-		bytes_read = camel_stream_read (sbf->stream, (gchar *) sbf->buf, sbf->size);
+		bytes_read = camel_stream_read (
+			sbf->priv->stream, (gchar *)
+			sbf->priv->buf, sbf->priv->size);
 		if (bytes_read == -1) {
 			if (buf == outptr)
 				return -1;
 			else
 				bytes_read = 0;
 		}
-		sbf->ptr = sbf->buf;
-		sbf->end = sbf->buf + bytes_read;
-		inptr = (gchar *) sbf->ptr;
-		inend = (gchar *) sbf->end;
+		sbf->priv->ptr = sbf->priv->buf;
+		sbf->priv->end = sbf->priv->buf + bytes_read;
+		inptr = (gchar *) sbf->priv->ptr;
+		inend = (gchar *) sbf->priv->end;
 	} while (bytes_read>0);
 
-	sbf->ptr = (guchar *) inptr;
+	sbf->priv->ptr = (guchar *) inptr;
 	*outptr = 0;
 
 	return (gint)(outptr - buf);
 }
 
 /**
- * camel_stream_buffer_read_line: read a complete line from the stream
+ * camel_stream_buffer_read_line:
  * @sbf: a #CamelStreamBuffer object
  *
  * This function reads a complete newline-terminated line from the stream
@@ -441,12 +520,14 @@ camel_stream_buffer_read_line (CamelStreamBuffer *sbf)
 	guchar *p;
 	gint nread;
 
-	p = sbf->linebuf;
+	p = sbf->priv->linebuf;
 
 	while (1) {
-		nread = camel_stream_buffer_gets (sbf, (gchar *) p, sbf->linesize - (p - sbf->linebuf));
+		nread = camel_stream_buffer_gets (
+			sbf, (gchar *) p, sbf->priv->linesize -
+			(p - sbf->priv->linebuf));
 		if (nread <=0) {
-			if (p > sbf->linebuf)
+			if (p > sbf->priv->linebuf)
 				break;
 			return NULL;
 		}
@@ -455,16 +536,17 @@ camel_stream_buffer_read_line (CamelStreamBuffer *sbf)
 		if (p[-1] == '\n')
 			break;
 
-		nread = p - sbf->linebuf;
-		sbf->linesize *= 2;
-		sbf->linebuf = g_realloc (sbf->linebuf, sbf->linesize);
-		p = sbf->linebuf + nread;
+		nread = p - sbf->priv->linebuf;
+		sbf->priv->linesize *= 2;
+		sbf->priv->linebuf = g_realloc (
+			sbf->priv->linebuf, sbf->priv->linesize);
+		p = sbf->priv->linebuf + nread;
 	}
 
 	p--;
-	if (p > sbf->linebuf && p[-1] == '\r')
+	if (p > sbf->priv->linebuf && p[-1] == '\r')
 		p--;
 	p[0] = 0;
 
-	return g_strdup((gchar *) sbf->linebuf);
+	return g_strdup ((gchar *) sbf->priv->linebuf);
 }
diff --git a/camel/camel-stream-buffer.h b/camel/camel-stream-buffer.h
index fef2f0f..d2cd638 100644
--- a/camel/camel-stream-buffer.h
+++ b/camel/camel-stream-buffer.h
@@ -37,11 +37,14 @@
 #define CAMEL_STREAM_BUFFER(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBuffer))
 #define CAMEL_STREAM_BUFFER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBufferClass))
 #define CAMEL_IS_STREAM_BUFFER(o)    (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_BUFFER_TYPE))
+#define CAMEL_STREAM_BUFFER_GET_CLASS(obj) \
+	((CamelStreamBufferClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
 typedef struct _CamelStreamBuffer CamelStreamBuffer;
 typedef struct _CamelStreamBufferClass CamelStreamBufferClass;
+typedef struct _CamelStreamBufferPrivate CamelStreamBufferPrivate;
 
 typedef enum {
 	CAMEL_STREAM_BUFFER_BUFFER = 0,
@@ -53,18 +56,7 @@ typedef enum {
 
 struct _CamelStreamBuffer {
 	CamelStream parent;
-
-	/* these are all of course, private */
-	CamelStream *stream;
-
-	guchar *buf, *ptr, *end;
-	gint size;
-
-	guchar *linebuf;	/* for reading lines at a time */
-	gint linesize;
-
-	CamelStreamBufferMode mode;
-	guint flags;	/* internal flags */
+	CamelStreamBufferPrivate *priv;
 };
 
 struct _CamelStreamBufferClass {
diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c
index c97ead8..57a125a 100644
--- a/camel/camel-stream-filter.c
+++ b/camel/camel-stream-filter.c
@@ -41,6 +41,9 @@ struct _filter {
 };
 
 struct _CamelStreamFilterPrivate {
+
+	CamelStream *source;
+
 	struct _filter *filters;
 	gint filterid;		/* next filter id */
 
@@ -57,210 +60,81 @@ struct _CamelStreamFilterPrivate {
 #define READ_PAD (128)		/* bytes padded before buffer */
 #define READ_SIZE (4096)
 
-#define _PRIVATE(o) (((CamelStreamFilter *)(o))->priv)
-
-static void camel_stream_filter_class_init (CamelStreamFilterClass *klass);
-static void camel_stream_filter_init       (CamelStreamFilter *obj);
-
-static	gssize   do_read       (CamelStream *stream, gchar *buffer, gsize n);
-static	gssize   do_write      (CamelStream *stream, const gchar *buffer, gsize n);
-static	gint       do_flush      (CamelStream *stream);
-static	gint       do_close      (CamelStream *stream);
-static	gboolean  do_eos        (CamelStream *stream);
-static	gint       do_reset      (CamelStream *stream);
-
 static CamelStreamClass *camel_stream_filter_parent;
 
 static void
-camel_stream_filter_class_init (CamelStreamFilterClass *klass)
-{
-	CamelStreamClass *camel_stream_class = (CamelStreamClass *) klass;
-
-	camel_stream_filter_parent = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
-
-	camel_stream_class->read = do_read;
-	camel_stream_class->write = do_write;
-	camel_stream_class->flush = do_flush;
-	camel_stream_class->close = do_close;
-	camel_stream_class->eos = do_eos;
-	camel_stream_class->reset = do_reset;
-
-}
-
-static void
-camel_stream_filter_init (CamelStreamFilter *obj)
+stream_filter_finalize (CamelStreamFilter *filter)
 {
-	struct _CamelStreamFilterPrivate *p;
-
-	_PRIVATE(obj) = p = g_malloc0(sizeof(*p));
-	p->realbuffer = g_malloc(READ_SIZE + READ_PAD);
-	p->buffer = p->realbuffer + READ_PAD;
-	p->last_was_read = TRUE;
-	p->flushed = FALSE;
-}
-
-static void
-camel_stream_filter_finalize(CamelObject *o)
-{
-	CamelStreamFilter *filter = (CamelStreamFilter *)o;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
 	struct _filter *fn, *f;
 
-	f = p->filters;
+	f = filter->priv->filters;
 	while (f) {
 		fn = f->next;
-		camel_object_unref((CamelObject *)f->filter);
-		g_free(f);
+		camel_object_unref (f->filter);
+		g_free (f);
 		f = fn;
 	}
-	g_free(p->realbuffer);
-	g_free(p);
-	camel_object_unref((CamelObject *)filter->source);
-}
-
-CamelType
-camel_stream_filter_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (CAMEL_STREAM_TYPE, "CamelStreamFilter",
-					    sizeof (CamelStreamFilter),
-					    sizeof (CamelStreamFilterClass),
-					    (CamelObjectClassInitFunc) camel_stream_filter_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_stream_filter_init,
-					    (CamelObjectFinalizeFunc) camel_stream_filter_finalize);
-	}
-
-	return type;
-}
-
-/**
- * camel_stream_filter_new:
- *
- * Create a new #CamelStreamFilter object.
- *
- * Returns: a new #CamelStreamFilter object.
- **/
-CamelStream *
-camel_stream_filter_new (CamelStream *stream)
-{
-	CamelStreamFilter *new = CAMEL_STREAM_FILTER ( camel_object_new (camel_stream_filter_get_type ()));
-
-	new->source = stream;
-	camel_object_ref ((CamelObject *)stream);
-
-	return CAMEL_STREAM (new);
-}
-
-/**
- * camel_stream_filter_add:
- * @stream: a #CamelStreamFilter object
- * @filter: a #CamelMimeFilter object
- *
- * Add a new #CamelMimeFilter to execute during the processing of this
- * stream.  Each filter added is processed after the previous one.
- *
- * Note that a filter should only be added to a single stream
- * at a time, otherwise unpredictable results may occur.
- *
- * Returns: a filter id for the added @filter.
- **/
-gint
-camel_stream_filter_add (CamelStreamFilter *stream, CamelMimeFilter *filter)
-{
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(stream);
-	struct _filter *fn, *f;
-
-	fn = g_malloc(sizeof(*fn));
-	fn->id = p->filterid++;
-	fn->filter = filter;
-	camel_object_ref (filter);
-
-	/* sure, we could use a GList, but we wouldn't save much */
-	f = (struct _filter *)&p->filters;
-	while (f->next)
-		f = f->next;
-	f->next = fn;
-	fn->next = NULL;
-	return fn->id;
-}
+	g_free (filter->priv->realbuffer);
+	camel_object_unref (filter->priv->source);
 
-/**
- * camel_stream_filter_remove:
- * @stream: a #CamelStreamFilter object
- * @id: Filter id, as returned from #camel_stream_filter_add
- *
- * Remove a processing filter from the stream by id.
- **/
-void
-camel_stream_filter_remove(CamelStreamFilter *stream, gint id)
-{
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(stream);
-	struct _filter *fn, *f;
-
-	f = (struct _filter *)&p->filters;
-	while (f && f->next) {
-		fn = f->next;
-		if (fn->id == id) {
-			f->next = fn->next;
-			camel_object_unref(fn->filter);
-			g_free(fn);
-		}
-		f = f->next;
-	}
+	g_free (filter->priv);
 }
 
 static gssize
-do_read (CamelStream *stream, gchar *buffer, gsize n)
+stream_filter_read (CamelStream *stream,
+                    gchar *buffer,
+                    gsize n)
 {
-	CamelStreamFilter *filter = (CamelStreamFilter *)stream;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
+	CamelStreamFilterPrivate *priv;
 	gssize size;
 	struct _filter *f;
 
-	p->last_was_read = TRUE;
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	priv->last_was_read = TRUE;
 
-	g_check(p->realbuffer);
+	g_check(priv->realbuffer);
 
-	if (p->filteredlen<=0) {
+	if (priv->filteredlen<=0) {
 		gsize presize = READ_PAD;
 
-		size = camel_stream_read(filter->source, p->buffer, READ_SIZE);
+		size = camel_stream_read (
+			priv->source, priv->buffer, READ_SIZE);
 		if (size <= 0) {
 			/* this is somewhat untested */
-			if (camel_stream_eos(filter->source)) {
-				f = p->filters;
-				p->filtered = p->buffer;
-				p->filteredlen = 0;
+			if (camel_stream_eos(priv->source)) {
+				f = priv->filters;
+				priv->filtered = priv->buffer;
+				priv->filteredlen = 0;
 				while (f) {
-					camel_mime_filter_complete(f->filter, p->filtered, p->filteredlen,
-								   presize, &p->filtered, &p->filteredlen, &presize);
-					g_check(p->realbuffer);
+					camel_mime_filter_complete (
+						f->filter, priv->filtered, priv->filteredlen,
+						presize, &priv->filtered, &priv->filteredlen, &presize);
+					g_check(priv->realbuffer);
 					f = f->next;
 				}
-				size = p->filteredlen;
-				p->flushed = TRUE;
+				size = priv->filteredlen;
+				priv->flushed = TRUE;
 			}
 			if (size <= 0)
 				return size;
 		} else {
-			f = p->filters;
-			p->filtered = p->buffer;
-			p->filteredlen = size;
+			f = priv->filters;
+			priv->filtered = priv->buffer;
+			priv->filteredlen = size;
 
-			d(printf ("\n\nOriginal content (%s): '", ((CamelObject *)filter->source)->klass->name));
-			d(fwrite(p->filtered, sizeof(gchar), p->filteredlen, stdout));
+			d(printf ("\n\nOriginal content (%s): '", ((CamelObject *)priv->source)->class->name));
+			d(fwrite(priv->filtered, sizeof(gchar), priv->filteredlen, stdout));
 			d(printf("'\n"));
 
 			while (f) {
-				camel_mime_filter_filter(f->filter, p->filtered, p->filteredlen, presize,
-							 &p->filtered, &p->filteredlen, &presize);
-				g_check(p->realbuffer);
+				camel_mime_filter_filter (
+					f->filter, priv->filtered, priv->filteredlen, presize,
+					&priv->filtered, &priv->filteredlen, &presize);
+				g_check(priv->realbuffer);
 
-				d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name));
-				d(fwrite(p->filtered, sizeof(gchar), p->filteredlen, stdout));
+				d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->class->name));
+				d(fwrite(priv->filtered, sizeof(gchar), priv->filteredlen, stdout));
 				d(printf("'\n"));
 
 				f = f->next;
@@ -268,12 +142,12 @@ do_read (CamelStream *stream, gchar *buffer, gsize n)
 		}
 	}
 
-	size = MIN(n, p->filteredlen);
-	memcpy(buffer, p->filtered, size);
-	p->filteredlen -= size;
-	p->filtered += size;
+	size = MIN(n, priv->filteredlen);
+	memcpy(buffer, priv->filtered, size);
+	priv->filteredlen -= size;
+	priv->filtered += size;
 
-	g_check(p->realbuffer);
+	g_check(priv->realbuffer);
 
 	return size;
 }
@@ -282,21 +156,24 @@ do_read (CamelStream *stream, gchar *buffer, gsize n)
    write (for 'success'), we return what they asked us to write (for 'success')
    rather than the true number of written bytes */
 static gssize
-do_write (CamelStream *stream, const gchar *buf, gsize n)
+stream_filter_write (CamelStream *stream,
+                     const gchar *buf,
+                     gsize n)
 {
-	CamelStreamFilter *filter = (CamelStreamFilter *)stream;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
+	CamelStreamFilterPrivate *priv;
 	struct _filter *f;
 	gsize presize, len, left = n;
 	gchar *buffer, realbuffer[READ_SIZE+READ_PAD];
 
-	p->last_was_read = FALSE;
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
 
-	d(printf ("\n\nWriting: Original content (%s): '", ((CamelObject *)filter->source)->klass->name));
+	priv->last_was_read = FALSE;
+
+	d(printf ("\n\nWriting: Original content (%s): '", ((CamelObject *)priv->source)->class->name));
 	d(fwrite(buf, sizeof(gchar), n, stdout));
 	d(printf("'\n"));
 
-	g_check(p->realbuffer);
+	g_check(priv->realbuffer);
 
 	while (left) {
 		/* Sigh, since filters expect non const args, copy the input first, we do this in handy sized chunks */
@@ -306,109 +183,259 @@ do_write (CamelStream *stream, const gchar *buf, gsize n)
 		buf += len;
 		left -= len;
 
-		f = p->filters;
+		f = priv->filters;
 		presize = READ_PAD;
 		while (f) {
 			camel_mime_filter_filter(f->filter, buffer, len, presize, &buffer, &len, &presize);
 
-			g_check(p->realbuffer);
+			g_check(priv->realbuffer);
 
-			d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name));
+			d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->class->name));
 			d(fwrite(buffer, sizeof(gchar), len, stdout));
 			d(printf("'\n"));
 
 			f = f->next;
 		}
 
-		if (camel_stream_write(filter->source, buffer, len) != len)
+		if (camel_stream_write (priv->source, buffer, len) != len)
 			return -1;
 	}
 
-	g_check(p->realbuffer);
+	g_check(priv->realbuffer);
 
 	return n;
 }
 
 static gint
-do_flush (CamelStream *stream)
+stream_filter_flush (CamelStream *stream)
 {
-	CamelStreamFilter *filter = (CamelStreamFilter *)stream;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
+	CamelStreamFilterPrivate *priv;
 	struct _filter *f;
 	gchar *buffer;
 	gsize presize;
 	gsize len;
 
-	if (p->last_was_read)
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	if (priv->last_was_read)
 		return 0;
 
 	buffer = (gchar *) "";
 	len = 0;
 	presize = 0;
-	f = p->filters;
+	f = priv->filters;
 
-	d(printf ("\n\nFlushing: Original content (%s): '", ((CamelObject *)filter->source)->klass->name));
+	d(printf ("\n\nFlushing: Original content (%s): '", ((CamelObject *)priv->source)->class->name));
 	d(fwrite(buffer, sizeof(gchar), len, stdout));
 	d(printf("'\n"));
 
 	while (f) {
 		camel_mime_filter_complete(f->filter, buffer, len, presize, &buffer, &len, &presize);
 
-		d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name));
+		d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->class->name));
 		d(fwrite(buffer, sizeof(gchar), len, stdout));
 		d(printf("'\n"));
 
 		f = f->next;
 	}
-	if (len > 0 && camel_stream_write(filter->source, buffer, len) == -1)
+
+	if (len > 0 && camel_stream_write (priv->source, buffer, len) == -1)
 		return -1;
-	return camel_stream_flush(filter->source);
+
+	return camel_stream_flush (priv->source);
 }
 
 static gint
-do_close (CamelStream *stream)
+stream_filter_close (CamelStream *stream)
 {
-	CamelStreamFilter *filter = (CamelStreamFilter *)stream;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
+	CamelStreamFilterPrivate *priv;
 
-	if (!p->last_was_read) {
-		do_flush(stream);
-	}
-	return camel_stream_close(filter->source);
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	if (!priv->last_was_read)
+		stream_filter_flush (stream);
+
+	return camel_stream_close (priv->source);
 }
 
 static gboolean
-do_eos (CamelStream *stream)
+stream_filter_eos (CamelStream *stream)
 {
-	CamelStreamFilter *filter = (CamelStreamFilter *)stream;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
+	CamelStreamFilterPrivate *priv;
+
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
 
-	if (p->filteredlen > 0)
+	if (priv->filteredlen > 0)
 		return FALSE;
 
-	if (!p->flushed)
+	if (!priv->flushed)
 		return FALSE;
 
-	return camel_stream_eos(filter->source);
+	return camel_stream_eos (priv->source);
 }
 
 static gint
-do_reset (CamelStream *stream)
+stream_filter_reset (CamelStream *stream)
 {
-	CamelStreamFilter *filter = (CamelStreamFilter *)stream;
-	struct _CamelStreamFilterPrivate *p = _PRIVATE(filter);
+	CamelStreamFilterPrivate *priv;
 	struct _filter *f;
 
-	p->filteredlen = 0;
-	p->flushed = FALSE;
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	priv->filteredlen = 0;
+	priv->flushed = FALSE;
 
 	/* and reset filters */
-	f = p->filters;
+	f = priv->filters;
 	while (f) {
-		camel_mime_filter_reset(f->filter);
+		camel_mime_filter_reset (f->filter);
 		f = f->next;
 	}
 
-	return camel_stream_reset(filter->source);
+	return camel_stream_reset (priv->source);
+}
+
+static void
+camel_stream_filter_class_init (CamelStreamFilterClass *class)
+{
+	CamelStreamClass *stream_class;
+
+	camel_stream_filter_parent = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = stream_filter_read;
+	stream_class->write = stream_filter_write;
+	stream_class->flush = stream_filter_flush;
+	stream_class->close = stream_filter_close;
+	stream_class->eos = stream_filter_eos;
+	stream_class->reset = stream_filter_reset;
+}
+
+static void
+camel_stream_filter_init (CamelStreamFilter *stream)
+{
+	stream->priv = g_new0 (CamelStreamFilterPrivate, 1);
+	stream->priv->realbuffer = g_malloc(READ_SIZE + READ_PAD);
+	stream->priv->buffer = stream->priv->realbuffer + READ_PAD;
+	stream->priv->last_was_read = TRUE;
+	stream->priv->flushed = FALSE;
+}
+
+CamelType
+camel_stream_filter_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (CAMEL_STREAM_TYPE, "CamelStreamFilter",
+					    sizeof (CamelStreamFilter),
+					    sizeof (CamelStreamFilterClass),
+					    (CamelObjectClassInitFunc) camel_stream_filter_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_stream_filter_init,
+					    (CamelObjectFinalizeFunc) stream_filter_finalize);
+	}
+
+	return type;
+}
+
+/**
+ * camel_stream_filter_new:
+ *
+ * Create a new #CamelStreamFilter object.
+ *
+ * Returns: a new #CamelStreamFilter object.
+ **/
+CamelStream *
+camel_stream_filter_new (CamelStream *source)
+{
+	CamelStream *stream;
+	CamelStreamFilterPrivate *priv;
+
+	g_return_val_if_fail (CAMEL_IS_STREAM (source), NULL);
+
+	stream = CAMEL_STREAM (camel_object_new (camel_stream_filter_get_type ()));
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	priv->source = source;
+	camel_object_ref (source);
+
+	return stream;
+}
+
+CamelStream *
+camel_stream_filter_get_source (CamelStreamFilter *stream)
+{
+	g_return_val_if_fail (CAMEL_IS_STREAM_FILTER (stream), NULL);
+
+	return stream->priv->source;
+}
+
+/**
+ * camel_stream_filter_add:
+ * @stream: a #CamelStreamFilter object
+ * @filter: a #CamelMimeFilter object
+ *
+ * Add a new #CamelMimeFilter to execute during the processing of this
+ * stream.  Each filter added is processed after the previous one.
+ *
+ * Note that a filter should only be added to a single stream
+ * at a time, otherwise unpredictable results may occur.
+ *
+ * Returns: a filter id for the added @filter.
+ **/
+gint
+camel_stream_filter_add (CamelStreamFilter *stream,
+                         CamelMimeFilter *filter)
+{
+	CamelStreamFilterPrivate *priv;
+	struct _filter *fn, *f;
+
+	g_return_val_if_fail (CAMEL_IS_STREAM_FILTER (stream), -1);
+	g_return_val_if_fail (CAMEL_IS_MIME_FILTER (filter), -1);
+
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	fn = g_malloc(sizeof(*fn));
+	fn->id = priv->filterid++;
+	fn->filter = filter;
+	camel_object_ref (filter);
+
+	/* sure, we could use a GList, but we wouldn't save much */
+	f = (struct _filter *)&priv->filters;
+	while (f->next)
+		f = f->next;
+	f->next = fn;
+	fn->next = NULL;
+	return fn->id;
 }
 
+/**
+ * camel_stream_filter_remove:
+ * @stream: a #CamelStreamFilter object
+ * @id: Filter id, as returned from #camel_stream_filter_add
+ *
+ * Remove a processing filter from the stream by id.
+ **/
+void
+camel_stream_filter_remove (CamelStreamFilter *stream,
+                            gint id)
+{
+	CamelStreamFilterPrivate *priv;
+	struct _filter *fn, *f;
+
+	g_return_if_fail (CAMEL_IS_STREAM_FILTER (stream));
+
+	priv = CAMEL_STREAM_FILTER (stream)->priv;
+
+	f = (struct _filter *)&priv->filters;
+	while (f && f->next) {
+		fn = f->next;
+		if (fn->id == id) {
+			f->next = fn->next;
+			camel_object_unref (fn->filter);
+			g_free(fn);
+		}
+		f = f->next;
+	}
+}
diff --git a/camel/camel-stream-filter.h b/camel/camel-stream-filter.h
index 545fa50..18fef88 100644
--- a/camel/camel-stream-filter.h
+++ b/camel/camel-stream-filter.h
@@ -41,9 +41,6 @@ typedef struct _CamelStreamFilterPrivate CamelStreamFilterPrivate;
 
 struct _CamelStreamFilter {
 	CamelStream parent;
-
-	CamelStream *source;
-
 	CamelStreamFilterPrivate *priv;
 };
 
@@ -53,6 +50,7 @@ struct _CamelStreamFilterClass {
 
 CamelType	camel_stream_filter_get_type	(void);
 CamelStream *	camel_stream_filter_new		(CamelStream *stream);
+CamelStream *	camel_stream_filter_get_source	(CamelStreamFilter *stream);
 gint		camel_stream_filter_add		(CamelStreamFilter *stream,
 						 CamelMimeFilter *filter);
 void		camel_stream_filter_remove	(CamelStreamFilter *stream,
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 87f1820..f1e2b00 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -32,7 +32,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <glib.h>
 #include <glib/gstdio.h>
 
 #include "camel-file-utils.h"
@@ -40,53 +39,164 @@
 #include "camel-private.h"
 #include "camel-stream-fs.h"
 
+struct _CamelStreamFsPrivate {
+	gint fd;	/* file descriptor on the underlying file */
+};
+
 static CamelSeekableStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelStreamFS */
-#define CSFS_CLASS(so) CAMEL_STREAM_FS_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static void
+camel_stream_fs_finalize (CamelStreamFs *stream_fs)
+{
+	CamelStreamFsPrivate *priv = stream_fs->priv;
+
+	if (priv->fd != -1)
+		close (priv->fd);
 
-static gssize stream_read   (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write  (CamelStream *stream, const gchar *buffer, gsize n);
-static gint stream_flush  (CamelStream *stream);
-static gint stream_close  (CamelStream *stream);
-static off_t stream_seek (CamelSeekableStream *stream, off_t offset,
-			  CamelStreamSeekPolicy policy);
+	g_free (priv);
+}
 
-static void
-camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class)
+static gssize
+stream_fs_read (CamelStream *stream,
+                gchar *buffer,
+                gsize n)
 {
-	CamelSeekableStreamClass *camel_seekable_stream_class =
-		CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_fs_class);
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_stream_fs_class);
+	CamelStreamFsPrivate *priv;
+	CamelSeekableStream *seekable;
+	gssize nread;
 
-	parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ()));
+	priv = CAMEL_STREAM_FS (stream)->priv;
+	seekable = CAMEL_SEEKABLE_STREAM (stream);
+
+	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
+		n = MIN (seekable->bound_end - seekable->position, n);
+
+	if ((nread = camel_read (priv->fd, buffer, n)) > 0)
+		seekable->position += nread;
+	else if (nread == 0)
+		stream->eos = TRUE;
+
+	return nread;
+}
+
+static gssize
+stream_fs_write (CamelStream *stream,
+                 const gchar *buffer,
+                 gsize n)
+{
+	CamelStreamFsPrivate *priv;
+	CamelSeekableStream *seekable;
+	gssize nwritten;
+
+	priv = CAMEL_STREAM_FS (stream)->priv;
+	seekable = CAMEL_SEEKABLE_STREAM (stream);
 
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
+	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
+		n = MIN (seekable->bound_end - seekable->position, n);
 
-	camel_seekable_stream_class->seek = stream_seek;
+	if ((nwritten = camel_write (priv->fd, buffer, n)) > 0)
+		seekable->position += nwritten;
+
+	return nwritten;
+}
+
+static gint
+stream_fs_flush (CamelStream *stream)
+{
+	CamelStreamFsPrivate *priv;
+
+	priv = CAMEL_STREAM_FS (stream)->priv;
+
+	return fsync (priv->fd);
+}
+
+static gint
+stream_fs_close (CamelStream *stream)
+{
+	CamelStreamFsPrivate *priv;
+
+	priv = CAMEL_STREAM_FS (stream)->priv;
+
+	if (close (priv->fd) == -1)
+		return -1;
+
+	priv->fd = -1;
+
+	return 0;
+}
+
+static off_t
+stream_fs_seek (CamelSeekableStream *stream,
+                off_t offset,
+                CamelStreamSeekPolicy policy)
+{
+	CamelStreamFsPrivate *priv;
+	off_t real = 0;
+
+	priv = CAMEL_STREAM_FS (stream)->priv;
+
+	switch (policy) {
+	case CAMEL_STREAM_SET:
+		real = offset;
+		break;
+	case CAMEL_STREAM_CUR:
+		real = stream->position + offset;
+		break;
+	case CAMEL_STREAM_END:
+		if (stream->bound_end == CAMEL_STREAM_UNBOUND) {
+			real = lseek(priv->fd, offset, SEEK_END);
+			if (real != -1) {
+				if (real<stream->bound_start)
+					real = stream->bound_start;
+				stream->position = real;
+			}
+			return real;
+		}
+		real = stream->bound_end + offset;
+		break;
+	}
+
+	if (stream->bound_end != CAMEL_STREAM_UNBOUND)
+		real = MIN (real, stream->bound_end);
+	real = MAX (real, stream->bound_start);
+
+	real = lseek(priv->fd, real, SEEK_SET);
+	if (real == -1)
+		return -1;
+
+	if (real != stream->position && ((CamelStream *)stream)->eos)
+		((CamelStream *)stream)->eos = FALSE;
+
+	stream->position = real;
+
+	return real;
 }
 
 static void
-camel_stream_fs_init (gpointer object, gpointer klass)
+camel_stream_fs_class_init (CamelStreamFsClass *class)
 {
-	CamelStreamFs *stream = CAMEL_STREAM_FS (object);
+	CamelStreamClass *stream_class;
+	CamelSeekableStreamClass *seekable_stream_class;
+
+	parent_class = CAMEL_SEEKABLE_STREAM_CLASS (camel_type_get_global_classfuncs (camel_seekable_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = stream_fs_read;
+	stream_class->write = stream_fs_write;
+	stream_class->flush = stream_fs_flush;
+	stream_class->close = stream_fs_close;
 
-	stream->fd = -1;
-	((CamelSeekableStream *)stream)->bound_end = CAMEL_STREAM_UNBOUND;
+	seekable_stream_class = CAMEL_SEEKABLE_STREAM_CLASS (class);
+	seekable_stream_class->seek = stream_fs_seek;
 }
 
 static void
-camel_stream_fs_finalize (CamelObject *object)
+camel_stream_fs_init (CamelStreamFs *stream)
 {
-	CamelStreamFs *stream_fs = CAMEL_STREAM_FS (object);
+	stream->priv = g_new0 (CamelStreamFsPrivate, 1);
+	stream->priv->fd = -1;
 
-	if (stream_fs->fd != -1)
-		close (stream_fs->fd);
+	CAMEL_SEEKABLE_STREAM (stream)->bound_end = CAMEL_STREAM_UNBOUND;
 }
 
 CamelType
@@ -120,20 +230,23 @@ camel_stream_fs_get_type (void)
 CamelStream *
 camel_stream_fs_new_with_fd (gint fd)
 {
-	CamelStreamFs *stream_fs;
+	CamelStreamFsPrivate *priv;
+	CamelStream *stream;
 	off_t offset;
 
 	if (fd == -1)
 		return NULL;
 
-	stream_fs = CAMEL_STREAM_FS (camel_object_new (camel_stream_fs_get_type ()));
-	stream_fs->fd = fd;
+	stream = CAMEL_STREAM (camel_object_new (camel_stream_fs_get_type ()));
+	priv = CAMEL_STREAM_FS (stream)->priv;
+
+	priv->fd = fd;
 	offset = lseek (fd, 0, SEEK_CUR);
 	if (offset == -1)
 		offset = 0;
-	CAMEL_SEEKABLE_STREAM (stream_fs)->position = offset;
+	CAMEL_SEEKABLE_STREAM (stream)->position = offset;
 
-	return CAMEL_STREAM (stream_fs);
+	return stream;
 }
 
 /**
@@ -148,12 +261,15 @@ camel_stream_fs_new_with_fd (gint fd)
  * Returns: the bound stream
  **/
 CamelStream *
-camel_stream_fs_new_with_fd_and_bounds (gint fd, off_t start, off_t end)
+camel_stream_fs_new_with_fd_and_bounds (gint fd,
+                                        off_t start,
+                                        off_t end)
 {
 	CamelStream *stream;
 
 	stream = camel_stream_fs_new_with_fd (fd);
-	camel_seekable_stream_set_bounds (CAMEL_SEEKABLE_STREAM (stream), start, end);
+	camel_seekable_stream_set_bounds (
+		CAMEL_SEEKABLE_STREAM (stream), start, end);
 
 	return stream;
 }
@@ -170,14 +286,15 @@ camel_stream_fs_new_with_fd_and_bounds (gint fd, off_t start, off_t end)
  * Returns: the new stream, or %NULL on error.
  **/
 CamelStream *
-camel_stream_fs_new_with_name (const gchar *name, gint flags, mode_t mode)
+camel_stream_fs_new_with_name (const gchar *name,
+                               gint flags,
+                               mode_t mode)
 {
 	gint fd;
 
 	fd = g_open (name, flags|O_BINARY, mode);
-	if (fd == -1) {
+	if (fd == -1)
 		return NULL;
-	}
 
 	return camel_stream_fs_new_with_fd (fd);
 }
@@ -195,8 +312,11 @@ camel_stream_fs_new_with_name (const gchar *name, gint flags, mode_t mode)
  * Returns: the stream, or %NULL on error.
  **/
 CamelStream *
-camel_stream_fs_new_with_name_and_bounds (const gchar *name, gint flags,
-					  mode_t mode, off_t start, off_t end)
+camel_stream_fs_new_with_name_and_bounds (const gchar *name,
+                                          gint flags,
+                                          mode_t mode,
+                                          off_t start,
+                                          off_t end)
 {
 	CamelStream *stream;
 
@@ -204,101 +324,17 @@ camel_stream_fs_new_with_name_and_bounds (const gchar *name, gint flags,
 	if (stream == NULL)
 		return NULL;
 
-	camel_seekable_stream_set_bounds (CAMEL_SEEKABLE_STREAM (stream),
-					  start, end);
+	camel_seekable_stream_set_bounds (
+		CAMEL_SEEKABLE_STREAM (stream),
+		start, end);
 
 	return stream;
 }
 
-static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
-{
-	CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
-	CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
-	gssize nread;
-
-	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
-		n = MIN (seekable->bound_end - seekable->position, n);
-
-	if ((nread = camel_read (stream_fs->fd, buffer, n)) > 0)
-		seekable->position += nread;
-	else if (nread == 0)
-		stream->eos = TRUE;
-
-	return nread;
-}
-
-static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
-{
-	CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
-	CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
-	gssize nwritten;
-
-	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
-		n = MIN (seekable->bound_end - seekable->position, n);
-
-	if ((nwritten = camel_write (stream_fs->fd, buffer, n)) > 0)
-		seekable->position += nwritten;
-
-	return nwritten;
-}
-
-static gint
-stream_flush (CamelStream *stream)
-{
-	return fsync(((CamelStreamFs *)stream)->fd);
-}
-
-static gint
-stream_close (CamelStream *stream)
-{
-	if (close (((CamelStreamFs *)stream)->fd) == -1)
-		return -1;
-
-	((CamelStreamFs *)stream)->fd = -1;
-	return 0;
-}
-
-static off_t
-stream_seek (CamelSeekableStream *stream, off_t offset, CamelStreamSeekPolicy policy)
+gint
+camel_stream_fs_get_fd (CamelStreamFs *stream)
 {
-	CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
-	off_t real = 0;
+	g_return_val_if_fail (CAMEL_IS_STREAM_FS (stream), -1);
 
-	switch (policy) {
-	case CAMEL_STREAM_SET:
-		real = offset;
-		break;
-	case CAMEL_STREAM_CUR:
-		real = stream->position + offset;
-		break;
-	case CAMEL_STREAM_END:
-		if (stream->bound_end == CAMEL_STREAM_UNBOUND) {
-			real = lseek(stream_fs->fd, offset, SEEK_END);
-			if (real != -1) {
-				if (real<stream->bound_start)
-					real = stream->bound_start;
-				stream->position = real;
-			}
-			return real;
-		}
-		real = stream->bound_end + offset;
-		break;
-	}
-
-	if (stream->bound_end != CAMEL_STREAM_UNBOUND)
-		real = MIN (real, stream->bound_end);
-	real = MAX (real, stream->bound_start);
-
-	real = lseek(stream_fs->fd, real, SEEK_SET);
-	if (real == -1)
-		return -1;
-
-	if (real != stream->position && ((CamelStream *)stream)->eos)
-		((CamelStream *)stream)->eos = FALSE;
-
-	stream->position = real;
-
-	return real;
+	return stream->priv->fd;
 }
diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h
index 23c3cff..885da92 100644
--- a/camel/camel-stream-fs.h
+++ b/camel/camel-stream-fs.h
@@ -45,11 +45,11 @@ G_BEGIN_DECLS
 
 typedef struct _CamelStreamFs CamelStreamFs;
 typedef struct _CamelStreamFsClass CamelStreamFsClass;
+typedef struct _CamelStreamFsPrivate CamelStreamFsPrivate;
 
 struct _CamelStreamFs {
 	CamelSeekableStream parent;
-
-	gint fd;             /* file descriptor on the underlying file */
+	CamelStreamFsPrivate *priv;
 };
 
 struct _CamelStreamFsClass {
@@ -71,6 +71,7 @@ CamelStream *	camel_stream_fs_new_with_fd_and_bounds
 						(gint fd,
 						 off_t start,
 						 off_t end);
+gint		camel_stream_fs_get_fd		(CamelStreamFs *stream);
 
 G_END_DECLS
 
diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c
index 789bfed..3209f26 100644
--- a/camel/camel-stream-mem.c
+++ b/camel/camel-stream-mem.c
@@ -36,59 +36,174 @@
 
 static CamelSeekableStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelStreamMem */
-#define CSM_CLASS(so) CAMEL_STREAM_MEM_CLASS(CAMEL_OBJECT_GET_CLASS(so))
+struct _CamelStreamMemPrivate {
+	guint owner  : 1;	/* do we own the buffer? */
+	guint secure : 1;	/* do we clear the buffer on finalize?
+				   (only if we own it) */
 
-static gssize stream_read (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write (CamelStream *stream, const gchar *buffer, gsize n);
-static gboolean stream_eos (CamelStream *stream);
-static off_t stream_seek (CamelSeekableStream *stream, off_t offset,
-			  CamelStreamSeekPolicy policy);
+	GByteArray *buffer;
+};
 
-static void camel_stream_mem_finalize (CamelObject *object);
+/* could probably be a util method */
+static void
+clear_mem (gpointer p, gsize len)
+{
+	gchar *s = p;
+
+	/* This also helps debug bad access memory errors */
+	while (len > 4) {
+		*s++ = 0xAB;
+		*s++ = 0xAD;
+		*s++ = 0xF0;
+		*s++ = 0x0D;
+		len -= 4;
+	}
+
+	memset(s, 0xbf, len);
+}
 
 static void
-camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class)
+camel_stream_mem_finalize (CamelStreamMem *stream)
 {
-	CamelSeekableStreamClass *camel_seekable_stream_class =
-		CAMEL_SEEKABLE_STREAM_CLASS (camel_stream_mem_class);
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_stream_mem_class);
+	CamelStreamMemPrivate *priv = stream->priv;
 
-	parent_class = CAMEL_SEEKABLE_STREAM_CLASS( camel_type_get_global_classfuncs( CAMEL_SEEKABLE_STREAM_TYPE ) );
+	if (priv->buffer && priv->owner) {
+		/* TODO: we need our own bytearray type since we don't know
+		   the real size of the underlying buffer :-/ */
+		if (priv->secure && priv->buffer->len)
+			clear_mem (priv->buffer->data, priv->buffer->len);
+		g_byte_array_free (priv->buffer, TRUE);
+	}
 
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->eos = stream_eos;
+	g_free (priv);
+}
 
-	camel_seekable_stream_class->seek = stream_seek;
+static gssize
+stream_mem_read (CamelStream *stream,
+                 gchar *buffer,
+                 gsize n)
+{
+	CamelStreamMemPrivate *priv;
+	CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
+	gssize nread;
+
+	priv = CAMEL_STREAM_MEM (stream)->priv;
+
+	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
+		n = MIN(seekable->bound_end - seekable->position, n);
+
+	nread = MIN (n, priv->buffer->len - seekable->position);
+	if (nread > 0) {
+		memcpy (buffer, priv->buffer->data + seekable->position, nread);
+		seekable->position += nread;
+	} else
+		nread = 0;
+
+	return nread;
 }
 
-static void
-camel_stream_mem_init (CamelObject *object)
+static gssize
+stream_mem_write (CamelStream *stream,
+                  const gchar *buffer,
+                  gsize n)
+{
+	CamelStreamMemPrivate *priv;
+	CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
+	gssize nwrite = n;
+
+	priv = CAMEL_STREAM_MEM (stream)->priv;
+
+	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
+		nwrite = MIN(seekable->bound_end - seekable->position, n);
+
+	/* FIXME: we shouldn't use g_byte_arrays or g_malloc perhaps? */
+	if (seekable->position == priv->buffer->len) {
+		g_byte_array_append (priv->buffer, (const guint8 *)buffer, nwrite);
+	} else {
+		g_byte_array_set_size (priv->buffer, nwrite + priv->buffer->len);
+		memcpy (priv->buffer->data + seekable->position, buffer, nwrite);
+	}
+	seekable->position += nwrite;
+
+	return nwrite;
+}
+
+static gboolean
+stream_mem_eos (CamelStream *stream)
 {
-	CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (object);
+	CamelStreamMemPrivate *priv;
+	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
 
-	stream_mem->owner = FALSE;
-	stream_mem->buffer = NULL;
+	priv = CAMEL_STREAM_MEM (stream)->priv;
+
+	return priv->buffer->len <= seekable_stream->position;
 }
 
-/* could probably be a util method */
-static void clear_mem(gpointer p, gsize len)
+static off_t
+stream_mem_seek (CamelSeekableStream *stream,
+                 off_t offset,
+                 CamelStreamSeekPolicy policy)
 {
-	gchar *s = p;
+	CamelStreamMemPrivate *priv;
+	off_t position;
 
-	/* This also helps debug bad access memory errors */
-	while (len > 4) {
-		*s++ = 0xAB;
-		*s++ = 0xAD;
-		*s++ = 0xF0;
-		*s++ = 0x0D;
-		len -= 4;
+	priv = CAMEL_STREAM_MEM (stream)->priv;
+
+	switch  (policy) {
+	case CAMEL_STREAM_SET:
+		position = offset;
+		break;
+	case CAMEL_STREAM_CUR:
+		position = stream->position + offset;
+		break;
+	case CAMEL_STREAM_END:
+		position = (priv->buffer)->len + offset;
+		break;
+	default:
+		position = offset;
+		break;
 	}
 
-	memset(s, 0xbf, len);
+	if (stream->bound_end != CAMEL_STREAM_UNBOUND)
+		position = MIN (position, stream->bound_end);
+	if (stream->bound_start != CAMEL_STREAM_UNBOUND)
+		position = MAX (position, 0);
+	else
+		position = MAX (position, stream->bound_start);
+
+	if (position > priv->buffer->len) {
+		gint oldlen = priv->buffer->len;
+		g_byte_array_set_size (priv->buffer, position);
+		memset (priv->buffer->data + oldlen, 0,
+			position - oldlen);
+	}
+
+	stream->position = position;
+
+	return position;
+}
+
+static void
+camel_stream_mem_class_init (CamelStreamMemClass *class)
+{
+	CamelStreamClass *stream_class;
+	CamelSeekableStreamClass *seekable_stream_class;
+
+	parent_class = CAMEL_SEEKABLE_STREAM_CLASS( camel_type_get_global_classfuncs( CAMEL_SEEKABLE_STREAM_TYPE ) );
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = stream_mem_read;
+	stream_class->write = stream_mem_write;
+	stream_class->eos = stream_mem_eos;
+
+	seekable_stream_class = CAMEL_SEEKABLE_STREAM_CLASS (class);
+	seekable_stream_class->seek = stream_mem_seek;
+}
+
+static void
+camel_stream_mem_init (CamelStreamMem *stream)
+{
+	stream->priv = g_new0 (CamelStreamMemPrivate, 1);
 }
 
 CamelType
@@ -137,12 +252,16 @@ camel_stream_mem_new (void)
  * Returns: a new #CamelStreamMem
  **/
 CamelStream *
-camel_stream_mem_new_with_buffer (const gchar *buffer, gsize len)
+camel_stream_mem_new_with_buffer (const gchar *buffer,
+                                  gsize len)
 {
 	GByteArray *ba;
 
+	g_return_val_if_fail (buffer != NULL, NULL);
+
 	ba = g_byte_array_new ();
 	g_byte_array_append (ba, (const guint8 *)buffer, len);
+
 	return camel_stream_mem_new_with_byte_array (ba);
 }
 
@@ -160,13 +279,18 @@ camel_stream_mem_new_with_buffer (const gchar *buffer, gsize len)
 CamelStream *
 camel_stream_mem_new_with_byte_array (GByteArray *buffer)
 {
-	CamelStreamMem *stream_mem;
+	CamelStream *stream;
+	CamelStreamMemPrivate *priv;
+
+	g_return_val_if_fail (buffer != NULL, NULL);
+
+	stream = CAMEL_STREAM (camel_object_new (CAMEL_STREAM_MEM_TYPE));
+	priv = CAMEL_STREAM_MEM (stream)->priv;
 
-	stream_mem = CAMEL_STREAM_MEM (camel_object_new (CAMEL_STREAM_MEM_TYPE));
-	stream_mem->buffer = buffer;
-	stream_mem->owner = TRUE;
+	priv->buffer = buffer;
+	priv->owner = TRUE;
 
-	return CAMEL_STREAM (stream_mem);
+	return stream;
 }
 
 /**
@@ -180,12 +304,21 @@ camel_stream_mem_new_with_byte_array (GByteArray *buffer)
 void
 camel_stream_mem_set_secure(CamelStreamMem *mem)
 {
-	mem->secure = 1;
-	/* setup a mem-locked buffer etc?  blah blah, well not yet anyway */
+	g_return_if_fail (CAMEL_IS_STREAM_MEM (mem));
+
+	mem->priv->secure = 1;
 }
 
 /* note: with these functions the caller is the 'owner' of the buffer */
 
+GByteArray *
+camel_stream_mem_get_byte_array (CamelStreamMem *mem)
+{
+	g_return_val_if_fail (CAMEL_IS_STREAM_MEM (mem), NULL);
+
+	return mem->priv->buffer;
+}
+
 /**
  * camel_stream_mem_set_byte_array:
  * @mem: a #CamelStreamMem object
@@ -197,15 +330,21 @@ camel_stream_mem_set_secure(CamelStreamMem *mem)
  * be freed separately from @mem.
  **/
 void
-camel_stream_mem_set_byte_array (CamelStreamMem *mem, GByteArray *buffer)
+camel_stream_mem_set_byte_array (CamelStreamMem *mem,
+                                 GByteArray *buffer)
 {
-	if (mem->buffer && mem->owner) {
-		if (mem->secure && mem->buffer->len)
-			clear_mem (mem->buffer->data, mem->buffer->len);
-		g_byte_array_free (mem->buffer, TRUE);
+	g_return_if_fail (CAMEL_IS_STREAM_MEM (mem));
+	g_return_if_fail (buffer != NULL);
+
+	if (mem->priv->buffer && mem->priv->owner) {
+		if (mem->priv->secure && mem->priv->buffer->len)
+			clear_mem (
+				mem->priv->buffer->data,
+				mem->priv->buffer->len);
+		g_byte_array_free (mem->priv->buffer, TRUE);
 	}
-	mem->owner = FALSE;
-	mem->buffer = buffer;
+	mem->priv->owner = FALSE;
+	mem->priv->buffer = buffer;
 }
 
 /**
@@ -220,118 +359,17 @@ camel_stream_mem_set_byte_array (CamelStreamMem *mem, GByteArray *buffer)
  * and so may have resource implications to consider.
  **/
 void
-camel_stream_mem_set_buffer (CamelStreamMem *mem, const gchar *buffer, gsize len)
+camel_stream_mem_set_buffer (CamelStreamMem *mem,
+                             const gchar *buffer,
+                             gsize len)
 {
 	GByteArray *ba;
 
+	g_return_if_fail (CAMEL_IS_STREAM_MEM (mem));
+	g_return_if_fail (buffer != NULL);
+
 	ba = g_byte_array_new ();
 	g_byte_array_append(ba, (const guint8 *)buffer, len);
 	camel_stream_mem_set_byte_array(mem, ba);
-	mem->owner = TRUE;
-}
-
-static void
-camel_stream_mem_finalize (CamelObject *object)
-{
-	CamelStreamMem *s = CAMEL_STREAM_MEM (object);
-
-	if (s->buffer && s->owner) {
-		/* TODO: we need our own bytearray type since we don't know
-		   the real size of the underlying buffer :-/ */
-		if (s->secure && s->buffer->len)
-			clear_mem(s->buffer->data, s->buffer->len);
-		g_byte_array_free(s->buffer, TRUE);
-	}
-}
-
-static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
-{
-	CamelStreamMem *camel_stream_mem = CAMEL_STREAM_MEM (stream);
-	CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
-	gssize nread;
-
-	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
-		n = MIN(seekable->bound_end - seekable->position, n);
-
-	nread = MIN (n, camel_stream_mem->buffer->len - seekable->position);
-	if (nread > 0) {
-		memcpy (buffer, camel_stream_mem->buffer->data + seekable->position, nread);
-		seekable->position += nread;
-	} else
-		nread = 0;
-
-	return nread;
-}
-
-static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
-{
-	CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (stream);
-	CamelSeekableStream *seekable = CAMEL_SEEKABLE_STREAM (stream);
-	gssize nwrite = n;
-
-	if (seekable->bound_end != CAMEL_STREAM_UNBOUND)
-		nwrite = MIN(seekable->bound_end - seekable->position, n);
-
-	/* FIXME: we shouldn't use g_byte_arrays or g_malloc perhaps? */
-	if (seekable->position == stream_mem->buffer->len) {
-		g_byte_array_append(stream_mem->buffer, (const guint8 *)buffer, nwrite);
-	} else {
-		g_byte_array_set_size(stream_mem->buffer, nwrite + stream_mem->buffer->len);
-		memcpy(stream_mem->buffer->data + seekable->position, buffer, nwrite);
-	}
-	seekable->position += nwrite;
-
-	return nwrite;
-}
-
-static gboolean
-stream_eos (CamelStream *stream)
-{
-	CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (stream);
-	CamelSeekableStream *seekable_stream = CAMEL_SEEKABLE_STREAM (stream);
-
-	return stream_mem->buffer->len <= seekable_stream->position;
-}
-
-static off_t
-stream_seek (CamelSeekableStream *stream, off_t offset,
-	     CamelStreamSeekPolicy policy)
-{
-	off_t position;
-	CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (stream);
-
-	switch  (policy) {
-	case CAMEL_STREAM_SET:
-		position = offset;
-		break;
-	case CAMEL_STREAM_CUR:
-		position = stream->position + offset;
-		break;
-	case CAMEL_STREAM_END:
-		position = (stream_mem->buffer)->len + offset;
-		break;
-	default:
-		position = offset;
-		break;
-	}
-
-	if (stream->bound_end != CAMEL_STREAM_UNBOUND)
-		position = MIN (position, stream->bound_end);
-	if (stream->bound_start != CAMEL_STREAM_UNBOUND)
-		position = MAX (position, 0);
-	else
-		position = MAX (position, stream->bound_start);
-
-	if (position > stream_mem->buffer->len) {
-		gint oldlen = stream_mem->buffer->len;
-		g_byte_array_set_size (stream_mem->buffer, position);
-		memset (stream_mem->buffer->data + oldlen, 0,
-			position - oldlen);
-	}
-
-	stream->position = position;
-
-	return position;
+	mem->priv->owner = TRUE;
 }
diff --git a/camel/camel-stream-mem.h b/camel/camel-stream-mem.h
index ad98483..ffd2bd2 100644
--- a/camel/camel-stream-mem.h
+++ b/camel/camel-stream-mem.h
@@ -41,13 +41,11 @@ G_BEGIN_DECLS
 
 typedef struct _CamelStreamMem CamelStreamMem;
 typedef struct _CamelStreamMemClass CamelStreamMemClass;
+typedef struct _CamelStreamMemPrivate CamelStreamMemPrivate;
 
 struct _CamelStreamMem {
 	CamelSeekableStream parent;
-
-	guint owner:1;	/* do we own the buffer? */
-	guint secure:1;	/* do we clear the buffer on finalize (if we own it) */
-	GByteArray *buffer;
+	CamelStreamMemPrivate *priv;
 };
 
 struct _CamelStreamMemClass {
@@ -61,6 +59,7 @@ CamelStream *	camel_stream_mem_new_with_byte_array
 CamelStream *	camel_stream_mem_new_with_buffer(const gchar *buffer,
 						 gsize len);
 void		camel_stream_mem_set_secure	(CamelStreamMem *mem);
+GByteArray *	camel_stream_mem_get_byte_array	(CamelStreamMem *mem);
 void		camel_stream_mem_set_byte_array	(CamelStreamMem *mem,
 						 GByteArray *buffer);
 void		camel_stream_mem_set_buffer	(CamelStreamMem *mem,
diff --git a/camel/camel-stream-null.c b/camel/camel-stream-null.c
index 03e8906..1731a34 100644
--- a/camel/camel-stream-null.c
+++ b/camel/camel-stream-null.c
@@ -30,31 +30,46 @@
 
 static CamelObjectClass *parent_class = NULL;
 
-/* Returns the class for a CamelStream */
-#define CS_CLASS(so) CAMEL_STREAM_NULL_CLASS(CAMEL_OBJECT_GET_CLASS(so))
+static gssize
+stream_null_write (CamelStream *stream,
+                   const gchar *buffer,
+                   gsize n)
+{
+	CAMEL_STREAM_NULL (stream)->written += n;
+
+	return n;
+}
+
+static gboolean
+stream_null_eos (CamelStream *stream)
+{
+	return TRUE;
+}
+
+static gint
+stream_null_reset (CamelStream *stream)
+{
+	CAMEL_STREAM_NULL (stream)->written = 0;
 
-/* dummy implementations, for a NULL stream */
-static gssize   stream_read       (CamelStream *stream, gchar *buffer, gsize n) { return 0; }
-static gssize   stream_write      (CamelStream *stream, const gchar *buffer, gsize n) { ((CamelStreamNull *)stream)->written += n; return n; }
-static gint       stream_close      (CamelStream *stream) { return 0; }
-static gint       stream_flush      (CamelStream *stream) { return 0; }
-static gboolean  stream_eos        (CamelStream *stream) { return TRUE; }
-static gint       stream_reset      (CamelStream *stream) { ((CamelStreamNull *)stream)->written = 0; return 0; }
+	return 0;
+}
 
 static void
-camel_stream_null_class_init (CamelStreamClass *camel_stream_null_class)
+camel_stream_null_class_init (CamelStreamNullClass *class)
 {
-	CamelStreamClass *camel_stream_class = (CamelStreamClass *)camel_stream_null_class;
+	CamelStreamClass *stream_class;
 
 	parent_class = camel_type_get_global_classfuncs( CAMEL_TYPE_OBJECT );
 
-	/* virtual method definition */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->close = stream_close;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->eos = stream_eos;
-	camel_stream_class->reset = stream_reset;
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->write = stream_null_write;
+	stream_class->eos = stream_null_eos;
+	stream_class->reset = stream_null_reset;
+}
+
+static void
+camel_stream_null_init (CamelStreamNull *stream_null)
+{
 }
 
 CamelType
@@ -69,7 +84,7 @@ camel_stream_null_get_type (void)
 							      sizeof( CamelStreamNullClass ),
 							      (CamelObjectClassInitFunc) camel_stream_null_class_init,
 							      NULL,
-							      NULL,
+							      (CamelObjectInitFunc) camel_stream_null_init,
 							      NULL );
 	}
 
diff --git a/camel/camel-stream-process.c b/camel/camel-stream-process.c
index eafaac2..6fcae95 100644
--- a/camel/camel-stream-process.c
+++ b/camel/camel-stream-process.c
@@ -46,80 +46,18 @@ extern gint camel_verbose_debug;
 
 static CamelObjectClass *parent_class = NULL;
 
-/* Returns the class for a CamelStream */
-#define CS_CLASS(so) CAMEL_STREAM_PROCESS_CLASS(CAMEL_OBJECT_GET_CLASS(so))
-
-/* dummy implementations, for a PROCESS stream */
-static gssize   stream_read       (CamelStream *stream, gchar *buffer, gsize n);
-static gssize   stream_write      (CamelStream *stream, const gchar *buffer, gsize n);
-static gint       stream_close      (CamelStream *stream);
-static gint       stream_flush      (CamelStream *stream);
-
 static void
-camel_stream_process_finalize (CamelObject *object)
+stream_process_finalize (CamelObject *object)
 {
 	/* Ensure we clean up after ourselves -- kill
 	   the child process and reap it. */
-	stream_close (CAMEL_STREAM (object));
-}
-
-static void
-camel_stream_process_class_init (CamelStreamProcessClass *camel_stream_process_class)
-{
-	CamelStreamClass *camel_stream_class = (CamelStreamClass *) camel_stream_process_class;
-
-	parent_class = camel_type_get_global_classfuncs (CAMEL_TYPE_OBJECT);
-
-	/* virtual method definition */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->close = stream_close;
-	camel_stream_class->flush = stream_flush;
-}
-
-static void
-camel_stream_process_init (gpointer object, gpointer klass)
-{
-        CamelStreamProcess *stream = CAMEL_STREAM_PROCESS (object);
-
-        stream->sockfd = -1;
-	stream->childpid = 0;
-}
-
-CamelType
-camel_stream_process_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type =  camel_type_register (camel_stream_get_type (),
-					     "CamelStreamProcess",
-					     sizeof (CamelStreamProcess),
-					     sizeof (CamelStreamProcessClass),
-					     (CamelObjectClassInitFunc) camel_stream_process_class_init,
-					     NULL,
-					     (CamelObjectInitFunc) camel_stream_process_init,
-					     (CamelObjectFinalizeFunc) camel_stream_process_finalize);
-	}
-
-	return type;
-}
-
-/**
- * camel_stream_process_new:
- *
- * Returns a PROCESS stream.
- *
- * Returns: the stream
- **/
-CamelStream *
-camel_stream_process_new (void)
-{
-	return (CamelStream *) camel_object_new (camel_stream_process_get_type ());
+	camel_stream_close (CAMEL_STREAM (object));
 }
 
 static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
+stream_process_read (CamelStream *stream,
+                     gchar *buffer,
+                     gsize n)
 {
 	CamelStreamProcess *stream_process = CAMEL_STREAM_PROCESS (stream);
 
@@ -127,7 +65,9 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
 }
 
 static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+stream_process_write (CamelStream *stream,
+                      const gchar *buffer,
+                      gsize n)
 {
 	CamelStreamProcess *stream_process = CAMEL_STREAM_PROCESS (stream);
 
@@ -135,13 +75,7 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 }
 
 static gint
-stream_flush (CamelStream *stream)
-{
-	return 0;
-}
-
-static gint
-stream_close (CamelStream *object)
+stream_process_close (CamelStream *object)
 {
 	CamelStreamProcess *stream = CAMEL_STREAM_PROCESS (object);
 
@@ -189,6 +123,65 @@ stream_close (CamelStream *object)
 	return 0;
 }
 
+static gint
+stream_process_flush (CamelStream *stream)
+{
+	return 0;
+}
+
+static void
+camel_stream_process_class_init (CamelStreamProcessClass *class)
+{
+	CamelStreamClass *stream_class;
+
+	parent_class = camel_type_get_global_classfuncs (CAMEL_TYPE_OBJECT);
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = stream_process_read;
+	stream_class->write = stream_process_write;
+	stream_class->close = stream_process_close;
+	stream_class->flush = stream_process_flush;
+}
+
+static void
+camel_stream_process_init (CamelStreamProcess *stream)
+{
+	stream->sockfd = -1;
+	stream->childpid = 0;
+}
+
+CamelType
+camel_stream_process_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		type =  camel_type_register (camel_stream_get_type (),
+					     "CamelStreamProcess",
+					     sizeof (CamelStreamProcess),
+					     sizeof (CamelStreamProcessClass),
+					     (CamelObjectClassInitFunc) camel_stream_process_class_init,
+					     NULL,
+					     (CamelObjectInitFunc) camel_stream_process_init,
+					     (CamelObjectFinalizeFunc) stream_process_finalize);
+	}
+
+	return type;
+}
+
+/**
+ * camel_stream_process_new:
+ *
+ * Returns a PROCESS stream.
+ *
+ * Returns: the stream
+ **/
+CamelStream *
+camel_stream_process_new (void)
+{
+	return (CamelStream *) camel_object_new (camel_stream_process_get_type ());
+}
+
 G_GNUC_NORETURN static void
 do_exec_command (gint fd, const gchar *command, gchar **env)
 {
@@ -235,12 +228,17 @@ do_exec_command (gint fd, const gchar *command, gchar **env)
 }
 
 gint
-camel_stream_process_connect (CamelStreamProcess *stream, const gchar *command, const gchar **env)
+camel_stream_process_connect (CamelStreamProcess *stream,
+                              const gchar *command,
+                              const gchar **env)
 {
 	gint sockfds[2];
 
+	g_return_val_if_fail (CAMEL_IS_STREAM_PROCESS (stream), -1);
+	g_return_val_if_fail (command != NULL, -1);
+
 	if (stream->sockfd != -1 || stream->childpid)
-		stream_close (CAMEL_STREAM (stream));
+		camel_stream_close (CAMEL_STREAM (stream));
 
 	if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockfds))
 		return -1;
diff --git a/camel/camel-stream-vfs.c b/camel/camel-stream-vfs.c
index c90464f..0f1bad0 100644
--- a/camel/camel-stream-vfs.c
+++ b/camel/camel-stream-vfs.c
@@ -28,7 +28,6 @@
 #include <errno.h>
 #include <string.h>
 
-#include <glib.h>
 #include <gio/gio.h>
 
 #include "camel-file-utils.h"
@@ -38,44 +37,123 @@
 
 static CamelStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelStreamVFS */
-#define CSVFS_CLASS(so) CAMEL_STREAM_VFS_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-static gssize stream_read   (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write  (CamelStream *stream, const gchar *buffer, gsize n);
-static gint stream_flush  (CamelStream *stream);
-static gint stream_close  (CamelStream *stream);
 
 static void
-camel_stream_vfs_class_init (CamelStreamVFSClass *camel_stream_vfs_class)
+stream_vfs_finalize (CamelStreamVFS *stream_vfs)
 {
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_stream_vfs_class);
+	if (stream_vfs->stream)
+		g_object_unref (stream_vfs->stream);
+}
 
-	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
+static gssize
+stream_vfs_read (CamelStream *stream,
+                 gchar *buffer,
+                 gsize n)
+{
+	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
+	gssize nread;
+	GError *error = NULL;
+
+	nread = g_input_stream_read (
+		G_INPUT_STREAM (stream_vfs->stream),
+		buffer, n, NULL, &error);
+
+	if (nread == 0 || error != NULL)
+		stream->eos = TRUE;
+
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
 
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
+	return nread;
 }
 
-static void
-camel_stream_vfs_init (gpointer object, gpointer klass)
+static gssize
+stream_vfs_write (CamelStream *stream,
+                  const gchar *buffer,
+                  gsize n)
 {
-	CamelStreamVFS *stream = CAMEL_STREAM_VFS (object);
+	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
+	gboolean success;
+	gsize bytes_written;
+	GError *error = NULL;
 
-	stream->stream = NULL;
+	success = g_output_stream_write_all (
+		G_OUTPUT_STREAM (stream_vfs->stream),
+		buffer, n, &bytes_written, NULL, &error);
+
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+
+	return success ? bytes_written : -1;
 }
 
-static void
-camel_stream_vfs_finalize (CamelObject *object)
+static gint
+stream_vfs_flush (CamelStream *stream)
 {
-	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (object);
+	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
+	gboolean success;
+	GError *error = NULL;
 
-	if (stream_vfs->stream)
+	success = g_output_stream_flush (
+		G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
+
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+
+	return success ? 0 : -1;
+}
+
+static gint
+stream_vfs_close (CamelStream *stream)
+{
+	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
+	gboolean success;
+	GError *error = NULL;
+
+	if (G_IS_OUTPUT_STREAM (stream_vfs->stream))
+		success = g_output_stream_close (
+			G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
+	else
+		success = g_input_stream_close (
+			G_INPUT_STREAM (stream_vfs->stream), NULL, &error);
+
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+	}
+
+	if (success) {
 		g_object_unref (stream_vfs->stream);
+		stream_vfs->stream = NULL;
+	}
+
+	return success ? 0 : -1;
+}
+
+static void
+camel_stream_vfs_class_init (CamelStreamVFSClass *class)
+{
+	CamelStreamClass *stream_class;
+
+	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (camel_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = stream_vfs_read;
+	stream_class->write = stream_vfs_write;
+	stream_class->flush = stream_vfs_flush;
+	stream_class->close = stream_vfs_close;
+}
+
+static void
+camel_stream_vfs_init (CamelStreamVFS *stream)
+{
+	stream->stream = NULL;
 }
 
 CamelType
@@ -90,7 +168,7 @@ camel_stream_vfs_get_type (void)
 							    (CamelObjectClassInitFunc) camel_stream_vfs_class_init,
 							    NULL,
 							    (CamelObjectInitFunc) camel_stream_vfs_init,
-							    (CamelObjectFinalizeFunc) camel_stream_vfs_finalize);
+							    (CamelObjectFinalizeFunc) stream_vfs_finalize);
 	}
 
 	return camel_stream_vfs_type;
@@ -188,92 +266,3 @@ camel_stream_vfs_is_writable (CamelStreamVFS *stream_vfs)
 
 	return G_IS_OUTPUT_STREAM (stream_vfs->stream);
 }
-
-static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
-{
-	gssize nread;
-	GError *error = NULL;
-	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
-
-	g_return_val_if_fail (G_IS_INPUT_STREAM (stream_vfs->stream), 0);
-
-	nread = g_input_stream_read (G_INPUT_STREAM (stream_vfs->stream), buffer, n, NULL, &error);
-
-	if (nread == 0 || error)
-		stream->eos = TRUE;
-
-	if (error) {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-	}
-
-	return nread;
-}
-
-static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
-{
-	gboolean success;
-	gsize bytes_written;
-	GError *error = NULL;
-	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
-
-	g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream), 0);
-
-	success = g_output_stream_write_all (G_OUTPUT_STREAM (stream_vfs->stream), buffer, n, &bytes_written, NULL, &error);
-
-	if (error) {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-	}
-	return success ? bytes_written : -1;
-}
-
-static gint
-stream_flush (CamelStream *stream)
-{
-	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
-	GError *error = NULL;
-
-	g_return_val_if_fail (CAMEL_IS_STREAM_VFS (stream) && stream_vfs != NULL, -1);
-	g_return_val_if_fail (stream_vfs->stream != NULL, -1);
-	g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream), -1);
-
-	g_output_stream_flush (G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
-
-	if (error) {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-		return -1;
-	}
-
-	return 0;
-}
-
-static gint
-stream_close (CamelStream *stream)
-{
-	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
-	GError *error = NULL;
-
-	g_return_val_if_fail (CAMEL_IS_STREAM_VFS (stream) && stream_vfs != NULL, -1);
-	g_return_val_if_fail (stream_vfs->stream != NULL, -1);
-	g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream_vfs->stream) || G_IS_INPUT_STREAM (stream_vfs->stream), -1);
-
-	if (G_IS_OUTPUT_STREAM (stream_vfs->stream))
-		g_output_stream_close (G_OUTPUT_STREAM (stream_vfs->stream), NULL, &error);
-	else
-		g_input_stream_close (G_INPUT_STREAM (stream_vfs->stream), NULL, &error);
-
-	if (error) {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-		return -1;
-	}
-
-	g_object_unref (stream_vfs->stream);
-	stream_vfs->stream = NULL;
-
-	return 0;
-}
diff --git a/camel/camel-stream-vfs.h b/camel/camel-stream-vfs.h
index fa2eb94..06b9e2a 100644
--- a/camel/camel-stream-vfs.h
+++ b/camel/camel-stream-vfs.h
@@ -29,9 +29,7 @@
 #ifndef CAMEL_STREAM_VFS_H
 #define CAMEL_STREAM_VFS_H
 
-#include <glib.h>
 #include <glib-object.h>
-
 #include <camel/camel-stream.h>
 
 #define CAMEL_STREAM_VFS_TYPE     (camel_stream_vfs_get_type ())
diff --git a/camel/camel-stream.c b/camel/camel-stream.c
index 5ef7b5b..dcf09aa 100644
--- a/camel/camel-stream.c
+++ b/camel/camel-stream.c
@@ -32,29 +32,62 @@
 
 static CamelObjectClass *parent_class = NULL;
 
-/* Returns the class for a CamelStream */
-#define CS_CLASS(so) CAMEL_STREAM_CLASS(CAMEL_OBJECT_GET_CLASS(so))
+static gssize
+stream_read (CamelStream *stream,
+             gchar *buffer,
+             gsize n)
+{
+	return 0;
+}
 
-/* default implementations, do very little */
-static gssize   stream_read       (CamelStream *stream, gchar *buffer, gsize n) { return 0; }
-static gssize   stream_write      (CamelStream *stream, const gchar *buffer, gsize n) { return n; }
-static gint       stream_close      (CamelStream *stream) { return 0; }
-static gint       stream_flush      (CamelStream *stream) { return 0; }
-static gboolean  stream_eos        (CamelStream *stream) { return stream->eos; }
-static gint       stream_reset      (CamelStream *stream) { return 0; }
+static gssize
+stream_write (CamelStream *stream,
+              const gchar *buffer,
+              gsize n)
+{
+	return n;
+}
+
+static gint
+stream_close (CamelStream *stream)
+{
+	return 0;
+}
+
+static gint
+stream_flush (CamelStream *stream)
+{
+	return 0;
+}
+
+static gboolean
+stream_eos (CamelStream *stream)
+{
+	return stream->eos;
+}
+
+static gint
+stream_reset (CamelStream *stream)
+{
+	return 0;
+}
 
 static void
-camel_stream_class_init (CamelStreamClass *camel_stream_class)
+camel_stream_class_init (CamelStreamClass *class)
 {
 	parent_class = camel_type_get_global_classfuncs( CAMEL_TYPE_OBJECT );
 
-	/* virtual method definition */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->close = stream_close;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->eos = stream_eos;
-	camel_stream_class->reset = stream_reset;
+	class->read = stream_read;
+	class->write = stream_write;
+	class->close = stream_close;
+	class->flush = stream_flush;
+	class->eos = stream_eos;
+	class->reset = stream_reset;
+}
+
+static void
+camel_stream_init (CamelStream *stream)
+{
 }
 
 CamelType
@@ -69,7 +102,7 @@ camel_stream_get_type (void)
 							 sizeof( CamelStreamClass ),
 							 (CamelObjectClassInitFunc) camel_stream_class_init,
 							 NULL,
-							 NULL,
+							 (CamelObjectInitFunc) camel_stream_init,
 							 NULL );
 	}
 
@@ -88,12 +121,19 @@ camel_stream_get_type (void)
  * errno.
  **/
 gssize
-camel_stream_read (CamelStream *stream, gchar *buffer, gsize n)
+camel_stream_read (CamelStream *stream,
+                   gchar *buffer,
+                   gsize n)
 {
+	CamelStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
 	g_return_val_if_fail (n == 0 || buffer, -1);
 
-	return (CS_CLASS (stream)->read) (stream, buffer, n);
+	class = CAMEL_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->read != NULL, -1);
+
+	return class->read (stream, buffer, n);
 }
 
 /**
@@ -108,12 +148,19 @@ camel_stream_read (CamelStream *stream, gchar *buffer, gsize n)
  * along with setting errno.
  **/
 gssize
-camel_stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+camel_stream_write (CamelStream *stream,
+                    const gchar *buffer,
+                    gsize n)
 {
+	CamelStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
 	g_return_val_if_fail (n == 0 || buffer, -1);
 
-	return CS_CLASS (stream)->write (stream, buffer, n);
+	class = CAMEL_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->write != NULL, -1);
+
+	return class->write (stream, buffer, n);
 }
 
 /**
@@ -128,9 +175,14 @@ camel_stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 gint
 camel_stream_flush (CamelStream *stream)
 {
+	CamelStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
 
-	return CS_CLASS (stream)->flush (stream);
+	class = CAMEL_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->flush != NULL, -1);
+
+	return class->flush (stream);
 }
 
 /**
@@ -144,9 +196,14 @@ camel_stream_flush (CamelStream *stream)
 gint
 camel_stream_close (CamelStream *stream)
 {
+	CamelStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
 
-	return CS_CLASS (stream)->close (stream);
+	class = CAMEL_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->close != NULL, -1);
+
+	return class->close (stream);
 }
 
 /**
@@ -160,9 +217,14 @@ camel_stream_close (CamelStream *stream)
 gboolean
 camel_stream_eos (CamelStream *stream)
 {
+	CamelStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_STREAM (stream), TRUE);
 
-	return CS_CLASS (stream)->eos (stream);
+	class = CAMEL_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->eos != NULL, TRUE);
+
+	return class->eos (stream);
 }
 
 /**
@@ -178,9 +240,14 @@ camel_stream_eos (CamelStream *stream)
 gint
 camel_stream_reset (CamelStream *stream)
 {
+	CamelStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_STREAM (stream), -1);
 
-	return CS_CLASS (stream)->reset (stream);
+	class = CAMEL_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->reset != NULL, -1);
+
+	return class->reset (stream);
 }
 
 /***************** Utility functions ********************/
@@ -222,11 +289,12 @@ camel_stream_printf (CamelStream *stream, const gchar *fmt, ... )
 	string = g_strdup_vprintf (fmt, args);
 	va_end (args);
 
-	if (!string)
+	if (string == NULL)
 		return -1;
 
 	ret = camel_stream_write (stream, string, strlen (string));
 	g_free (string);
+
 	return ret;
 }
 
@@ -242,7 +310,8 @@ camel_stream_printf (CamelStream *stream, const gchar *fmt, ... )
  * copied across streams.
  **/
 gssize
-camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream)
+camel_stream_write_to_stream (CamelStream *stream,
+                              CamelStream *output_stream)
 {
 	gchar tmp_buf[4096];
 	gssize total = 0;
@@ -253,15 +322,17 @@ camel_stream_write_to_stream (CamelStream *stream, CamelStream *output_stream)
 	g_return_val_if_fail (CAMEL_IS_STREAM (output_stream), -1);
 
 	while (!camel_stream_eos (stream)) {
-		nb_read = camel_stream_read (stream, tmp_buf, sizeof (tmp_buf));
+		nb_read = camel_stream_read (
+			stream, tmp_buf, sizeof (tmp_buf));
 		if (nb_read < 0)
 			return -1;
 		else if (nb_read > 0) {
 			nb_written = 0;
 
 			while (nb_written < nb_read) {
-				gssize len = camel_stream_write (output_stream, tmp_buf + nb_written,
-								  nb_read - nb_written);
+				gssize len = camel_stream_write (
+					output_stream, tmp_buf + nb_written,
+					nb_read - nb_written);
 				if (len < 0)
 					return -1;
 				nb_written += len;
diff --git a/camel/camel-stream.h b/camel/camel-stream.h
index e78b6b6..d150dbe 100644
--- a/camel/camel-stream.h
+++ b/camel/camel-stream.h
@@ -37,6 +37,8 @@
 #define CAMEL_STREAM(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_TYPE, CamelStream))
 #define CAMEL_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_TYPE, CamelStreamClass))
 #define CAMEL_IS_STREAM(o)    (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_TYPE))
+#define CAMEL_STREAM_GET_CLASS(obj) \
+	((CamelStreamClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
@@ -81,7 +83,7 @@ gssize		camel_stream_write_string	(CamelStream *stream,
 						 const gchar *string);
 gssize		camel_stream_printf		(CamelStream *stream,
 						 const gchar *fmt,
-						 ... ) G_GNUC_PRINTF (2, 3);
+						 ...) G_GNUC_PRINTF (2, 3);
 gssize		camel_stream_vprintf		(CamelStream *stream,
 						 const gchar *fmt,
 						 va_list ap);
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 177f95d..095c4b6 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -54,79 +54,6 @@
 
 static CamelTcpStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelTcpStreamRaw */
-#define CTSR_CLASS(so) CAMEL_TCP_STREAM_RAW_CLASS (CAMEL_OBJECT_GET_CLASS (so))
-
-static gssize stream_read (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write (CamelStream *stream, const gchar *buffer, gsize n);
-static gint stream_flush  (CamelStream *stream);
-static gint stream_close  (CamelStream *stream);
-
-static gint stream_connect (CamelTcpStream *stream, struct addrinfo *host);
-static gint stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
-static gint stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
-static struct sockaddr *stream_get_local_address (CamelTcpStream *stream, socklen_t *len);
-static struct sockaddr *stream_get_remote_address (CamelTcpStream *stream, socklen_t *len);
-
-static void
-camel_tcp_stream_raw_class_init (CamelTcpStreamRawClass *camel_tcp_stream_raw_class)
-{
-	CamelTcpStreamClass *camel_tcp_stream_class =
-		CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_raw_class);
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_tcp_stream_raw_class);
-
-	parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
-
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
-
-	camel_tcp_stream_class->connect = stream_connect;
-	camel_tcp_stream_class->getsockopt = stream_getsockopt;
-	camel_tcp_stream_class->setsockopt  = stream_setsockopt;
-	camel_tcp_stream_class->get_local_address  = stream_get_local_address;
-	camel_tcp_stream_class->get_remote_address = stream_get_remote_address;
-}
-
-static void
-camel_tcp_stream_raw_init (gpointer object, gpointer klass)
-{
-	CamelTcpStreamRaw *stream = CAMEL_TCP_STREAM_RAW (object);
-
-	stream->sockfd = -1;
-}
-
-static void
-camel_tcp_stream_raw_finalize (CamelObject *object)
-{
-	CamelTcpStreamRaw *stream = CAMEL_TCP_STREAM_RAW (object);
-
-	if (stream->sockfd != -1)
-		SOCKET_CLOSE (stream->sockfd);
-}
-
-CamelType
-camel_tcp_stream_raw_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_tcp_stream_get_type (),
-					    "CamelTcpStreamRaw",
-					    sizeof (CamelTcpStreamRaw),
-					    sizeof (CamelTcpStreamRawClass),
-					    (CamelObjectClassInitFunc) camel_tcp_stream_raw_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_tcp_stream_raw_init,
-					    (CamelObjectFinalizeFunc) camel_tcp_stream_raw_finalize);
-	}
-
-	return type;
-}
-
 #ifdef SIMULATE_FLAKY_NETWORK
 static gssize
 flaky_tcp_write (gint fd, const gchar *buffer, gsize buflen)
@@ -228,53 +155,45 @@ flaky_tcp_read (gint fd, gchar *buffer, gsize buflen)
 
 #endif /* SIMULATE_FLAKY_NETWORK */
 
-/**
- * camel_tcp_stream_raw_new:
- *
- * Create a new #CamelTcpStreamRaw object.
- *
- * Returns: a new #CamelTcpStream object
- **/
-CamelStream *
-camel_tcp_stream_raw_new (void)
-{
-	CamelTcpStreamRaw *stream;
-
-	stream = CAMEL_TCP_STREAM_RAW (camel_object_new (camel_tcp_stream_raw_get_type ()));
-
-	return CAMEL_STREAM (stream);
-}
-
-static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
-{
-	CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
-
-	return camel_read_socket (raw->sockfd, buffer, n);
-}
-
-static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
-{
-	CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
-
-	return camel_write_socket (raw->sockfd, buffer, n);
-}
-
 static gint
-stream_flush (CamelStream *stream)
+get_sockopt_level (const CamelSockOptData *data)
 {
-	return 0;
+	switch (data->option) {
+	case CAMEL_SOCKOPT_MAXSEGMENT:
+	case CAMEL_SOCKOPT_NODELAY:
+		return IPPROTO_TCP;
+	default:
+		return SOL_SOCKET;
+	}
 }
 
 static gint
-stream_close (CamelStream *stream)
+get_sockopt_optname (const CamelSockOptData *data)
 {
-	if (SOCKET_CLOSE (((CamelTcpStreamRaw *)stream)->sockfd) == -1)
+	switch (data->option) {
+#ifdef TCP_MAXSEG
+	case CAMEL_SOCKOPT_MAXSEGMENT:
+		return TCP_MAXSEG;
+#endif
+	case CAMEL_SOCKOPT_NODELAY:
+		return TCP_NODELAY;
+	case CAMEL_SOCKOPT_BROADCAST:
+		return SO_BROADCAST;
+	case CAMEL_SOCKOPT_KEEPALIVE:
+		return SO_KEEPALIVE;
+	case CAMEL_SOCKOPT_LINGER:
+		return SO_LINGER;
+	case CAMEL_SOCKOPT_RECVBUFFERSIZE:
+		return SO_RCVBUF;
+	case CAMEL_SOCKOPT_SENDBUFFERSIZE:
+		return SO_SNDBUF;
+	case CAMEL_SOCKOPT_REUSEADDR:
+		return SO_REUSEADDR;
+	case CAMEL_SOCKOPT_IPTYPEOFSERVICE:
+		return SO_TYPE;
+	default:
 		return -1;
-
-	((CamelTcpStreamRaw *)stream)->sockfd = -1;
-	return 0;
+	}
 }
 
 /* this is a 'cancellable' connect, cancellable from camel_operation_cancel etc */
@@ -402,67 +321,71 @@ socket_connect(struct addrinfo *h)
 	return fd;
 }
 
-static gint
-stream_connect (CamelTcpStream *stream, struct addrinfo *host)
+static void
+tcp_stream_raw_finalize (CamelTcpStreamRaw *stream)
 {
-	CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
+	if (stream->sockfd != -1)
+		SOCKET_CLOSE (stream->sockfd);
+}
 
-	g_return_val_if_fail (host != NULL, -1);
+static gssize
+tcp_stream_raw_read (CamelStream *stream,
+                     gchar *buffer,
+                     gsize n)
+{
+	CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
 
-	while (host) {
-		raw->sockfd = socket_connect(host);
-		if (raw->sockfd != -1)
-			return 0;
+	return camel_read_socket (raw->sockfd, buffer, n);
+}
 
-		host = host->ai_next;
-	}
+static gssize
+tcp_stream_raw_write (CamelStream *stream,
+                      const gchar *buffer,
+                      gsize n)
+{
+	CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
 
-	return -1;
+	return camel_write_socket (raw->sockfd, buffer, n);
 }
 
 static gint
-get_sockopt_level (const CamelSockOptData *data)
+tcp_stream_raw_flush (CamelStream *stream)
 {
-	switch (data->option) {
-	case CAMEL_SOCKOPT_MAXSEGMENT:
-	case CAMEL_SOCKOPT_NODELAY:
-		return IPPROTO_TCP;
-	default:
-		return SOL_SOCKET;
-	}
+	return 0;
 }
 
 static gint
-get_sockopt_optname (const CamelSockOptData *data)
+tcp_stream_raw_close (CamelStream *stream)
 {
-	switch (data->option) {
-#ifdef TCP_MAXSEG
-	case CAMEL_SOCKOPT_MAXSEGMENT:
-		return TCP_MAXSEG;
-#endif
-	case CAMEL_SOCKOPT_NODELAY:
-		return TCP_NODELAY;
-	case CAMEL_SOCKOPT_BROADCAST:
-		return SO_BROADCAST;
-	case CAMEL_SOCKOPT_KEEPALIVE:
-		return SO_KEEPALIVE;
-	case CAMEL_SOCKOPT_LINGER:
-		return SO_LINGER;
-	case CAMEL_SOCKOPT_RECVBUFFERSIZE:
-		return SO_RCVBUF;
-	case CAMEL_SOCKOPT_SENDBUFFERSIZE:
-		return SO_SNDBUF;
-	case CAMEL_SOCKOPT_REUSEADDR:
-		return SO_REUSEADDR;
-	case CAMEL_SOCKOPT_IPTYPEOFSERVICE:
-		return SO_TYPE;
-	default:
+	if (SOCKET_CLOSE (((CamelTcpStreamRaw *)stream)->sockfd) == -1)
 		return -1;
+
+	((CamelTcpStreamRaw *)stream)->sockfd = -1;
+	return 0;
+}
+
+static gint
+tcp_stream_raw_connect (CamelTcpStream *stream,
+                        struct addrinfo *host)
+{
+	CamelTcpStreamRaw *raw = CAMEL_TCP_STREAM_RAW (stream);
+
+	g_return_val_if_fail (host != NULL, -1);
+
+	while (host) {
+		raw->sockfd = socket_connect(host);
+		if (raw->sockfd != -1)
+			return 0;
+
+		host = host->ai_next;
 	}
+
+	return -1;
 }
 
 static gint
-stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
+tcp_stream_raw_getsockopt (CamelTcpStream *stream,
+                           CamelSockOptData *data)
 {
 	gint optname, optlen;
 
@@ -492,7 +415,8 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
 }
 
 static gint
-stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
+tcp_stream_raw_setsockopt (CamelTcpStream *stream,
+                           const CamelSockOptData *data)
 {
 	gint optname;
 
@@ -529,7 +453,8 @@ stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
 }
 
 static struct sockaddr *
-stream_get_local_address (CamelTcpStream *stream, socklen_t *len)
+tcp_stream_raw_get_local_address (CamelTcpStream *stream,
+                                  socklen_t *len)
 {
 #ifdef ENABLE_IPv6
 	struct sockaddr_in6 sin;
@@ -549,7 +474,8 @@ stream_get_local_address (CamelTcpStream *stream, socklen_t *len)
 }
 
 static struct sockaddr *
-stream_get_remote_address (CamelTcpStream *stream, socklen_t *len)
+tcp_stream_raw_get_remote_address (CamelTcpStream *stream,
+                                   socklen_t *len)
 {
 #ifdef ENABLE_IPv6
 	struct sockaddr_in6 sin;
@@ -567,3 +493,63 @@ stream_get_remote_address (CamelTcpStream *stream, socklen_t *len)
 
 	return saddr;
 }
+
+static void
+camel_tcp_stream_raw_class_init (CamelTcpStreamRawClass *class)
+{
+	CamelStreamClass *stream_class;
+	CamelTcpStreamClass *tcp_stream_class;
+
+	parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = tcp_stream_raw_read;
+	stream_class->write = tcp_stream_raw_write;
+	stream_class->flush = tcp_stream_raw_flush;
+	stream_class->close = tcp_stream_raw_close;
+
+	tcp_stream_class = CAMEL_TCP_STREAM_CLASS (class);
+	tcp_stream_class->connect = tcp_stream_raw_connect;
+	tcp_stream_class->getsockopt = tcp_stream_raw_getsockopt;
+	tcp_stream_class->setsockopt = tcp_stream_raw_setsockopt;
+	tcp_stream_class->get_local_address = tcp_stream_raw_get_local_address;
+	tcp_stream_class->get_remote_address = tcp_stream_raw_get_remote_address;
+}
+
+static void
+camel_tcp_stream_raw_init (CamelTcpStreamRaw *stream)
+{
+	stream->sockfd = -1;
+}
+
+CamelType
+camel_tcp_stream_raw_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (camel_tcp_stream_get_type (),
+					    "CamelTcpStreamRaw",
+					    sizeof (CamelTcpStreamRaw),
+					    sizeof (CamelTcpStreamRawClass),
+					    (CamelObjectClassInitFunc) camel_tcp_stream_raw_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_tcp_stream_raw_init,
+					    (CamelObjectFinalizeFunc) tcp_stream_raw_finalize);
+	}
+
+	return type;
+}
+
+/**
+ * camel_tcp_stream_raw_new:
+ *
+ * Create a new #CamelTcpStreamRaw object.
+ *
+ * Returns: a new #CamelTcpStream object
+ **/
+CamelStream *
+camel_tcp_stream_raw_new (void)
+{
+	return CAMEL_STREAM (camel_object_new (camel_tcp_stream_raw_get_type ()));
+}
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index f80f9f9..111408a 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -49,7 +49,6 @@
 #include <certdb.h>
 #include <pk11func.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
 
@@ -71,164 +70,15 @@
 
 static CamelTcpStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelTcpStreamSSL */
-#define CTSS_CLASS(so) CAMEL_TCP_STREAM_SSL_CLASS (CAMEL_OBJECT_GET_CLASS (so))
-
-static gssize stream_read (CamelStream *stream, gchar *buffer, gsize n);
-static gssize stream_write (CamelStream *stream, const gchar *buffer, gsize n);
-static gint stream_flush  (CamelStream *stream);
-static gint stream_close  (CamelStream *stream);
-
-static PRFileDesc *enable_ssl (CamelTcpStreamSSL *ssl, PRFileDesc *fd);
-
-static gint stream_connect    (CamelTcpStream *stream, struct addrinfo *host);
-static gint stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
-static gint stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
-static struct sockaddr *stream_get_local_address (CamelTcpStream *stream, socklen_t *len);
-static struct sockaddr *stream_get_remote_address (CamelTcpStream *stream, socklen_t *len);
-
 struct _CamelTcpStreamSSLPrivate {
 	PRFileDesc *sockfd;
 
-	struct _CamelSession *session;
+	CamelSession *session;
 	gchar *expected_host;
 	gboolean ssl_mode;
 	guint32 flags;
 };
 
-static void
-camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *camel_tcp_stream_ssl_class)
-{
-	CamelTcpStreamClass *camel_tcp_stream_class =
-		CAMEL_TCP_STREAM_CLASS (camel_tcp_stream_ssl_class);
-	CamelStreamClass *camel_stream_class =
-		CAMEL_STREAM_CLASS (camel_tcp_stream_ssl_class);
-
-	parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
-
-	/* virtual method overload */
-	camel_stream_class->read = stream_read;
-	camel_stream_class->write = stream_write;
-	camel_stream_class->flush = stream_flush;
-	camel_stream_class->close = stream_close;
-
-	camel_tcp_stream_class->connect = stream_connect;
-	camel_tcp_stream_class->getsockopt = stream_getsockopt;
-	camel_tcp_stream_class->setsockopt = stream_setsockopt;
-	camel_tcp_stream_class->get_local_address  = stream_get_local_address;
-	camel_tcp_stream_class->get_remote_address = stream_get_remote_address;
-}
-
-static void
-camel_tcp_stream_ssl_init (gpointer object, gpointer klass)
-{
-	CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object);
-
-	stream->priv = g_new0 (struct _CamelTcpStreamSSLPrivate, 1);
-}
-
-static void
-camel_tcp_stream_ssl_finalize (CamelObject *object)
-{
-	CamelTcpStreamSSL *stream = CAMEL_TCP_STREAM_SSL (object);
-
-	if (stream->priv->sockfd != NULL) {
-		PR_Shutdown (stream->priv->sockfd, PR_SHUTDOWN_BOTH);
-		PR_Close (stream->priv->sockfd);
-	}
-
-	if (stream->priv->session)
-		camel_object_unref(stream->priv->session);
-
-	g_free (stream->priv->expected_host);
-
-	g_free (stream->priv);
-}
-
-CamelType
-camel_tcp_stream_ssl_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_tcp_stream_get_type (),
-					    "CamelTcpStreamSSL",
-					    sizeof (CamelTcpStreamSSL),
-					    sizeof (CamelTcpStreamSSLClass),
-					    (CamelObjectClassInitFunc) camel_tcp_stream_ssl_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_tcp_stream_ssl_init,
-					    (CamelObjectFinalizeFunc) camel_tcp_stream_ssl_finalize);
-	}
-
-	return type;
-}
-
-/**
- * camel_tcp_stream_ssl_new:
- * @session: an active #CamelSession object
- * @expected_host: host that the stream is expected to connect with
- * @flags: a bitwise combination of any of
- * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL2,
- * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL3 or
- * #CAMEL_TCP_STREAM_SSL_ENABLE_TLS
- *
- * Since the SSL certificate authenticator may need to prompt the
- * user, a #CamelSession is needed. @expected_host is needed as a
- * protection against an MITM attack.
- *
- * Returns: a new #CamelTcpStreamSSL stream preset in SSL mode
- **/
-CamelStream *
-camel_tcp_stream_ssl_new (CamelSession *session, const gchar *expected_host, guint32 flags)
-{
-	CamelTcpStreamSSL *stream;
-
-	g_assert(CAMEL_IS_SESSION(session));
-
-	stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
-
-	stream->priv->session = session;
-	camel_object_ref(session);
-	stream->priv->expected_host = g_strdup (expected_host);
-	stream->priv->ssl_mode = TRUE;
-	stream->priv->flags = flags;
-
-	return CAMEL_STREAM (stream);
-}
-
-/**
- * camel_tcp_stream_ssl_new_raw:
- * @session: an active #CamelSession object
- * @expected_host: host that the stream is expected to connect with
- * @flags: a bitwise combination of any of
- * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL2,
- * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL3 or
- * #CAMEL_TCP_STREAM_SSL_ENABLE_TLS
- *
- * Since the SSL certificate authenticator may need to prompt the
- * user, a CamelSession is needed. @expected_host is needed as a
- * protection against an MITM attack.
- *
- * Returns: a new #CamelTcpStreamSSL stream not yet toggled into SSL mode
- **/
-CamelStream *
-camel_tcp_stream_ssl_new_raw (CamelSession *session, const gchar *expected_host, guint32 flags)
-{
-	CamelTcpStreamSSL *stream;
-
-	g_assert(CAMEL_IS_SESSION(session));
-
-	stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
-
-	stream->priv->session = session;
-	camel_object_ref(session);
-	stream->priv->expected_host = g_strdup (expected_host);
-	stream->priv->ssl_mode = FALSE;
-	stream->priv->flags = flags;
-
-	return CAMEL_STREAM (stream);
-}
 
 static void
 set_errno (gint code)
@@ -292,47 +142,29 @@ set_errno (gint code)
 	}
 }
 
-/**
- * camel_tcp_stream_ssl_enable_ssl:
- * @ssl: a #CamelTcpStreamSSL object
- *
- * Toggles an ssl-capable stream into ssl mode (if it isn't already).
- *
- * Returns: %0 on success or %-1 on fail
- **/
-gint
-camel_tcp_stream_ssl_enable_ssl (CamelTcpStreamSSL *ssl)
+static void
+tcp_stream_ssl_finalize (CamelTcpStreamSSL *stream)
 {
-	PRFileDesc *fd;
-
-	g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (ssl), -1);
+	CamelTcpStreamSSLPrivate *priv = stream->priv;
 
-	if (ssl->priv->sockfd && !ssl->priv->ssl_mode) {
-		if (!(fd = enable_ssl (ssl, NULL))) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
-
-		ssl->priv->sockfd = fd;
-
-		if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
-
-		if (SSL_ForceHandshake (fd) == SECFailure) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
+	if (priv->sockfd != NULL) {
+		PR_Shutdown (priv->sockfd, PR_SHUTDOWN_BOTH);
+		PR_Close (priv->sockfd);
 	}
 
-	ssl->priv->ssl_mode = TRUE;
+	if (priv->session)
+		camel_object_unref (priv->session);
 
-	return 0;
+	g_free (priv->expected_host);
+
+	g_free (priv);
 }
 
+
 static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n)
+tcp_stream_ssl_read (CamelStream *stream,
+                     gchar *buffer,
+                     gsize n)
 {
 	CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
 	PRFileDesc *cancel_fd;
@@ -415,7 +247,9 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
 }
 
 static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+tcp_stream_ssl_write (CamelStream *stream,
+                      const gchar *buffer,
+                      gsize n)
 {
 	CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
 	gssize w, written = 0;
@@ -510,14 +344,14 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
 }
 
 static gint
-stream_flush (CamelStream *stream)
+tcp_stream_ssl_flush (CamelStream *stream)
 {
 	/*return PR_Sync (((CamelTcpStreamSSL *)stream)->priv->sockfd);*/
 	return 0;
 }
 
 static gint
-stream_close (CamelStream *stream)
+tcp_stream_ssl_close (CamelStream *stream)
 {
 	if (((CamelTcpStreamSSL *)stream)->priv->sockfd == NULL) {
 		errno = EINVAL;
@@ -800,9 +634,12 @@ camel_certdb_nss_cert_set(CamelCertDB *certdb, CamelCert *ccert, CERTCertificate
 	path = g_strdup_printf ("%s/%s", dir, fingerprint);
 	g_free (dir);
 
-	stream = camel_stream_fs_new_with_name (path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+	stream = camel_stream_fs_new_with_name (
+		path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
 	if (stream != NULL) {
-		if (camel_stream_write (stream, (const gchar *) ccert->rawcert->data, ccert->rawcert->len) == -1) {
+		if (camel_stream_write (
+			stream, (const gchar *) ccert->rawcert->data,
+			ccert->rawcert->len) == -1) {
 			g_warning ("Could not save cert: %s: %s", path, g_strerror (errno));
 			g_unlink (path);
 		}
@@ -899,7 +736,7 @@ ssl_bad_cert (gpointer data, PRFileDesc *sockfd)
 	}
 
 	camel_certdb_cert_unref(certdb, ccert);
-	camel_object_unref(certdb);
+	camel_object_unref (certdb);
 
 	return accept ? SECSuccess : SECFailure;
 
@@ -1124,7 +961,8 @@ sockaddr_to_praddr(struct sockaddr *s, gint len, PRNetAddr *addr)
 }
 
 static gint
-socket_connect(CamelTcpStream *stream, struct addrinfo *host)
+tcp_socket_ssl_connect (CamelTcpStream *stream,
+                        struct addrinfo *host)
 {
 	CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream);
 	PRNetAddr netaddr;
@@ -1219,10 +1057,11 @@ socket_connect(CamelTcpStream *stream, struct addrinfo *host)
 }
 
 static gint
-stream_connect(CamelTcpStream *stream, struct addrinfo *host)
+tcp_stream_ssl_connect (CamelTcpStream *stream,
+                        struct addrinfo *host)
 {
 	while (host) {
-		if (socket_connect(stream, host) == 0)
+		if (tcp_socket_ssl_connect (stream, host) == 0)
 			return 0;
 		host = host->ai_next;
 	}
@@ -1231,7 +1070,8 @@ stream_connect(CamelTcpStream *stream, struct addrinfo *host)
 }
 
 static gint
-stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
+tcp_stream_ssl_getsockopt (CamelTcpStream *stream,
+                           CamelSockOptData *data)
 {
 	PRSocketOptionData sodata;
 
@@ -1247,7 +1087,8 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
 }
 
 static gint
-stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
+tcp_stream_ssl_setsockopt (CamelTcpStream *stream,
+                           const CamelSockOptData *data)
 {
 	PRSocketOptionData sodata;
 
@@ -1294,7 +1135,8 @@ sockaddr_from_praddr(PRNetAddr *addr, socklen_t *len)
 }
 
 static struct sockaddr *
-stream_get_local_address(CamelTcpStream *stream, socklen_t *len)
+tcp_stream_ssl_get_local_address (CamelTcpStream *stream,
+                                  socklen_t *len)
 {
 	PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
 	PRNetAddr addr;
@@ -1306,7 +1148,8 @@ stream_get_local_address(CamelTcpStream *stream, socklen_t *len)
 }
 
 static struct sockaddr *
-stream_get_remote_address (CamelTcpStream *stream, socklen_t *len)
+tcp_stream_ssl_get_remote_address (CamelTcpStream *stream,
+                                   socklen_t *len)
 {
 	PRFileDesc *sockfd = CAMEL_TCP_STREAM_SSL (stream)->priv->sockfd;
 	PRNetAddr addr;
@@ -1331,4 +1174,156 @@ camel_tcp_stream_ssl_sockfd (CamelTcpStreamSSL *stream)
 	return stream->priv->sockfd;
 }
 
+static void
+camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *class)
+{
+	CamelStreamClass *stream_class;
+	CamelTcpStreamClass *tcp_stream_class;
+
+	parent_class = CAMEL_TCP_STREAM_CLASS (camel_type_get_global_classfuncs (camel_tcp_stream_get_type ()));
+
+	stream_class = CAMEL_STREAM_CLASS (class);
+	stream_class->read = tcp_stream_ssl_read;
+	stream_class->write = tcp_stream_ssl_write;
+	stream_class->flush = tcp_stream_ssl_flush;
+	stream_class->close = tcp_stream_ssl_close;
+
+	tcp_stream_class = CAMEL_TCP_STREAM_CLASS (class);
+	tcp_stream_class->connect = tcp_stream_ssl_connect;
+	tcp_stream_class->getsockopt = tcp_stream_ssl_getsockopt;
+	tcp_stream_class->setsockopt = tcp_stream_ssl_setsockopt;
+	tcp_stream_class->get_local_address  = tcp_stream_ssl_get_local_address;
+	tcp_stream_class->get_remote_address = tcp_stream_ssl_get_remote_address;
+}
+
+static void
+camel_tcp_stream_ssl_init (CamelTcpStreamSSL *stream)
+{
+	stream->priv = g_new0 (CamelTcpStreamSSLPrivate, 1);
+}
+
+CamelType
+camel_tcp_stream_ssl_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (camel_tcp_stream_get_type (),
+					    "CamelTcpStreamSSL",
+					    sizeof (CamelTcpStreamSSL),
+					    sizeof (CamelTcpStreamSSLClass),
+					    (CamelObjectClassInitFunc) camel_tcp_stream_ssl_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_tcp_stream_ssl_init,
+					    (CamelObjectFinalizeFunc) tcp_stream_ssl_finalize);
+	}
+
+	return type;
+}
+
+/**
+ * camel_tcp_stream_ssl_new:
+ * @session: an active #CamelSession object
+ * @expected_host: host that the stream is expected to connect with
+ * @flags: a bitwise combination of any of
+ * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL2,
+ * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL3 or
+ * #CAMEL_TCP_STREAM_SSL_ENABLE_TLS
+ *
+ * Since the SSL certificate authenticator may need to prompt the
+ * user, a #CamelSession is needed. @expected_host is needed as a
+ * protection against an MITM attack.
+ *
+ * Returns: a new #CamelTcpStreamSSL stream preset in SSL mode
+ **/
+CamelStream *
+camel_tcp_stream_ssl_new (CamelSession *session, const gchar *expected_host, guint32 flags)
+{
+	CamelTcpStreamSSL *stream;
+
+	g_assert(CAMEL_IS_SESSION(session));
+
+	stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
+
+	stream->priv->session = session;
+	camel_object_ref (session);
+	stream->priv->expected_host = g_strdup (expected_host);
+	stream->priv->ssl_mode = TRUE;
+	stream->priv->flags = flags;
+
+	return CAMEL_STREAM (stream);
+}
+
+/**
+ * camel_tcp_stream_ssl_new_raw:
+ * @session: an active #CamelSession object
+ * @expected_host: host that the stream is expected to connect with
+ * @flags: a bitwise combination of any of
+ * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL2,
+ * #CAMEL_TCP_STREAM_SSL_ENABLE_SSL3 or
+ * #CAMEL_TCP_STREAM_SSL_ENABLE_TLS
+ *
+ * Since the SSL certificate authenticator may need to prompt the
+ * user, a CamelSession is needed. @expected_host is needed as a
+ * protection against an MITM attack.
+ *
+ * Returns: a new #CamelTcpStreamSSL stream not yet toggled into SSL mode
+ **/
+CamelStream *
+camel_tcp_stream_ssl_new_raw (CamelSession *session, const gchar *expected_host, guint32 flags)
+{
+	CamelTcpStreamSSL *stream;
+
+	g_assert(CAMEL_IS_SESSION(session));
+
+	stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
+
+	stream->priv->session = session;
+	camel_object_ref (session);
+	stream->priv->expected_host = g_strdup (expected_host);
+	stream->priv->ssl_mode = FALSE;
+	stream->priv->flags = flags;
+
+	return CAMEL_STREAM (stream);
+}
+
+/**
+ * camel_tcp_stream_ssl_enable_ssl:
+ * @ssl: a #CamelTcpStreamSSL object
+ *
+ * Toggles an ssl-capable stream into ssl mode (if it isn't already).
+ *
+ * Returns: %0 on success or %-1 on fail
+ **/
+gint
+camel_tcp_stream_ssl_enable_ssl (CamelTcpStreamSSL *ssl)
+{
+	PRFileDesc *fd;
+
+	g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (ssl), -1);
+
+	if (ssl->priv->sockfd && !ssl->priv->ssl_mode) {
+		if (!(fd = enable_ssl (ssl, NULL))) {
+			set_errno (PR_GetError ());
+			return -1;
+		}
+
+		ssl->priv->sockfd = fd;
+
+		if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
+			set_errno (PR_GetError ());
+			return -1;
+		}
+
+		if (SSL_ForceHandshake (fd) == SECFailure) {
+			set_errno (PR_GetError ());
+			return -1;
+		}
+	}
+
+	ssl->priv->ssl_mode = TRUE;
+
+	return 0;
+}
+
 #endif /* HAVE_NSS */
diff --git a/camel/camel-tcp-stream.c b/camel/camel-tcp-stream.c
index 1575af6..39aa6e3 100644
--- a/camel/camel-tcp-stream.c
+++ b/camel/camel-tcp-stream.c
@@ -37,34 +37,15 @@
 
 static CamelStreamClass *parent_class = NULL;
 
-/* Returns the class for a CamelTcpStream */
-#define CTS_CLASS(so) CAMEL_TCP_STREAM_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-static gint tcp_connect    (CamelTcpStream *stream, struct addrinfo *host);
-static gint tcp_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
-static gint tcp_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
-static struct sockaddr *tcp_get_local_address (CamelTcpStream *stream, socklen_t *len);
-static struct sockaddr *tcp_get_remote_address (CamelTcpStream *stream, socklen_t *len);
-
 static void
-camel_tcp_stream_class_init (CamelTcpStreamClass *camel_tcp_stream_class)
+camel_tcp_stream_class_init (CamelTcpStreamClass *class)
 {
-	/*CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_tcp_stream_class);*/
-
 	parent_class = CAMEL_STREAM_CLASS (camel_type_get_global_classfuncs (CAMEL_STREAM_TYPE));
-
-	/* tcp stream methods */
-	camel_tcp_stream_class->connect            = tcp_connect;
-	camel_tcp_stream_class->getsockopt         = tcp_getsockopt;
-	camel_tcp_stream_class->setsockopt         = tcp_setsockopt;
-	camel_tcp_stream_class->get_local_address  = tcp_get_local_address;
-	camel_tcp_stream_class->get_remote_address = tcp_get_remote_address;
 }
 
 static void
-camel_tcp_stream_init (gpointer o)
+camel_tcp_stream_init (CamelTcpStream *tcp_stream)
 {
-	;
 }
 
 CamelType
@@ -86,13 +67,6 @@ camel_tcp_stream_get_type (void)
 	return type;
 }
 
-static gint
-tcp_connect (CamelTcpStream *stream, struct addrinfo *host)
-{
-	w(g_warning ("CamelTcpStream::connect called on default implementation"));
-	return -1;
-}
-
 /**
  * camel_tcp_stream_connect:
  * @stream: a #CamelTcpStream object
@@ -104,18 +78,17 @@ tcp_connect (CamelTcpStream *stream, struct addrinfo *host)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_tcp_stream_connect (CamelTcpStream *stream, struct addrinfo *host)
+camel_tcp_stream_connect (CamelTcpStream *stream,
+                          struct addrinfo *host)
 {
+	CamelTcpStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
 
-	return CTS_CLASS (stream)->connect (stream, host);
-}
+	class = CAMEL_TCP_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->connect != NULL, -1);
 
-static gint
-tcp_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
-{
-	w(g_warning ("CamelTcpStream::getsockopt called on default implementation"));
-	return -1;
+	return class->connect (stream, host);
 }
 
 /**
@@ -128,18 +101,17 @@ tcp_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_tcp_stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
+camel_tcp_stream_getsockopt (CamelTcpStream *stream,
+                             CamelSockOptData *data)
 {
+	CamelTcpStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
 
-	return CTS_CLASS (stream)->getsockopt (stream, data);
-}
+	class = CAMEL_TCP_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->getsockopt != NULL, -1);
 
-static gint
-tcp_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
-{
-	w(g_warning ("CamelTcpStream::setsockopt called on default implementation"));
-	return -1;
+	return class->getsockopt (stream, data);
 }
 
 /**
@@ -152,18 +124,17 @@ tcp_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_tcp_stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
+camel_tcp_stream_setsockopt (CamelTcpStream *stream,
+                             const CamelSockOptData *data)
 {
+	CamelTcpStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
 
-	return CTS_CLASS (stream)->setsockopt (stream, data);
-}
+	class = CAMEL_TCP_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->setsockopt != NULL, -1);
 
-static struct sockaddr *
-tcp_get_local_address (CamelTcpStream *stream, socklen_t *len)
-{
-	w(g_warning ("CamelTcpStream::get_local_address called on default implementation"));
-	return NULL;
+	return class->setsockopt (stream, data);
 }
 
 /**
@@ -179,19 +150,18 @@ tcp_get_local_address (CamelTcpStream *stream, socklen_t *len)
  * Since: 2.22
  **/
 struct sockaddr *
-camel_tcp_stream_get_local_address (CamelTcpStream *stream, socklen_t *len)
+camel_tcp_stream_get_local_address (CamelTcpStream *stream,
+                                    socklen_t *len)
 {
+	CamelTcpStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), NULL);
-	g_return_val_if_fail(len != NULL, NULL);
+	g_return_val_if_fail (len != NULL, NULL);
 
-	return CTS_CLASS (stream)->get_local_address (stream, len);
-}
+	class = CAMEL_TCP_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->get_local_address != NULL, NULL);
 
-static struct sockaddr *
-tcp_get_remote_address (CamelTcpStream *stream, socklen_t *len)
-{
-	w(g_warning ("CamelTcpStream::get_remote_address called on default implementation"));
-	return NULL;
+	return class->get_local_address (stream, len);
 }
 
 /**
@@ -207,10 +177,16 @@ tcp_get_remote_address (CamelTcpStream *stream, socklen_t *len)
  * Since: 2.22
  **/
 struct sockaddr *
-camel_tcp_stream_get_remote_address (CamelTcpStream *stream, socklen_t *len)
+camel_tcp_stream_get_remote_address (CamelTcpStream *stream,
+                                     socklen_t *len)
 {
+	CamelTcpStreamClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), NULL);
-	g_return_val_if_fail(len != NULL, NULL);
+	g_return_val_if_fail (len != NULL, NULL);
+
+	class = CAMEL_TCP_STREAM_GET_CLASS (stream);
+	g_return_val_if_fail (class->get_remote_address != NULL, NULL);
 
-	return CTS_CLASS (stream)->get_remote_address (stream, len);
+	return class->get_remote_address (stream, len);
 }
diff --git a/camel/camel-tcp-stream.h b/camel/camel-tcp-stream.h
index f5468ab..fd43165 100644
--- a/camel/camel-tcp-stream.h
+++ b/camel/camel-tcp-stream.h
@@ -27,8 +27,6 @@
 #ifndef CAMEL_TCP_STREAM_H
 #define CAMEL_TCP_STREAM_H
 
-#include <camel/camel-stream.h>
-
 #ifndef G_OS_WIN32
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -46,10 +44,14 @@ struct addrinfo;
 #endif
 #include <unistd.h>
 
+#include <camel/camel-stream.h>
+
 #define CAMEL_TCP_STREAM_TYPE     (camel_tcp_stream_get_type ())
 #define CAMEL_TCP_STREAM(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_TCP_STREAM_TYPE, CamelTcpStream))
 #define CAMEL_TCP_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TCP_STREAM_TYPE, CamelTcpStreamClass))
 #define CAMEL_IS_TCP_STREAM(o)    (CAMEL_CHECK_TYPE((o), CAMEL_TCP_STREAM_TYPE))
+#define CAMEL_TCP_STREAM_GET_CLASS(obj) \
+	((CamelTcpStreamClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
@@ -79,7 +81,6 @@ typedef enum {
 	CAMEL_SOCKOPT_LAST
 } CamelSockOpt;
 
-
 typedef struct _CamelSockOptData {
 	CamelSockOpt option;
 	union {
diff --git a/camel/providers/groupwise/camel-groupwise-utils.c b/camel/providers/groupwise/camel-groupwise-utils.c
index e1100e0..4209bfd 100644
--- a/camel/providers/groupwise/camel-groupwise-utils.c
+++ b/camel/providers/groupwise/camel-groupwise-utils.c
@@ -283,6 +283,7 @@ send_as_attachment (EGwConnection *cnc, EGwItem *item, CamelStreamMem *content,
 	EGwConnectionStatus status;
 	EGwItemAttachment *attachment;
 	EGwItem *temp_item;
+	GByteArray *byte_array;
 
 	attachment = g_new0 (EGwItemAttachment, 1);
 	attachment->contentType = camel_content_type_simple (type);
@@ -290,27 +291,29 @@ send_as_attachment (EGwConnection *cnc, EGwItem *item, CamelStreamMem *content,
 	if (cid)
 		attachment->contentid = camel_header_contentid_decode (cid);
 
-	if (filename && content->buffer->data) {
+	byte_array = camel_stream_mem_get_byte_array (content);
+
+	if (filename && byte_array->data) {
 		if (camel_content_type_is (type, "application", "pgp-signature")) {
 			gchar *temp_str;
 			gint temp_len;
-			temp_str = g_base64_encode (content->buffer->data, content->buffer->len);
+			temp_str = g_base64_encode (byte_array->data, byte_array->len);
 			temp_len = strlen (temp_str);
 			attachment->data = g_strdup (temp_str);
 			attachment->size = temp_len;
 			g_free (temp_str);
 			temp_str = NULL;
 		} else {
-			attachment->data = g_base64_encode(content->buffer->data, content->buffer->len);
+			attachment->data = g_base64_encode(byte_array->data, byte_array->len);
 			attachment->size = strlen (attachment->data);
 		}
-	} else if (content->buffer->data) {
+	} else if (byte_array->data) {
 		gchar *temp_str;
 		gint temp_len;
 		if (!strcmp (attachment->contentType, "multipart/digest")) {
 			/* FIXME? */
 		} else {
-			temp_str = g_base64_encode (content->buffer->data, content->buffer->len);
+			temp_str = g_base64_encode (byte_array->data, byte_array->len);
 			temp_len = strlen (temp_str);
 			attachment->data = g_strdup (temp_str);
 			attachment->size = temp_len;
@@ -413,6 +416,7 @@ camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *me
 		CamelStreamMem *content = (CamelStreamMem *)camel_stream_mem_new ();
 		CamelDataWrapper *dw = NULL;
 		CamelContentType *type;
+		GByteArray *byte_array;
 
 		dw = camel_medium_get_content (CAMEL_MEDIUM (message));
 		type = camel_mime_part_get_content_type((CamelMimePart *)message);
@@ -444,7 +448,8 @@ camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *me
 			camel_object_unref (filtered_stream);
 
 			camel_stream_write ((CamelStream *) content, "", 1);
-			e_gw_item_set_message (item, (const gchar *)content->buffer->data);
+			byte_array = camel_stream_mem_get_byte_array (content);
+			e_gw_item_set_message (item, (const gchar *)byte_array->data);
 		} else {
 			camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content);
 			send_as_attachment (cnc, item, content, type, dw, NULL, NULL, &attach_list);
@@ -602,9 +607,11 @@ do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **at
 		CamelMimePart *part;
 		CamelStreamMem *content = (CamelStreamMem *)camel_stream_mem_new ();
 		CamelDataWrapper *dw = NULL;
+		GByteArray *byte_array;
 		const gchar *disposition, *filename;
 		const gchar *content_id = NULL;
 		gboolean is_alternative = FALSE;
+
 		/*
 		 * XXX:
 		 * Assuming the first part always is the actual message
@@ -671,7 +678,8 @@ do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **at
 			camel_object_unref (filtered_stream);
 
 			camel_stream_write ((CamelStream *) content, "", 1);
-			e_gw_item_set_message (item, (const gchar *)content->buffer->data);
+			byte_array = camel_stream_mem_get_byte_array (content);
+			e_gw_item_set_message (item, (const gchar *) byte_array->data);
 		} else {
 			filename = camel_mime_part_get_filename (part);
 			disposition = camel_mime_part_get_disposition (part);
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 07a5727..25ef124 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -403,6 +403,7 @@ imapx_command_add_part(CamelIMAPXCommand *ic, camel_imapx_command_part_t type, g
 {
 	CamelIMAPXCommandPart *cp;
 	CamelStreamNull *null;
+	GByteArray *byte_array;
 	guint ob_size = 0;
 
 	/* TODO: literal+? */
@@ -462,18 +463,20 @@ imapx_command_add_part(CamelIMAPXCommand *ic, camel_imapx_command_part_t type, g
 		ob_size = 0;
 	}
 
+	byte_array = camel_stream_mem_get_byte_array (ic->mem);
+
 	cp = g_malloc0(sizeof(*cp));
 	cp->type = type;
 	cp->ob_size = ob_size;
 	cp->ob = o;
-	cp->data_size = ic->mem->buffer->len;
+	cp->data_size = byte_array->len;
 	cp->data = g_malloc(cp->data_size+1);
-	memcpy(cp->data, ic->mem->buffer->data, cp->data_size);
+	memcpy(cp->data, byte_array->data, cp->data_size);
 	cp->data[cp->data_size] = 0;
 
 	camel_stream_reset((CamelStream *)ic->mem);
 	/* FIXME: hackish? */
-	g_byte_array_set_size(ic->mem->buffer, 0);
+	g_byte_array_set_size(byte_array, 0);
 
 	camel_dlist_addtail(&ic->parts, (CamelDListNode *)cp);
 }
@@ -733,8 +736,12 @@ void
 camel_imapx_command_close(CamelIMAPXCommand *ic)
 {
 	if (ic->mem) {
-		c(printf("completing command buffer is [%d] '%.*s'\n", ic->mem->buffer->len, (gint)ic->mem->buffer->len, ic->mem->buffer->data));
-		if (ic->mem->buffer->len > 0)
+		GByteArray *byte_array;
+
+		byte_array = camel_stream_mem_get_byte_array (ic->mem);
+
+		c(printf("completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data));
+		if (byte_array->len > 0)
 			imapx_command_add_part(ic, CAMEL_IMAPX_COMMAND_SIMPLE, NULL);
 
 		camel_object_unref((CamelObject *)ic->mem);
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index a5e6fe9..eb54cbe 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -289,9 +289,13 @@ fail_write:
 				      lf->folder_path, g_strerror (errno));
 
 	if (output_stream) {
+		gint fd;
+
+		fd = camel_stream_fs_get_fd (CAMEL_STREAM_FS (output_stream));
+
 		/* reset the file to original size */
 		do {
-			retval = ftruncate (((CamelStreamFs *) output_stream)->fd, mbs->folder_size);
+			retval = ftruncate (fd, mbs->folder_size);
 		} while (retval == -1 && errno == EINTR);
 
 		camel_object_unref (output_stream);
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 69a4ab0..c4ef4e6 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -1229,6 +1229,7 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex)
 gint
 camel_nntp_raw_commandv (CamelNNTPStore *store, CamelException *ex, gchar **line, const gchar *fmt, va_list ap)
 {
+	GByteArray *byte_array;
 	const guchar *p, *ps;
 	guchar c;
 	gchar *s;
@@ -1280,16 +1281,17 @@ camel_nntp_raw_commandv (CamelNNTPStore *store, CamelException *ex, gchar **line
 		}
 	}
 
+	byte_array = camel_stream_mem_get_byte_array (store->mem);
 	camel_stream_write ((CamelStream *) store->mem, (const gchar *) ps, p-ps-1);
-	dd(printf("NNTP_COMMAND: '%.*s'\n", (gint)store->mem->buffer->len, store->mem->buffer->data));
+	dd(printf("NNTP_COMMAND: '%.*s'\n", (gint)byte_array->len, byte_array->data));
 	camel_stream_write ((CamelStream *) store->mem, "\r\n", 2);
 
-	if (camel_stream_write((CamelStream *) store->stream, (const gchar *) store->mem->buffer->data, store->mem->buffer->len) == -1)
+	if (camel_stream_write((CamelStream *) store->stream, (const gchar *) byte_array->data, byte_array->len) == -1)
 		goto ioerror;
 
 	/* FIXME: hack */
 	camel_stream_reset ((CamelStream *) store->mem);
-	g_byte_array_set_size (store->mem->buffer, 0);
+	g_byte_array_set_size (byte_array, 0);
 
 	if (camel_nntp_stream_line (store->stream, (guchar **) line, &u) == -1)
 		goto ioerror;
diff --git a/docs/reference/camel/tmpl/camel-address.sgml b/docs/reference/camel/tmpl/camel-address.sgml
index 677b3cd..be2f32a 100644
--- a/docs/reference/camel/tmpl/camel-address.sgml
+++ b/docs/reference/camel/tmpl/camel-address.sgml
@@ -22,6 +22,9 @@ CamelAddress
 
 </para>
 
+ parent: 
+ addresses: 
+ priv: 
 
 <!-- ##### FUNCTION camel_address_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-block-file.sgml b/docs/reference/camel/tmpl/camel-block-file.sgml
index cf08d27..454f9d4 100644
--- a/docs/reference/camel/tmpl/camel-block-file.sgml
+++ b/docs/reference/camel/tmpl/camel-block-file.sgml
@@ -58,6 +58,19 @@ CamelKeyFile
 
 </para>
 
+ parent: 
+ priv: 
+ version: 
+ path: 
+ flags: 
+ fd: 
+ block_size: 
+ root: 
+ root_block: 
+ block_cache_limit: 
+ block_cache_count: 
+ block_cache: 
+ blocks: 
 
 <!-- ##### MACRO CAMEL_BLOCK_FILE_SYNC ##### -->
 <para>
@@ -214,6 +227,12 @@ CamelKeyFile
 
 </para>
 
+ parent: 
+ priv: 
+ fp: 
+ path: 
+ flags: 
+ last: 
 
 <!-- ##### FUNCTION camel_key_file_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-certdb.sgml b/docs/reference/camel/tmpl/camel-certdb.sgml
index 810718e..85522c8 100644
--- a/docs/reference/camel/tmpl/camel-certdb.sgml
+++ b/docs/reference/camel/tmpl/camel-certdb.sgml
@@ -22,6 +22,16 @@ CamelCertDB
 
 </para>
 
+ parent: 
+ priv: 
+ filename: 
+ version: 
+ saved_certs: 
+ flags: 
+ cert_size: 
+ cert_chunks: 
+ certs: 
+ cert_hash: 
 
 <!-- ##### ENUM CamelCertTrust ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-cipher-context.sgml b/docs/reference/camel/tmpl/camel-cipher-context.sgml
index 44a677c..14db85e 100644
--- a/docs/reference/camel/tmpl/camel-cipher-context.sgml
+++ b/docs/reference/camel/tmpl/camel-cipher-context.sgml
@@ -22,11 +22,8 @@ CamelCipherContext
 
 </para>
 
-
-<!-- ##### ARG CamelCipherContext:session ##### -->
-<para>
-
-</para>
+ parent: 
+ priv: 
 
 <!-- ##### STRUCT CamelCipherValidity ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-data-cache.sgml b/docs/reference/camel/tmpl/camel-data-cache.sgml
index dc727f5..5f14ce7 100644
--- a/docs/reference/camel/tmpl/camel-data-cache.sgml
+++ b/docs/reference/camel/tmpl/camel-data-cache.sgml
@@ -22,11 +22,8 @@ CamelDataCache
 
 </para>
 
-
-<!-- ##### ARG CamelDataCache:path ##### -->
-<para>
-
-</para>
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_data_cache_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-data-wrapper.sgml b/docs/reference/camel/tmpl/camel-data-wrapper.sgml
index 11144cc..ffcde75 100644
--- a/docs/reference/camel/tmpl/camel-data-wrapper.sgml
+++ b/docs/reference/camel/tmpl/camel-data-wrapper.sgml
@@ -22,6 +22,12 @@ CamelDataWrapper
 
 </para>
 
+ parent: 
+ priv: 
+ encoding: 
+ mime_type: 
+ stream: 
+ offline: 
 
 <!-- ##### FUNCTION camel_data_wrapper_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-disco-diary.sgml b/docs/reference/camel/tmpl/camel-disco-diary.sgml
index 2114195..9dbc6ae 100644
--- a/docs/reference/camel/tmpl/camel-disco-diary.sgml
+++ b/docs/reference/camel/tmpl/camel-disco-diary.sgml
@@ -22,6 +22,11 @@ CamelDiscoDiary
 
 </para>
 
+ parent: 
+ store: 
+ file: 
+ folders: 
+ uidmap: 
 
 <!-- ##### ENUM CamelDiscoDiaryAction ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-disco-folder.sgml b/docs/reference/camel/tmpl/camel-disco-folder.sgml
index 1635928..88fb38f 100644
--- a/docs/reference/camel/tmpl/camel-disco-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-disco-folder.sgml
@@ -22,6 +22,8 @@ CamelDiscoFolder
 
 </para>
 
+ parent: 
+ offline_sync: 
 
 <!-- ##### FUNCTION camel_disco_folder_expunge_uids ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-disco-store.sgml b/docs/reference/camel/tmpl/camel-disco-store.sgml
index ea7c191..7bfafd2 100644
--- a/docs/reference/camel/tmpl/camel-disco-store.sgml
+++ b/docs/reference/camel/tmpl/camel-disco-store.sgml
@@ -22,6 +22,9 @@ CamelDiscoStore
 
 </para>
 
+ parent: 
+ status: 
+ diary: 
 
 <!-- ##### ENUM CamelDiscoStoreStatus ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-filter-driver.sgml b/docs/reference/camel/tmpl/camel-filter-driver.sgml
index 7ab976c..b46e6f2 100644
--- a/docs/reference/camel/tmpl/camel-filter-driver.sgml
+++ b/docs/reference/camel/tmpl/camel-filter-driver.sgml
@@ -22,6 +22,8 @@ CamelFilterDriver
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### USER_FUNCTION CamelFilterGetFolderFunc ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-folder-search.sgml b/docs/reference/camel/tmpl/camel-folder-search.sgml
index 8ba597c..b3ea24a 100644
--- a/docs/reference/camel/tmpl/camel-folder-search.sgml
+++ b/docs/reference/camel/tmpl/camel-folder-search.sgml
@@ -22,6 +22,16 @@ CamelFolderSearch
 
 </para>
 
+ parent: 
+ priv: 
+ sexp: 
+ last_search: 
+ folder: 
+ summary: 
+ summary_set: 
+ current: 
+ current_message: 
+ body_index: 
 
 <!-- ##### FUNCTION camel_folder_search_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-folder-summary.sgml b/docs/reference/camel/tmpl/camel-folder-summary.sgml
index 832c45f..1269637 100644
--- a/docs/reference/camel/tmpl/camel-folder-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-folder-summary.sgml
@@ -22,6 +22,33 @@ CamelFolderSummary
 
 </para>
 
+ parent: 
+ priv: 
+ version: 
+ flags: 
+ nextuid: 
+ time: 
+ saved_count: 
+ unread_count: 
+ deleted_count: 
+ junk_count: 
+ junk_not_deleted_count: 
+ visible_count: 
+ message_info_size: 
+ content_info_size: 
+ message_info_chunks: 
+ content_info_chunks: 
+ summary_path: 
+ build_content: 
+ uids: 
+ loaded_infos: 
+ folder: 
+ meta_summary: 
+ cache_load_time: 
+ timeout_handle: 
+ collate: 
+ sort_by: 
+ later: 
 
 <!-- ##### STRUCT CamelMessageInfo ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-folder.sgml b/docs/reference/camel/tmpl/camel-folder.sgml
index e47dea6..e315a40 100644
--- a/docs/reference/camel/tmpl/camel-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-folder.sgml
@@ -22,6 +22,16 @@ CamelFolder
 
 </para>
 
+ parent: 
+ priv: 
+ name: 
+ full_name: 
+ description: 
+ parent_store: 
+ summary: 
+ folder_flags: 
+ permanent_flags: 
+ later: 
 
 <!-- ##### STRUCT CamelFolderChangeInfo ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-gpg-context.sgml b/docs/reference/camel/tmpl/camel-gpg-context.sgml
index 935a50a..2282337 100644
--- a/docs/reference/camel/tmpl/camel-gpg-context.sgml
+++ b/docs/reference/camel/tmpl/camel-gpg-context.sgml
@@ -22,11 +22,8 @@ CamelGpgContext
 
 </para>
 
-
-<!-- ##### ARG CamelGpgContext:always-trust ##### -->
-<para>
-
-</para>
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_gpg_context_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-html-parser.sgml b/docs/reference/camel/tmpl/camel-html-parser.sgml
index 191b15b..8cc957f 100644
--- a/docs/reference/camel/tmpl/camel-html-parser.sgml
+++ b/docs/reference/camel/tmpl/camel-html-parser.sgml
@@ -22,6 +22,8 @@ CamelHTMLParser
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM camel_html_parser_t ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-http-stream.sgml b/docs/reference/camel/tmpl/camel-http-stream.sgml
index 2885970..c5749a2 100644
--- a/docs/reference/camel/tmpl/camel-http-stream.sgml
+++ b/docs/reference/camel/tmpl/camel-http-stream.sgml
@@ -22,6 +22,20 @@ CamelHttpStream
 
 </para>
 
+ parent: 
+ parser: 
+ content_type: 
+ headers: 
+ method: 
+ session: 
+ url: 
+ user_agent: 
+ proxy: 
+ authrealm: 
+ authpass: 
+ statuscode: 
+ raw: 
+ read: 
 
 <!-- ##### ENUM CamelHttpMethod ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-index.sgml b/docs/reference/camel/tmpl/camel-index.sgml
index 8585986..c2b3646 100644
--- a/docs/reference/camel/tmpl/camel-index.sgml
+++ b/docs/reference/camel/tmpl/camel-index.sgml
@@ -22,6 +22,14 @@ CamelIndex
 
 </para>
 
+ parent: 
+ priv: 
+ path: 
+ version: 
+ flags: 
+ state: 
+ normalize: 
+ normalize_data: 
 
 <!-- ##### USER_FUNCTION CamelIndexNorm ##### -->
 <para>
@@ -39,6 +47,9 @@ CamelIndex
 
 </para>
 
+ parent: 
+ priv: 
+ index: 
 
 <!-- ##### FUNCTION camel_index_cursor_new ##### -->
 <para>
@@ -72,6 +83,12 @@ CamelIndex
 
 </para>
 
+ parent: 
+ priv: 
+ index: 
+ name: 
+ buffer: 
+ words: 
 
 <!-- ##### FUNCTION camel_index_name_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-internet-address.sgml b/docs/reference/camel/tmpl/camel-internet-address.sgml
index a8fade6..b1d03e4 100644
--- a/docs/reference/camel/tmpl/camel-internet-address.sgml
+++ b/docs/reference/camel/tmpl/camel-internet-address.sgml
@@ -22,6 +22,8 @@ CamelInternetAddress
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_internet_address_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-medium.sgml b/docs/reference/camel/tmpl/camel-medium.sgml
index af15f39..c6a1ad8 100644
--- a/docs/reference/camel/tmpl/camel-medium.sgml
+++ b/docs/reference/camel/tmpl/camel-medium.sgml
@@ -22,11 +22,8 @@ CamelMedium
 
 </para>
 
-
-<!-- ##### ARG CamelMedium:content ##### -->
-<para>
-
-</para>
+ parent: 
+ content: 
 
 <!-- ##### STRUCT CamelMediumHeader ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-basic.sgml b/docs/reference/camel/tmpl/camel-mime-filter-basic.sgml
index 22e855b..617d77f 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-basic.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-basic.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterBasic
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM CamelMimeFilterBasicType ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-bestenc.sgml b/docs/reference/camel/tmpl/camel-mime-filter-bestenc.sgml
index 505dfda..a3a4974 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-bestenc.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-bestenc.sgml
@@ -42,6 +42,8 @@ CamelMimeFilterBestenc
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_bestenc_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-canon.sgml b/docs/reference/camel/tmpl/camel-mime-filter-canon.sgml
index 336eee0..23dff68 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-canon.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-canon.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterCanon
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_canon_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-charset.sgml b/docs/reference/camel/tmpl/camel-mime-filter-charset.sgml
index 9806a55..b7dd16e 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-charset.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-charset.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterCharset
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_charset_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-crlf.sgml b/docs/reference/camel/tmpl/camel-mime-filter-crlf.sgml
index 936b52c..d946a00 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-crlf.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-crlf.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterCRLF
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM CamelMimeFilterCRLFDirection ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-enriched.sgml b/docs/reference/camel/tmpl/camel-mime-filter-enriched.sgml
index a69b360..d26326b 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-enriched.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-enriched.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterEnriched
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### MACRO CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-from.sgml b/docs/reference/camel/tmpl/camel-mime-filter-from.sgml
index cb78e93..8502442 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-from.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-from.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterFrom
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_from_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-gzip.sgml b/docs/reference/camel/tmpl/camel-mime-filter-gzip.sgml
index b0f2fbf..98f6aac 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-gzip.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-gzip.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterGZip
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM CamelMimeFilterGZipMode ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-html.sgml b/docs/reference/camel/tmpl/camel-mime-filter-html.sgml
index 3b13488..f4ce6d9 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-html.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-html.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterHTML
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_html_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-index.sgml b/docs/reference/camel/tmpl/camel-mime-filter-index.sgml
index 8e0d706..85aa557 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-index.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-index.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterIndex
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_index_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-linewrap.sgml b/docs/reference/camel/tmpl/camel-mime-filter-linewrap.sgml
index b59e3cc..d38d24d 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-linewrap.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-linewrap.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterLinewrap
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_linewrap_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-pgp.sgml b/docs/reference/camel/tmpl/camel-mime-filter-pgp.sgml
index ecba711..32fa671 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-pgp.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-pgp.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterPgp
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_pgp_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-progress.sgml b/docs/reference/camel/tmpl/camel-mime-filter-progress.sgml
index ba16e3f..4fd0fc7 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-progress.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-progress.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterProgress
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_progress_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-save.sgml b/docs/reference/camel/tmpl/camel-mime-filter-save.sgml
index 3ae7be0..bd8e171 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-save.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-save.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterSave
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_save_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-tohtml.sgml b/docs/reference/camel/tmpl/camel-mime-filter-tohtml.sgml
index 045a916..7e34b92 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-tohtml.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-tohtml.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterToHTML
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### MACRO CAMEL_MIME_FILTER_TOHTML_PRE ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-windows.sgml b/docs/reference/camel/tmpl/camel-mime-filter-windows.sgml
index a82467f..273381e 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-windows.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-windows.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterWindows
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_mime_filter_windows_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter-yenc.sgml b/docs/reference/camel/tmpl/camel-mime-filter-yenc.sgml
index b532a44..0b4590f 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter-yenc.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter-yenc.sgml
@@ -22,6 +22,8 @@ CamelMimeFilterYenc
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM CamelMimeFilterYencDirection ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-filter.sgml b/docs/reference/camel/tmpl/camel-mime-filter.sgml
index f96d7d6..13572c9 100644
--- a/docs/reference/camel/tmpl/camel-mime-filter.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-filter.sgml
@@ -22,6 +22,16 @@ CamelMimeFilter
 
 </para>
 
+ parent: 
+ priv: 
+ outreal: 
+ outbuf: 
+ outptr: 
+ outsize: 
+ outpre: 
+ backbuf: 
+ backsize: 
+ backlen: 
 
 <!-- ##### FUNCTION camel_mime_filter_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-message.sgml b/docs/reference/camel/tmpl/camel-mime-message.sgml
index f7b6ed6..c8ed194 100644
--- a/docs/reference/camel/tmpl/camel-mime-message.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-message.sgml
@@ -22,6 +22,16 @@ CamelMimeMessage
 
 </para>
 
+ parent: 
+ date: 
+ date_offset: 
+ date_received: 
+ date_received_offset: 
+ subject: 
+ message_id: 
+ reply_to: 
+ from: 
+ recipients: 
 
 <!-- ##### MACRO CAMEL_RECIPIENT_TYPE_TO ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-parser.sgml b/docs/reference/camel/tmpl/camel-mime-parser.sgml
index d31c7bf..18a207c 100644
--- a/docs/reference/camel/tmpl/camel-mime-parser.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-parser.sgml
@@ -22,6 +22,8 @@ CamelMimeParser
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM camel_mime_parser_state_t ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-mime-part.sgml b/docs/reference/camel/tmpl/camel-mime-part.sgml
index 1629dbd..3fbaa9b 100644
--- a/docs/reference/camel/tmpl/camel-mime-part.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-part.sgml
@@ -22,26 +22,15 @@ CamelMimePart
 
 </para>
 
-
-<!-- ##### ARG CamelMimePart:content-id ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG CamelMimePart:content-md5 ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG CamelMimePart:description ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG CamelMimePart:disposition ##### -->
-<para>
-
-</para>
+ parent: 
+ headers: 
+ description: 
+ disposition: 
+ content_id: 
+ content_MD5: 
+ content_location: 
+ content_languages: 
+ encoding: 
 
 <!-- ##### FUNCTION camel_mime_part_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-multipart-encrypted.sgml b/docs/reference/camel/tmpl/camel-multipart-encrypted.sgml
index 08650ed..edf031b 100644
--- a/docs/reference/camel/tmpl/camel-multipart-encrypted.sgml
+++ b/docs/reference/camel/tmpl/camel-multipart-encrypted.sgml
@@ -22,6 +22,11 @@ CamelMultipartEncrypted
 
 </para>
 
+ parent: 
+ version: 
+ content: 
+ decrypted: 
+ protocol: 
 
 <!-- ##### FUNCTION camel_multipart_encrypted_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-multipart-signed.sgml b/docs/reference/camel/tmpl/camel-multipart-signed.sgml
index 5b52b15..0c90906 100644
--- a/docs/reference/camel/tmpl/camel-multipart-signed.sgml
+++ b/docs/reference/camel/tmpl/camel-multipart-signed.sgml
@@ -22,6 +22,16 @@ CamelMultipartSigned
 
 </para>
 
+ parent: 
+ content: 
+ signature: 
+ contentraw: 
+ protocol: 
+ micalg: 
+ start1: 
+ end1: 
+ start2: 
+ end2: 
 
 <!-- ##### FUNCTION camel_multipart_signed_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-multipart.sgml b/docs/reference/camel/tmpl/camel-multipart.sgml
index dbda444..19994a4 100644
--- a/docs/reference/camel/tmpl/camel-multipart.sgml
+++ b/docs/reference/camel/tmpl/camel-multipart.sgml
@@ -22,6 +22,10 @@ CamelMultipart
 
 </para>
 
+ parent: 
+ parts: 
+ preface: 
+ postface: 
 
 <!-- ##### FUNCTION camel_multipart_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-nntp-address.sgml b/docs/reference/camel/tmpl/camel-nntp-address.sgml
index 21b710f..7d49d8a 100644
--- a/docs/reference/camel/tmpl/camel-nntp-address.sgml
+++ b/docs/reference/camel/tmpl/camel-nntp-address.sgml
@@ -22,6 +22,8 @@ CamelNNTPAddress
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_nntp_address_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-object.sgml b/docs/reference/camel/tmpl/camel-object.sgml
index a7d933c..6178fb9 100644
--- a/docs/reference/camel/tmpl/camel-object.sgml
+++ b/docs/reference/camel/tmpl/camel-object.sgml
@@ -35,6 +35,13 @@ CamelObject
 
 </para>
 
+ klass: 
+ magic: 
+ hooks: 
+ ref_count: 
+ flags: 
+ next: 
+ prev: 
 
 <!-- ##### MACRO CAMEL_CHECK_CAST ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-offline-folder.sgml b/docs/reference/camel/tmpl/camel-offline-folder.sgml
index 250e5f2..25c604a 100644
--- a/docs/reference/camel/tmpl/camel-offline-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-offline-folder.sgml
@@ -22,6 +22,8 @@ CamelOfflineFolder
 
 </para>
 
+ parent: 
+ sync_offline: 
 
 <!-- ##### FUNCTION camel_offline_folder_downsync ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-offline-journal.sgml b/docs/reference/camel/tmpl/camel-offline-journal.sgml
index 9d732d7..6ab8510 100644
--- a/docs/reference/camel/tmpl/camel-offline-journal.sgml
+++ b/docs/reference/camel/tmpl/camel-offline-journal.sgml
@@ -22,6 +22,10 @@ CamelOfflineJournal
 
 </para>
 
+ parent: 
+ folder: 
+ filename: 
+ queue: 
 
 <!-- ##### STRUCT CamelOfflineJournalEntry ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-offline-store.sgml b/docs/reference/camel/tmpl/camel-offline-store.sgml
index 728e593..9e2c453 100644
--- a/docs/reference/camel/tmpl/camel-offline-store.sgml
+++ b/docs/reference/camel/tmpl/camel-offline-store.sgml
@@ -22,6 +22,8 @@ CamelOfflineStore
 
 </para>
 
+ parent: 
+ state: 
 
 <!-- ##### FUNCTION camel_offline_store_set_network_state ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-partition-table.sgml b/docs/reference/camel/tmpl/camel-partition-table.sgml
index 8f600d7..b9eaafc 100644
--- a/docs/reference/camel/tmpl/camel-partition-table.sgml
+++ b/docs/reference/camel/tmpl/camel-partition-table.sgml
@@ -56,6 +56,13 @@ CamelKeyTable
 
 </para>
 
+ parent: 
+ priv: 
+ blocks: 
+ rootid: 
+ is_key: 
+ is_key_data: 
+ partition: 
 
 <!-- ##### FUNCTION camel_partition_table_new ##### -->
 <para>
@@ -142,6 +149,12 @@ CamelKeyTable
 
 </para>
 
+ parent: 
+ priv: 
+ blocks: 
+ rootid: 
+ root: 
+ root_block: 
 
 <!-- ##### FUNCTION camel_key_table_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-anonymous.sgml b/docs/reference/camel/tmpl/camel-sasl-anonymous.sgml
index 9653859..6b4afb8 100644
--- a/docs/reference/camel/tmpl/camel-sasl-anonymous.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-anonymous.sgml
@@ -22,6 +22,9 @@ CamelSaslAnonymous
 
 </para>
 
+ parent: 
+ trace_info: 
+ type: 
 
 <!-- ##### ENUM CamelSaslAnonTraceType ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-cram-md5.sgml b/docs/reference/camel/tmpl/camel-sasl-cram-md5.sgml
index b4e39dc..cf30711 100644
--- a/docs/reference/camel/tmpl/camel-sasl-cram-md5.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-cram-md5.sgml
@@ -22,6 +22,8 @@ CamelSaslCramMd5
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_cram_md5_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-digest-md5.sgml b/docs/reference/camel/tmpl/camel-sasl-digest-md5.sgml
index d1d54f7..d50d8e8 100644
--- a/docs/reference/camel/tmpl/camel-sasl-digest-md5.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-digest-md5.sgml
@@ -22,6 +22,8 @@ CamelSaslDigestMd5
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_digest_md5_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-gssapi.sgml b/docs/reference/camel/tmpl/camel-sasl-gssapi.sgml
index bf2d7b4..a8cf46f 100644
--- a/docs/reference/camel/tmpl/camel-sasl-gssapi.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-gssapi.sgml
@@ -22,6 +22,8 @@ CamelSaslGssapi
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_gssapi_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-login.sgml b/docs/reference/camel/tmpl/camel-sasl-login.sgml
index 55f4dc8..d6cf93f 100644
--- a/docs/reference/camel/tmpl/camel-sasl-login.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-login.sgml
@@ -22,6 +22,8 @@ CamelSaslLogin
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_login_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-ntlm.sgml b/docs/reference/camel/tmpl/camel-sasl-ntlm.sgml
index e475b80..7077ad5 100644
--- a/docs/reference/camel/tmpl/camel-sasl-ntlm.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-ntlm.sgml
@@ -22,6 +22,8 @@ CamelSaslNTLM
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_ntlm_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-plain.sgml b/docs/reference/camel/tmpl/camel-sasl-plain.sgml
index 3e1feb5..60a5422 100644
--- a/docs/reference/camel/tmpl/camel-sasl-plain.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-plain.sgml
@@ -22,6 +22,8 @@ CamelSaslPlain
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_plain_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl-popb4smtp.sgml b/docs/reference/camel/tmpl/camel-sasl-popb4smtp.sgml
index ac9ae62..50ccd14 100644
--- a/docs/reference/camel/tmpl/camel-sasl-popb4smtp.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl-popb4smtp.sgml
@@ -22,6 +22,8 @@ CamelSaslPOPB4SMTP
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### VARIABLE camel_sasl_popb4smtp_authtype ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-sasl.sgml b/docs/reference/camel/tmpl/camel-sasl.sgml
index 328761e..4a3dea4 100644
--- a/docs/reference/camel/tmpl/camel-sasl.sgml
+++ b/docs/reference/camel/tmpl/camel-sasl.sgml
@@ -22,26 +22,8 @@ CamelSasl
 
 </para>
 
-
-<!-- ##### ARG CamelSasl:authenticated ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG CamelSasl:mechanism ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG CamelSasl:service ##### -->
-<para>
-
-</para>
-
-<!-- ##### ARG CamelSasl:service-name ##### -->
-<para>
-
-</para>
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_sasl_challenge ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-seekable-stream.sgml b/docs/reference/camel/tmpl/camel-seekable-stream.sgml
index b12cddb..cc28a54 100644
--- a/docs/reference/camel/tmpl/camel-seekable-stream.sgml
+++ b/docs/reference/camel/tmpl/camel-seekable-stream.sgml
@@ -22,6 +22,10 @@ CamelSeekableStream
 
 </para>
 
+ parent: 
+ position: 
+ bound_start: 
+ bound_end: 
 
 <!-- ##### ENUM CamelStreamSeekPolicy ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-seekable-substream.sgml b/docs/reference/camel/tmpl/camel-seekable-substream.sgml
index d2b9ef3..0609561 100644
--- a/docs/reference/camel/tmpl/camel-seekable-substream.sgml
+++ b/docs/reference/camel/tmpl/camel-seekable-substream.sgml
@@ -22,6 +22,8 @@ CamelSeekableSubstream
 
 </para>
 
+ parent: 
+ parent_stream: 
 
 <!-- ##### FUNCTION camel_seekable_substream_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-service.sgml b/docs/reference/camel/tmpl/camel-service.sgml
index b384dcb..0474be8 100644
--- a/docs/reference/camel/tmpl/camel-service.sgml
+++ b/docs/reference/camel/tmpl/camel-service.sgml
@@ -22,6 +22,13 @@ CamelService
 
 </para>
 
+ parent: 
+ priv: 
+ session: 
+ provider: 
+ status: 
+ connect_op: 
+ url: 
 
 <!-- ##### MACRO CAMEL_SERVICE_USERNAME ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-session.sgml b/docs/reference/camel/tmpl/camel-session.sgml
index e868e6a..1c3b7f6 100644
--- a/docs/reference/camel/tmpl/camel-session.sgml
+++ b/docs/reference/camel/tmpl/camel-session.sgml
@@ -22,6 +22,13 @@ CamelSession
 
 </para>
 
+ parent: 
+ priv: 
+ storage_path: 
+ junk_plugin: 
+ online: 
+ check_junk: 
+ network_state: 
 
 <!-- ##### USER_FUNCTION CamelTimeoutCallback ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-smime-context.sgml b/docs/reference/camel/tmpl/camel-smime-context.sgml
index 78c3220..1a12ad3 100644
--- a/docs/reference/camel/tmpl/camel-smime-context.sgml
+++ b/docs/reference/camel/tmpl/camel-smime-context.sgml
@@ -22,6 +22,8 @@ CamelSMIMEContext
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### ENUM camel_smime_sign_t ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-store-summary.sgml b/docs/reference/camel/tmpl/camel-store-summary.sgml
index 4886fa4..e98a3d2 100644
--- a/docs/reference/camel/tmpl/camel-store-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-store-summary.sgml
@@ -53,6 +53,18 @@ CamelStoreSummary
 
 </para>
 
+ parent: 
+ priv: 
+ version: 
+ flags: 
+ count: 
+ time: 
+ uri_base: 
+ store_info_size: 
+ store_info_chunks: 
+ summary_path: 
+ folders: 
+ folders_path: 
 
 <!-- ##### MACRO CAMEL_STORE_INFO_FOLDER_UNKNOWN ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-store.sgml b/docs/reference/camel/tmpl/camel-store.sgml
index 4960002..83c99a3 100644
--- a/docs/reference/camel/tmpl/camel-store.sgml
+++ b/docs/reference/camel/tmpl/camel-store.sgml
@@ -22,6 +22,14 @@ CamelStore
 
 </para>
 
+ parent: 
+ priv: 
+ folders: 
+ cdb_r: 
+ cdb_w: 
+ flags: 
+ mode: 
+ later: 
 
 <!-- ##### STRUCT CamelFolderInfo ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-buffer.sgml b/docs/reference/camel/tmpl/camel-stream-buffer.sgml
index 35348b7..9782e2e 100644
--- a/docs/reference/camel/tmpl/camel-stream-buffer.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-buffer.sgml
@@ -22,6 +22,16 @@ CamelStreamBuffer
 
 </para>
 
+ parent: 
+ stream: 
+ buf: 
+ ptr: 
+ end: 
+ size: 
+ linebuf: 
+ linesize: 
+ mode: 
+ flags: 
 
 <!-- ##### ENUM CamelStreamBufferMode ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-filter.sgml b/docs/reference/camel/tmpl/camel-stream-filter.sgml
index 0311635..790b1b4 100644
--- a/docs/reference/camel/tmpl/camel-stream-filter.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-filter.sgml
@@ -22,6 +22,9 @@ CamelStreamFilter
 
 </para>
 
+ parent: 
+ source: 
+ priv: 
 
 <!-- ##### FUNCTION camel_stream_filter_add ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-fs.sgml b/docs/reference/camel/tmpl/camel-stream-fs.sgml
index cbbf35d..4abf2ca 100644
--- a/docs/reference/camel/tmpl/camel-stream-fs.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-fs.sgml
@@ -22,6 +22,8 @@ CamelStreamFs
 
 </para>
 
+ parent: 
+ fd: 
 
 <!-- ##### FUNCTION camel_stream_fs_new_with_name ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-mem.sgml b/docs/reference/camel/tmpl/camel-stream-mem.sgml
index 42a46c2..d7a63a1 100644
--- a/docs/reference/camel/tmpl/camel-stream-mem.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-mem.sgml
@@ -22,6 +22,10 @@ CamelStreamMem
 
 </para>
 
+ parent: 
+ owner: 
+ secure: 
+ buffer: 
 
 <!-- ##### FUNCTION camel_stream_mem_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-null.sgml b/docs/reference/camel/tmpl/camel-stream-null.sgml
index 43c9a29..2c5a847 100644
--- a/docs/reference/camel/tmpl/camel-stream-null.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-null.sgml
@@ -22,6 +22,8 @@ CamelStreamNull
 
 </para>
 
+ parent: 
+ written: 
 
 <!-- ##### FUNCTION camel_stream_null_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-process.sgml b/docs/reference/camel/tmpl/camel-stream-process.sgml
index a1e349e..351c1d2 100644
--- a/docs/reference/camel/tmpl/camel-stream-process.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-process.sgml
@@ -22,6 +22,9 @@ CamelStreamProcess
 
 </para>
 
+ parent: 
+ sockfd: 
+ childpid: 
 
 <!-- ##### FUNCTION camel_stream_process_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-vfs.sgml b/docs/reference/camel/tmpl/camel-stream-vfs.sgml
index f984d8a..2af3894 100644
--- a/docs/reference/camel/tmpl/camel-stream-vfs.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-vfs.sgml
@@ -22,6 +22,8 @@ CamelStreamVFS
 
 </para>
 
+ parent: 
+ stream: 
 
 <!-- ##### ENUM CamelStreamVFSOpenMethod ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream.sgml b/docs/reference/camel/tmpl/camel-stream.sgml
index 109f381..bbcd73a 100644
--- a/docs/reference/camel/tmpl/camel-stream.sgml
+++ b/docs/reference/camel/tmpl/camel-stream.sgml
@@ -22,6 +22,8 @@ CamelStream
 
 </para>
 
+ parent: 
+ eos: 
 
 <!-- ##### FUNCTION camel_stream_read ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-tcp-stream-raw.sgml b/docs/reference/camel/tmpl/camel-tcp-stream-raw.sgml
index e78b311..cf53240 100644
--- a/docs/reference/camel/tmpl/camel-tcp-stream-raw.sgml
+++ b/docs/reference/camel/tmpl/camel-tcp-stream-raw.sgml
@@ -22,6 +22,9 @@ CamelTcpStreamRaw
 
 </para>
 
+ parent: 
+ sockfd: 
+ is_nonblocking: 
 
 <!-- ##### FUNCTION camel_tcp_stream_raw_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-tcp-stream-ssl.sgml b/docs/reference/camel/tmpl/camel-tcp-stream-ssl.sgml
index cfa1532..15e5ceb 100644
--- a/docs/reference/camel/tmpl/camel-tcp-stream-ssl.sgml
+++ b/docs/reference/camel/tmpl/camel-tcp-stream-ssl.sgml
@@ -22,6 +22,8 @@ CamelTcpStreamSSL
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### MACRO CAMEL_TCP_STREAM_SSL_ENABLE_SSL2 ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-tcp-stream.sgml b/docs/reference/camel/tmpl/camel-tcp-stream.sgml
index 4ddafee..5e1cfa0 100644
--- a/docs/reference/camel/tmpl/camel-tcp-stream.sgml
+++ b/docs/reference/camel/tmpl/camel-tcp-stream.sgml
@@ -22,6 +22,7 @@ CamelTcpStream
 
 </para>
 
+ parent: 
 
 <!-- ##### ENUM CamelSockOpt ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-text-index.sgml b/docs/reference/camel/tmpl/camel-text-index.sgml
index ab4bb90..faa0037 100644
--- a/docs/reference/camel/tmpl/camel-text-index.sgml
+++ b/docs/reference/camel/tmpl/camel-text-index.sgml
@@ -32,24 +32,32 @@ CamelTextIndex
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### STRUCT CamelTextIndexCursor ##### -->
 <para>
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### STRUCT CamelTextIndexKeyCursor ##### -->
 <para>
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### STRUCT CamelTextIndexName ##### -->
 <para>
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_text_index_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-transport.sgml b/docs/reference/camel/tmpl/camel-transport.sgml
index 4f43ce0..e589313 100644
--- a/docs/reference/camel/tmpl/camel-transport.sgml
+++ b/docs/reference/camel/tmpl/camel-transport.sgml
@@ -22,6 +22,8 @@ CamelTransport
 
 </para>
 
+ parent: 
+ priv: 
 
 <!-- ##### FUNCTION camel_transport_send_to ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-unused.sgml b/docs/reference/camel/tmpl/camel-unused.sgml
index f648471..701e47e 100644
--- a/docs/reference/camel/tmpl/camel-unused.sgml
+++ b/docs/reference/camel/tmpl/camel-unused.sgml
@@ -492,6 +492,18 @@ camel-types
 </para>
 
 
+<!-- ##### ARG CamelCipherContext:session ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelDataCache:path ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### STRUCT CamelDigestFolder ##### -->
 <para>
 
@@ -514,6 +526,12 @@ camel-types
 
 @parent_object: 
 
+<!-- ##### ARG CamelGpgContext:always-trust ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### STRUCT CamelIMAP4Command ##### -->
 <para>
 
@@ -828,12 +846,42 @@ camel-types
 </para>
 
 
+<!-- ##### ARG CamelMedium:content ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### STRUCT CamelMimeFilterChomp ##### -->
 <para>
 
 </para>
 
 
+<!-- ##### ARG CamelMimePart:content-id ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelMimePart:content-md5 ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelMimePart:description ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelMimePart:disposition ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### STRUCT CamelNNTPFolderPrivate ##### -->
 <para>
 
@@ -898,6 +946,30 @@ camel-types
 @value: 
 @name: 
 
+<!-- ##### ARG CamelSasl:authenticated ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelSasl:mechanism ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelSasl:service ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### ARG CamelSasl:service-name ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### STRUCT CamelSimpleDataWrapper ##### -->
 <para>
 
diff --git a/docs/reference/camel/tmpl/camel-vee-folder.sgml b/docs/reference/camel/tmpl/camel-vee-folder.sgml
index 2d24836..8675cb2 100644
--- a/docs/reference/camel/tmpl/camel-vee-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-vee-folder.sgml
@@ -22,6 +22,16 @@ CamelVeeFolder
 
 </para>
 
+ parent: 
+ priv: 
+ expression: 
+ flags: 
+ changes: 
+ search: 
+ parent_vee_store: 
+ hashes: 
+ loaded: 
+ deleted: 
 
 <!-- ##### MACRO CAMEL_UNMATCHED_NAME ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-vee-store.sgml b/docs/reference/camel/tmpl/camel-vee-store.sgml
index 61ae391..723b730 100644
--- a/docs/reference/camel/tmpl/camel-vee-store.sgml
+++ b/docs/reference/camel/tmpl/camel-vee-store.sgml
@@ -22,6 +22,9 @@ CamelVeeStore
 
 </para>
 
+ parent: 
+ folder_unmatched: 
+ unmatched_uids: 
 
 <!-- ##### MACRO CAMEL_STORE_VEE_FOLDER_AUTO ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-vee-summary.sgml b/docs/reference/camel/tmpl/camel-vee-summary.sgml
index 137b636..969d25f 100644
--- a/docs/reference/camel/tmpl/camel-vee-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-vee-summary.sgml
@@ -22,6 +22,9 @@ CamelVeeSummary
 
 </para>
 
+ summary: 
+ force_counts: 
+ fake_visible_count: 
 
 <!-- ##### STRUCT CamelVeeMessageInfo ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-vtrash-folder.sgml b/docs/reference/camel/tmpl/camel-vtrash-folder.sgml
index d9783c6..b08bedd 100644
--- a/docs/reference/camel/tmpl/camel-vtrash-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-vtrash-folder.sgml
@@ -36,6 +36,9 @@ CamelVTrashFolder
 
 </para>
 
+ parent: 
+ type: 
+ bit: 
 
 <!-- ##### ENUM camel_vtrash_folder_t ##### -->
 <para>



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