Blob Blame History Raw
--- evolution-data-server-1.11.2/addressbook/backends/file/e-book-backend-file.c.e-flag	2007-05-13 13:39:43.000000000 -0400
+++ evolution-data-server-1.11.2/addressbook/backends/file/e-book-backend-file.c	2007-05-18 11:13:41.000000000 -0400
@@ -43,6 +43,7 @@
 #include "libedataserver/e-dbhash.h"
 #include "libedataserver/e-db3-utils.h"
 #include "libedataserver/e-data-server-util.h"
+#include "libedataserver/e-flag.h"
 
 #include "libebook/e-contact.h"
 
@@ -497,18 +498,15 @@
 
 typedef struct {
 	EBookBackendFile *bf;
-	GMutex *mutex;
-	GCond *cond;
 	GThread *thread;
-	gboolean stopped;
+	EFlag *running;
 } FileBackendSearchClosure;
 
 static void
 closure_destroy (FileBackendSearchClosure *closure)
 {
 	d(printf ("destroying search closure\n"));
-	g_mutex_free (closure->mutex);
-	g_cond_free (closure->cond);
+	e_flag_free (closure->running);
 	g_free (closure);
 }
 
@@ -518,10 +516,8 @@
 	FileBackendSearchClosure *closure = g_new (FileBackendSearchClosure, 1);
 
 	closure->bf = bf;
-	closure->mutex = g_mutex_new ();
-	closure->cond = g_cond_new ();
 	closure->thread = NULL;
-	closure->stopped = FALSE;
+	closure->running = e_flag_new ();
 
 	g_object_set_data_full (G_OBJECT (book_view), "EBookBackendFile.BookView::closure",
 				closure, (GDestroyNotify)closure_destroy);
@@ -545,7 +541,7 @@
 	DB  *db;
 	DBT id_dbt, vcard_dbt;
 	int db_error;
-	gboolean stopped = FALSE, allcontacts;
+	gboolean allcontacts;
 
 	d(printf ("starting initial population of book view\n"));
 
@@ -565,9 +561,7 @@
 	}
 
 	d(printf ("signalling parent thread\n"));
