[evolution-kolab/ek-wip-porting] camel, libekolab: build fixes (pt. II) (fixes for Camel API changes)



commit 815e4ee44fa5acd3374a881d8fb5f6c01148baec
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Dec 9 11:03:30 2011 +0100

    camel, libekolab: build fixes (pt. II) (fixes for Camel API changes)
    
    * make all functions which have this Camel
      requirement cancellable
    * use *_sync() Camel functions where applicable (closest match
      to the functions we used before)

 src/camel/camel-kolab-imapx-store.c     |   19 +++
 src/camel/camel-kolab-imapx-store.h     |    7 +
 src/camel/camel-kolab-session.c         |    4 +
 src/camel/camel-kolab-session.h         |    2 +
 src/libekolab/kolab-mail-access.c       |   86 ++++++++++-
 src/libekolab/kolab-mail-access.h       |  129 +++++++++++++----
 src/libekolab/kolab-mail-imap-client.c  |  252 +++++++++++++++++++++++--------
 src/libekolab/kolab-mail-imap-client.h  |  126 ++++++++++++---
 src/libekolab/kolab-mail-mime-builder.c |   56 +++----
 src/libekolab/kolab-mail-mime-builder.h |   50 +++++--
 src/libekolab/kolab-mail-synchronizer.c |   38 +++++-
 src/libekolab/kolab-mail-synchronizer.h |  120 +++++++++-------
 12 files changed, 672 insertions(+), 217 deletions(-)
---
diff --git a/src/camel/camel-kolab-imapx-store.c b/src/camel/camel-kolab-imapx-store.c
index fbcbd5e..036e5e1 100644
--- a/src/camel/camel-kolab-imapx-store.c
+++ b/src/camel/camel-kolab-imapx-store.c
@@ -659,10 +659,12 @@ camel_kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *self,
 KolabFolderTypeID
 camel_kolab_imapx_store_get_folder_type (CamelKolabIMAPXStore *self,
                                          const gchar *foldername,
+                                         GCancellable *cancellable,
                                          GError **err)
 {
 	g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
 	(void)foldername; /* FIXME */
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, KOLAB_FOLDER_TYPE_INVAL);
 
 	/* FIXME implement me */
@@ -671,6 +673,23 @@ camel_kolab_imapx_store_get_folder_type (CamelKolabIMAPXStore *self,
 	return KOLAB_FOLDER_TYPE_INVAL;
 }
 
