[evolution-exchange] Adapt to Camel API changes.



commit e6a82d571be79b4030019336584edb3986d620c7
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Sep 18 22:28:16 2010 -0400

    Adapt to Camel API changes.

 addressbook/e-book-backend-exchange.c |   15 +-
 calendar/e-cal-backend-exchange.c     |   14 +-
 camel/camel-exchange-folder.c         |  400 +++++++++++++++++----------------
 camel/camel-exchange-folder.h         |   71 ++++---
 camel/camel-exchange-journal.c        |   40 +++--
 camel/camel-exchange-journal.h        |    2 +
 camel/camel-exchange-search.c         |    2 +-
 camel/camel-exchange-store.c          |  242 +++++++++++----------
 camel/camel-exchange-store.h          |    1 +
 camel/camel-exchange-summary.c        |   19 +-
 camel/camel-exchange-transport.c      |   19 +-
 camel/camel-exchange-utils.c          |   42 ++--
 camel/camel-exchange-utils.h          |  270 ++++++++++++-----------
 eplugin/exchange-delegates-user.c     |    6 +-
 14 files changed, 615 insertions(+), 528 deletions(-)
---
diff --git a/addressbook/e-book-backend-exchange.c b/addressbook/e-book-backend-exchange.c
index d2a3127..24eb3b0 100644
--- a/addressbook/e-book-backend-exchange.c
+++ b/addressbook/e-book-backend-exchange.c
@@ -526,7 +526,8 @@ e_contact_from_props (EBookBackendExchange *be, E2kResult *result)
 	stream = camel_stream_mem_new_with_buffer (response->data, response->length);
 	soup_buffer_free (response);
 	msg = camel_mime_message_new ();
-	camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream, NULL);
+	camel_data_wrapper_construct_from_stream_sync (
+		CAMEL_DATA_WRAPPER (msg), stream, NULL, NULL);
 	g_object_unref (stream);
 
 	content = camel_medium_get_content (CAMEL_MEDIUM (msg));
@@ -549,7 +550,8 @@ e_contact_from_props (EBookBackendExchange *be, E2kResult *result)
 
 			byte_array = g_byte_array_new ();
 			stream = camel_stream_mem_new_with_byte_array (byte_array);
-			camel_data_wrapper_decode_to_stream (content, stream, NULL);
+			camel_data_wrapper_decode_to_stream_sync (
+				content, stream, NULL, NULL);
 
 			photo.type = E_CONTACT_PHOTO_TYPE_INLINED;
 			photo.data.inlined.mime_type = NULL;
@@ -1379,7 +1381,8 @@ build_message (const gchar *from_name, const gchar *from_email,
 	if (note) {
 		stream = camel_stream_mem_new_with_buffer (note, strlen (note));
 		wrapper = camel_data_wrapper_new ();
-		camel_data_wrapper_construct_from_stream (wrapper, stream, NULL);
+		camel_data_wrapper_construct_from_stream_sync (
+			wrapper, stream, NULL, NULL);
 		g_object_unref (stream);
 
 		type = camel_content_type_new ("text", "plain");
@@ -1433,7 +1436,8 @@ build_message (const gchar *from_name, const gchar *from_email,
 		stream = camel_stream_mem_new_with_byte_array (photo_ba);
 
 		wrapper = camel_data_wrapper_new ();
-		camel_data_wrapper_construct_from_stream (wrapper, stream, NULL);
+		camel_data_wrapper_construct_from_stream_sync (
+			wrapper, stream, NULL, NULL);
 		g_object_unref (stream);
 		camel_data_wrapper_set_mime_type (wrapper, content_type);
 
@@ -1464,7 +1468,8 @@ build_message (const gchar *from_name, const gchar *from_email,
 	buffer = g_byte_array_new ();
 	stream = camel_stream_mem_new ();
 	camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), buffer);
-	camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), stream, NULL);
+	camel_data_wrapper_write_to_stream_sync (
+		CAMEL_DATA_WRAPPER (msg), stream, NULL, NULL);
 	g_object_unref (stream);
 	g_object_unref (msg);
 
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index 384a55f..a3ea7b2 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -1724,7 +1724,7 @@ save_attach_file (const gchar *dest_file, gchar *file_contents, gint len)
 		goto end;
 	}
 