-	g_mutex_lock (closure->mutex);
-	g_cond_signal (closure->cond);
-	g_mutex_unlock (closure->mutex);
+	e_flag_set (closure->running);
 
 	if (e_book_backend_summary_is_summary_query (bf->priv->summary, query)) {
 		/* do a summary query */
@@ -576,11 +570,8 @@
 
 		for (i = 0; i < ids->len; i ++) {
 			char *id = g_ptr_array_index (ids, i);
-			g_mutex_lock (closure->mutex);
-			stopped = closure->stopped;
-			g_mutex_unlock (closure->mutex);
 
-			if (stopped)
+			if (!e_flag_is_set (closure->running))
 				break;
 
 			string_to_dbt (id, &id_dbt);
@@ -613,11 +604,7 @@
 			db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST);
 			while (db_error == 0) {
 
-				g_mutex_lock (closure->mutex);
-				stopped = closure->stopped;
-				g_mutex_unlock (closure->mutex);
-
-				if (stopped)
+				if (!e_flag_is_set (closure->running))
 					break;
 
 				/* don't include the version in the list of cards */
@@ -647,7 +634,7 @@
 
 	}
 
-	if (!stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 
 	/* unref the */
@@ -665,15 +652,12 @@
 {
 	FileBackendSearchClosure *closure = init_closure (book_view, E_BOOK_BACKEND_FILE (backend));
 
-	g_mutex_lock (closure->mutex);
-
 	d(printf ("starting book view thread\n"));
 	closure->thread = g_thread_create (book_view_thread, book_view, TRUE, NULL);
 
-	g_cond_wait (closure->cond, closure->mutex);
+	e_flag_wait (closure->running);
 
 	/* at this point we know the book view thread is actually running */
-	g_mutex_unlock (closure->mutex);
 	d(printf ("returning from start_book_view\n"));
 }
 
@@ -682,14 +666,11 @@
 				    EDataBookView *book_view)
 {
 	FileBackendSearchClosure *closure = get_closure (book_view);
-	gboolean need_join = FALSE;
+	gboolean need_join;
 
 	d(printf ("stopping query\n"));
-	g_mutex_lock (closure->mutex);
-	if (!closure->stopped)
-		need_join = TRUE;
-	closure->stopped = TRUE;
-	g_mutex_unlock (closure->mutex);
+	need_join = e_flag_is_set (closure->running);
+	e_flag_clear (closure->running);
 
 	if (need_join)
 		g_thread_join (closure->thread);
--- evolution-data-server-1.11.2/addressbook/backends/groupwise/e-book-backend-groupwise.c.e-flag	2007-04-18 06:10:20.000000000 -0400
+++ evolution-data-server-1.11.2/addressbook/backends/groupwise/e-book-backend-groupwise.c	2007-05-18 11:15:53.000000000 -0400
@@ -40,6 +40,7 @@
 #include "libedataserver/e-sexp.h"
 #include "libedataserver/e-data-server-util.h"
 #include "libedataserver/e-db3-utils.h"
+#include "libedataserver/e-flag.h"
 #include "libedataserver/e-url.h" 
 #include "libebook/e-contact.h"
 #include "libedata-book/e-book-backend-sexp.h"
@@ -2071,17 +2072,14 @@
 	
 typedef struct {
 	EBookBackendGroupwise *bg;
-	GMutex *mutex;
-	GCond *cond;
 	GThread *thread;
-	gboolean stopped;
+	EFlag *running;
 } GroupwiseBackendSearchClosure;
 
 static void
 closure_destroy (GroupwiseBackendSearchClosure *closure)
 {
-	g_mutex_free (closure->mutex);
-	g_cond_free (closure->cond);
+	e_flag_free (closure->running);
 	g_free (closure);
 }
 
@@ -2091,10 +2089,8 @@
 	GroupwiseBackendSearchClosure *closure = g_new (GroupwiseBackendSearchClosure, 1);
 
 	closure->bg = bg;
-	closure->mutex = g_mutex_new ();
-	closure->cond = g_cond_new ();
 	closure->thread = NULL;
-	closure->stopped = FALSE;
+	closure->running = e_flag_new ();
 
 	g_object_set_data_full (G_OBJECT (book_view), "EBookBackendGroupwise.BookView::closure",
 				closure, (GDestroyNotify)closure_destroy);
@@ -2116,7 +2112,6 @@
 			 GroupwiseBackendSearchClosure *closure)
 {
 	int i;
-	gboolean stopped = FALSE;
 
 	if (enable_debug)
 		printf ("\nread contacts from cache for the ids found in summary\n");
@@ -2124,12 +2119,8 @@
 		char *uid;
 		EContact *contact; 
 
-		g_mutex_lock (closure->mutex);
-		stopped = closure->stopped;
-		g_mutex_unlock (closure->mutex);
-
-		if (stopped)
-			break;	
+		if (!e_flag_is_set (closure->running))
+			break;
 
  		uid = g_ptr_array_index (ids, i);
 		contact = e_book_backend_db_cache_get_contact (ebgw->priv->file_db, uid);
@@ -2138,7 +2129,7 @@
 			g_object_unref (contact);
 		}
 	}
-	if (!stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (book_view, 
 						  GNOME_Evolution_Addressbook_Success);
 }
@@ -2153,7 +2144,6 @@
 	const char *query = NULL;
 	EGwFilter *filter = NULL;
 	GPtrArray *ids = NULL;
-	gboolean stopped = FALSE;
 	EDataBookView *book_view = data;
 	GroupwiseBackendSearchClosure *closure = get_closure (book_view);
 	char *view = NULL;
@@ -2168,9 +2158,7 @@
 	if (enable_debug)
 		printf ("start book view for %s \n", gwb->priv->book_name);
        	bonobo_object_ref (book_view);
-	g_mutex_lock (closure->mutex);
-	g_cond_signal (closure->cond);
-	g_mutex_unlock (closure->mutex);
+	e_flag_set (closure->running);
 	
 	query = e_data_book_view_get_card_query (book_view);
 	if (enable_debug)
