[evolution-kolab/ek-wip-porting] KolabMailAccess: moved API function opmode checking inside big_lock sentinel



commit 621a777ffdcbd811a484442d6c5ebacfd4c4fe0f
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Mar 20 18:17:01 2012 +0100

    KolabMailAccess: moved API function opmode checking inside big_lock sentinel

 src/libekolab/kolab-mail-access.c |   41 +++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/libekolab/kolab-mail-access.c b/src/libekolab/kolab-mail-access.c
index fc4de9f..c644893 100644
--- a/src/libekolab/kolab-mail-access.c
+++ b/src/libekolab/kolab-mail-access.c
@@ -1984,10 +1984,12 @@ kolab_mail_access_query_uids (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	foldername = kolab_mail_access_foldername_new_from_sourcename (self,
 	                                                               sourcename,
 	                                                               &tmp_err);
@@ -2064,10 +2066,12 @@ kolab_mail_access_query_changed_uids (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	foldername = kolab_mail_access_foldername_new_from_sourcename (self,
 	                                                               sourcename,
 	                                                               &tmp_err);
@@ -2161,10 +2165,12 @@ kolab_mail_access_get_handle (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* map Evo calendar name to Kolab folder name */
 	foldername = kolab_mail_access_foldername_new_from_sourcename (self,
 	                                                               sourcename,
@@ -2310,10 +2316,12 @@ kolab_mail_access_store_handle (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* folder check */
 
 	/* sourcename data */
@@ -2443,10 +2451,12 @@ kolab_mail_access_retrieve_handle (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* lookup mail handle in local databases */
 	local_handle = kolab_mail_access_local_handle_get (self,
 	                                                   kmailhandle,
@@ -2601,10 +2611,12 @@ kolab_mail_access_delete_handle (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* lookup mail handle in local databases */
 	local_handle = kolab_mail_access_local_handle_get (self,
 	                                                   kmailhandle,
@@ -2698,10 +2710,12 @@ kolab_mail_access_delete_by_uid (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	foldername = kolab_mail_access_foldername_new_from_sourcename (self,
 	                                                               sourcename,
 	                                                               &tmp_err);
@@ -2794,10 +2808,12 @@ kolab_mail_access_query_sources (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* query KolabMailInfoDb for existing foldernames in current context */
 	folders = kolab_mail_info_db_query_foldernames (priv->infodb,
 	                                                &tmp_err);
@@ -2890,10 +2906,12 @@ kolab_mail_access_create_source (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* map Evo sourcename to Kolab foldername */
 	foldername = kolab_util_backend_foldername_new_from_sourcename (sourcename,
 	                                                                &tmp_err);
@@ -2978,10 +2996,12 @@ kolab_mail_access_delete_source (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 
+	if (priv->state->opmode <= KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED)
+		goto exit;
+
 	/* map Evo sourcename to Kolab foldername */
 	foldername = kolab_util_backend_foldername_new_from_sourcename (sourcename,
 	                                                                &tmp_err);
@@ -3057,7 +3077,6 @@ kolab_mail_access_source_fbtrigger_needed (KolabMailAccess *self,
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
 	priv = KOLAB_MAIL_ACCESS_PRIVATE (self);
-	g_assert (priv->state->opmode > KOLAB_MAIL_ACCESS_OPMODE_CONFIGURED);
 
 	g_mutex_lock (priv->big_lock);
 



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