[evolution-data-server/camel-gobject] Minor changes to sync with master.



commit 3be1252b7ea62a7f7dd4e33d08b52a942be29c6f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Apr 10 10:11:05 2010 -0400

    Minor changes to sync with master.

 camel/camel-disco-folder.c                         |  190 ++--
 camel/camel-disco-store.c                          |  235 ++--
 camel/camel-filter-driver.c                        |   14 +-
 camel/camel-folder.c                               | 1503 ++++++++++----------
 camel/camel-http-stream.c                          |    7 +-
 camel/camel-index.c                                |    2 +-
 camel/camel-mime-parser.c                          |   22 +-
 camel/camel-mime-part.c                            |   11 +-
 camel/camel-mime-utils.c                           |    5 +
 camel/camel-multipart-signed.c                     |    4 +-
 camel/camel-multipart.c                            |   42 +-
 camel/camel-offline-folder.c                       |    4 +-
 camel/camel-seekable-substream.c                   |    6 +-
 camel/camel-store-summary.c                        |  403 +++---
 camel/camel-store.c                                |   80 +-
 camel/camel-stream-buffer.c                        |    7 +-
 camel/camel-stream-filter.c                        |   16 +-
 camel/camel-stream-fs.c                            |    4 +-
 camel/camel-stream-mem.c                           |    6 +-
 camel/camel-stream-mem.h                           |    2 +-
 camel/camel-stream-process.c                       |    5 +-
 camel/camel-stream-vfs.c                           |    2 +-
 camel/camel-stream.c                               |    3 +
 camel/camel-tcp-stream-raw.c                       |    5 +-
 camel/camel-tcp-stream-ssl.c                       |  382 +++---
 camel/camel-tcp-stream.c                           |    5 +
 camel/camel-tcp-stream.h                           |   15 +-
 camel/camel-text-index.c                           |   11 +-
 camel/camel-vee-store.c                            |    8 +
 camel/camel-vtrash-folder.c                        |    1 +
 docs/reference/camel/tmpl/camel-imap4-command.sgml |  141 --
 docs/reference/camel/tmpl/camel-imap4-engine.sgml  |  299 ----
 docs/reference/camel/tmpl/camel-imap4-folder.sgml  |   34 -
 docs/reference/camel/tmpl/camel-imap4-journal.sgml |   46 -
 docs/reference/camel/tmpl/camel-imap4-search.sgml  |   24 -
 .../reference/camel/tmpl/camel-imap4-specials.sgml |   56 -
 .../camel/tmpl/camel-imap4-store-summary.sgml      |   73 -
 docs/reference/camel/tmpl/camel-imap4-store.sgml   |   10 -
 docs/reference/camel/tmpl/camel-imap4-stream.sgml  |   93 --
 docs/reference/camel/tmpl/camel-imap4-summary.sgml |  109 --
 docs/reference/camel/tmpl/camel-imap4-utils.sgml   |  185 ---
 docs/reference/camel/tmpl/camel-unused.sgml        |  989 +++++++++++++
 42 files changed, 2558 insertions(+), 2501 deletions(-)
---
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index f37f02d..9d0f033 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -37,26 +37,9 @@ static CamelProperty disco_property_list[] = {
 	{ CAMEL_DISCO_FOLDER_OFFLINE_SYNC, "offline_sync", N_("Copy folder content locally for offline operation") },
 };
 
-static gint disco_getv(CamelObject *object, GError **error, CamelArgGetV *args);
-static gint disco_setv(CamelObject *object, GError **error, CamelArgV *args);
-
-static gboolean disco_refresh_info (CamelFolder *folder, GError **error);
-static gboolean disco_refresh_info_online (CamelFolder *folder, GError **error);
-static gboolean disco_sync (CamelFolder *folder, gboolean expunge, GError **error);
+/* Forward Declarations */
 static gboolean disco_expunge (CamelFolder *folder, GError **error);
 
-static gboolean disco_append_message (CamelFolder *folder, CamelMimeMessage *message,
-				  const CamelMessageInfo *info, gchar **appended_uid, GError **error);
-static gboolean disco_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
-					CamelFolder *destination,
-					GPtrArray **transferred_uids,
-					gboolean delete_originals,
-					GError **error);
-
-static gboolean disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
-				       const gchar *expression,
-				       GError **error);
-
 struct _cdf_sync_msg {
 	CamelSessionThreadMsg msg;
 
@@ -119,49 +102,11 @@ cdf_folder_changed(CamelFolder *folder, CamelFolderChangeInfo *changes, gpointer
 		m = camel_session_thread_msg_new(session, &cdf_sync_ops, sizeof(*m));
 		m->changes = camel_folder_change_info_new();
 		camel_folder_change_info_cat(m->changes, changes);
-		m->folder = folder;
-		g_object_ref (folder);
+		m->folder = g_object_ref (folder);
 		camel_session_thread_queue(session, &m->msg, 0);
 	}
 }
 
-static void
-camel_disco_folder_class_init (CamelDiscoFolderClass *class)
-{
-	CamelObjectClass *camel_object_class;
-	CamelFolderClass *folder_class;
-	gint ii;
-
-	camel_object_class = CAMEL_OBJECT_CLASS (class);
-	camel_object_class->getv = disco_getv;
-	camel_object_class->setv = disco_setv;
-
-	folder_class = CAMEL_FOLDER_CLASS (class);
-	folder_class->refresh_info = disco_refresh_info;
-	folder_class->sync = disco_sync;
-	folder_class->expunge = disco_expunge;
-	folder_class->append_message = disco_append_message;
-	folder_class->transfer_messages_to = disco_transfer_messages_to;
-
-	class->prepare_for_offline = disco_prepare_for_offline;
-	class->refresh_info_online = disco_refresh_info_online;
-
-	for (ii = 0; ii < G_N_ELEMENTS (disco_property_list); ii++) {
-		disco_property_list[ii].description =
-			_(disco_property_list[ii].description);
-		disco_folder_properties = g_slist_prepend (
-			disco_folder_properties, &disco_property_list[ii]);
-	}
-}
-
-static void
-camel_disco_folder_init (CamelDiscoFolder *disco_folder)
-{
-	camel_object_hook_event (
-		disco_folder, "folder_changed",
-		(CamelObjectEventHookFunc) cdf_folder_changed, NULL);
-}
-
 static gint
 disco_getv (CamelObject *object,
             GError **error,
@@ -238,13 +183,6 @@ disco_setv (CamelObject *object,
 }
 
 static gboolean
-disco_refresh_info_online (CamelFolder *folder,
-                           GError **error)
-{
-	return TRUE;
-}
-
-static gboolean
 disco_refresh_info (CamelFolder *folder,
                     GError **error)
 {
@@ -406,6 +344,90 @@ disco_transfer_messages_to (CamelFolder *source,
 	g_return_val_if_reached (FALSE);
 }
 
+static gboolean
+disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
+                           const gchar *expression,
+                           GError **error)
+{
+	CamelFolder *folder = CAMEL_FOLDER (disco_folder);
+	GPtrArray *uids;
+	gint i;
+	gboolean success = TRUE;
+
+	camel_operation_start(NULL, _("Preparing folder '%s' for offline"), folder->full_name);
+
+	if (expression)
+		uids = camel_folder_search_by_expression (folder, expression, error);
+	else
+		uids = camel_folder_get_uids (folder);
+
+	if (!uids) {
+		camel_operation_end(NULL);
+		return FALSE;
+	}
+
+	for (i = 0; i < uids->len && success; i++) {
+		gint pc = i * 100 / uids->len;
+
+		camel_operation_progress(NULL, pc);
+		success = camel_disco_folder_cache_message (
+			disco_folder, uids->pdata[i], error);
+	}
+
+	if (expression)
+		camel_folder_search_free (folder, uids);
+	else
+		camel_folder_free_uids (folder, uids);
+
+	camel_operation_end(NULL);
+
+	return success;
+}
+
+static gboolean
+disco_refresh_info_online (CamelFolder *folder,
+                           GError **error)
+{
+	return TRUE;
+}
+
+static void
+camel_disco_folder_class_init (CamelDiscoFolderClass *class)
+{
+	CamelObjectClass *camel_object_class;
+	CamelFolderClass *folder_class;
+	gint ii;
+
+	camel_object_class = CAMEL_OBJECT_CLASS (class);
+	camel_object_class->getv = disco_getv;
+	camel_object_class->setv = disco_setv;
+
+	folder_class = CAMEL_FOLDER_CLASS (class);
+	folder_class->refresh_info = disco_refresh_info;
+	folder_class->sync = disco_sync;
+	folder_class->expunge = disco_expunge;
+	folder_class->append_message = disco_append_message;
+	folder_class->transfer_messages_to = disco_transfer_messages_to;
+
+	class->prepare_for_offline = disco_prepare_for_offline;
+	class->refresh_info_online = disco_refresh_info_online;
+
+	for (ii = 0; ii < G_N_ELEMENTS (disco_property_list); ii++) {
+		disco_property_list[ii].description =
+			_(disco_property_list[ii].description);
+		disco_folder_properties = g_slist_prepend (
+			disco_folder_properties, &disco_property_list[ii]);
+	}
+}
+
+static void
+camel_disco_folder_init (CamelDiscoFolder *disco_folder)
+{
+	camel_object_hook_event (
+		disco_folder, "folder_changed",
+		(CamelObjectEventHookFunc) cdf_folder_changed, NULL);
+}
+
 /**
  * camel_disco_folder_expunge_uids:
  * @folder: a (disconnectable) folder
@@ -457,46 +479,6 @@ camel_disco_folder_cache_message (CamelDiscoFolder *disco_folder,
 	return class->cache_message (disco_folder, uid, error);
 }
 
-static gboolean
-disco_prepare_for_offline (CamelDiscoFolder *disco_folder,
-                           const gchar *expression,
-                           GError **error)
-{
-	CamelFolder *folder = CAMEL_FOLDER (disco_folder);
-	GPtrArray *uids;
-	gint i;
-	gboolean success = TRUE;
-
-	camel_operation_start(NULL, _("Preparing folder '%s' for offline"), folder->full_name);
-
-	if (expression)
-		uids = camel_folder_search_by_expression (folder, expression, error);
-	else
-		uids = camel_folder_get_uids (folder);
-
-	if (!uids) {
-		camel_operation_end(NULL);
-		return FALSE;
-	}
-
-	for (i = 0; i < uids->len && success; i++) {
-		gint pc = i * 100 / uids->len;
-
-		camel_operation_progress(NULL, pc);
-		success = camel_disco_folder_cache_message (
-			disco_folder, uids->pdata[i], error);
-	}
-
-	if (expression)
-		camel_folder_search_free (folder, uids);
-	else
-		camel_folder_free_uids (folder, uids);
-
-	camel_operation_end(NULL);
-
-	return success;
-}
-
 /**
  * camel_disco_folder_prepare_for_offline:
  * @disco_folder: the folder
diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c
index fcaf74d..d7003fa 100644
--- a/camel/camel-disco-store.c
+++ b/camel/camel-disco-store.c
@@ -35,55 +35,14 @@
 
 #define d(x)
 
-static gboolean disco_construct (CamelService *service, CamelSession *session,
-			     CamelProvider *provider, CamelURL *url,
-			     GError **error);
-static gboolean disco_connect (CamelService *service, GError **error);
-static void disco_cancel_connect (CamelService *service);
-static gboolean disco_disconnect (CamelService *service, gboolean clean, GError **error);
-static CamelFolder *disco_get_folder (CamelStore *store, const gchar *name,
-				      guint32 flags, GError **error);
-static CamelFolderInfo *disco_get_folder_info (CamelStore *store,
-					       const gchar *top, guint32 flags,
-					       GError **error);
-static void set_status (CamelDiscoStore *disco_store,
-			CamelDiscoStoreStatus status,
-			GError **error);
-static gboolean can_work_offline (CamelDiscoStore *disco_store);
-
 G_DEFINE_TYPE (CamelDiscoStore, camel_disco_store, CAMEL_TYPE_STORE)
 
-static void
-camel_disco_store_class_init (CamelDiscoStoreClass *class)
-{
-	CamelServiceClass *service_class;
-	CamelStoreClass *store_class;
-
-	service_class = CAMEL_SERVICE_CLASS (class);
-	service_class->construct = disco_construct;
-	service_class->connect = disco_connect;
-	service_class->disconnect = disco_disconnect;
-	service_class->cancel_connect = disco_cancel_connect;
-
-	store_class = CAMEL_STORE_CLASS (class);
-	store_class->get_folder = disco_get_folder;
-	store_class->get_folder_info = disco_get_folder_info;
-
-	class->set_status = set_status;
-	class->can_work_offline = can_work_offline;
-}
-
-static void
-camel_disco_store_init (CamelDiscoStore *disco_store)
-{
-}
-
 static gboolean
-disco_construct (CamelService *service,
-                 CamelSession *session,
-                 CamelProvider *provider,
-                 CamelURL *url,
-                 GError **error)
+disco_store_construct (CamelService *service,
+                       CamelSession *session,
+                       CamelProvider *provider,
+                       CamelURL *url,
+                       GError **error)
 {
 	CamelServiceClass *service_class;
 	CamelDiscoStore *disco = CAMEL_DISCO_STORE (service);
@@ -100,8 +59,8 @@ disco_construct (CamelService *service,
 }
 
 static gboolean
-disco_connect (CamelService *service,
-               GError **error)
+disco_store_connect (CamelService *service,
+                     GError **error)
 {
 	CamelDiscoStore *store = CAMEL_DISCO_STORE (service);
 	CamelDiscoStoreStatus status;
@@ -134,8 +93,7 @@ disco_connect (CamelService *service,
 		/* Need to resync.  Note we do the ref thing since during the replay
 		   disconnect could be called, which will remove store->diary and unref it */
 		store->status = CAMEL_DISCO_STORE_RESYNCING;
-		diary = store->diary;
-		g_object_ref (diary);
+		diary = g_object_ref (store->diary);
 		camel_disco_diary_replay(diary, &local_error);
 		g_object_unref (diary);
 		store->status = CAMEL_DISCO_STORE_ONLINE;
@@ -156,20 +114,10 @@ disco_connect (CamelService *service,
 	return FALSE;
 }
 
-static void
-disco_cancel_connect (CamelService *service)
-{
-	CamelDiscoStore *store = CAMEL_DISCO_STORE (service);
-
-	/* Fall back */
-	store->status = CAMEL_DISCO_STORE_OFFLINE;
-	CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->cancel_connect (service);
-}
-
 static gboolean
-disco_disconnect (CamelService *service,
-                  gboolean clean,
-                  GError **error)
+disco_store_disconnect (CamelService *service,
+                        gboolean clean,
+                        GError **error)
 {
 	CamelDiscoStore *store = CAMEL_DISCO_STORE (service);
 
@@ -190,40 +138,61 @@ disco_disconnect (CamelService *service,
 	return CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->disconnect (service, clean, error);
 }
 
+static void
+disco_store_cancel_connect (CamelService *service)
+{
+	CamelDiscoStore *store = CAMEL_DISCO_STORE (service);
+
+	/* Fall back */
+	store->status = CAMEL_DISCO_STORE_OFFLINE;
+	CAMEL_SERVICE_CLASS (camel_disco_store_parent_class)->cancel_connect (service);
+}
+
 static CamelFolder *
-disco_get_folder (CamelStore *store,
-                  const gchar *name,
-                  guint32 flags,
-                  GError **error)
+disco_store_get_folder (CamelStore *store,
+                        const gchar *name,
+                        guint32 flags,
+                        GError **error)
 {
 	CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
+	CamelDiscoStoreClass *class;
+
+	class = CAMEL_DISCO_STORE_GET_CLASS (disco_store);
+	g_return_val_if_fail (class->get_folder_online != NULL, NULL);
+	g_return_val_if_fail (class->get_folder_offline != NULL, NULL);
+	g_return_val_if_fail (class->get_folder_resyncing != NULL, NULL);
 
 	switch (camel_disco_store_status (disco_store)) {
 	case CAMEL_DISCO_STORE_ONLINE:
-		return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_online (store, name, flags, error);
+		return class->get_folder_online (store, name, flags, error);
 
 	case CAMEL_DISCO_STORE_OFFLINE:
-		return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_offline (store, name, flags, error);
+		return class->get_folder_offline (store, name, flags, error);
 
 	case CAMEL_DISCO_STORE_RESYNCING:
-		return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_resyncing (store, name, flags, error);
+		return class->get_folder_resyncing (store, name, flags, error);
 	}
 
-	g_assert_not_reached ();
-	return NULL;
+	g_return_val_if_reached (NULL);
 }
 
 static CamelFolderInfo *
-disco_get_folder_info (CamelStore *store,
-                       const gchar *top,
-                       guint32 flags,
-                       GError **error)
+disco_store_get_folder_info (CamelStore *store,
+                             const gchar *top,
+                             guint32 flags,
+                             GError **error)
 {
 	CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (store);
+	CamelDiscoStoreClass *class;
+
+	class = CAMEL_DISCO_STORE_GET_CLASS (disco_store);
+	g_return_val_if_fail (class->get_folder_info_online != NULL, NULL);
+	g_return_val_if_fail (class->get_folder_info_offline != NULL, NULL);
+	g_return_val_if_fail (class->get_folder_info_resyncing != NULL, NULL);
 
 	switch (camel_disco_store_status (disco_store)) {
 	case CAMEL_DISCO_STORE_ONLINE:
-		return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_online (store, top, flags, error);
+		return class->get_folder_info_online (store, top, flags, error);
 
 	case CAMEL_DISCO_STORE_OFFLINE:
 		/* Can't edit subscriptions while offline */
@@ -233,40 +202,19 @@ disco_get_folder_info (CamelStore *store,
 			return NULL;
 		}
 
-		return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_offline (store, top, flags, error);
+		return class->get_folder_info_offline (store, top, flags, error);
 
 	case CAMEL_DISCO_STORE_RESYNCING:
-		return CAMEL_DISCO_STORE_GET_CLASS (store)->get_folder_info_resyncing (store, top, flags, error);
+		return class->get_folder_info_resyncing (store, top, flags, error);
 	}
 
-	g_assert_not_reached ();
-	return NULL;
-}
-
-/**
- * camel_disco_store_status:
- * @store: a disconnectable store
- *
- * Returns: the current online/offline status of @store.
- **/
-CamelDiscoStoreStatus
-camel_disco_store_status (CamelDiscoStore *store)
-{
-	CamelService *service = CAMEL_SERVICE (store);
-
-	g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), CAMEL_DISCO_STORE_ONLINE);
-
-	if (store->status != CAMEL_DISCO_STORE_OFFLINE
-	    && !camel_session_is_online (service->session))
-		store->status = CAMEL_DISCO_STORE_OFFLINE;
-
-	return store->status;
+	g_return_val_if_reached (NULL);
 }
 
 static void
-set_status (CamelDiscoStore *disco_store,
-            CamelDiscoStoreStatus status,
-            GError **error)
+disco_store_set_status (CamelDiscoStore *disco_store,
+                        CamelDiscoStoreStatus status,
+                        GError **error)
 {
 	CamelService *service = CAMEL_SERVICE (disco_store);
 	gboolean network_state = camel_session_get_network_state (service->session);
@@ -310,6 +258,50 @@ set_status (CamelDiscoStore *disco_store,
 	camel_service_connect (CAMEL_SERVICE (disco_store), error);
 }
 
+static void
+camel_disco_store_class_init (CamelDiscoStoreClass *class)
+{
+	CamelServiceClass *service_class;
+	CamelStoreClass *store_class;
+
+	service_class = CAMEL_SERVICE_CLASS (class);
+	service_class->construct = disco_store_construct;
+	service_class->connect = disco_store_connect;
+	service_class->disconnect = disco_store_disconnect;
+	service_class->cancel_connect = disco_store_cancel_connect;
+
+	store_class = CAMEL_STORE_CLASS (class);
+	store_class->get_folder = disco_store_get_folder;
+	store_class->get_folder_info = disco_store_get_folder_info;
+
+	class->set_status = disco_store_set_status;
+}
+
+static void
+camel_disco_store_init (CamelDiscoStore *disco_store)
+{
+}
+
+/**
+ * camel_disco_store_status:
+ * @store: a disconnectable store
+ *
+ * Returns: the current online/offline status of @store.
+ **/
+CamelDiscoStoreStatus
+camel_disco_store_status (CamelDiscoStore *store)
+{
+	CamelService *service = CAMEL_SERVICE (store);
+
+	g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), CAMEL_DISCO_STORE_ONLINE);
+
+	if (store->status != CAMEL_DISCO_STORE_OFFLINE
+	    && !camel_session_is_online (service->session))
+		store->status = CAMEL_DISCO_STORE_OFFLINE;
+
+	return store->status;
+}
+
 /**
  * camel_disco_store_set_status:
  * @store: a disconnectable store
@@ -324,17 +316,14 @@ camel_disco_store_set_status (CamelDiscoStore *store,
                               CamelDiscoStoreStatus status,
                               GError **error)
 {
-	d(printf("disco store set status: %s\n", status == CAMEL_DISCO_STORE_ONLINE?"online":"offline"));
+	CamelDiscoStoreClass *class;
 
-	CAMEL_DISCO_STORE_GET_CLASS (store)->set_status (store, status, error);
-}
+	g_return_if_fail (CAMEL_IS_DISCO_STORE (store));
 
-static gboolean
-can_work_offline (CamelDiscoStore *disco_store)
-{
-	g_warning ("CamelDiscoStore::can_work_offline not implemented for '%s'",
-		   G_OBJECT_CLASS_NAME (G_OBJECT_TYPE (disco_store)));
-	return FALSE;
+	class = CAMEL_DISCO_STORE_GET_CLASS (store);
+	g_return_if_fail (class->set_status != NULL);
+
+	class->set_status (store, status, error);
 }
 
 /**
@@ -347,7 +336,14 @@ can_work_offline (CamelDiscoStore *disco_store)
 gboolean
 camel_disco_store_can_work_offline (CamelDiscoStore *store)
 {
-	return CAMEL_DISCO_STORE_GET_CLASS (store)->can_work_offline (store);
+	CamelDiscoStoreClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), FALSE);
+
+	class = CAMEL_DISCO_STORE_GET_CLASS (store);
+	g_return_val_if_fail (class->can_work_offline != NULL, FALSE);
+
+	return class->can_work_offline (store);
 }
 
 /**
@@ -365,6 +361,8 @@ gboolean
 camel_disco_store_check_online (CamelDiscoStore *store,
                                 GError **error)
 {
+	g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), FALSE);
+
 	if (camel_disco_store_status (store) == CAMEL_DISCO_STORE_ONLINE)
 		return TRUE;
 
@@ -380,12 +378,15 @@ void
 camel_disco_store_prepare_for_offline (CamelDiscoStore *disco_store,
                                        GError **error)
 {
-	CamelService *service = CAMEL_SERVICE (disco_store);
-	gboolean network_state = camel_session_get_network_state (service->session);
+	CamelService *service;
+
+	g_return_if_fail (CAMEL_IS_DISCO_STORE (disco_store));
+
+	service = CAMEL_SERVICE (disco_store);
 
 	/* Sync the folder fully if we've been told to sync online for this store or this folder */
 