@@ -2202,10 +2190,7 @@
 		contacts = e_book_backend_db_cache_get_contacts (gwb->priv->file_db, query);
 		temp_list = contacts;
 		for (; contacts != NULL; contacts = g_list_next(contacts)) {
-			g_mutex_lock (closure->mutex);
-			stopped = closure->stopped;
-			g_mutex_unlock (closure->mutex);
-			if (stopped) {
+			if (!e_flag_is_set (closure->running)) {
 				for (;contacts != NULL; contacts = g_list_next (contacts))
 					g_object_unref (contacts->data);
 				break;
@@ -2213,7 +2198,7 @@
 			e_data_book_view_notify_update (book_view, E_CONTACT(contacts->data));
 			g_object_unref (contacts->data);
 		}
-		if (!stopped)
+		if (e_flag_is_set (closure->running))
 			e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 		if (temp_list)
 			g_list_free (temp_list);
@@ -2341,10 +2326,7 @@
 		temp_list = gw_items;
 		for (; gw_items != NULL; gw_items = g_list_next(gw_items)) { 
 
-			g_mutex_lock (closure->mutex);
-			stopped = closure->stopped;
-			g_mutex_unlock (closure->mutex);
-			if (stopped) {
+			if (!e_flag_is_set (closure->running)) {
 				for (;gw_items != NULL; gw_items = g_list_next (gw_items))
 					g_object_unref (gw_items->data);
 				break;
@@ -2365,7 +2347,7 @@
 		}
 		if (temp_list)
 			g_list_free (temp_list);
-		if (!stopped)
+		if (e_flag_is_set (closure->running))
 			e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 		if (filter)
 			g_object_unref (filter);
@@ -2394,12 +2376,10 @@
 
 	if (enable_debug)
 		printf ("\ne_book_backend_groupwise_start_book_view...\n");
-	g_mutex_lock (closure->mutex);
 	closure->thread = g_thread_create (book_view_thread, book_view, FALSE, NULL);
-	g_cond_wait (closure->cond, closure->mutex);
+	e_flag_wait (closure->running);
 	
 	/* at this point we know the book view thread is actually running */
-	g_mutex_unlock (closure->mutex);
 }
   
 static void
@@ -2410,10 +2390,7 @@
 	
 	if (enable_debug)
 		printf ("\ne_book_backend_groupwise_stop_book_view...\n");
-	g_mutex_lock (closure->mutex);
-	if (!closure->stopped)
-		closure->stopped = TRUE;
-	g_mutex_unlock (closure->mutex);
+	e_flag_clear (closure->running);
 }
 
 static void
@@ -2655,11 +2632,8 @@
 	if (book_view) {
 		closure = get_closure (book_view);
 		bonobo_object_ref (book_view);
-		if (closure) {
-			g_mutex_lock (closure->mutex);
-			g_cond_signal (closure->cond);
-			g_mutex_unlock (closure->mutex);
-		}
+		if (closure)
+			e_flag_set (closure->running);
 	}
 
 	while (!done) {
@@ -2804,11 +2778,8 @@
 	if (book_view) {
 		closure = get_closure (book_view);
 		bonobo_object_ref (book_view);
-		if (closure) {
-			g_mutex_lock (closure->mutex);
-			g_cond_signal (closure->cond);
-			g_mutex_unlock (closure->mutex);
-		}
+		if (closure)
+			e_flag_set (closure->running);
 	}
 
 	cache_file_name = e_book_backend_db_cache_get_filename(ebgw->priv->file_db);
@@ -2974,11 +2945,8 @@
 	if (book_view) {
 		closure = get_closure (book_view);
 		bonobo_object_ref (book_view);
-		if (closure){
-			g_mutex_lock (closure->mutex);
-			g_cond_signal (closure->cond);
-			g_mutex_unlock (closure->mutex);
-		}
+		if (closure)
+			e_flag_set (closure->running);
 	}
 
 	/* update the cache */
--- evolution-data-server-1.11.2/addressbook/backends/vcf/e-book-backend-vcf.c.e-flag	2007-04-18 06:10:21.000000000 -0400
+++ evolution-data-server-1.11.2/addressbook/backends/vcf/e-book-backend-vcf.c	2007-05-18 11:13:41.000000000 -0400
@@ -41,6 +41,7 @@
 #include <glib/gi18n-lib.h>
 
 #include "libedataserver/e-data-server-util.h"
+#include "libedataserver/e-flag.h"
 
 #include "libebook/e-contact.h"
  
@@ -427,18 +428,15 @@
 typedef struct {
 	EBookBackendVCF *bvcf;
 	EDataBookView *view;
-	GMutex *mutex;
-	GCond *cond;
 	GThread *thread;
-	gboolean stopped;
+	EFlag *running;
 } VCFBackendSearchClosure;
 
 static void
 closure_destroy (VCFBackendSearchClosure *closure)
 {
 	d(printf ("destroying search closure\n"));
-	g_mutex_free (closure->mutex);
-	g_cond_free (closure->cond);
+	e_flag_free (closure->running);
 	g_free (closure);
 }
 
@@ -449,10 +447,8 @@
 
 	closure->bvcf = bvcf;
 	closure->view = book_view;
-	closure->mutex = g_mutex_new ();
-	closure->cond = g_cond_new ();
 	closure->thread = NULL;
-	closure->stopped = FALSE;
+	closure->running = e_flag_new ();
 
 	g_object_set_data_full (G_OBJECT (book_view), "EBookBackendVCF.BookView::closure",
 				closure, (GDestroyNotify)closure_destroy);
@@ -486,9 +482,7 @@
 		e_data_book_view_notify_status_message (book_view, _("Searching..."));
 
 	d(printf ("signalling parent thread\n"));
-	g_mutex_lock (closure->mutex);
-	g_cond_signal (closure->cond);
-	g_mutex_unlock (closure->mutex);
+	e_flag_set (closure->running);
 
 	for (l = closure->bvcf->priv->contact_list; l; l = l->next) {
 		char *vcard_string = l->data;
@@ -496,11 +490,11 @@
 		e_data_book_view_notify_update (closure->view, contact);
 		g_object_unref (contact);
 
-		if (closure->stopped)
+		if (!e_flag_is_set (closure->running))
 			break;
 	}
 
-	if (!closure->stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (closure->view, GNOME_Evolution_Addressbook_Success);
 
 	/* unref the book view */
@@ -518,15 +512,12 @@
 {
 	VCFBackendSearchClosure *closure = init_closure (book_view, E_BOOK_BACKEND_VCF (backend));
 
-	g_mutex_lock (closure->mutex);
-
 	d(printf ("starting book view thread\n"));
 	closure->thread = g_thread_create (book_view_thread, book_view, TRUE, NULL);
 
-	g_cond_wait (closure->cond, closure->mutex);
+	e_flag_wait (closure->running);
 
 	/* at this point we know the book view thread is actually running */
-	g_mutex_unlock (closure->mutex);
 	d(printf ("returning from start_book_view\n"));
 
 }
@@ -536,14 +527,11 @@
 				   EDataBookView *book_view)
 {
 	VCFBackendSearchClosure *closure = get_closure (book_view);
-	gboolean need_join = FALSE;
+	gboolean need_join;
 
 	d(printf ("stopping query\n"));
-	g_mutex_lock (closure->mutex);
-	if (!closure->stopped)
-		need_join = TRUE;
-	closure->stopped = TRUE;
-	g_mutex_unlock (closure->mutex);
+	need_join = e_flag_is_set (closure->running);
+	e_flag_clear (closure->running);
 
 	if (need_join)
 		g_thread_join (closure->thread);
--- evolution-data-server-1.11.2/calendar/libecal/e-cal.c.e-flag	2007-05-14 00:24:28.000000000 -0400
+++ evolution-data-server-1.11.2/calendar/libecal/e-cal.c	2007-05-18 11:16:58.000000000 -0400
@@ -33,6 +33,7 @@
 #include <bonobo/bonobo-main.h>
 
 #include <libedataserver/e-component-listener.h>
+#include <libedataserver/e-flag.h>
 #include <libedataserver/e-url.h>
 #include "e-cal-marshal.h"
 #include "e-cal-time-util.h"
@@ -49,8 +50,7 @@
 
 
 typedef struct {
-	GMutex *mutex;
-	GCond *cond;
+	EFlag *done;
 	ECalendarStatus status;
 
 	char *uid;
@@ -303,8 +303,7 @@
 {
 	ECalendarOp *op = g_new0 (ECalendarOp, 1);
 
-	op->mutex = g_mutex_new ();
-	op->cond = g_cond_new ();
+	op->done = e_flag_new ();
 
 	ecal->priv->current_op = op;
 
@@ -326,8 +325,7 @@
 e_calendar_free_op (ECalendarOp *op)
 {
 	/* XXX more stuff here */
-	g_cond_free (op->cond);
-	g_mutex_free (op->mutex);
+	e_flag_free (op->done);
 	g_free (op);
 }
 
@@ -445,14 +443,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->bool = read_only;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -474,14 +468,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (address);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -497,14 +487,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (address);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -520,14 +506,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (attribute);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -543,14 +525,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (capabilities);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -566,13 +544,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -588,13 +562,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -610,14 +580,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->uid = g_strdup (uid);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -633,13 +599,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -655,13 +617,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -677,13 +635,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -699,13 +653,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -722,8 +672,6 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (users);
 	op->string = g_strdup (object);
@@ -731,9 +679,7 @@
 	for (l = op->list; l; l = l->next)
 		l->data = g_strdup (l->data);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -749,14 +695,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (object);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -772,14 +714,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (object);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -796,17 +734,13 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (objects);
 	
 	for (l = op->list; l; l = l->next)
 		l->data = icalcomponent_new_clone (l->data);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -822,14 +756,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->slist = g_slist_copy (attachments);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -845,15 +775,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (object);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
-
+	e_flag_set (op->done);
 }
 
 static void
@@ -869,15 +794,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->uid = g_strdup (tzid);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
-
+	e_flag_set (op->done);
 }
 
 static void
@@ -893,13 +813,9 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -916,8 +832,6 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (changes);
 
@@ -931,9 +845,7 @@
 		l->data = new_ccc;
 	}
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -950,17 +862,13 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (freebusy);
 
 	for (l = op->list; l; l = l->next)
 		l->data = e_cal_component_clone (l->data);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -976,14 +884,10 @@
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->query = e_cal_view_new (query, op->listener, ecal);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);	
+	e_flag_set (op->done);
 }
 
 static gboolean  
@@ -1724,7 +1628,6 @@
 	}
 	/* start the open operation */
 	our_op = e_calendar_new_op (ecal);