-	if (camel_write (fd, file_contents, len, NULL) < 0) {
+	if (camel_write (fd, file_contents, len, NULL, NULL) < 0) {
 		d(printf ("camel write to attach file failed\n"));
 		goto end;
 	}
@@ -1753,7 +1753,8 @@ get_attachment (ECalBackendExchange *cbex, const gchar *uid,
 
 	stream = camel_stream_mem_new_with_buffer (body, len);
 	msg = camel_mime_message_new ();
-	camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream, NULL);
+	camel_data_wrapper_construct_from_stream_sync (
+		CAMEL_DATA_WRAPPER (msg), stream, NULL, NULL);
 	g_object_unref (stream);
 
 	msg_content = camel_medium_get_content (CAMEL_MEDIUM (msg));
@@ -1770,7 +1771,7 @@ get_attachment (ECalBackendExchange *cbex, const gchar *uid,
 
 				byte_array = g_byte_array_new ();
 				stream = camel_stream_mem_new_with_byte_array (byte_array);
-				camel_data_wrapper_decode_to_stream (content, stream, NULL);
+				camel_data_wrapper_decode_to_stream_sync (content, stream, NULL, NULL);
 				attach_data = g_memdup (byte_array->data, byte_array->len);
 				attach_file = g_strdup_printf ("%s/%s-%s", cbex->priv->local_attachment_store, uid, filename);
 				// Attach
@@ -1810,7 +1811,7 @@ get_attach_file_contents (const gchar *filename, gint *length)
 	if (len > 0) {
 		file_contents = g_malloc0 (len + 1);
 
-		if (camel_read (fd, file_contents, len, NULL) < 0) {
+		if (camel_read (fd, file_contents, len, NULL, NULL) < 0) {
 			d(printf ("reading from the attachment file failed\n"));
 			g_free (file_contents);
 			file_contents = NULL;
@@ -2049,7 +2050,8 @@ build_msg ( ECalBackendExchange *cbex, ECalComponent *comp, const gchar *subject
 		/* Content */
 		stream = camel_stream_mem_new_with_buffer (file_contents, len);
 		wrapper = camel_data_wrapper_new ();
-		camel_data_wrapper_construct_from_stream (wrapper, stream, NULL);
+		camel_data_wrapper_construct_from_stream_sync (
+			wrapper, stream, NULL, NULL);
 		g_object_unref (stream);
 
 		mime_type = get_mime_type (dest_url);
@@ -2089,7 +2091,7 @@ build_msg ( ECalBackendExchange *cbex, ECalComponent *comp, const gchar *subject
 	byte_array = g_byte_array_new ();
 	stream = camel_stream_mem_new_with_byte_array (byte_array);
 	dw = camel_medium_get_content (CAMEL_MEDIUM (msg));
-	camel_data_wrapper_decode_to_stream (dw, stream, NULL);
+	camel_data_wrapper_decode_to_stream_sync (dw, stream, NULL, NULL);
 	buffer = g_memdup (byte_array->data, byte_array->len);
 	buffer[byte_array->len] = '\0';
 	d(printf ("|| Buffer: \n%s\n", buffer));
diff --git a/camel/camel-exchange-folder.c b/camel/camel-exchange-folder.c
index f064089..0b670ae 100644
--- a/camel/camel-exchange-folder.c
+++ b/camel/camel-exchange-folder.c
@@ -55,8 +55,9 @@ static gboolean
 exchange_folder_append_message_data (CamelFolder *folder,
                                      GByteArray *message,
                                      const gchar *subject,
-                                     const CamelMessageInfo *info,
+                                     CamelMessageInfo *info,
                                      gchar **appended_uid,
+                                     GCancellable *cancellable,
                                      GError **error)
 {
 	CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
@@ -85,8 +86,8 @@ exchange_folder_append_message_data (CamelFolder *folder,
 		if (stream_cache) {
 			camel_stream_write (stream_cache,
 					    (gchar *) message->data,
-					    message->len, NULL);
-			camel_stream_flush (stream_cache, NULL);
+					    message->len, cancellable, NULL);
+			camel_stream_flush (stream_cache, cancellable, NULL);
 			g_object_unref (stream_cache);
 		}
 		if (appended_uid)
@@ -102,6 +103,7 @@ exchange_folder_append_message_data (CamelFolder *folder,
 static GByteArray *
 exchange_folder_get_message_data (CamelFolder *folder,
                                   const gchar *uid,
+                                  GCancellable *cancellable,
                                   GError **error)
 {
 	CamelExchangeFolder *exch;
@@ -123,14 +125,14 @@ exchange_folder_get_message_data (CamelFolder *folder,
 		stream_mem = camel_stream_mem_new ();
 		camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream_mem), ba);
 		camel_stream_reset (stream, NULL);
-		camel_stream_write_to_stream (stream, stream_mem, NULL);
+		camel_stream_write_to_stream (stream, stream_mem, cancellable, NULL);
 		g_object_unref (CAMEL_OBJECT (stream_mem));
 		g_object_unref (CAMEL_OBJECT (stream));
 
 		return ba;
 	}
 
-	if (!camel_exchange_store_connected (store, NULL)) {
+	if (!camel_exchange_store_connected (store, cancellable, NULL)) {
 		g_set_error (
 			error, CAMEL_SERVICE_ERROR,
 			CAMEL_SERVICE_ERROR_UNAVAILABLE,
@@ -148,8 +150,8 @@ exchange_folder_get_message_data (CamelFolder *folder,
 		return NULL;
 	}
 
-	camel_stream_write (stream, (gchar *) ba->data, ba->len, NULL);
-	camel_stream_flush (stream, NULL);
+	camel_stream_write (stream, (gchar *) ba->data, ba->len, cancellable, NULL);
+	camel_stream_flush (stream, cancellable, NULL);
 	g_object_unref (stream);
 
 	return ba;
@@ -215,6 +217,7 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
                                                 CamelFolder *dest,
                                                 GPtrArray **transferred_uids,
                                                 gboolean delete_originals,
+                                                GCancellable *cancellable,
                                                 GError **error)
 {
 	CamelMessageInfo *info;
@@ -237,7 +240,7 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
 			continue;
 
 		ba = exchange_folder_get_message_data (
-			source, uids->pdata[i], error);
+			source, uids->pdata[i], cancellable, error);
 		if (!ba) {
 			camel_message_info_free (info);
 			success = FALSE;
@@ -245,7 +248,7 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
 		}
 
 		success = exchange_folder_append_message_data (
-			dest, ba, NULL, info, &ret_uid, error);
+			dest, ba, NULL, info, &ret_uid, cancellable, error);
 		camel_message_info_free (info);
 		g_byte_array_free (ba, TRUE);
 
@@ -260,7 +263,8 @@ exchange_folder_transfer_messages_the_hard_way (CamelFolder *source,
 
 	if (success && delete_originals)
 		success = camel_exchange_utils_expunge_uids (
-			CAMEL_SERVICE (parent_store), full_name, uids, error);
+			CAMEL_SERVICE (parent_store),
+			full_name, uids, cancellable, error);
 
 	return success;
 }
@@ -287,7 +291,7 @@ exchange_folder_cache_xfer (CamelExchangeFolder *folder_source,
 		dest = camel_data_cache_add (folder_dest->cache, "cache",
 					     dest_uids->pdata[i], NULL);
 		if (dest) {
-			camel_stream_write_to_stream (src, dest, NULL);
+			camel_stream_write_to_stream (src, dest, NULL, NULL);
 			g_object_unref (dest);
 		}
 		g_object_unref (src);
@@ -327,99 +331,91 @@ exchange_folder_finalize (GObject *object)
 	G_OBJECT_CLASS (camel_exchange_folder_parent_class)->finalize (object);
 }
 
-static gboolean
-exchange_folder_refresh_info (CamelFolder *folder,
-                              GError **error)
+static gint
+exchange_folder_cmp_uids (CamelFolder *folder,
+                          const gchar *uid1,
+                          const gchar *uid2)
 {
-	CamelExchangeFolder *exch;
-	CamelExchangeStore *store;
-	CamelStore *parent_store;
-	guint32 unread_count, visible_count;
-	const gchar *full_name;
-	gboolean success = TRUE;
-
-	full_name = camel_folder_get_full_name (folder);
-	parent_store = camel_folder_get_parent_store (folder);
+	g_return_val_if_fail (uid1 != NULL, 0);
+	g_return_val_if_fail (uid2 != NULL, 0);
 
-	exch = CAMEL_EXCHANGE_FOLDER (folder);
-	store = CAMEL_EXCHANGE_STORE (parent_store);
+	return strcmp (uid1, uid2);
+}
 
-	if (camel_exchange_store_connected (store, NULL)) {
-		camel_offline_journal_replay (exch->journal, NULL);
+static GPtrArray *
+exchange_folder_search_by_expression (CamelFolder *folder,
+                                      const gchar *expression,
+                                      GError **error)
+{
+	CamelFolderSearch *search;
+	GPtrArray *matches;
 
-		camel_exchange_utils_refresh_folder (
-			CAMEL_SERVICE (parent_store), full_name, NULL);
-	}
+	search = camel_exchange_search_new ();
+	camel_folder_search_set_folder (search, folder);
 
-	/* sync up the counts now */
-	if (!camel_exchange_utils_sync_count (
-		CAMEL_SERVICE (parent_store), full_name,
-		&unread_count, &visible_count, error)) {
-		g_print("\n Error syncing up the counts");
-		success = FALSE;
-	}
+	matches = camel_folder_search_search (
+		search, expression, NULL, error);
 
-	folder->summary->unread_count = unread_count;
-	folder->summary->visible_count = visible_count;
+	g_object_unref (search);
 
-	return success;
+	return matches;
 }
 
-static gboolean
-exchange_folder_expunge (CamelFolder *folder,
-                         GError **error)
+static GPtrArray *
+exchange_folder_search_by_uids (CamelFolder *folder,
+                                const gchar *expression,
+                                GPtrArray *uids,
+                                GError **error)
 {
-	CamelFolder *trash;
-	GPtrArray *uids;
-	CamelExchangeStore *store;
-	CamelStore *parent_store;
-	const gchar *full_name;
-	gboolean success;
+	CamelFolderSearch *search;
+	GPtrArray *matches;
 
-	parent_store = camel_folder_get_parent_store (folder);
-	store = CAMEL_EXCHANGE_STORE (parent_store);
+	search = camel_exchange_search_new ();
+	camel_folder_search_set_folder (search, folder);
+	camel_folder_search_set_summary (search, uids);
 
-	if (!camel_exchange_store_connected (store, NULL)) {
-		g_set_error (
-			error, CAMEL_SERVICE_ERROR,
-			CAMEL_SERVICE_ERROR_UNAVAILABLE,
-			_("You cannot expunge in offline mode."));
-		return FALSE;
-	}
+	matches = camel_folder_search_execute_expression (
+		search, expression, error);
 
-	trash = camel_store_get_trash (parent_store, NULL);
-	if (!trash) {
-		printf ("Expunge failed, could not read trash folder\n");
-		return TRUE;  /* XXX exception not set */
-	}
+	g_object_unref (search);
 
-	uids = camel_folder_get_uids (trash);
-	full_name = camel_folder_get_full_name (trash);
-	success = camel_exchange_utils_expunge_uids (
-		CAMEL_SERVICE (parent_store), full_name, uids, error);
-	camel_folder_free_uids (trash, uids);
-	g_object_unref (trash);
+	return matches;
+}
 
-	return success;
+static guint32
+exchange_folder_count_by_expression (CamelFolder *folder,
+                                     const gchar *expression,
+                                     GError **error)
+{
+	CamelFolderSearch *search;
+	guint32 matches;
+
+	search = camel_exchange_search_new ();
+	camel_folder_search_set_folder (search, folder);
+	matches = camel_folder_search_count (search, expression, error);
+
+	g_object_unref (search);
+
+	return matches;
 }
 
-static gboolean
-exchange_folder_sync (CamelFolder *folder,
-                      gboolean expunge,
-                      GError **error)
+static gchar *
+exchange_folder_get_filename (CamelFolder *folder,
+                              const gchar *uid,
+                              GError **error)
 {
-	if (expunge)
-		exchange_folder_expunge (folder, NULL);
+	CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
 
-	return camel_folder_summary_save_to_db (folder->summary, error) == 0;
+	return camel_data_cache_get_filename (exch->cache, "cache", uid, NULL);
 }
 
 static gboolean
-exchange_folder_append_message (CamelFolder *folder,
-                                CamelMimeMessage *message,
-                                const CamelMessageInfo *info,
-                                gchar **appended_uid,
-                                GError **error)
+exchange_folder_append_message_sync (CamelFolder *folder,
+                                     CamelMimeMessage *message,
+                                     CamelMessageInfo *info,
+                                     gchar **appended_uid,
+                                     GCancellable *cancellable,
+                                     GError **error)
 {
 	CamelStream *stream;
 	CamelExchangeStore *store;
@@ -456,32 +452,74 @@ exchange_folder_append_message (CamelFolder *folder,
 		g_string_free (new_subject, TRUE);
 	}
 
-	if (!camel_exchange_store_connected (store, NULL))
+	if (!camel_exchange_store_connected (store, cancellable, NULL))
 		return camel_exchange_journal_append (
 			(CamelExchangeJournal *)
 			((CamelExchangeFolder *)folder)->journal,
-			message, info, appended_uid, error);
+			message, info, appended_uid, cancellable, error);
 
 	byte_array = g_byte_array_new ();
 	stream = camel_stream_mem_new_with_byte_array (byte_array);
-	camel_data_wrapper_write_to_stream (
-		CAMEL_DATA_WRAPPER (message), stream, NULL);
-	camel_stream_flush (stream, NULL);
+	camel_data_wrapper_write_to_stream_sync (
+		CAMEL_DATA_WRAPPER (message), stream, cancellable, NULL);
+	camel_stream_flush (stream, cancellable, NULL);
 
 	success = exchange_folder_append_message_data (
 		folder, byte_array,
 		camel_mime_message_get_subject (message),
-		info, appended_uid, error);
+		info, appended_uid, cancellable, error);
 
 	g_object_unref (stream);
 
 	return success;
 }
 
+static gboolean
+exchange_folder_expunge_sync (CamelFolder *folder,
+                              GCancellable *cancellable,
+                              GError **error)
+{
+	CamelFolder *trash;
+	GPtrArray *uids;
+	CamelExchangeStore *store;
+	CamelStore *parent_store;
+	const gchar *full_name;
+	gboolean success;
+
+	parent_store = camel_folder_get_parent_store (folder);
+	store = CAMEL_EXCHANGE_STORE (parent_store);
+
+	if (!camel_exchange_store_connected (store, cancellable, NULL)) {
+		g_set_error (
+			error, CAMEL_SERVICE_ERROR,
+			CAMEL_SERVICE_ERROR_UNAVAILABLE,
+			_("You cannot expunge in offline mode."));
+		return FALSE;
+	}
+
+	trash = camel_store_get_trash_folder_sync (
+		parent_store, cancellable, NULL);
+	if (!trash) {
+		printf ("Expunge failed, could not read trash folder\n");
+		return TRUE;  /* XXX exception not set */
+	}
+
+	uids = camel_folder_get_uids (trash);
+	full_name = camel_folder_get_full_name (trash);
+	success = camel_exchange_utils_expunge_uids (
+		CAMEL_SERVICE (parent_store),
+		full_name, uids, cancellable, error);
+	camel_folder_free_uids (trash, uids);
+	g_object_unref (trash);
+
+	return success;
+}
+
 static CamelMimeMessage *
-exchange_folder_get_message (CamelFolder *folder,
-                             const gchar *uid,
-                             GError **error)
+exchange_folder_get_message_sync (CamelFolder *folder,
+                                  const gchar *uid,
+                                  GCancellable *cancellable,
+                                  GError **error)
 {
 	CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
 	CamelMimeMessage *msg;
@@ -492,7 +530,7 @@ exchange_folder_get_message (CamelFolder *folder,
 	gchar **list_headers = NULL;
 	gboolean found_list = FALSE;
 
-	ba = exchange_folder_get_message_data (folder, uid, error);
+	ba = exchange_folder_get_message_data (folder, uid, cancellable, error);
 	if (!ba)
 		return NULL;
 
@@ -521,9 +559,9 @@ exchange_folder_get_message (CamelFolder *folder,
 	g_object_unref (stream);
 
 	msg = camel_mime_message_new ();
-	camel_data_wrapper_construct_from_stream (
+	camel_data_wrapper_construct_from_stream_sync (
 		CAMEL_DATA_WRAPPER (msg),
-		CAMEL_STREAM (filtered_stream), NULL);
+		CAMEL_STREAM (filtered_stream), NULL, NULL);
 	g_object_unref (filtered_stream);
 	camel_mime_message_set_source (msg, exch->source);
 
@@ -549,64 +587,67 @@ exchange_folder_get_message (CamelFolder *folder,
 	return msg;
 }
 
-static gint
-exchange_folder_cmp_uids (CamelFolder *folder,
-                          const gchar *uid1,
-                          const gchar *uid2)
+static gboolean
+exchange_folder_refresh_info_sync (CamelFolder *folder,
+                                   GCancellable *cancellable,
+                                   GError **error)
 {
-	g_return_val_if_fail (uid1 != NULL, 0);
-	g_return_val_if_fail (uid2 != NULL, 0);
+	CamelExchangeFolder *exch;
+	CamelExchangeStore *store;
+	CamelStore *parent_store;
+	guint32 unread_count, visible_count;
+	const gchar *full_name;
+	gboolean success = TRUE;
 
-	return strcmp (uid1, uid2);
-}
+	full_name = camel_folder_get_full_name (folder);
+	parent_store = camel_folder_get_parent_store (folder);
 
-static GPtrArray *
-exchange_folder_search_by_expression (CamelFolder *folder,
-                                      const gchar *expression,
-                                      GError **error)
-{
-	CamelFolderSearch *search;
-	GPtrArray *matches;
+	exch = CAMEL_EXCHANGE_FOLDER (folder);
+	store = CAMEL_EXCHANGE_STORE (parent_store);
 
-	search = camel_exchange_search_new ();
-	camel_folder_search_set_folder (search, folder);
+	if (camel_exchange_store_connected (store, cancellable, NULL)) {
+		camel_offline_journal_replay (
+			exch->journal, cancellable, NULL);
 
-	matches = camel_folder_search_search (
-		search, expression, NULL, error);
+		camel_exchange_utils_refresh_folder (
+			CAMEL_SERVICE (parent_store),
+			full_name, cancellable, NULL);
+	}
 
-	g_object_unref (search);
+	/* sync up the counts now */
+	if (!camel_exchange_utils_sync_count (
+		CAMEL_SERVICE (parent_store), full_name,
+		&unread_count, &visible_count, error)) {
+		g_print("\n Error syncing up the counts");
+		success = FALSE;
+	}
 
-	return matches;
+	folder->summary->unread_count = unread_count;
+	folder->summary->visible_count = visible_count;
+
+	return success;
 }
 
-static GPtrArray *
-exchange_folder_search_by_uids (CamelFolder *folder,
-                                const gchar *expression,
-                                GPtrArray *uids,
-                                GError **error)
+static gboolean
+exchange_folder_synchronize_sync (CamelFolder *folder,
+                                  gboolean expunge,
+                                  GCancellable *cancellable,
+                                  GError **error)
 {
-	CamelFolderSearch *search;
-	GPtrArray *matches;
-
-	search = camel_exchange_search_new ();
-	camel_folder_search_set_folder (search, folder);
-	camel_folder_search_set_summary (search, uids);
-
-	matches = camel_folder_search_execute_expression (
-		search, expression, error);
-
-	g_object_unref (search);
+	if (expunge)
+		exchange_folder_expunge_sync (folder, cancellable, NULL);
 
-	return matches;
+	return camel_folder_summary_save_to_db (folder->summary, error) == 0;
 }
 
 static gboolean
-exchange_folder_transfer_messages_to (CamelFolder *source,
-                                      GPtrArray *uids,
-                                      CamelFolder *dest,
-                                      GPtrArray **transferred_uids,
-                                      gboolean delete_originals,
-                                      GError **error)
+exchange_folder_transfer_messages_to_sync (CamelFolder *source,
+                                           GPtrArray *uids,
+                                           CamelFolder *dest,
+                                           gboolean delete_originals,
+                                           GPtrArray **transferred_uids,
+                                           GCancellable *cancellable,
+                                           GError **error)
 {
 	CamelExchangeFolder *exch_source = CAMEL_EXCHANGE_FOLDER (source);
 	CamelExchangeFolder *exch_dest = CAMEL_EXCHANGE_FOLDER (dest);
@@ -623,11 +664,12 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
 	parent_store = camel_folder_get_parent_store (source);
 	store = CAMEL_EXCHANGE_STORE (parent_store);
 
-	camel_operation_start (NULL, delete_originals ? _("Moving messages") :
-			       _("Copying messages"));
+	camel_operation_push_message (
+		cancellable, delete_originals ?
+		_("Moving messages") : _("Copying messages"));
 
 	/* Check for offline operation */
-	if (!camel_exchange_store_connected (store, &local_error)) {
+	if (!camel_exchange_store_connected (store, cancellable, &local_error)) {
 		CamelExchangeJournal *journal;
 		CamelMimeMessage *message;
 
@@ -645,8 +687,9 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
 			if (!info)
 				continue;
 
-			message = exchange_folder_get_message (
-				source, camel_message_info_uid (info), error);
+			message = exchange_folder_get_message_sync (
+				source, camel_message_info_uid (info),
+				cancellable, error);
 			if (message == NULL) {
 				success = FALSE;
 				break;
@@ -655,7 +698,7 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
 			success = camel_exchange_journal_transfer (
 				journal, exch_source, message,
 				info, uids->pdata[i], NULL,
-				delete_originals, error);
+				delete_originals, cancellable, error);
 
 			g_object_unref (message);
 		}
@@ -670,7 +713,7 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
 	if (strncmp (source_full_name, dest_full_name, hier_len) != 0)
 		return exchange_folder_transfer_messages_the_hard_way (
 			source, uids, dest, transferred_uids,
-			delete_originals, error);
+			delete_originals, cancellable, error);
 
 	success = camel_exchange_utils_transfer_messages (
 		CAMEL_SERVICE (store),
@@ -692,38 +735,11 @@ exchange_folder_transfer_messages_to (CamelFolder *source,
 		*transferred_uids = NULL;
 
 end:
-	camel_operation_end (NULL);
+	camel_operation_pop_message (cancellable);
 
 	return success;
 }
 
-static guint32
-exchange_folder_count_by_expression (CamelFolder *folder,
-                                     const gchar *expression,
-                                     GError **error)
-{
-	CamelFolderSearch *search;
-	guint32 matches;
-
-	search = camel_exchange_search_new ();
-	camel_folder_search_set_folder (search, folder);
-	matches = camel_folder_search_count (search, expression, error);
-
-	g_object_unref (search);
-
-	return matches;
-}
-
-static gchar *
-exchange_folder_get_filename (CamelFolder *folder,
-                              const gchar *uid,
-                              GError **error)
-{
-	CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
-
-	return camel_data_cache_get_filename (exch->cache, "cache", uid, NULL);
-}
-
 static void
 camel_exchange_folder_class_init (CamelExchangeFolderClass *class)
 {
@@ -735,17 +751,17 @@ camel_exchange_folder_class_init (CamelExchangeFolderClass *class)
 	object_class->finalize = exchange_folder_finalize;
 
 	folder_class = CAMEL_FOLDER_CLASS (class);
-	folder_class->refresh_info = exchange_folder_refresh_info;
-	folder_class->sync = exchange_folder_sync;
-	folder_class->expunge = exchange_folder_expunge;
-	folder_class->append_message = exchange_folder_append_message;
-	folder_class->get_message = exchange_folder_get_message;
 	folder_class->cmp_uids = exchange_folder_cmp_uids;
 	folder_class->search_by_expression = exchange_folder_search_by_expression;
 	folder_class->search_by_uids = exchange_folder_search_by_uids;
-	folder_class->transfer_messages_to = exchange_folder_transfer_messages_to;
 	folder_class->count_by_expression = exchange_folder_count_by_expression;
 	folder_class->get_filename = exchange_folder_get_filename;
+	folder_class->append_message_sync = exchange_folder_append_message_sync;
+	folder_class->expunge_sync = exchange_folder_expunge_sync;
+	folder_class->get_message_sync = exchange_folder_get_message_sync;
+	folder_class->refresh_info_sync = exchange_folder_refresh_info_sync;
+	folder_class->synchronize_sync = exchange_folder_synchronize_sync;
+	folder_class->transfer_messages_to_sync = exchange_folder_transfer_messages_to_sync;
 }
 
 static void
@@ -824,7 +840,8 @@ camel_exchange_folder_add_message (CamelExchangeFolder *exch,
 
 	stream = camel_stream_mem_new_with_buffer (headers, strlen (headers));
 	msg = camel_mime_message_new ();
-	camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream, NULL);
+	camel_data_wrapper_construct_from_stream_sync (
+		CAMEL_DATA_WRAPPER (msg), stream, NULL, NULL);
 	g_object_unref (stream);
 
 	info = camel_folder_summary_info_new_from_message (folder->summary, msg, NULL);
@@ -1037,16 +1054,18 @@ camel_exchange_folder_update_message_tag (CamelExchangeFolder *exch,
  * @name: the full name of the folder
  * @camel_flags: the folder flags passed to camel_store_get_folder().
  * @folder_dir: local directory this folder can cache data into
- * @offline_state : offline status
+ * @online : %TRUE for online, %FALSE for offline
+ * @cancellable: optional #GCancellable object, or %NULL
  * @error: return location for a #GError, or %NULL
  *
  * Return value: success or failure.
  **/
 gboolean
 camel_exchange_folder_construct (CamelFolder *folder,
-				 guint32 camel_flags,
+                                 guint32 camel_flags,
                                  const gchar *folder_dir,
-                                 gint offline_state,
+                                 gboolean online,
+                                 GCancellable *cancellable,
                                  GError **error)
 {
 	CamelExchangeFolder *exch = (CamelExchangeFolder *)folder;
@@ -1143,13 +1162,14 @@ camel_exchange_folder_construct (CamelFolder *folder,
 			//camel_tag_list_free (&((CamelMessageInfoBase *)info)->user_tags);
 		}
 
-		camel_operation_start (NULL, _("Scanning for changed messages"));
+		camel_operation_push_message (
+			cancellable, _("Scanning for changed messages"));
 		ok = camel_exchange_utils_get_folder (
 			CAMEL_SERVICE (parent_store),
 			full_name, create, uids, flags, hrefs,
 			CAMEL_EXCHANGE_SUMMARY (folder->summary)->high_article_num,
 			&folder_flags, &exch->source, &readonly, error);
-		camel_operation_end (NULL);
+		camel_operation_pop_message (cancellable);
 		g_ptr_array_free (uids, TRUE);
 		g_byte_array_free (flags, TRUE);
 		g_ptr_array_free (hrefs, TRUE);
@@ -1164,16 +1184,18 @@ camel_exchange_folder_construct (CamelFolder *folder,
 
 		camel_exchange_summary_set_readonly (folder->summary, readonly);
 
-		if (offline_state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+		if (!online)
 			return TRUE;
 
 		if (len)
 			return TRUE;
 
-		camel_operation_start (NULL, _("Fetching summary information for new messages"));
+		camel_operation_push_message (
+			cancellable, _("Fetching summary information for new messages"));
 		ok = camel_exchange_utils_refresh_folder (
-			CAMEL_SERVICE (parent_store), full_name, error);
-		camel_operation_end (NULL);
+			CAMEL_SERVICE (parent_store),
+			full_name, cancellable, error);
+		camel_operation_pop_message (cancellable);
 		if (!ok)
 			return FALSE;
 
diff --git a/camel/camel-exchange-folder.h b/camel/camel-exchange-folder.h
index 5007559..12b9894 100644
--- a/camel/camel-exchange-folder.h
+++ b/camel/camel-exchange-folder.h
@@ -48,38 +48,45 @@ struct _CamelExchangeFolderClass {
 
 GType    camel_exchange_folder_get_type (void);
 
-gboolean camel_exchange_folder_construct            (CamelFolder *folder,
-						     guint32 camel_flags,
-						     const gchar *folder_dir,
-						     gint offline_state,
-						     GError **error);
-
-void     camel_exchange_folder_add_message          (CamelExchangeFolder *exch,
-						     const gchar *uid,
-						     guint32 flags,
-						     guint32 size,
-						     const gchar *headers,
-						     const gchar *href);
-
-void     camel_exchange_folder_remove_message       (CamelExchangeFolder *exch,
-						     const gchar *uid);
-
-void     camel_exchange_folder_uncache_message      (CamelExchangeFolder *exch,
-						     const gchar *uid);
-
-void     camel_exchange_folder_update_message_flags (CamelExchangeFolder *exch,
-						     const gchar *uid,
-						     guint32 flags);
-
-void     camel_exchange_folder_update_message_flags_ex (CamelExchangeFolder *exch,
-							const gchar *uid,
-							guint32 flags,
-							guint32 mask);
-
-void     camel_exchange_folder_update_message_tag   (CamelExchangeFolder *exch,
-						     const gchar *uid,
-						     const gchar *name,
-						     const gchar *value);
+gboolean	camel_exchange_folder_construct	(CamelFolder *folder,
+						 guint32 camel_flags,
+						 const gchar *folder_dir,
+						 gboolean online,
+						 GCancellable *cancellable,
+						 GError **error);
+
+void		camel_exchange_folder_add_message
+						(CamelExchangeFolder *exch,
+						 const gchar *uid,
+						 guint32 flags,
+						 guint32 size,
+						 const gchar *headers,
+						 const gchar *href);
+
+void		camel_exchange_folder_remove_message
+						(CamelExchangeFolder *exch,
+						 const gchar *uid);
+
+void		camel_exchange_folder_uncache_message
+						(CamelExchangeFolder *exch,
+						 const gchar *uid);
+
+void		camel_exchange_folder_update_message_flags
+						(CamelExchangeFolder *exch,
+						 const gchar *uid,
+						 guint32 flags);
+
+void		camel_exchange_folder_update_message_flags_ex
+						(CamelExchangeFolder *exch,
+						 const gchar *uid,
+						 guint32 flags,
+						 guint32 mask);
+
+void		camel_exchange_folder_update_message_tag
+						(CamelExchangeFolder *exch,
+						 const gchar *uid,
+						 const gchar *name,
+						 const gchar *value);
 
 G_END_DECLS
 
diff --git a/camel/camel-exchange-journal.c b/camel/camel-exchange-journal.c
index 67b3cb5..0b77de3 100644
--- a/camel/camel-exchange-journal.c
+++ b/camel/camel-exchange-journal.c
@@ -57,6 +57,7 @@ exchange_message_info_dup_to (CamelMessageInfoBase *dest,
 static gint
 exchange_entry_play_append (CamelOfflineJournal *journal,
                             CamelExchangeJournalEntry *entry,
+                            GCancellable *cancellable,
                             GError **error)
 {
 	CamelExchangeFolder *exchange_folder = (CamelExchangeFolder *) journal->folder;
@@ -71,7 +72,8 @@ exchange_entry_play_append (CamelOfflineJournal *journal,
 		goto done;
 
 	message = camel_mime_message_new ();
-	if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, NULL) == -1) {
+	if (!camel_data_wrapper_construct_from_stream_sync (
+		(CamelDataWrapper *) message, stream, cancellable, NULL)) {
 		g_object_unref (message);
 		g_object_unref (stream);
 		goto done;
@@ -84,7 +86,8 @@ exchange_entry_play_append (CamelOfflineJournal *journal,
 		info = camel_message_info_new (NULL);
 	}
 
-	if (!camel_folder_append_message (folder, message, info, &uid, error))
+	if (!camel_folder_append_message_sync (
+		folder, message, info, &uid, cancellable, error))
 		return -1;
 
 	real = camel_folder_summary_info_new_from_message (folder->summary, message, NULL);
@@ -109,6 +112,7 @@ exchange_entry_play_append (CamelOfflineJournal *journal,
 static gint
 exchange_entry_play_transfer (CamelOfflineJournal *journal,
                               CamelExchangeJournalEntry *entry,
+                              GCancellable *cancellable,
                               GError **error)
 {
 	CamelExchangeFolder *exchange_folder = (CamelExchangeFolder *) journal->folder;
@@ -125,7 +129,8 @@ exchange_entry_play_transfer (CamelOfflineJournal *journal,
 		goto done;
 
 	message = camel_mime_message_new ();
-	if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream, NULL) == -1) {
+	if (!camel_data_wrapper_construct_from_stream_sync (
+		(CamelDataWrapper *) message, stream, cancellable, NULL)) {
 		g_object_unref (message);
 		g_object_unref (stream);
 		goto done;
@@ -157,9 +162,9 @@ exchange_entry_play_transfer (CamelOfflineJournal *journal,
 		uids = g_ptr_array_sized_new (1);
 		g_ptr_array_add (uids, entry->original_uid);
 
-		success = camel_folder_transfer_messages_to (
-			src, uids, folder, &xuids,
-			entry->delete_original, error);
+		success = camel_folder_transfer_messages_to_sync (
+			src, uids, folder, entry->delete_original,
+			&xuids, cancellable, error);
 		if (!success)
 			goto exception;
 
@@ -202,6 +207,7 @@ exception:
 static gint
 exchange_entry_play_delete (CamelOfflineJournal *journal,
                             CamelExchangeJournalEntry *entry,
+                            GCancellable *cancellable,
                             GError **error)
 {
 	CamelFolder *folder;
@@ -346,6 +352,7 @@ exchange_journal_entry_write (CamelOfflineJournal *journal,
 static gint
 exchange_journal_entry_play (CamelOfflineJournal *journal,
                              CamelDListNode *entry,
+                             GCancellable *cancellable,
                              GError **error)
 {
 	CamelExchangeJournalEntry *exchange_entry = (CamelExchangeJournalEntry *) entry;
@@ -353,13 +360,13 @@ exchange_journal_entry_play (CamelOfflineJournal *journal,
 	switch (exchange_entry->type) {
 	case CAMEL_EXCHANGE_JOURNAL_ENTRY_APPEND:
 		return exchange_entry_play_append (
-			journal, exchange_entry, error);
+			journal, exchange_entry, cancellable, error);
 	case CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER:
 		return exchange_entry_play_transfer (
-			journal, exchange_entry, error);
+			journal, exchange_entry, cancellable, error);
 	case CAMEL_EXCHANGE_JOURNAL_ENTRY_DELETE:
 		return exchange_entry_play_delete (
-			journal, exchange_entry, error);
+			journal, exchange_entry, cancellable, error);
 	default:
 		g_critical ("%s: Uncaught case (%d)", G_STRLOC, exchange_entry->type);
 		return -1;
@@ -401,6 +408,7 @@ update_cache (CamelExchangeJournal *exchange_journal,
               CamelMimeMessage *message,
               const CamelMessageInfo *mi,
               gchar **updated_uid,
+              GCancellable *cancellable,
               GError **error)
 {
 	CamelOfflineJournal *journal = (CamelOfflineJournal *) exchange_journal;
@@ -430,9 +438,9 @@ update_cache (CamelExchangeJournal *exchange_journal,
 		return FALSE;
 	}
 
-	if (camel_data_wrapper_write_to_stream (
-		(CamelDataWrapper *) message, cache, error) == -1
-	    || camel_stream_flush (cache, error) == -1) {
+	if (camel_data_wrapper_write_to_stream_sync (
+		(CamelDataWrapper *) message, cache, cancellable, error) == -1
+	    || camel_stream_flush (cache, cancellable, error) == -1) {
 		g_prefix_error (
 			error, _("Cannot append message in offline mode: "));
 		camel_data_cache_remove (
@@ -468,13 +476,15 @@ camel_exchange_journal_append (CamelExchangeJournal *exchange_journal,
                                CamelMimeMessage *message,
                                const CamelMessageInfo *mi,
                                gchar **appended_uid,
+                               GCancellable *cancellable,
                                GError **error)
 {
 	CamelOfflineJournal *journal = (CamelOfflineJournal *) exchange_journal;
 	CamelExchangeJournalEntry *entry;
 	gchar *uid;
 
-	if (!update_cache (exchange_journal, message, mi, &uid, error))
+	if (!update_cache (
+		exchange_journal, message, mi, &uid, cancellable, error))
 		return FALSE;
 
 	entry = g_new (CamelExchangeJournalEntry, 1);
@@ -538,6 +548,7 @@ camel_exchange_journal_transfer (CamelExchangeJournal *exchange_journal,
                                  const gchar *original_uid,
                                  gchar **transferred_uid,
                                  gboolean delete_original,
+                                 GCancellable *cancellable,
                                  GError **error)
 {
 	CamelOfflineJournal *journal = (CamelOfflineJournal *) exchange_journal;
@@ -546,7 +557,8 @@ camel_exchange_journal_transfer (CamelExchangeJournal *exchange_journal,
 	const gchar *real_source_folder = NULL, *real_uid = NULL;
 	gint type;
 
-	if (!update_cache (exchange_journal, message, mi, &uid, error))
+	if (!update_cache (
+		exchange_journal, message, mi, &uid, cancellable, error))
 		return FALSE;
 
 	real_uid = original_uid;
diff --git a/camel/camel-exchange-journal.h b/camel/camel-exchange-journal.h
index c7b6ab5..4891b59 100644
--- a/camel/camel-exchange-journal.h
+++ b/camel/camel-exchange-journal.h
@@ -92,6 +92,7 @@ gboolean	camel_exchange_journal_append	(CamelExchangeJournal *journal,
 						 CamelMimeMessage *message,
 						 const CamelMessageInfo *mi,
 						 gchar **appended_uid,
+						 GCancellable *cancellable,
 						 GError **error);
 
 gboolean	camel_exchange_journal_transfer	(CamelExchangeJournal *journal,
@@ -101,6 +102,7 @@ gboolean	camel_exchange_journal_transfer	(CamelExchangeJournal *journal,
 						 const gchar *original_uid,
 						 gchar **transferred_uid,
 						 gboolean delete_original,
+						 GCancellable *cancellable,
 						 GError **error);
 gboolean	camel_exchange_journal_delete	(CamelExchangeJournal *journal,
 						 const gchar *uid,
diff --git a/camel/camel-exchange-search.c b/camel/camel-exchange-search.c
index 71aeef8..a8636b5 100644
--- a/camel/camel-exchange-search.c
+++ b/camel/camel-exchange-search.c
@@ -57,7 +57,7 @@ exchange_search_body_contains (struct _ESExp *f,
 
 	offline_store = CAMEL_OFFLINE_STORE (parent_store);
 
-	if (offline_store->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL)
+	if (!camel_offline_store_get_online (offline_store))
 		return folder_search_class->body_contains (f, argc, argv, s);
 
 	if (s->current) {
diff --git a/camel/camel-exchange-store.c b/camel/camel-exchange-store.c
index 5dfb5a6..046dcca 100644
--- a/camel/camel-exchange-store.c
+++ b/camel/camel-exchange-store.c
@@ -42,9 +42,9 @@
 
 /* Even if we are disconnected, we need to exchange_store_connect()
    to get the offline data */
-#define RETURN_VAL_IF_NOT_CONNECTED(store, ex, val)\
-	if (!camel_exchange_store_connected (store, ex) && \
-	    !exchange_store_connect (CAMEL_SERVICE (store), ex)) \
+#define RETURN_VAL_IF_NOT_CONNECTED(store, cancellable, ex, val)\
+	if (!camel_exchange_store_connected (store, cancellable, ex) && \
+	    !exchange_store_connect_sync (CAMEL_SERVICE (store), cancellable, ex)) \
 		return val;
 
 extern CamelServiceAuthType camel_exchange_password_authtype;
@@ -279,18 +279,6 @@ exchange_store_construct (CamelService *service,
 	return (exch->storage_path != NULL);
 }
 
-static GList *
-exchange_store_query_auth_types (CamelService *service,
-                                 GError **error)
-{
-	GList *list = NULL;
-
-	list = g_list_prepend (list, &camel_exchange_password_authtype);
-	list = g_list_prepend (list, &camel_exchange_ntlm_authtype);
-
-	return list;
-}
-
 static gchar *
 exchange_store_get_name (CamelService *service,
                          gboolean brief)
@@ -307,8 +295,9 @@ exchange_store_get_name (CamelService *service,
 }
 
 static gboolean
-exchange_store_connect (CamelService *service,
-                        GError **error)
+exchange_store_connect_sync (CamelService *service,
+                             GCancellable *cancellable,
+                             GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (service);
 	gchar *password = NULL;
@@ -391,44 +380,75 @@ exchange_store_connect (CamelService *service,
 }
 
 static gboolean
-exchange_store_disconnect (CamelService *service,
-                           gboolean clean,
-                           GError **error)
+exchange_store_disconnect_sync (CamelService *service,
+                                gboolean clean,
+                                GCancellable *cancellable,
+                                GError **error)
 {
 	/* CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (service); */
 	/* keep account connect as it can be used for other parts like cal, gal or addressbook? */
 	return TRUE;
 }
 
-static CamelFolder *
-exchange_store_get_trash (CamelStore *store,
-                          GError **error)
+static GList *
+exchange_store_query_auth_types_sync (CamelService *service,
+                                      GCancellable *cancellable,
+                                      GError **error)
 {
-	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
+	GList *list = NULL;
 
-	RETURN_VAL_IF_NOT_CONNECTED (exch, error, NULL);
+	list = g_list_prepend (list, &camel_exchange_password_authtype);
+	list = g_list_prepend (list, &camel_exchange_ntlm_authtype);
 
-	if (!exch->trash_name) {
-		if (!camel_exchange_utils_get_trash_name (
-			CAMEL_SERVICE (store), &exch->trash_name, error))
-			return NULL;
+	return list;
+}
+
+static gboolean
+exchange_store_can_refresh_folder (CamelStore *store,
+                                   CamelFolderInfo *info,
+                                   GError **error)
+{
+	CamelStoreClass *store_class;
+	gboolean res;
+
+	store_class = CAMEL_STORE_CLASS (camel_exchange_store_parent_class);
+
+	res = store_class->can_refresh_folder (store, info, error) ||
+	      (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
+
+	return res;
+}
+
+static gboolean
+exchange_store_folder_is_subscribed (CamelStore *store,
+                                     const gchar *folder_name)
+{
+	gboolean is_subscribed = FALSE;
+
+	d(printf ("is subscribed folder : %s\n", folder_name));
+	if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)))
+		return FALSE;
+
+	if (!camel_exchange_utils_is_subscribed_folder (CAMEL_SERVICE (store), folder_name, &is_subscribed, NULL)) {
+		return FALSE;
 	}
 
-	return camel_store_get_folder (store, exch->trash_name, 0, error);
+	return is_subscribed;
 }
 
 static CamelFolder *
-exchange_store_get_folder (CamelStore *store,
-                           const gchar *folder_name,
-                           guint32 flags,
-                           GError **error)
+exchange_store_get_folder_sync (CamelStore *store,
+                                const gchar *folder_name,
+                                guint32 flags,
+                                GCancellable *cancellable,
+                                GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 	CamelFolder *folder;
 	const gchar *short_name;
 	gchar *folder_dir;
 
-	RETURN_VAL_IF_NOT_CONNECTED (exch, error, NULL);
+	RETURN_VAL_IF_NOT_CONNECTED (exch, cancellable, error, NULL);
 
 	if (!folder_name || !*folder_name || g_ascii_strcasecmp (folder_name, "inbox") == 0)
 		folder_name = "personal/Inbox";
@@ -436,7 +456,7 @@ exchange_store_get_folder (CamelStore *store,
 	folder_dir = exchange_store_path_to_physical (
 		exch->storage_path, folder_name);
 
-	if (!camel_exchange_store_connected (exch, NULL)) {
+	if (!camel_exchange_store_connected (exch, cancellable, NULL)) {
 		if (!folder_dir || !g_file_test (folder_dir, G_FILE_TEST_IS_DIR)) {
 			g_free (folder_dir);
 			g_set_error (
@@ -472,7 +492,8 @@ exchange_store_get_folder (CamelStore *store,
 
 	if (!camel_exchange_folder_construct (
 		folder, flags, folder_dir,
-		((CamelOfflineStore *) store)->state, error)) {
+		camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)),
+		cancellable, error)) {
 
 		gchar *key;
 		g_mutex_lock (exch->folders_lock);
@@ -498,10 +519,11 @@ exchange_store_get_folder (CamelStore *store,
 }
 
 static CamelFolderInfo *
-exchange_store_get_folder_info (CamelStore *store,
-                                const gchar *top,
-                                guint32 flags,
-                                GError **error)
+exchange_store_get_folder_info_sync (CamelStore *store,
+                                     const gchar *top,
+                                     guint32 flags,
+                                     GCancellable *cancellable,
+                                     GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 	GPtrArray *folders, *folder_names = NULL, *folder_uris = NULL;
@@ -515,7 +537,7 @@ exchange_store_get_folder_info (CamelStore *store,
 	 * each time auto-send/recv runs.
 	 */
 
-	RETURN_VAL_IF_NOT_CONNECTED (exch, error, NULL);
+	RETURN_VAL_IF_NOT_CONNECTED (exch, cancellable, error, NULL);
 
 	if (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)
 		store_flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE;
@@ -561,18 +583,38 @@ exchange_store_get_folder_info (CamelStore *store,
 	return info;
 }
 
+static CamelFolder *
+exchange_store_get_trash_folder_sync (CamelStore *store,
+                                      GCancellable *cancellable,
+                                      GError **error)
+{
+	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
+
+	RETURN_VAL_IF_NOT_CONNECTED (exch, cancellable, error, NULL);
+
+	if (!exch->trash_name) {
+		if (!camel_exchange_utils_get_trash_name (
+			CAMEL_SERVICE (store), &exch->trash_name, error))
+			return NULL;
+	}
+
+	return camel_store_get_folder_sync (
+		store, exch->trash_name, 0, cancellable, error);
+}
+
 static CamelFolderInfo *
-exchange_store_create_folder (CamelStore *store,
-                              const gchar *parent_name,
-                              const gchar *folder_name,
-                              GError **error)
+exchange_store_create_folder_sync (CamelStore *store,
+                                   const gchar *parent_name,
+                                   const gchar *folder_name,
+                                   GCancellable *cancellable,
+                                   GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 	gchar *folder_uri;
 	guint32 unread_count, flags;
 	CamelFolderInfo *info;
 
-	if (!camel_exchange_store_connected (exch, NULL)) {
+	if (!camel_exchange_store_connected (exch, cancellable, NULL)) {
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot create folder in offline mode."));
@@ -596,13 +638,14 @@ exchange_store_create_folder (CamelStore *store,
 }
 
 static gboolean
-exchange_store_delete_folder (CamelStore *store,
-                              const gchar *folder_name,
-                              GError **error)
+exchange_store_delete_folder_sync (CamelStore *store,
+                                   const gchar *folder_name,
+                                   GCancellable *cancellable,
+                                   GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 
-	if (!camel_exchange_store_connected (exch, NULL)) {
+	if (!camel_exchange_store_connected (exch, cancellable, NULL)) {
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot delete folder in offline mode."));
@@ -614,10 +657,11 @@ exchange_store_delete_folder (CamelStore *store,
 }
 
 static gboolean
-exchange_store_rename_folder (CamelStore *store,
-                              const gchar *old_name,
-                              const gchar *new_name,
-                              GError **error)
+exchange_store_rename_folder_sync (CamelStore *store,
+                                   const gchar *old_name,
+                                   const gchar *new_name,
+                                   GCancellable *cancellable,
+                                   GError **error)
 {
 	GPtrArray *folders = NULL, *folder_names = NULL, *folder_uris = NULL;
 	GArray *unread_counts = NULL;
@@ -628,7 +672,7 @@ exchange_store_rename_folder (CamelStore *store,
 
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 
-	if (!camel_exchange_store_connected (exch, NULL))
+	if (!camel_exchange_store_connected (exch, cancellable, NULL))
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot rename folder in offline mode."));
@@ -684,32 +728,15 @@ exchange_store_rename_folder (CamelStore *store,
 }
 
 static gboolean
-exchange_store_folder_is_subscribed (CamelStore *store,
-                                     const gchar *folder_name)
-{
-	gboolean is_subscribed = FALSE;
-
-	d(printf ("is subscribed folder : %s\n", folder_name));
-	if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
-		return FALSE;
-	}
-
-	if (!camel_exchange_utils_is_subscribed_folder (CAMEL_SERVICE (store), folder_name, &is_subscribed, NULL)) {
-		return FALSE;
-	}
-
-	return is_subscribed;
-}
-
-static gboolean
-exchange_store_subscribe_folder (CamelStore *store,
-                                 const gchar *folder_name,
-                                 GError **error)
+exchange_store_subscribe_folder_sync (CamelStore *store,
+                                      const gchar *folder_name,
+                                      GCancellable *cancellable,
+                                      GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 
 	d(printf ("subscribe folder : %s\n", folder_name));
-	if (!camel_exchange_store_connected (exch, NULL)) {
+	if (!camel_exchange_store_connected (exch, cancellable, NULL)) {
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot subscribe folder in offline mode."));
@@ -721,14 +748,15 @@ exchange_store_subscribe_folder (CamelStore *store,
 }
 
 static gboolean
-exchange_store_unsubscribe_folder (CamelStore *store,
-                                   const gchar *folder_name,
-                                   GError **error)
+exchange_store_unsubscribe_folder_sync (CamelStore *store,
+                                        const gchar *folder_name,
+                                        GCancellable *cancellable,
+                                        GError **error)
 {
 	CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (store);
 
 	d(printf ("unsubscribe folder : %s\n", folder_name));
-	if (!camel_exchange_store_connected (exch, NULL)) {
+	if (!camel_exchange_store_connected (exch, cancellable, NULL)) {
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
 			_("Cannot unsubscribe folder in offline mode."));
@@ -739,22 +767,6 @@ exchange_store_unsubscribe_folder (CamelStore *store,
 		CAMEL_SERVICE (store), folder_name, error);
 }
 
-static gboolean
-exchange_store_can_refresh_folder (CamelStore *store,
-                                   CamelFolderInfo *info,
-                                   GError **error)
-{
-	CamelStoreClass *store_class;
-	gboolean res;
-
-	store_class = CAMEL_STORE_CLASS (camel_exchange_store_parent_class);
-
-	res = store_class->can_refresh_folder (store, info, error) ||
-	      (camel_url_get_param (((CamelService *)store)->url, "check_all") != NULL);
-
-	return res;
-}
-
 static void
 camel_exchange_store_class_init (CamelExchangeStoreClass *class)
 {
@@ -767,23 +779,23 @@ camel_exchange_store_class_init (CamelExchangeStoreClass *class)
 
 	service_class = CAMEL_SERVICE_CLASS (class);
 	service_class->construct = exchange_store_construct;
-	service_class->query_auth_types = exchange_store_query_auth_types;
 	service_class->get_name = exchange_store_get_name;
-	service_class->connect = exchange_store_connect;
-	service_class->disconnect = exchange_store_disconnect;
+	service_class->connect_sync = exchange_store_connect_sync;
+	service_class->disconnect_sync = exchange_store_disconnect_sync;
+	service_class->query_auth_types_sync = exchange_store_query_auth_types_sync;
 
 	store_class = CAMEL_STORE_CLASS (class);
-	store_class->get_trash = exchange_store_get_trash;
-	store_class->free_folder_info = camel_store_free_folder_info_full;
-	store_class->get_folder = exchange_store_get_folder;
-	store_class->get_folder_info = exchange_store_get_folder_info;
-	store_class->create_folder = exchange_store_create_folder;
-	store_class->delete_folder = exchange_store_delete_folder;
-	store_class->rename_folder = exchange_store_rename_folder;
-	store_class->folder_is_subscribed = exchange_store_folder_is_subscribed;
-	store_class->subscribe_folder = exchange_store_subscribe_folder;
-	store_class->unsubscribe_folder = exchange_store_unsubscribe_folder;
 	store_class->can_refresh_folder = exchange_store_can_refresh_folder;
+	store_class->folder_is_subscribed = exchange_store_folder_is_subscribed;
+	store_class->free_folder_info = camel_store_free_folder_info_full;
+	store_class->get_folder_sync = exchange_store_get_folder_sync;
+	store_class->get_folder_info_sync = exchange_store_get_folder_info_sync;
+	store_class->get_trash_folder_sync = exchange_store_get_trash_folder_sync;
+	store_class->create_folder_sync = exchange_store_create_folder_sync;
+	store_class->delete_folder_sync = exchange_store_delete_folder_sync;
+	store_class->rename_folder_sync = exchange_store_rename_folder_sync;
+	store_class->subscribe_folder_sync = exchange_store_subscribe_folder_sync;
+	store_class->unsubscribe_folder_sync = exchange_store_unsubscribe_folder_sync;
 }
 
 static void
@@ -806,7 +818,9 @@ camel_exchange_store_init (CamelExchangeStore *exch)
 /* Use this to ensure that the camel session is online and we are connected
    too. Also returns the current status of the store */
 gboolean
-camel_exchange_store_connected (CamelExchangeStore *store, GError **error)
+camel_exchange_store_connected (CamelExchangeStore *store,
+                                GCancellable *cancellable,
+                                GError **error)
 {
 	CamelService *service;
 	CamelSession *session;
@@ -818,11 +832,11 @@ camel_exchange_store_connected (CamelExchangeStore *store, GError **error)
 
 	if (service->status != CAMEL_SERVICE_CONNECTED &&
 	    camel_session_get_online (session) &&
-	    !camel_service_connect (service, error)) {
+	    !camel_service_connect_sync (service, error)) {
 		return FALSE;
 	}
 
-	return CAMEL_OFFLINE_STORE (store)->state != CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL;
+	return camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store));
 }
 
 void
diff --git a/camel/camel-exchange-store.h b/camel/camel-exchange-store.h
index 488ec98..a1041e3 100644
--- a/camel/camel-exchange-store.h
+++ b/camel/camel-exchange-store.h
@@ -50,6 +50,7 @@ struct _CamelExchangeStoreClass {
 
 GType		camel_exchange_store_get_type	(void);
 gboolean	camel_exchange_store_connected	(CamelExchangeStore *store,
+						 GCancellable *cancellable,
 						 GError **error);
 void		camel_exchange_store_folder_created
 						(CamelExchangeStore *estore,
diff --git a/camel/camel-exchange-summary.c b/camel/camel-exchange-summary.c
index 5bbb62a..c68b38e 100644
--- a/camel/camel-exchange-summary.c
+++ b/camel/camel-exchange-summary.c
@@ -44,13 +44,16 @@
 G_DEFINE_TYPE (CamelExchangeSummary, camel_exchange_summary, CAMEL_TYPE_FOLDER_SUMMARY)
 
 static gboolean
-exchange_summary_check_for_trash (CamelFolder *folder)
+exchange_summary_check_for_trash (CamelFolder *folder,
+                                  GCancellable *cancellable)
 {
 	CamelStore *parent_store;
 	CamelFolder *trash;
 
 	parent_store = camel_folder_get_parent_store (folder);
-	trash = camel_store_get_trash (parent_store, NULL);
+
+	trash = camel_store_get_trash_folder_sync (
+		parent_store, cancellable, NULL);
 
 	if (trash == NULL)
 		return FALSE;
@@ -61,6 +64,7 @@ exchange_summary_check_for_trash (CamelFolder *folder)
 static gboolean
 exchange_summary_expunge_mail (CamelFolder *folder,
                                CamelMessageInfo *info,
+                               GCancellable *cancellable,
                                GError **error)
 {
 	GPtrArray *uids = g_ptr_array_new ();
@@ -75,7 +79,8 @@ exchange_summary_expunge_mail (CamelFolder *folder,
 	g_ptr_array_add (uids, uid);
 
 	success = camel_exchange_utils_expunge_uids (
-		CAMEL_SERVICE (parent_store), full_name, uids, error);
+		CAMEL_SERVICE (parent_store),
+		full_name, uids, cancellable, error);
 
 	g_ptr_array_free (uids, TRUE);
 
@@ -350,11 +355,11 @@ exchange_summary_info_set_flags (CamelMessageInfo *info,
 	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (
 		camel_exchange_summary_parent_class);
 
-	if (offline_store->state != CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
+	if (!camel_offline_store_get_online (offline_store)) {
 		if (folder && info->uid) {
 			if ((flags & set & CAMEL_MESSAGE_DELETED) &&
-			    exchange_summary_check_for_trash (folder)) {
-				return exchange_summary_expunge_mail (folder, info, NULL);
+			    exchange_summary_check_for_trash (folder, NULL)) {
+				return exchange_summary_expunge_mail (folder, info, NULL, NULL);
 			} else {
 				camel_exchange_utils_set_message_flags (
 					CAMEL_SERVICE (parent_store),
@@ -366,7 +371,7 @@ exchange_summary_info_set_flags (CamelMessageInfo *info,
 	else {
 		if (folder && info->uid) {
 			if ((flags & set & CAMEL_MESSAGE_DELETED) &&
-			    exchange_summary_check_for_trash (folder)) {
+			    exchange_summary_check_for_trash (folder, NULL)) {
 				/* FIXME: should add a separate journal entry for this case. */ ;
 			} else {
 				CamelExchangeFolder *exchange_folder = (CamelExchangeFolder *) folder;
diff --git a/camel/camel-exchange-transport.c b/camel/camel-exchange-transport.c
index f22f098..82c4aac 100644
--- a/camel/camel-exchange-transport.c
+++ b/camel/camel-exchange-transport.c
@@ -32,11 +32,12 @@
 G_DEFINE_TYPE (CamelExchangeTransport, camel_exchange_transport, CAMEL_TYPE_TRANSPORT)
 
 static gboolean
-exchange_transport_send_to (CamelTransport *transport,
-                            CamelMimeMessage *message,
-                            CamelAddress *from,
-                            CamelAddress *recipients,
-                            GError **error)
+exchange_transport_send_to_sync (CamelTransport *transport,
+                                 CamelMimeMessage *message,
+                                 CamelAddress *from,
+                                 CamelAddress *recipients,
+                                 GCancellable *cancellable,
+                                 GError **error)
 {
 	CamelService *service = CAMEL_SERVICE (transport);
 	CamelStore *store = NULL;
@@ -112,10 +113,10 @@ exchange_transport_send_to (CamelTransport *transport,
 
 	camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc");
 
-	camel_data_wrapper_write_to_stream (
+	camel_data_wrapper_write_to_stream_sync (
 		CAMEL_DATA_WRAPPER (message),
-		CAMEL_STREAM (filtered_stream), NULL);
-	camel_stream_flush (CAMEL_STREAM (filtered_stream), NULL);
+		CAMEL_STREAM (filtered_stream), cancellable, NULL);
+	camel_stream_flush (CAMEL_STREAM (filtered_stream), cancellable, NULL);
 	g_object_unref (CAMEL_OBJECT (filtered_stream));
 
 	/* add the bcc headers back */
@@ -148,7 +149,7 @@ camel_exchange_transport_class_init (CamelExchangeTransportClass *class)
 	CamelTransportClass *transport_class;
 
 	transport_class = CAMEL_TRANSPORT_CLASS (class);
-	transport_class->send_to = exchange_transport_send_to;
+	transport_class->send_to_sync = exchange_transport_send_to_sync;
 }
 
 static void
diff --git a/camel/camel-exchange-utils.c b/camel/camel-exchange-utils.c
index 464672a..0661761 100644
--- a/camel/camel-exchange-utils.c
+++ b/camel/camel-exchange-utils.c
@@ -399,7 +399,9 @@ change_flags (ExchangeFolder *mfld, CamelFolder *folder, ExchangeMessage *mmsg,
 }
 
 static void
-refresh_folder_internal (ExchangeFolder *mfld, GError **error)
+refresh_folder_internal (ExchangeFolder *mfld,
+                         GCancellable *cancellable,
+                         GError **error)
 {
 	static const gchar *new_message_props[] = {
 		E2K_PR_REPL_UID,
@@ -511,7 +513,8 @@ refresh_folder_internal (ExchangeFolder *mfld, GError **error)
 
 		if (rm.headers) {
 			got++;
-			camel_operation_progress (NULL, (got * 100) / total);
+			camel_operation_progress (
+				cancellable, (got * 100) / total);
 		} else {
 			href = strrchr (rm.href, '/');
 			if (!href++)
@@ -559,7 +562,7 @@ refresh_folder_internal (ExchangeFolder *mfld, GError **error)
 		rmp->headers = mail_util_mapi_to_smtp_headers (result->props);
 
 		got++;
-		camel_operation_progress (NULL, (got * 100) / total);
+		camel_operation_progress (cancellable, (got * 100) / total);
 	}
 	status = e2k_result_iter_free (iter);
 
@@ -574,7 +577,7 @@ refresh_folder_internal (ExchangeFolder *mfld, GError **error)
 	 */
 
  return_data:
-	camel_operation_progress (NULL, 100);
+	camel_operation_progress (cancellable, 100);
 	folder = get_camel_folder (mfld);
 	if (folder)
 		camel_folder_freeze (folder);
@@ -777,7 +780,7 @@ storage_folder_changed (EFolder *folder, gpointer user_data)
 	ExchangeFolder *mfld = user_data;
 
 	if (e_folder_get_unread_count (folder) > mfld->unread_count)
-		refresh_folder_internal (mfld, NULL);
+		refresh_folder_internal (mfld, NULL, NULL);
 }
 
 static void
@@ -1020,11 +1023,6 @@ get_folder_contents_online (ExchangeFolder *mfld, GError **error)
 			camel_exchange_folder_update_message_tag (CAMEL_EXCHANGE_FOLDER (folder), mmsg->uid, "completed-on", prop);
 
 		m++;
-#if 0
-		if (ex) {
-			camel_operation_progress (NULL, (m * 100) / total);
-		}
-#endif
 	}
 
 	/* If there are further messages beyond mfld->messages->len,
@@ -1044,11 +1042,6 @@ get_folder_contents_online (ExchangeFolder *mfld, GError **error)
 		}
 
 		m++;
-#if 0
-		if (ex) {
-			camel_operation_progress (NULL, (m * 100) / total);
-		}
-#endif
 	}
 	status = e2k_result_iter_free (iter);
 	if (!E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) {
@@ -1125,7 +1118,7 @@ notify_cb (E2kContext *ctx, const gchar *uri, E2kContextChangeType type, gpointe
 	time_t now;
 
 	if (type == E2K_CONTEXT_OBJECT_ADDED)
-		refresh_folder_internal (mfld, NULL);
+		refresh_folder_internal (mfld, NULL, NULL);
 	else {
 		now = time (NULL);
 
@@ -2310,8 +2303,9 @@ camel_exchange_utils_get_trash_name (CamelService *service,
 
 gboolean
 camel_exchange_utils_refresh_folder (CamelService *service,
-				const gchar *folder_name,
-				GError **error)
+                                     const gchar *folder_name,
+                                     GCancellable *cancellable,
+                                     GError **error)
 {
 	ExchangeData *ed = get_data_for_service (service);
 	ExchangeFolder *mfld;
@@ -2322,7 +2316,7 @@ camel_exchange_utils_refresh_folder (CamelService *service,
 	if (!mfld)
 		return FALSE;
 
-	refresh_folder_internal (mfld, NULL);
+	refresh_folder_internal (mfld, cancellable, NULL);
 	sync_deletions (mfld);
 
 	return TRUE;
@@ -2356,9 +2350,10 @@ camel_exchange_utils_sync_count (CamelService *service,
 
 gboolean
 camel_exchange_utils_expunge_uids (CamelService *service,
-				const gchar *folder_name,
-				GPtrArray *uids,
-				GError **error)
+                                   const gchar *folder_name,
+                                   GPtrArray *uids,
+                                   GCancellable *cancellable,
+                                   GError **error)
 {
 	ExchangeData *ed = get_data_for_service (service);
 	ExchangeFolder *mfld;
@@ -2414,7 +2409,8 @@ camel_exchange_utils_expunge_uids (CamelService *service,
 		mfld->deleted_count++;
 		ndeleted++;
 
-		camel_operation_progress (NULL, ndeleted * 100 / hrefs->len);
+		camel_operation_progress (
+			cancellable, ndeleted * 100 / hrefs->len);
 	}
 	status = e2k_result_iter_free (iter);
 	g_static_rec_mutex_unlock (&ed->changed_msgs_mutex);
diff --git a/camel/camel-exchange-utils.h b/camel/camel-exchange-utils.h
index 22617f6..a61ac19 100644
--- a/camel/camel-exchange-utils.h
+++ b/camel/camel-exchange-utils.h
@@ -8,132 +8,150 @@
 
 G_BEGIN_DECLS
 
-gboolean camel_exchange_utils_connect (CamelService *service,
-					const gchar *pwd,
-					guint32 *status, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_get_folder (CamelService *service,
-					const gchar *name,
-					gboolean create,
-					GPtrArray *uids,
-					GByteArray *flags,
-					GPtrArray *hrefs,
-					guint32 high_article_num,
-					guint32 *folder_flags, /* out */
-					gchar **folder_uri, /* out */
-					gboolean *readonly, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_get_trash_name (CamelService *service,
-					gchar **trash_name, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_refresh_folder (CamelService *service,
-					const gchar *folder_name,
-					GError **error);
-
-gboolean camel_exchange_utils_sync_count (CamelService *service,
-					const gchar *folder_name,
-					guint32 *unread_count, /* out */
-					guint32 *visible_count, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_expunge_uids (CamelService *service,
-					const gchar *folder_name,
-					GPtrArray *uids,
-					GError **error);
-
-gboolean camel_exchange_utils_append_message (CamelService *service,
-					const gchar *folder_name,
-					guint32 flags,
-					const gchar *subject,
-					const GByteArray *message,
-					gchar **new_uid, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_set_message_flags (CamelService *service,
-					const gchar *folder_name,
-					const gchar *uid,
-					guint32 flags,
-					guint32 mask,
-					GError **error);
-
-gboolean camel_exchange_utils_set_message_tag (CamelService *service,
-					const gchar *folder_name,
-					const gchar *uid,
-					const gchar *name,
-					const gchar *value,
-					GError **error);
-
-gboolean camel_exchange_utils_get_message (CamelService *service,
-					const gchar *folder_name,
-					const gchar *uid,
-					GByteArray **message_bytes, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_search (CamelService *service,
-					const gchar *folder_name,
-					const gchar *text,
-					GPtrArray **found_uids, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_transfer_messages (CamelService *service,
-					const gchar *source_name,
-					const gchar *dest_name,
-					GPtrArray *uids,
-					gboolean delete_originals,
-					GPtrArray **ret_uids, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_get_folder_info (CamelService *service,
-					const gchar *top,
-					guint32 store_flags,
-					GPtrArray **folder_names, /* out */
-					GPtrArray **folder_uris, /* out */
-					GArray **unread_counts, /* out */
-					GArray **folder_flags, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_send_message (CamelService *service,
-					const gchar *from,
-					GPtrArray *recipients,
-					const GByteArray *message,
-					GError **error);
-
-gboolean camel_exchange_utils_create_folder (CamelService *service,
-					const gchar *parent_name,
-					const gchar *folder_name,
-					gchar **folder_uri, /* out */
-					guint32 *unread_count, /* out */
-					guint32 *flags, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_delete_folder (CamelService *service,
-					const gchar *folder_name,
-					GError **error);
-
-gboolean camel_exchange_utils_rename_folder (CamelService *service,
-					const gchar *old_name,
-					const gchar *new_name,
-					GPtrArray **folder_names, /* out */
-					GPtrArray **folder_uris, /* out */
-					GArray **unread_counts, /* out */
-					GArray **folder_flags, /* out */
-					GError **error);
-
-gboolean camel_exchange_utils_subscribe_folder (CamelService *service,
-					const gchar *folder_name,
-					GError **error);
-
-gboolean camel_exchange_utils_unsubscribe_folder (CamelService *service,
-					const gchar *folder_name,
-					GError **error);
-
-gboolean camel_exchange_utils_is_subscribed_folder (CamelService *service,
-					const gchar *folder_name,
-					gboolean *is_subscribed, /* out */
-					GError **error);
+gboolean	camel_exchange_utils_connect	(CamelService *service,
+						 const gchar *pwd,
+						 guint32 *status, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_get_folder	(CamelService *service,
+						 const gchar *name,
+						 gboolean create,
+						 GPtrArray *uids,
+						 GByteArray *flags,
+						 GPtrArray *hrefs,
+						 guint32 high_article_num,
+						 guint32 *folder_flags, /* out */
+						 gchar **folder_uri, /* out */
+						 gboolean *readonly, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_get_trash_name
+						(CamelService *service,
+						 gchar **trash_name, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_refresh_folder
+						(CamelService *service,
+						 const gchar *folder_name,
+						 GCancellable *cancellable,
+						 GError **error);
+
+gboolean	camel_exchange_utils_sync_count	(CamelService *service,
+						 const gchar *folder_name,
+						 guint32 *unread_count, /* out */
+						 guint32 *visible_count, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_expunge_uids
+						(CamelService *service,
+						 const gchar *folder_name,
+						 GPtrArray *uids,
+						 GCancellable *cancelable,
+						 GError **error);
+
+gboolean	camel_exchange_utils_append_message
+						(CamelService *service,
+						 const gchar *folder_name,
+						 guint32 flags,
+						 const gchar *subject,
+						 const GByteArray *message,
+						 gchar **new_uid, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_set_message_flags
+						(CamelService *service,
+						 const gchar *folder_name,
+						 const gchar *uid,
+						 guint32 flags,
+						 guint32 mask,
+						 GError **error);
+
+gboolean	camel_exchange_utils_set_message_tag
+						(CamelService *service,
+						 const gchar *folder_name,
+						 const gchar *uid,
+						 const gchar *name,
+						 const gchar *value,
+						 GError **error);
+
+gboolean	camel_exchange_utils_get_message
+						(CamelService *service,
+						 const gchar *folder_name,
+						 const gchar *uid,
+						 GByteArray **message_bytes, /* out */
+						GError **error);
+
+gboolean	camel_exchange_utils_search	(CamelService *service,
+						 const gchar *folder_name,
+						 const gchar *text,
+						 GPtrArray **found_uids, /* out */
+						GError **error);
+
+gboolean	camel_exchange_utils_transfer_messages
+						(CamelService *service,
+						 const gchar *source_name,
+						 const gchar *dest_name,
+						 GPtrArray *uids,
+						 gboolean delete_originals,
+						 GPtrArray **ret_uids, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_get_folder_info
+						(CamelService *service,
+						 const gchar *top,
+						 guint32 store_flags,
+						 GPtrArray **folder_names, /* out */
+						 GPtrArray **folder_uris, /* out */
+						 GArray **unread_counts, /* out */
+						 GArray **folder_flags, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_send_message
+						(CamelService *service,
+						 const gchar *from,
+						 GPtrArray *recipients,
+						 const GByteArray *message,
+						 GError **error);
+
+gboolean	camel_exchange_utils_create_folder
+						(CamelService *service,
+						 const gchar *parent_name,
+						 const gchar *folder_name,
+						 gchar **folder_uri, /* out */
+						 guint32 *unread_count, /* out */
+						 guint32 *flags, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_delete_folder
+						(CamelService *service,
+						 const gchar *folder_name,
+						 GError **error);
+
+gboolean	camel_exchange_utils_rename_folder
+						(CamelService *service,
+						 const gchar *old_name,
+						 const gchar *new_name,
+						 GPtrArray **folder_names, /* out */
+						 GPtrArray **folder_uris, /* out */
+						 GArray **unread_counts, /* out */
+						 GArray **folder_flags, /* out */
+						 GError **error);
+
+gboolean	camel_exchange_utils_subscribe_folder
+						(CamelService *service,
+						 const gchar *folder_name,
+						 GError **error);
+
+gboolean	camel_exchange_utils_unsubscribe_folder
+						(CamelService *service,
+						 const gchar *folder_name,
+						 GError **error);
+
+gboolean	camel_exchange_utils_is_subscribed_folder
+						(CamelService *service,
+						 const gchar *folder_name,
+						 gboolean *is_subscribed, /* out */
+						 GError **error);
 
 G_END_DECLS
 
diff --git a/eplugin/exchange-delegates-user.c b/eplugin/exchange-delegates-user.c
index 468ce6f..b7bd34d 100644
--- a/eplugin/exchange-delegates-user.c
+++ b/eplugin/exchange-delegates-user.c
@@ -464,7 +464,8 @@ exchange_delegates_user_edit (ExchangeAccount *account,
 				*/
 				camel_stream_printf (stream, "<br>%s", _("However, you are not permitted "
 							 "to see my private items."));
-			camel_data_wrapper_construct_from_stream (delegate_mail_text, stream, NULL);
+			camel_data_wrapper_construct_from_stream_sync (
+				delegate_mail_text, stream, NULL, NULL);
 			g_free (role_name);
 			g_string_free (role_name_final, TRUE);
 			g_object_unref (stream);
@@ -483,7 +484,8 @@ exchange_delegates_user_edit (ExchangeAccount *account,
 			stream = camel_stream_mem_new ();
 			part = camel_mime_part_new ();
 
-			camel_data_wrapper_construct_from_stream (delegate_mail_data, stream, NULL);
+			camel_data_wrapper_construct_from_stream_sync (
+				delegate_mail_data, stream, NULL, NULL);
 			g_object_unref (stream);
 			camel_medium_set_content (CAMEL_MEDIUM (part), delegate_mail_data);
 			g_object_unref (delegate_mail_data);



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