Index: addressbook/backends/file/e-book-backend-file.c
===================================================================
--- addressbook/backends/file/e-book-backend-file.c	(revision 7647)
+++ addressbook/backends/file/e-book-backend-file.c	(working copy)
@@ -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"
 
@@ -479,18 +480,15 @@ e_book_backend_file_get_contact_list (EB
 
 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);
 }
 
@@ -500,10 +498,8 @@ init_closure (EDataBookView *book_view, 
 	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);
@@ -527,7 +523,7 @@ book_view_thread (gpointer data)
 	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"));
 
@@ -547,9 +543,7 @@ book_view_thread (gpointer data)
 	}
 
 	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 */
@@ -558,12 +552,9 @@ book_view_thread (gpointer data)
 
 		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)
-				break;
+			if (!e_flag_is_set (closure->running))
+				break;
 
 			string_to_dbt (id, &id_dbt);
 			memset (&vcard_dbt, 0, sizeof (vcard_dbt));
@@ -595,12 +586,8 @@ book_view_thread (gpointer data)
 			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)
-					break;
+				if (!e_flag_is_set (closure->running))
+					break;
 
 				/* don't include the version in the list of cards */
 				if (strcmp (id_dbt.data, E_BOOK_BACKEND_FILE_VERSION_NAME)) {
@@ -628,7 +615,7 @@ book_view_thread (gpointer data)
 
 	}
 
-	if (!stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 
 	/* unref the */
@@ -646,15 +633,12 @@ e_book_backend_file_start_book_view (EBo
 {
 	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"));
 }
 
@@ -663,14 +647,11 @@ e_book_backend_file_stop_book_view (EBoo
 				    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);
Index: addressbook/backends/groupwise/e-book-backend-groupwise.c
===================================================================
--- addressbook/backends/groupwise/e-book-backend-groupwise.c	(revision 7647)
+++ addressbook/backends/groupwise/e-book-backend-groupwise.c	(working copy)
@@ -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"
@@ -2070,17 +2071,14 @@ e_book_backend_groupwise_get_contact_lis
 	
 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);
 }
 
@@ -2090,10 +2088,8 @@ init_closure (EDataBookView *book_view, 
 	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);
@@ -2115,19 +2111,14 @@ get_contacts_from_cache (EBookBackendGro
 			 GroupwiseBackendSearchClosure *closure)
 {
 	int i;
-	gboolean stopped = FALSE;
 
 	if (enable_debug)
 		printf ("\nread contacts from cache for the ids found in summary\n");
 	for (i = 0; i < ids->len; i ++) {
 		char *uid = g_ptr_array_index (ids, i);
 
-		g_mutex_lock (closure->mutex);
-		stopped = closure->stopped;
-		g_mutex_unlock (closure->mutex);
-
-		if (stopped)
-			break;	
+		if (!e_flag_is_set (closure->running))
+			break;
 
 		EContact *contact = 
 			e_book_backend_db_cache_get_contact (ebgw->priv->file_db, uid);
@@ -2136,7 +2127,7 @@ get_contacts_from_cache (EBookBackendGro
 			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);
 }
@@ -2151,7 +2142,6 @@ book_view_thread (gpointer data)
 	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;
@@ -2166,9 +2156,7 @@ book_view_thread (gpointer data)
 	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)
@@ -2200,10 +2188,7 @@ book_view_thread (gpointer data)
 		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;
@@ -2211,7 +2196,7 @@ book_view_thread (gpointer data)
 			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);
@@ -2339,10 +2324,7 @@ book_view_thread (gpointer data)
 		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;
@@ -2363,7 +2345,7 @@ book_view_thread (gpointer data)
 		}
 		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);
@@ -2392,12 +2374,10 @@ e_book_backend_groupwise_start_book_view
 
 	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
@@ -2408,10 +2388,7 @@ e_book_backend_groupwise_stop_book_view 
 	
 	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