+gboolean
+camel_kolab_imapx_store_logout_sync (CamelKolabIMAPXStore *self,
+                                     GCancellable *cancellable,
+                                     GError **err)
+{
+	/* TODO check whether this function is still needed */
+
+	g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	/* FIXME implement me */
+	g_error ("%s: FIXME implement me", __func__);
+
+	return FALSE;
+}
+
 GList*
 camel_kolab_imapx_store_resect_folder_list (CamelKolabIMAPXStore *self)
 {
diff --git a/src/camel/camel-kolab-imapx-store.h b/src/camel/camel-kolab-imapx-store.h
index c099e87..bc4c179 100644
--- a/src/camel/camel-kolab-imapx-store.h
+++ b/src/camel/camel-kolab-imapx-store.h
@@ -101,8 +101,15 @@ camel_kolab_imapx_store_set_folder_context (CamelKolabIMAPXStore *self,
 KolabFolderTypeID
 camel_kolab_imapx_store_get_folder_type (CamelKolabIMAPXStore *self,
                                          const gchar *foldername,
+                                         GCancellable *cancellable,
                                          GError **err);
 
+/* send a LOGOUT to the server (still neeed??) */
+gboolean
+camel_kolab_imapx_store_logout_sync (CamelKolabIMAPXStore *self,
+                                     GCancellable *cancellable,
+                                     GError **err);
+
 GList*
 camel_kolab_imapx_store_resect_folder_list (CamelKolabIMAPXStore *self);
 
diff --git a/src/camel/camel-kolab-session.c b/src/camel/camel-kolab-session.c
index b19d9cd..d2f8c33 100644
--- a/src/camel/camel-kolab-session.c
+++ b/src/camel/camel-kolab-session.c
@@ -170,6 +170,7 @@ pk11_password (PK11SlotInfo *slot,
 
 gboolean
 camel_kolab_session_bringup (CamelKolabSession *self,
+                             GCancellable *cancellable,
                              GError **err)
 {
 	/* TODO rework to use GInitable */
@@ -177,6 +178,7 @@ camel_kolab_session_bringup (CamelKolabSession *self,
 	CamelKolabSessionPrivate *priv = NULL;
 
 	g_assert (CAMEL_IS_KOLAB_SESSION (self));
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = CAMEL_KOLAB_SESSION_PRIVATE (self);
@@ -215,11 +217,13 @@ camel_kolab_session_bringup (CamelKolabSession *self,
 
 gboolean
 camel_kolab_session_shutdown (CamelKolabSession *self,
+                              GCancellable *cancellable,
                               GError **err)
 {
 	CamelKolabSessionPrivate *priv = NULL;
 
 	g_assert (CAMEL_IS_KOLAB_SESSION (self));
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = CAMEL_KOLAB_SESSION_PRIVATE (self);
diff --git a/src/camel/camel-kolab-session.h b/src/camel/camel-kolab-session.h
index baaf064..0bffe54 100644
--- a/src/camel/camel-kolab-session.h
+++ b/src/camel/camel-kolab-session.h
@@ -85,10 +85,12 @@ camel_kolab_session_get_type (void);
 
 gboolean
 camel_kolab_session_bringup (CamelKolabSession *self,
+                             GCancellable *cancellable,
                              GError **err);
 
 gboolean
 camel_kolab_session_shutdown (CamelKolabSession *self,
+                              GCancellable *cancellable,
                               GError **err);
 
 void
diff --git a/src/libekolab/kolab-mail-access.c b/src/libekolab/kolab-mail-access.c
index 3e59fce..cafd779 100644
--- a/src/libekolab/kolab-mail-access.c
+++ b/src/libekolab/kolab-mail-access.c
@@ -487,6 +487,7 @@ static gboolean
 kolab_mail_access_local_store (KolabMailAccess *self,
                                KolabMailHandle *kmailhandle,
                                const gchar *foldername,
+                               GCancellable *cancellable,
                                GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -506,6 +507,7 @@ kolab_mail_access_local_store (KolabMailAccess *self,
 	if (kmailhandle != NULL)
 		g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -557,6 +559,7 @@ kolab_mail_access_local_store (KolabMailAccess *self,
 	                                                         foldername,
 	                                                         NULL,
 	                                                         TRUE, /* need to update folder */
+	                                                         cancellable,
 	                                                         &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -569,6 +572,7 @@ kolab_mail_access_local_store (KolabMailAccess *self,
 	                                                        foldername,
 	                                                        imap_summaries,
 	                                                        &record,
+	                                                        cancellable,
 	                                                        &tmp_err);
 	if (imap_summaries != NULL) {
 		g_hash_table_destroy (imap_summaries);
@@ -622,6 +626,7 @@ kolab_mail_access_local_store (KolabMailAccess *self,
 		                                   local_handle,
 		                                   foldername,
 		                                   FALSE, /* folder already updated */
+		                                   cancellable,
 		                                   &tmp_err);
 		if (ok) {
 			sync_opmode = KOLAB_MAIL_ACCESS_OPMODE_ONLINE;
@@ -686,6 +691,7 @@ static gboolean
 kolab_mail_access_local_delete (KolabMailAccess *self,
                                 KolabMailHandle *kmailhandle,
                                 const gchar *foldername,
+                                GCancellable *cancellable,
                                 GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -706,6 +712,7 @@ kolab_mail_access_local_delete (KolabMailAccess *self,
 	if (kmailhandle != NULL)
 		g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -755,6 +762,7 @@ kolab_mail_access_local_delete (KolabMailAccess *self,
 	                                                         foldername,
 	                                                         NULL,
 	                                                         TRUE, /* need to update folder here */
+	                                                         cancellable,
 	                                                         &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -768,6 +776,7 @@ kolab_mail_access_local_delete (KolabMailAccess *self,
 	                                                      foldername_del,
 	                                                      imap_summaries,
 	                                                      &record,
+	                                                      cancellable,
 	                                                      &tmp_err);
 	if (imap_summaries != NULL) {
 		g_hash_table_destroy (imap_summaries);
@@ -812,6 +821,7 @@ kolab_mail_access_local_delete (KolabMailAccess *self,
 					                                    kmailhandle,
 					                                    FALSE, /* try not only by IMAP UID */
 					                                    FALSE, /* folder already updated */
+					                                    cancellable,
 					                                    &tmp_err);
 				} else {
 					ok = TRUE;
@@ -824,6 +834,7 @@ kolab_mail_access_local_delete (KolabMailAccess *self,
 				 */
 				ok = kolab_mail_imap_client_delete_folder (priv->client,
 				                                           foldername_del,
+				                                           cancellable,
 				                                           &tmp_err);
 			}
 			if (ok) {
@@ -895,7 +906,7 @@ kolab_mail_access_local_delete (KolabMailAccess *self,
 /*----------------------------------------------------------------------------*/
 /* object state transition table and functions */
 
-typedef gboolean (*KolabMailAccessStateTransitionFunc) (KolabMailAccess *self, GError **err);
+typedef gboolean (*KolabMailAccessStateTransitionFunc) (KolabMailAccess *self, GCancellable *cancellable, GError **err);
 
 typedef struct _KolabMailAccessSTFWrap KolabMailAccessSTFWrap;
 struct _KolabMailAccessSTFWrap {
@@ -915,6 +926,7 @@ static gint opmode_values[] = {
 
 static gboolean
 kolab_mail_access_strans_configured_offline (KolabMailAccess *self,
+                                             GCancellable *cancellable,
                                              GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -924,6 +936,7 @@ kolab_mail_access_strans_configured_offline (KolabMailAccess *self,
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -952,6 +965,7 @@ kolab_mail_access_strans_configured_offline (KolabMailAccess *self,
 
 	/* KolabMailImapClient *client */
 	ok = kolab_mail_imap_client_bringup (priv->client,
+	                                     cancellable,
 	                                     &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -993,6 +1007,7 @@ kolab_mail_access_strans_configured_offline (KolabMailAccess *self,
 	ok = kolab_mail_synchronizer_info_sync (priv->synchronizer,
 	                                        KOLAB_MAIL_ACCESS_OPMODE_OFFLINE,
 	                                        NULL,
+	                                        cancellable,
 	                                        &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1031,6 +1046,7 @@ kolab_mail_access_strans_configured_offline (KolabMailAccess *self,
 
 static gboolean
 kolab_mail_access_strans_offline_online (KolabMailAccess *self,
+                                         GCancellable *cancellable,
                                          GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -1040,6 +1056,7 @@ kolab_mail_access_strans_offline_online (KolabMailAccess *self,
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -1060,6 +1077,7 @@ kolab_mail_access_strans_offline_online (KolabMailAccess *self,
 
 	/* get IMAP client into online mode */
 	ok = kolab_mail_imap_client_go_online (priv->client,
+	                                       cancellable,
 	                                       &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1070,6 +1088,7 @@ kolab_mail_access_strans_offline_online (KolabMailAccess *self,
 	ok = kolab_mail_synchronizer_info_sync (priv->synchronizer,
 	                                        KOLAB_MAIL_ACCESS_OPMODE_ONLINE,
 	                                        NULL,
+	                                        cancellable,
 	                                        &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1082,6 +1101,7 @@ kolab_mail_access_strans_offline_online (KolabMailAccess *self,
 	ok = kolab_mail_synchronizer_full_sync (priv->synchronizer,
 	                                        KOLAB_MAIL_ACCESS_OPMODE_ONLINE,
 	                                        NULL,
+	                                        cancellable,
 	                                        &tmp_err);
 	if (! ok) {
 		g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1121,21 +1141,27 @@ kolab_mail_access_strans_offline_online (KolabMailAccess *self,
 
 static gboolean
 kolab_mail_access_strans_configured_online (KolabMailAccess *self,
+                                            GCancellable *cancellable,
                                             GError **err)
 {
 	gboolean ok = FALSE;
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	ok = kolab_mail_access_strans_configured_offline (self, &tmp_err);
+	ok = kolab_mail_access_strans_configured_offline (self,
+	                                                  cancellable,
+	                                                  &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
 
-	ok = kolab_mail_access_strans_offline_online (self, &tmp_err);
+	ok = kolab_mail_access_strans_offline_online (self,
+	                                              cancellable,
+	                                              &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -1146,6 +1172,7 @@ kolab_mail_access_strans_configured_online (KolabMailAccess *self,
 
 static gboolean
 kolab_mail_access_strans_online_offline (KolabMailAccess *self,
+                                         GCancellable *cancellable,
                                          GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -1155,6 +1182,7 @@ kolab_mail_access_strans_online_offline (KolabMailAccess *self,
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -1191,6 +1219,7 @@ kolab_mail_access_strans_online_offline (KolabMailAccess *self,
 	ok = kolab_mail_synchronizer_info_sync (priv->synchronizer,
 	                                        KOLAB_MAIL_ACCESS_OPMODE_ONLINE,
 	                                        NULL,
+	                                        cancellable,
 	                                        &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1204,6 +1233,7 @@ kolab_mail_access_strans_online_offline (KolabMailAccess *self,
 	ok = kolab_mail_synchronizer_full_sync (priv->synchronizer,
 	                                        KOLAB_MAIL_ACCESS_OPMODE_ONLINE,
 	                                        NULL,
+	                                        cancellable,
 	                                        &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1212,6 +1242,7 @@ kolab_mail_access_strans_online_offline (KolabMailAccess *self,
 
 	/* get IMAP client into offline mode */
 	ok = kolab_mail_imap_client_go_offline (priv->client,
+	                                        cancellable,
 	                                        &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1251,6 +1282,7 @@ kolab_mail_access_strans_online_offline (KolabMailAccess *self,
 
 static gboolean
 kolab_mail_access_strans_offline_shutdown (KolabMailAccess *self,
+                                           GCancellable *cancellable,
                                            GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -1258,6 +1290,7 @@ kolab_mail_access_strans_offline_shutdown (KolabMailAccess *self,
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -1327,6 +1360,7 @@ kolab_mail_access_strans_offline_shutdown (KolabMailAccess *self,
 
 	/* KolabMailImapClient *client */
 	ok = kolab_mail_imap_client_shutdown (priv->client,
+	                                      cancellable,
 	                                      &tmp_err);
 	if (! ok) {
 		g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1342,21 +1376,27 @@ kolab_mail_access_strans_offline_shutdown (KolabMailAccess *self,
 
 static gboolean
 kolab_mail_access_strans_online_shutdown (KolabMailAccess *self,
+                                          GCancellable *cancellable,
                                           GError **err)
 {
 	gboolean ok = FALSE;
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	ok = kolab_mail_access_strans_online_offline (self, &tmp_err);
+	ok = kolab_mail_access_strans_online_offline (self,
+	                                              cancellable,
+	                                              &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
 
-	ok = kolab_mail_access_strans_offline_shutdown (self, &tmp_err);
+	ok = kolab_mail_access_strans_offline_shutdown (self,
+	                                                cancellable,
+	                                                &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -1367,11 +1407,13 @@ kolab_mail_access_strans_online_shutdown (KolabMailAccess *self,
 
 static gboolean
 kolab_mail_access_strans_shutdown_configured (KolabMailAccess *self,
+                                              GCancellable *cancellable,
                                               GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -1692,16 +1734,19 @@ kolab_mail_access_get_settings_handler (KolabMailAccess *self)
  */
 gboolean
 kolab_mail_access_bringup (KolabMailAccess *self,
+                           GCancellable *cancellable,
                            GError **err)
 {
 	gboolean ok = FALSE;
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	ok = kolab_mail_access_set_opmode (self,
 	                                   KOLAB_MAIL_ACCESS_OPMODE_OFFLINE,
+	                                   cancellable,
 	                                   &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1734,6 +1779,7 @@ kolab_mail_access_bringup (KolabMailAccess *self,
  */
 gboolean
 kolab_mail_access_shutdown (KolabMailAccess *self,
+                            GCancellable *cancellable,
                             GError **err)
 {
 	gboolean ok = FALSE;
@@ -1744,6 +1790,7 @@ kolab_mail_access_shutdown (KolabMailAccess *self,
 
 	ok = kolab_mail_access_set_opmode (self,
 	                                   KOLAB_MAIL_ACCESS_OPMODE_SHUTDOWN,
+	                                   cancellable,
 	                                   &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1790,6 +1837,7 @@ kolab_mail_access_shutdown (KolabMailAccess *self,
 gboolean
 kolab_mail_access_set_opmode (KolabMailAccess *self,
                               KolabMailAccessOpmodeID opmode,
+                              GCancellable *cancellable,
                               GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -1800,6 +1848,7 @@ kolab_mail_access_set_opmode (KolabMailAccess *self,
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert ((opmode > KOLAB_MAIL_ACCESS_OPMODE_INVAL) &&
 	          (opmode < KOLAB_MAIL_ACCESS_LAST_OPMODE));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -1816,7 +1865,9 @@ kolab_mail_access_set_opmode (KolabMailAccess *self,
 	}
 
 	/* call opmode state transition function */
-	strans_ok = strans_fn (self, &tmp_err);
+	strans_ok = strans_fn (self,
+	                       cancellable,
+	                       &tmp_err);
 	if (! strans_ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -1981,6 +2032,7 @@ GList*
 kolab_mail_access_query_changed_uids (KolabMailAccess *self,
                                       const gchar *sourcename,
                                       const gchar *sexp,
+                                      GCancellable *cancellable,
                                       GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -1992,6 +2044,7 @@ kolab_mail_access_query_changed_uids (KolabMailAccess *self,
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (sourcename != NULL);
 	/* sexp may be NULL */
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2009,6 +2062,7 @@ kolab_mail_access_query_changed_uids (KolabMailAccess *self,
 		ok = kolab_mail_synchronizer_info_sync (priv->synchronizer,
 		                                        KOLAB_MAIL_ACCESS_OPMODE_ONLINE,
 		                                        foldername,
+		                                        cancellable,
 		                                        &tmp_err);
 		if (! ok) {
 			g_propagate_error (err, tmp_err);
@@ -2066,6 +2120,7 @@ const KolabMailHandle*
 kolab_mail_access_get_handle (KolabMailAccess *self,
                               const gchar *uid,
                               const gchar *sourcename,
+                              GCancellable *cancellable,
                               GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -2079,6 +2134,7 @@ kolab_mail_access_get_handle (KolabMailAccess *self,
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (uid != NULL);
 	g_assert (sourcename != NULL);
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2198,6 +2254,7 @@ gboolean
 kolab_mail_access_store_handle (KolabMailAccess *self,
                                 KolabMailHandle *kmailhandle,
                                 const gchar *sourcename,
+                                GCancellable *cancellable,
                                 GError **err)
 {
 	/* we take ownership of KolabMailHandle here */
@@ -2217,6 +2274,7 @@ kolab_mail_access_store_handle (KolabMailAccess *self,
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
 	g_assert (sourcename != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2274,6 +2332,7 @@ kolab_mail_access_store_handle (KolabMailAccess *self,
 	ok = kolab_mail_access_local_store (self,
 	                                    kmailhandle,
 	                                    sourcename_fn,
+	                                    cancellable,
 	                                    &tmp_err);
 	g_free (sourcename_fn);
 	if (! ok) {
@@ -2326,6 +2385,7 @@ gboolean
 kolab_mail_access_retrieve_handle (KolabMailAccess *self,
                                    const KolabMailHandle *kmailhandle,
                                    gboolean bulk,
+                                   GCancellable *cancellable,
                                    GError **err)
 {
 	/* TODO in online mode, do we re-check with the server for
@@ -2343,6 +2403,7 @@ kolab_mail_access_retrieve_handle (KolabMailAccess *self,
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2420,6 +2481,7 @@ kolab_mail_access_retrieve_handle (KolabMailAccess *self,
 		ok = kolab_mail_imap_client_retrieve (priv->client,
 		                                      local_handle,
 		                                      update,
+		                                      cancellable,
 		                                      &tmp_err);
 		if (! ok) {
 			g_propagate_error (err, tmp_err);
@@ -2477,6 +2539,7 @@ kolab_mail_access_retrieve_handle (KolabMailAccess *self,
 gboolean
 kolab_mail_access_delete_handle (KolabMailAccess *self,
                                  const KolabMailHandle *kmailhandle,
+                                 GCancellable *cancellable,
                                  GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -2489,6 +2552,7 @@ kolab_mail_access_delete_handle (KolabMailAccess *self,
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2517,6 +2581,7 @@ kolab_mail_access_delete_handle (KolabMailAccess *self,
 	ok = kolab_mail_access_local_delete (self,
 	                                     local_handle,
 	                                     foldername,
+	                                     cancellable,
 	                                     &tmp_err);
 	if (! ok) {
 		g_warning ("%s: UID (%s) Folder (%s) error destroying: %s",
@@ -2563,6 +2628,7 @@ gboolean
 kolab_mail_access_delete_by_uid (KolabMailAccess *self,
                                  const gchar *uid,
                                  const gchar *sourcename,
+                                 GCancellable *cancellable,
                                  GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -2576,6 +2642,7 @@ kolab_mail_access_delete_by_uid (KolabMailAccess *self,
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (uid != NULL);
 	g_assert (sourcename != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2612,6 +2679,7 @@ kolab_mail_access_delete_by_uid (KolabMailAccess *self,
 	ok = kolab_mail_access_local_delete (self,
 	                                     local_handle,
 	                                     foldername,
+	                                     cancellable,
 	                                     &tmp_err);
 	if (! ok) {
 		g_free (foldername);
@@ -2741,6 +2809,7 @@ kolab_mail_access_query_sources (KolabMailAccess *self,
 gboolean
 kolab_mail_access_create_source (KolabMailAccess *self,
                                  const gchar *sourcename,
+                                 GCancellable *cancellable,
                                  GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -2751,6 +2820,7 @@ kolab_mail_access_create_source (KolabMailAccess *self,
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (sourcename != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2783,6 +2853,7 @@ kolab_mail_access_create_source (KolabMailAccess *self,
 	ok = kolab_mail_access_local_store (self,
 	                                    NULL,
 	                                    foldername,
+	                                    cancellable,
 	                                    &tmp_err);
 	g_free (foldername);
 	if (! ok) {
@@ -2823,6 +2894,7 @@ kolab_mail_access_create_source (KolabMailAccess *self,
 gboolean
 kolab_mail_access_delete_source (KolabMailAccess *self,
                                  const gchar *sourcename,
+                                 GCancellable *cancellable,
                                  GError **err)
 {
 	KolabMailAccessPrivate *priv = NULL;
@@ -2833,6 +2905,7 @@ kolab_mail_access_delete_source (KolabMailAccess *self,
 
 	g_assert (KOLAB_IS_MAIL_ACCESS (self));
 	g_assert (sourcename != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
@@ -2865,6 +2938,7 @@ kolab_mail_access_delete_source (KolabMailAccess *self,
 	ok = kolab_mail_access_local_delete (self,
 	                                     NULL,
 	                                     foldername,
+	                                     cancellable,
 	                                     &tmp_err);
 	g_free (foldername);
 	if (! ok) {
diff --git a/src/libekolab/kolab-mail-access.h b/src/libekolab/kolab-mail-access.h
index a8180b8..0685784 100644
--- a/src/libekolab/kolab-mail-access.h
+++ b/src/libekolab/kolab-mail-access.h
@@ -12,17 +12,17 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
  */
- 
+
 /*----------------------------------------------------------------------------*/
 
 /**
@@ -32,7 +32,7 @@
  * @section_id:
  * @see_also: #KolabMailImapClient, #KolabMailInfoDb, #KolabMailMimeBuilder, #KolabMailSideCache, #KolabMailSynchronizer, #KolabMailHandle, #KolabSettingsHandler
  * @stability: unstable
- * 
+ *
  * This class is the main Kolab2 PIM email store and server connector. It is
  * comprised of the following main objects
  * <itemizedlist>
@@ -132,29 +132,104 @@ struct _KolabMailAccess
 	GObject parent_instance;
 };
 
-GType kolab_mail_access_get_type (void) G_GNUC_CONST;
-
-gboolean kolab_mail_access_configure (KolabMailAccess *self, KolabSettingsHandler *ksettings, GError **err);
-KolabSettingsHandler* kolab_mail_access_get_settings_handler (KolabMailAccess *self);
-gboolean kolab_mail_access_bringup (KolabMailAccess *self, GError **err);
-gboolean kolab_mail_access_shutdown (KolabMailAccess *self, GError **err);
-
-gboolean kolab_mail_access_set_opmode (KolabMailAccess *self, KolabMailAccessOpmodeID opmode, GError **err);
-KolabMailAccessOpmodeID kolab_mail_access_get_opmode (KolabMailAccess *self, GError **err);
-
-GList* kolab_mail_access_query_sources (KolabMailAccess *self, GError **err);
-gboolean kolab_mail_access_create_source (KolabMailAccess *self, const gchar *sourcename, GError **err);
-gboolean kolab_mail_access_delete_source (KolabMailAccess *self, const gchar *sourcename, GError **err);
-gboolean kolab_mail_access_source_fbtrigger_needed (KolabMailAccess *self, const gchar *sourcename, GError **err);
-
-GList* kolab_mail_access_query_uids (KolabMailAccess *self, const gchar *sourcename, const gchar *sexp, GError **err);
-GList* kolab_mail_access_query_changed_uids (KolabMailAccess *self, const gchar *sourcename, const gchar *sexp, GError **err);
-
-const KolabMailHandle* kolab_mail_access_get_handle (KolabMailAccess *self, const gchar *uid, const gchar *sourcename, GError **err);
-gboolean kolab_mail_access_store_handle (KolabMailAccess *self, KolabMailHandle *kmailhandle, const gchar *sourcename, GError **err);
-gboolean kolab_mail_access_retrieve_handle (KolabMailAccess *self, const KolabMailHandle *kmailhandle, gboolean bulk, GError **err);
-gboolean kolab_mail_access_delete_handle (KolabMailAccess *self, const KolabMailHandle *kmailhandle, GError **err);
-gboolean kolab_mail_access_delete_by_uid (KolabMailAccess *self, const gchar *uid, const gchar *sourcename, GError **err);
+GType
+kolab_mail_access_get_type (void) G_GNUC_CONST;
+
+gboolean
+kolab_mail_access_configure (KolabMailAccess *self,
+                             KolabSettingsHandler *ksettings,
+                             GError **err);
+
+KolabSettingsHandler*
+kolab_mail_access_get_settings_handler (KolabMailAccess *self);
+
+gboolean
+kolab_mail_access_bringup (KolabMailAccess *self,
+                           GCancellable *cancellable,
+                           GError **err);
+
+gboolean
+kolab_mail_access_shutdown (KolabMailAccess *self,
+                            GCancellable *cancellable,
+                            GError **err);
+
+gboolean
+kolab_mail_access_set_opmode (KolabMailAccess *self,
+                              KolabMailAccessOpmodeID opmode,
+                              GCancellable *cancellable,
+                              GError **err);
+
+KolabMailAccessOpmodeID
+kolab_mail_access_get_opmode (KolabMailAccess *self,
+                              GError **err);
+
+GList*
+kolab_mail_access_query_sources (KolabMailAccess *self,
+                                 GError **err);
+
+gboolean
+kolab_mail_access_create_source (KolabMailAccess *self,
+                                 const gchar *sourcename,
+                                 GCancellable *cancellable,
+                                 GError **err);
+
+gboolean
+kolab_mail_access_delete_source (KolabMailAccess *self,
+                                 const gchar *sourcename,
+                                 GCancellable *cancellable,
+                                 GError **err);
+
+gboolean
+kolab_mail_access_source_fbtrigger_needed (KolabMailAccess *self,
+                                           const gchar *sourcename,
+                                           GError **err);
+
+GList*
+kolab_mail_access_query_uids (KolabMailAccess *self,
+                              const gchar *sourcename,
+                              const gchar *sexp,
+                              GError **err);
+
+GList*
+kolab_mail_access_query_changed_uids (KolabMailAccess *self,
+                                      const gchar *sourcename,
+                                      const gchar *sexp,
+                                      GCancellable *cancellable,
+                                      GError **err);
+
+const KolabMailHandle*
+kolab_mail_access_get_handle (KolabMailAccess *self,
+                              const gchar *uid,
+                              const gchar *sourcename,
+                              GCancellable *cancellable,
+                              GError **err);
+
+gboolean
+kolab_mail_access_store_handle (KolabMailAccess *self,
+                                KolabMailHandle *kmailhandle,
+                                const gchar *sourcename,
+                                GCancellable *cancellable,
+                                GError **err);
+
+gboolean
+kolab_mail_access_retrieve_handle (KolabMailAccess *self,
+                                   const KolabMailHandle *kmailhandle,
+                                   gboolean bulk,
+                                   GCancellable *cancellable,
+                                   GError **err);
+
+gboolean
+kolab_mail_access_delete_handle (KolabMailAccess *self,
+                                 const KolabMailHandle *kmailhandle,
+                                 GCancellable *cancellable,
+                                 GError **err);
+
+gboolean
+kolab_mail_access_delete_by_uid (KolabMailAccess *self,
+                                 const gchar *uid,
+                                 const gchar *sourcename,
+                                 GCancellable *cancellable,
+                                 GError **err);
 
 G_END_DECLS
 
diff --git a/src/libekolab/kolab-mail-imap-client.c b/src/libekolab/kolab-mail-imap-client.c
index 0c2392e..3a80102 100644
--- a/src/libekolab/kolab-mail-imap-client.c
+++ b/src/libekolab/kolab-mail-imap-client.c
@@ -184,15 +184,17 @@ kolab_mail_imap_client_class_init (KolabMailImapClientClass *klass)
 static CamelFolder*
 kolab_mail_imap_client_camel_get_folder (KolabMailImapClient *self,
                                          const gchar *foldername,
+                                         GCancellable *cancellable,
                                          GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
 	CamelFolder *folder = NULL;
 	GError *tmp_err = NULL;
-	guint32 flags = 0; /* TODO check which flags to set */
+	CamelStoreGetFolderFlags flags = 0; /* TODO check which flags to set */
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -206,10 +208,11 @@ kolab_mail_imap_client_camel_get_folder (KolabMailImapClient *self,
 	}
 
 	/* get new CamelFolder */
-	folder = camel_store_get_folder (CAMEL_STORE (priv->store),
-	                                 foldername,
-	                                 flags,
-	                                 &tmp_err);
+	folder = camel_store_get_folder_sync (CAMEL_STORE (priv->store),
+	                                      foldername,
+	                                      flags,
+	                                      cancellable,
+	                                      &tmp_err);
 	if (tmp_err != NULL) {
 		if (folder != NULL)
 			g_object_unref (folder);
@@ -243,6 +246,7 @@ kolab_mail_imap_client_camel_gen_summaries (KolabMailImapClient *self,
                                             const gchar *foldername,
                                             KolabFolderTypeID foldertype,
                                             KolabFolderContextID foldercontext,
+                                            GCancellable *cancellable,
                                             GError **err)
 {
 	/* KolabMailImapClientPrivate *priv = NULL; */
@@ -259,12 +263,13 @@ kolab_mail_imap_client_camel_gen_summaries (KolabMailImapClient *self,
 	          (foldertype < KOLAB_FOLDER_LAST_TYPE));
 	g_assert ((foldercontext >= KOLAB_FOLDER_CONTEXT_CALENDAR) &&
 	          (foldercontext < KOLAB_FOLDER_LAST_CONTEXT));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	/* priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self); */
-
 	folder =  kolab_mail_imap_client_camel_get_folder (self,
 	                                                   foldername,
+	                                                   cancellable,
 	                                                   &tmp_err);
 	if (folder == NULL) {
 		g_propagate_error (err, tmp_err);
@@ -361,6 +366,7 @@ kolab_mail_imap_client_camel_get_msg_imap_uid (KolabMailImapClient *self,
                                                const gchar *foldername,
                                                const gchar *imap_uid,
                                                const gchar *kolab_uid,
+                                               GCancellable *cancellable,
                                                GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -373,6 +379,7 @@ kolab_mail_imap_client_camel_get_msg_imap_uid (KolabMailImapClient *self,
 	g_assert (foldername != NULL);
 	g_assert (imap_uid != NULL);
 	/* kolab_uid may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -381,6 +388,7 @@ kolab_mail_imap_client_camel_get_msg_imap_uid (KolabMailImapClient *self,
 
 	folder = kolab_mail_imap_client_camel_get_folder (self,
 	                                                  foldername,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	if (folder == NULL) {
 		g_propagate_error (err, tmp_err);
@@ -420,7 +428,10 @@ kolab_mail_imap_client_camel_get_msg_imap_uid (KolabMailImapClient *self,
 
 	camel_folder_free_message_info (folder, mi);
 
-	message = camel_folder_get_message (folder, imap_uid, &tmp_err);
+	message = camel_folder_get_message_sync (folder,
+	                                         imap_uid,
+	                                         cancellable,
+	                                         &tmp_err);
 	if (tmp_err != NULL) {
 		if (message != NULL)
 			g_object_unref (message);
@@ -449,6 +460,7 @@ static CamelMimeMessage*
 kolab_mail_imap_client_camel_get_msg_kolab_uid (KolabMailImapClient *self,
                                                 const gchar *foldername,
                                                 const gchar *kolab_uid,
+                                                GCancellable *cancellable,
                                                 GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -461,6 +473,7 @@ kolab_mail_imap_client_camel_get_msg_kolab_uid (KolabMailImapClient *self,
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
 	g_assert (kolab_uid != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -469,13 +482,16 @@ kolab_mail_imap_client_camel_get_msg_kolab_uid (KolabMailImapClient *self,
 
 	folder = kolab_mail_imap_client_camel_get_folder (self,
 	                                                  foldername,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	if (folder ==  NULL) {
 		g_propagate_error (err, tmp_err);
 		return NULL;
 	}
 
-	camel_folder_refresh_info (folder, &tmp_err);
+	camel_folder_refresh_info_sync (folder,
+	                                cancellable,
+	                                &tmp_err);
 	if (tmp_err != NULL) {
 		g_object_unref (folder);
 		g_propagate_error (err, tmp_err);
@@ -501,6 +517,7 @@ kolab_mail_imap_client_camel_get_msg_kolab_uid (KolabMailImapClient *self,
 		                                                         foldername,
 		                                                         imap_uid,
 		                                                         NULL,
+		                                                         cancellable,
 		                                                         &tmp_err);
 		if (tmp_err != NULL) {
 			if (message != NULL) {
@@ -543,6 +560,7 @@ kolab_mail_imap_client_camel_get_msg_kolab_uid (KolabMailImapClient *self,
 static gboolean
 kolab_mail_imap_client_update_folder (KolabMailImapClient *self,
                                       const gchar *foldername,
+                                      GCancellable *cancellable,
                                       GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -551,12 +569,14 @@ kolab_mail_imap_client_update_folder (KolabMailImapClient *self,
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
 
 	folder = kolab_mail_imap_client_camel_get_folder (self,
 	                                                  foldername,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	if (folder == NULL) {
 		g_propagate_error (err, tmp_err);
@@ -573,30 +593,38 @@ kolab_mail_imap_client_update_folder (KolabMailImapClient *self,
 		return TRUE;
 	}
 
-	camel_offline_folder_downsync (CAMEL_OFFLINE_FOLDER (folder),
-	                               NULL,
-	                               &tmp_err);
+	camel_offline_folder_downsync_sync (CAMEL_OFFLINE_FOLDER (folder),
+	                                    NULL,
+	                                    cancellable,
+	                                    &tmp_err);
 	if (tmp_err != NULL) {
 		g_object_unref (folder);
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
 
-	camel_folder_sync (folder, TRUE, &tmp_err);
+	camel_folder_synchronize_sync (folder,
+	                               TRUE,
+	                               cancellable,
+	                               &tmp_err);
 	if (tmp_err != NULL) {
 		g_object_unref (folder);
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
 
-	camel_folder_expunge (folder, &tmp_err);
+	camel_folder_expunge_sync (folder,
+	                           cancellable,
+	                           &tmp_err);
 	if (tmp_err != NULL) {
 		g_object_unref (folder);
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
 
-	camel_folder_refresh_info (folder, &tmp_err);
+	camel_folder_refresh_info_sync (folder,
+	                                cancellable,
+	                                &tmp_err);
 	if (tmp_err != NULL) {
 		g_object_unref (folder);
 		g_propagate_error (err, tmp_err);
@@ -689,20 +717,35 @@ kolab_mail_imap_client_configure (KolabMailImapClient *self,
 
 gboolean
 kolab_mail_imap_client_bringup (KolabMailImapClient *self,
+                                GCancellable *cancellable,
                                 GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
 	CamelService *service = NULL;
-	CamelURL *camel_url = NULL;
-	gchar *camel_url_string = NULL;
-	const gchar *tmp_str = NULL;
-	KolabTLSVariantID tlsvariant = KOLAB_TLS_VARIANT_NONE;
-	const gchar *variant_str = NULL;
+	gchar *service_uid = NULL;
+	/* const gchar *tmp_str = NULL; */
+	/* KolabTLSVariantID tlsvariant = KOLAB_TLS_VARIANT_NONE; */
+	/* const gchar *variant_str = NULL; */
 	gchar *dbpath = NULL;
 	gboolean ok = FALSE;
 	GError *tmp_err = NULL;
 
+	/* TODO rework this function for new CamelSession API
+	 *
+	 *      CamelServices are now identified by an
+	 *      UID string, not by their CamelURL.
+	 *
+	 *      We need to set our CamelKolabIMAPXStore
+	 *      on the CamelSession with a call to
+	 *      camel_session_add_service() before retrieving
+	 *      it here. Need to find a suitable place to do
+	 *      that. Also need to get the UID string from
+	 *      somewhere.
+	 *
+	 */
+
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -713,12 +756,14 @@ kolab_mail_imap_client_bringup (KolabMailImapClient *self,
 		return TRUE;
 
 	/* bring up session object */
-	ok = camel_kolab_session_bringup (priv->session, &tmp_err);
+	ok = camel_kolab_session_bringup (priv->session,
+	                                  cancellable,
+	                                  &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
-
+#if 0
 	/* create url string for session getter */
 	camel_url = camel_url_new (KOLAB_CAMELURL_DUMMY_URL, NULL);
 	camel_url_set_protocol (camel_url, KOLAB_CAMEL_PROVIDER_PROTOCOL);
@@ -787,12 +832,11 @@ kolab_mail_imap_client_bringup (KolabMailImapClient *self,
 	/* camel_url_string = camel_url_to_string (camel_url, CAMEL_URL_HIDE_ALL); */
 	camel_url_string = camel_url_to_string (camel_url, 0);
 	g_debug ("%s: CamelURL: (%s)", __func__, camel_url_string);
-
+#endif
 	/* bring up imapx object */
 	service = camel_session_get_service (CAMEL_SESSION (priv->session),
-	                                     camel_url_string,
-	                                     CAMEL_PROVIDER_STORE,
-	                                     &tmp_err);
+	                                     service_uid);
+#if 0
 	g_free (camel_url_string);
 	camel_url_free (camel_url);
 	if (tmp_err != NULL) {
@@ -811,7 +855,7 @@ kolab_mail_imap_client_bringup (KolabMailImapClient *self,
 		             __func__, KOLAB_CAMEL_PROVIDER_PROTOCOL);
 		return FALSE;
 	}
-
+#endif
 	priv->store = CAMEL_KOLAB_IMAPX_STORE (service);
 	ok = camel_kolab_imapx_store_set_folder_context (priv->store,
 	                                                 priv->context);
@@ -825,9 +869,10 @@ kolab_mail_imap_client_bringup (KolabMailImapClient *self,
 	}
 
 	/* set offline state */
-	ok = camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->store),
-	                                            CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL,
-	                                            &tmp_err);
+	ok = camel_offline_store_set_online_sync (CAMEL_OFFLINE_STORE (priv->store),
+	                                          FALSE, /* offline */
+	                                          cancellable,
+	                                          &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -860,6 +905,7 @@ kolab_mail_imap_client_bringup (KolabMailImapClient *self,
 
 gboolean
 kolab_mail_imap_client_shutdown (KolabMailImapClient *self,
+                                 GCancellable *cancellable,
                                  GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -867,6 +913,7 @@ kolab_mail_imap_client_shutdown (KolabMailImapClient *self,
 	gboolean ok = FALSE;
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -879,7 +926,9 @@ kolab_mail_imap_client_shutdown (KolabMailImapClient *self,
 	/* TODO shut down imapx object */
 
 	/* shut down session object */
-	ok = camel_kolab_session_shutdown (priv->session, &tmp_err);
+	ok = camel_kolab_session_shutdown (priv->session,
+	                                   cancellable,
+	                                   &tmp_err);
 	if (! ok) {
 		g_warning ("%s: %s",
 		           __func__, tmp_err->message);
@@ -895,6 +944,7 @@ kolab_mail_imap_client_shutdown (KolabMailImapClient *self,
 
 gboolean
 kolab_mail_imap_client_go_online (KolabMailImapClient *self,
+                                  GCancellable *cancellable,
                                   GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -903,6 +953,7 @@ kolab_mail_imap_client_go_online (KolabMailImapClient *self,
 	gboolean ok = FALSE;
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -943,15 +994,16 @@ kolab_mail_imap_client_go_online (KolabMailImapClient *self,
 	priv->foldername = NULL;
 
 	/* connect the camel service */
-	ok = camel_service_connect (CAMEL_SERVICE (priv->store), &tmp_err);
+	ok = camel_service_connect_sync (CAMEL_SERVICE (priv->store), &tmp_err);
 	camel_kolab_session_set_token_pin (priv->session, NULL); /* forget pin */
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
-	camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->store),
-	                                       CAMEL_OFFLINE_STORE_NETWORK_AVAIL,
-	                                       &tmp_err);
+	camel_offline_store_set_online_sync (CAMEL_OFFLINE_STORE (priv->store),
+	                                     TRUE, /* online */
+	                                     cancellable,
+	                                     &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -966,6 +1018,7 @@ kolab_mail_imap_client_go_online (KolabMailImapClient *self,
 
 gboolean
 kolab_mail_imap_client_go_offline (KolabMailImapClient *self,
+                                   GCancellable *cancellable,
                                    GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -991,8 +1044,9 @@ kolab_mail_imap_client_go_offline (KolabMailImapClient *self,
 	priv->foldername = NULL;
 
 	/* disconnect the camel service */
-	camel_offline_store_prepare_for_offline (CAMEL_OFFLINE_STORE (priv->store),
-	                                         &tmp_err);
+	camel_offline_store_prepare_for_offline_sync (CAMEL_OFFLINE_STORE (priv->store),
+	                                              cancellable,
+	                                              &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -1009,16 +1063,25 @@ kolab_mail_imap_client_go_offline (KolabMailImapClient *self,
 	 */
 
 	/* issue LOGOUT message so we can get a BYE from server */
-	camel_kolab_imapx_store_logout_sync (priv->store);
+	ok = camel_kolab_imapx_store_logout_sync (priv->store,
+	                                          cancellable,
+	                                          &tmp_err);
+	if (! ok) {
+		g_propagate_error (err, tmp_err);
+		return FALSE;
+	}
 
-	ok = camel_service_disconnect (CAMEL_SERVICE (priv->store), TRUE, &tmp_err);
+	ok = camel_service_disconnect_sync (CAMEL_SERVICE (priv->store),
+	                                    TRUE, /* try to disconnect cleanly */
+	                                    &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
 	}
-	camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (priv->store),
-	                                       CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL,
-	                                       &tmp_err);
+	camel_offline_store_set_online_sync (CAMEL_OFFLINE_STORE (priv->store),
+	                                     FALSE, /* offline */
+	                                     cancellable,
+	                                     &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return FALSE;
@@ -1036,15 +1099,17 @@ kolab_mail_imap_client_go_offline (KolabMailImapClient *self,
 
 GList*
 kolab_mail_imap_client_query_foldernames (KolabMailImapClient *self,
+                                          GCancellable *cancellable,
                                           GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
 	CamelFolderInfo *fi = NULL;
 	GList *folder_list = NULL;
-	guint32 flags = 0;
+	CamelStoreGetFolderInfoFlags flags = 0;
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1052,10 +1117,11 @@ kolab_mail_imap_client_query_foldernames (KolabMailImapClient *self,
 	g_assert (priv->is_up == TRUE);
 
 	flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL;
-	fi = camel_store_get_folder_info (CAMEL_STORE (priv->store),
-	                                  NULL,
-	                                  flags,
-	                                  &tmp_err);
+	fi = camel_store_get_folder_info_sync (CAMEL_STORE (priv->store),
+	                                       NULL,
+	                                       flags,
+	                                       cancellable,
+	                                       &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
 		return NULL;
@@ -1073,6 +1139,7 @@ kolab_mail_imap_client_query_foldernames (KolabMailImapClient *self,
 KolabFolderTypeID
 kolab_mail_imap_client_get_folder_type (KolabMailImapClient *self,
                                         const gchar *foldername,
+                                        GCancellable *cancellable,
                                         GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -1081,12 +1148,14 @@ kolab_mail_imap_client_get_folder_type (KolabMailImapClient *self,
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, KOLAB_FOLDER_TYPE_INVAL);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
 
 	foldertype = camel_kolab_imapx_store_get_folder_type (priv->store,
 	                                                      foldername,
+	                                                      cancellable,
 	                                                      &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1107,21 +1176,24 @@ kolab_mail_imap_client_get_folder_type (KolabMailImapClient *self,
 static guint64
 kolab_mail_imap_client_get_folder_uidvalidity (KolabMailImapClient *self,
                                                const gchar *foldername,
+                                               GCancellable *cancellable,
                                                GError **err)
 {
-	KolabMailImapClientPrivate *priv = NULL;
+	/* KolabMailImapClientPrivate *priv = NULL; */
 	CamelFolder *folder = NULL;
 	guint64 uidvalidity = 0;
 	GError *tmp_err = NULL;
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, KOLAB_FOLDER_TYPE_INVAL);
 
-	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
+	/* priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self); */
 
 	folder = kolab_mail_imap_client_camel_get_folder (self,
 	                                                  foldername,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	if (folder == NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1149,6 +1221,7 @@ kolab_mail_imap_client_get_folder_uidvalidity (KolabMailImapClient *self,
 KolabFolderSummary*
 kolab_mail_imap_client_query_folder_summary (KolabMailImapClient *self,
                                              const gchar *foldername,
+                                             GCancellable *cancellable,
                                              GError **err)
 {
 	/* KolabMailImapClientPrivate *priv = NULL; */
@@ -1159,12 +1232,14 @@ kolab_mail_imap_client_query_folder_summary (KolabMailImapClient *self,
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	/* priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self); */
 
 	foldertype = kolab_mail_imap_client_get_folder_type (self,
 	                                                     foldername,
+	                                                     cancellable,
 	                                                     &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1173,6 +1248,7 @@ kolab_mail_imap_client_query_folder_summary (KolabMailImapClient *self,
 
 	uidvalidity = kolab_mail_imap_client_get_folder_uidvalidity (self,
 	                                                             foldername,
+	                                                             cancellable,
 	                                                             &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1198,18 +1274,25 @@ kolab_mail_imap_client_query_folder_summary (KolabMailImapClient *self,
 
 GList*
 kolab_mail_imap_client_query_foldernames_anon (gpointer self,
+                                               GCancellable *cancellable,
                                                GError **err)
 {
 	GList *list = NULL;
-	KolabMailImapClient *myself = KOLAB_MAIL_IMAP_CLIENT (self);
 
-	list = kolab_mail_imap_client_query_foldernames(myself, err);
+	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
+	/* cancellable may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+	list = kolab_mail_imap_client_query_foldernames(self,
+	                                                cancellable,
+	                                                err);
 	return list;
 }
 
 gboolean
 kolab_mail_imap_client_create_folder (KolabMailImapClient *self,
                                       const gchar *foldername,
+                                      GCancellable *cancellable,
                                       GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -1218,6 +1301,7 @@ kolab_mail_imap_client_create_folder (KolabMailImapClient *self,
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1228,6 +1312,7 @@ kolab_mail_imap_client_create_folder (KolabMailImapClient *self,
 	                                   NULL,
 	                                   foldername,
 	                                   TRUE,
+	                                   cancellable,
 	                                   &tmp_err);
 	if (! ok) {
 		g_propagate_error (err, tmp_err);
@@ -1240,12 +1325,14 @@ kolab_mail_imap_client_create_folder (KolabMailImapClient *self,
 gboolean
 kolab_mail_imap_client_delete_folder (KolabMailImapClient *self,
                                       const gchar *foldername,
+                                      GCancellable *cancellable,
                                       GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1260,12 +1347,14 @@ kolab_mail_imap_client_delete_folder (KolabMailImapClient *self,
 gboolean
 kolab_mail_imap_client_exists_folder (KolabMailImapClient *self,
                                       const gchar *foldername,
+                                      GCancellable *cancellable,
                                       GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
+	(void)cancellable; /* FIXME */ /* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1285,6 +1374,7 @@ kolab_mail_imap_client_query_summaries (KolabMailImapClient *self,
                                         const gchar *foldername,
                                         const gchar *sexp,
                                         gboolean update,
+                                        GCancellable *cancellable,
                                         GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -1297,6 +1387,7 @@ kolab_mail_imap_client_query_summaries (KolabMailImapClient *self,
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (foldername != NULL);
 	(void)sexp; /* TODO implement expression search */ /* sexp may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1306,6 +1397,7 @@ kolab_mail_imap_client_query_summaries (KolabMailImapClient *self,
 	/* get folder type and context */
 	foldertype = kolab_mail_imap_client_get_folder_type (self,
 	                                                     foldername,
+	                                                     cancellable,
 	                                                     &tmp_err);
 	if (foldertype == KOLAB_FOLDER_TYPE_INVAL) {
 		g_propagate_error (err, tmp_err);
@@ -1325,6 +1417,7 @@ kolab_mail_imap_client_query_summaries (KolabMailImapClient *self,
 	if (update) {
 		ok = kolab_mail_imap_client_update_folder (self,
 		                                           foldername,
+		                                           cancellable,
 		                                           &tmp_err);
 		if (! ok) {
 			g_propagate_error (err, tmp_err);
@@ -1337,6 +1430,7 @@ kolab_mail_imap_client_query_summaries (KolabMailImapClient *self,
 	                                                        foldername,
 	                                                        foldertype,
 	                                                        foldercontext,
+	                                                        cancellable,
 	                                                        &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1351,6 +1445,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
                               KolabMailHandle *kmailhandle,
                               const gchar *foldername,
                               gboolean update,
+                              GCancellable *cancellable,
                               GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -1413,6 +1508,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 	if (update) {
 		ok = kolab_mail_imap_client_update_folder (self,
 		                                           foldername,
+		                                           cancellable,
 		                                           &tmp_err);
 		if (! ok)
 			goto cleanup;
@@ -1421,6 +1517,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 	/* normal store operation (handle_foldername may be unset) */
 	folder = kolab_mail_imap_client_camel_get_folder (self,
 	                                                  foldername,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	if (tmp_err != NULL)
 		goto cleanup;
@@ -1446,6 +1543,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 		                                                              foldername,
 		                                                              imap_uid,
 		                                                              kolab_uid,
+		                                                              cancellable,
 		                                                              &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1459,6 +1557,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 		orig_message = kolab_mail_imap_client_camel_get_msg_kolab_uid (self,
 		                                                               foldername,
 		                                                               kolab_uid,
+		                                                               cancellable,
 		                                                               &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1472,6 +1571,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 	g_assert (kconvmail != NULL); /* must be ok since the handle is complete */
 	new_message = kolab_mail_mime_builder_camel_new_from_conv (priv->mimebuilder,
 	                                                           kconvmail,
+	                                                           cancellable,
 	                                                           &tmp_err);
 	if (new_message == NULL)
 		goto cleanup;
@@ -1493,11 +1593,12 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 		goto cleanup;
 
 	/* append the new message to the imap folder */
-	camel_folder_append_message (folder,
-	                             new_message,
-	                             NULL,
-	                             /* new IMAP UID never reported by IMAPX */ NULL,
-	                             &tmp_err);
+	camel_folder_append_message_sync (folder,
+	                                  new_message,
+	                                  NULL,
+	                                  /* new IMAP UID never reported by IMAPX */ NULL,
+	                                  cancellable,
+	                                  &tmp_err);
 
 	/* FIXME CamelIMAPX error reporting is not working in all cases
 	 *       - tmp_ex is not set here if the server rejects the message
@@ -1525,6 +1626,7 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 	stored_message = kolab_mail_imap_client_camel_get_msg_kolab_uid (self,
 	                                                                 foldername,
 	                                                                 kolab_uid,
+	                                                                 cancellable,
 	                                                                 &tmp_err);
 	if (tmp_err != NULL)
 		goto cleanup;
@@ -1572,12 +1674,17 @@ kolab_mail_imap_client_store (KolabMailImapClient *self,
 	}
 
 	/* update folder */
-	camel_folder_sync (folder, TRUE, &tmp_err);
+	camel_folder_synchronize_sync (folder,
+	                               TRUE,
+	                               cancellable,
+	                               &tmp_err);
 	if (tmp_err != NULL)
 		goto cleanup;
 
 	/* refresh folder info */
-	camel_folder_refresh_info (folder, &tmp_err);
+	camel_folder_refresh_info_sync (folder,
+	                                cancellable,
+	                                &tmp_err);
 	if (tmp_err != NULL)
 		goto cleanup;
 
@@ -1614,6 +1721,7 @@ gboolean
 kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
                                  KolabMailHandle *kmailhandle,
                                  gboolean update,
+                                 GCancellable *cancellable,
                                  GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -1632,6 +1740,7 @@ kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1664,6 +1773,7 @@ kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
 	/* folder type/context checking */
 	folder_type = kolab_mail_imap_client_get_folder_type (self,
 	                                                      foldername,
+	                                                      cancellable,
 	                                                      &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1691,6 +1801,7 @@ kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
 	if (update) {
 		ok = kolab_mail_imap_client_update_folder (self,
 		                                           foldername,
+		                                           cancellable,
 		                                           &tmp_err);
 		if (! ok) {
 			g_propagate_error (err, tmp_err);
@@ -1707,6 +1818,7 @@ kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
 		                                                               foldername,
 		                                                               imap_uid,
 		                                                               kolab_uid,
+		                                                               cancellable,
 		                                                               &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1720,6 +1832,7 @@ kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
 		camel_message = kolab_mail_imap_client_camel_get_msg_kolab_uid (self,
 		                                                                foldername,
 		                                                                kolab_uid,
+		                                                                cancellable,
 		                                                                &tmp_err);
 		if (tmp_err != NULL) {
 			g_propagate_error (err, tmp_err);
@@ -1738,6 +1851,7 @@ kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
 
 	kconvmail = kolab_mail_mime_builder_conv_new_from_camel (priv->mimebuilder,
 	                                                         camel_message,
+	                                                         cancellable,
 	                                                         &tmp_err);
 	g_object_unref (camel_message);
 
@@ -1770,6 +1884,7 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
                                KolabMailHandle *kmailhandle,
                                gboolean imapuid_only,
                                gboolean update,
+                               GCancellable *cancellable,
                                GError **err)
 {
 	KolabMailImapClientPrivate *priv = NULL;
@@ -1784,6 +1899,7 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 
 	g_assert (KOLAB_IS_MAIL_IMAP_CLIENT (self));
 	g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_IMAP_CLIENT_PRIVATE (self);
@@ -1814,6 +1930,7 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 	if (update) {
 		ok = kolab_mail_imap_client_update_folder (self,
 		                                           foldername,
+		                                           cancellable,
 		                                           &tmp_err);
 		if (! ok) {
 			g_propagate_error (err, tmp_err);
@@ -1824,6 +1941,7 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 	/* get the CamelFolder */
 	folder = kolab_mail_imap_client_camel_get_folder (self,
 	                                                  foldername,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1849,6 +1967,7 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 		                                                               foldername,
 		                                                               imap_uid,
 		                                                               kolab_uid,
+		                                                               cancellable,
 		                                                               &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1866,6 +1985,7 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 		camel_message = kolab_mail_imap_client_camel_get_msg_kolab_uid (self,
 		                                                                foldername,
 		                                                                kolab_uid,
+		                                                                cancellable,
 		                                                                &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s", __func__, tmp_err->message);
@@ -1879,14 +1999,19 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 	if (camel_message == NULL) {
 		g_warning ("%s: UID (%s) not found in folder (%s)",
 		           __func__, kolab_uid, foldername);
-		camel_folder_sync (folder, TRUE, &tmp_err);
+		camel_folder_synchronize_sync (folder,
+		                               TRUE,
+		                               cancellable,
+		                               &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s",
 			           __func__, tmp_err->message);
 			g_error_free (tmp_err);
 			tmp_err = NULL;
 		}
-		camel_folder_refresh_info (folder, &tmp_err);
+		camel_folder_refresh_info_sync (folder,
+		                                cancellable,
+		                                &tmp_err);
 		if (tmp_err != NULL) {
 			g_warning ("%s: %s",
 			           __func__, tmp_err->message);
@@ -1917,10 +2042,15 @@ kolab_mail_imap_client_delete (KolabMailImapClient *self,
 		g_warning ("%s: Kolab UID (%s) IMAP UID not set on camel message",
 		           __func__, kolab_uid);
 
-	camel_folder_sync (folder, TRUE, &tmp_err);
+	camel_folder_synchronize_sync (folder,
+	                               TRUE,
+	                               cancellable,
+	                               &tmp_err);
 	if (tmp_err != NULL)
 		goto cleanup;
-	camel_folder_refresh_info (folder, &tmp_err);
+	camel_folder_refresh_info_sync (folder,
+	                                cancellable,
+	                                &tmp_err);
 
  cleanup:
 	if (tmp_err != NULL) {
diff --git a/src/libekolab/kolab-mail-imap-client.h b/src/libekolab/kolab-mail-imap-client.h
index 506e890..a1afe7b 100644
--- a/src/libekolab/kolab-mail-imap-client.h
+++ b/src/libekolab/kolab-mail-imap-client.h
@@ -12,12 +12,12 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
@@ -32,7 +32,7 @@
  * @section_id:
  * @see_also: #CamelKolabIMAPXStore, #CamelKolabSession
  * @stability: unstable
- * 
+ *
  * This class is the Kolab2 mail access wrapper. It is
  * comprised of at least the following
  * <itemizedlist>
@@ -98,27 +98,104 @@ struct _KolabMailImapClient
 	GObject parent_instance;
 };
 
-GType kolab_mail_imap_client_get_type (void) G_GNUC_CONST;
-
-gboolean kolab_mail_imap_client_configure (KolabMailImapClient *self, KolabSettingsHandler *ksettings, KolabMailMimeBuilder *mimebuilder, GError **err);
-gboolean kolab_mail_imap_client_bringup (KolabMailImapClient *self, GError **err);
-gboolean kolab_mail_imap_client_shutdown (KolabMailImapClient *self, GError **err);
-
-gboolean kolab_mail_imap_client_go_online (KolabMailImapClient *self, GError **err);
-gboolean kolab_mail_imap_client_go_offline (KolabMailImapClient *self, GError **err);
-
-GList* kolab_mail_imap_client_query_foldernames (KolabMailImapClient *self, GError **err);
-GList* kolab_mail_imap_client_query_foldernames_anon (gpointer self, GError **err);
-KolabFolderTypeID kolab_mail_imap_client_get_folder_type (KolabMailImapClient *self, const gchar *foldername, GError **err);
-KolabFolderSummary* kolab_mail_imap_client_query_folder_summary (KolabMailImapClient *self, const gchar *foldername, GError **err);
-gboolean kolab_mail_imap_client_create_folder (KolabMailImapClient *self, const gchar *foldername, GError **err);
-gboolean kolab_mail_imap_client_delete_folder (KolabMailImapClient *self, const gchar *foldername, GError **err);
-gboolean kolab_mail_imap_client_exists_folder (KolabMailImapClient *self, const gchar *foldername, GError **err);
-
-GHashTable* kolab_mail_imap_client_query_summaries (KolabMailImapClient *self, const gchar* foldername, const gchar *sexp, gboolean update, GError **err);
-gboolean kolab_mail_imap_client_store (KolabMailImapClient *self, KolabMailHandle *kmailhandle, const gchar *foldername, gboolean update, GError **err);
-gboolean kolab_mail_imap_client_retrieve (KolabMailImapClient *self, KolabMailHandle *kmailhandle, gboolean update, GError **err);
-gboolean kolab_mail_imap_client_delete (KolabMailImapClient *self, KolabMailHandle *kmailhandle, gboolean imapuid_only, gboolean update, GError **err);
+GType
+kolab_mail_imap_client_get_type (void) G_GNUC_CONST;
+
+gboolean
+kolab_mail_imap_client_configure (KolabMailImapClient *self,
+                                  KolabSettingsHandler *ksettings,
+                                  KolabMailMimeBuilder *mimebuilder,
+                                  GError **err);
+
+gboolean
+kolab_mail_imap_client_bringup (KolabMailImapClient *self,
+                                GCancellable *cancellable,
+                                GError **err);
+
+gboolean
+kolab_mail_imap_client_shutdown (KolabMailImapClient *self,
+                                 GCancellable *cancellable,
+                                 GError **err);
+
+gboolean
+kolab_mail_imap_client_go_online (KolabMailImapClient *self,
+                                  GCancellable *cancellable,
+                                  GError **err);
+
+gboolean
+kolab_mail_imap_client_go_offline (KolabMailImapClient *self,
+                                   GCancellable *cancellable,
+                                   GError **err);
+
+GList*
+kolab_mail_imap_client_query_foldernames (KolabMailImapClient *self,
+                                          GCancellable *cancellable,
+                                          GError **err);
+
+GList*
+kolab_mail_imap_client_query_foldernames_anon (gpointer self,
+                                               GCancellable *cancellable,
+                                               GError **err);
+
+KolabFolderTypeID
+kolab_mail_imap_client_get_folder_type (KolabMailImapClient *self,
+                                        const gchar *foldername,
+                                        GCancellable *cancellable,
+                                        GError **err);
+
+KolabFolderSummary*
+kolab_mail_imap_client_query_folder_summary (KolabMailImapClient *self,
+                                             const gchar *foldername,
+                                             GCancellable *cancellable,
+                                             GError **err);
+
+gboolean
+kolab_mail_imap_client_create_folder (KolabMailImapClient *self,
+                                      const gchar *foldername,
+                                      GCancellable *cancellable,
+                                      GError **err);
+
+gboolean
+kolab_mail_imap_client_delete_folder (KolabMailImapClient *self,
+                                      const gchar *foldername,
+                                      GCancellable *cancellable,
+                                      GError **err);
+
+gboolean kolab_mail_imap_client_exists_folder (KolabMailImapClient *self,
+                                               const gchar *foldername,
+                                               GCancellable *cancellable,
+                                               GError **err);
+
+GHashTable*
+kolab_mail_imap_client_query_summaries (KolabMailImapClient *self,
+                                        const gchar* foldername,
+                                        const gchar *sexp,
+                                        gboolean update,
+                                        GCancellable *cancellable,
+                                        GError **err);
+
+gboolean
+kolab_mail_imap_client_store (KolabMailImapClient *self,
+                              KolabMailHandle *kmailhandle,
+                              const gchar *foldername,
+                              gboolean update,
+                              GCancellable *cancellable,
+                              GError **err);
+
+gboolean
+kolab_mail_imap_client_retrieve (KolabMailImapClient *self,
+                                 KolabMailHandle *kmailhandle,
+                                 gboolean update,
+                                 GCancellable *cancellable,
+                                 GError **err);
+
+gboolean
+kolab_mail_imap_client_delete (KolabMailImapClient *self,
+                               KolabMailHandle *kmailhandle,
+                               gboolean imapuid_only,
+                               gboolean update,
+                               GCancellable *cancellable,
+                               GError **err);
 
 G_END_DECLS
 
@@ -127,4 +204,3 @@ G_END_DECLS
 #endif /* _KOLAB_MAIL_IMAP_CLIENT_H_ */
 
 /*----------------------------------------------------------------------------*/
-
diff --git a/src/libekolab/kolab-mail-mime-builder.c b/src/libekolab/kolab-mail-mime-builder.c
index c2bdd91..6addd0b 100644
--- a/src/libekolab/kolab-mail-mime-builder.c
+++ b/src/libekolab/kolab-mail-mime-builder.c
@@ -198,6 +198,7 @@ kolab_mail_mime_builder_shutdown (KolabMailMimeBuilder *self,
 Kolab_conv_mail*
 kolab_mail_mime_builder_conv_new_from_camel (KolabMailMimeBuilder *self,
                                              const CamelMimeMessage *message,
+                                             GCancellable *cancellable,
                                              GError **err)
 {
 	KolabMailMimeBuilderPrivate *priv = NULL;
@@ -211,13 +212,14 @@ kolab_mail_mime_builder_conv_new_from_camel (KolabMailMimeBuilder *self,
 
 	g_assert (KOLAB_IS_MAIL_MIME_BUILDER (self));
 	g_assert (CAMEL_IS_MIME_MESSAGE (message));
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_MIME_BUILDER_PRIVATE (self);
 
 	g_assert (priv->is_up == TRUE);
 
-	data_wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (message));
+	data_wrapper = camel_medium_get_content (CAMEL_MEDIUM (message));
 	if (data_wrapper == NULL) {
 		g_set_error (err,
 		             KOLAB_BACKEND_ERROR,
@@ -273,7 +275,7 @@ kolab_mail_mime_builder_conv_new_from_camel (KolabMailMimeBuilder *self,
 		content_type = camel_mime_part_get_content_type (mimepart);
 		content_type_str = camel_content_type_simple (content_type);
 		name = camel_mime_part_get_filename (mimepart);
-		mpart_data_wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mimepart));
+		mpart_data_wrapper = camel_medium_get_content (CAMEL_MEDIUM (mimepart));
 
 		kconvmailpart = &(kconvmail->mail_parts[ii - 1]);
 
@@ -305,16 +307,12 @@ kolab_mail_mime_builder_conv_new_from_camel (KolabMailMimeBuilder *self,
 		memstream = CAMEL_STREAM_MEM (camel_stream_mem_new ());
 		buffer = g_byte_array_new ();
 		camel_stream_mem_set_byte_array (memstream, buffer);
-		stream_bytes = camel_data_wrapper_decode_to_stream (mpart_data_wrapper,
-		                                                    CAMEL_STREAM (memstream));
-		if (stream_bytes < 0) {
-			g_set_error (&tmp_err,
-			             KOLAB_BACKEND_ERROR,
-			             KOLAB_BACKEND_ERROR_CAMEL,
-			             "%s: failed to write to CamelMemStream",
-			             __func__);
+		stream_bytes = camel_data_wrapper_decode_to_stream_sync (mpart_data_wrapper,
+		                                                         CAMEL_STREAM (memstream),
+		                                                         cancellable,
+		                                                         &tmp_err);
+		if (stream_bytes < 0)
 			goto mime_part_cleanup;
-		}
 
 		kconvmailpart->name = g_strdup (name);
 		kconvmailpart->mime_type = g_strdup (content_type_str);
@@ -392,6 +390,7 @@ kolab_mail_mime_builder_new_zeroth_mime_part (KolabMailMimeBuilder *self)
 CamelMimeMessage*
 kolab_mail_mime_builder_camel_new_from_conv (KolabMailMimeBuilder *self,
                                              const Kolab_conv_mail *kconvmail,
+                                             GCancellable *cancellable,
                                              GError **err)
 {
 	KolabMailMimeBuilderPrivate *priv = NULL;
@@ -404,6 +403,7 @@ kolab_mail_mime_builder_camel_new_from_conv (KolabMailMimeBuilder *self,
 
 	g_assert (KOLAB_IS_MAIL_MIME_BUILDER (self));
 	g_assert (kconvmail != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_MIME_BUILDER_PRIVATE (self);
@@ -471,32 +471,24 @@ kolab_mail_mime_builder_camel_new_from_conv (KolabMailMimeBuilder *self,
 		memstream = CAMEL_STREAM_MEM (camel_stream_mem_new ());
 		stream_bytes = camel_stream_write (CAMEL_STREAM (memstream),
 		                                   kconvmailpart->data,
-		                                   kconvmailpart->length);
-		if (stream_bytes < 0) {
-			g_set_error (&tmp_err,
-			             KOLAB_BACKEND_ERROR,
-			             KOLAB_BACKEND_ERROR_CAMEL,
-			             "%s: failed to write to CamelMemStream",
-			             __func__);
+		                                   kconvmailpart->length,
+		                                   cancellable,
+		                                   &tmp_err);
+		if (stream_bytes < 0)
 			goto mime_part_skip;
-		}
 
 		data_wrapper = camel_data_wrapper_new ();
-		rval = camel_data_wrapper_construct_from_stream (data_wrapper,
-		                                                 CAMEL_STREAM (memstream));
-		if ((rval < 0) || (! CAMEL_IS_DATA_WRAPPER (data_wrapper))) {
-			g_set_error (&tmp_err,
-			             KOLAB_BACKEND_ERROR,
-			             KOLAB_BACKEND_ERROR_CAMEL,
-			             "%s: failed to create CamelDataWrapper",
-			             __func__);
+		rval = camel_data_wrapper_construct_from_stream_sync (data_wrapper,
+		                                                      CAMEL_STREAM (memstream),
+		                                                      cancellable,
+		                                                      &tmp_err);
+		if ((rval < 0) || (! CAMEL_IS_DATA_WRAPPER (data_wrapper)))
 			goto mime_part_skip;
-		}
 
 		/* create new mimepart */
 		mimepart = camel_mime_part_new ();
-		camel_medium_set_content_object (CAMEL_MEDIUM (mimepart),
-		                                 data_wrapper);
+		camel_medium_set_content (CAMEL_MEDIUM (mimepart),
+		                          data_wrapper);
 
 		camel_mime_part_set_filename (mimepart,
 		                              kconvmailpart->name);
@@ -534,8 +526,8 @@ kolab_mail_mime_builder_camel_new_from_conv (KolabMailMimeBuilder *self,
 	}
 
 	message = camel_mime_message_new ();
-	camel_medium_set_content_object (CAMEL_MEDIUM (message),
-	                                 CAMEL_DATA_WRAPPER (multipart));
+	camel_medium_set_content (CAMEL_MEDIUM (message),
+	                          CAMEL_DATA_WRAPPER (multipart));
 	camel_mime_message_encode_8bit_parts (message);
 	if (msg_mimetype != NULL) {
 		camel_medium_set_header (CAMEL_MEDIUM (message),
diff --git a/src/libekolab/kolab-mail-mime-builder.h b/src/libekolab/kolab-mail-mime-builder.h
index 1564f87..0594d2e 100644
--- a/src/libekolab/kolab-mail-mime-builder.h
+++ b/src/libekolab/kolab-mail-mime-builder.h
@@ -12,17 +12,17 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
  */
- 
+
 /*----------------------------------------------------------------------------*/
 
 /**
@@ -32,7 +32,7 @@
  * @section_id:
  * @see_also: #KolabMailAccess, #KolabMailSynchronizer, #KolabMailImapClient, #KolabMailSideCache
  * @stability: unstable
- * 
+ *
  * This class constructs MIME messages (or message parts) from #Kolab_conv_mail
  * data and vice versa. It also contains facility for data checksumming.
  *
@@ -100,15 +100,39 @@ struct _KolabMailMimeBuilder
 	GObject parent_instance;
 };
 
-GType kolab_mail_mime_builder_get_type (void) G_GNUC_CONST;
-
-gboolean kolab_mail_mime_builder_configure (KolabMailMimeBuilder *self, KolabSettingsHandler *ksettings, GError **err);
-gboolean kolab_mail_mime_builder_bringup (KolabMailMimeBuilder *self, GError **err);
-gboolean kolab_mail_mime_builder_shutdown (KolabMailMimeBuilder *self, GError **err);
-
-Kolab_conv_mail* kolab_mail_mime_builder_conv_new_from_camel (KolabMailMimeBuilder *self, const CamelMimeMessage *message, GError **err);
-CamelMimeMessage* kolab_mail_mime_builder_camel_new_from_conv (KolabMailMimeBuilder *self, const Kolab_conv_mail *kconvmail, GError **err);
-gboolean kolab_mail_mime_builder_camel_set_header (KolabMailMimeBuilder *self, CamelMimeMessage *message, const KolabMailMimeBuilderHeaderInfo *headerinfo, CamelMimeMessage *orig_message, GError **err);
+GType
+kolab_mail_mime_builder_get_type (void) G_GNUC_CONST;
+
+gboolean
+kolab_mail_mime_builder_configure (KolabMailMimeBuilder *self,
+                                   KolabSettingsHandler *ksettings,
+                                   GError **err);
+
+gboolean
+kolab_mail_mime_builder_bringup (KolabMailMimeBuilder *self,
+                                 GError **err);
+
+gboolean
+kolab_mail_mime_builder_shutdown (KolabMailMimeBuilder *self,
+                                  GError **err);
+
+Kolab_conv_mail*
+kolab_mail_mime_builder_conv_new_from_camel (KolabMailMimeBuilder *self,
+                                             const CamelMimeMessage *message,
+                                             GCancellable *cancellable,
+                                             GError **err);
+
+CamelMimeMessage*
+kolab_mail_mime_builder_camel_new_from_conv (KolabMailMimeBuilder *self,
+                                             const Kolab_conv_mail *kconvmail,
+                                             GCancellable *cancellable,
+                                             GError **err);
+
+gboolean
+kolab_mail_mime_builder_camel_set_header (KolabMailMimeBuilder *self,
+                                          CamelMimeMessage *message,
+                                          const KolabMailMimeBuilderHeaderInfo *headerinfo,
+                                          CamelMimeMessage *orig_message, GError **err);
 
 G_END_DECLS
 
diff --git a/src/libekolab/kolab-mail-synchronizer.c b/src/libekolab/kolab-mail-synchronizer.c
index 5caa1fa..05869ae 100644
--- a/src/libekolab/kolab-mail-synchronizer.c
+++ b/src/libekolab/kolab-mail-synchronizer.c
@@ -159,6 +159,7 @@ static KolabFolderTypeID
 kolab_mail_synchronizer_get_foldertype (KolabMailSynchronizer *self,
                                         const gchar *info_fn,
                                         const gchar *imap_fn,
+                                        GCancellable *cancellable,
                                         GError **err)
 
 {
@@ -173,6 +174,7 @@ kolab_mail_synchronizer_get_foldertype (KolabMailSynchronizer *self,
 	g_assert (KOLAB_IS_MAIL_SYNCHRONIZER (self));
 	/* info_fn may be NULL */
 	/* imap_fn may be NULL */
+	/* cancellable may be NULL */
 	if ((info_fn != NULL) && (imap_fn != NULL))
 		g_assert (g_strcmp0 (info_fn, imap_fn) == 0);
 	g_return_val_if_fail (err == NULL || *err == NULL, KOLAB_FOLDER_TYPE_INVAL);
@@ -193,6 +195,7 @@ kolab_mail_synchronizer_get_foldertype (KolabMailSynchronizer *self,
 	if (imap_fn != NULL)
 		imap_summary = kolab_mail_imap_client_query_folder_summary (priv->client,
 		                                                            imap_fn,
+		                                                            cancellable,
 		                                                            &tmp_err);
 	if (tmp_err != NULL) {
 		if (tmp_err->code != KOLAB_BACKEND_ERROR_NOTFOUND)
@@ -387,6 +390,7 @@ kolab_mail_synchronizer_folders_update_summary (KolabMailSynchronizer *self,
                                                 const gchar *info_fn,
                                                 const gchar *imap_fn,
                                                 const gchar *side_fn,
+                                                GCancellable *cancellable,
                                                 GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -406,6 +410,7 @@ kolab_mail_synchronizer_folders_update_summary (KolabMailSynchronizer *self,
 	/* info_fn may be NULL */
 	/* imap_fn may be NULL */
 	/* side_fn may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -470,6 +475,7 @@ kolab_mail_synchronizer_folders_update_summary (KolabMailSynchronizer *self,
 	folder_type = kolab_mail_synchronizer_get_foldertype (self,
 	                                                      info_fn,
 	                                                      imap_fn,
+	                                                      cancellable,
 	                                                      &tmp_err);
 	if (folder_type == KOLAB_FOLDER_TYPE_INVAL) {
 		g_propagate_error (err, tmp_err);
@@ -566,6 +572,7 @@ kolab_mail_synchronizer_folders_update_walk (KolabMailSynchronizer *self,
                                              GList *folders_lst,
                                              GHashTable *imap_folders_tbl,
                                              GHashTable *side_folders_tbl,
+                                             GCancellable *cancellable,
                                              GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -578,6 +585,7 @@ kolab_mail_synchronizer_folders_update_walk (KolabMailSynchronizer *self,
 	/* folders_lst may be NULL      */
 	/* imap_folders_tbl may be NULL */
 	/* side_folders_tbl may be NULL */
+	/* cancellable may be NULL      */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -625,6 +633,7 @@ kolab_mail_synchronizer_folders_update_walk (KolabMailSynchronizer *self,
 		                                                     info_fn,
 		                                                     imap_fn,
 		                                                     side_fn,
+		                                                     cancellable,
 		                                                     &tmp_err);
 		if (! ok) {
 			g_propagate_error (err, tmp_err);
@@ -657,6 +666,7 @@ kolab_mail_synchronizer_folders_update_walk (KolabMailSynchronizer *self,
 static gboolean
 kolab_mail_synchronizer_folders_update_infodb (KolabMailSynchronizer *self,
                                                KolabMailAccessOpmodeID opmode,
+                                               GCancellable *cancellable,
                                                GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -669,12 +679,14 @@ kolab_mail_synchronizer_folders_update_infodb (KolabMailSynchronizer *self,
 
 	g_assert (KOLAB_IS_MAIL_SYNCHRONIZER (self));
 	g_assert (opmode < KOLAB_MAIL_ACCESS_LAST_OPMODE);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
 
 	/* get ImapClient folders */
 	tmp_lst = kolab_mail_imap_client_query_foldernames (priv->client,
+	                                                    cancellable,
 	                                                    &tmp_err);
 	if (tmp_err != NULL)
 		goto skip;
@@ -704,6 +716,7 @@ kolab_mail_synchronizer_folders_update_infodb (KolabMailSynchronizer *self,
 	                                                  info_folders_lst,
 	                                                  imap_folders_tbl,
 	                                                  side_folders_tbl,
+	                                                  cancellable,
 	                                                  &tmp_err);
 	kolab_util_glib_glist_free (info_folders_lst);
 	info_folders_lst = NULL;
@@ -719,6 +732,7 @@ kolab_mail_synchronizer_folders_update_infodb (KolabMailSynchronizer *self,
 		                                                  tmp_lst,
 		                                                  imap_folders_tbl,
 		                                                  side_folders_tbl,
+		                                                  cancellable,
 		                                                  &tmp_err);
 		g_list_free (tmp_lst);
 		tmp_lst = NULL;
@@ -735,6 +749,7 @@ kolab_mail_synchronizer_folders_update_infodb (KolabMailSynchronizer *self,
 		                                                  tmp_lst,
 		                                                  imap_folders_tbl,
 		                                                  side_folders_tbl,
+		                                                  cancellable,
 		                                                  &tmp_err);
 		g_list_free (tmp_lst);
 		tmp_lst = NULL;
@@ -1108,6 +1123,7 @@ static gboolean
 kolab_mail_synchronizer_uids_update_infodb (KolabMailSynchronizer *self,
                                             KolabMailAccessOpmodeID opmode,
                                             const gchar *foldername,
+                                            GCancellable *cancellable,
                                             GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -1118,6 +1134,7 @@ kolab_mail_synchronizer_uids_update_infodb (KolabMailSynchronizer *self,
 	g_assert (KOLAB_IS_MAIL_SYNCHRONIZER (self));
 	g_assert (opmode < KOLAB_MAIL_ACCESS_LAST_OPMODE);
 	/* foldername may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -1171,6 +1188,7 @@ kolab_mail_synchronizer_uids_update_infodb (KolabMailSynchronizer *self,
 		                                                             foldername,
 		                                                             NULL,
 		                                                             TRUE, /* do folder update */
+		                                                             cancellable,
 		                                                             &tmp_err);
 		if (tmp_err != NULL)
 			goto folder_skip;
@@ -1448,6 +1466,7 @@ kolab_mail_synchronizer_handle_new_from_record (KolabMailSynchronizer *self,
 static gboolean
 kolab_mail_synchronizer_push_sidecache (KolabMailSynchronizer *self,
                                         const gchar *foldername,
+                                        GCancellable *cancellable,
                                         GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -1458,6 +1477,7 @@ kolab_mail_synchronizer_push_sidecache (KolabMailSynchronizer *self,
 
 	g_assert (KOLAB_IS_MAIL_SYNCHRONIZER (self));
 	g_assert (foldername != NULL);
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -1481,6 +1501,7 @@ kolab_mail_synchronizer_push_sidecache (KolabMailSynchronizer *self,
 	                                                         foldername,
 	                                                         NULL,
 	                                                         FALSE, /* update folder done in infosync */
+	                                                         cancellable,
 	                                                         &tmp_err);
 	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
@@ -1562,6 +1583,7 @@ kolab_mail_synchronizer_push_sidecache (KolabMailSynchronizer *self,
 		                                                      foldername,
 		                                                      imap_summaries,
 		                                                      &record,
+		                                                      cancellable,
 		                                                      &tmp_err);
 		if (tmp_err != NULL)
 			goto uid_cleanup;
@@ -1593,6 +1615,7 @@ kolab_mail_synchronizer_push_sidecache (KolabMailSynchronizer *self,
 					                                    kmailhandle,
 					                                    TRUE, /* try only IMAP UID */
 					                                    FALSE, /* folder already updated */
+					                                    cancellable,
 					                                    &tmp_err);
 				} else {
 					ok = TRUE;
@@ -1602,6 +1625,7 @@ kolab_mail_synchronizer_push_sidecache (KolabMailSynchronizer *self,
 				                                   kmailhandle,
 				                                   foldername,
 				                                   FALSE, /* folder already updated */
+				                                   cancellable,
 				                                   &tmp_err);
 			}
 		} else {
@@ -1790,6 +1814,7 @@ kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
                                              const gchar *foldername,
                                              GHashTable *imap_summaries,
                                              KolabMailInfoDbRecord **record,
+                                             GCancellable *cancellable,
                                              GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -1830,6 +1855,7 @@ kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
 		g_assert (KOLAB_IS_MAIL_HANDLE (kmailhandle));
 	g_assert (foldername != NULL);
 	/* imap_summaries may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -2075,6 +2101,7 @@ kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
 		ok = kolab_mail_imap_client_retrieve (priv->client,
 		                                      kmh_srv,
 		                                      FALSE, /* folder needs to be uptodate already */
+		                                      cancellable,
 		                                      &tmp_err);
 		if (! ok) {
 			if (tmp_err->code == KOLAB_BACKEND_ERROR_NOTFOUND) {
@@ -2430,6 +2457,7 @@ gboolean
 kolab_mail_synchronizer_info_sync (KolabMailSynchronizer *self,
                                    KolabMailAccessOpmodeID opmode,
                                    const gchar *foldername,
+                                   GCancellable *cancellable,
                                    GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -2443,6 +2471,7 @@ kolab_mail_synchronizer_info_sync (KolabMailSynchronizer *self,
 	g_assert ((opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED) &&
 	          (opmode < KOLAB_MAIL_ACCESS_LAST_OPMODE));
 	/* foldername may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -2457,6 +2486,7 @@ kolab_mail_synchronizer_info_sync (KolabMailSynchronizer *self,
 	}
 	ok = kolab_mail_synchronizer_folders_update_infodb (self,
 	                                                    opmode,
+	                                                    cancellable,
 	                                                    &tmp_err);
 	if (! ok) {
 		ok = kolab_mail_info_db_transaction_abort (priv->infodb, &tmp_err_2);
@@ -2504,6 +2534,7 @@ kolab_mail_synchronizer_info_sync (KolabMailSynchronizer *self,
 		ok = kolab_mail_synchronizer_uids_update_infodb (self,
 		                                                 opmode,
 		                                                 fn,
+		                                                 cancellable,
 		                                                 &tmp_err);
 		if (! ok)
 			break;
@@ -2539,6 +2570,7 @@ gboolean
 kolab_mail_synchronizer_full_sync (KolabMailSynchronizer *self,
                                    KolabMailAccessOpmodeID opmode,
                                    const gchar *foldername,
+                                   GCancellable *cancellable,
                                    GError **err)
 {
 	KolabMailSynchronizerPrivate *priv = NULL;
@@ -2555,6 +2587,7 @@ kolab_mail_synchronizer_full_sync (KolabMailSynchronizer *self,
 	g_assert ((opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED) &&
 	          (opmode < KOLAB_MAIL_ACCESS_LAST_OPMODE));
 	/* foldername may be NULL */
+	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_SYNCHRONIZER_PRIVATE (self);
@@ -2582,7 +2615,10 @@ kolab_mail_synchronizer_full_sync (KolabMailSynchronizer *self,
 	folders_lst_ptr = folders_lst;
 	while (folders_lst_ptr != NULL) {
 		gchar *fn = (gchar *)(folders_lst_ptr->data);
-		ok = kolab_mail_synchronizer_push_sidecache (self, fn, &tmp_err);
+		ok = kolab_mail_synchronizer_push_sidecache (self,
+		                                             fn,
+		                                             cancellable,
+		                                             &tmp_err);
 		if (! ok) {
 			g_warning ("%s: %s", __func__, tmp_err->message);
 			g_error_free (tmp_err);
diff --git a/src/libekolab/kolab-mail-synchronizer.h b/src/libekolab/kolab-mail-synchronizer.h
index bc9ce07..74ac575 100644
--- a/src/libekolab/kolab-mail-synchronizer.h
+++ b/src/libekolab/kolab-mail-synchronizer.h
@@ -12,12 +12,12 @@
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
@@ -108,27 +108,27 @@
  *                |            | overwritten, delete UID data on server,
  *                |            | push new UID data (new email). Re-fetch
  *                |            | data to get it into IMAPX cache
- *                |            | 
+ *                |            |
  *                |            | InfoDb: unset SideCache location bit
  *      -----------------------+------------------------------------------------
  *      X         |            | PIM object was created in offline mode
- *                |            | 
+ *                |            |
  *                |            | SideCache: after sync success, delete UID
  *                |            |
  *                |            | ImapClient: Re-fetch data to get it
  *                |            | into IMAPX cache
- *                |            | 
+ *                |            |
  *                |            | InfoDb: unset SideCache location bit
  *      -----------------------+------------------------------------------------
  *                |            | New PIM object was created on the server
  *                |            | and has not yet been fetched into IMAPX
  *                |            | offline store
- *                |            | 
+ *                |            |
  *                |            | SideCache: none
- *                |            | 
+ *                |            |
  *                |            | ImapClient: Fetch data to get it
  *                |            | into IMAPX cache
- *                |            | 
+ *                |            |
  *                |            | InfoDb: set ImapClient cache location bit
  *      -----------------------+------------------------------------------------
  * ]|
@@ -187,15 +187,22 @@ typedef enum {
 
 GType kolab_mail_synchronizer_get_type (void) G_GNUC_CONST;
 
-gboolean kolab_mail_synchronizer_configure (KolabMailSynchronizer *self,
-                                            KolabSettingsHandler *ksettings,
-                                            KolabMailImapClient *client,
-                                            KolabMailInfoDb *infodb,
-                                            KolabMailSideCache *sidecache,
-                                            KolabMailMimeBuilder *mimebuilder,
-                                            GError **err);
-gboolean kolab_mail_synchronizer_bringup (KolabMailSynchronizer *self, GError **err);
-gboolean kolab_mail_synchronizer_shutdown (KolabMailSynchronizer *self, GError **err);
+gboolean
+kolab_mail_synchronizer_configure (KolabMailSynchronizer *self,
+                                   KolabSettingsHandler *ksettings,
+                                   KolabMailImapClient *client,
+                                   KolabMailInfoDb *infodb,
+                                   KolabMailSideCache *sidecache,
+                                   KolabMailMimeBuilder *mimebuilder,
+                                   GError **err);
+
+gboolean
+kolab_mail_synchronizer_bringup (KolabMailSynchronizer *self,
+                                 GError **err);
+
+gboolean
+kolab_mail_synchronizer_shutdown (KolabMailSynchronizer *self,
+                                  GError **err);
 
 KolabMailHandle*
 kolab_mail_synchronizer_handle_new_from_infodb (KolabMailSynchronizer *self,
@@ -203,45 +210,54 @@ kolab_mail_synchronizer_handle_new_from_infodb (KolabMailSynchronizer *self,
                                                 const gchar *foldername,
                                                 GError **err);
 
-gboolean kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
-                                                      KolabMailAccessOpmodeID opmode,
-                                                      KolabMailSynchronizerTransactionTypeID ttid,
-                                                      KolabMailHandle *kmailhandle,
-                                                      const gchar *foldername,
-                                                      GHashTable *imap_summaries,
-                                                      KolabMailInfoDbRecord **record,
-                                                      GError **err);
-gboolean kolab_mail_synchronizer_transaction_start (KolabMailSynchronizer *self,
-                                                    KolabMailAccessOpmodeID opmode,
-                                                    KolabMailSynchronizerTransactionTypeID ttid,
-                                                    KolabMailHandle *kmailhandle,
-                                                    const gchar *foldername,
-                                                    KolabMailInfoDbRecord *record,
-                                                    GError **err);
-gboolean kolab_mail_synchronizer_transaction_abort (KolabMailSynchronizer *self,
-                                                    KolabMailAccessOpmodeID opmode,
-                                                    KolabMailSynchronizerTransactionTypeID ttid,
-                                                    KolabMailHandle *kmailhandle,
-                                                    const gchar *foldername,
-                                                    KolabMailInfoDbRecord *record,
-                                                    GError **err);
-gboolean kolab_mail_synchronizer_transaction_commit (KolabMailSynchronizer *self,
-                                                     KolabMailAccessOpmodeID opmode,
-                                                     KolabMailSynchronizerTransactionTypeID ttid,
-                                                     KolabMailHandle *kmailhandle,
-                                                     const gchar *foldername,
-                                                     KolabMailInfoDbRecord *record,
-                                                     GError **err);
-
-gboolean kolab_mail_synchronizer_info_sync (KolabMailSynchronizer *self,
-                                            KolabMailAccessOpmodeID opmode,
-                                            const gchar *foldername,
-                                            GError **err);
-gboolean kolab_mail_synchronizer_full_sync (KolabMailSynchronizer *self,
+gboolean
+kolab_mail_synchronizer_transaction_prepare (KolabMailSynchronizer *self,
+                                             KolabMailAccessOpmodeID opmode,
+                                             KolabMailSynchronizerTransactionTypeID ttid,
+                                             KolabMailHandle *kmailhandle,
+                                             const gchar *foldername,
+                                             GHashTable *imap_summaries,
+                                             KolabMailInfoDbRecord **record,
+                                             GCancellable *cancellable,
+                                             GError **err);
+gboolean
+kolab_mail_synchronizer_transaction_start (KolabMailSynchronizer *self,
+                                           KolabMailAccessOpmodeID opmode,
+                                           KolabMailSynchronizerTransactionTypeID ttid,
+                                           KolabMailHandle *kmailhandle,
+                                           const gchar *foldername,
+                                           KolabMailInfoDbRecord *record,
+                                           GError **err);
+gboolean
+kolab_mail_synchronizer_transaction_abort (KolabMailSynchronizer *self,
+                                           KolabMailAccessOpmodeID opmode,
+                                           KolabMailSynchronizerTransactionTypeID ttid,
+                                           KolabMailHandle *kmailhandle,
+                                           const gchar *foldername,
+                                           KolabMailInfoDbRecord *record,
+                                           GError **err);
+gboolean
+kolab_mail_synchronizer_transaction_commit (KolabMailSynchronizer *self,
                                             KolabMailAccessOpmodeID opmode,
+                                            KolabMailSynchronizerTransactionTypeID ttid,
+                                            KolabMailHandle *kmailhandle,
                                             const gchar *foldername,
+                                            KolabMailInfoDbRecord *record,
                                             GError **err);
 
+gboolean
+kolab_mail_synchronizer_info_sync (KolabMailSynchronizer *self,
+                                   KolabMailAccessOpmodeID opmode,
+                                   const gchar *foldername,
+                                   GCancellable *cancellable,
+                                   GError **err);
+gboolean
+kolab_mail_synchronizer_full_sync (KolabMailSynchronizer *self,
+                                   KolabMailAccessOpmodeID opmode,
+                                   const gchar *foldername,
+                                   GCancellable *cancellable,
+                                   GError **err);
+
 G_END_DECLS
 
 /*----------------------------------------------------------------------------*/



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