-	if (network_state) {
+	if (camel_session_get_network_state (service->session)) {
 		if (disco_store->status == CAMEL_DISCO_STORE_ONLINE) {
 			if (((CamelStore *)disco_store)->folders) {
 				GPtrArray *folders;
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 7fdff54..4b6b494 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -139,7 +139,7 @@ static ESExpResult *do_copy (struct _ESExp *f, gint argc, struct _ESExpResult **
 static ESExpResult *do_move (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
 static ESExpResult *do_stop (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
 static ESExpResult *do_label (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
-static ESExpResult *do_colour (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
+static ESExpResult *do_color (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
 static ESExpResult *do_score (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
 static ESExpResult *do_adjust_score(struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
 static ESExpResult *set_flag (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *);
@@ -163,7 +163,7 @@ static struct {
 	{ "move-to",           (ESExpFunc *) do_move,      0 },
 	{ "stop",              (ESExpFunc *) do_stop,      0 },
 	{ "set-label",         (ESExpFunc *) do_label,     0 },
-	{ "set-colour",        (ESExpFunc *) do_colour,    0 },
+	{ "set-color",        (ESExpFunc *) do_color,    0 },
 	{ "set-score",         (ESExpFunc *) do_score,     0 },
 	{ "adjust-score",      (ESExpFunc *) do_adjust_score, 0 },
 	{ "set-system-flag",   (ESExpFunc *) set_flag,     0 },
@@ -638,17 +638,17 @@ do_label (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDr
 }
 
 static ESExpResult *
-do_colour (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
+do_color (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
 	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
-	d(fprintf (stderr, "setting colour tag\n"));
+	d(fprintf (stderr, "setting color tag\n"));
 	if (argc > 0 && argv[0]->type == ESEXP_RES_STRING) {
 		if (p->source && p->uid && camel_folder_has_summary_capability (p->source))
-			camel_folder_set_message_user_tag (p->source, p->uid, "colour", argv[0]->value.string);
+			camel_folder_set_message_user_tag (p->source, p->uid, "color", argv[0]->value.string);
 		else
-			camel_message_info_set_user_tag(p->info, "colour", argv[0]->value.string);
-		camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set colour to %s", argv[0]->value.string);
+			camel_message_info_set_user_tag(p->info, "color", argv[0]->value.string);
+		camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set color to %s", argv[0]->value.string);
 	}
 
 	return NULL;
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index c88e413..5faa9e6 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -50,58 +50,73 @@
 #define d(x)
 #define w(x)
 
-static gboolean refresh_info (CamelFolder *folder, GError **error);
+G_DEFINE_ABSTRACT_TYPE (CamelFolder, camel_folder, CAMEL_TYPE_OBJECT)
 
-static const gchar *get_name (CamelFolder *folder);
-static const gchar *get_full_name (CamelFolder *folder);
-static CamelStore *get_parent_store   (CamelFolder *folder);
+/* Forward Declarations */
+static gboolean folder_changed (CamelObject *object, gpointer event_data);
 
-static guint32 get_permanent_flags (CamelFolder *folder);
-static guint32 get_message_flags (CamelFolder *folder, const gchar *uid);
-static gboolean set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set);
-static gboolean get_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name);
-static void set_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value);
-static const gchar *get_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name);
-static void set_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value);
+static gint
+cmp_array_uids (gconstpointer a,
+                gconstpointer b,
+                gpointer user_data)
+{
+	const gchar *uid1 = *(const gchar **) a;
+	const gchar *uid2 = *(const gchar **) b;
+	CamelFolder *folder = user_data;
 
-static gint get_message_count (CamelFolder *folder);
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
 
-static gint folder_getv (CamelObject *object, GError **error, CamelArgGetV *args);
-static void folder_free (CamelObject *o, guint32 tag, gpointer val);
+	return camel_folder_cmp_uids (folder, uid1, uid2);
+}
 
-static GPtrArray        *get_uids            (CamelFolder *folder);
-static GPtrArray	*get_uncached_uids   (CamelFolder *, GPtrArray * uids, GError **);
-static void              free_uids           (CamelFolder *folder,
-					      GPtrArray *array);
-static gint cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2);
-static void              sort_uids           (CamelFolder *folder,
-					      GPtrArray *uids);
-static GPtrArray        *get_summary         (CamelFolder *folder);
-static void              free_summary        (CamelFolder *folder,
-					      GPtrArray *array);
+static void
+folder_transfer_message_to (CamelFolder *source,
+                            const gchar *uid,
+                            CamelFolder *dest,
+                            gchar **transferred_uid,
+                            gboolean delete_original,
+                            GError **error)
+{
+	CamelMimeMessage *msg;
+	CamelMessageInfo *minfo, *info;
+	GError *local_error = NULL;
 
-static CamelMessageInfo *get_message_info    (CamelFolder *folder, const gchar *uid);
-static void		 free_message_info   (CamelFolder *folder, CamelMessageInfo *info);
-static void		 ref_message_info    (CamelFolder *folder, CamelMessageInfo *info);
+	/* Default implementation. */
 
-static void            search_free           (CamelFolder * folder, GPtrArray *result);
+	msg = camel_folder_get_message (source, uid, error);
+	if (!msg)
+		return;
 
-static gboolean        transfer_messages_to  (CamelFolder *source, GPtrArray *uids, CamelFolder *dest,
-					      GPtrArray **transferred_uids, gboolean delete_originals, GError **error);
+	/* if its deleted we poke the flags, so we need to copy the messageinfo */
+	if ((source->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY)
+			&& (minfo = camel_folder_get_message_info (source, uid))) {
+		info = camel_message_info_clone (minfo);
+		camel_folder_free_message_info (source, minfo);
+	} else {
+		CamelMimePart *mime_part;
+		GQueue *header_queue;
 
-static void            delete                (CamelFolder *folder);
-static void            folder_rename         (CamelFolder *folder, const gchar *new);
+		mime_part = CAMEL_MIME_PART (msg);
+		header_queue = camel_mime_part_get_raw_headers (mime_part);
+		info = camel_message_info_new_from_header (NULL, header_queue);
+	}
 
-static void            freeze                (CamelFolder *folder);
-static void            thaw                  (CamelFolder *folder);
-static gboolean        is_frozen             (CamelFolder *folder);
+	/* we don't want to retain the deleted flag */
+	camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 0);
 
-static gboolean        folder_changed        (CamelObject *object,
-					      gpointer event_data);
+	camel_folder_append_message (
+		dest, msg, info, transferred_uid, &local_error);
+	g_object_unref (msg);
 
-static CamelFolderQuotaInfo *get_quota_info  (CamelFolder *folder);
+	if (local_error != NULL)
+		g_propagate_error (error, local_error);
+	else if (delete_original)
+		camel_folder_set_message_flags (
+			source, uid, CAMEL_MESSAGE_DELETED |
+			CAMEL_MESSAGE_SEEN, ~0);
 
-G_DEFINE_ABSTRACT_TYPE (CamelFolder, camel_folder, CAMEL_TYPE_OBJECT)
+	camel_message_info_free (info);
+}
 
 static void
 folder_dispose (GObject *object)
@@ -147,204 +162,6 @@ folder_finalize (GObject *object)
 	G_OBJECT_CLASS (camel_folder_parent_class)->finalize (object);
 }
 
-static void
-camel_folder_class_init (CamelFolderClass *class)
-{
-	GObjectClass *object_class;
-	CamelObjectClass *camel_object_class;
-
-	g_type_class_add_private (class, sizeof (CamelFolderPrivate));
-
-	object_class = G_OBJECT_CLASS (class);
-	object_class->dispose = folder_dispose;
-	object_class->finalize = folder_finalize;
-
-	camel_object_class = CAMEL_OBJECT_CLASS (class);
-	camel_object_class->getv = folder_getv;
-	camel_object_class->free = folder_free;
-
-	class->refresh_info = refresh_info;
-	class->get_name = get_name;
-	class->get_full_name = get_full_name;
-	class->get_parent_store = get_parent_store;
-	class->get_message_count = get_message_count;
-	class->get_permanent_flags = get_permanent_flags;
-	class->get_message_flags = get_message_flags;
-	class->set_message_flags = set_message_flags;
-	class->get_message_user_flag = get_message_user_flag;
-	class->set_message_user_flag = set_message_user_flag;
-	class->get_message_user_tag = get_message_user_tag;
-	class->set_message_user_tag = set_message_user_tag;
-	class->get_uids = get_uids;
-	class->get_uncached_uids = get_uncached_uids;
-	class->free_uids = free_uids;
-	class->cmp_uids = cmp_uids;
-	class->sort_uids = sort_uids;
-	class->get_summary = get_summary;
-	class->free_summary = free_summary;
-	class->search_free = search_free;
-	class->get_message_info = get_message_info;
-	class->ref_message_info = ref_message_info;
-	class->free_message_info = free_message_info;
-	class->transfer_messages_to = transfer_messages_to;
-	class->delete = delete;
-	class->rename = folder_rename;
-	class->freeze = freeze;
-	class->sync_message = NULL;
-	class->thaw = thaw;
-	class->is_frozen = is_frozen;
-	class->get_quota_info = get_quota_info;
-
-	camel_object_class_add_event (
-		camel_object_class, "folder_changed", folder_changed);
-	camel_object_class_add_event (
-		camel_object_class, "deleted", NULL);
-	camel_object_class_add_event (
-		camel_object_class, "renamed", NULL);
-}
-
-static void
-camel_folder_init (CamelFolder *folder)
-{
-	folder->priv = CAMEL_FOLDER_GET_PRIVATE (folder);
-
-	folder->priv->frozen = 0;
-	folder->priv->changed_frozen = camel_folder_change_info_new ();
-
-	g_static_rec_mutex_init (&folder->priv->lock);
-	g_static_mutex_init (&folder->priv->change_lock);
-}
-
-GQuark
-camel_folder_error_quark (void)
-{
-	static GQuark quark = 0;
-
-	if (G_UNLIKELY (quark == 0)) {
-		const gchar *string = "camel-folder-error-quark";
-		quark = g_quark_from_static_string (string);
-	}
-
-	return quark;
-}
-
-/**
- * camel_folder_get_filename:
- *
- * Since: 2.26
- **/
-gchar *
-camel_folder_get_filename (CamelFolder *folder,
-                           const gchar *uid,
-                           GError **error)
-{
-	CamelFolderClass *class;
-
-	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
-
-	class = CAMEL_FOLDER_GET_CLASS (folder);
-	g_return_val_if_fail (class->get_filename != NULL, NULL);
-
-	return class->get_filename (folder, uid, error);
-}
-
-/**
- * camel_folder_construct:
- * @folder: a #CamelFolder object to construct
- * @parent_store: parent #CamelStore object of the folder
- * @full_name: full name of the folder
- * @name: short name of the folder
- *
- * Initalizes the folder by setting the parent store and name.
- **/
-void
-camel_folder_construct (CamelFolder *folder, CamelStore *parent_store,
-			const gchar *full_name, const gchar *name)
-{
-	g_return_if_fail (CAMEL_IS_FOLDER (folder));
-	g_return_if_fail (CAMEL_IS_STORE (parent_store));
-	g_return_if_fail (folder->parent_store == NULL);
-	g_return_if_fail (folder->name == NULL);
-
-	folder->parent_store = parent_store;
-	if (parent_store)
-		g_object_ref (parent_store);
-
-	folder->name = g_strdup (name);
-	folder->full_name = g_strdup (full_name);
-}
-
-/**
- * camel_folder_sync:
- * @folder: a #CamelFolder object
- * @expunge: whether or not to expunge deleted messages
- * @error: return location for a #GError, or %NULL
- *
- * Sync changes made to a folder to its backing store, possibly
- * expunging deleted messages as well.
- *
- * Returns: %TRUE on success, %FALSE on failure
- **/
-gboolean
-camel_folder_sync (CamelFolder *folder,
-                   gboolean expunge,
-                   GError **error)
-{
-	CamelFolderClass *class;
-	gboolean success = TRUE;
-
-	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
-
-	class = CAMEL_FOLDER_GET_CLASS (folder);
-	g_return_val_if_fail (class->sync != NULL, FALSE);
-
-	CAMEL_FOLDER_REC_LOCK (folder, lock);
-
-	if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
-		success = class->sync (folder, expunge, error);
-
-	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
-
-	return success;
-}
-
-static gboolean
-refresh_info (CamelFolder *folder,
-              GError **error)
-{
-	return TRUE;
-}
-
-/**
- * camel_folder_refresh_info:
- * @folder: a #CamelFolder object
- * @error: return location for a #GError, or %NULL
- *
- * Updates a folder's summary to be in sync with its backing store.
- *
- * Returns: %TRUE on success, %FALSE on failure
- **/
-gboolean
-camel_folder_refresh_info (CamelFolder *folder,
-                           GError **error)
-{
-	CamelFolderClass *class;
-	gboolean success;
-
-	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
-
-	class = CAMEL_FOLDER_GET_CLASS (folder);
-	g_return_val_if_fail (class->refresh_info != NULL, FALSE);
-
-	CAMEL_FOLDER_REC_LOCK (folder, lock);
-
-	success = class->refresh_info (folder, error);
-
-	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
-
-	return success;
-}
-
 static gint
 folder_getv (CamelObject *object,
              GError **error,
@@ -474,7 +291,7 @@ folder_getv (CamelObject *object,
 			}
 			*arg->ca_ptr = array;*/
 			/* WTH this is reqd ?, let it crash to find out who uses this */
-			g_assert (0);
+			g_assert_not_reached ();
 			break; }
 		case CAMEL_FOLDER_ARG_INFO_ARRAY:
 			*arg->ca_ptr = camel_folder_summary_array (folder->summary);
@@ -493,9 +310,11 @@ folder_getv (CamelObject *object,
 }
 
 static void
-folder_free (CamelObject *o, guint32 tag, gpointer val)
+folder_free (CamelObject *object,
+             guint32 tag,
+             gpointer val)
 {
-	CamelFolder *folder = (CamelFolder *)o;
+	CamelFolder *folder = (CamelFolder *)object;
 
 	switch (tag & CAMEL_ARG_TAG) {
 	case CAMEL_FOLDER_ARG_UID_ARRAY: {
@@ -513,19 +332,615 @@ folder_free (CamelObject *o, guint32 tag, gpointer val)
 		g_slist_free (val);
 		break;
 	default:
-		CAMEL_OBJECT_CLASS (camel_folder_parent_class)->free (o, tag, val);
+		CAMEL_OBJECT_CLASS (camel_folder_parent_class)->free (object, tag, val);
 	}
 }
 
+static gboolean
+folder_refresh_info (CamelFolder *folder,
+                     GError **error)
+{
+	return TRUE;
+}
+
 static const gchar *
-get_name (CamelFolder *folder)
+folder_get_name (CamelFolder *folder)
 {
 	return folder->name;
 }
 
+static const gchar *
+folder_get_full_name (CamelFolder *folder)
+{
+	return folder->full_name;
+}
+
+static CamelStore *
+folder_get_parent_store (CamelFolder * folder)
+{
+	return folder->parent_store;
+}
+
+static gint
+folder_get_message_count (CamelFolder *folder)
+{
+	g_return_val_if_fail (folder->summary != NULL, -1);
+
+	return camel_folder_summary_count (folder->summary);
+}
+
+static guint32
+folder_get_permanent_flags (CamelFolder *folder)
+{
+	return folder->permanent_flags;
+}
+
+static guint32
+folder_get_message_flags (CamelFolder *folder,
+                          const gchar *uid)
+{
+	CamelMessageInfo *info;
+	guint32 flags;
+
+	g_return_val_if_fail (folder->summary != NULL, 0);
+
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return 0;
+
+	flags = camel_message_info_flags (info);
+	camel_message_info_free (info);
+
+	return flags;
+}
+
+static gboolean
+folder_set_message_flags (CamelFolder *folder,
+                          const gchar *uid,
+                          guint32 flags,
+                          guint32 set)
+{
+	CamelMessageInfo *info;
+	gint res;
+
+	g_return_val_if_fail (folder->summary != NULL, FALSE);
+
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return FALSE;
+
+	res = camel_message_info_set_flags (info, flags, set);
+	camel_message_info_free (info);
+
+	return res;
+}
+
+static gboolean
+folder_get_message_user_flag (CamelFolder *folder,
+                              const gchar *uid,
+                              const gchar *name)
+{
+	CamelMessageInfo *info;
+	gboolean ret;
+
+	g_return_val_if_fail (folder->summary != NULL, FALSE);
+
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return FALSE;
+
+	ret = camel_message_info_user_flag (info, name);
+	camel_message_info_free (info);
+
+	return ret;
+}
+
+static void
+folder_set_message_user_flag (CamelFolder *folder,
+                              const gchar *uid,
+                              const gchar *name,
+                              gboolean value)
+{
+	CamelMessageInfo *info;
+
+	g_return_if_fail (folder->summary != NULL);
+
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return;
+
+	camel_message_info_set_user_flag (info, name, value);
+	camel_message_info_free (info);
+}
+
+static const gchar *
+folder_get_message_user_tag (CamelFolder *folder,
+                             const gchar *uid,
+                             const gchar *name)
+{
+	CamelMessageInfo *info;
+	const gchar *ret;
+
+	g_return_val_if_fail (folder->summary != NULL, NULL);
+
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return NULL;
+
+	ret = camel_message_info_user_tag (info, name);
+	camel_message_info_free (info);
+
+	return ret;
+}
+
+static void
+folder_set_message_user_tag (CamelFolder *folder,
+                             const gchar *uid,
+                             const gchar *name,
+                             const gchar *value)
+{
+	CamelMessageInfo *info;
+
+	g_return_if_fail (folder->summary != NULL);
+
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return;
+
+	camel_message_info_set_user_tag (info, name, value);
+	camel_message_info_free (info);
+}
+
+static GPtrArray *
+folder_get_uids (CamelFolder *folder)
+{
+	g_return_val_if_fail (folder->summary != NULL, NULL);
+
+	return camel_folder_summary_array (folder->summary);
+}
+
+static GPtrArray *
+folder_get_uncached_uids (CamelFolder *folder,
+                          GPtrArray * uids,
+                          GError **error)
+{
+	GPtrArray *result;
+	gint i;
+
+	result = g_ptr_array_new ();
+
+	g_ptr_array_set_size (result, uids->len);
+	for (i = 0; i < uids->len; i++)
+		result->pdata[i] =
+			(gpointer) camel_pstring_strdup (uids->pdata[i]);
+
+	return result;
+}
+
+static void
+folder_free_uids (CamelFolder *folder,
+                  GPtrArray *array)
+{
+	gint i;
+
+	for (i=0; i<array->len; i++)
+		camel_pstring_free (array->pdata[i]);
+	g_ptr_array_free (array, TRUE);
+}
+
+static gint
+folder_cmp_uids (CamelFolder *folder,
+                 const gchar *uid1,
+                 const gchar *uid2)
+{
+	g_return_val_if_fail (uid1 != NULL, 0);
+	g_return_val_if_fail (uid2 != NULL, 0);
+
+	return strtoul (uid1, NULL, 10) - strtoul (uid2, NULL, 10);
+}
+
+static void
+folder_sort_uids (CamelFolder *folder,
+                  GPtrArray *uids)
+{
+	g_qsort_with_data (
+		uids->pdata, uids->len,
+		sizeof (gpointer), cmp_array_uids, folder);
+}
+
+static GPtrArray *
+folder_get_summary (CamelFolder *folder)
+{
+	g_return_val_if_fail (folder->summary != NULL, NULL);
+
+	return camel_folder_summary_array (folder->summary);
+}
+
+static void
+folder_free_summary (CamelFolder *folder,
+                     GPtrArray *summary)
+{
+	g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
+	g_ptr_array_free (summary, TRUE);
+}
+
+static void
+folder_search_free (CamelFolder *folder,
+                    GPtrArray *result)
+{
+	gint i;
+
+	for (i = 0; i < result->len; i++)
+		camel_pstring_free (g_ptr_array_index (result, i));
+	g_ptr_array_free (result, TRUE);
+}
+
+static CamelMessageInfo *
+folder_get_message_info (CamelFolder *folder,
+                         const gchar *uid)
+{
+	g_return_val_if_fail (folder->summary != NULL, NULL);
+
+	return camel_folder_summary_uid (folder->summary, uid);
+}
+
+static void
+folder_ref_message_info (CamelFolder *folder,
+                         CamelMessageInfo *info)
+{
+	g_return_if_fail (folder->summary != NULL);
+
+	camel_message_info_ref (info);
+}
+
+static void
+folder_free_message_info (CamelFolder *folder,
+                          CamelMessageInfo *info)
+{
+	g_return_if_fail (folder->summary != NULL);
+
+	camel_message_info_free (info);
+}
+
+static gboolean
+folder_transfer_messages_to (CamelFolder *source,
+                             GPtrArray *uids,
+                             CamelFolder *dest,
+                             GPtrArray **transferred_uids,
+                             gboolean delete_originals,
+                             GError **error)
+{
+	gchar **ret_uid = NULL;
+	gint i;
+	GError *local_error = NULL;
+
+	if (transferred_uids) {
+		*transferred_uids = g_ptr_array_new ();
+		g_ptr_array_set_size (*transferred_uids, uids->len);
+	}
+
+	if (delete_originals)
+		camel_operation_start (NULL, _("Moving messages"));
+	else
+		camel_operation_start (NULL, _("Copying messages"));
+
+	if (uids->len > 1) {
+		camel_folder_freeze (dest);
+		if (delete_originals)
+			camel_folder_freeze (source);
+	}
+
+	for (i = 0; i < uids->len && local_error != NULL; i++) {
+		if (transferred_uids)
+			ret_uid = (gchar **)&((*transferred_uids)->pdata[i]);
+		folder_transfer_message_to (
+			source, uids->pdata[i], dest, ret_uid,
+			delete_originals, &local_error);
+		camel_operation_progress (NULL, i * 100 / uids->len);
+	}
+
+	if (uids->len > 1) {
+		camel_folder_thaw (dest);
+		if (delete_originals)
+			camel_folder_thaw (source);
+	}
+
+	camel_operation_end (NULL);
+
+	if (local_error != NULL)
+		g_propagate_error (error, local_error);
+
+	return TRUE;
+}
+
+static void
+folder_delete (CamelFolder *folder)
+{
+	if (folder->summary)
+		camel_folder_summary_clear (folder->summary);
+}
+
+static void
+folder_rename (CamelFolder *folder,
+               const gchar *new)
+{
+	gchar *tmp;
+
+	d (printf ("CamelFolder:rename ('%s')\n", new));
+
+	g_free (folder->full_name);
+	folder->full_name = g_strdup (new);
+	g_free (folder->name);
+	tmp = strrchr (new, '/');
+	folder->name = g_strdup (tmp?tmp+1:new);
+}
+
+static void
+folder_freeze (CamelFolder *folder)
+{
+	g_return_if_fail (folder->priv->frozen >= 0);
+
+	CAMEL_FOLDER_LOCK (folder, change_lock);
+
+	folder->priv->frozen++;
+
+	d (printf ("freeze (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
+	CAMEL_FOLDER_UNLOCK (folder, change_lock);
+}
+
+static void
+folder_thaw (CamelFolder * folder)
+{
+	CamelFolderChangeInfo *info = NULL;
+
+	g_return_if_fail (folder->priv->frozen > 0);
+
+	CAMEL_FOLDER_LOCK (folder, change_lock);
+
+	folder->priv->frozen--;
+
+	d (printf ("thaw (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
+
+	if (folder->priv->frozen == 0
+	    && camel_folder_change_info_changed (folder->priv->changed_frozen)) {
+		info = folder->priv->changed_frozen;
+		folder->priv->changed_frozen = camel_folder_change_info_new ();
+	}
+
+	CAMEL_FOLDER_UNLOCK (folder, change_lock);
+
+	if (info) {
+		camel_object_trigger_event (folder, "folder_changed", info);
+		camel_folder_change_info_free (info);
+	}
+}
+
+static gboolean
+folder_is_frozen (CamelFolder *folder)
+{
+	return folder->priv->frozen != 0;
+}
+
+static CamelFolderQuotaInfo *
+folder_get_quota_info (CamelFolder *folder)
+{
+	return NULL;
+}
+
+static void
+camel_folder_class_init (CamelFolderClass *class)
+{
+	GObjectClass *object_class;
+	CamelObjectClass *camel_object_class;
+
+	g_type_class_add_private (class, sizeof (CamelFolderPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = folder_dispose;
+	object_class->finalize = folder_finalize;
+
+	camel_object_class = CAMEL_OBJECT_CLASS (class);
+	camel_object_class->getv = folder_getv;
+	camel_object_class->free = folder_free;
+
+	class->refresh_info = folder_refresh_info;
+	class->get_name = folder_get_name;
+	class->get_full_name = folder_get_full_name;
+	class->get_parent_store = folder_get_parent_store;
+	class->get_message_count = folder_get_message_count;
+	class->get_permanent_flags = folder_get_permanent_flags;
+	class->get_message_flags = folder_get_message_flags;
+	class->set_message_flags = folder_set_message_flags;
+	class->get_message_user_flag = folder_get_message_user_flag;
+	class->set_message_user_flag = folder_set_message_user_flag;
+	class->get_message_user_tag = folder_get_message_user_tag;
+	class->set_message_user_tag = folder_set_message_user_tag;
+	class->get_uids = folder_get_uids;
+	class->get_uncached_uids = folder_get_uncached_uids;
+	class->free_uids = folder_free_uids;
+	class->cmp_uids = folder_cmp_uids;
+	class->sort_uids = folder_sort_uids;
+	class->get_summary = folder_get_summary;
+	class->free_summary = folder_free_summary;
+	class->search_free = folder_search_free;
+	class->get_message_info = folder_get_message_info;
+	class->ref_message_info = folder_ref_message_info;
+	class->free_message_info = folder_free_message_info;
+	class->transfer_messages_to = folder_transfer_messages_to;
+	class->delete = folder_delete;
+	class->rename = folder_rename;
+	class->freeze = folder_freeze;
+	class->thaw = folder_thaw;
+	class->is_frozen = folder_is_frozen;
+	class->get_quota_info = folder_get_quota_info;
+
+	camel_object_class_add_event (
+		camel_object_class, "folder_changed", folder_changed);
+	camel_object_class_add_event (
+		camel_object_class, "deleted", NULL);
+	camel_object_class_add_event (
+		camel_object_class, "renamed", NULL);
+}
+
+static void
+camel_folder_init (CamelFolder *folder)
+{
+	folder->priv = CAMEL_FOLDER_GET_PRIVATE (folder);
+
+	folder->priv->frozen = 0;
+	folder->priv->changed_frozen = camel_folder_change_info_new ();
+
+	g_static_rec_mutex_init (&folder->priv->lock);
+	g_static_mutex_init (&folder->priv->change_lock);
+}
+
+GQuark
+camel_folder_error_quark (void)
+{
+	static GQuark quark = 0;
+
+	if (G_UNLIKELY (quark == 0)) {
+		const gchar *string = "camel-folder-error-quark";
+		quark = g_quark_from_static_string (string);
+	}
+
+	return quark;
+}
+
+/**
+ * camel_folder_set_lock_async:
+ * @folder: a #CamelFolder
+ * @skip_folder_lock:
+ *
+ * FIXME Document me!
+ *
+ * Since: 2.30
+ **/
+void
+camel_folder_set_lock_async (CamelFolder *folder,
+                             gboolean skip_folder_lock)
+{
+	g_return_if_fail (CAMEL_IS_FOLDER (folder));
+
+	folder->priv->skip_folder_lock = skip_folder_lock;
+}
+
+/**
+ * camel_folder_get_filename:
+ *
+ * Since: 2.26
+ **/
+gchar *
+camel_folder_get_filename (CamelFolder *folder,
+                           const gchar *uid,
+                           GError **error)
+{
+	CamelFolderClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+	g_return_val_if_fail (uid != NULL, NULL);
+
+	class = CAMEL_FOLDER_GET_CLASS (folder);
+	g_return_val_if_fail (class->get_filename != NULL, NULL);
+
+	return class->get_filename (folder, uid, error);
+}
+
+/**
+ * camel_folder_construct:
+ * @folder: a #CamelFolder to construct
+ * @parent_store: parent #CamelStore object of the folder
+ * @full_name: full name of the folder
+ * @name: short name of the folder
+ *
+ * Initalizes the folder by setting the parent store and name.
+ **/
+void
+camel_folder_construct (CamelFolder *folder,
+                        CamelStore *parent_store,
+                        const gchar *full_name,
+                        const gchar *name)
+{
+	g_return_if_fail (CAMEL_IS_FOLDER (folder));
+	g_return_if_fail (CAMEL_IS_STORE (parent_store));
+	g_return_if_fail (folder->parent_store == NULL);
+	g_return_if_fail (folder->name == NULL);
+
+	folder->parent_store = parent_store;
+	if (parent_store)
+		g_object_ref (parent_store);
+
+	folder->name = g_strdup (name);
+	folder->full_name = g_strdup (full_name);
+}
+
+/**
+ * camel_folder_sync:
+ * @folder: a #CamelFolder
+ * @expunge: whether or not to expunge deleted messages
+ * @error: return location for a #GError, or %NULL
+ *
+ * Sync changes made to a folder to its backing store, possibly
+ * expunging deleted messages as well.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
+ **/
+gboolean
+camel_folder_sync (CamelFolder *folder,
+                   gboolean expunge,
+                   GError **error)
+{
+	CamelFolderClass *class;
+	gboolean success = TRUE;
+
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+
+	class = CAMEL_FOLDER_GET_CLASS (folder);
+	g_return_val_if_fail (class->sync != NULL, FALSE);
+
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
+
+	if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
+		success = class->sync (folder, expunge, error);
+
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+	return success;
+}
+
+/**
+ * camel_folder_refresh_info:
+ * @folder: a #CamelFolder
+ * @error: return location for a #GError, or %NULL
+ *
+ * Updates a folder's summary to be in sync with its backing store.
+ *
+ * Returns: %TRUE on success, %FALSE on failure
+ **/
+gboolean
+camel_folder_refresh_info (CamelFolder *folder,
+                           GError **error)
+{
+	CamelFolderClass *class;
+	gboolean success;
+
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+
+	class = CAMEL_FOLDER_GET_CLASS (folder);
+	g_return_val_if_fail (class->refresh_info != NULL, FALSE);
+
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
+
+	success = class->refresh_info (folder, error);
+
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
+
+	return success;
+}
+
 /**
  * camel_folder_get_name:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Get the (short) name of the folder. The fully qualified name
  * can be obtained with the #camel_folder_get_full_name method.
@@ -545,15 +960,9 @@ camel_folder_get_name (CamelFolder *folder)
 	return class->get_name (folder);
 }
 
-static const gchar *
-get_full_name (CamelFolder *folder)
-{
-	return folder->full_name;
-}
-
 /**
  * camel_folder_get_full_name:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Get the full name of the folder.
  *
@@ -572,15 +981,9 @@ camel_folder_get_full_name (CamelFolder *folder)
 	return class->get_full_name (folder);
 }
 
-static CamelStore *
-get_parent_store (CamelFolder * folder)
-{
-	return folder->parent_store;
-}
-
 /**
  * camel_folder_get_parent_store:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Returns: the parent #CamelStore of the folder
  **/
@@ -599,7 +1002,7 @@ camel_folder_get_parent_store (CamelFolder *folder)
 
 /**
  * camel_folder_expunge:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @error: return location for a #GError, or %NULL
  *
  * Delete messages which have been marked as "DELETED"
@@ -628,17 +1031,9 @@ camel_folder_expunge (CamelFolder *folder,
 	return success;
 }
 
-static gint
-get_message_count (CamelFolder *folder)
-{
-	g_return_val_if_fail (folder->summary != NULL, -1);
-
-	return camel_folder_summary_count (folder->summary);
-}
-
 /**
  * camel_folder_get_message_count:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Returns: the number of messages in the folder, or %-1 if unknown
  **/
@@ -657,7 +1052,7 @@ camel_folder_get_message_count (CamelFolder *folder)
 
 /**
  * camel_folder_get_unread_message_count:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * DEPRECATED: use #camel_object_get instead.
  *
@@ -678,7 +1073,7 @@ camel_folder_get_unread_message_count (CamelFolder *folder)
 
 /**
  * camel_folder_get_deleted_message_count:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Returns: the number of deleted messages in the folder, or %-1 if
  * unknown
@@ -697,7 +1092,7 @@ camel_folder_get_deleted_message_count (CamelFolder *folder)
 
 /**
  * camel_folder_append_message:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @message: a #CamelMimeMessage object
  * @info: a #CamelMessageInfo with additional flags/etc to set on
  * new message, or %NULL
@@ -735,15 +1130,9 @@ camel_folder_append_message (CamelFolder *folder,
 	return success;
 }
 
-static guint32
-get_permanent_flags (CamelFolder *folder)
-{
-	return folder->permanent_flags;
-}
-
 /**
  * camel_folder_get_permanent_flags:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Returns: the set of #CamelMessageFlags that can be permanently
  * stored on a message between sessions. If it includes
@@ -762,27 +1151,9 @@ camel_folder_get_permanent_flags (CamelFolder *folder)
 	return class->get_permanent_flags (folder);
 }
 
-static guint32
-get_message_flags (CamelFolder *folder, const gchar *uid)
-{
-	CamelMessageInfo *info;
-	guint32 flags;
-
-	g_return_val_if_fail (folder->summary != NULL, 0);
-
-	info = camel_folder_summary_uid (folder->summary, uid);
-	if (info == NULL)
-		return 0;
-
-	flags = camel_message_info_flags (info);
-	camel_message_info_free (info);
-
-	return flags;
-}
-
 /**
  * camel_folder_get_message_flags:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID of a message in @folder
  *
  * Deprecated: Use #camel_folder_get_message_info instead.
@@ -805,27 +1176,9 @@ camel_folder_get_message_flags (CamelFolder *folder,
 	return class->get_message_flags (folder, uid);
 }
 
-static gboolean
-set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set)
-{
-	CamelMessageInfo *info;
-	gint res;
-
-	g_return_val_if_fail (folder->summary != NULL, FALSE);
-
-	info = camel_folder_summary_uid (folder->summary, uid);
-	if (info == NULL)
-		return FALSE;
-
-	res = camel_message_info_set_flags (info, flags, set);
-	camel_message_info_free (info);
-
-	return res;
-}
-
 /**
  * camel_folder_set_message_flags:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID of a message in @folder
  * @flags: a set of #CamelMessageFlag values to set
  * @set: the mask of values in @flags to use.
@@ -864,27 +1217,9 @@ camel_folder_set_message_flags (CamelFolder *folder,
 	return class->set_message_flags (folder, uid, flags, set);
 }
 
-static gboolean
-get_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name)
-{
-	CamelMessageInfo *info;
-	gboolean ret;
-
-	g_return_val_if_fail (folder->summary != NULL, FALSE);
-
-	info = camel_folder_summary_uid (folder->summary, uid);
-	if (info == NULL)
-		return FALSE;
-
-	ret = camel_message_info_user_flag (info, name);
-	camel_message_info_free (info);
-
-	return ret;
-}
-
 /**
  * camel_folder_get_message_user_flag:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID of a message in @folder
  * @name: the name of a user flag
  *
@@ -911,24 +1246,9 @@ camel_folder_get_message_user_flag (CamelFolder *folder,
 	return class->get_message_user_flag (folder, uid, name);
 }
 
-static void
-set_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value)
-{
-	CamelMessageInfo *info;
-
-	g_return_if_fail (folder->summary != NULL);
-
-	info = camel_folder_summary_uid (folder->summary, uid);
-	if (info == NULL)
-		return;
-
-	camel_message_info_set_user_flag (info, name, value);
-	camel_message_info_free (info);
-}
-
 /**
  * camel_folder_set_message_user_flag:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID of a message in @folder
  * @name: the name of the user flag to set
  * @value: the value to set it to
@@ -958,27 +1278,9 @@ camel_folder_set_message_user_flag (CamelFolder *folder,
 	class->set_message_user_flag (folder, uid, name, value);
 }
 
-static const gchar *
-get_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name)
-{
-	CamelMessageInfo *info;
-	const gchar *ret;
-
-	g_return_val_if_fail (folder->summary != NULL, NULL);
-
-	info = camel_folder_summary_uid (folder->summary, uid);
-	if (info == NULL)
-		return NULL;
-
-	ret = camel_message_info_user_tag (info, name);
-	camel_message_info_free (info);
-
-	return ret;
-}
-
 /**
  * camel_folder_get_message_user_tag:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID of a message in @folder
  * @name: the name of a user tag
  *
@@ -1005,24 +1307,9 @@ camel_folder_get_message_user_tag (CamelFolder *folder,
 	return class->get_message_user_tag (folder, uid, name);
 }
 
-static void
-set_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value)
-{
-	CamelMessageInfo *info;
-
-	g_return_if_fail (folder->summary != NULL);
-
-	info = camel_folder_summary_uid (folder->summary, uid);
-	if (info == NULL)
-		return;
-
-	camel_message_info_set_user_tag (info, name, value);
-	camel_message_info_free (info);
-}
-
 /**
  * camel_folder_set_message_user_tag:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID of a message in @folder
  * @name: the name of the user tag to set
  * @value: the value to set it to
@@ -1052,17 +1339,9 @@ camel_folder_set_message_user_tag (CamelFolder *folder,
 	class->set_message_user_tag (folder, uid, name, value);
 }
 
-static CamelMessageInfo *
-get_message_info (CamelFolder *folder, const gchar *uid)
-{
-	g_return_val_if_fail (folder->summary != NULL, NULL);
-
-	return camel_folder_summary_uid (folder->summary, uid);
-}
-
 /**
  * camel_folder_get_message_info:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the uid of a message
  *
  * Retrieve the #CamelMessageInfo for the specified @uid.  This return
@@ -1086,17 +1365,9 @@ camel_folder_get_message_info (CamelFolder *folder,
 	return class->get_message_info (folder, uid);
 }
 
-static void
-free_message_info (CamelFolder *folder, CamelMessageInfo *info)
-{
-	g_return_if_fail (folder->summary != NULL);
-
-	camel_message_info_free (info);
-}
-
 /**
  * camel_folder_free_message_info:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @info: a #CamelMessageInfo
  *
  * Free (unref) a #CamelMessageInfo, previously obtained with
@@ -1117,17 +1388,9 @@ camel_folder_free_message_info (CamelFolder *folder,
 	class->free_message_info (folder, info);
 }
 
-static void
-ref_message_info (CamelFolder *folder, CamelMessageInfo *info)
-{
-	g_return_if_fail (folder->summary != NULL);
-
-	camel_message_info_ref (info);
-}
-
 /**
  * camel_folder_ref_message_info:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @info: a #CamelMessageInfo
  *
  * DEPRECATED: Use #camel_message_info_ref directly.
@@ -1153,7 +1416,7 @@ camel_folder_ref_message_info (CamelFolder *folder,
 /* TODO: is this function required anyway? */
 /**
  * camel_folder_has_summary_capability:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Get whether or not the folder has a summary.
  *
@@ -1171,7 +1434,7 @@ camel_folder_has_summary_capability (CamelFolder *folder)
 
 /**
  * camel_folder_get_message:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID
  * @error: return location for a #GError, or %NULL
  *
@@ -1184,13 +1447,18 @@ camel_folder_get_message (CamelFolder *folder,
                           const gchar *uid,
                           GError **error)
 {
+	CamelFolderClass *class;
 	CamelMimeMessage *ret;
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+	g_return_val_if_fail (uid != NULL, NULL);
+
+	class = CAMEL_FOLDER_GET_CLASS (folder);
+	g_return_val_if_fail (class->get_message != NULL, NULL);
 
 	CAMEL_FOLDER_REC_LOCK (folder, lock);
 
-	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message (folder, uid, error);
+	ret = class->get_message (folder, uid, error);
 
 	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 
@@ -1205,7 +1473,7 @@ camel_folder_get_message (CamelFolder *folder,
 
 /**
  * camel_folder_sync_message:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid: the UID
  * @error: return location for a #GError, or %NULL
  *
@@ -1247,17 +1515,9 @@ camel_folder_sync_message (CamelFolder *folder,
 	return success;
 }
 
-static GPtrArray *
-get_uids (CamelFolder *folder)
-{
-	g_return_val_if_fail (folder->summary != NULL, g_ptr_array_new ());
-
-	return camel_folder_summary_array (folder->summary);
-}
-
 /**
  * camel_folder_get_uids:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Get the list of UIDs available in a folder. This routine is useful
  * for finding what messages are available when the folder does not
@@ -1280,19 +1540,9 @@ camel_folder_get_uids (CamelFolder *folder)
 	return class->get_uids (folder);
 }
 
-static void
-free_uids (CamelFolder *folder, GPtrArray *array)
-{
-	gint i;
-
-	for (i=0; i<array->len; i++)
-		camel_pstring_free (array->pdata[i]);
-	g_ptr_array_free (array, TRUE);
-}
-
 /**
  * camel_folder_free_uids:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @array: the array of uids to free
  *
  * Frees the array of UIDs returned by #camel_folder_get_uids.
@@ -1313,27 +1563,8 @@ camel_folder_free_uids (CamelFolder *folder,
 }
 
 /**
- * Default: return the uids we are given.
- */
-static GPtrArray *
-get_uncached_uids (CamelFolder *folder,
-                   GPtrArray * uids,
-                   GError **error)
-{
-	GPtrArray *result;
-	gint i;
-
-	result = g_ptr_array_new ();
-
-	g_ptr_array_set_size (result, uids->len);
-	for (i = 0; i < uids->len; i++)
-	    result->pdata[i] = (gchar *)camel_pstring_strdup (uids->pdata[i]);
-	return result;
-}
-
-/**
  * camel_folder_get_uncached_uids:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uids: the array of uids to filter down to uncached ones.
  *
  * Returns the known-uncached uids from a list of uids. It may return uids
@@ -1359,18 +1590,9 @@ camel_folder_get_uncached_uids (CamelFolder *folder,
 	return class->get_uncached_uids (folder, uids, error);
 }
 
-static gint
-cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2)
-{
-	g_return_val_if_fail (uid1 != NULL, 0);
-	g_return_val_if_fail (uid2 != NULL, 0);
-
-	return strtoul (uid1, NULL, 10) - strtoul (uid2, NULL, 10);
-}
-
 /**
  * camel_folder_cmp_uids:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uid1: The first uid.
  * @uid2: the second uid.
  *
@@ -1398,27 +1620,9 @@ camel_folder_cmp_uids (CamelFolder *folder,
 	return class->cmp_uids (folder, uid1, uid2);
 }
 
-static gint
-cmp_array_uids (gconstpointer a, gconstpointer b, gpointer user_data)
-{
-	const gchar *uid1 = *(const gchar **) a;
-	const gchar *uid2 = *(const gchar **) b;
-	CamelFolder *folder = user_data;
-
-	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
-
-	return camel_folder_cmp_uids (folder, uid1, uid2);
-}
-
-static void
-sort_uids (CamelFolder *folder, GPtrArray *uids)
-{
-	g_qsort_with_data (uids->pdata, uids->len, sizeof (gpointer), cmp_array_uids, folder);
-}
-
 /**
  * camel_folder_sort_uids:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @uids: array of uids
  *
  * Sorts the array of UIDs.
@@ -1440,17 +1644,9 @@ camel_folder_sort_uids (CamelFolder *folder,
 	class->sort_uids (folder, uids);
 }
 
-static GPtrArray *
-get_summary (CamelFolder *folder)
-{
-	g_assert (folder->summary != NULL);
-
-	return camel_folder_summary_array (folder->summary);
-}
-
 /**
  * camel_folder_get_summary:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * This returns the summary information for the folder. This array
  * should not be modified, and must be freed with
@@ -1471,16 +1667,9 @@ camel_folder_get_summary (CamelFolder *folder)
 	return class->get_summary (folder);
 }
 
-static void
-free_summary (CamelFolder *folder, GPtrArray *summary)
-{
-	g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
-	g_ptr_array_free (summary, TRUE);
-}
-
 /**
  * camel_folder_free_summary:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @array: the summary array to free
  *
  * Frees the summary array returned by #camel_folder_get_summary.
@@ -1502,7 +1691,7 @@ camel_folder_free_summary (CamelFolder *folder,
 
 /**
  * camel_folder_has_search_capability:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Checks if a folder supports searching.
  *
@@ -1518,7 +1707,7 @@ camel_folder_has_search_capability (CamelFolder *folder)
 
 /**
  * camel_folder_search_by_expression:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @expr: a search expression
  * @error: return location for a #GError, or %NULL
  *
@@ -1547,7 +1736,7 @@ camel_folder_search_by_expression (CamelFolder *folder,
 
 /**
  * camel_folder_count_by_expression:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @expr: a search expression
  * @error: return location for a #GError, or %NULL
  *
@@ -1577,7 +1766,7 @@ camel_folder_count_by_expression (CamelFolder *folder,
 
 /**
  * camel_folder_search_by_uids:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @expr: search expression
  * @uids: array of uid's to match against.
  * @error: return location for a #GError, or %NULL
@@ -1606,19 +1795,9 @@ camel_folder_search_by_uids (CamelFolder *folder,
 	return class->search_by_uids (folder, expr, uids, error);
 }
 
-static void
-search_free (CamelFolder *folder, GPtrArray *result)
-{
-	gint i;
-
-	for (i = 0; i < result->len; i++)
-		camel_pstring_free (g_ptr_array_index (result, i));
-	g_ptr_array_free (result, TRUE);
-}
-
 /**
  * camel_folder_search_free:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @result: search results to free
  *
  * Free the result of a search as gotten by #camel_folder_search or
@@ -1641,106 +1820,6 @@ camel_folder_search_free (CamelFolder *folder,
 	class->search_free (folder, result);
 }
 
-static void
-transfer_message_to (CamelFolder *source,
-                     const gchar *uid,
-                     CamelFolder *dest,
-                     gchar **transferred_uid,
-                     gboolean delete_original,
-                     GError **error)
-{
-	CamelMimeMessage *msg;
-	CamelMessageInfo *minfo, *info;
-	GError *local_error = NULL;
-
-	/* Default implementation. */
-
-	msg = camel_folder_get_message (source, uid, error);
-	if (!msg)
-		return;
-
-	/* if its deleted we poke the flags, so we need to copy the messageinfo */
-	if ((source->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY)
-			&& (minfo = camel_folder_get_message_info (source, uid))) {
-		info = camel_message_info_clone (minfo);
-		camel_folder_free_message_info (source, minfo);
-	} else {
-		CamelMimePart *mime_part;
-		GQueue *header_queue;
-
-		mime_part = CAMEL_MIME_PART (msg);
-		header_queue = camel_mime_part_get_raw_headers (mime_part);
-		info = camel_message_info_new_from_header (NULL, header_queue);
-	}
-
-	/* we don't want to retain the deleted flag */
-	camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 0);
-
-	camel_folder_append_message (
-		dest, msg, info, transferred_uid, &local_error);
-	g_object_unref (msg);
-
-	if (local_error != NULL)
-		g_propagate_error (error, local_error);
-	else if (delete_original)
-		camel_folder_set_message_flags (
-			source, uid, CAMEL_MESSAGE_DELETED |
-			CAMEL_MESSAGE_SEEN, ~0);
-
-	camel_message_info_free (info);
-}
-
-static gboolean
-transfer_messages_to (CamelFolder *source,
-                      GPtrArray *uids,
-                      CamelFolder *dest,
-                      GPtrArray **transferred_uids,
-                      gboolean delete_originals,
-                      GError **error)
-{
-	gchar **ret_uid = NULL;
-	gint i;
-	GError *local_error = NULL;
-
-	if (transferred_uids) {
-		*transferred_uids = g_ptr_array_new ();
-		g_ptr_array_set_size (*transferred_uids, uids->len);
-	}
-
-	if (delete_originals)
-		camel_operation_start (NULL, _("Moving messages"));
-	else
-		camel_operation_start (NULL, _("Copying messages"));
-
-	if (uids->len > 1) {
-		camel_folder_freeze (dest);
-		if (delete_originals)
-			camel_folder_freeze (source);
-	}
-
-	for (i = 0; i < uids->len && local_error != NULL; i++) {
-		if (transferred_uids)
-			ret_uid = (gchar **)&((*transferred_uids)->pdata[i]);
-		transfer_message_to (
-			source, uids->pdata[i], dest, ret_uid,
-			delete_originals, &local_error);
-		camel_operation_progress (NULL, i * 100 / uids->len);
-	}
-
-	if (uids->len > 1) {
-		camel_folder_thaw (dest);
-		if (delete_originals)
-			camel_folder_thaw (source);
-	}
-
-	camel_operation_end (NULL);
-
-	if (local_error != NULL)
-		g_propagate_error (error, local_error);
-
-	return TRUE;
-}
-
 /**
  * camel_folder_transfer_messages_to:
  * @source: the source #CamelFolder object
@@ -1769,8 +1848,8 @@ camel_folder_transfer_messages_to (CamelFolder *source,
 	gboolean success;
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (source), FALSE);
-	g_return_val_if_fail (uids != NULL, FALSE);
 	g_return_val_if_fail (CAMEL_IS_FOLDER (dest), FALSE);
+	g_return_val_if_fail (uids != NULL, FALSE);
 
 	if (source == dest || uids->len == 0) {
 		/* source and destination folders are the same, or no work to do, do nothing. */
@@ -1779,8 +1858,7 @@ camel_folder_transfer_messages_to (CamelFolder *source,
 
 	if (source->parent_store == dest->parent_store) {
 		/* If either folder is a vtrash, we need to use the
-		 * vtrash transfer method.
-		 */
+		 * vtrash transfer method. */
 		if (CAMEL_IS_VTRASH_FOLDER (dest))
 			class = CAMEL_FOLDER_GET_CLASS (dest);
 		else
@@ -1789,23 +1867,16 @@ camel_folder_transfer_messages_to (CamelFolder *source,
 			source, uids, dest, transferred_uids,
 			delete_originals, error);
 	} else
-		success = transfer_messages_to (
+		success = folder_transfer_messages_to (
 			source, uids, dest, transferred_uids,
 			delete_originals, error);
 
 	return success;
 }
 
-static void
-delete (CamelFolder *folder)
-{
-	if (folder->summary)
-		camel_folder_summary_clear (folder->summary);
-}
-
 /**
  * camel_folder_delete:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Marks a folder object as deleted and performs any required cleanup.
  **/
@@ -1837,23 +1908,9 @@ camel_folder_delete (CamelFolder *folder)
 	camel_object_trigger_event (folder, "deleted", NULL);
 }
 
-static void
-folder_rename (CamelFolder *folder, const gchar *new)
-{
-	gchar *tmp;
-
-	d (printf ("CamelFolder:rename ('%s')\n", new));
-
-	g_free (folder->full_name);
-	folder->full_name = g_strdup (new);
-	g_free (folder->name);
-	tmp = strrchr (new, '/');
-	folder->name = g_strdup (tmp?tmp+1:new);
-}
-
 /**
  * camel_folder_rename:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @new: new name for the folder
  *
  * Mark an active folder object as renamed.
@@ -1883,19 +1940,6 @@ camel_folder_rename (CamelFolder *folder,
 	g_free (old);
 }
 
-static void
-freeze (CamelFolder *folder)
-{
-	CAMEL_FOLDER_LOCK (folder, change_lock);
-
-	g_assert (folder->priv->frozen >= 0);
-
-	folder->priv->frozen++;
-
-	d (printf ("freeze (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
-	CAMEL_FOLDER_UNLOCK (folder, change_lock);
-}
-
 /**
  * camel_folder_freeze:
  * @folder: a #CamelFolder
@@ -1906,7 +1950,7 @@ freeze (CamelFolder *folder)
  * be emitted.
  **/
 void
-camel_folder_freeze (CamelFolder * folder)
+camel_folder_freeze (CamelFolder *folder)
 {
 	CamelFolderClass *class;
 
@@ -1918,36 +1962,9 @@ camel_folder_freeze (CamelFolder * folder)
 	class->freeze (folder);
 }
 
-static void
-thaw (CamelFolder * folder)
-{
-	CamelFolderChangeInfo *info = NULL;
-
-	CAMEL_FOLDER_LOCK (folder, change_lock);
-
-	g_assert (folder->priv->frozen > 0);
-
-	folder->priv->frozen--;
-
-	d (printf ("thaw (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
-
-	if (folder->priv->frozen == 0
-	    && camel_folder_change_info_changed (folder->priv->changed_frozen)) {
-		info = folder->priv->changed_frozen;
-		folder->priv->changed_frozen = camel_folder_change_info_new ();
-	}
-
-	CAMEL_FOLDER_UNLOCK (folder, change_lock);
-
-	if (info) {
-		camel_object_trigger_event (folder, "folder_changed", info);
-		camel_folder_change_info_free (info);
-	}
-}
-
 /**
  * camel_folder_thaw:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Thaws the folder and emits any pending folder_changed
  * signals.
@@ -1966,15 +1983,9 @@ camel_folder_thaw (CamelFolder *folder)
 	class->thaw (folder);
 }
 
-static gboolean
-is_frozen (CamelFolder *folder)
-{
-	return folder->priv->frozen != 0;
-}
-
 /**
  * camel_folder_is_frozen:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Returns: whether or not the folder is frozen
  **/
@@ -1991,15 +2002,9 @@ camel_folder_is_frozen (CamelFolder *folder)
 	return class->is_frozen (folder);
 }
 
-static CamelFolderQuotaInfo *
-get_quota_info (CamelFolder *folder)
-{
-	return NULL;
-}
-
 /**
  * camel_folder_get_quota_info:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  *
  * Returns: list of known quota(s) for the folder.
  *
@@ -2030,7 +2035,9 @@ camel_folder_get_quota_info (CamelFolder *folder)
  * Since: 2.24
  **/
 CamelFolderQuotaInfo *
-camel_folder_quota_info_new (const gchar *name, guint64 used, guint64 total)
+camel_folder_quota_info_new (const gchar *name,
+                             guint64 used,
+                             guint64 total)
 {
 	CamelFolderQuotaInfo *info;
 
@@ -2116,7 +2123,8 @@ filter_filter (CamelSession *session, CamelSessionThreadMsg *tmsg)
 	GError *local_error = NULL;
 
 	if (m->junk) {
-		camel_operation_start (NULL, ngettext ("Learning new spam message", "Learning new spam messages", m->junk->len));
+		/* Translators: The %s is replaced with a folder name where the operation is running. */
+		camel_operation_start (NULL, ngettext ("Learning new spam message in '%s'", "Learning new spam messages in '%s'", m->junk->len), m->folder->full_name);
 
 		for (i = 0; i < m->junk->len; i ++) {
 			CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->junk->pdata[i], NULL);
@@ -2133,7 +2141,8 @@ filter_filter (CamelSession *session, CamelSessionThreadMsg *tmsg)
 	}
 
 	if (m->notjunk) {
-		camel_operation_start (NULL, ngettext ("Learning new ham message", "Learning new ham messages", m->notjunk->len));
+		/* Translators: The %s is replaced with a folder name where the operation is running. */
+		camel_operation_start (NULL, ngettext ("Learning new ham message in '%s'", "Learning new ham messages in '%s'", m->notjunk->len), m->folder->full_name);
 		for (i = 0; i < m->notjunk->len; i ++) {
 			CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->notjunk->pdata[i], NULL);
 			gint pc = 100 * i / m->notjunk->len;
@@ -2152,7 +2161,8 @@ filter_filter (CamelSession *session, CamelSessionThreadMsg *tmsg)
 		camel_junk_plugin_commit_reports (csp);
 
 	if (m->driver && m->recents) {
-		camel_operation_start (NULL, ngettext ("Filtering new message", "Filtering new messages", m->recents->len));
+		/* Translators: The %s is replaced with a folder name where the operation is running. */
+		camel_operation_start (NULL, ngettext ("Filtering new message in '%s'", "Filtering new messages in '%s'", m->recents->len), m->folder->full_name);
 
 		source_url = camel_service_get_url ((CamelService *)m->folder->parent_store);
 		uri = camel_url_new (source_url, NULL);
@@ -2309,8 +2319,7 @@ folder_changed (CamelObject *obj, gpointer event_data)
 		msg->recents = recents;
 		msg->junk = junk;
 		msg->notjunk = notjunk;
-		msg->folder = folder;
-		g_object_ref (folder);
+		msg->folder = g_object_ref (folder);
 		camel_folder_freeze (folder);
 		/* Copy changes back to changed_frozen list to retain
 		 * them while we are filtering */
@@ -2328,7 +2337,7 @@ folder_changed (CamelObject *obj, gpointer event_data)
 
 /**
  * camel_folder_free_nop:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @array: an array of uids or #CamelMessageInfo
  *
  * "Frees" the provided array by doing nothing. Used by #CamelFolder
@@ -2336,14 +2345,15 @@ folder_changed (CamelObject *obj, gpointer event_data)
  * the returned array is "static" information and should not be freed.
  **/
 void
-camel_folder_free_nop (CamelFolder *folder, GPtrArray *array)
+camel_folder_free_nop (CamelFolder *folder,
+                       GPtrArray *array)
 {
 	;
 }
 
 /**
  * camel_folder_free_shallow:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @array: an array of uids or #CamelMessageInfo
  *
  * Frees the provided array but not its contents. Used by #CamelFolder
@@ -2352,14 +2362,15 @@ camel_folder_free_nop (CamelFolder *folder, GPtrArray *array)
  * "static" information.
  **/
 void
-camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array)
+camel_folder_free_shallow (CamelFolder *folder,
+                           GPtrArray *array)
 {
 	g_ptr_array_free (array, TRUE);
 }
 
 /**
  * camel_folder_free_deep:
- * @folder: a #CamelFolder object
+ * @folder: a #CamelFolder
  * @array: an array of uids
  *
  * Frees the provided array and its contents. Used by #CamelFolder
@@ -2367,10 +2378,13 @@ camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array)
  * information was created explicitly by the corresponding get_ call.
  **/
 void
-camel_folder_free_deep (CamelFolder *folder, GPtrArray *array)
+camel_folder_free_deep (CamelFolder *folder,
+                        GPtrArray *array)
 {
 	gint i;
 
+	g_return_if_fail (array != NULL);
+
 	for (i = 0; i < array->len; i++)
 		g_free (array->pdata[i]);
 	g_ptr_array_free (array, TRUE);
@@ -2413,11 +2427,13 @@ camel_folder_change_info_new (void)
  * Add a source uid for generating a changeset.
  **/
 void
-camel_folder_change_info_add_source (CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_add_source (CamelFolderChangeInfo *info,
+                                     const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (uid != NULL);
 
 	p = info->priv;
 
@@ -2436,13 +2452,14 @@ camel_folder_change_info_add_source (CamelFolderChangeInfo *info, const gchar *u
  * Add a list of source uid's for generating a changeset.
  **/
 void
-camel_folder_change_info_add_source_list (CamelFolderChangeInfo *info, const GPtrArray *list)
+camel_folder_change_info_add_source_list (CamelFolderChangeInfo *info,
+                                          const GPtrArray *list)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	gint i;
 
-	g_assert (info != NULL);
-	g_assert (list != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (list != NULL);
 
 	p = info->priv;
 
@@ -2465,13 +2482,15 @@ camel_folder_change_info_add_source_list (CamelFolderChangeInfo *info, const GPt
  * Add a uid from the updated list, used to generate a changeset diff.
  **/
 void
-camel_folder_change_info_add_update (CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_add_update (CamelFolderChangeInfo *info,
+                                     const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	gchar *key;
 	gint value;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (uid != NULL);
 
 	p = info->priv;
 
@@ -2495,12 +2514,13 @@ camel_folder_change_info_add_update (CamelFolderChangeInfo *info, const gchar *u
  * Add a list of uid's from the updated list.
  **/
 void
-camel_folder_change_info_add_update_list (CamelFolderChangeInfo *info, const GPtrArray *list)
+camel_folder_change_info_add_update_list (CamelFolderChangeInfo *info,
+                                          const GPtrArray *list)
 {
 	gint i;
 
-	g_assert (info != NULL);
-	g_assert (list != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (list != NULL);
 
 	for (i=0;i<list->len;i++)
 		camel_folder_change_info_add_update (info, list->pdata[i]);
@@ -2540,7 +2560,7 @@ camel_folder_change_info_build_diff (CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
 
 	p = info->priv;
 
@@ -2601,10 +2621,11 @@ change_info_cat (CamelFolderChangeInfo *info, GPtrArray *source, void (*add)(Cam
  * too.
  **/
 void
-camel_folder_change_info_cat (CamelFolderChangeInfo *info, CamelFolderChangeInfo *source)
+camel_folder_change_info_cat (CamelFolderChangeInfo *info,
+                              CamelFolderChangeInfo *source)
 {
-	g_assert (info != NULL);
-	g_assert (source != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (source != NULL);
 
 	change_info_cat (info, source->uid_added, camel_folder_change_info_add_uid);
 	change_info_cat (info, source->uid_removed, camel_folder_change_info_remove_uid);
@@ -2621,13 +2642,15 @@ camel_folder_change_info_cat (CamelFolderChangeInfo *info, CamelFolderChangeInfo
  * Add a new uid to the changeinfo.
  **/
 void
-camel_folder_change_info_add_uid (CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_add_uid (CamelFolderChangeInfo *info,
+                                  const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (uid != NULL);
 
 	p = info->priv;
 
@@ -2655,13 +2678,15 @@ camel_folder_change_info_add_uid (CamelFolderChangeInfo *info, const gchar *uid)
  * Add a uid to the removed uid list.
  **/
 void
-camel_folder_change_info_remove_uid (CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_remove_uid (CamelFolderChangeInfo *info,
+                                     const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (uid != NULL);
 
 	p = info->priv;
 
@@ -2688,13 +2713,15 @@ camel_folder_change_info_remove_uid (CamelFolderChangeInfo *info, const gchar *u
  * Add a uid to the changed uid list.
  **/
 void
-camel_folder_change_info_change_uid (CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_change_uid (CamelFolderChangeInfo *info,
+                                     const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (uid != NULL);
 
 	p = info->priv;
 
@@ -2718,9 +2745,11 @@ camel_folder_change_info_change_uid (CamelFolderChangeInfo *info, const gchar *u
  * filtering
  **/
 void
-camel_folder_change_info_recent_uid (CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_recent_uid (CamelFolderChangeInfo *info,
+                                     const gchar *uid)
 {
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
+	g_return_if_fail (uid != NULL);
 
 	change_info_recent_uid (info, uid);
 	change_info_filter_uid (info, uid);
@@ -2738,7 +2767,7 @@ camel_folder_change_info_recent_uid (CamelFolderChangeInfo *info, const gchar *u
 gboolean
 camel_folder_change_info_changed (CamelFolderChangeInfo *info)
 {
-	g_assert (info != NULL);
+	g_return_val_if_fail (info != NULL, FALSE);
 
 	return (info->uid_added->len || info->uid_removed->len || info->uid_changed->len || info->uid_recent->len);
 }
@@ -2755,7 +2784,7 @@ camel_folder_change_info_clear (CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
 
 	p = info->priv;
 
@@ -2784,7 +2813,7 @@ camel_folder_change_info_free (CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert (info != NULL);
+	g_return_if_fail (info != NULL);
 
 	p = info->priv;
 
diff --git a/camel/camel-http-stream.c b/camel/camel-http-stream.c
index cd156fc..6f9285f 100644
--- a/camel/camel-http-stream.c
+++ b/camel/camel-http-stream.c
@@ -47,6 +47,11 @@
 
 #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>
+#endif
+
 #define d(x)
 
 G_DEFINE_TYPE (CamelHttpStream, camel_http_stream, CAMEL_TYPE_STREAM)
@@ -549,7 +554,7 @@ camel_http_stream_init (CamelHttpStream *http)
  * @session: active session
  * @url: URL to act upon
  *
- * Return value: a http stream
+ * Returns: a http stream
  **/
 CamelStream *
 camel_http_stream_new (CamelHttpMethod method, struct _CamelSession *session, CamelURL *url)
diff --git a/camel/camel-index.c b/camel/camel-index.c
index 1130ba7..5eeba72 100644
--- a/camel/camel-index.c
+++ b/camel/camel-index.c
@@ -279,7 +279,7 @@ camel_index_find (CamelIndex *idx, const gchar *word)
 {
 	CamelIndexClass *class;
 	CamelIndexCursor *ret;
-	gchar *b = (gchar *)word;
+	gchar *b = (gchar *) word;
 
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
 
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 1ade04a..01fddc6 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -33,7 +33,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-
+#include "camel-mempool.h"
 #include "camel-mime-filter.h"
 #include "camel-mime-parser.h"
 #include "camel-mime-utils.h"
@@ -50,6 +50,8 @@
 
 /*#define PURIFY*/
 
+#define MEMPOOL
+
 #ifdef PURIFY
 gint inend_id = -1,
   inbuffer_id = -1;
@@ -114,6 +116,9 @@ struct _header_scan_stack {
 
 	camel_mime_parser_state_t savestate; /* state at invocation of this part */
 
+#ifdef MEMPOOL
+	CamelMemPool *pool;	/* memory pool to keep track of headers/etc at this level */
+#endif
 	GQueue *raw_headers;	/* headers for this part */
 
 	CamelContentType *content_type;
@@ -151,6 +156,10 @@ static off_t folder_tell(struct _header_scan_state *s);
 static gint folder_read(struct _header_scan_state *s);
 static void folder_push_part(struct _header_scan_state *s, struct _header_scan_stack *h);
 
+#ifdef MEMPOOL
+static void header_append_mempool(struct _header_scan_state *s, struct _header_scan_stack *h, gchar *header, gint offset);
+#endif
+
 #if d(!)0
 static gchar *states[] = {
 	"CAMEL_MIME_PARSER_STATE_INITIAL",
@@ -995,10 +1004,12 @@ folder_pull_part(struct _header_scan_state *s)
 	if (h) {
 		s->parts = h->parent;
 		g_free(h->boundary);
-
+#ifdef MEMPOOL
+		camel_mempool_destroy(h->pool);
+#else
 		camel_header_raw_clear(h->raw_headers);
 		g_queue_free (h->raw_headers);
-
+#endif
 		camel_content_type_unref(h->content_type);
 		if (h->pretext)
 			g_byte_array_free(h->pretext, TRUE);
@@ -1151,6 +1162,9 @@ folder_scan_header(struct _header_scan_state *s, gint *lastone)
 	h(printf("scanning first bit\n"));
 
 	h = g_malloc0(sizeof(*h));
+#ifdef MEMPOOL
+	h->pool = camel_mempool_new(8192, 4096, CAMEL_MEMPOOL_ALIGN_STRUCT);
+#endif
 	h->raw_headers = g_queue_new ();
 
 	if (s->parts)
@@ -1640,7 +1654,7 @@ tail_recurse:
 				while (f) {
 					camel_mime_filter_filter(f->filter, *databuffer, *datalength, presize,
 								 databuffer, datalength, &presize);
-					d(printf("Filtered content (%s): '", ((CamelObject *)f->filter)->class->name));
+					d(printf("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name));
 					d(fwrite(*databuffer, sizeof(gchar), *datalength, stdout));
 					d(printf("'\n"));
 					f = f->next;
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 5ef3163..15723ae 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -224,7 +224,7 @@ static void
 mime_part_set_disposition (CamelMimePart *mime_part,
                            const gchar *disposition)
 {
-	camel_content_disposition_unref(mime_part->priv->disposition);
+	camel_content_disposition_unref (mime_part->priv->disposition);
 	if (disposition)
 		mime_part->priv->disposition =
 			camel_content_disposition_decode (disposition);
@@ -626,8 +626,7 @@ mime_part_write_to_stream (CamelDataWrapper *dw,
 			/* if we have a character encoder, add that always */
 			if (charenc) {
 				camel_stream_filter_add (
-					CAMEL_STREAM_FILTER (filter_stream),
-					charenc);
+					CAMEL_STREAM_FILTER (filter_stream), charenc);
 				g_object_unref (charenc);
 			}
 
@@ -637,15 +636,13 @@ mime_part_write_to_stream (CamelDataWrapper *dw,
 										   CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
 
 				camel_stream_filter_add (
-					CAMEL_STREAM_FILTER (filter_stream),
-					crlf);
+					CAMEL_STREAM_FILTER (filter_stream), crlf);
 				g_object_unref (crlf);
 			}
 
 			if (filter) {
 				camel_stream_filter_add (
-					CAMEL_STREAM_FILTER (filter_stream),
-					filter);
+					CAMEL_STREAM_FILTER (filter_stream), filter);
 				g_object_unref (filter);
 			}
 
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 0afa0bd..507430e 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -48,6 +48,11 @@
 #include "camel-iconv.h"
 #include "camel-mime-utils.h"
 #include "camel-net-utils.h"
+#ifdef G_OS_WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include "camel-net-utils-win32.h"
+#endif
 #include "camel-utf8.h"
 
 #ifdef G_OS_WIN32
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index a045d1d..69794c7 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -107,7 +107,7 @@ multipart_signed_parse_content (CamelMultipartSigned *mps)
 	gsize len;
 	gint state;
 
-	boundary = camel_multipart_get_boundary(mp);
+	boundary = camel_multipart_get_boundary (mp);
 	g_return_val_if_fail (boundary != NULL, -1);
 
 	stream = ((CamelDataWrapper *)mps)->stream;
@@ -318,7 +318,7 @@ multipart_signed_write_to_stream (CamelDataWrapper *data_wrapper,
 
 	/* signature */
 	count = camel_data_wrapper_write_to_stream (
-		(CamelDataWrapper *) mps->signature, stream, error);
+		CAMEL_DATA_WRAPPER (mps->signature), stream, error);
 	if (count == -1)
 		return -1;
 	total += count;
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index dee33e0..876a59e 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -153,7 +153,8 @@ multipart_is_offline (CamelDataWrapper *data_wrapper)
 }
 
 static void
-multipart_add_part (CamelMultipart *multipart, CamelMimePart *part)
+multipart_add_part (CamelMultipart *multipart,
+                    CamelMimePart *part)
 {
 	multipart->parts = g_list_append (
 		multipart->parts, g_object_ref (part));
@@ -407,7 +408,8 @@ camel_multipart_add_part (CamelMultipart *multipart,
  **/
 void
 camel_multipart_add_part_at (CamelMultipart *multipart,
-                             CamelMimePart *part, guint index)
+                             CamelMimePart *part,
+                             guint index)
 {
 	CamelMultipartClass *class;
 
@@ -559,15 +561,16 @@ camel_multipart_get_boundary (CamelMultipart *multipart)
  * be relatively short, and will be ignored by any MIME mail client.
  **/
 void
-camel_multipart_set_preface(CamelMultipart *multipart, const gchar *preface)
+camel_multipart_set_preface (CamelMultipart *multipart,
+                             const gchar *preface)
 {
-	if (multipart->preface != preface) {
-		g_free(multipart->preface);
-		if (preface)
-			multipart->preface = g_strdup(preface);
-		else
-			multipart->preface = NULL;
-	}
+	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
+
+	if (multipart->preface == preface)
+		return;
+
+	g_free (multipart->preface);
+	multipart->preface = g_strdup (preface);
 }
 
 /**
@@ -582,15 +585,16 @@ camel_multipart_set_preface(CamelMultipart *multipart, const gchar *preface)
  * Generally postface texts should not be sent with multipart messages.
  **/
 void
-camel_multipart_set_postface(CamelMultipart *multipart, const gchar *postface)
+camel_multipart_set_postface (CamelMultipart *multipart,
+                              const gchar *postface)
 {
-	if (multipart->postface != postface) {
-		g_free(multipart->postface);
-		if (postface)
-			multipart->postface = g_strdup(postface);
-		else
-			multipart->postface = NULL;
-	}
+	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
+
+	if (multipart->postface == postface)
+		return;
+
+	g_free (multipart->postface);
+	multipart->postface = g_strdup (postface);
 }
 
 /**
@@ -614,5 +618,5 @@ camel_multipart_construct_from_parser (CamelMultipart *multipart,
 	class = CAMEL_MULTIPART_GET_CLASS (multipart);
 	g_return_val_if_fail (class->construct_from_parser != NULL, -1);
 
-	return class->construct_from_parser(multipart, mp);
+	return class->construct_from_parser (multipart, mp);
 }
diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c
index 5daad5e..5b62b1e 100644
--- a/camel/camel-offline-folder.c
+++ b/camel/camel-offline-folder.c
@@ -99,8 +99,7 @@ offline_folder_changed (CamelFolder *folder, CamelFolderChangeInfo *changes, gpo
 		m = camel_session_thread_msg_new (session, &offline_downsync_ops, sizeof (*m));
 		m->changes = camel_folder_change_info_new ();
 		camel_folder_change_info_cat (m->changes, changes);
-		g_object_ref (folder);
-		m->folder = folder;
+		m->folder = g_object_ref (folder);
 
 		camel_session_thread_queue (session, &m->msg, 0);
 	}
@@ -240,7 +239,6 @@ camel_offline_folder_class_init (CamelOfflineFolderClass *class)
 		offline_folder_props = g_slist_prepend (
 			offline_folder_props, &offline_prop_list[ii]);
 	}
-
 }
 
 static void
diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c
index 0007ff4..fbde3cb 100644
--- a/camel/camel-seekable-substream.c
+++ b/camel/camel-seekable-substream.c
@@ -50,7 +50,7 @@ seekable_substream_dispose (GObject *object)
 
 	seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (object);
 
-	if (seekable_substream->parent_stream) {
+	if (seekable_substream->parent_stream != NULL) {
 		g_object_unref (seekable_substream->parent_stream);
 		seekable_substream = NULL;
 	}
@@ -207,7 +207,7 @@ seekable_substream_seek (CamelSeekableStream *seekable_stream,
 
 	case CAMEL_STREAM_END:
 		if (seekable_stream->bound_end == CAMEL_STREAM_UNBOUND) {
-			real_offset = camel_seekable_stream_seek(
+			real_offset = camel_seekable_stream_seek (
 				seekable_substream->parent_stream,
 				offset, CAMEL_STREAM_END, error);
 			if (real_offset != -1) {
@@ -273,7 +273,7 @@ camel_seekable_substream_init (CamelSeekableSubstream *seekable_substream)
  * the current position of @parent_stream. After the substream has been
  * closed, @parent_stream will stabilize again.
  *
- * Return value: the substream
+ * Returns: the substream
  **/
 CamelStream *
 camel_seekable_substream_new(CamelSeekableStream *parent_stream, off_t start, off_t end)
diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c
index ccea39a..9df8308 100644
--- a/camel/camel-store-summary.c
+++ b/camel/camel-store-summary.c
@@ -260,6 +260,7 @@ store_summary_store_info_set_string (CamelStoreSummary *summary,
 		g_hash_table_remove (summary->folders_path, (gchar *)camel_store_info_path (summary, info));
 		g_free (info->path);
 		g_free (info->uri);
+		info->uri = NULL;
 		info->path = g_strdup (str);
 		g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
 		summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
@@ -279,6 +280,8 @@ store_summary_store_info_set_string (CamelStoreSummary *summary,
 		}
 		g_free (info->path);
 		info->path = v;
+		g_free (info->uri);
+		info->uri = NULL;
 		g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
 		CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 		break;
@@ -353,14 +356,17 @@ camel_store_summary_new (void)
  * Set the filename where the summary will be loaded to/saved from.
  **/
 void
-camel_store_summary_set_filename (CamelStoreSummary *s, const gchar *name)
+camel_store_summary_set_filename (CamelStoreSummary *summary,
+                                  const gchar *name)
 {
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
 
-	g_free (s->summary_path);
-	s->summary_path = g_strdup (name);
+	g_free (summary->summary_path);
+	summary->summary_path = g_strdup (name);
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 }
 
 /**
@@ -371,15 +377,18 @@ camel_store_summary_set_filename (CamelStoreSummary *s, const gchar *name)
  * Sets the base URI for the summary.
  **/
 void
-camel_store_summary_set_uri_base (CamelStoreSummary *s, CamelURL *base)
+camel_store_summary_set_uri_base (CamelStoreSummary *summary,
+                                  CamelURL *base)
 {
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
 
-	if (s->uri_base)
-		camel_url_free (s->uri_base);
-	s->uri_base = camel_url_new_with_base (base, "");
+	if (summary->uri_base)
+		camel_url_free (summary->uri_base);
+	summary->uri_base = camel_url_new_with_base (base, "");
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 }
 
 /**
@@ -391,9 +400,11 @@ camel_store_summary_set_uri_base (CamelStoreSummary *s, CamelURL *base)
  * Returns: the number of items gint he summary.
  **/
 gint
-camel_store_summary_count (CamelStoreSummary *s)
+camel_store_summary_count (CamelStoreSummary *summary)
 {
-	return s->folders->len;
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), -1);
+
+	return summary->folders->len;
 }
 
 /**
@@ -411,22 +422,25 @@ camel_store_summary_count (CamelStoreSummary *s)
  * Returns: the summary item, or %NULL if @index is out of range
  **/
 CamelStoreInfo *
-camel_store_summary_index (CamelStoreSummary *s, gint i)
+camel_store_summary_index (CamelStoreSummary *summary,
+                           gint i)
 {
 	CamelStoreInfo *info = NULL;
 
-	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
 
-	if (i<s->folders->len)
-		info = g_ptr_array_index (s->folders, i);
+	if (i < summary->folders->len)
+		info = g_ptr_array_index (summary->folders, i);
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 
 	if (info)
 		info->refcount++;
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 
 	return info;
 }
@@ -443,23 +457,26 @@ camel_store_summary_index (CamelStoreSummary *s, gint i)
  * Returns: the summary array
  **/
 GPtrArray *
-camel_store_summary_array (CamelStoreSummary *s)
+camel_store_summary_array (CamelStoreSummary *summary)
 {
 	CamelStoreInfo *info;
-	GPtrArray *res = g_ptr_array_new ();
+	GPtrArray *res;
 	gint i;
 
-	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
 
-	g_ptr_array_set_size (res, s->folders->len);
-	for (i=0;i<s->folders->len;i++) {
-		info = res->pdata[i] = g_ptr_array_index (s->folders, i);
+	res = g_ptr_array_new ();
+	g_ptr_array_set_size (res, summary->folders->len);
+	for (i=0; i < summary->folders->len; i++) {
+		info = res->pdata[i] = g_ptr_array_index (summary->folders, i);
 		info->refcount++;
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
-	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 
 	return res;
 }
@@ -472,12 +489,16 @@ camel_store_summary_array (CamelStoreSummary *s)
  * Free the folder summary array.
  **/
 void
-camel_store_summary_array_free (CamelStoreSummary *s, GPtrArray *array)
+camel_store_summary_array_free (CamelStoreSummary *summary,
+                                GPtrArray *array)
 {
 	gint i;
 
-	for (i=0;i<array->len;i++)
-		camel_store_summary_info_free (s, array->pdata[i]);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+	g_return_if_fail (array != NULL);
+
+	for (i=0; i < array->len; i++)
+		camel_store_summary_info_free (summary, array->pdata[i]);
 
 	g_ptr_array_free (array, TRUE);
 }
@@ -498,21 +519,25 @@ camel_store_summary_array_free (CamelStoreSummary *s, GPtrArray *array)
  * available
  **/
 CamelStoreInfo *
-camel_store_summary_path (CamelStoreSummary *s, const gchar *path)
+camel_store_summary_path (CamelStoreSummary *summary,
+                          const gchar *path)
 {
 	CamelStoreInfo *info;
 
-	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
+	g_return_val_if_fail (path != NULL, NULL);
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
 
-	info = g_hash_table_lookup (s->folders_path, path);
+	info = g_hash_table_lookup (summary->folders_path, path);
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 
 	if (info)
 		info->refcount++;
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 
 	return info;
 }
@@ -526,52 +551,52 @@ camel_store_summary_path (CamelStoreSummary *s, const gchar *path)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_store_summary_load (CamelStoreSummary *s)
+camel_store_summary_load (CamelStoreSummary *summary)
 {
+	CamelStoreSummaryClass *class;
+	CamelStoreInfo *info;
 	FILE *in;
 	gint i;
-	CamelStoreInfo *info;
-	CamelStoreSummaryClass *class;
 
-	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (s), -1);
-	g_return_val_if_fail (s->summary_path != NULL, -1);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), -1);
+	g_return_val_if_fail (summary->summary_path != NULL, -1);
 
-	in = g_fopen (s->summary_path, "rb");
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
+	g_return_val_if_fail (class->store_info_load != NULL, -1);
+
+	in = g_fopen (summary->summary_path, "rb");
 	if (in == NULL)
 		return -1;
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
-	g_return_val_if_fail (class->store_info_load != NULL, -1);
-
-	CAMEL_STORE_SUMMARY_LOCK (s, io_lock);
-	if (class->summary_header_load (s, in) == -1)
+	CAMEL_STORE_SUMMARY_LOCK (summary, io_lock);
+	if (class->summary_header_load (summary, in) == -1)
 		goto error;
 
 	/* now read in each message ... */
-	for (i=0;i<s->count;i++) {
-		info = class->store_info_load (s, in);
+	for (i = 0; i < summary->count; i++) {
+		info = class->store_info_load (summary, in);
 
 		if (info == NULL)
 			goto error;
 
-		camel_store_summary_add (s, info);
+		camel_store_summary_add (summary, info);
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
 
 	if (fclose (in) != 0)
 		return -1;
 
-	s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
+	summary->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
 
 	return 0;
 
 error:
 	i = ferror (in);
 	g_warning ("Cannot load summary file: %s", g_strerror (ferror (in)));
-	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
 	fclose (in);
-	s->flags |= ~CAMEL_STORE_SUMMARY_DIRTY;
+	summary->flags |= ~CAMEL_STORE_SUMMARY_DIRTY;
 	errno = i;
 
 	return -1;
@@ -587,32 +612,35 @@ error:
  * Returns: %0 on succes or %-1 on fail
  **/
 gint
-camel_store_summary_save (CamelStoreSummary *s)
+camel_store_summary_save (CamelStoreSummary *summary)
 {
+	CamelStoreSummaryClass *class;
+	CamelStoreInfo *info;
 	FILE *out;
 	gint fd;
 	gint i;
 	guint32 count;
-	CamelStoreInfo *info;
-	CamelStoreSummaryClass *class;
 
-	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (s), -1);
-	g_return_val_if_fail (s->summary_path != NULL, -1);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), -1);
+	g_return_val_if_fail (summary->summary_path != NULL, -1);
+
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
+	g_return_val_if_fail (class->summary_header_save != NULL, -1);
 
 	io (printf ("** saving summary\n"));
 
-	if ((s->flags & CAMEL_STORE_SUMMARY_DIRTY) == 0) {
+	if ((summary->flags & CAMEL_STORE_SUMMARY_DIRTY) == 0) {
 		io (printf ("**  summary clean no save\n"));
 		return 0;
 	}
 
-	fd = g_open (s->summary_path, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
+	fd = g_open (summary->summary_path, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
 	if (fd == -1) {
 		io (printf ("**  open error: %s\n", g_strerror (errno)));
 		return -1;
 	}
 
-	out = fdopen(fd, "wb");
+	out = fdopen (fd, "wb");
 	if (out == NULL) {
 		i = errno;
 		printf ("**  fdopen error: %s\n", g_strerror (errno));
@@ -621,17 +649,14 @@ camel_store_summary_save (CamelStoreSummary *s)
 		return -1;
 	}
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
-	g_return_val_if_fail (class->summary_header_save != NULL, -1);
-
 	io (printf ("saving header\n"));
 
-	CAMEL_STORE_SUMMARY_LOCK (s, io_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, io_lock);
 
-	if (class->summary_header_save (s, out) == -1) {
+	if (class->summary_header_save (summary, out) == -1) {
 		i = errno;
 		fclose (out);
-		CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
 		errno = i;
 		return -1;
 	}
@@ -640,13 +665,13 @@ camel_store_summary_save (CamelStoreSummary *s)
 
 	/* FIXME: Locking? */
 
-	count = s->folders->len;
-	for (i=0;i<count;i++) {
-		info = s->folders->pdata[i];
-		class->store_info_save (s, out, info);
+	count = summary->folders->len;
+	for (i=0; i < count; i++) {
+		info = summary->folders->pdata[i];
+		class->store_info_save (summary, out, info);
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
 
 	if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
 		i = errno;
@@ -658,7 +683,7 @@ camel_store_summary_save (CamelStoreSummary *s)
 	if (fclose (out) != 0)
 		return -1;
 
-	s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
+	summary->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
 	return 0;
 }
 
@@ -673,28 +698,28 @@ camel_store_summary_save (CamelStoreSummary *s)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_store_summary_header_load (CamelStoreSummary *s)
+camel_store_summary_header_load (CamelStoreSummary *summary)
 {
 	CamelStoreSummaryClass *class;
 	FILE *in;
 	gint ret;
 
-	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (s), -1);
-	g_return_val_if_fail (s->summary_path != NULL, -1);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), -1);
+	g_return_val_if_fail (summary->summary_path != NULL, -1);
+
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
+	g_return_val_if_fail (class->summary_header_load != NULL, -1);
 
-	in = g_fopen (s->summary_path, "rb");
+	in = g_fopen (summary->summary_path, "rb");
 	if (in == NULL)
 		return -1;
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
-	g_return_val_if_fail (class->summary_header_load != NULL, -1);
-
-	CAMEL_STORE_SUMMARY_LOCK (s, io_lock);
-	ret = class->summary_header_load (s, in);
-	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, io_lock);
+	ret = class->summary_header_load (summary, in);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, io_lock);
 
 	fclose (in);
-	s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
+	summary->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
 	return ret;
 }
 
@@ -712,23 +737,26 @@ camel_store_summary_header_load (CamelStoreSummary *s)
  * class.  And MUST NOT be allocated directly using malloc.
  **/
 void
-camel_store_summary_add (CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_add (CamelStoreSummary *summary,
+                         CamelStoreInfo *info)
 {
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+
 	if (info == NULL)
 		return;
 
-	if (camel_store_info_path (s, info) == NULL) {
+	if (camel_store_info_path (summary, info) == NULL) {
 		g_warning ("Trying to add a folder info with missing required path name\n");
 		return;
 	}
 
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
 
-	g_ptr_array_add (s->folders, info);
-	g_hash_table_insert (s->folders_path, (gchar *)camel_store_info_path (s, info), info);
-	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
+	g_ptr_array_add (summary->folders, info);
+	g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
+	summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 }
 
 /**
@@ -741,24 +769,28 @@ camel_store_summary_add (CamelStoreSummary *s, CamelStoreInfo *info)
  * Returns: the newly added record
  **/
 CamelStoreInfo *
-camel_store_summary_add_from_path (CamelStoreSummary *s, const gchar *path)
+camel_store_summary_add_from_path (CamelStoreSummary *summary,
+                                   const gchar *path)
 {
 	CamelStoreInfo *info;
 
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
+	g_return_val_if_fail (path != NULL, NULL);
 
-	info = g_hash_table_lookup (s->folders_path, path);
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+
+	info = g_hash_table_lookup (summary->folders_path, path);
 	if (info != NULL) {
 		g_warning ("Trying to add folder '%s' to summary that already has it", path);
 		info = NULL;
 	} else {
-		info = camel_store_summary_info_new_from_path (s, path);
-		g_ptr_array_add (s->folders, info);
-		g_hash_table_insert (s->folders_path, (gchar *)camel_store_info_path (s, info), info);
-		s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
+		info = camel_store_summary_info_new_from_path (summary, path);
+		g_ptr_array_add (summary->folders, info);
+		g_hash_table_insert (summary->folders_path, (gchar *)camel_store_info_path (summary, info), info);
+		summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 
 	return info;
 }
@@ -777,18 +809,17 @@ camel_store_summary_add_from_path (CamelStoreSummary *s, const gchar *path)
  * Returns: the #CamelStoreInfo associated with @path
  **/
 CamelStoreInfo *
-camel_store_summary_info_new_from_path (CamelStoreSummary *s,
+camel_store_summary_info_new_from_path (CamelStoreSummary *summary,
                                         const gchar *path)
 {
 	CamelStoreSummaryClass *class;
 
-	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (s), NULL);
-	g_return_val_if_fail (path != NULL, NULL);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
 	g_return_val_if_fail (class->store_info_new != NULL, NULL);
 
-	return class->store_info_new (s, path);
+	return class->store_info_new (summary, path);
 }
 
 /**
@@ -799,29 +830,28 @@ camel_store_summary_info_new_from_path (CamelStoreSummary *s,
  * Unref and potentially free @info, and all associated memory.
  **/
 void
-camel_store_summary_info_free (CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_info_free (CamelStoreSummary *summary,
+                               CamelStoreInfo *info)
 {
 	CamelStoreSummaryClass *class;
 
-	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (s));
-	g_return_if_fail (info != NULL);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+	g_return_if_fail (info != NULL && info->refcount >= 1);
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
 	g_return_if_fail (class->store_info_free != NULL);
 
-	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
-
-	g_assert (info->refcount >= 1);
+	CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
 
 	info->refcount--;
 	if (info->refcount > 0) {
-		CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 		return;
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 
-	class->store_info_free (s, info);
+	class->store_info_free (summary, info);
 }
 
 /**
@@ -832,15 +862,15 @@ camel_store_summary_info_free (CamelStoreSummary *s, CamelStoreInfo *info)
  * Add an extra reference to @info.
  **/
 void
-camel_store_summary_info_ref (CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_info_ref (CamelStoreSummary *summary,
+                              CamelStoreInfo *info)
 {
-	g_assert (info);
-	g_assert (s);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+	g_return_if_fail (info != NULL && info->refcount >= 1);
 
-	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
-	g_assert (info->refcount >= 1);
+	CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
 	info->refcount++;
-	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 }
 
 /**
@@ -851,11 +881,13 @@ camel_store_summary_info_ref (CamelStoreSummary *s, CamelStoreInfo *info)
  * written back to disk.
  **/
 void
-camel_store_summary_touch (CamelStoreSummary *s)
+camel_store_summary_touch (CamelStoreSummary *summary)
 {
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
-	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+	summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 }
 
 /**
@@ -865,24 +897,26 @@ camel_store_summary_touch (CamelStoreSummary *s)
  * Empty the summary contents.
  **/
 void
-camel_store_summary_clear (CamelStoreSummary *s)
+camel_store_summary_clear (CamelStoreSummary *summary)
 {
 	gint i;
 
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
-	if (camel_store_summary_count (s) == 0) {
-		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+	if (camel_store_summary_count (summary) == 0) {
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 		return;
 	}
 
-	for (i=0;i<s->folders->len;i++)
-		camel_store_summary_info_free (s, s->folders->pdata[i]);
+	for (i=0; i < summary->folders->len; i++)
+		camel_store_summary_info_free (summary, summary->folders->pdata[i]);
 
-	g_ptr_array_set_size (s->folders, 0);
-	g_hash_table_destroy (s->folders_path);
-	s->folders_path = g_hash_table_new (g_str_hash, g_str_equal);
-	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	g_ptr_array_set_size (summary->folders, 0);
+	g_hash_table_destroy (summary->folders_path);
+	summary->folders_path = g_hash_table_new (g_str_hash, g_str_equal);
+	summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 }
 
 /**
@@ -893,15 +927,19 @@ camel_store_summary_clear (CamelStoreSummary *s)
  * Remove a specific @info record from the summary.
  **/
 void
-camel_store_summary_remove (CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_remove (CamelStoreSummary *summary,
+                            CamelStoreInfo *info)
 {
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
-	g_hash_table_remove (s->folders_path, camel_store_info_path (s, info));
-	g_ptr_array_remove (s->folders, info);
-	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+	g_return_if_fail (info != NULL);
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+	g_hash_table_remove (summary->folders_path, camel_store_info_path (summary, info));
+	g_ptr_array_remove (summary->folders, info);
+	summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
+	CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 
-	camel_store_summary_info_free (s, info);
+	camel_store_summary_info_free (summary, info);
 }
 
 /**
@@ -912,23 +950,27 @@ camel_store_summary_remove (CamelStoreSummary *s, CamelStoreInfo *info)
  * Remove a specific info record from the summary, by @path.
  **/
 void
-camel_store_summary_remove_path (CamelStoreSummary *s, const gchar *path)
+camel_store_summary_remove_path (CamelStoreSummary *summary,
+                                 const gchar *path)
 {
-        CamelStoreInfo *oldinfo;
-        gchar *oldpath;
+	CamelStoreInfo *oldinfo;
+	gchar *oldpath;
+
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+	g_return_if_fail (path != NULL);
 
-	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
-        if (g_hash_table_lookup_extended (s->folders_path, path, (gpointer)&oldpath, (gpointer)&oldinfo)) {
+	CAMEL_STORE_SUMMARY_LOCK (summary, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+        if (g_hash_table_lookup_extended (summary->folders_path, path, (gpointer)&oldpath, (gpointer)&oldinfo)) {
 		/* make sure it doesn't vanish while we're removing it */
 		oldinfo->refcount++;
-		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
-		CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
-		camel_store_summary_remove (s, oldinfo);
-		camel_store_summary_info_free (s, oldinfo);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
+		camel_store_summary_remove (summary, oldinfo);
+		camel_store_summary_info_free (summary, oldinfo);
         } else {
-		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
-		CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, ref_lock);
 	}
 }
 
@@ -940,20 +982,23 @@ camel_store_summary_remove_path (CamelStoreSummary *s, const gchar *path)
  * Remove a specific info record from the summary, by index.
  **/
 void
-camel_store_summary_remove_index (CamelStoreSummary *s, gint index)
+camel_store_summary_remove_index (CamelStoreSummary *summary,
+                                  gint index)
 {
-	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
-	if (index < s->folders->len) {
-		CamelStoreInfo *info = s->folders->pdata[index];
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
+
+	CAMEL_STORE_SUMMARY_LOCK (summary, summary_lock);
+	if (index < summary->folders->len) {
+		CamelStoreInfo *info = summary->folders->pdata[index];
 
-		g_hash_table_remove (s->folders_path, camel_store_info_path (s, info));
-		g_ptr_array_remove_index (s->folders, index);
-		s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
+		g_hash_table_remove (summary->folders_path, camel_store_info_path (summary, info));
+		g_ptr_array_remove_index (summary->folders, index);
+		summary->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 
-		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
-		camel_store_summary_info_free (s, info);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
+		camel_store_summary_info_free (summary, info);
 	} else {
-		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (summary, summary_lock);
 	}
 }
 
@@ -967,12 +1012,15 @@ camel_store_summary_remove_index (CamelStoreSummary *s, gint index)
  * Returns: the newly allocated #CamelStoreInfo
  **/
 CamelStoreInfo *
-camel_store_summary_info_new (CamelStoreSummary *s)
+camel_store_summary_info_new (CamelStoreSummary *summary)
 {
 	CamelStoreInfo *info;
 
-	info = g_slice_alloc0 (s->store_info_size);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
+
+	info = g_slice_alloc0 (summary->store_info_size);
 	info->refcount = 1;
+
 	return info;
 }
 
@@ -987,19 +1035,19 @@ camel_store_summary_info_new (CamelStoreSummary *s)
  * Returns: the string value
  **/
 const gchar *
-camel_store_info_string (CamelStoreSummary *s,
+camel_store_info_string (CamelStoreSummary *summary,
                          const CamelStoreInfo *info,
                          gint type)
 {
 	CamelStoreSummaryClass *class;
 
-	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (s), NULL);
+	g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
 	g_return_val_if_fail (info != NULL, NULL);
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
 	g_return_val_if_fail (class->store_info_string != NULL, NULL);
 
-	return class->store_info_string (s, info, type);
+	return class->store_info_string (summary, info, type);
 }
 
 /**
@@ -1012,19 +1060,18 @@ camel_store_info_string (CamelStoreSummary *s,
  * Set a specific string on the @info.
  **/
 void
-camel_store_info_set_string (CamelStoreSummary *s,
+camel_store_info_set_string (CamelStoreSummary *summary,
                              CamelStoreInfo *info,
                              gint type,
                              const gchar *value)
 {
 	CamelStoreSummaryClass *class;
 
-	/* XXX Can 'value' be NULL? */
-	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (s));
+	g_return_if_fail (CAMEL_IS_STORE_SUMMARY (summary));
 	g_return_if_fail (info != NULL);
 
-	class = CAMEL_STORE_SUMMARY_GET_CLASS (s);
+	class = CAMEL_STORE_SUMMARY_GET_CLASS (summary);
 	g_return_if_fail (class->store_info_set_string != NULL);
 
-	class->store_info_set_string (s, info, type, value);
+	class->store_info_set_string (summary, info, type, value);
 }
diff --git a/camel/camel-store.c b/camel/camel-store.c
index be8ebaf..512655f 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -351,11 +351,14 @@ camel_store_get_folder (CamelStore *store,
                         guint32 flags,
                         GError **error)
 {
+	CamelStoreClass *class;
 	CamelFolder *folder = NULL;
 
 	g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
 	g_return_val_if_fail (folder_name != NULL, NULL);
 
+	class = CAMEL_STORE_GET_CLASS (store);
+
 	/* O_EXCL doesn't make sense if we aren't requesting to also create the folder if it doesn't exist */
 	if (!(flags & CAMEL_STORE_FOLDER_CREATE))
 		flags &= ~CAMEL_STORE_FOLDER_EXCL;
@@ -391,11 +394,11 @@ camel_store_get_folder (CamelStore *store,
 		}
 
 		if ((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0) {
-			folder = CAMEL_STORE_GET_CLASS(store)->get_trash(store, error);
+			folder = class->get_trash(store, error);
 		} else if ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0) {
-			folder = CAMEL_STORE_GET_CLASS(store)->get_junk(store, error);
+			folder = class->get_junk(store, error);
 		} else {
-			folder = CAMEL_STORE_GET_CLASS (store)->get_folder(store, folder_name, flags, error);
+			folder = class->get_folder(store, folder_name, flags, error);
 			if (folder) {
 				CamelVeeFolder *vfolder;
 
@@ -452,6 +455,9 @@ camel_store_create_folder (CamelStore *store,
 	g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
 	g_return_val_if_fail (folder_name != NULL, NULL);
 
+	class = CAMEL_STORE_GET_CLASS (store);
+	g_return_val_if_fail (class->create_folder != NULL, NULL);
+
 	if ((parent_name == NULL || parent_name[0] == 0)
 	    && (((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0)
 		|| ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0))) {
@@ -463,9 +469,6 @@ camel_store_create_folder (CamelStore *store,
 		return NULL;
 	}
 
-	class = CAMEL_STORE_GET_CLASS (store);
-	g_return_val_if_fail (class->create_folder != NULL, NULL);
-
 	CAMEL_STORE_LOCK(store, folder_lock);
 	fi = class->create_folder (store, parent_name, folder_name, error);
 	CAMEL_STORE_UNLOCK(store, folder_lock);
@@ -524,6 +527,9 @@ camel_store_delete_folder (CamelStore *store,
 	g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
 	g_return_val_if_fail (folder_name != NULL, FALSE);
 
+	class = CAMEL_STORE_GET_CLASS (store);
+	g_return_val_if_fail (class->delete_folder != NULL, FALSE);
+
 	/* TODO: should probably be a parameter/bit on the storeinfo */
 	if (((store->flags & CAMEL_STORE_VTRASH) && strcmp(folder_name, CAMEL_VTRASH_NAME) == 0)
 	    || ((store->flags & CAMEL_STORE_VJUNK) && strcmp(folder_name, CAMEL_VJUNK_NAME) == 0)) {
@@ -535,9 +541,6 @@ camel_store_delete_folder (CamelStore *store,
 		return FALSE;
 	}
 
-	class = CAMEL_STORE_GET_CLASS (store);
-	g_return_val_if_fail (class->delete_folder != NULL, FALSE);
-
 	CAMEL_STORE_LOCK(store, folder_lock);
 
 	success = class->delete_folder (store, folder_name, &local_error);
@@ -585,6 +588,9 @@ camel_store_rename_folder (CamelStore *store,
 	g_return_val_if_fail (old_namein != NULL, FALSE);
 	g_return_val_if_fail (new_name != NULL, FALSE);
 
+	class = CAMEL_STORE_GET_CLASS (store);
+	g_return_val_if_fail (class->rename_folder != NULL, FALSE);
+
 	if (strcmp(old_namein, new_name) == 0)
 		return TRUE;
 
@@ -598,9 +604,6 @@ camel_store_rename_folder (CamelStore *store,
 		return FALSE;
 	}
 
-	class = CAMEL_STORE_GET_CLASS (store);
-	g_return_val_if_fail (class->rename_folder != NULL, FALSE);
-
 	/* need to save this, since old_namein might be folder->full_name, which could go away */
 	old_name = g_strdup(old_namein);
 	oldlen = strlen(old_name);
@@ -700,9 +703,9 @@ camel_store_get_inbox (CamelStore *store,
 	class = CAMEL_STORE_GET_CLASS (store);
 	g_return_val_if_fail (class->get_inbox != NULL, NULL);
 
-	CAMEL_STORE_LOCK(store, folder_lock);
+	CAMEL_STORE_LOCK (store, folder_lock);
 	folder = class->get_inbox (store, error);
-	CAMEL_STORE_UNLOCK(store, folder_lock);
+	CAMEL_STORE_UNLOCK (store, folder_lock);
 
 	return folder;
 }
@@ -786,7 +789,12 @@ camel_store_sync (CamelStore *store,
 }
 
 static void
-add_special_info (CamelStore *store, CamelFolderInfo *info, const gchar *name, const gchar *translated, gboolean unread_count, guint32 flags)
+add_special_info (CamelStore *store,
+                  CamelFolderInfo *info,
+                  const gchar *name,
+                  const gchar *translated,
+                  gboolean unread_count,
+                  guint32 flags)
 {
 	CamelFolderInfo *fi, *vinfo, *parent;
 	gchar *uri, *path;
@@ -843,7 +851,7 @@ add_special_info (CamelStore *store, CamelFolderInfo *info, const gchar *name, c
 }
 
 static void
-dump_fi(CamelFolderInfo *fi, gint depth)
+dump_fi (CamelFolderInfo *fi, gint depth)
 {
 	gchar *s;
 
@@ -941,7 +949,7 @@ camel_store_free_folder_info (CamelStore *store,
 
 	g_return_if_fail (CAMEL_IS_STORE (store));
 
-	if (!fi)
+	if (fi == NULL)
 		return;
 
 	class = CAMEL_STORE_GET_CLASS (store);
@@ -959,7 +967,8 @@ camel_store_free_folder_info (CamelStore *store,
  * of the data.
  **/
 void
-camel_store_free_folder_info_full (CamelStore *store, CamelFolderInfo *fi)
+camel_store_free_folder_info_full (CamelStore *store,
+                                   CamelFolderInfo *fi)
 {
 	camel_folder_info_free (fi);
 }
@@ -972,7 +981,8 @@ camel_store_free_folder_info_full (CamelStore *store, CamelFolderInfo *fi)
  * An implementation for #CamelStore::free_folder_info. Does nothing.
  **/
 void
-camel_store_free_folder_info_nop (CamelStore *store, CamelFolderInfo *fi)
+camel_store_free_folder_info_nop (CamelStore *store,
+                                  CamelFolderInfo *fi)
 {
 	;
 }
@@ -986,7 +996,7 @@ camel_store_free_folder_info_nop (CamelStore *store, CamelFolderInfo *fi)
 void
 camel_folder_info_free (CamelFolderInfo *fi)
 {
-	if (fi) {
+	if (fi != NULL) {
 		camel_folder_info_free (fi->next);
 		camel_folder_info_free (fi->child);
 		g_free (fi->name);
@@ -1010,7 +1020,8 @@ camel_folder_info_new (void)
 }
 
 static gint
-folder_info_cmp (gconstpointer ap, gconstpointer bp)
+folder_info_cmp (gconstpointer ap,
+                 gconstpointer bp)
 {
 	const CamelFolderInfo *a = ((CamelFolderInfo **)ap)[0];
 	const CamelFolderInfo *b = ((CamelFolderInfo **)bp)[0];
@@ -1040,17 +1051,19 @@ folder_info_cmp (gconstpointer ap, gconstpointer bp)
  * Returns: the top level of the tree of linked folder info.
  **/
 CamelFolderInfo *
-camel_folder_info_build (GPtrArray *folders, const gchar *name_space,
-			 gchar separator, gboolean short_names)
+camel_folder_info_build (GPtrArray *folders,
+                         const gchar *namespace,
+                         gchar separator,
+                         gboolean short_names)
 {
 	CamelFolderInfo *fi, *pfi, *top = NULL, *tail = NULL;
 	GHashTable *hash;
 	gchar *p, *pname;
 	gint i, nlen;
 
-	if (!name_space)
-		name_space = "";
-	nlen = strlen (name_space);
+	if (!namespace)
+		namespace = "";
+	nlen = strlen (namespace);
 
 	qsort (folders->pdata, folders->len, sizeof (folders->pdata[0]), folder_info_cmp);
 
@@ -1064,7 +1077,7 @@ camel_folder_info_build (GPtrArray *folders, const gchar *name_space,
 	/* Now find parents. */
 	for (i = 0; i < folders->len; i++) {
 		fi = folders->pdata[i];
-		if (!strncmp (name_space, fi->full_name, nlen)
+		if (!strncmp (namespace, fi->full_name, nlen)
 		    && (p = strrchr(fi->full_name+nlen, separator))) {
 			pname = g_strndup(fi->full_name, p - fi->full_name);
 			pfi = g_hash_table_lookup(hash, pname);
@@ -1143,7 +1156,8 @@ camel_folder_info_build (GPtrArray *folders, const gchar *name_space,
 }
 
 static CamelFolderInfo *
-folder_info_clone_rec(CamelFolderInfo *fi, CamelFolderInfo *parent)
+folder_info_clone_rec (CamelFolderInfo *fi,
+                       CamelFolderInfo *parent)
 {
 	CamelFolderInfo *info;
 
@@ -1177,7 +1191,7 @@ folder_info_clone_rec(CamelFolderInfo *fi, CamelFolderInfo *parent)
  * Returns: the cloned #CamelFolderInfo tree.
  **/
 CamelFolderInfo *
-camel_folder_info_clone(CamelFolderInfo *fi)
+camel_folder_info_clone (CamelFolderInfo *fi)
 {
 	if (fi == NULL)
 		return NULL;
@@ -1196,6 +1210,8 @@ camel_folder_info_clone(CamelFolderInfo *fi)
 gboolean
 camel_store_supports_subscriptions (CamelStore *store)
 {
+	g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+
 	return (store->flags & CAMEL_STORE_SUBSCRIPTIONS);
 }
 
@@ -1336,6 +1352,7 @@ camel_store_folder_uri_equal (CamelStore *store,
                               const gchar *uri0,
                               const gchar *uri1)
 {
+	CamelStoreClass *class;
 	CamelProvider *provider;
 	CamelURL *url0, *url1;
 	gint equal;
@@ -1343,6 +1360,9 @@ camel_store_folder_uri_equal (CamelStore *store,
 	g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
 	g_return_val_if_fail (uri0 && uri1, FALSE);
 
+	class = CAMEL_STORE_GET_CLASS (store);
+	g_return_val_if_fail (class->compare_folder_name != NULL, FALSE);
+
 	provider = ((CamelService *) store)->provider;
 
 	if (!(url0 = camel_url_new (uri0, NULL)))
@@ -1370,7 +1390,7 @@ camel_store_folder_uri_equal (CamelStore *store,
 		if (name1 == NULL)
 			g_warning("URI is badly formed, missing folder name: %s", uri1);
 
-		equal = name0 && name1 && CAMEL_STORE_GET_CLASS (store)->compare_folder_name (name0, name1);
+		equal = name0 && name1 && class->compare_folder_name (name0, name1);
 	}
 
 	camel_url_free (url0);
diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c
index 56ce5ec..a1cc186 100644
--- a/camel/camel-stream-buffer.c
+++ b/camel/camel-stream-buffer.c
@@ -428,10 +428,13 @@ camel_stream_buffer_new (CamelStream *stream,
  * If @buf is NULL, then allocate and manage @size bytes
  * for all buffering.
  *
- * Return value: A new stream with buffering applied.
+ * Returns: A new stream with buffering applied.
  **/
 CamelStream *
-camel_stream_buffer_new_with_vbuf (CamelStream *stream, CamelStreamBufferMode mode, gchar *buf, guint32 size)
+camel_stream_buffer_new_with_vbuf (CamelStream *stream,
+                                   CamelStreamBufferMode mode,
+                                   gchar *buf,
+                                   guint32 size)
 {
 	CamelStreamBuffer *sbf;
 	CamelStreamBufferClass *class;
diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c
index aee3d71..4717178 100644
--- a/camel/camel-stream-filter.c
+++ b/camel/camel-stream-filter.c
@@ -115,8 +115,9 @@ stream_filter_read (CamelStream *stream,
 				priv->filtered = priv->buffer;
 				priv->filteredlen = 0;
 				while (f) {
-					camel_mime_filter_complete(f->filter, priv->filtered, priv->filteredlen,
-								   presize, &priv->filtered, &priv->filteredlen, &presize);
+					camel_mime_filter_complete (
+						f->filter, priv->filtered, priv->filteredlen,
+						presize, &priv->filtered, &priv->filteredlen, &presize);
 					g_check(priv->realbuffer);
 					f = f->next;
 				}
@@ -135,8 +136,9 @@ stream_filter_read (CamelStream *stream,
 			d(printf("'\n"));
 
 			while (f) {
-				camel_mime_filter_filter(f->filter, priv->filtered, priv->filteredlen, presize,
-							 &priv->filtered, &priv->filteredlen, &presize);
+				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)->class->name));
@@ -280,7 +282,7 @@ stream_filter_eos (CamelStream *stream)
 	if (!priv->flushed)
 		return FALSE;
 
-	return camel_stream_eos(priv->source);
+	return camel_stream_eos (priv->source);
 }
 
 static gint
@@ -323,7 +325,6 @@ camel_stream_filter_class_init (CamelStreamFilterClass *class)
 	stream_class->close = stream_filter_close;
 	stream_class->eos = stream_filter_eos;
 	stream_class->reset = stream_filter_reset;
-
 }
 
 static void
@@ -415,7 +416,8 @@ camel_stream_filter_add (CamelStreamFilter *stream,
  * Remove a processing filter from the stream by id.
  **/
 void
-camel_stream_filter_remove (CamelStreamFilter *stream, gint id)
+camel_stream_filter_remove (CamelStreamFilter *stream,
+                            gint id)
 {
 	CamelStreamFilterPrivate *priv;
 	struct _filter *fn, *f;
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index cacf5a4..71d42f6 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -283,7 +283,9 @@ 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;
 
diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c
index 607ee91..e7655e9 100644
--- a/camel/camel-stream-mem.c
+++ b/camel/camel-stream-mem.c
@@ -127,10 +127,10 @@ stream_mem_write (CamelStream *stream,
 
 	/* 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);
+		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);
+		g_byte_array_set_size (priv->buffer, nwrite + priv->buffer->len);
+		memcpy (priv->buffer->data + seekable->position, buffer, nwrite);
 	}
 	seekable->position += nwrite;
 
diff --git a/camel/camel-stream-mem.h b/camel/camel-stream-mem.h
index 7e85c01..77a01c6 100644
--- a/camel/camel-stream-mem.h
+++ b/camel/camel-stream-mem.h
@@ -73,7 +73,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);
+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-process.c b/camel/camel-stream-process.c
index c88c2f8..f550440 100644
--- a/camel/camel-stream-process.c
+++ b/camel/camel-stream-process.c
@@ -164,7 +164,7 @@ camel_stream_process_init (CamelStreamProcess *stream)
  *
  * Returns a PROCESS stream.
  *
- * Return value: the stream
+ * Returns: the stream
  **/
 CamelStream *
 camel_stream_process_new (void)
@@ -224,6 +224,9 @@ camel_stream_process_connect (CamelStreamProcess *stream,
 {
 	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)
 		camel_stream_close (CAMEL_STREAM (stream), NULL);
 
diff --git a/camel/camel-stream-vfs.c b/camel/camel-stream-vfs.c
index ca741d2..309cf0c 100644
--- a/camel/camel-stream-vfs.c
+++ b/camel/camel-stream-vfs.c
@@ -76,9 +76,9 @@ stream_vfs_write (CamelStream *stream,
                   gsize n,
                   GError **error)
 {
+	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
 	gboolean success;
 	gsize bytes_written;
-	CamelStreamVFS *stream_vfs = CAMEL_STREAM_VFS (stream);
 
 	success = g_output_stream_write_all (
 		G_OUTPUT_STREAM (stream_vfs->stream),
diff --git a/camel/camel-stream.c b/camel/camel-stream.c
index a422956..d7dd232 100644
--- a/camel/camel-stream.c
+++ b/camel/camel-stream.c
@@ -288,6 +288,9 @@ camel_stream_printf (CamelStream *stream,
 	string = g_strdup_vprintf (fmt, args);
 	va_end (args);
 
+	if (string == NULL)
+		return -1;
+
 	ret = camel_stream_write (stream, string, strlen (string), error);
 	g_free (string);
 
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index abda3a7..5b9b709 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -44,6 +44,8 @@
 #define SOCKET_ERROR_IS_EINPROGRESS() (errno == EINPROGRESS)
 #define SOCKET_ERROR_IS_EINTR() (errno == EINTR)
 #else
+#include <winsock2.h>
+#include <ws2tcpip.h>
 #define SOCKET_ERROR_CODE() WSAGetLastError ()
 #define SOCKET_CLOSE(fd) closesocket (fd)
 #define SOCKET_ERROR_IS_EINPROGRESS() (WSAGetLastError () == WSAEWOULDBLOCK)
@@ -489,7 +491,8 @@ tcp_stream_raw_get_local_address (CamelTcpStream *stream,
 }
 
 static struct sockaddr *
-tcp_stream_raw_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;
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 817b38d..0421fb6 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -61,6 +61,11 @@
 #include "camel-stream-fs.h"
 #include "camel-tcp-stream-ssl.h"
 
+#ifdef G_OS_WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+
 #define IO_TIMEOUT (PR_TicksPerSecond() * 4 * 60)
 #define CONNECT_TIMEOUT (PR_TicksPerSecond () * 4 * 60)
 
@@ -68,23 +73,10 @@
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), CAMEL_TYPE_TCP_STREAM_SSL, CamelTcpStreamSSLPrivate))
 
-static gssize stream_read (CamelStream *stream, gchar *buffer, gsize n, GError **error);
-static gssize stream_write (CamelStream *stream, const gchar *buffer, gsize n, GError **error);
-static gint stream_flush  (CamelStream *stream, GError **error);
-static gint stream_close  (CamelStream *stream, GError **error);
-
-static PRFileDesc *enable_ssl (CamelTcpStreamSSL *ssl, PRFileDesc *fd);
-
-static gint stream_connect    (CamelTcpStream *stream, struct addrinfo *host, GError **error);
-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;
@@ -93,137 +85,6 @@ struct _CamelTcpStreamSSLPrivate {
 G_DEFINE_TYPE (CamelTcpStreamSSL, camel_tcp_stream_ssl, CAMEL_TYPE_TCP_STREAM)
 
 static void
-tcp_stream_ssl_dispose (GObject *object)
-{
-	CamelTcpStreamSSLPrivate *priv;
-
-	priv = CAMEL_TCP_STREAM_SSL_GET_PRIVATE (object);
-
-	if (priv->session != NULL) {
-		g_object_unref (priv->session);
-		priv->session = NULL;
-	}
-
-	/* Chain up to parent's dispose() method. */
-	G_OBJECT_CLASS (camel_tcp_stream_ssl_parent_class)->dispose (object);
-}
-
-static void
-tcp_stream_ssl_finalize (GObject *object)
-{
-	CamelTcpStreamSSLPrivate *priv;
-
-	priv = CAMEL_TCP_STREAM_SSL_GET_PRIVATE (object);
-
-	if (priv->sockfd != NULL) {
-		PR_Shutdown (priv->sockfd, PR_SHUTDOWN_BOTH);
-		PR_Close (priv->sockfd);
-	}
-
-	g_free (priv->expected_host);
-
-	/* Chain up to parent's finalize() method. */
-	G_OBJECT_CLASS (camel_tcp_stream_ssl_parent_class)->finalize (object);
-}
-
-static void
-camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *class)
-{
-	GObjectClass *object_class;
-	CamelStreamClass *stream_class;
-	CamelTcpStreamClass *tcp_stream_class;
-
-	g_type_class_add_private (class, sizeof (CamelTcpStreamSSLPrivate));
-
-	object_class = G_OBJECT_CLASS (class);
-	object_class->dispose = tcp_stream_ssl_dispose;
-	object_class->finalize = tcp_stream_ssl_finalize;
-
-	stream_class = CAMEL_STREAM_CLASS (class);
-	stream_class->read = stream_read;
-	stream_class->write = stream_write;
-	stream_class->flush = stream_flush;
-	stream_class->close = stream_close;
-
-	tcp_stream_class = CAMEL_TCP_STREAM_CLASS (class);
-	tcp_stream_class->connect = stream_connect;
-	tcp_stream_class->getsockopt = stream_getsockopt;
-	tcp_stream_class->setsockopt = stream_setsockopt;
-	tcp_stream_class->get_local_address  = stream_get_local_address;
-	tcp_stream_class->get_remote_address = stream_get_remote_address;
-}
-
-static void
-camel_tcp_stream_ssl_init (CamelTcpStreamSSL *stream)
-{
-	stream->priv = CAMEL_TCP_STREAM_SSL_GET_PRIVATE (stream);
-}
-
-/**
- * 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 = g_object_new (CAMEL_TYPE_TCP_STREAM_SSL, NULL);
-
-	stream->priv->session = g_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 = g_object_new (CAMEL_TYPE_TCP_STREAM_SSL, NULL);
-
-	stream->priv->session = g_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)
 {
 	/* FIXME: this should handle more. */
@@ -285,47 +146,45 @@ 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_dispose (GObject *object)
 {
-	PRFileDesc *fd;
+	CamelTcpStreamSSLPrivate *priv;
 
-	g_return_val_if_fail (CAMEL_IS_TCP_STREAM_SSL (ssl), -1);
+	priv = CAMEL_TCP_STREAM_SSL_GET_PRIVATE (object);
 
-	if (ssl->priv->sockfd && !ssl->priv->ssl_mode) {
-		if (!(fd = enable_ssl (ssl, NULL))) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
+	if (priv->session != NULL) {
+		g_object_unref (priv->session);
+		priv->session = NULL;
+	}
 
-		ssl->priv->sockfd = fd;
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (camel_tcp_stream_ssl_parent_class)->dispose (object);
+}
 
-		if (SSL_ResetHandshake (fd, FALSE) == SECFailure) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
+static void
+tcp_stream_ssl_finalize (GObject *object)
+{
+	CamelTcpStreamSSLPrivate *priv;
 
-		if (SSL_ForceHandshake (fd) == SECFailure) {
-			set_errno (PR_GetError ());
-			return -1;
-		}
+	priv = CAMEL_TCP_STREAM_SSL_GET_PRIVATE (object);
+
+	if (priv->sockfd != NULL) {
+		PR_Shutdown (priv->sockfd, PR_SHUTDOWN_BOTH);
+		PR_Close (priv->sockfd);
 	}
 
-	ssl->priv->ssl_mode = TRUE;
+	g_free (priv->expected_host);
 
-	return 0;
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (camel_tcp_stream_ssl_parent_class)->finalize (object);
 }
 
 static gssize
-stream_read (CamelStream *stream, gchar *buffer, gsize n, GError **error)
+tcp_stream_ssl_read (CamelStream *stream,
+                     gchar *buffer,
+                     gsize n,
+                     GError **error)
 {
 	CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
 	PRFileDesc *cancel_fd;
@@ -412,10 +271,10 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n, GError **error)
 }
 
 static gssize
-stream_write (CamelStream *stream,
-              const gchar *buffer,
-              gsize n,
-              GError **error)
+tcp_stream_ssl_write (CamelStream *stream,
+                      const gchar *buffer,
+                      gsize n,
+                      GError **error)
 {
 	CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
 	gssize w, written = 0;
@@ -519,16 +378,16 @@ stream_write (CamelStream *stream,
 }
 
 static gint
-stream_flush (CamelStream *stream,
-              GError **error)
+tcp_stream_ssl_flush (CamelStream *stream,
+                      GError **error)
 {
 	/*return PR_Sync (((CamelTcpStreamSSL *)stream)->priv->sockfd);*/
 	return 0;
 }
 
 static gint
-stream_close (CamelStream *stream,
-              GError **error)
+tcp_stream_ssl_close (CamelStream *stream,
+                      GError **error)
 {
 	if (((CamelTcpStreamSSL *)stream)->priv->sockfd == NULL) {
 		g_set_error (
@@ -1142,7 +1001,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;
@@ -1237,12 +1097,12 @@ socket_connect(CamelTcpStream *stream, struct addrinfo *host)
 }
 
 static gint
-stream_connect (CamelTcpStream *stream,
-                struct addrinfo *host,
-                GError **error)
+tcp_stream_ssl_connect (CamelTcpStream *stream,
+                        struct addrinfo *host,
+                        GError **error)
 {
 	while (host) {
-		if (socket_connect(stream, host) == 0)
+		if (tcp_socket_ssl_connect (stream, host) == 0)
 			return 0;
 		host = host->ai_next;
 	}
@@ -1251,7 +1111,8 @@ stream_connect (CamelTcpStream *stream,
 }
 
 static gint
-stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
+tcp_stream_ssl_getsockopt (CamelTcpStream *stream,
+                           CamelSockOptData *data)
 {
 	PRSocketOptionData sodata;
 
@@ -1267,7 +1128,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;
 
@@ -1314,7 +1176,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;
@@ -1326,7 +1189,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;
@@ -1351,4 +1215,140 @@ camel_tcp_stream_ssl_sockfd (CamelTcpStreamSSL *stream)
 	return stream->priv->sockfd;
 }
 
+static void
+camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *class)
+{
+	GObjectClass *object_class;
+	CamelStreamClass *stream_class;
+	CamelTcpStreamClass *tcp_stream_class;
+
+	g_type_class_add_private (class, sizeof (CamelTcpStreamSSLPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = tcp_stream_ssl_dispose;
+	object_class->finalize = tcp_stream_ssl_finalize;
+
+	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 = CAMEL_TCP_STREAM_SSL_GET_PRIVATE (stream);
+}
+
+/**
+ * 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 = g_object_new (CAMEL_TYPE_TCP_STREAM_SSL, NULL);
+
+	stream->priv->session = g_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 = g_object_new (CAMEL_TYPE_TCP_STREAM_SSL, NULL);
+
+	stream->priv->session = g_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 0e3304e..439e3b7 100644
--- a/camel/camel-tcp-stream.c
+++ b/camel/camel-tcp-stream.c
@@ -28,6 +28,11 @@
 
 #include "camel-tcp-stream.h"
 
+#ifdef G_OS_WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+
 #define w(x)
 
 G_DEFINE_TYPE (CamelTcpStream, camel_tcp_stream, CAMEL_TYPE_STREAM)
diff --git a/camel/camel-tcp-stream.h b/camel/camel-tcp-stream.h
index 7eec5bb..ef12640 100644
--- a/camel/camel-tcp-stream.h
+++ b/camel/camel-tcp-stream.h
@@ -33,9 +33,14 @@
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <netdb.h>
+typedef struct linger CamelLinger;
 #else
-#include <winsock2.h>
-#include <ws2tcpip.h>
+typedef struct {
+	unsigned short l_onoff;
+	unsigned short l_linger;
+} CamelLinger;
+#define socklen_t int
+struct addrinfo;
 #endif
 #include <unistd.h>
 
@@ -88,8 +93,6 @@ typedef enum {
 	CAMEL_SOCKOPT_LAST
 } CamelSockOpt;
 
-typedef struct linger CamelLinger;
-
 typedef struct _CamelSockOptData {
 	CamelSockOpt option;
 	union {
@@ -150,4 +153,8 @@ struct sockaddr *
 
 G_END_DECLS
 
+#ifdef G_OS_WIN32
+#undef socklen_t
+#endif
+
 #endif /* CAMEL_TCP_STREAM_H */
diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c
index 129e063..fa9e0e6 100644
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@ -401,8 +401,7 @@ text_index_sync (CamelIndex *idx,
 			ret = text_index_compress_nosync (idx, error);
 	}
 
-	if (ret == 0)
-		ret = camel_block_file_sync (p->blocks);
+	ret = camel_block_file_sync (p->blocks);
 
 	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
@@ -1292,7 +1291,7 @@ camel_text_index_dump (CamelTextIndex *idx)
 		printf ("Word: '%s':\n", word);
 
 		idc = camel_index_find ((CamelIndex *)idx, word);
-		while ( (name = camel_index_cursor_next (idc)) ) {
+		while ((name = camel_index_cursor_next (idc))) {
 			printf (" %s", name);
 		}
 		printf ("\n");
@@ -1349,8 +1348,8 @@ camel_text_index_validate (CamelTextIndex *idx)
 
 	keyid = 0;
 	while ((keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data, NULL))) {
-		if ((oldword = g_hash_table_lookup (names, GINT_TO_POINTER(keyid))) != NULL
-		    || (oldword = g_hash_table_lookup (deleted, GINT_TO_POINTER(keyid))) != NULL) {
+		if ((oldword = g_hash_table_lookup (names, GINT_TO_POINTER (keyid))) != NULL
+		    || (oldword = g_hash_table_lookup (deleted, GINT_TO_POINTER (keyid))) != NULL) {
 			printf ("Warning, name '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
 			g_free (word);
 		} else {
@@ -1400,7 +1399,7 @@ camel_text_index_validate (CamelTextIndex *idx)
 		used = g_hash_table_new (g_str_hash, g_str_equal);
 
 		idc = camel_index_find ((CamelIndex *)idx, word);
-		while ( (name = camel_index_cursor_next (idc)) ) {
+		while ((name = camel_index_cursor_next (idc))) {
 			if (g_hash_table_lookup (name_word, name) == NULL) {
 				printf ("word '%s' references non-existant name '%s'\n", word, name);
 			}
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 48d6bcb..930f06e 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -135,6 +135,13 @@ vee_store_construct (CamelService *service,
 	return TRUE;
 }
 
+static gchar *
+vee_store_get_name (CamelService *service,
+                    gboolean brief)
+{
+	return g_strdup ("Virtual Folder Store");
+}
+
 static CamelFolder *
 vee_store_get_folder (CamelStore *store,
                       const gchar *folder_name,
@@ -431,6 +438,7 @@ camel_vee_store_class_init (CamelVeeStoreClass *class)
 
 	service_class = CAMEL_SERVICE_CLASS (class);
 	service_class->construct = vee_store_construct;
+	service_class->get_name = vee_store_get_name;
 
 	store_class = CAMEL_STORE_CLASS (class);
 	store_class->get_folder = vee_store_get_folder;
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
index b3113e8..cde904b 100644
--- a/camel/camel-vtrash-folder.c
+++ b/camel/camel-vtrash-folder.c
@@ -313,3 +313,4 @@ camel_vtrash_folder_new (CamelStore *parent_store, camel_vtrash_folder_t type)
 
 	return (CamelFolder *)vtrash;
 }
+
diff --git a/docs/reference/camel/tmpl/camel-imap4-command.sgml b/docs/reference/camel/tmpl/camel-imap4-command.sgml
index 03b6915..5646430 100644
--- a/docs/reference/camel/tmpl/camel-imap4-command.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-command.sgml
@@ -17,144 +17,3 @@ camel-imap4-command
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Command ##### -->
-<para>
-
-</para>
-
- node: 
- engine: 
- ref_count: 
- status: 
- result: 
- id: 
- tag: 
- resp_codes: 
- folder: 
- ex: 
- parts: 
- part: 
- untagged: 
- plus: 
- reset: 
- user_data: 
-
-<!-- ##### STRUCT CamelIMAP4Literal ##### -->
-<para>
-
-</para>
-
- type: 
-
-<!-- ##### USER_FUNCTION CamelIMAP4PlusCallback ##### -->
-<para>
-
-</para>
-
- engine: 
- ic: 
- linebuf: 
- linelen: 
- error: 
- Returns: 
-
-
-<!-- ##### USER_FUNCTION CamelIMAP4UntaggedCallback ##### -->
-<para>
-
-</para>
-
- engine: 
- ic: 
- index: 
- token: 
- error: 
- Returns: 
-
-
-<!-- ##### USER_FUNCTION CamelIMAP4CommandReset ##### -->
-<para>
-
-</para>
-
- ic: 
- user_data: 
-
-
-<!-- ##### STRUCT CamelIMAP4CommandPart ##### -->
-<para>
-
-</para>
-
- next: 
- buffer: 
- buflen: 
- literal: 
-
-<!-- ##### FUNCTION camel_imap4_command_new ##### -->
-<para>
-
-</para>
-
- engine: 
- folder: 
- format: 
- Varargs: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_command_newv ##### -->
-<para>
-
-</para>
-
- engine: 
- folder: 
- format: 
- args: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_command_register_untagged ##### -->
-<para>
-
-</para>
-
- ic: 
- atom: 
- untagged: 
-
-
-<!-- ##### FUNCTION camel_imap4_command_ref ##### -->
-<para>
-
-</para>
-
- ic: 
-
-
-<!-- ##### FUNCTION camel_imap4_command_unref ##### -->
-<para>
-
-</para>
-
- ic: 
-
-
-<!-- ##### FUNCTION camel_imap4_command_step ##### -->
-<para>
-
-</para>
-
- ic: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_command_reset ##### -->
-<para>
-
-</para>
-
- ic: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-engine.sgml b/docs/reference/camel/tmpl/camel-imap4-engine.sgml
index 3727697..5c23bd6 100644
--- a/docs/reference/camel/tmpl/camel-imap4-engine.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-engine.sgml
@@ -17,302 +17,3 @@ CamelIMAP4Engine
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Engine ##### -->
-<para>
-
-</para>
-
- parent: 
- reconnect: 
- reconnecting: 
- session: 
- service: 
- url: 
- state: 
- level: 
- capa: 
- maxlen: 
- maxlentype: 
- namespaces: 
- authtypes: 
- istream: 
- ostream: 
- tagprefix: 
- tag: 
- nextid: 
- folder: 
- queue: 
- current: 
-
-<!-- ##### ENUM camel_imap4_engine_t ##### -->
-<para>
-
-</para>
-
- CAMEL_IMAP4_ENGINE_DISCONNECTED: 
- CAMEL_IMAP4_ENGINE_CONNECTED: 
- CAMEL_IMAP4_ENGINE_PREAUTH: 
- CAMEL_IMAP4_ENGINE_AUTHENTICATED: 
- CAMEL_IMAP4_ENGINE_SELECTED: 
-
-<!-- ##### ENUM camel_imap4_level_t ##### -->
-<para>
-
-</para>
-
- CAMEL_IMAP4_LEVEL_UNKNOWN: 
- CAMEL_IMAP4_LEVEL_IMAP4: 
- CAMEL_IMAP4_LEVEL_IMAP4REV1: 
-
-<!-- ##### ENUM camel_imap4_resp_code_t ##### -->
-<para>
-
-</para>
-
- CAMEL_IMAP4_RESP_CODE_ALERT: 
- CAMEL_IMAP4_RESP_CODE_BADCHARSET: 
- CAMEL_IMAP4_RESP_CODE_CAPABILITY: 
- CAMEL_IMAP4_RESP_CODE_PARSE: 
- CAMEL_IMAP4_RESP_CODE_PERM_FLAGS: 
- CAMEL_IMAP4_RESP_CODE_READONLY: 
- CAMEL_IMAP4_RESP_CODE_READWRITE: 
- CAMEL_IMAP4_RESP_CODE_TRYCREATE: 
- CAMEL_IMAP4_RESP_CODE_UIDNEXT: 
- CAMEL_IMAP4_RESP_CODE_UIDVALIDITY: 
- CAMEL_IMAP4_RESP_CODE_UNSEEN: 
- CAMEL_IMAP4_RESP_CODE_NEWNAME: 
- CAMEL_IMAP4_RESP_CODE_APPENDUID: 
- CAMEL_IMAP4_RESP_CODE_COPYUID: 
- CAMEL_IMAP4_RESP_CODE_UNKNOWN: 
-
-<!-- ##### STRUCT CamelIMAP4RespCode ##### -->
-<para>
-
-</para>
-
- code: 
-
-<!-- ##### STRUCT CamelIMAP4Namespace ##### -->
-<para>
-
-</para>
-
- next: 
- path: 
- sep: 
-
-<!-- ##### STRUCT CamelIMAP4NamespaceList ##### -->
-<para>
-
-</para>
-
- personal: 
- other: 
- shared: 
-
-<!-- ##### USER_FUNCTION CamelIMAP4ReconnectFunc ##### -->
-<para>
-
-</para>
-
- engine: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_new ##### -->
-<para>
-
-</para>
-
- service: 
- reconnect: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_take_stream ##### -->
-<para>
-
-</para>
-
- engine: 
- stream: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_disconnect ##### -->
-<para>
-
-</para>
-
- engine: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_capability ##### -->
-<para>
-
-</para>
-
- engine: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_namespace ##### -->
-<para>
-
-</para>
-
- engine: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_select_folder ##### -->
-<para>
-
-</para>
-
- engine: 
- folder: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_queue ##### -->
-<para>
-
-</para>
-
- engine: 
- folder: 
- format: 
- Varargs: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_prequeue ##### -->
-<para>
-
-</para>
-
- engine: 
- folder: 
- format: 
- Varargs: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_dequeue ##### -->
-<para>
-
-</para>
-
- engine: 
- ic: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_iterate ##### -->
-<para>
-
-</para>
-
- engine: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_handle_untagged_1 ##### -->
-<para>
-
-</para>
-
- engine: 
- token: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_handle_untagged ##### -->
-<para>
-
-</para>
-
- engine: 
- error: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_next_token ##### -->
-<para>
-
-</para>
-
- engine: 
- token: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_line ##### -->
-<para>
-
-</para>
-
- engine: 
- line: 
- len: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_literal ##### -->
-<para>
-
-</para>
-
- engine: 
- literal: 
- len: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_nstring ##### -->
-<para>
-
-</para>
-
- engine: 
- nstring: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_eat_line ##### -->
-<para>
-
-</para>
-
- engine: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_engine_parse_resp_code ##### -->
-<para>
-
-</para>
-
- engine: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_resp_code_free ##### -->
-<para>
-
-</para>
-
- rcode: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-folder.sgml b/docs/reference/camel/tmpl/camel-imap4-folder.sgml
index bbad80a..719a948 100644
--- a/docs/reference/camel/tmpl/camel-imap4-folder.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-folder.sgml
@@ -17,37 +17,3 @@ CamelIMAP4Folder
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Folder ##### -->
-<para>
-
-</para>
-
- parent: 
- search: 
- journal: 
- cache: 
- cachedir: 
- utf7_name: 
- read_only: 
- enable_mlist: 
-
-<!-- ##### FUNCTION camel_imap4_folder_new ##### -->
-<para>
-
-</para>
-
- store: 
- full_name: 
- error: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_folder_utf7_name ##### -->
-<para>
-
-</para>
-
- folder: 
- Returns: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-journal.sgml b/docs/reference/camel/tmpl/camel-imap4-journal.sgml
index 9812a36..399bc04 100644
--- a/docs/reference/camel/tmpl/camel-imap4-journal.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-journal.sgml
@@ -17,49 +17,3 @@ CamelIMAP4Journal
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Journal ##### -->
-<para>
-
-</para>
-
- parent: 
- failed: 
-
-<!-- ##### STRUCT CamelIMAP4JournalEntry ##### -->
-<para>
-
-</para>
-
- node: 
- type: 
-
-<!-- ##### FUNCTION camel_imap4_journal_new ##### -->
-<para>
-
-</para>
-
- folder: 
- filename: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_journal_readd_failed ##### -->
-<para>
-
-</para>
-
- journal: 
-
-
-<!-- ##### FUNCTION camel_imap4_journal_append ##### -->
-<para>
-
-</para>
-
- journal: 
- message: 
- mi: 
- appended_uid: 
- error: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-search.sgml b/docs/reference/camel/tmpl/camel-imap4-search.sgml
index 678b010..43600f5 100644
--- a/docs/reference/camel/tmpl/camel-imap4-search.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-search.sgml
@@ -17,27 +17,3 @@ CamelIMAP4Search
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Search ##### -->
-<para>
-
-</para>
-
- parent: 
- engine: 
- lastuid: 
- validity: 
- cache: 
- matches: 
- matches_hash: 
- matches_count: 
-
-<!-- ##### FUNCTION camel_imap4_search_new ##### -->
-<para>
-
-</para>
-
- engine: 
- cachedir: 
- Returns: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-specials.sgml b/docs/reference/camel/tmpl/camel-imap4-specials.sgml
index 69cb5fa..2f5837b 100644
--- a/docs/reference/camel/tmpl/camel-imap4-specials.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-specials.sgml
@@ -17,59 +17,3 @@ camel-imap4-specials
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### MACRO is_atom ##### -->
-<para>
-
-</para>
-
- x: 
-
-
-<!-- ##### MACRO is_ctrl ##### -->
-<para>
-
-</para>
-
- x: 
-
-
-<!-- ##### MACRO is_lwsp ##### -->
-<para>
-
-</para>
-
- x: 
-
-
-<!-- ##### MACRO is_type ##### -->
-<para>
-
-</para>
-
- x: 
- t: 
-
-
-<!-- ##### MACRO is_qsafe ##### -->
-<para>
-
-</para>
-
- x: 
-
-
-<!-- ##### MACRO is_wild ##### -->
-<para>
-
-</para>
-
- x: 
-
-
-<!-- ##### FUNCTION camel_imap4_specials_init ##### -->
-<para>
-
-</para>
-
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-store-summary.sgml b/docs/reference/camel/tmpl/camel-imap4-store-summary.sgml
index 8264999..b890181 100644
--- a/docs/reference/camel/tmpl/camel-imap4-store-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-store-summary.sgml
@@ -17,76 +17,3 @@ CamelIMAP4StoreSummary
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4StoreInfo ##### -->
-<para>
-
-</para>
-
- info: 
-
-<!-- ##### STRUCT CamelIMAP4StoreSummary ##### -->
-<para>
-
-</para>
-
- summary: 
- priv: 
- version: 
- namespaces: 
- capa: 
-
-<!-- ##### FUNCTION camel_imap4_store_summary_new ##### -->
-<para>
-
-</para>
-
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_store_summary_set_capabilities ##### -->
-<para>
-
-</para>
-
- s: 
- capa: 
-
-
-<!-- ##### FUNCTION camel_imap4_store_summary_set_namespaces ##### -->
-<para>
-
-</para>
-
- s: 
- ns: 
-
-
-<!-- ##### FUNCTION camel_imap4_store_summary_note_info ##### -->
-<para>
-
-</para>
-
- s: 
- fi: 
-
-
-<!-- ##### FUNCTION camel_imap4_store_summary_unnote_info ##### -->
-<para>
-
-</para>
-
- s: 
- fi: 
-
-
-<!-- ##### FUNCTION camel_imap4_store_summary_get_folder_info ##### -->
-<para>
-
-</para>
-
- s: 
- top: 
- flags: 
- Returns: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-store.sgml b/docs/reference/camel/tmpl/camel-imap4-store.sgml
index b2b6ea3..dc04e5e 100644
--- a/docs/reference/camel/tmpl/camel-imap4-store.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-store.sgml
@@ -17,13 +17,3 @@ CamelIMAP4Store
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Store ##### -->
-<para>
-
-</para>
-
- parent: 
- summary: 
- engine: 
- storage_path: 
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-stream.sgml b/docs/reference/camel/tmpl/camel-imap4-stream.sgml
index 1c9627a..0cf556b 100644
--- a/docs/reference/camel/tmpl/camel-imap4-stream.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-stream.sgml
@@ -17,96 +17,3 @@ CamelIMAP4Stream
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### MACRO IMAP4_READ_PRELEN ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### MACRO IMAP4_READ_BUFLEN ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### STRUCT camel_imap4_token_t ##### -->
-<para>
-
-</para>
-
- token: 
-
-<!-- ##### STRUCT CamelIMAP4Stream ##### -->
-<para>
-
-</para>
-
- parent: 
- stream: 
- disconnected: 
- have_unget: 
- mode: 
- eol: 
- literal: 
- realbuf: 
- inbuf: 
- inptr: 
- inend: 
- tokenbuf: 
- tokenptr: 
- tokenleft: 
- unget: 
-
-<!-- ##### FUNCTION camel_imap4_stream_new ##### -->
-<para>
-
-</para>
-
- stream: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_stream_next_token ##### -->
-<para>
-
-</para>
-
- stream: 
- token: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_stream_unget_token ##### -->
-<para>
-
-</para>
-
- stream: 
- token: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_stream_line ##### -->
-<para>
-
-</para>
-
- stream: 
- line: 
- len: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_stream_literal ##### -->
-<para>
-
-</para>
-
- stream: 
- literal: 
- len: 
- Returns: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-summary.sgml b/docs/reference/camel/tmpl/camel-imap4-summary.sgml
index 1fb3c98..7141e0f 100644
--- a/docs/reference/camel/tmpl/camel-imap4-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-summary.sgml
@@ -17,112 +17,3 @@ CamelIMAP4Summary
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT CamelIMAP4Summary ##### -->
-<para>
-
-</para>
-
- parent: 
- version: 
- exists: 
- recent: 
- unseen: 
- uidvalidity: 
- uidvalidity_changed: 
- update_flags: 
-
-<!-- ##### STRUCT CamelIMAP4MessageInfo ##### -->
-<para>
-
-</para>
-
- info: 
- server_flags: 
-
-<!-- ##### STRUCT CamelIMAP4MessageContentInfo ##### -->
-<para>
-
-</para>
-
- info: 
-
-<!-- ##### MACRO CAMEL_IMAP4_MESSAGE_RECENT ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### FUNCTION camel_imap4_summary_new ##### -->
-<para>
-
-</para>
-
- folder: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_set_exists ##### -->
-<para>
-
-</para>
-
- summary: 
- exists: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_set_recent ##### -->
-<para>
-
-</para>
-
- summary: 
- recent: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_set_unseen ##### -->
-<para>
-
-</para>
-
- summary: 
- unseen: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_set_uidnext ##### -->
-<para>
-
-</para>
-
- summary: 
- uidnext: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_set_uidvalidity ##### -->
-<para>
-
-</para>
-
- summary: 
- uidvalidity: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_expunge ##### -->
-<para>
-
-</para>
-
- summary: 
- seqid: 
-
-
-<!-- ##### FUNCTION camel_imap4_summary_flush_updates ##### -->
-<para>
-
-</para>
-
- summary: 
- error: 
- Returns: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-imap4-utils.sgml b/docs/reference/camel/tmpl/camel-imap4-utils.sgml
index f351e20..6eb5d85 100644
--- a/docs/reference/camel/tmpl/camel-imap4-utils.sgml
+++ b/docs/reference/camel/tmpl/camel-imap4-utils.sgml
@@ -25,188 +25,3 @@ camel-imap4-utils
 @changed: 
 @bits: 
 
-<!-- ##### FUNCTION camel_imap4_flags_diff ##### -->
-<para>
-
-</para>
-
- diff: 
- old: 
- new: 
-
-
-<!-- ##### FUNCTION camel_imap4_flags_merge ##### -->
-<para>
-
-</para>
-
- diff: 
- flags: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_merge_flags ##### -->
-<para>
-
-</para>
-
- original: 
- local: 
- server: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_build_folder_info_tree ##### -->
-<para>
-
-</para>
-
- array: 
- top: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_namespace_clear ##### -->
-<para>
-
-</para>
-
- ns: 
-
-
-<!-- ##### FUNCTION camel_imap4_namespace_list_copy ##### -->
-<para>
-
-</para>
-
- nsl: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_namespace_list_free ##### -->
-<para>
-
-</para>
-
- nsl: 
-
-
-<!-- ##### FUNCTION camel_imap4_get_path_delim ##### -->
-<para>
-
-</para>
-
- s: 
- full_name: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_get_uid_set ##### -->
-<para>
-
-</para>
-
- engine: 
- summary: 
- infos: 
- cur: 
- linelen: 
- set: 
- Returns: 
-
-
-<!-- ##### FUNCTION camel_imap4_utils_set_unexpected_token_error ##### -->
-<para>
-
-</para>
-
- error: 
- engine: 
- token: 
-
-
-<!-- ##### FUNCTION camel_imap4_parse_flags_list ##### -->
-<para>
-
-</para>
-
- engine: 
- flags: 
- error: 
- Returns: 
-
-
-<!-- ##### MACRO CAMEL_IMAP4_FOLDER_MARKED ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### MACRO CAMEL_IMAP4_FOLDER_UNMARKED ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### STRUCT camel_imap4_list_t ##### -->
-<para>
-
-</para>
-
- flags: 
- delim: 
- name: 
-
-<!-- ##### FUNCTION camel_imap4_untagged_list ##### -->
-<para>
-
-</para>
-
- engine: 
- ic: 
- index: 
- token: 
- error: 
- Returns: 
-
-
-<!-- ##### STRUCT camel_imap4_status_attr_t ##### -->
-<para>
-
-</para>
-
- next: 
- type: 
- value: 
-
-<!-- ##### STRUCT camel_imap4_status_t ##### -->
-<para>
-
-</para>
-
- attr_list: 
- mailbox: 
-
-<!-- ##### FUNCTION camel_imap4_status_free ##### -->
-<para>
-
-</para>
-
- status: 
-
-
-<!-- ##### FUNCTION camel_imap4_untagged_status ##### -->
-<para>
-
-</para>
-
- engine: 
- ic: 
- index: 
- token: 
- error: 
- Returns: 
-
-
diff --git a/docs/reference/camel/tmpl/camel-unused.sgml b/docs/reference/camel/tmpl/camel-unused.sgml
index 9d3f1fd..f0e1191 100644
--- a/docs/reference/camel/tmpl/camel-unused.sgml
+++ b/docs/reference/camel/tmpl/camel-unused.sgml
@@ -342,6 +342,24 @@ camel-types
 @f: 
 @l: 
 
+<!-- ##### MACRO CAMEL_IMAP4_FOLDER_MARKED ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### MACRO CAMEL_IMAP4_FOLDER_UNMARKED ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### MACRO CAMEL_IMAP4_MESSAGE_RECENT ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### MACRO CAMEL_IMAP_FOLDER_LOCK ##### -->
 <para>
 
@@ -449,6 +467,260 @@ camel-types
 </para>
 
 
+<!-- ##### STRUCT CamelIMAP4Command ##### -->
+<para>
+
+</para>
+
+ node: 
+ engine: 
+ ref_count: 
+ status: 
+ result: 
+ id: 
+ tag: 
+ resp_codes: 
+ folder: 
+ ex: 
+ parts: 
+ part: 
+ untagged: 
+ plus: 
+ reset: 
+ user_data: 
+
+<!-- ##### STRUCT CamelIMAP4CommandPart ##### -->
+<para>
+
+</para>
+
+ next: 
+ buffer: 
+ buflen: 
+ literal: 
+
+<!-- ##### USER_FUNCTION CamelIMAP4CommandReset ##### -->
+<para>
+
+</para>
+
+ ic: 
+ user_data: 
+
+<!-- ##### STRUCT CamelIMAP4Engine ##### -->
+<para>
+
+</para>
+
+ parent: 
+ reconnect: 
+ reconnecting: 
+ session: 
+ service: 
+ url: 
+ state: 
+ level: 
+ capa: 
+ maxlen: 
+ maxlentype: 
+ namespaces: 
+ authtypes: 
+ istream: 
+ ostream: 
+ tagprefix: 
+ tag: 
+ nextid: 
+ folder: 
+ queue: 
+ current: 
+
+<!-- ##### STRUCT CamelIMAP4Folder ##### -->
+<para>
+
+</para>
+
+ parent: 
+ search: 
+ journal: 
+ cache: 
+ cachedir: 
+ utf7_name: 
+ read_only: 
+ enable_mlist: 
+
+<!-- ##### STRUCT CamelIMAP4Journal ##### -->
+<para>
+
+</para>
+
+ parent: 
+ failed: 
+
+<!-- ##### STRUCT CamelIMAP4JournalEntry ##### -->
+<para>
+
+</para>
+
+ node: 
+ type: 
+
+<!-- ##### STRUCT CamelIMAP4Literal ##### -->
+<para>
+
+</para>
+
+ type: 
+
+<!-- ##### STRUCT CamelIMAP4MessageContentInfo ##### -->
+<para>
+
+</para>
+
+ info: 
+
+<!-- ##### STRUCT CamelIMAP4MessageInfo ##### -->
+<para>
+
+</para>
+
+ info: 
+ server_flags: 
+
+<!-- ##### STRUCT CamelIMAP4Namespace ##### -->
+<para>
+
+</para>
+
+ next: 
+ path: 
+ sep: 
+
+<!-- ##### STRUCT CamelIMAP4NamespaceList ##### -->
+<para>
+
+</para>
+
+ personal: 
+ other: 
+ shared: 
+
+<!-- ##### USER_FUNCTION CamelIMAP4PlusCallback ##### -->
+<para>
+
+</para>
+
+ engine: 
+ ic: 
+ linebuf: 
+ linelen: 
+ error: 
+ Returns: 
+
+<!-- ##### USER_FUNCTION CamelIMAP4ReconnectFunc ##### -->
+<para>
+
+</para>
+
+ engine: 
+ error: 
+ Returns: 
+
+<!-- ##### STRUCT CamelIMAP4RespCode ##### -->
+<para>
+
+</para>
+
+ code: 
+
+<!-- ##### STRUCT CamelIMAP4Search ##### -->
+<para>
+
+</para>
+
+ parent: 
+ engine: 
+ lastuid: 
+ validity: 
+ cache: 
+ matches: 
+ matches_hash: 
+ matches_count: 
+
+<!-- ##### STRUCT CamelIMAP4Store ##### -->
+<para>
+
+</para>
+
+ parent: 
+ summary: 
+ engine: 
+ storage_path: 
+
+<!-- ##### STRUCT CamelIMAP4StoreInfo ##### -->
+<para>
+
+</para>
+
+ info: 
+
+<!-- ##### STRUCT CamelIMAP4StoreSummary ##### -->
+<para>
+
+</para>
+
+ summary: 
+ priv: 
+ version: 
+ namespaces: 
+ capa: 
+
+<!-- ##### STRUCT CamelIMAP4Stream ##### -->
+<para>
+
+</para>
+
+ parent: 
+ stream: 
+ disconnected: 
+ have_unget: 
+ mode: 
+ eol: 
+ literal: 
+ realbuf: 
+ inbuf: 
+ inptr: 
+ inend: 
+ tokenbuf: 
+ tokenptr: 
+ tokenleft: 
+ unget: 
+
+<!-- ##### STRUCT CamelIMAP4Summary ##### -->
+<para>
+
+</para>
+
+ parent: 
+ version: 
+ exists: 
+ recent: 
+ unseen: 
+ uidvalidity: 
+ uidvalidity_changed: 
+ update_flags: 
+
+<!-- ##### USER_FUNCTION CamelIMAP4UntaggedCallback ##### -->
+<para>
+
+</para>
+
+ engine: 
+ ic: 
+ index: 
+ token: 
+ error: 
+ Returns: 
+
 <!-- ##### STRUCT CamelImapFolderPrivate ##### -->
 <para>
 
@@ -584,6 +856,18 @@ camel-types
 </para>
 
 
+<!-- ##### MACRO IMAP4_READ_BUFLEN ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### MACRO IMAP4_READ_PRELEN ##### -->
+<para>
+
+</para>
+
+
 <!-- ##### FUNCTION camel_data_cache_clear ##### -->
 <para>
 
@@ -605,6 +889,668 @@ camel-types
 @error: 
 @Returns: 
 
+<!-- ##### FUNCTION camel_imap4_build_folder_info_tree ##### -->
+<para>
+
+</para>
+
+ array: 
+ top: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_command_new ##### -->
+<para>
+
+</para>
+
+ engine: 
+ folder: 
+ format: 
+ Varargs: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_command_newv ##### -->
+<para>
+
+</para>
+
+ engine: 
+ folder: 
+ format: 
+ args: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_command_ref ##### -->
+<para>
+
+</para>
+
+ ic: 
+
+<!-- ##### FUNCTION camel_imap4_command_register_untagged ##### -->
+<para>
+
+</para>
+
+ ic: 
+ atom: 
+ untagged: 
+
+<!-- ##### FUNCTION camel_imap4_command_reset ##### -->
+<para>
+
+</para>
+
+ ic: 
+
+<!-- ##### FUNCTION camel_imap4_command_step ##### -->
+<para>
+
+</para>
+
+ ic: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_command_unref ##### -->
+<para>
+
+</para>
+
+ ic: 
+
+<!-- ##### FUNCTION camel_imap4_engine_capability ##### -->
+<para>
+
+</para>
+
+ engine: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_dequeue ##### -->
+<para>
+
+</para>
+
+ engine: 
+ ic: 
+
+<!-- ##### FUNCTION camel_imap4_engine_disconnect ##### -->
+<para>
+
+</para>
+
+ engine: 
+
+<!-- ##### FUNCTION camel_imap4_engine_eat_line ##### -->
+<para>
+
+</para>
+
+ engine: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_handle_untagged ##### -->
+<para>
+
+</para>
+
+ engine: 
+ error: 
+
+<!-- ##### FUNCTION camel_imap4_engine_handle_untagged_1 ##### -->
+<para>
+
+</para>
+
+ engine: 
+ token: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_iterate ##### -->
+<para>
+
+</para>
+
+ engine: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_line ##### -->
+<para>
+
+</para>
+
+ engine: 
+ line: 
+ len: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_literal ##### -->
+<para>
+
+</para>
+
+ engine: 
+ literal: 
+ len: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_namespace ##### -->
+<para>
+
+</para>
+
+ engine: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_new ##### -->
+<para>
+
+</para>
+
+ service: 
+ reconnect: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_next_token ##### -->
+<para>
+
+</para>
+
+ engine: 
+ token: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_nstring ##### -->
+<para>
+
+</para>
+
+ engine: 
+ nstring: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_parse_resp_code ##### -->
+<para>
+
+</para>
+
+ engine: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_prequeue ##### -->
+<para>
+
+</para>
+
+ engine: 
+ folder: 
+ format: 
+ Varargs: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_queue ##### -->
+<para>
+
+</para>
+
+ engine: 
+ folder: 
+ format: 
+ Varargs: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_engine_select_folder ##### -->
+<para>
+
+</para>
+
+ engine: 
+ folder: 
+ error: 
+ Returns: 
+
+<!-- ##### ENUM camel_imap4_engine_t ##### -->
+<para>
+
+</para>
+
+ CAMEL_IMAP4_ENGINE_DISCONNECTED: 
+ CAMEL_IMAP4_ENGINE_CONNECTED: 
+ CAMEL_IMAP4_ENGINE_PREAUTH: 
+ CAMEL_IMAP4_ENGINE_AUTHENTICATED: 
+ CAMEL_IMAP4_ENGINE_SELECTED: 
+
+<!-- ##### FUNCTION camel_imap4_engine_take_stream ##### -->
+<para>
+
+</para>
+
+ engine: 
+ stream: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_flags_diff ##### -->
+<para>
+
+</para>
+
+ diff: 
+ old: 
+ new: 
+
+<!-- ##### FUNCTION camel_imap4_flags_merge ##### -->
+<para>
+
+</para>
+
+ diff: 
+ flags: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_folder_new ##### -->
+<para>
+
+</para>
+
+ store: 
+ full_name: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_folder_utf7_name ##### -->
+<para>
+
+</para>
+
+ folder: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_get_path_delim ##### -->
+<para>
+
+</para>
+
+ s: 
+ full_name: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_get_uid_set ##### -->
+<para>
+
+</para>
+
+ engine: 
+ summary: 
+ infos: 
+ cur: 
+ linelen: 
+ set: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_journal_append ##### -->
+<para>
+
+</para>
+
+ journal: 
+ message: 
+ mi: 
+ appended_uid: 
+ error: 
+
+<!-- ##### FUNCTION camel_imap4_journal_new ##### -->
+<para>
+
+</para>
+
+ folder: 
+ filename: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_journal_readd_failed ##### -->
+<para>
+
+</para>
+
+ journal: 
+
+<!-- ##### ENUM camel_imap4_level_t ##### -->
+<para>
+
+</para>
+
+ CAMEL_IMAP4_LEVEL_UNKNOWN: 
+ CAMEL_IMAP4_LEVEL_IMAP4: 
+ CAMEL_IMAP4_LEVEL_IMAP4REV1: 
+
+<!-- ##### STRUCT camel_imap4_list_t ##### -->
+<para>
+
+</para>
+
+ flags: 
+ delim: 
+ name: 
+
+<!-- ##### FUNCTION camel_imap4_merge_flags ##### -->
+<para>
+
+</para>
+
+ original: 
+ local: 
+ server: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_namespace_clear ##### -->
+<para>
+
+</para>
+
+ ns: 
+
+<!-- ##### FUNCTION camel_imap4_namespace_list_copy ##### -->
+<para>
+
+</para>
+
+ nsl: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_namespace_list_free ##### -->
+<para>
+
+</para>
+
+ nsl: 
+
+<!-- ##### FUNCTION camel_imap4_parse_flags_list ##### -->
+<para>
+
+</para>
+
+ engine: 
+ flags: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_resp_code_free ##### -->
+<para>
+
+</para>
+
+ rcode: 
+
+<!-- ##### ENUM camel_imap4_resp_code_t ##### -->
+<para>
+
+</para>
+
+ CAMEL_IMAP4_RESP_CODE_ALERT: 
+ CAMEL_IMAP4_RESP_CODE_BADCHARSET: 
+ CAMEL_IMAP4_RESP_CODE_CAPABILITY: 
+ CAMEL_IMAP4_RESP_CODE_PARSE: 
+ CAMEL_IMAP4_RESP_CODE_PERM_FLAGS: 
+ CAMEL_IMAP4_RESP_CODE_READONLY: 
+ CAMEL_IMAP4_RESP_CODE_READWRITE: 
+ CAMEL_IMAP4_RESP_CODE_TRYCREATE: 
+ CAMEL_IMAP4_RESP_CODE_UIDNEXT: 
+ CAMEL_IMAP4_RESP_CODE_UIDVALIDITY: 
+ CAMEL_IMAP4_RESP_CODE_UNSEEN: 
+ CAMEL_IMAP4_RESP_CODE_NEWNAME: 
+ CAMEL_IMAP4_RESP_CODE_APPENDUID: 
+ CAMEL_IMAP4_RESP_CODE_COPYUID: 
+ CAMEL_IMAP4_RESP_CODE_UNKNOWN: 
+
+<!-- ##### FUNCTION camel_imap4_search_new ##### -->
+<para>
+
+</para>
+
+ engine: 
+ cachedir: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_specials_init ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### STRUCT camel_imap4_status_attr_t ##### -->
+<para>
+
+</para>
+
+ next: 
+ type: 
+ value: 
+
+<!-- ##### FUNCTION camel_imap4_status_free ##### -->
+<para>
+
+</para>
+
+ status: 
+
+<!-- ##### STRUCT camel_imap4_status_t ##### -->
+<para>
+
+</para>
+
+ attr_list: 
+ mailbox: 
+
+<!-- ##### FUNCTION camel_imap4_store_summary_get_folder_info ##### -->
+<para>
+
+</para>
+
+ s: 
+ top: 
+ flags: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_store_summary_new ##### -->
+<para>
+
+</para>
+
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_store_summary_note_info ##### -->
+<para>
+
+</para>
+
+ s: 
+ fi: 
+
+<!-- ##### FUNCTION camel_imap4_store_summary_set_capabilities ##### -->
+<para>
+
+</para>
+
+ s: 
+ capa: 
+
+<!-- ##### FUNCTION camel_imap4_store_summary_set_namespaces ##### -->
+<para>
+
+</para>
+
+ s: 
+ ns: 
+
+<!-- ##### FUNCTION camel_imap4_store_summary_unnote_info ##### -->
+<para>
+
+</para>
+
+ s: 
+ fi: 
+
+<!-- ##### FUNCTION camel_imap4_stream_line ##### -->
+<para>
+
+</para>
+
+ stream: 
+ line: 
+ len: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_stream_literal ##### -->
+<para>
+
+</para>
+
+ stream: 
+ literal: 
+ len: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_stream_new ##### -->
+<para>
+
+</para>
+
+ stream: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_stream_next_token ##### -->
+<para>
+
+</para>
+
+ stream: 
+ token: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_stream_unget_token ##### -->
+<para>
+
+</para>
+
+ stream: 
+ token: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_summary_expunge ##### -->
+<para>
+
+</para>
+
+ summary: 
+ seqid: 
+
+<!-- ##### FUNCTION camel_imap4_summary_flush_updates ##### -->
+<para>
+
+</para>
+
+ summary: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_summary_new ##### -->
+<para>
+
+</para>
+
+ folder: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_summary_set_exists ##### -->
+<para>
+
+</para>
+
+ summary: 
+ exists: 
+
+<!-- ##### FUNCTION camel_imap4_summary_set_recent ##### -->
+<para>
+
+</para>
+
+ summary: 
+ recent: 
+
+<!-- ##### FUNCTION camel_imap4_summary_set_uidnext ##### -->
+<para>
+
+</para>
+
+ summary: 
+ uidnext: 
+
+<!-- ##### FUNCTION camel_imap4_summary_set_uidvalidity ##### -->
+<para>
+
+</para>
+
+ summary: 
+ uidvalidity: 
+
+<!-- ##### FUNCTION camel_imap4_summary_set_unseen ##### -->
+<para>
+
+</para>
+
+ summary: 
+ unseen: 
+
+<!-- ##### STRUCT camel_imap4_token_t ##### -->
+<para>
+
+</para>
+
+ token: 
+
+<!-- ##### FUNCTION camel_imap4_untagged_list ##### -->
+<para>
+
+</para>
+
+ engine: 
+ ic: 
+ index: 
+ token: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_untagged_status ##### -->
+<para>
+
+</para>
+
+ engine: 
+ ic: 
+ index: 
+ token: 
+ error: 
+ Returns: 
+
+<!-- ##### FUNCTION camel_imap4_utils_set_unexpected_token_error ##### -->
+<para>
+
+</para>
+
+ error: 
+ engine: 
+ token: 
+
 <!-- ##### FUNCTION camel_index_set_normalise ##### -->
 <para>
 
@@ -920,3 +1866,46 @@ camel-types
 @needle: 
 @Returns: 
 
+<!-- ##### MACRO is_atom ##### -->
+<para>
+
+</para>
+
+ x: 
+
+<!-- ##### MACRO is_ctrl ##### -->
+<para>
+
+</para>
+
+ x: 
+
+<!-- ##### MACRO is_lwsp ##### -->
+<para>
+
+</para>
+
+ x: 
+
+<!-- ##### MACRO is_qsafe ##### -->
+<para>
+
+</para>
+
+ x: 
+
+<!-- ##### MACRO is_type ##### -->
+<para>
+
+</para>
+
+ x: 
+ t: 
+
+<!-- ##### MACRO is_wild ##### -->
+<para>
+
+</para>
+
+ x: 
+



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