@@ -2650,11 +2627,8 @@ build_cache (EBookBackendGroupwise *ebgw
 	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) {
@@ -2799,11 +2773,8 @@ update_cache (EBookBackendGroupwise *ebg
 	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);
@@ -2967,11 +2938,8 @@ update_address_book_deltas (EBookBackend
 	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 */
Index: addressbook/backends/vcf/e-book-backend-vcf.c
===================================================================
--- addressbook/backends/vcf/e-book-backend-vcf.c	(revision 7647)
+++ addressbook/backends/vcf/e-book-backend-vcf.c	(working copy)
@@ -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 @@ e_book_backend_vcf_get_contact_list (EBo
 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 @@ init_closure (EDataBookView *book_view, 
 
 	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 @@ book_view_thread (gpointer data)
 		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 @@ book_view_thread (gpointer data)
 		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 @@ e_book_backend_vcf_start_book_view (EBoo
 {
 	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 @@ e_book_backend_vcf_stop_book_view (EBook
 				   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);
Index: calendar/libecal/e-cal.c
===================================================================
--- calendar/libecal/e-cal.c	(revision 7647)
+++ calendar/libecal/e-cal.c	(working copy)
@@ -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 @@ get_read_only (ECal *ecal, gboolean *rea
 
 
 typedef struct {
-	GMutex *mutex;
-	GCond *cond;
+	EFlag *done;
 	ECalendarStatus status;
 
 	char *uid;
@@ -303,8 +303,7 @@ e_calendar_new_op (ECal *ecal)
 {
 	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 @@ static void
 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 @@ cal_read_only_cb (ECalListener *listener
 		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 @@ cal_cal_address_cb (ECalListener *listen
 		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 @@ cal_alarm_address_cb (ECalListener *list
 		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 @@ cal_ldap_attribute_cb (ECalListener *lis
 		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 @@ cal_static_capabilities_cb (ECalListener
 		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 @@ cal_opened_cb (ECalListener *listener, E
 		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 @@ cal_removed_cb (ECalListener *listener, 
 		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 @@ cal_object_created_cb (ECalListener *lis
 		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 @@ cal_object_modified_cb (ECalListener *li
 		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 @@ cal_object_removed_cb (ECalListener *lis
 		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 @@ cal_alarm_discarded_cb (ECalListener *li
 		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 @@ cal_objects_received_cb (ECalListener *l
 		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 @@ cal_objects_sent_cb (ECalListener *liste
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (users);
 	op->string = g_strdup (object);
@@ -731,9 +679,7 @@ cal_objects_sent_cb (ECalListener *liste
 	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 @@ cal_default_object_requested_cb (ECalLis
 		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 @@ cal_object_requested_cb (ECalListener *l
 		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 @@ cal_object_list_cb (ECalListener *listen
 		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 @@ cal_attachment_list_cb (ECalListener *li
 		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 @@ cal_get_timezone_cb (ECalListener *liste
 		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 @@ cal_add_timezone_cb (ECalListener *liste
 		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 @@ cal_set_default_timezone_cb (ECalListene
 		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 @@ cal_get_changes_cb (ECalListener *listen
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (changes);
 
@@ -931,9 +845,7 @@ cal_get_changes_cb (ECalListener *listen
 		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 @@ cal_get_free_busy_cb (ECalListener *list
 		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 @@ cal_query_cb (ECalListener *listener, EC
 		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  
@@ -1714,7 +1618,6 @@ open_calendar (ECal *ecal, gboolean only
 	}
 	/* start the open operation */
 	our_op = e_calendar_new_op (ecal);
-	g_mutex_lock (our_op->mutex);
 
 	g_mutex_unlock (priv->mutex);
 
@@ -1727,7 +1630,6 @@ open_calendar (ECal *ecal, gboolean only
 
 		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;
@@ -1737,7 +1639,6 @@ open_calendar (ECal *ecal, gboolean only
 		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;
@@ -1765,7 +1666,6 @@ open_calendar (ECal *ecal, gboolean only
 
 		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;
@@ -1776,7 +1676,6 @@ open_calendar (ECal *ecal, gboolean only
 
 		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; 
@@ -1801,7 +1700,6 @@ open_calendar (ECal *ecal, gboolean only
 
 	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);
@@ -1815,14 +1713,11 @@ open_calendar (ECal *ecal, gboolean only
 
 	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;
@@ -1978,8 +1873,6 @@ e_cal_remove (ECal *ecal, GError **error
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -1988,7 +1881,6 @@ e_cal_remove (ECal *ecal, GError **error
 	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);
@@ -2000,14 +1892,11 @@ e_cal_remove (ECal *ecal, GError **error
 
 	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);
@@ -2239,8 +2128,6 @@ get_read_only (ECal *ecal, gboolean *rea
 
 	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;
@@ -2253,7 +2140,6 @@ get_read_only (ECal *ecal, gboolean *rea
 	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);
@@ -2265,9 +2151,7 @@ get_read_only (ECal *ecal, gboolean *rea
 
 	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;
 	
@@ -2275,7 +2159,6 @@ get_read_only (ECal *ecal, gboolean *rea
 		*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);
 }
@@ -2318,8 +2201,6 @@ e_cal_get_cal_address (ECal *ecal, char 
 
 		our_op = e_calendar_new_op (ecal);
 
-		g_mutex_lock (our_op->mutex);
-
 		g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2328,7 +2209,6 @@ e_cal_get_cal_address (ECal *ecal, char 
 		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);
@@ -2340,14 +2220,11 @@ e_cal_get_cal_address (ECal *ecal, char 
 
 		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);
@@ -2395,8 +2272,6 @@ e_cal_get_alarm_email_address (ECal *eca
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2405,7 +2280,6 @@ e_cal_get_alarm_email_address (ECal *eca
 	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);
@@ -2417,15 +2291,12 @@ e_cal_get_alarm_email_address (ECal *eca
 
 	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);
@@ -2468,8 +2339,6 @@ e_cal_get_ldap_attribute (ECal *ecal, ch
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2478,7 +2347,6 @@ e_cal_get_ldap_attribute (ECal *ecal, ch
 	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);
@@ -2490,15 +2358,12 @@ e_cal_get_ldap_attribute (ECal *ecal, ch
 
 	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);
@@ -2531,8 +2396,6 @@ load_static_capabilities (ECal *ecal, GE
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2541,7 +2404,6 @@ load_static_capabilities (ECal *ecal, GE
 	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);
@@ -2553,15 +2415,12 @@ load_static_capabilities (ECal *ecal, GE
 
 	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);
@@ -2770,8 +2629,6 @@ e_cal_get_default_object (ECal *ecal, ic
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -2779,7 +2636,6 @@ e_cal_get_default_object (ECal *ecal, ic
 	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);
@@ -2791,9 +2647,7 @@ e_cal_get_default_object (ECal *ecal, ic
 
 	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) {
@@ -2806,7 +2660,6 @@ e_cal_get_default_object (ECal *ecal, ic
 	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);
@@ -2851,15 +2704,12 @@ e_cal_get_attachments_for_comp (ECal *ec
 
 	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);
@@ -2871,9 +2721,7 @@ e_cal_get_attachments_for_comp (ECal *ec
 
 	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){ 
@@ -2883,7 +2731,6 @@ e_cal_get_attachments_for_comp (ECal *ec
 	}
 
 	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);
@@ -2928,8 +2775,6 @@ e_cal_get_object (ECal *ecal, const char
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -2937,7 +2782,6 @@ e_cal_get_object (ECal *ecal, const char
 	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);
@@ -2949,9 +2793,7 @@ e_cal_get_object (ECal *ecal, const char
 
 	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){ 
@@ -2999,7 +2841,6 @@ e_cal_get_object (ECal *ecal, const char
 	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);
@@ -3045,8 +2886,6 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3054,7 +2893,6 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 	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);
@@ -3066,9 +2904,7 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 
 	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){ 
@@ -3126,7 +2962,6 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 	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);
@@ -3196,8 +3031,6 @@ e_cal_get_changes (ECal *ecal, const cha
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3206,7 +3039,6 @@ e_cal_get_changes (ECal *ecal, const cha
 
 	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);
@@ -3218,15 +3050,12 @@ e_cal_get_changes (ECal *ecal, const cha
 	
 	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);
@@ -3296,8 +3125,6 @@ e_cal_get_object_list (ECal *ecal, const
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3306,7 +3133,6 @@ e_cal_get_object_list (ECal *ecal, const
 
 	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);
@@ -3318,15 +3144,12 @@ e_cal_get_object_list (ECal *ecal, const
 	
 	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);
@@ -3429,8 +3252,6 @@ e_cal_get_free_busy (ECal *ecal, GList *
 
 	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 */
@@ -3450,7 +3271,6 @@ e_cal_get_free_busy (ECal *ecal, GList *
 	
 	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);
@@ -3462,15 +3282,12 @@ e_cal_get_free_busy (ECal *ecal, GList *
 	
 	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);
@@ -4161,8 +3978,6 @@ e_cal_discard_alarm (ECal *ecal, ECalCom
 
 	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);
@@ -4172,7 +3987,6 @@ e_cal_discard_alarm (ECal *ecal, ECalCom
 	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);
@@ -4184,14 +3998,11 @@ e_cal_discard_alarm (ECal *ecal, ECalCom
 
 	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);
@@ -4407,8 +4218,6 @@ e_cal_create_object (ECal *ecal, icalcom
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4416,7 +4225,6 @@ e_cal_create_object (ECal *ecal, icalcom
 	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);
@@ -4428,16 +4236,13 @@ e_cal_create_object (ECal *ecal, icalcom
 
 	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)
 		*uid = our_op->uid;
 	
 	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);
@@ -4487,8 +4292,6 @@ e_cal_modify_object (ECal *ecal, icalcom
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4496,7 +4299,6 @@ e_cal_modify_object (ECal *ecal, icalcom
 	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);
@@ -4508,14 +4310,11 @@ e_cal_modify_object (ECal *ecal, icalcom
 
 	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);
@@ -4568,8 +4367,6 @@ e_cal_remove_object_with_mod (ECal *ecal
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -4578,7 +4375,6 @@ e_cal_remove_object_with_mod (ECal *ecal
 	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);
@@ -4590,14 +4386,11 @@ e_cal_remove_object_with_mod (ECal *ecal
 
 	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);
@@ -4662,8 +4455,6 @@ e_cal_receive_objects (ECal *ecal, icalc
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4671,7 +4462,6 @@ e_cal_receive_objects (ECal *ecal, icalc
 	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);
@@ -4683,14 +4473,11 @@ e_cal_receive_objects (ECal *ecal, icalc
 
 	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);
@@ -4736,8 +4523,6 @@ e_cal_send_objects (ECal *ecal, icalcomp
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4745,7 +4530,6 @@ e_cal_send_objects (ECal *ecal, icalcomp
 	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);
@@ -4757,9 +4541,7 @@ e_cal_send_objects (ECal *ecal, icalcomp
 
 	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;
@@ -4780,7 +4562,6 @@ e_cal_send_objects (ECal *ecal, icalcomp
 	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);
@@ -4825,8 +4606,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 
 	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 */
@@ -4835,7 +4614,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	/* 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;
@@ -4853,7 +4631,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	
 	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);	
@@ -4865,7 +4642,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	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);
@@ -4877,9 +4653,7 @@ e_cal_get_timezone (ECal *ecal, const ch
 
 	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){ 
@@ -4893,7 +4667,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	
 	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);
@@ -4904,7 +4677,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 		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);
@@ -4914,7 +4686,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	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);
@@ -4959,15 +4730,12 @@ e_cal_add_timezone (ECal *ecal, icaltime
 
 	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);
@@ -4976,7 +4744,6 @@ e_cal_add_timezone (ECal *ecal, icaltime
 	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);
@@ -4991,7 +4758,6 @@ e_cal_add_timezone (ECal *ecal, icaltime
 	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);
@@ -5003,14 +4769,11 @@ e_cal_add_timezone (ECal *ecal, icaltime
 
 	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);
@@ -5052,8 +4815,6 @@ e_cal_get_query (ECal *ecal, const char 
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -5063,7 +4824,6 @@ e_cal_get_query (ECal *ecal, const char 
 
 	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);
@@ -5075,9 +4835,7 @@ e_cal_get_query (ECal *ecal, const char 
 	
 	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;
@@ -5085,7 +4843,6 @@ e_cal_get_query (ECal *ecal, const char 
 	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);
@@ -5166,15 +4923,12 @@ e_cal_set_default_timezone (ECal *ecal, 
 
 	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);
@@ -5189,7 +4943,6 @@ e_cal_set_default_timezone (ECal *ecal, 
 	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);
@@ -5201,9 +4954,7 @@ e_cal_set_default_timezone (ECal *ecal, 
 
 	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;
 
@@ -5215,7 +4966,6 @@ e_cal_set_default_timezone (ECal *ecal, 
 	}
 
 	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);