-	g_mutex_lock (our_op->mutex);
 
 	g_mutex_unlock (priv->mutex);
 
@@ -1737,7 +1640,6 @@
 
 		if (priv->auth_func == NULL) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
@@ -1747,7 +1649,6 @@
 		username = e_source_get_property (priv->source, "username");
 		if (!username) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
@@ -1775,7 +1676,6 @@
 
 		if (!key) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_URI_NOT_LOADED;
@@ -1786,7 +1686,6 @@
 
 		if (!password) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED; 
@@ -1811,7 +1710,6 @@
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 		
 		CORBA_exception_free (&ev);
@@ -1825,14 +1723,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	*status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 	if (*status == E_CALENDAR_STATUS_OK) {
 		priv->load_state = E_CAL_LOAD_LOADED;
@@ -1988,8 +1883,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -1998,7 +1891,6 @@
 	GNOME_Evolution_Calendar_Cal_remove (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2010,14 +1902,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2249,8 +2138,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	/* set it to true so that op does not emit cond signals for all notifications
 	   from the backend */
 	our_op->bool = TRUE;
@@ -2263,7 +2150,6 @@
 	GNOME_Evolution_Calendar_Cal_isReadOnly (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2275,9 +2161,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
@@ -2285,7 +2169,6 @@
 		*read_only = our_op->bool;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 	E_CALENDAR_CHECK_STATUS (status, error);
 }
@@ -2328,8 +2211,6 @@
 
 		our_op = e_calendar_new_op (ecal);
 
-		g_mutex_lock (our_op->mutex);
-
 		g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2338,7 +2219,6 @@
 		GNOME_Evolution_Calendar_Cal_getCalAddress (priv->cal, &ev);
 		if (BONOBO_EX (&ev)) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 
 			CORBA_exception_free (&ev);
@@ -2350,14 +2230,11 @@
 
 		CORBA_exception_free (&ev);
 
-		/* wait for something to happen (both cancellation and a
-		   successful response will notity us via our cv */
-		g_cond_wait (our_op->cond, our_op->mutex);
+		e_flag_wait (our_op->done);
 
 		status = our_op->status;
 		*cal_address = our_op->string;
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (status, error);
@@ -2405,8 +2282,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2415,7 +2290,6 @@
 	GNOME_Evolution_Calendar_Cal_getAlarmEmailAddress (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2427,15 +2301,12 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*alarm_address = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2478,8 +2349,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2488,7 +2357,6 @@
 	GNOME_Evolution_Calendar_Cal_getLdapAttribute (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2500,15 +2368,12 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*ldap_attribute = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2541,8 +2406,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2551,7 +2414,6 @@
 	GNOME_Evolution_Calendar_Cal_getStaticCapabilities (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2563,15 +2425,12 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	priv->capabilities = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2780,8 +2639,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -2789,7 +2646,6 @@
 	GNOME_Evolution_Calendar_Cal_getDefaultObject (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2801,9 +2657,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK) {
@@ -2816,7 +2670,6 @@
 	g_free (our_op->string);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2861,15 +2714,12 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_Calendar_Cal_getAttachmentList (priv->cal, uid, rid ? rid : "", &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2881,9 +2731,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -2893,7 +2741,6 @@
 	}
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2938,8 +2785,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -2947,7 +2792,6 @@
 	GNOME_Evolution_Calendar_Cal_getObject (priv->cal, uid, rid ? rid : "", &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2959,9 +2803,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -3009,7 +2851,6 @@
 	g_free (our_op->string);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3055,8 +2896,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3064,7 +2903,6 @@
 	GNOME_Evolution_Calendar_Cal_getObject (priv->cal, uid, "", &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3076,9 +2914,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -3136,7 +2972,6 @@
 	g_free (our_op->string);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3206,8 +3041,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3216,7 +3049,6 @@
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3228,15 +3060,12 @@
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*changes = our_op->list;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3306,8 +3135,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3316,7 +3143,6 @@
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3328,15 +3154,12 @@
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*objects = our_op->list;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3439,8 +3262,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	/* create the CORBA user list to be passed to the backend */
@@ -3460,7 +3281,6 @@
 	
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3472,15 +3292,12 @@
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*freebusy = our_op->list;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4174,8 +3991,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	e_cal_component_get_uid (comp, &uid);
@@ -4185,7 +4000,6 @@
 	GNOME_Evolution_Calendar_Cal_discardAlarm (priv->cal, uid, auid, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4197,14 +4011,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4420,8 +4231,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4429,7 +4238,6 @@
 	GNOME_Evolution_Calendar_Cal_createObject (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4441,9 +4249,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	if (uid)
@@ -4453,7 +4259,6 @@
 	}
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4503,8 +4308,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4512,7 +4315,6 @@
 	GNOME_Evolution_Calendar_Cal_modifyObject (priv->cal, icalcomponent_as_ical_string (icalcomp), mod, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4524,14 +4326,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4584,8 +4383,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -4594,7 +4391,6 @@
 	GNOME_Evolution_Calendar_Cal_removeObject (priv->cal, uid, rid ? rid : "", mod, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4606,14 +4402,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4678,8 +4471,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4687,7 +4478,6 @@
 	GNOME_Evolution_Calendar_Cal_receiveObjects (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4699,14 +4489,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4752,8 +4539,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4761,7 +4546,6 @@
 	GNOME_Evolution_Calendar_Cal_sendObjects (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4773,9 +4557,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*users = our_op->list;
@@ -4796,7 +4578,6 @@
 	g_free (our_op->string);
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4841,8 +4622,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (priv->mutex);
 
 	/* Check for well known zones and in the cache */
@@ -4851,7 +4630,6 @@
 	/* If tzid is NULL or "" we return NULL, since it is a 'local time'. */
 	if (!tzid || !tzid[0]) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		*zone = NULL;
@@ -4869,7 +4647,6 @@
 	
 	if (*zone) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);	
@@ -4881,7 +4658,6 @@
 	GNOME_Evolution_Calendar_Cal_getTimezone (priv->cal, tzid, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4893,9 +4669,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -4909,7 +4683,6 @@
 	
 	if (!icalcomp) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (status, error);
@@ -4920,7 +4693,6 @@
 		icaltimezone_free (*zone, 1);
 
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OBJECT_NOT_FOUND, error);
@@ -4930,7 +4702,6 @@
 	g_hash_table_insert (priv->timezones, icaltimezone_get_tzid (*zone), *zone);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4975,15 +4746,12 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (priv->mutex);
 
 	/* Make sure we have a valid component - UTC doesn't, nor do
 	 * we really have to add it */
 	if (izone == icaltimezone_get_utc_timezone ()) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 		
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
@@ -4992,7 +4760,6 @@
 	icalcomp = icaltimezone_get_component (izone);
 	if (!icalcomp) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
@@ -5007,7 +4774,6 @@
 	GNOME_Evolution_Calendar_Cal_addTimezone (priv->cal, tzobj, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -5019,14 +4785,11 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -5068,8 +4831,6 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -5079,7 +4840,6 @@
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -5091,9 +4851,7 @@
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*query = our_op->query;
@@ -5101,7 +4859,6 @@
 	bonobo_object_unref (BONOBO_OBJECT (our_op->listener));
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -5146,15 +4903,12 @@
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (priv->mutex);
 
 	/* FIXME Adding it to the server to change the tzid */
 	icalcomp = icaltimezone_get_component (zone);
 	if (!icalcomp) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
@@ -5169,7 +4923,6 @@
 	GNOME_Evolution_Calendar_Cal_setDefaultTimezone (priv->cal, tzobj, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -5181,9 +4934,7 @@
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 
@@ -5195,7 +4946,6 @@
 	}
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);