[evolution-data-server/dbus-calendar: 6/8] Port libedata-cal to DBus



commit f2a71f30530d2a65ed81af922bdaab7eca7e450c
Author: Ross Burton <ross linux intel com>
Date:   Mon Jul 6 16:52:12 2009 +0100

    Port libedata-cal to DBus

 calendar/libedata-cal/Makefile.am                  |   62 +-
 calendar/libedata-cal/e-cal-backend-sync.c         |   94 +-
 calendar/libedata-cal/e-cal-backend-sync.h         |    1 -
 calendar/libedata-cal/e-cal-backend.c              |  145 +-
 calendar/libedata-cal/e-cal-backend.h              |  101 +-
 calendar/libedata-cal/e-data-cal-common.h          |    3 +
 calendar/libedata-cal/e-data-cal-factory.c         |  465 +++---
 calendar/libedata-cal/e-data-cal-factory.h         |   24 +-
 calendar/libedata-cal/e-data-cal-factory.xml       |   16 +
 calendar/libedata-cal/e-data-cal-marshal.list      |    1 +
 calendar/libedata-cal/e-data-cal-types.h           |  106 ++
 calendar/libedata-cal/e-data-cal-view.c            |  814 ++++-------
 calendar/libedata-cal/e-data-cal-view.h            |   29 +-
 calendar/libedata-cal/e-data-cal-view.xml          |   32 +
 calendar/libedata-cal/e-data-cal.c                 | 1556 +++++++-------------
 calendar/libedata-cal/e-data-cal.h                 |   77 +-
 calendar/libedata-cal/e-data-cal.xml               |  198 +++
 calendar/libedata-cal/libedata-cal.pc.in           |    5 +-
 ....gnome.evolution.dataserver.Calendar.service.in |    3 +
 19 files changed, 1645 insertions(+), 2087 deletions(-)
---
diff --git a/calendar/libedata-cal/Makefile.am b/calendar/libedata-cal/Makefile.am
index b3b66b8..2a6b7ea 100644
--- a/calendar/libedata-cal/Makefile.am
+++ b/calendar/libedata-cal/Makefile.am
@@ -8,42 +8,36 @@ AM_CPPFLAGS =						\
 	$(LIBICAL_CFLAGS)				\
 	$(EVOLUTION_CALENDAR_CFLAGS)
 
-CORBA_GENERATED_H =				\
-	Evolution-DataServer-Calendar.h
+MARSHAL_GENERATED = e-data-cal-marshal.c e-data-cal-marshal.h
+ EVO_MARSHAL_RULE@
 
-CORBA_GENERATED_C =				\
-	Evolution-DataServer-Calendar-common.c		\
-	Evolution-DataServer-Calendar-skels.c		\
-	Evolution-DataServer-Calendar-stubs.c
+DBUS_GENERATED_H = e-data-cal-glue.h e-data-cal-factory-glue.h e-data-cal-view-glue.h
+%-glue.h: %.xml
+	dbus-binding-tool --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
 
-CORBA_GENERATED = $(CORBA_GENERATED_H) $(CORBA_GENERATED_C)
+include $(top_srcdir)/glib-gen.mak
+glib_enum_headers=e-data-cal-types.h
+glib_enum_define=E_DATA_CAL
+glib_enum_prefix=e_data_cal
 
-idls =						\
-	$(srcdir)/../idl/Evolution-DataServer-Calendar.idl
-
-idl_flags = -I $(srcdir) $(IDL_INCLUDES)
-
-$(CORBA_GENERATED_H): $(idls)
-	$(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/Evolution-DataServer-Calendar.idl
-
-$(CORBA_GENERATED_C): $(CORBA_GENERATED_H)
+ENUM_GENERATED = e-data-cal-enumtypes.h e-data-cal-enumtypes.c
 
 # The libraray
 lib_LTLIBRARIES = libedata-cal-1.2.la
 
 libedata_cal_1_2_la_SOURCES =		\
-	$(CORBA_GENERATED_C)		\
+	$(MARSHAL_GENERATED)		\
+	$(ENUM_GENERATED)		\
+	$(DBUS_GENERATED_H)		\
 	e-cal-backend.c			\
 	e-cal-backend-cache.c		\
 	e-cal-backend-factory.c		\
-	e-cal-backend-loader-factory.c		\
 	e-cal-backend-sexp.c		\
 	e-cal-backend-sync.c		\
 	e-cal-backend-util.c		\
 	e-cal-backend-store.c		\
 	e-cal-backend-file-store.c	\
 	e-data-cal.c			\
-	e-data-cal-factory.c		\
 	e-data-cal-view.c
 
 libedata_cal_1_2_la_LIBADD =					\
@@ -59,11 +53,10 @@ libedata_cal_1_2_la_LDFLAGS = 								\
 libedata_calincludedir = $(privincludedir)/libedata-cal
 
 libedata_calinclude_HEADERS = 		\
-	$(CORBA_GENERATED_H)		\
+	e-data-cal-types.h		\
 	e-cal-backend.h			\
 	e-cal-backend-cache.h		\
 	e-cal-backend-factory.h		\
-	e-cal-backend-loader-factory.h	\
 	e-cal-backend-sync.h		\
 	e-cal-backend-util.h		\
 	e-cal-backend-sexp.h		\
@@ -80,13 +73,30 @@ libedata_calinclude_HEADERS = 		\
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libedata-cal-$(API_VERSION).pc
 
-BUILT_SOURCES = $(CORBA_GENERATED)
-CLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = $(pkgconfig_DATA)
+service_in_files = org.gnome.evolution.dataserver.Calendar.service.in
+servicedir = $(datadir)/dbus-1/services
+service_DATA = $(service_in_files:.service.in=.service)
+ EVO_SUBST_SERVICE_RULE@
+
+BUILT_SOURCES = $(DBUS_GENERATED_H) $(MARSHAL_GENERATED) $(ENUM_GENERATED)
+CLEANFILES = $(BUILT_SOURCES) $(service_DATA)
+DISTCLEANFILES = $(pkgconfig_DATA) $(service_DATA)
 
 EXTRA_DIST = 						\
+	e-data-cal-marshal.list				\
+	e-data-cal-factory.xml				\
+	e-data-cal-view.xml				\
+	e-data-cal.xml					\
+	$(service_in_files)				\
 	$(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in)
 
-dist-hook:
-	cd $(distdir); rm -f $(BUILT_SOURCES)
 
+factorydir = $(libexecdir)
+factory_PROGRAMS = e-calendar-factory
+
+e_calendar_factory_SOURCES = \
+	e-data-cal-factory.c \
+	e-data-cal-factory.h \
+	e-cal-backend-loader-factory.c \
+	e-cal-backend-loader-factory.h
+e_calendar_factory_LDADD = $(builddir)/libedata-cal-1.2.la
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index 10fdf8a..8764067 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -647,87 +647,87 @@ _e_cal_backend_is_read_only (ECalBackend *backend, EDataCal *cal)
 }
 
 static void
-_e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal)
+_e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	ECalBackendSyncStatus status;
 	gchar *address = NULL;
 
 	status = e_cal_backend_sync_get_cal_address (E_CAL_BACKEND_SYNC (backend), cal, &address);
 
-	e_data_cal_notify_cal_address (cal, status, address);
+	e_data_cal_notify_cal_address (cal, context, status, address);
 
 	g_free (address);
 }
 
 static void
-_e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal)
+_e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	ECalBackendSyncStatus status;
 	gchar *address = NULL;
 
 	status = e_cal_backend_sync_get_alarm_email_address (E_CAL_BACKEND_SYNC (backend), cal, &address);
 
-	e_data_cal_notify_alarm_email_address (cal, status, address);
+	e_data_cal_notify_alarm_email_address (cal, context, status, address);
 
 	g_free (address);
 }
 
 static void
-_e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal)
+_e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	ECalBackendSyncStatus status;
 	gchar *attribute = NULL;
 
 	status = e_cal_backend_sync_get_ldap_attribute (E_CAL_BACKEND_SYNC (backend), cal, &attribute);
 
-	e_data_cal_notify_ldap_attribute (cal, status, attribute);
+	e_data_cal_notify_ldap_attribute (cal, context, status, attribute);
 
 	g_free (attribute);
 }
 
 static void
-_e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal)
+_e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	ECalBackendSyncStatus status;
 	gchar *capabilities = NULL;
 
 	status = e_cal_backend_sync_get_static_capabilities (E_CAL_BACKEND_SYNC (backend), cal, &capabilities);
 
-	e_data_cal_notify_static_capabilities (cal, status, capabilities);
+	e_data_cal_notify_static_capabilities (cal, context, status, capabilities);
 
 	g_free (capabilities);
 }
 
 static void
-_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists,
+_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists,
 		     const gchar *username, const gchar *password)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_open (E_CAL_BACKEND_SYNC (backend), cal, only_if_exists, username, password);
 
-	e_data_cal_notify_open (cal, status);
+	e_data_cal_notify_open (cal, context, status);
 }
 
 static void
-_e_cal_backend_remove (ECalBackend *backend, EDataCal *cal)
+_e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_remove (E_CAL_BACKEND_SYNC (backend), cal);
 
-	e_data_cal_notify_remove (cal, status);
+	e_data_cal_notify_remove (cal, context, status);
 }
 
 static void
-_e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+_e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
 {
 	ECalBackendSyncStatus status;
 	gchar *uid = NULL, *modified_calobj = (gchar *) calobj;
 
 	status = e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, &modified_calobj, &uid);
 
-	e_data_cal_notify_object_created (cal, status, uid, modified_calobj);
+	e_data_cal_notify_object_created (cal, context, status, uid, modified_calobj);
 
 	/* free memory */
 	if (uid)
@@ -738,7 +738,7 @@ _e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const gchar *
 }
 
 static void
-_e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod)
+_e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj, CalObjModType mod)
 {
 	ECalBackendSyncStatus status;
 	gchar *old_object = NULL;
@@ -748,16 +748,16 @@ _e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *
 						   calobj, mod, &old_object, &new_object);
 
 	if (new_object)
-		e_data_cal_notify_object_modified (cal, status, old_object, new_object);
+		e_data_cal_notify_object_modified (cal, context, status, old_object, new_object);
 	else
-		e_data_cal_notify_object_modified (cal, status, old_object, calobj);
+		e_data_cal_notify_object_modified (cal, context, status, old_object, calobj);
 
 	g_free (old_object);
 	g_free (new_object);
 }
 
 static void
-_e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod)
+_e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid, CalObjModType mod)
 {
 	ECalBackendSyncStatus status;
 	gchar *object = NULL, *old_object = NULL;
@@ -773,47 +773,47 @@ _e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *
 			id->rid = g_strdup (rid);
 
 		if (!object)
-			e_data_cal_notify_object_removed (cal, status, id, old_object, object);
+			e_data_cal_notify_object_removed (cal, context, status, id, old_object, object);
 		else
-			e_data_cal_notify_object_modified (cal, status, old_object, object);
+			e_data_cal_notify_object_modified (cal, context, status, old_object, object);
 
 		e_cal_component_free_id (id);
 	} else
-		e_data_cal_notify_object_removed (cal, status, NULL, old_object, object);
+		e_data_cal_notify_object_removed (cal, context, status, NULL, old_object, object);
 
 	g_free (old_object);
 	g_free (object);
 }
 
 static void
-_e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+_e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *auid)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_discard_alarm (E_CAL_BACKEND_SYNC (backend), cal, uid, auid);
 
-	e_data_cal_notify_alarm_discarded (cal, status);
+	e_data_cal_notify_alarm_discarded (cal, context, status);
 }
 
 static void
-_e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+_e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_receive_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj);
 
-	e_data_cal_notify_objects_received (cal, status);
+	e_data_cal_notify_objects_received (cal, context, status);
 }
 
 static void
-_e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+_e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
 {
 	ECalBackendSyncStatus status;
 	GList *users = NULL;
 	gchar *modified_calobj = NULL;
 
 	status = e_cal_backend_sync_send_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj, &users, &modified_calobj);
-	e_data_cal_notify_objects_sent (cal, status, users, modified_calobj);
+	e_data_cal_notify_objects_sent (cal, context, status, users, modified_calobj);
 
 	g_list_foreach (users, (GFunc) g_free, NULL);
 	g_list_free (users);
@@ -821,54 +821,54 @@ _e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *c
 }
 
 static void
-_e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal)
+_e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	ECalBackendSyncStatus status;
 	gchar *object = NULL;
 
 	status = e_cal_backend_sync_get_default_object (E_CAL_BACKEND_SYNC (backend), cal, &object);
 
-	e_data_cal_notify_default_object (cal, status, object);
+	e_data_cal_notify_default_object (cal, context, status, object);
 
 	g_free (object);
 }
 
 static void
-_e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
+_e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
 {
 	ECalBackendSyncStatus status;
 	gchar *object = NULL;
 
 	status = e_cal_backend_sync_get_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &object);
 
-	e_data_cal_notify_object (cal, status, object);
+	e_data_cal_notify_object (cal, context, status, object);
 
 	g_free (object);
 }
 
 static void
-_e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
+_e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
 {
 	ECalBackendSyncStatus status;
 	GSList *list = NULL;
 
 	status = e_cal_backend_sync_get_attachment_list (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &list);
 
-	e_data_cal_notify_attachment_list (cal, status, list);
+	e_data_cal_notify_attachment_list (cal, context, status, list);
 
 	g_slist_foreach (list, (GFunc) g_free, NULL);
 	g_free (list);
 }
 
 static void
-_e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar *sexp)
+_e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp)
 {
 	ECalBackendSyncStatus status;
 	GList *objects = NULL, *l;
 
 	status = e_cal_backend_sync_get_object_list (E_CAL_BACKEND_SYNC (backend), cal, sexp, &objects);
 
-	e_data_cal_notify_object_list (cal, status, objects);
+	e_data_cal_notify_object_list (cal, context, status, objects);
 
 	for (l = objects; l; l = l->next)
 		g_free (l->data);
@@ -876,7 +876,7 @@ _e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar
 }
 
 static void
-_e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
+_e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
 {
 	ECalBackendSyncStatus status;
 	gchar *object = NULL;
@@ -929,19 +929,19 @@ _e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *t
 			e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, object);
 	}
 
-	e_data_cal_notify_timezone_requested (cal, status, object);
+	e_data_cal_notify_timezone_requested (cal, context, status, object);
 
 	g_free (object);
 }
 
 static void
-_e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzobj)
+_e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzobj);
 
-	e_data_cal_notify_timezone_added (cal, status, tzobj);
+	e_data_cal_notify_timezone_added (cal, context, status, tzobj);
 }
 
 static icaltimezone *
@@ -962,27 +962,27 @@ _e_cal_backend_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
 }
 
 static void
-_e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const gchar *tz)
+_e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tz)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_set_default_zone (E_CAL_BACKEND_SYNC (backend), cal, tz);
 
-	e_data_cal_notify_default_timezone_set (cal, status);
+	e_data_cal_notify_default_timezone_set (cal, context, status);
 }
 
 static void
-_e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
+_e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
 {
 	ECalBackendSyncStatus status;
 
 	status = e_cal_backend_sync_set_default_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid);
 
-	e_data_cal_notify_default_timezone_set (cal, status);
+	e_data_cal_notify_default_timezone_set (cal, context, status);
 }
 
 static void
-_e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *change_id)
+_e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *change_id)
 {
 	ECalBackendSyncStatus status;
 	GList *adds = NULL, *modifies = NULL, *deletes = NULL, *l;
@@ -990,7 +990,7 @@ _e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *ch
 	status = e_cal_backend_sync_get_changes (E_CAL_BACKEND_SYNC (backend), cal, change_id,
 					       &adds, &modifies, &deletes);
 
-	e_data_cal_notify_changes (cal, status, adds, modifies, deletes);
+	e_data_cal_notify_changes (cal, context, status, adds, modifies, deletes);
 
 	for (l = adds; l; l = l->next)
 		g_free (l->data);
@@ -1006,14 +1006,14 @@ _e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *ch
 }
 
 static void
-_e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end)
+_e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end)
 {
 	ECalBackendSyncStatus status;
 	GList *freebusy = NULL, *l;
 
 	status = e_cal_backend_sync_get_free_busy (E_CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy);
 
-	e_data_cal_notify_free_busy (cal, status, freebusy);
+	e_data_cal_notify_free_busy (cal, context, status, freebusy);
 
 	for (l = freebusy; l; l = l->next)
 		g_free (l->data);
diff --git a/calendar/libedata-cal/e-cal-backend-sync.h b/calendar/libedata-cal/e-cal-backend-sync.h
index 6b16519..bf2a0f6 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.h
+++ b/calendar/libedata-cal/e-cal-backend-sync.h
@@ -6,7 +6,6 @@
 #define __E_CAL_BACKEND_SYNC_H__
 
 #include <glib.h>
-#include <libedata-cal/Evolution-DataServer-Calendar.h>
 #include <libedata-cal/e-cal-backend.h>
 
 G_BEGIN_DECLS
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index b572943..42787df 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -31,7 +31,7 @@
 
 
 
-G_DEFINE_TYPE (ECalBackend, e_cal_backend, G_TYPE_OBJECT)
+G_DEFINE_TYPE (ECalBackend, e_cal_backend, G_TYPE_OBJECT);
 
 /* Private part of the CalBackend structure */
 struct _ECalBackendPrivate {
@@ -287,8 +287,7 @@ e_cal_backend_init (ECalBackend *backend)
 	priv->clients_mutex = g_mutex_new ();
 	priv->last_percent_notified = 0;
 
-	/* FIXME bonobo_object_ref/unref? */
-	priv->queries = e_list_new ((EListCopyFunc) bonobo_object_ref, (EListFreeFunc) bonobo_object_unref, NULL);
+	priv->queries = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL);
 	priv->queries_mutex = g_mutex_new ();
 }
 
@@ -384,23 +383,6 @@ e_cal_backend_get_kind (ECalBackend *backend)
 }
 
 static void
-cal_destroy_cb (gpointer data, GObject *where_cal_was)
-{
-	ECalBackend *backend = E_CAL_BACKEND (data);
-
-	e_cal_backend_remove_client (backend, (EDataCal *) where_cal_was);
-}
-
-static void
-listener_died_cb (gpointer cnx, gpointer data)
-{
-	EDataCal *cal = E_DATA_CAL (data);
-
-	if (ORBit_small_get_connection_status (e_data_cal_get_listener(cal)) == ORBIT_CONNECTION_DISCONNECTED)
-		e_cal_backend_remove_client (e_data_cal_get_backend (cal), cal);
-}
-
-static void
 last_client_gone (ECalBackend *backend)
 {
 	g_signal_emit (backend, e_cal_backend_signals[LAST_CLIENT_GONE], 0);
@@ -426,11 +408,14 @@ e_cal_backend_add_client (ECalBackend *backend, EDataCal *cal)
 
 	priv = backend->priv;
 
+	/* TODO: Implement this? */
+#if 0
 	bonobo_object_set_immortal (BONOBO_OBJECT (cal), TRUE);
 
 	g_object_weak_ref (G_OBJECT (cal), cal_destroy_cb, backend);
 
 	ORBit_small_listen_for_broken (e_data_cal_get_listener (cal), G_CALLBACK (listener_died_cb), cal);
+#endif
 
 	g_mutex_lock (priv->clients_mutex);
 	priv->clients = g_list_append (priv->clients, cal);
@@ -538,13 +523,13 @@ e_cal_backend_remove_query (ECalBackend *backend, EDataCalView *query)
  * must already have an open calendar.
  **/
 void
-e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->get_cal_address != NULL);
-	(* CLASS (backend)->get_cal_address) (backend, cal);
+	(* CLASS (backend)->get_cal_address) (backend, cal, context);
 }
 
 void
@@ -564,7 +549,7 @@ e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only)
 }
 
 void
-e_cal_backend_notify_cal_address (ECalBackend *backend, gchar *address)
+e_cal_backend_notify_cal_address (ECalBackend *backend, EServerMethodContext context, gchar *address)
 {
 	ECalBackendPrivate *priv;
 	GList *l;
@@ -572,7 +557,7 @@ e_cal_backend_notify_cal_address (ECalBackend *backend, gchar *address)
 	priv = backend->priv;
 
 	for (l = priv->clients; l; l = l->next)
-		e_data_cal_notify_cal_address (l->data, GNOME_Evolution_Calendar_Success, address);
+		e_data_cal_notify_cal_address (l->data, context, GNOME_Evolution_Calendar_Success, address);
 }
 
 /**
@@ -583,13 +568,13 @@ e_cal_backend_notify_cal_address (ECalBackend *backend, gchar *address)
  * Calls the get_alarm_email_address method on the given backend.
  */
 void
-e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->get_alarm_email_address != NULL);
-	(* CLASS (backend)->get_alarm_email_address) (backend, cal);
+	(* CLASS (backend)->get_alarm_email_address) (backend, cal, context);
 }
 
 /**
@@ -600,13 +585,13 @@ e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal)
  * Calls the get_ldap_attribute method of the given backend.
  */
 void
-e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->get_ldap_attribute != NULL);
-	(* CLASS (backend)->get_ldap_attribute) (backend, cal);
+	(* CLASS (backend)->get_ldap_attribute) (backend, cal, context);
 }
 
 /**
@@ -617,13 +602,13 @@ e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal)
  * Calls the get_static_capabilities method on the given backend.
  */
 void
-e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->get_static_capabilities != NULL);
-	(* CLASS (backend)->get_static_capabilities) (backend, cal);
+	(* CLASS (backend)->get_static_capabilities) (backend, cal, context);
 }
 
 /**
@@ -640,14 +625,14 @@ e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal)
  * URI.
  */
 void
-e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists,
+e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists,
 		    const gchar *username, const gchar *password)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->open != NULL);
-	(* CLASS (backend)->open) (backend, cal, only_if_exists, username, password);
+	(* CLASS (backend)->open) (backend, cal, context, only_if_exists, username, password);
 }
 
 /**
@@ -658,13 +643,13 @@ e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists
  * Removes the calendar being accessed by the given backend.
  */
 void
-e_cal_backend_remove (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->remove != NULL);
-	(* CLASS (backend)->remove) (backend, cal);
+	(* CLASS (backend)->remove) (backend, cal, context);
 }
 
 /**
@@ -772,13 +757,13 @@ e_cal_backend_set_mode (ECalBackend *backend, CalMode mode)
  * Calls the get_default_object method on the given backend.
  */
 void
-e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->get_default_object != NULL);
-	(* CLASS (backend)->get_default_object) (backend, cal);
+	(* CLASS (backend)->get_default_object) (backend, cal, context);
 }
 
 /**
@@ -792,14 +777,14 @@ e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal)
  * identifier and its recurrence ID (if a recurrent appointment).
  */
 void
-e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
+e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (uid != NULL);
 
 	g_assert (CLASS (backend)->get_object != NULL);
-	(* CLASS (backend)->get_object) (backend, cal, uid, rid);
+	(* CLASS (backend)->get_object) (backend, cal, context, uid, rid);
 }
 
 /**
@@ -811,13 +796,13 @@ e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const gchar *uid,
  * Calls the get_object_list method on the given backend.
  */
 void
-e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar *sexp)
+e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 
 	g_assert (CLASS (backend)->get_object_list != NULL);
-	(* CLASS (backend)->get_object_list) (backend, cal, sexp);
+	(* CLASS (backend)->get_object_list) (backend, cal, context, sexp);
 }
 
 /**
@@ -831,14 +816,14 @@ e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar
  * on its unique identifier and its recurrence ID (if a recurrent appointment).
  */
 void
-e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
+e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (uid != NULL);
 
 	g_assert (CLASS (backend)->get_object != NULL);
-	(* CLASS (backend)->get_attachment_list) (backend, cal, uid, rid);
+	(* CLASS (backend)->get_attachment_list) (backend, cal, context, uid, rid);
 }
 
 /**
@@ -852,7 +837,7 @@ e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const gc
  * Gets a free/busy object for the given time interval
  */
 void
-e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end)
+e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
@@ -860,7 +845,7 @@ e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users,
 	g_return_if_fail (start <= end);
 
 	g_assert (CLASS (backend)->get_free_busy != NULL);
-	(* CLASS (backend)->get_free_busy) (backend, cal, users, start, end);
+	(* CLASS (backend)->get_free_busy) (backend, cal, context, users, start, end);
 }
 
 /**
@@ -873,14 +858,14 @@ e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users,
  * the last time the give change_id was seen
  */
 void
-e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *change_id)
+e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *change_id)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (change_id != NULL);
 
 	g_assert (CLASS (backend)->get_changes != NULL);
-	(* CLASS (backend)->get_changes) (backend, cal, change_id);
+	(* CLASS (backend)->get_changes) (backend, cal, context, change_id);
 }
 
 /**
@@ -894,7 +879,7 @@ e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *cha
  * to do whatever is needed to really discard the alarm.
  */
 void
-e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *auid)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
@@ -902,7 +887,7 @@ e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *u
 	g_return_if_fail (auid != NULL);
 
 	g_assert (CLASS (backend)->discard_alarm != NULL);
-	(* CLASS (backend)->discard_alarm) (backend, cal, uid, auid);
+	(* CLASS (backend)->discard_alarm) (backend, cal, context, uid, auid);
 }
 
 /**
@@ -914,16 +899,16 @@ e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *u
  * Calls the create_object method on the given backend.
  */
 void
-e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (calobj != NULL);
 
 	if (CLASS (backend)->create_object)
-		(* CLASS (backend)->create_object) (backend, cal, calobj);
+		(* CLASS (backend)->create_object) (backend, cal, context, calobj);
 	else
-		e_data_cal_notify_object_created (cal, GNOME_Evolution_Calendar_PermissionDenied, NULL, NULL);
+		e_data_cal_notify_object_created (cal, context, PermissionDenied, NULL, NULL);
 }
 
 /**
@@ -936,16 +921,16 @@ e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const gchar *c
  * Calls the modify_object method on the given backend.
  */
 void
-e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod)
+e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj, CalObjModType mod)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (calobj != NULL);
 
 	if (CLASS (backend)->modify_object)
-		(* CLASS (backend)->modify_object) (backend, cal, calobj, mod);
+		(* CLASS (backend)->modify_object) (backend, cal, context, calobj, mod);
 	else
-		e_data_cal_notify_object_removed (cal, GNOME_Evolution_Calendar_PermissionDenied, NULL, NULL, NULL);
+		e_data_cal_notify_object_removed (cal, context, PermissionDenied, NULL, NULL, NULL);
 }
 
 /**
@@ -960,14 +945,14 @@ e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *c
  * clients about the change.
  */
 void
-e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod)
+e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid, CalObjModType mod)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (uid != NULL);
 
 	g_assert (CLASS (backend)->remove_object != NULL);
-	(* CLASS (backend)->remove_object) (backend, cal, uid, rid, mod);
+	(* CLASS (backend)->remove_object) (backend, cal, context, uid, rid, mod);
 }
 
 /**
@@ -979,14 +964,14 @@ e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *u
  * Calls the receive_objects method on the given backend.
  */
 void
-e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (calobj != NULL);
 
 	g_assert (CLASS (backend)->receive_objects != NULL);
-	(* CLASS (backend)->receive_objects) (backend, cal, calobj);
+	(* CLASS (backend)->receive_objects) (backend, cal, context, calobj);
 }
 
 /**
@@ -998,14 +983,14 @@ e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const gchar
  * Calls the send_objects method on the given backend.
  */
 void
-e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (calobj != NULL);
 
 	g_assert (CLASS (backend)->send_objects != NULL);
-	(* CLASS (backend)->send_objects) (backend, cal, calobj);
+	(* CLASS (backend)->send_objects) (backend, cal, context, calobj);
 }
 
 /**
@@ -1019,14 +1004,14 @@ e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *ca
  * can't be found.
  */
 void
-e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
+e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (tzid != NULL);
 
 	g_assert (CLASS (backend)->get_timezone != NULL);
-	(* CLASS (backend)->get_timezone) (backend, cal, tzid);
+	(* CLASS (backend)->get_timezone) (backend, cal, context, tzid);
 }
 
 /**
@@ -1039,13 +1024,13 @@ e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tz
  * DATE and floating DATE-TIME values.
  */
 void
-e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const gchar *tzobj)
+e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (tzobj != NULL);
 
-	(* CLASS (backend)->set_default_zone) (backend, cal, tzobj);
+	(* CLASS (backend)->set_default_zone) (backend, cal, context, tzobj);
 }
 
 /**
@@ -1063,13 +1048,13 @@ e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const gchar
  *
  */
 void
-e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
+e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
 {
 	g_return_if_fail (backend != NULL);
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (tzid != NULL);
 
-	(* CLASS (backend)->set_default_timezone) (backend, cal, tzid);
+	(* CLASS (backend)->set_default_timezone) (backend, cal, context, tzid);
 }
 
 /**
@@ -1081,13 +1066,13 @@ e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const g
  * Add a timezone object to the given backend.
  */
 void
-e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzobj)
+e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj)
 {
 	g_return_if_fail (E_IS_CAL_BACKEND (backend));
 	g_return_if_fail (tzobj != NULL);
 	g_return_if_fail (CLASS (backend)->add_timezone != NULL);
 
-	(* CLASS (backend)->add_timezone) (backend, cal, tzobj);
+	(* CLASS (backend)->add_timezone) (backend, cal, context, tzobj);
 }
 
 /**
@@ -1173,10 +1158,10 @@ e_cal_backend_notify_object_created (ECalBackend *backend, const gchar *calobj)
 	while (e_iterator_is_valid (iter)) {
 		query = QUERY (e_iterator_get (iter));
 
-		bonobo_object_ref (query);
+		g_object_ref (query);
 		if (e_data_cal_view_object_matches (query, calobj))
 			e_data_cal_view_notify_objects_added_1 (query, calobj);
-		bonobo_object_unref (query);
+		g_object_unref (query);
 
 		e_iterator_next (iter);
 	}
@@ -1262,11 +1247,11 @@ e_cal_backend_notify_view_progress (ECalBackend *backend, const gchar *message,
 	while (e_iterator_is_valid (iter)) {
 		query = QUERY (e_iterator_get (iter));
 
-		bonobo_object_ref (query);
+		g_object_ref (query);
 
 		e_data_cal_view_notify_progress (query, message, percent);
 
-		bonobo_object_unref (query);
+		g_object_unref (query);
 
 		e_iterator_next (iter);
 	}
@@ -1301,11 +1286,11 @@ e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_C
 	while (e_iterator_is_valid (iter)) {
 		query = QUERY (e_iterator_get (iter));
 
-		bonobo_object_ref (query);
+		g_object_ref (query);
 
 		e_data_cal_view_notify_done (query, status);
 
-		bonobo_object_unref (query);
+		g_object_unref (query);
 
 		e_iterator_next (iter);
 	}
@@ -1346,9 +1331,9 @@ e_cal_backend_notify_object_modified (ECalBackend *backend,
 	while (e_iterator_is_valid (iter)) {
 		query = QUERY (e_iterator_get (iter));
 
-		bonobo_object_ref (query);
+		g_object_ref (query);
 		match_query_and_notify (query, old_object, object);
-		bonobo_object_unref (query);
+		g_object_unref (query);
 
 		e_iterator_next (iter);
 	}
@@ -1392,7 +1377,7 @@ e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId
 	while (e_iterator_is_valid (iter)) {
 		query = QUERY (e_iterator_get (iter));
 
-		bonobo_object_ref (query);
+		g_object_ref (query);
 
 		if (object == NULL) {
 			/* if object == NULL, it means the object has been completely
@@ -1402,7 +1387,7 @@ e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId
 		} else
 			match_query_and_notify (query, old_object, object);
 
-		bonobo_object_unref (query);
+		g_object_unref (query);
 
 		e_iterator_next (iter);
 	}
@@ -1438,8 +1423,8 @@ e_cal_backend_notify_objects_modified (ECalBackend *backend, EDataCalView *query
  **/
 void
 e_cal_backend_notify_mode (ECalBackend *backend,
-			   GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
-			   GNOME_Evolution_Calendar_CalMode mode)
+			   EDataCalViewListenerSetModeStatus status,
+			   EDataCalMode mode)
 {
 	ECalBackendPrivate *priv = backend->priv;
 	GList *l;
diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h
index ea1fc81..be67b5e 100644
--- a/calendar/libedata-cal/e-cal-backend.h
+++ b/calendar/libedata-cal/e-cal-backend.h
@@ -27,10 +27,10 @@
 #include "libedataserver/e-source.h"
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-component.h>
-#include <libedata-cal/Evolution-DataServer-Calendar.h>
+#include "e-data-cal-common.h"
 #include <libedata-cal/e-data-cal-common.h>
 #include <libedata-cal/e-data-cal.h>
-#include <libedata-cal/e-data-cal-view.h>
+#include "e-data-cal-types.h"
 
 G_BEGIN_DECLS
 
@@ -70,35 +70,35 @@ struct _ECalBackendClass {
 
 	/* Virtual methods */
 	void (* is_read_only) (ECalBackend *backend, EDataCal *cal);
-	void (* get_cal_address) (ECalBackend *backend, EDataCal *cal);
-	void (* get_alarm_email_address) (ECalBackend *backend, EDataCal *cal);
-	void (* get_ldap_attribute) (ECalBackend *backend, EDataCal *cal);
-	void (* get_static_capabilities) (ECalBackend *backend, EDataCal *cal);
+	void (* get_cal_address) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+	void (* get_alarm_email_address) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+	void (* get_ldap_attribute) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+	void (* get_static_capabilities) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
-	void (* open) (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password);
-	void (* remove) (ECalBackend *backend, EDataCal *cal);
+	void (* open) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists, const gchar *username, const gchar *password);
+	void (* remove) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
 	/* Object related virtual methods */
-	void (* create_object) (ECalBackend *backend, EDataCal *cal, const gchar *calobj);
-	void (* modify_object) (ECalBackend *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod);
-	void (* remove_object) (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod);
+	void (* create_object) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
+	void (* modify_object) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj, CalObjModType mod);
+	void (* remove_object) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid, CalObjModType mod);
 
-	void (* discard_alarm) (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *auid);
+	void (* discard_alarm) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *auid);
 
-	void (* receive_objects) (ECalBackend *backend, EDataCal *cal, const gchar *calobj);
-	void (* send_objects) (ECalBackend *backend, EDataCal *cal, const gchar *calobj);
+	void (* receive_objects) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
+	void (* send_objects) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
 
-	void (* get_default_object) (ECalBackend *backend, EDataCal *cal);
-	void (* get_object) (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid);
-	void (* get_object_list) (ECalBackend *backend, EDataCal *cal, const gchar *sexp);
+	void (* get_default_object) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+	void (* get_object) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid);
+	void (* get_object_list) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp);
 
-	void (* get_attachment_list) (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid);
+	void (* get_attachment_list) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid);
 
 	/* Timezone related virtual methods */
-	void (* get_timezone) (ECalBackend *backend, EDataCal *cal, const gchar *tzid);
-	void (* add_timezone) (ECalBackend *backend, EDataCal *cal, const gchar *object);
-	void (* set_default_zone) (ECalBackend *backend, EDataCal *cal, const gchar *tzobj);
-	void (* set_default_timezone) (ECalBackend *backend, EDataCal *cal, const gchar *tzid);
+	void (* get_timezone) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid);
+	void (* add_timezone) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *object);
+	void (* set_default_zone) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj);
+	void (* set_default_timezone) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid);
 
 	void (* start_query) (ECalBackend *backend, EDataCalView *query);
 
@@ -106,8 +106,8 @@ struct _ECalBackendClass {
 	CalMode (* get_mode) (ECalBackend *backend);
 	void    (* set_mode) (ECalBackend *backend, CalMode mode);
 
-	void (* get_free_busy) (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end);
-	void (* get_changes) (ECalBackend *backend, EDataCal *cal, const gchar *change_id);
+	void (* get_free_busy) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end);
+	void (* get_changes) (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *change_id);
 
 	/* Internal methods for use only in the pcs */
 	icaltimezone *(* internal_get_default_timezone) (ECalBackend *backend);
@@ -128,28 +128,27 @@ EList *e_cal_backend_get_queries (ECalBackend *backend);
 void e_cal_backend_remove_query (ECalBackend *backend, EDataCalView *query);
 
 void e_cal_backend_is_read_only (ECalBackend *backend, EDataCal *cal);
-void e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal);
-void e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal);
-void e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal);
-void e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal);
+void e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+void e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+void e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+void e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
-void e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password);
-void e_cal_backend_remove (ECalBackend *backend, EDataCal *cal);
+void e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists, const gchar *username, const gchar *password);
+void e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
 
-void e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj);
-void e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod);
-void e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod);
+void e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
+void e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj, CalObjModType mod);
+void e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid, CalObjModType mod);
 
-void e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *auid);
+void e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *auid);
 
-void e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj);
-void e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj);
+void e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
+void e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj);
 
-void e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal);
-void e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid);
-void e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar *sexp);
-
-void e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid);
+void e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context);
+void e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid);
+void e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp);
+void e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid);
 
 gboolean e_cal_backend_is_loaded (ECalBackend *backend);
 
@@ -158,13 +157,13 @@ void e_cal_backend_start_query (ECalBackend *backend, EDataCalView *query);
 CalMode e_cal_backend_get_mode (ECalBackend *backend);
 void e_cal_backend_set_mode (ECalBackend *backend, CalMode mode);
 
-void e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid);
-void e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const gchar *object);
-void e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid);
-void e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const gchar *tzobj);
+void e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid);
+void e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *object);
+void e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid);
+void e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj);
 
-void e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *change_id);
-void e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end);
+void e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *change_id);
+void e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end);
 
 icaltimezone* e_cal_backend_internal_get_default_timezone (ECalBackend *backend);
 icaltimezone* e_cal_backend_internal_get_timezone (ECalBackend *backend, const gchar *tzid);
@@ -175,16 +174,16 @@ void e_cal_backend_notify_object_modified (ECalBackend *backend, const gchar *ol
 void e_cal_backend_notify_object_removed  (ECalBackend *backend, const ECalComponentId *id, const gchar *old_object, const gchar *object);
 
 void e_cal_backend_notify_mode      (ECalBackend *backend,
-				     GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
-				     GNOME_Evolution_Calendar_CalMode mode);
+				     EDataCalViewListenerSetModeStatus status,
+				     EDataCalMode mode);
 void e_cal_backend_notify_auth_required (ECalBackend *backend);
 void e_cal_backend_notify_error     (ECalBackend *backend, const gchar *message);
 
-void e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_CallStatus status);
+void e_cal_backend_notify_view_done (ECalBackend *backend, EDataCalCallStatus status);
 void e_cal_backend_notify_view_progress_start (ECalBackend *backend);
 void e_cal_backend_notify_view_progress (ECalBackend *backend, const gchar *message, gint percent);
 void e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only);
-void e_cal_backend_notify_cal_address (ECalBackend *backend, gchar *address);
+void e_cal_backend_notify_cal_address (ECalBackend *backend, EServerMethodContext context, gchar *address);
 
 void e_cal_backend_notify_objects_added (ECalBackend *backend, EDataCalView *query, const GList *objects);
 void e_cal_backend_notify_objects_removed (ECalBackend *backend, EDataCalView *query, const GList *ids);
diff --git a/calendar/libedata-cal/e-data-cal-common.h b/calendar/libedata-cal/e-data-cal-common.h
index e03fc15..e81fb34 100644
--- a/calendar/libedata-cal/e-data-cal-common.h
+++ b/calendar/libedata-cal/e-data-cal-common.h
@@ -39,6 +39,9 @@ typedef struct _EDataCalViewClass EDataCalViewClass;
 typedef struct _ECalBackendSExp ECalBackendSExp;
 typedef struct _ECalBackendSExpClass ECalBackendSExpClass;
 
+/* Opaque type for backend method context */
+typedef gpointer EServerMethodContext;
+
 
 
 G_END_DECLS
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 5ca2f29..e143a5b 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -1,10 +1,12 @@
 /* Evolution calendar factory
  *
  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
  *
  * Authors:
  *   Federico Mena-Quintero <federico ximian com>
  *   JP Rosevear <jpr ximian com>
+ *   Ross Burton <ross linux intel com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU Lesser General Public
@@ -20,68 +22,87 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-main.h>
+#include <config.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+
 #include "libedataserver/e-url.h"
 #include "libedataserver/e-source.h"
 #include "libedataserver/e-source-list.h"
 #include "libebackend/e-data-server-module.h"
 #include "libecal/e-cal.h"
 #include "e-cal-backend.h"
+#include "e-cal-backend-factory.h"
 #include "e-data-cal.h"
 #include "e-data-cal-factory.h"
+#include "e-cal-backend-loader-factory.h"
+
+static gboolean impl_CalFactory_getCal (EDataCalFactory *factory, const char *IN_uri, EDataCalObjType type, char **OUT_calendar, GError **error);
+#include "e-data-cal-factory-glue.h"
+
+static gchar *nm_dbus_escape_object_path (const gchar *utf8_string);
+
+static GMainLoop *loop;
+static EDataCalFactory *factory;
+extern DBusGConnection *connection;
+
+/* Convenience macro to test and set a GError/return on failure */
+#define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
+ if G_LIKELY (test) {} else { \
+   g_set_error (error, domain, code, #test); \
+   g_warning(#test " failed"); \
+   return (returnval); \
+ } \
+}G_STMT_END
 
-#define PARENT_TYPE                BONOBO_TYPE_OBJECT
-#define DEFAULT_E_DATA_CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_DataServer_CalFactory:" BASE_VERSION
+G_DEFINE_TYPE(EDataCalFactory, e_data_cal_factory, G_TYPE_OBJECT);
 
-static BonoboObjectClass *parent_class;
+#define E_DATA_CAL_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_DATA_CAL_FACTORY, EDataCalFactoryPrivate))
 
-/* Private part of the CalFactory structure */
 struct _EDataCalFactoryPrivate {
 	/* Hash table from URI method strings to GType * for backend class types */
 	GHashTable *methods;
 
-	/* Hash table from GnomeVFSURI structures to CalBackend objects */
 	GHashTable *backends;
 	/* mutex to access backends hash table */
 	GMutex *backends_mutex;
 
-	/* OAFIID of the factory */
-	gchar *iid;
-
-	/* Whether we have been registered with OAF yet */
-	guint registered : 1;
-
-        gint mode;
+	gint mode;
 
 	/* this is for notifications of source changes */
 	ESourceList *lists[E_CAL_SOURCE_TYPE_LAST];
 
 	/* backends divided by their type */
 	GSList *backends_by_type[E_CAL_SOURCE_TYPE_LAST];
-};
 
-/* Signal IDs */
-enum SIGNALS {
-	LAST_CALENDAR_GONE,
-	LAST_SIGNAL
+	guint exit_timeout;
 };
 
-static guint signals[LAST_SIGNAL];
-
-/* Opening calendars */
+/* Create the EDataCalFactory error quark */
+GQuark
+e_data_cal_factory_error_quark (void)
+{
+  static GQuark quark = 0;
+  if (!quark)
+    quark = g_quark_from_static_string ("e_data_cal_factory_error");
+  return quark;
+}
 
 static icalcomponent_kind
-calobjtype_to_icalkind (const GNOME_Evolution_Calendar_CalObjType type)
+calobjtype_to_icalkind (const EDataCalObjType type)
 {
-	switch (type) {
-	case GNOME_Evolution_Calendar_TYPE_EVENT:
+	switch (type){
+	case Event:
 		return ICAL_VEVENT_COMPONENT;
-	case GNOME_Evolution_Calendar_TYPE_TODO:
+	case Todo:
 		return ICAL_VTODO_COMPONENT;
-	case GNOME_Evolution_Calendar_TYPE_JOURNAL:
+	case Journal:
 		return ICAL_VJOURNAL_COMPONENT;
+	case AnyType:
+		return ICAL_NO_COMPONENT;
 	}
 
 	return ICAL_NO_COMPONENT;
@@ -155,7 +176,7 @@ source_list_changed_cb (ESourceList *list, EDataCalFactory *factory)
 	g_mutex_unlock (priv->backends_mutex);
 }
 
-static ECalBackendFactory*
+static ECalBackendFactory *
 get_backend_factory (GHashTable *methods, const gchar *method, icalcomponent_kind kind)
 {
 	GHashTable *kinds;
@@ -171,6 +192,35 @@ get_backend_factory (GHashTable *methods, const gchar *method, icalcomponent_kin
 	return factory;
 }
 
+static gchar *
+make_path_name (const gchar* uri)
+{
+  gchar *s, *path;
+  s = nm_dbus_escape_object_path (uri);
+  path = g_strdup_printf ("/org/gnome/evolution/dataserver/calendar/%s", s);
+  g_free (s);
+  return path;
+}
+
+static void
+my_remove (gchar *key, GObject *dead)
+{
+#warning TODO
+#if 0
+  EDataCalFactoryPrivate *priv = factory->priv;
+  g_mutex_lock (priv->calendars_lock);
+  g_hash_table_remove (priv->calendars, key);
+  g_mutex_unlock (priv->calendars_lock);
+  g_free (key);
+
+  /* If there are no open books, start a timer to quit */
+  if (priv->exit_timeout == 0 && g_hash_table_size (priv->calendars) == 0) {
+    priv->exit_timeout = g_timeout_add (10000, (GSourceFunc)g_main_loop_quit, loop);
+  }
+#endif
+}
+
+#if 0
 /* Callback used when a backend loses its last connected client */
 static void
 backend_last_client_gone_cb (ECalBackend *backend, gpointer data)
@@ -181,9 +231,6 @@ backend_last_client_gone_cb (ECalBackend *backend, gpointer data)
 	ECalSourceType st;
 	ESource *source;
 	gchar *uid_type_string;
-	gboolean last_calendar;
-
-	fprintf (stderr, "backend_last_client_gone_cb() called!\n");
 
 	factory = E_DATA_CAL_FACTORY (data);
 	priv = factory->priv;
@@ -211,70 +258,66 @@ backend_last_client_gone_cb (ECalBackend *backend, gpointer data)
 	g_signal_handlers_disconnect_matched (backend, G_SIGNAL_MATCH_DATA,
 					      0, 0, NULL, NULL, data);
 
-	last_calendar = (g_hash_table_size (priv->backends) == 0);
-
 	g_mutex_unlock (priv->backends_mutex);
-
-	/* Notify upstream if there are no more backends */
-	if (last_calendar)
-		g_signal_emit (G_OBJECT (factory), signals[LAST_CALENDAR_GONE], 0);
 }
-
-
-
-static GNOME_Evolution_Calendar_Cal
-impl_CalFactory_getCal (PortableServer_Servant servant,
-			const CORBA_char *source_xml,
-			const GNOME_Evolution_Calendar_CalObjType type,
-			const GNOME_Evolution_Calendar_CalListener listener,
-			CORBA_Environment *ev)
+#endif
+
+/* TODO: Error checking! */
+static gboolean
+impl_CalFactory_getCal (EDataCalFactory *factory,
+                        const gchar *source_xml,
+                        EDataCalObjType type,
+                        gchar **calendar_path,
+                        GError **error)
 {
-	GNOME_Evolution_Calendar_Cal ret_cal = CORBA_OBJECT_NIL;
-	EDataCalFactory *factory;
-	EDataCalFactoryPrivate *priv;
-	EDataCal *cal = CORBA_OBJECT_NIL;
-	ECalBackend *backend;
-	ECalBackendFactory *backend_factory;
+	EDataCal *calendar;
+	EDataCalFactoryPrivate *priv = factory->priv;
+        ECalBackendFactory *backend_factory;
+        ECalBackend *backend;
 	ESource *source;
 	gchar *str_uri;
 	EUri *uri;
 	gchar *uid_type_string;
+	gchar *path;
 
-	factory = E_DATA_CAL_FACTORY (bonobo_object_from_servant (servant));
-	priv = factory->priv;
+	g_set_error_val_if_fail (source_xml != NULL, FALSE, error, E_DATA_CAL_FACTORY_ERROR, E_DATA_CAL_FACTORY_ERROR_GENERIC);
+	g_set_error_val_if_fail (calendar_path != NULL, FALSE, error, E_DATA_CAL_FACTORY_ERROR, E_DATA_CAL_FACTORY_ERROR_GENERIC);
+
+	/* Remove a pending exit */
+	if (priv->exit_timeout) {
+		g_source_remove (priv->exit_timeout);
+		priv->exit_timeout = 0;
+	}
 
 	source = e_source_new_from_standalone_xml (source_xml);
 	if (!source) {
-		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI);
-
-		return CORBA_OBJECT_NIL;
+		/* TODO ERROR */
+		return FALSE;
 	}
 
 	/* Get the URI so we can extract the protocol */
 	str_uri = e_source_get_uri (source);
 	if (!str_uri) {
 		g_object_unref (source);
-		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI);
 
-		return CORBA_OBJECT_NIL;
+		/* TODO ERROR */
+		return FALSE;
 	}
 
 	/* Parse the uri */
 	uri = e_uri_new (str_uri);
 	if (!uri) {
-		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI);
-
-		return CORBA_OBJECT_NIL;
+		/* TODO ERROR */
+		return FALSE;
 	}
 
-	g_free (str_uri);
 	uid_type_string = g_strdup_printf ("%s:%d", e_source_peek_uid (source), (gint)calobjtype_to_icalkind (type));
 
 	/* Find the associated backend factory (if any) */
 	backend_factory = get_backend_factory (priv->methods, uri->protocol, calobjtype_to_icalkind (type));
 	if (!backend_factory) {
 		/* FIXME Distinguish between method and kind failures? */
-		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod);
+		/* TODO ERROR */
 		goto cleanup2;
 	}
 
@@ -294,7 +337,7 @@ impl_CalFactory_getCal (PortableServer_Servant servant,
 
 		if (!backend) {
 			g_warning (G_STRLOC ": could not instantiate backend");
-			bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod);
+		/* TODO ERROR */
 			goto cleanup;
 		}
 
@@ -311,25 +354,19 @@ impl_CalFactory_getCal (PortableServer_Servant servant,
 		/* Track the backend */
 		g_hash_table_insert (priv->backends, g_strdup (uid_type_string), backend);
 
-		g_signal_connect (G_OBJECT (backend), "last_client_gone",
-				  G_CALLBACK (backend_last_client_gone_cb),
-				  factory);
 	} else if (!e_source_equal (source, e_cal_backend_get_source (backend))) {
 		/* source changed, update it in a backend */
 		update_source_in_backend (backend, source);
 	}
 
-	/* Create the corba calendar */
-	cal = e_data_cal_new (backend, listener);
-	if (cal) {
-		/* Let the backend know about its clients corba clients */
-		e_cal_backend_add_client (backend, cal);
-		e_cal_backend_set_mode (backend, priv->mode);
-		ret_cal = bonobo_object_corba_objref (BONOBO_OBJECT (cal));
-	} else {
-		g_warning (G_STRLOC ": could not create the corba calendar");
-		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod);
-	}
+	calendar = e_data_cal_new (backend, source);
+	e_cal_backend_add_client (backend, calendar);
+	e_cal_backend_set_mode (backend, priv->mode);
+
+	path = make_path_name (str_uri);
+	dbus_g_connection_register_g_object (connection, path, G_OBJECT (calendar));
+	g_object_weak_ref (G_OBJECT (calendar), (GWeakNotify)my_remove, g_strdup (path));
+	*calendar_path = path;
 
  cleanup:
 	/* The reason why the lock is held for such a long time is that there is
@@ -338,104 +375,36 @@ impl_CalFactory_getCal (PortableServer_Servant servant,
 	   backend_last_client_gone_cb(), for details see bug 506457. */
 	g_mutex_unlock (priv->backends_mutex);
  cleanup2:
+	g_free (str_uri);
 	e_uri_free (uri);
 	g_free (uid_type_string);
 	g_object_unref (source);
 
-	return ret_cal;
+	return TRUE;
 }
 
-/**
- * e_data_cal_factory_new:
- * @void:
- *
- * Creates a new #EDataCalFactory object.
- *
- * Return value: A newly-created #EDataCalFactory, or NULL if its corresponding CORBA
- * object could not be created.
- **/
-EDataCalFactory *
-e_data_cal_factory_new (void)
-{
-	EDataCalFactory *factory;
-
-	factory = g_object_new (E_TYPE_DATA_CAL_FACTORY,
-				"poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
-				NULL);
-
-	return factory;
-}
-
-/* Destroy handler for the calendar */
+/* Class initialization function for the calendar factory */
 static void
-e_data_cal_factory_finalize (GObject *object)
+e_data_cal_factory_class_init (EDataCalFactoryClass *klass)
 {
-	EDataCalFactory *factory;
-	EDataCalFactoryPrivate *priv;
-	gint i;
-
-	g_return_if_fail (object != NULL);
-	g_return_if_fail (E_IS_DATA_CAL_FACTORY (object));
-
-	factory = E_DATA_CAL_FACTORY (object);
-	priv = factory->priv;
-
-	g_hash_table_destroy (priv->methods);
-	priv->methods = NULL;
-
-	/* Should we assert that there are no more backends? */
-	g_hash_table_destroy (priv->backends);
-	g_mutex_free (priv->backends_mutex);
-	priv->backends = NULL;
-
-	if (priv->registered) {
-		bonobo_activation_active_server_unregister (priv->iid, BONOBO_OBJREF (factory));
-		priv->registered = FALSE;
-	}
-	g_free (priv->iid);
-
-	for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
-		if (priv->lists[i]) {
-			g_object_unref (priv->lists[i]);
-			priv->lists[i] = NULL;
-		}
-
-		if (priv->backends_by_type[i]) {
-			g_slist_free (priv->backends_by_type[i]);
-			priv->backends_by_type[i] = NULL;
-		}
-	}
-
-	g_free (priv);
-	factory->priv = NULL;
-
-	if (G_OBJECT_CLASS (parent_class)->finalize)
-		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
+  g_type_class_add_private (klass, sizeof (EDataCalFactoryPrivate));
+  dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_e_data_cal_factory_object_info);
 }
 
-/* Class initialization function for the calendar factory */
+/* Instance init */
 static void
-e_data_cal_factory_class_init (EDataCalFactoryClass *klass)
+e_data_cal_factory_init (EDataCalFactory *factory)
 {
-	GObjectClass *object_class = (GObjectClass *) klass;
-	POA_GNOME_Evolution_Calendar_CalFactory__epv *epv = &klass->epv;
-
-	parent_class = g_type_class_peek_parent (klass);
+  factory->priv = E_DATA_CAL_FACTORY_GET_PRIVATE (factory);
 
-	signals[LAST_CALENDAR_GONE] =
-		g_signal_new ("last_calendar_gone",
-			      G_TYPE_FROM_CLASS (klass),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (EDataCalFactoryClass, last_calendar_gone),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE, 0);
+  factory->priv->methods = g_hash_table_new_full (g_str_hash, g_str_equal,
+						(GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_destroy);
 
-	/* Class method overrides */
-	object_class->finalize = e_data_cal_factory_finalize;
+  factory->priv->backends_mutex = g_mutex_new ();
+  factory->priv->backends = g_hash_table_new (g_str_hash, g_str_equal);
 
-	/* Epv methods */
-	epv->getCal = impl_CalFactory_getCal;
+  e_data_server_module_init ();
+  e_data_cal_factory_register_backends (factory);
 }
 
 static void
@@ -464,85 +433,6 @@ e_data_cal_factory_set_backend_mode (EDataCalFactory *factory, gint mode)
 	g_mutex_unlock (priv->backends_mutex);
 }
 
-/* Object initialization function for the calendar factory */
-static void
-e_data_cal_factory_init (EDataCalFactory *factory, EDataCalFactoryClass *klass)
-{
-	EDataCalFactoryPrivate *priv;
-
-	priv = g_new0 (EDataCalFactoryPrivate, 1);
-	factory->priv = priv;
-
-	priv->methods = g_hash_table_new_full (g_str_hash, g_str_equal,
-					       (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_destroy);
-	priv->backends = g_hash_table_new_full (g_str_hash, g_str_equal,
-						(GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
-	priv->registered = FALSE;
-	priv->backends_mutex = g_mutex_new ();
-}
-
-BONOBO_TYPE_FUNC_FULL (EDataCalFactory,
-		       GNOME_Evolution_Calendar_CalFactory,
-		       PARENT_TYPE,
-		       e_data_cal_factory)
-
-/**
- * e_data_cal_factory_register_storage:
- * @factory: A calendar factory.
- * @iid: OAFIID for the factory to be registered.
- *
- * Registers a calendar factory with the OAF object activation daemon.  This
- * function must be called before any clients can activate the factory.
- *
- * Return value: TRUE on success, FALSE otherwise.
- **/
-gboolean
-e_data_cal_factory_register_storage (EDataCalFactory *factory, const gchar *iid)
-{
-	EDataCalFactoryPrivate *priv;
-	Bonobo_RegistrationResult result;
-	gchar *tmp_iid;
-
-	g_return_val_if_fail (factory != NULL, FALSE);
-	g_return_val_if_fail (E_IS_DATA_CAL_FACTORY (factory), FALSE);
-
-	priv = factory->priv;
-
-	g_return_val_if_fail (!priv->registered, FALSE);
-
-	/* if iid is NULL, use the default factory OAFIID */
-	if (iid)
-		tmp_iid = g_strdup (iid);
-	else
-		tmp_iid = g_strdup (DEFAULT_E_DATA_CAL_FACTORY_OAF_ID);
-
-	result = bonobo_activation_active_server_register (tmp_iid, BONOBO_OBJREF (factory));
-
-	switch (result) {
-	case Bonobo_ACTIVATION_REG_SUCCESS:
-		priv->registered = TRUE;
-		priv->iid = tmp_iid;
-		return TRUE;
-
-	case Bonobo_ACTIVATION_REG_NOT_LISTED:
-		g_warning (G_STRLOC ": cannot register the calendar factory %s (not listed)", tmp_iid);
-		break;
-
-	case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE:
-		g_warning (G_STRLOC ": cannot register the calendar factory (already active)");
-		break;
-
-	case Bonobo_ACTIVATION_REG_ERROR:
-	default:
-		g_warning (G_STRLOC ": cannot register the calendar factory (generic error)");
-		break;
-	}
-
-	g_free (tmp_iid);
-
-	return FALSE;
-}
-
 /**
  * e_data_cal_factory_register_backend:
  * @factory: A calendar factory.
@@ -629,6 +519,7 @@ e_data_cal_factory_register_backends (EDataCalFactory *cal_factory)
 	}
 
 	e_data_server_extension_list_free (factories);
+	e_data_server_module_remove_unused ();
 }
 
 /**
@@ -687,3 +578,93 @@ e_data_cal_factory_dump_active_backends (EDataCalFactory *factory)
 	g_hash_table_foreach (priv->backends, dump_backend, NULL);
 	g_mutex_unlock (priv->backends_mutex);
 }
+
+/* Convenience function to print an error and exit */
+static void
+die (const char *prefix, GError *error)
+{
+  g_error("%s: %s", prefix, error->message);
+  g_error_free (error);
+  exit(1);
+}
+
+#define E_DATA_CAL_FACTORY_SERVICE_NAME "org.gnome.evolution.dataserver.Calendar"
+
+int
+main (gint argc, gchar **argv)
+{
+  GError *error = NULL;
+  DBusGProxy *bus_proxy;
+  guint32 request_name_ret;
+
+  g_type_init ();
+  if (!g_thread_supported ()) g_thread_init (NULL);
+  dbus_g_thread_init ();
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  /* Obtain a connection to the session bus */
+  connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (connection == NULL)
+    die ("Failed to open connection to bus", error);
+
+  bus_proxy = dbus_g_proxy_new_for_name (connection,
+                                            DBUS_SERVICE_DBUS,
+                                            DBUS_PATH_DBUS,
+                                            DBUS_INTERFACE_DBUS);
+
+  if (!org_freedesktop_DBus_request_name (bus_proxy, E_DATA_CAL_FACTORY_SERVICE_NAME,
+					  0, &request_name_ret, &error))
+    die ("Failed to get name", error);
+
+  if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+    g_error ("Got result code %u from requesting name", request_name_ret);
+    exit (1);
+  }
+
+  factory = g_object_new (E_TYPE_DATA_CAL_FACTORY, NULL);
+  dbus_g_connection_register_g_object (connection,
+                                       "/org/gnome/evolution/dataserver/calendar/CalFactory",
+                                       G_OBJECT (factory));
+
+  g_main_loop_run (loop);
+
+  dbus_g_connection_unref (connection);
+
+  return 0;
+}
+
+/* Stolen from http://cvs.gnome.org/viewcvs/NetworkManager/utils/nm-utils.c */
+static gchar *
+nm_dbus_escape_object_path (const gchar *utf8_string)
+{
+	const gchar *p;
+	GString *string;
+
+	g_return_val_if_fail (utf8_string != NULL, NULL);
+	g_return_val_if_fail (g_utf8_validate (utf8_string, -1, NULL), NULL);
+
+	string = g_string_sized_new ((strlen (utf8_string) + 1) * 2);
+
+	for (p = utf8_string; *p != '\0'; p = g_utf8_next_char (p))
+	{
+		gunichar character;
+
+		character = g_utf8_get_char (p);
+
+		if (((character >= ((gunichar) 'a')) &&
+		     (character <= ((gunichar) 'z'))) ||
+		    ((character >= ((gunichar) 'A')) &&
+		     (character <= ((gunichar) 'Z'))) ||
+		    ((character >= ((gunichar) '0')) &&
+		     (character <= ((gunichar) '9'))))
+		{
+			g_string_append_c (string, (gchar) character);
+			continue;
+		}
+
+		g_string_append_printf (string, "_%x_", character);
+	}
+
+	return g_string_free (string, FALSE);
+}
diff --git a/calendar/libedata-cal/e-data-cal-factory.h b/calendar/libedata-cal/e-data-cal-factory.h
index 19641a5..cd5afe6 100644
--- a/calendar/libedata-cal/e-data-cal-factory.h
+++ b/calendar/libedata-cal/e-data-cal-factory.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /* Evolution calendar factory
  *
  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
@@ -21,10 +22,7 @@
 #ifndef E_DATA_CAL_FACTORY_H
 #define E_DATA_CAL_FACTORY_H
 
-#include <bonobo/bonobo-object.h>
-#include <libical/ical.h>
-#include <libedata-cal/Evolution-DataServer-Calendar.h>
-#include <libedata-cal/e-cal-backend-loader-factory.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
@@ -42,25 +40,23 @@ typedef struct _EDataCalFactoryClass EDataCalFactoryClass;
 typedef struct _EDataCalFactoryPrivate EDataCalFactoryPrivate;
 
 struct _EDataCalFactory {
-	BonoboObject object;
-
-	/* Private data */
+	GObject parent;
 	EDataCalFactoryPrivate *priv;
 };
 
 struct _EDataCalFactoryClass {
-	BonoboObjectClass parent_class;
+	GObjectClass parent;
+};
 
-	POA_GNOME_Evolution_Calendar_CalFactory__epv epv;
+typedef enum {
+	E_DATA_CAL_FACTORY_ERROR_GENERIC
+} EDataCalFactoryError;
 
-	/* Notification signals */
-	void (* last_calendar_gone) (EDataCalFactory *factory);
-};
+GQuark e_data_cal_factory_error_quark (void);
+#define E_DATA_CAL_FACTORY_ERROR e_data_cal_factory_error_quark ()
 
 GType       e_data_cal_factory_get_type        (void);
-EDataCalFactory *e_data_cal_factory_new             (void);
 
-gboolean    e_data_cal_factory_register_storage (EDataCalFactory *factory, const gchar *iid);
 void        e_data_cal_factory_register_backend  (EDataCalFactory *factory,
 						  ECalBackendFactory *backend_factory);
 
diff --git a/calendar/libedata-cal/e-data-cal-factory.xml b/calendar/libedata-cal/e-data-cal-factory.xml
new file mode 100644
index 0000000..d0c669c
--- /dev/null
+++ b/calendar/libedata-cal/e-data-cal-factory.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/org/gnome/evolution/dataserver/calendar/CalFactory">
+
+	<interface name="org.gnome.evolution.dataserver.calendar.CalFactory">
+		<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EDataCalFactory"/>
+		<annotation name="org.freedesktop.DBus.GLib.Singleton" value="true"/>
+		
+		<method name="getCal">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_CalFactory_getCal"/>
+			<arg name="source" type="s" direction="in"/>
+			<arg name="type" type="u" direction="in"/>
+			<arg name="path" type="o" direction="out"/>
+		</method>
+	</interface>
+</node>
diff --git a/calendar/libedata-cal/e-data-cal-marshal.list b/calendar/libedata-cal/e-data-cal-marshal.list
new file mode 100644
index 0000000..17c4a78
--- /dev/null
+++ b/calendar/libedata-cal/e-data-cal-marshal.list
@@ -0,0 +1 @@
+NONE:STRING,UINT
diff --git a/calendar/libedata-cal/e-data-cal-types.h b/calendar/libedata-cal/e-data-cal-types.h
new file mode 100644
index 0000000..c36251f
--- /dev/null
+++ b/calendar/libedata-cal/e-data-cal-types.h
@@ -0,0 +1,106 @@
+
+#ifndef __E_DATA_CAL_TYPES_H__
+#define __E_DATA_CAL_TYPES_H__
+
+G_BEGIN_DECLS
+
+typedef enum {
+	Success,
+	RepositoryOffline,
+	PermissionDenied,
+	InvalidRange,
+	ObjectNotFound,
+	InvalidObject,
+	ObjectIdAlreadyExists,
+	AuthenticationFailed,
+	AuthenticationRequired,
+	UnsupportedField,
+	UnsupportedMethod,
+	UnsupportedAuthenticationMethod,
+	TLSNotAvailable,
+	NoSuchCal,
+	UnknownUser,
+	OfflineUnavailable,
+
+	/* These can be returned for successful searches, but
+		indicate the result set was truncated */
+	SearchSizeLimitExceeded,
+	SearchTimeLimitExceeded,
+
+	InvalidQuery,
+	QueryRefused,
+
+	CouldNotCancel,
+	
+	OtherError,
+	InvalidServerVersion
+	
+} EDataCalCallStatus;
+
+/* Some hacks so the backends compile without change */
+/* TODO: Find out how many of these are necessary */
+#define GNOME_Evolution_Calendar_CallStatus EDataCalCallStatus
+#define GNOME_Evolution_Calendar_Success Success
+#define GNOME_Evolution_Calendar_RepositoryOffline RepositoryOffline
+#define GNOME_Evolution_Calendar_PermissionDenied PermissionDenied
+#define GNOME_Evolution_Calendar_InvalidRange InvalidRange
+#define GNOME_Evolution_Calendar_ObjectNotFound ObjectNotFound
+#define GNOME_Evolution_Calendar_InvalidObject InvalidObject
+#define GNOME_Evolution_Calendar_ObjectIdAlreadyExists ObjectIdAlreadyExists
+#define GNOME_Evolution_Calendar_AuthenticationFailed AuthenticationFailed
+#define GNOME_Evolution_Calendar_AuthenticationRequired AuthenticationRequired
+#define GNOME_Evolution_Calendar_UnsupportedField UnsupportedField
+#define GNOME_Evolution_Calendar_UnsupportedMethod UnsupportedMethod
+#define GNOME_Evolution_Calendar_UnsupportedAuthenticationMethod UnsupportedAuthenticationMethod
+#define GNOME_Evolution_Calendar_TLSNotAvailable TLSNotAvailable
+#define GNOME_Evolution_Calendar_NoSuchCal NoSuchCal
+#define GNOME_Evolution_Calendar_UnknownUser UnknownUser
+#define GNOME_Evolution_Calendar_OfflineUnavailable OfflineUnavailable
+#define GNOME_Evolution_Calendar_SearchSizeLimitExceeded SearchSizeLimitExceeded
+#define GNOME_Evolution_Calendar_SearchTimeLimitExceeded SearchTimeLimitExceeded
+#define GNOME_Evolution_Calendar_InvalidQuery InvalidQuery
+#define GNOME_Evolution_Calendar_QueryRefused QueryRefused
+#define GNOME_Evolution_Calendar_CouldNotCancel CouldNotCancel
+#define GNOME_Evolution_Calendar_OtherError OtherError
+#define GNOME_Evolution_Calendar_InvalidServerVersion InvalidServerVersion
+
+typedef enum {
+	Set,                    /* All OK */
+	NotSet,                /* Generic error */
+	NotSupported           /* Mode not supported */
+} EDataCalViewListenerSetModeStatus;
+
+#define GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED NotSupported
+#define GNOME_Evolution_Calendar_CalListener_MODE_NOT_SET NotSet
+#define GNOME_Evolution_Calendar_CalListener_MODE_SET Set
+
+typedef enum {
+	Event = 1 << 0,
+	Todo = 1 << 1,
+	Journal = 1 << 2,
+	AnyType = 0x07
+} EDataCalObjType;
+
+#define GNOME_Evolution_Calendar_CalObjType EDataCalObjType
+
+typedef enum {
+	This = 1 << 0,
+	ThisAndPrior = 1 << 1,
+	ThisAndFuture = 1 << 2,
+	All = 0x07
+} EDataCalObjModType;
+
+typedef enum {
+	Local = 1 << 0,
+	Remote = 1 << 1,
+	AnyMode = 0x07
+} EDataCalMode;
+
+#define GNOME_Evolution_Calendar_CalMode EDataCalMode
+#define GNOME_Evolution_Calendar_MODE_LOCAL Local
+#define GNOME_Evolution_Calendar_MODE_REMOTE Remote
+#define GNOME_Evolution_Calendar_MODE_ANY AnyMode
+
+G_END_DECLS
+
+#endif /* __E_DATA_CAL_TYPES_H__ */
diff --git a/calendar/libedata-cal/e-data-cal-view.c b/calendar/libedata-cal/e-data-cal-view.c
index cdae589..f64b0cc 100644
--- a/calendar/libedata-cal/e-data-cal-view.c
+++ b/calendar/libedata-cal/e-data-cal-view.c
@@ -1,8 +1,11 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /* Evolution calendar - Live search query implementation
  *
  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
  *
- * Author: Federico Mena-Quintero <federico ximian com>
+ * Authors: Federico Mena-Quintero <federico ximian com>
+ *          Ross Burton <ross linux intel com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU Lesser General Public
@@ -24,256 +27,318 @@
 
 #include <string.h>
 #include <glib.h>
-#include <bonobo/bonobo-exception.h>
-#include "libedataserver/e-component-listener.h"
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+
 #include "e-cal-backend-sexp.h"
 #include "e-data-cal-view.h"
+#include "e-data-cal-marshal.h"
 
-
+extern DBusGConnection *connection;
 
-typedef struct {
-	GNOME_Evolution_Calendar_CalViewListener listener;
-	EComponentListener *component_listener;
+static gboolean impl_EDataCalView_start (EDataCalView *query, GError **error);
+#include "e-data-cal-view-glue.h"
 
-	gboolean notified_start;
-	gboolean notified_done;
-} ListenerData;
+#define THRESHOLD 32
 
-/* Private part of the Query structure */
 struct _EDataCalViewPrivate {
 	/* The backend we are monitoring */
 	ECalBackend *backend;
 
 	gboolean started;
 	gboolean done;
-	GNOME_Evolution_Calendar_CallStatus done_status;
-
-	GHashTable *matched_objects;
-
-	/* The listener we report to */
-	GList *listeners;
+	EDataCalCallStatus done_status;
 
 	/* Sexp that defines the query */
 	ECalBackendSExp *sexp;
-};
 
-
+	GArray *adds;
+	GArray *changes;
+	GArray *removes;
 
-static void e_data_cal_view_class_init (EDataCalViewClass *class);
-static void e_data_cal_view_init (EDataCalView *query, EDataCalViewClass *class);
-static void e_data_cal_view_finalize (GObject *object);
+	GHashTable *ids;
 
-static BonoboObjectClass *parent_class;
+	char *path;
+};
 
-
+G_DEFINE_TYPE (EDataCalView, e_data_cal_view, G_TYPE_OBJECT);
+#define E_DATA_CAL_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_DATA_CAL_VIEW_TYPE, EDataCalViewPrivate))
 
-BONOBO_TYPE_FUNC_FULL (EDataCalView,
-		       GNOME_Evolution_Calendar_CalView,
-		       BONOBO_TYPE_OBJECT,
-		       e_data_cal_view)
+static void e_data_cal_view_dispose (GObject *object);
+static void e_data_cal_view_finalize (GObject *object);
+static void e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void e_data_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
 
 /* Property IDs */
 enum props {
 	PROP_0,
 	PROP_BACKEND,
-	PROP_LISTENER,
 	PROP_SEXP
 };
 
-/* Signal IDs */
+/* Signals */
 enum {
-	LAST_LISTENER_GONE,
-	LAST_SIGNAL
+  OBJECTS_ADDED,
+  OBJECTS_MODIFIED,
+  OBJECTS_REMOVED,
+  PROGRESS,
+  DONE,
+  LAST_SIGNAL
 };
 
-static guint signals[LAST_SIGNAL];
+static guint signals[LAST_SIGNAL] = { 0 };
 
+/* Class init */
 static void
-add_object_to_cache (EDataCalView *query, const gchar *calobj)
+e_data_cal_view_class_init (EDataCalViewClass *klass)
 {
-	ECalComponent *comp;
-	gchar *real_uid;
-	const gchar *uid;
-	EDataCalViewPrivate *priv;
-
-	priv = query->priv;
+	GParamSpec *param;
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	comp = e_cal_component_new_from_string (calobj);
-	if (!comp)
-		return;
+	g_type_class_add_private (klass, sizeof (EDataCalViewPrivate));
 
-	e_cal_component_get_uid (comp, &uid);
-	if (!uid || !*uid) {
-		g_object_unref (comp);
-		return;
-	}
+	object_class->set_property = e_data_cal_view_set_property;
+	object_class->get_property = e_data_cal_view_get_property;
+	object_class->dispose = e_data_cal_view_dispose;
+	object_class->finalize = e_data_cal_view_finalize;
 
-	if (e_cal_component_is_instance (comp)) {
-		gchar *str;
-		str = e_cal_component_get_recurid_as_string (comp);
-		real_uid = g_strdup_printf ("%s %s", uid, str);
-		g_free (str);
-	} else
-		real_uid = g_strdup (uid);
+	param =  g_param_spec_object ("backend", NULL, NULL, E_TYPE_CAL_BACKEND,
+				      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
+	g_object_class_install_property (object_class, PROP_BACKEND, param);
+	param =  g_param_spec_object ("sexp", NULL, NULL, E_TYPE_CAL_BACKEND_SEXP,
+				      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
+	g_object_class_install_property (object_class, PROP_SEXP, param);
 
-	if (g_hash_table_lookup (priv->matched_objects, real_uid))
-		g_hash_table_replace (priv->matched_objects, real_uid, g_strdup (calobj));
-	else
-		g_hash_table_insert (priv->matched_objects, real_uid, g_strdup (calobj));
+        signals[OBJECTS_ADDED] =
+          g_signal_new ("objects-added",
+                        G_OBJECT_CLASS_TYPE (klass),
+                        G_SIGNAL_RUN_LAST,
+                        0, NULL, NULL,
+                        g_cclosure_marshal_VOID__BOXED,
+                        G_TYPE_NONE, 1, G_TYPE_STRV);
+
+        signals[OBJECTS_MODIFIED] =
+          g_signal_new ("objects-modified",
+                        G_OBJECT_CLASS_TYPE (klass),
+                        G_SIGNAL_RUN_LAST,
+                        0, NULL, NULL,
+                        g_cclosure_marshal_VOID__BOXED,
+                        G_TYPE_NONE, 1, G_TYPE_STRV);
+
+        signals[OBJECTS_REMOVED] =
+          g_signal_new ("objects-removed",
+                        G_OBJECT_CLASS_TYPE (klass),
+                        G_SIGNAL_RUN_LAST,
+                        0, NULL, NULL,
+                        g_cclosure_marshal_VOID__BOXED,
+                        G_TYPE_NONE, 1, G_TYPE_STRV);
+
+        signals[PROGRESS] =
+          g_signal_new ("progress",
+                        G_OBJECT_CLASS_TYPE (klass),
+                        G_SIGNAL_RUN_LAST,
+                        0, NULL, NULL,
+                        e_data_cal_marshal_VOID__STRING_UINT,
+                        G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
+
+        signals[DONE] =
+          g_signal_new ("done",
+                        G_OBJECT_CLASS_TYPE (klass),
+                        G_SIGNAL_RUN_LAST,
+                        0, NULL, NULL,
+                        g_cclosure_marshal_VOID__UINT,
+                        G_TYPE_NONE, 1, G_TYPE_UINT);
+
+	dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_e_data_cal_view_object_info);
+}
 
-	/* free memory */
-	g_object_unref (comp);
+static guint
+id_hash (gconstpointer key)
+{
+	const ECalComponentId *id = key;
+	return g_str_hash (id->uid) ^ (id->rid ? g_str_hash (id->rid) : 0);
 }
 
 static gboolean
-uncache_with_id_cb (gpointer key, gpointer value, gpointer user_data)
+id_equal (gconstpointer a, gconstpointer b)
 {
-	ECalComponent *comp;
-	ECalComponentId *id;
-	const gchar *this_uid;
-	gchar *object;
-	gboolean remove = FALSE;
-
-	id = user_data;
-	object = value;
-
-	comp = e_cal_component_new_from_string (object);
-	if (comp) {
-		e_cal_component_get_uid (comp, &this_uid);
-		if (this_uid && !strcmp (id->uid, this_uid)) {
-			if (id->rid && *id->rid) {
-				gchar *rid = e_cal_component_get_recurid_as_string (comp);
-
-				if (rid && !strcmp (id->rid, rid))
-					remove = TRUE;
-
-				g_free (rid);
-			} else
-				remove = TRUE;
-		}
-
-		g_object_unref (comp);
+	const ECalComponentId *id_a = a, *id_b = b;
+	return g_strcmp0 (id_a->uid, id_b->uid) == 0 && g_strcmp0 (id_a->rid, id_b->rid) == 0;
+}
+
+/* Instance init */
+static void
+e_data_cal_view_init (EDataCalView *view)
+{
+	EDataCalViewPrivate *priv = E_DATA_CAL_VIEW_GET_PRIVATE (view);
+
+	view->priv = priv;
+
+	priv->backend = NULL;
+	priv->started = FALSE;
+	priv->done = FALSE;
+	priv->done_status = Success;
+	priv->started = FALSE;
+	priv->sexp = NULL;
+
+	priv->adds = g_array_sized_new (TRUE, TRUE, sizeof (char*), THRESHOLD);
+	priv->changes = g_array_sized_new (TRUE, TRUE, sizeof (char*), THRESHOLD);
+	priv->removes = g_array_sized_new (TRUE, TRUE, sizeof (char*), THRESHOLD);
+
+	priv->ids = g_hash_table_new_full (id_hash, id_equal, (GDestroyNotify)e_cal_component_free_id, NULL);
+}
+
+EDataCalView *
+e_data_cal_view_new (ECalBackend *backend,
+		     const char *path, ECalBackendSExp *sexp)
+{
+	EDataCalView *query;
+
+	query = g_object_new (E_DATA_CAL_VIEW_TYPE, "backend", backend, "sexp", sexp, NULL);
+	query->priv->path = g_strdup (path);
+
+	dbus_g_connection_register_g_object (connection, path, G_OBJECT (query));
+
+	return query;
+}
+
+const char *
+e_data_cal_view_get_dbus_path (EDataCalView *view)
+{
+	g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), NULL);
+
+	return view->priv->path;
+}
+
+static void
+reset_array (GArray *array)
+{
+	gint i = 0;
+	gchar *tmp = NULL;
+
+	/* Free stored strings */
+	for (i = 0; i < array->len; i++) {
+		tmp = g_array_index (array, gchar *, i);
+		g_free (tmp);
 	}
 
-	return remove;
+	/* Force the array size to 0 */
+	g_array_set_size (array, 0);
 }
 
 static void
-remove_object_from_cache (EDataCalView *query, const ECalComponentId *id)
+send_pending_adds (EDataCalView *view)
 {
-	EDataCalViewPrivate *priv;
+	EDataCalViewPrivate *priv = view->priv;
 
-	priv = query->priv;
+	if (priv->adds->len == 0)
+		return;
 
-	g_hash_table_foreach_remove (priv->matched_objects, (GHRFunc) uncache_with_id_cb, (gpointer) id);
+	g_signal_emit (view, signals[OBJECTS_ADDED], 0, priv->adds->data);
+	reset_array (priv->adds);
 }
 
 static void
-listener_died_cb (EComponentListener *cl, gpointer data)
+send_pending_changes (EDataCalView *view)
 {
-	EDataCalView *query = QUERY (data);
-	EDataCalViewPrivate *priv;
-	GList *l;
+	EDataCalViewPrivate *priv = view->priv;
 
-	priv = query->priv;
+	if (priv->changes->len == 0)
+		return;
 
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
+	g_signal_emit (view, signals[OBJECTS_MODIFIED], 0, priv->changes->data);
+	reset_array (priv->changes);
+}
 
-		if (ld->component_listener == cl) {
-			g_object_unref (ld->component_listener);
-			ld->component_listener = NULL;
+static void
+send_pending_removes (EDataCalView *view)
+{
+	EDataCalViewPrivate *priv = view->priv;
 
-			bonobo_object_release_unref (ld->listener, NULL);
-			ld->listener = NULL;
+	if (priv->removes->len == 0)
+		return;
 
-			priv->listeners = g_list_remove_link (priv->listeners, l);
-			g_list_free (l);
-			g_free (ld);
+	/* TODO: send ECalComponentIds as a list of pairs */
+	g_signal_emit (view, signals[OBJECTS_REMOVED], 0, priv->removes->data);
+	reset_array (priv->removes);
+}
 
-			if (priv->listeners == NULL)
-				g_signal_emit (query, signals[LAST_LISTENER_GONE], 0);
+static void
+notify_add (EDataCalView *view, char *obj)
+{
+	EDataCalViewPrivate *priv = view->priv;
+	ECalComponent *comp;
 
-			break;
-		}
+	send_pending_changes (view);
+	send_pending_removes (view);
+
+	if (priv->adds->len == THRESHOLD) {
+		send_pending_adds (view);
 	}
+	g_array_append_val (priv->adds, obj);
+
+	comp = e_cal_component_new_from_string (obj);
+	g_hash_table_insert (priv->ids,
+			     e_cal_component_get_id (comp),
+			     GUINT_TO_POINTER (1));
+	g_object_unref (comp);
 }
 
 static void
-notify_matched_object_cb (gpointer key, gpointer value, gpointer user_data)
+notify_change (EDataCalView *view, char *obj)
 {
-	gchar *uid, *object;
-	EDataCalView *query;
-	EDataCalViewPrivate *priv;
-	GList *l;
+	EDataCalViewPrivate *priv = view->priv;
 
-	uid = key;
-	object = value;
-	query = user_data;
-	priv = query->priv;
+	send_pending_adds (view);
+	send_pending_removes (view);
 
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
+	g_array_append_val (priv->changes, obj);
+}
 
-		if (!ld->notified_start) {
-			GNOME_Evolution_Calendar_stringlist obj_list;
-			CORBA_Environment ev;
+static void
+notify_remove (EDataCalView *view, ECalComponentId *id)
+{
+	EDataCalViewPrivate *priv = view->priv;
+	char *uid;
 
-			obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (1);
-			obj_list._maximum = 1;
-			obj_list._length = 1;
-			obj_list._buffer[0] = CORBA_string_dup (object);
+	send_pending_adds (view);
+	send_pending_changes (view);
 
-			CORBA_exception_init (&ev);
-			GNOME_Evolution_Calendar_CalViewListener_notifyObjectsAdded (ld->listener, &obj_list, &ev);
-			CORBA_exception_free (&ev);
+	/* TODO: store ECalComponentId instead of just uid*/
+	uid = g_strdup (id->uid);
+	g_array_append_val (priv->removes, uid);
 
-			CORBA_free (obj_list._buffer);
-		}
-	}
+	g_hash_table_remove (priv->ids, id);
 }
 
 static void
-impl_EDataCalView_start (PortableServer_Servant servant, CORBA_Environment *ev)
+notify_done (EDataCalView *view)
 {
-	EDataCalView *query;
-	EDataCalViewPrivate *priv;
-	GList *l;
+	EDataCalViewPrivate *priv = view->priv;
 
-	query = QUERY (bonobo_object_from_servant (servant));
-	priv = query->priv;
-
-	if (priv->started) {
-		g_hash_table_foreach (priv->matched_objects, (GHFunc) notify_matched_object_cb, query);
+	send_pending_adds (view);
+	send_pending_changes (view);
+	send_pending_removes (view);
 
-		/* notify all listeners correctly if the query is already done */
-		for (l = priv->listeners; l != NULL; l = l->next) {
-			ListenerData *ld = l->data;
+	g_signal_emit (view, signals[DONE], 0, priv->done_status);
+}
 
-			if (!ld->notified_start) {
-				ld->notified_start = TRUE;
 
-				if (priv->done && !ld->notified_done) {
+static gboolean
+impl_EDataCalView_start (EDataCalView *query, GError **error)
+{
+	EDataCalViewPrivate *priv;
 
-					ld->notified_done = TRUE;
+	priv = query->priv;
 
-					CORBA_exception_init (ev);
-					GNOME_Evolution_Calendar_CalViewListener_notifyQueryDone (
-						ld->listener, priv->done_status, ev);
-					CORBA_exception_free (ev);
-				}
-			}
-		}
-	} else {
+	if (!priv->started) {
 		priv->started = TRUE;
 		e_cal_backend_start_query (priv->backend, query);
-
-		for (l = priv->listeners; l != NULL; l = l->next) {
-			ListenerData *ld = l->data;
-
-			ld->notified_start = TRUE;
-		}
 	}
+
+	return TRUE;
 }
 
 static void
@@ -289,9 +354,6 @@ e_data_cal_view_set_property (GObject *object, guint property_id, const GValue *
 	case PROP_BACKEND:
 		priv->backend = E_CAL_BACKEND (g_value_dup_object (value));
 		break;
-	case PROP_LISTENER:
-		e_data_cal_view_add_listener (query, g_value_get_pointer (value));
-		break;
 	case PROP_SEXP:
 		priv->sexp = E_CAL_BACKEND_SEXP (g_value_dup_object (value));
 		break;
@@ -313,14 +375,6 @@ e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value,
 	switch (property_id) {
 	case PROP_BACKEND:
 		g_value_set_object (value, priv->backend);
-	case PROP_LISTENER:
-
-		if (priv->listeners) {
-			ListenerData *ld;
-
-			ld = priv->listeners->data;
-			g_value_set_pointer (value, ld->listener);
-		}
 		break;
 	case PROP_SEXP:
 		g_value_set_object (value, priv->sexp);
@@ -331,67 +385,8 @@ e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value,
 	}
 }
 
-/* Class initialization function for the live search query */
-static void
-e_data_cal_view_class_init (EDataCalViewClass *klass)
-{
-	GObjectClass *object_class;
-	POA_GNOME_Evolution_Calendar_CalView__epv *epv = &klass->epv;
-	GParamSpec *param;
-
-	object_class = (GObjectClass *) klass;
-
-	parent_class = g_type_class_peek_parent (klass);
-
-	object_class->set_property = e_data_cal_view_set_property;
-	object_class->get_property = e_data_cal_view_get_property;
-	object_class->finalize = e_data_cal_view_finalize;
-
-	epv->start = impl_EDataCalView_start;
-
-	param =  g_param_spec_object ("backend", NULL, NULL, E_TYPE_CAL_BACKEND,
-				      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
-	g_object_class_install_property (object_class, PROP_BACKEND, param);
-	param =  g_param_spec_pointer ("listener", NULL, NULL,
-				      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
-	g_object_class_install_property (object_class, PROP_LISTENER, param);
-	param =  g_param_spec_object ("sexp", NULL, NULL, E_TYPE_CAL_BACKEND_SEXP,
-				      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
-	g_object_class_install_property (object_class, PROP_SEXP, param);
-
-	signals[LAST_LISTENER_GONE] =
-		g_signal_new ("last_listener_gone",
-			      G_TYPE_FROM_CLASS (klass),
-			      G_SIGNAL_RUN_FIRST,
-			      G_STRUCT_OFFSET (EDataCalViewClass, last_listener_gone),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE, 0);
-
-	klass->last_listener_gone = NULL;
-}
-
-/* Object initialization function for the live search query */
-static void
-e_data_cal_view_init (EDataCalView *query, EDataCalViewClass *class)
-{
-	EDataCalViewPrivate *priv;
-
-	priv = g_new0 (EDataCalViewPrivate, 1);
-	query->priv = priv;
-
-	priv->backend = NULL;
-	priv->started = FALSE;
-	priv->done = FALSE;
-	priv->done_status = GNOME_Evolution_Calendar_Success;
-	priv->matched_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-	priv->listeners = NULL;
-	priv->sexp = NULL;
-}
-
-/* Finalize handler for the live search query */
 static void
-e_data_cal_view_finalize (GObject *object)
+e_data_cal_view_dispose (GObject *object)
 {
 	EDataCalView *query;
 	EDataCalViewPrivate *priv;
@@ -402,87 +397,36 @@ e_data_cal_view_finalize (GObject *object)
 	query = QUERY (object);
 	priv = query->priv;
 
-	if (priv->backend)
+	if (priv->backend) {
 		g_object_unref (priv->backend);
-
-	while (priv->listeners) {
-		ListenerData *ld = priv->listeners->data;
-
-		if (ld->listener)
-			bonobo_object_release_unref (ld->listener, NULL);
-		if (ld->component_listener)
-			g_object_unref (ld->component_listener);
-		priv->listeners = g_list_remove (priv->listeners, ld);
-		g_free (ld);
+		priv->backend = NULL;
 	}
 
-	if (priv->matched_objects)
-		g_hash_table_destroy (priv->matched_objects);
-
-	if (priv->sexp)
+	if (priv->sexp) {
 		g_object_unref (priv->sexp);
+		priv->sexp = NULL;
+	}
 
-	g_free (priv);
-
-	if (G_OBJECT_CLASS (parent_class)->finalize)
-		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
+	(* G_OBJECT_CLASS (e_data_cal_view_parent_class)->dispose) (object);
 }
 
-/**
- * e_data_cal_view_new:
- * @backend: Calendar backend that the query object will monitor.
- * @ql: Listener for query results.
- * @sexp: Sexp that defines the query.
- *
- * Creates a new query engine object that monitors a calendar backend.
- *
- * Return value: A newly-created query object, or NULL on failure.
- **/
-EDataCalView *
-e_data_cal_view_new (ECalBackend *backend,
-		     GNOME_Evolution_Calendar_CalViewListener ql,
-		     ECalBackendSExp *sexp)
+static void
+e_data_cal_view_finalize (GObject *object)
 {
 	EDataCalView *query;
-
-	query = g_object_new (E_DATA_CAL_VIEW_TYPE, "backend", backend, "listener", ql,
-			      "sexp", sexp, NULL);
-
-	return query;
-}
-
-/**
- * e_data_cal_view_add_listener:
- * @query: A #EDataCalView object.
- * @ql: A CORBA query listener to add to the list of listeners.
- *
- * Adds the given CORBA listener to a #EDataCalView object. This makes the view
- * object notify that listener when notifying the other listeners already attached
- * to the view.
- */
-void
-e_data_cal_view_add_listener (EDataCalView *query, GNOME_Evolution_Calendar_CalViewListener ql)
-{
-	ListenerData *ld;
 	EDataCalViewPrivate *priv;
-	CORBA_Environment ev;
 
-	g_return_if_fail (IS_QUERY (query));
-	g_return_if_fail (ql != CORBA_OBJECT_NIL);
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (IS_QUERY (object));
 
+	query = QUERY (object);
 	priv = query->priv;
 
-	ld = g_new0 (ListenerData, 1);
+	g_hash_table_destroy (priv->ids);
 
-	CORBA_exception_init (&ev);
-	ld->listener = CORBA_Object_duplicate (ql, &ev);
-	CORBA_exception_free (&ev);
+	g_free (priv->path);
 
-	ld->component_listener = e_component_listener_new (ld->listener);
-	g_signal_connect (G_OBJECT (ld->component_listener), "component_died",
-			  G_CALLBACK (listener_died_cb), query);
-
-	priv->listeners = g_list_prepend (priv->listeners, ld);
+	(* G_OBJECT_CLASS (e_data_cal_view_parent_class)->finalize) (object);
 }
 
 /**
@@ -541,14 +485,6 @@ e_data_cal_view_object_matches (EDataCalView *query, const gchar *object)
 	return e_cal_backend_sexp_match_object (priv->sexp, object, priv->backend);
 }
 
-static void
-add_object_to_list (gpointer key, gpointer value, gpointer user_data)
-{
-	GList **list = user_data;
-
-	*list = g_list_append (*list, value);
-}
-
 /**
  * e_data_cal_view_get_matched_objects:
  * @query: A query object.
@@ -560,16 +496,9 @@ add_object_to_list (gpointer key, gpointer value, gpointer user_data)
 GList *
 e_data_cal_view_get_matched_objects (EDataCalView *query)
 {
-	EDataCalViewPrivate *priv;
-	GList *list = NULL;
-
 	g_return_val_if_fail (IS_QUERY (query), NULL);
-
-	priv = query->priv;
-
-	g_hash_table_foreach (priv->matched_objects, (GHFunc) add_object_to_list, &list);
-
-	return list;
+#warning TODO e_data_cal_view_get_matched_objects
+	return NULL;
 }
 
 /**
@@ -581,15 +510,11 @@ e_data_cal_view_get_matched_objects (EDataCalView *query)
  * Return value: TRUE if the query has already been started, FALSE otherwise.
  */
 gboolean
-e_data_cal_view_is_started (EDataCalView *query)
+e_data_cal_view_is_started (EDataCalView *view)
 {
-	EDataCalViewPrivate *priv;
+	g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), FALSE);
 
-	g_return_val_if_fail (IS_QUERY (query), FALSE);
-
-	priv = query->priv;
-
-	return priv->started;
+	return view->priv->started;
 }
 
 /**
@@ -624,7 +549,7 @@ e_data_cal_view_is_done (EDataCalView *query)
  *
  * Return value: The query status.
  */
-GNOME_Evolution_Calendar_CallStatus
+EDataCalCallStatus
 e_data_cal_view_get_done_status (EDataCalView *query)
 {
 	EDataCalViewPrivate *priv;
@@ -636,7 +561,7 @@ e_data_cal_view_get_done_status (EDataCalView *query)
 	if (priv->done)
 		return priv->done_status;
 
-	return GNOME_Evolution_Calendar_Success;
+	return Success;
 }
 
 /**
@@ -647,48 +572,22 @@ e_data_cal_view_get_done_status (EDataCalView *query)
  * Notifies all query listeners of the addition of a list of objects.
  */
 void
-e_data_cal_view_notify_objects_added (EDataCalView *query, const GList *objects)
+e_data_cal_view_notify_objects_added (EDataCalView *view, const GList *objects)
 {
 	EDataCalViewPrivate *priv;
-	GNOME_Evolution_Calendar_stringlist obj_list;
-	CORBA_Environment ev;
 	const GList *l;
-	gint num_objs, i;
-
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
 
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	priv = view->priv;
 
-	num_objs = g_list_length ((GList*)objects);
-	if (num_objs <= 0)
+	if (objects == NULL)
 		return;
 
-	obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs);
-	obj_list._maximum = num_objs;
-	obj_list._length = num_objs;
-
-	for (l = objects, i = 0; l; l = l->next, i++) {
-		obj_list._buffer[i] = CORBA_string_dup (l->data);
-
-		/* update our cache */
-		add_object_to_cache (query, l->data);
+	for (l = objects; l; l = l->next) {
+		notify_add (view, g_strdup (l->data));
 	}
 
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
-
-		CORBA_exception_init (&ev);
-
-		GNOME_Evolution_Calendar_CalViewListener_notifyObjectsAdded (ld->listener, &obj_list, &ev);
-		if (BONOBO_EX (&ev))
-			g_warning (G_STRLOC ": could not notify the listener of object addition");
-
-		CORBA_exception_free (&ev);
-	}
-
-	CORBA_free (obj_list._buffer);
+	send_pending_adds (view);
 }
 
 /**
@@ -699,22 +598,15 @@ e_data_cal_view_notify_objects_added (EDataCalView *query, const GList *objects)
  * Notifies all the query listeners of the addition of a single object.
  */
 void
-e_data_cal_view_notify_objects_added_1 (EDataCalView *query, const gchar *object)
+e_data_cal_view_notify_objects_added_1 (EDataCalView *view, const gchar *object)
 {
-	EDataCalViewPrivate *priv;
-	GList objects;
+	GList l = {0,};
 
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
-	g_return_if_fail (object != NULL);
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	g_return_if_fail (object);
 
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
-
-	objects.next = objects.prev = NULL;
-	objects.data = (gpointer)object;
-
-	e_data_cal_view_notify_objects_added (query, &objects);
+	l.data = (gpointer)object;
+	e_data_cal_view_notify_objects_added (view, &l);
 }
 
 /**
@@ -725,48 +617,23 @@ e_data_cal_view_notify_objects_added_1 (EDataCalView *query, const gchar *object
  * Notifies all query listeners of the modification of a list of objects.
  */
 void
-e_data_cal_view_notify_objects_modified (EDataCalView *query, const GList *objects)
+e_data_cal_view_notify_objects_modified (EDataCalView *view, const GList *objects)
 {
 	EDataCalViewPrivate *priv;
-	GNOME_Evolution_Calendar_CalObjUIDSeq obj_list;
-	CORBA_Environment ev;
 	const GList *l;
-	gint num_objs, i;
 
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
-
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	priv = view->priv;
 
-	num_objs = g_list_length ((GList*)objects);
-	if (num_objs <= 0)
+	if (objects == NULL)
 		return;
 
-	obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs);
-	obj_list._maximum = num_objs;
-	obj_list._length = num_objs;
-
-	for (l = objects, i = 0; l; l = l->next, i++) {
-		obj_list._buffer[i] = CORBA_string_dup (l->data);
-
-		/* update our cache */
-		add_object_to_cache (query, l->data);
-	}
-
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
-
-		CORBA_exception_init (&ev);
-
-		GNOME_Evolution_Calendar_CalViewListener_notifyObjectsModified (ld->listener, &obj_list, &ev);
-		if (BONOBO_EX (&ev))
-			g_warning (G_STRLOC ": could not notify the listener of object modification");
-
-		CORBA_exception_free (&ev);
+	for (l = objects; l; l = l->next) {
+		/* TODO: send add/remove/change as relevant, based on ->ids */
+		notify_change (view, g_strdup (l->data));
 	}
 
-	CORBA_free (obj_list._buffer);
+	send_pending_changes (view);
 }
 
 /**
@@ -777,22 +644,15 @@ e_data_cal_view_notify_objects_modified (EDataCalView *query, const GList *objec
  * Notifies all query listeners of the modification of a single object.
  */
 void
-e_data_cal_view_notify_objects_modified_1 (EDataCalView *query, const gchar *object)
+e_data_cal_view_notify_objects_modified_1 (EDataCalView *view, const gchar *object)
 {
-	EDataCalViewPrivate *priv;
-	GList objects;
-
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
-	g_return_if_fail (object != NULL);
+	GList l = {0,};
 
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
-
-	objects.next = objects.prev = NULL;
-	objects.data = (gpointer)object;
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	g_return_if_fail (object);
 
-	e_data_cal_view_notify_objects_modified (query, &objects);
+	l.data = (gpointer)object;
+	e_data_cal_view_notify_objects_modified (view, &l);
 }
 
 /**
@@ -803,57 +663,24 @@ e_data_cal_view_notify_objects_modified_1 (EDataCalView *query, const gchar *obj
  * Notifies all query listener of the removal of a list of objects.
  */
 void
-e_data_cal_view_notify_objects_removed (EDataCalView *query, const GList *ids)
+e_data_cal_view_notify_objects_removed (EDataCalView *view, const GList *ids)
 {
 	EDataCalViewPrivate *priv;
-	GNOME_Evolution_Calendar_CalObjIDSeq id_list;
-	CORBA_Environment ev;
 	const GList *l;
-	gint num_ids, i;
 
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
-
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	priv = view->priv;
 
-	num_ids = g_list_length ((GList*)ids);
-	if (num_ids <= 0)
+	if (ids == NULL)
 		return;
 
-	id_list._buffer = GNOME_Evolution_Calendar_CalObjIDSeq_allocbuf (num_ids);
-	id_list._maximum = num_ids;
-	id_list._length = num_ids;
-
-	i = 0;
-	for (l = ids; l; l = l->next, i++) {
+	for (l = ids; l; l = l->next) {
 		ECalComponentId *id = l->data;
-		GNOME_Evolution_Calendar_CalObjID *c_id = &id_list._buffer[i];
-
-		c_id->uid = CORBA_string_dup (id->uid);
-
-		if (id->rid)
-			c_id->rid = CORBA_string_dup (id->rid);
-		else
-			c_id->rid = CORBA_string_dup ("");
-
-		/* update our cache */
-		remove_object_from_cache (query, l->data);
+		if (g_hash_table_lookup (priv->ids, id))
+		    notify_remove (view, id);
 	}
 
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
-
-		CORBA_exception_init (&ev);
-
-		GNOME_Evolution_Calendar_CalViewListener_notifyObjectsRemoved (ld->listener, &id_list, &ev);
-		if (BONOBO_EX (&ev))
-			g_warning (G_STRLOC ": could not notify the listener of object removal");
-
-		CORBA_exception_free (&ev);
-	}
-
-	CORBA_free (id_list._buffer);
+	send_pending_removes (view);
 }
 
 /**
@@ -864,22 +691,15 @@ e_data_cal_view_notify_objects_removed (EDataCalView *query, const GList *ids)
  * Notifies all query listener of the removal of a single object.
  */
 void
-e_data_cal_view_notify_objects_removed_1 (EDataCalView *query, const ECalComponentId *id)
+e_data_cal_view_notify_objects_removed_1 (EDataCalView *view, const ECalComponentId *id)
 {
-	EDataCalViewPrivate *priv;
-	GList ids;
+	GList l = {0,};
 
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
-	g_return_if_fail (id != NULL);
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	g_return_if_fail (id);
 
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
-
-	ids.next = ids.prev = NULL;
-	ids.data = (gpointer)id;
-
-	e_data_cal_view_notify_objects_removed (query, &ids);
+	l.data = (gpointer)id;
+	e_data_cal_view_notify_objects_removed (view, &l);
 }
 
 /**
@@ -891,29 +711,17 @@ e_data_cal_view_notify_objects_removed_1 (EDataCalView *query, const ECalCompone
  * Notifies all query listeners of progress messages.
  */
 void
-e_data_cal_view_notify_progress (EDataCalView *query, const gchar *message, gint percent)
+e_data_cal_view_notify_progress (EDataCalView *view, const gchar *message, gint percent)
 {
 	EDataCalViewPrivate *priv;
-	CORBA_Environment ev;
-	GList *l;
 
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
-
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	priv = view->priv;
 
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
-
-		CORBA_exception_init (&ev);
-
-		GNOME_Evolution_Calendar_CalViewListener_notifyQueryProgress (ld->listener, message, percent, &ev);
-		if (BONOBO_EX (&ev))
-			g_warning (G_STRLOC ": could not notify the listener of query progress");
+	if (!priv->started)
+		return;
 
-		CORBA_exception_free (&ev);
-	}
+	g_signal_emit (view, signals[PROGRESS], 0, message, percent);
 }
 
 /**
@@ -925,30 +733,18 @@ e_data_cal_view_notify_progress (EDataCalView *query, const gchar *message, gint
  * status code.
  */
 void
-e_data_cal_view_notify_done (EDataCalView *query, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_view_notify_done (EDataCalView *view, GNOME_Evolution_Calendar_CallStatus status)
 {
 	EDataCalViewPrivate *priv;
-	CORBA_Environment ev;
-	GList *l;
 
-	g_return_if_fail (query != NULL);
-	g_return_if_fail (IS_QUERY (query));
+	g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+	priv = view->priv;
 
-	priv = query->priv;
-	g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
+	if (!priv->started)
+		return;
 
 	priv->done = TRUE;
 	priv->done_status = status;
 
-	for (l = priv->listeners; l != NULL; l = l->next) {
-		ListenerData *ld = l->data;
-
-		CORBA_exception_init (&ev);
-
-		GNOME_Evolution_Calendar_CalViewListener_notifyQueryDone (ld->listener, status, &ev);
-		if (BONOBO_EX (&ev))
-			g_warning (G_STRLOC ": could not notify the listener of query completion");
-
-		CORBA_exception_free (&ev);
-	}
+	notify_done (view);
 }
diff --git a/calendar/libedata-cal/e-data-cal-view.h b/calendar/libedata-cal/e-data-cal-view.h
index a69f74e..911b4f0 100644
--- a/calendar/libedata-cal/e-data-cal-view.h
+++ b/calendar/libedata-cal/e-data-cal-view.h
@@ -21,10 +21,12 @@
 #ifndef E_DATA_CAL_VIEW_H
 #define E_DATA_CAL_VIEW_H
 
-#include <bonobo/bonobo-object.h>
-#include <libedata-cal/Evolution-DataServer-Calendar.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
 #include <libedata-cal/e-data-cal-common.h>
 #include <libedata-cal/e-cal-backend-sexp.h>
+#include <libedata-cal/e-data-cal-types.h>
 
 G_BEGIN_DECLS
 
@@ -41,26 +43,19 @@ G_BEGIN_DECLS
 typedef struct _EDataCalViewPrivate EDataCalViewPrivate;
 
 struct _EDataCalView {
-	BonoboObject xobject;
-
-	/* Private data */
+	GObject parent;
 	EDataCalViewPrivate *priv;
 };
 
 struct _EDataCalViewClass {
-	BonoboObjectClass parent_class;
-
-	POA_GNOME_Evolution_Calendar_CalView__epv epv;
-
-	/* Notification signals */
-	void (* last_listener_gone) (EDataCalView *query);
+	GObjectClass parent_class;
 };
 
 GType                 e_data_cal_view_get_type (void);
-EDataCalView         *e_data_cal_view_new (ECalBackend                             *backend,
-					   GNOME_Evolution_Calendar_CalViewListener  ql,
-					   ECalBackendSExp                   *sexp);
-void                  e_data_cal_view_add_listener (EDataCalView *query, GNOME_Evolution_Calendar_CalViewListener ql);
+EDataCalView         *e_data_cal_view_new (ECalBackend *backend, const gchar *path, ECalBackendSExp *sexp);
+
+const gchar * e_data_cal_view_get_dbus_path (EDataCalView *view);
+
 const gchar           *e_data_cal_view_get_text (EDataCalView *query);
 ECalBackendSExp      *e_data_cal_view_get_object_sexp (EDataCalView *query);
 gboolean              e_data_cal_view_object_matches (EDataCalView *query, const gchar *object);
@@ -68,7 +63,7 @@ gboolean              e_data_cal_view_object_matches (EDataCalView *query, const
 GList                *e_data_cal_view_get_matched_objects (EDataCalView *query);
 gboolean              e_data_cal_view_is_started (EDataCalView *query);
 gboolean              e_data_cal_view_is_done (EDataCalView *query);
-GNOME_Evolution_Calendar_CallStatus e_data_cal_view_get_done_status (EDataCalView *query);
+EDataCalCallStatus e_data_cal_view_get_done_status (EDataCalView *query);
 
 void                  e_data_cal_view_notify_objects_added (EDataCalView       *query,
 							    const GList *objects);
@@ -86,7 +81,7 @@ void                  e_data_cal_view_notify_progress (EDataCalView      *query,
 						       const gchar *message,
 						       gint         percent);
 void                  e_data_cal_view_notify_done (EDataCalView                               *query,
-						   GNOME_Evolution_Calendar_CallStatus status);
+						   EDataCalCallStatus status);
 
 G_END_DECLS
 
diff --git a/calendar/libedata-cal/e-data-cal-view.xml b/calendar/libedata-cal/e-data-cal-view.xml
new file mode 100644
index 0000000..f61bc5d
--- /dev/null
+++ b/calendar/libedata-cal/e-data-cal-view.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node>
+  <interface name="org.gnome.evolution.dataserver.calendar.CalView">
+    <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EDataCalView"/>
+    
+    <method name="start">
+      <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_EDataCalView_start"/>
+    </method>
+    
+    <signal name="ObjectsAdded">
+      <arg name="objects" type="as"/>
+    </signal>
+
+    <signal name="ObjectsModified">
+      <arg name="objects" type="as"/>
+    </signal>
+
+    <signal name="ObjectsRemoved">
+      <arg name="ids" type="as"/>
+    </signal>
+
+    <signal name="Progress">
+      <arg name="message" type="s"/>
+      <arg name="progress" type="u"/>
+    </signal>
+
+    <signal name="Done">
+      <arg name="status" type="u"/>
+    </signal>
+  </interface>
+</node>
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index cb12f95..512188a 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -1,9 +1,12 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /* Evolution calendar client interface object
  *
  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
  *
  * Authors: Federico Mena-Quintero <federico ximian com>
  *          Rodrigo Moya <rodrigo ximian com>
+ *          Ross Burton <ross linux intel com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU Lesser General Public
@@ -24,408 +27,375 @@
 #endif
 
 #include <libical/ical.h>
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-exception.h>
-#include <libedata-cal/e-cal-backend.h>
+#include <glib/gi18n-lib.h>
+#include <unistd.h>
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+
 #include "e-data-cal.h"
+#include "e-data-cal-enumtypes.h"
+
+DBusGConnection *connection;
+
+/* DBus glue */
+static void impl_Cal_get_uri (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_open (EDataCal *cal, gboolean only_if_exists, gchar *username, gchar *password, DBusGMethodInvocation *context);
+static gboolean impl_Cal_close (EDataCal *cal, GError **error);
+static void impl_Cal_remove (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_isReadOnly (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_getCalAddress (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_getAlarmEmailAddress (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_getLdapAttribute (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_getStaticCapabilities (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_setMode (EDataCal *cal, EDataCalMode mode, DBusGMethodInvocation *context);
+static void impl_Cal_getDefaultObject (EDataCal *cal, DBusGMethodInvocation *context);
+static void impl_Cal_getObject (EDataCal *cal, const gchar *uid, const gchar *rid, DBusGMethodInvocation *context);
+static void impl_Cal_getObjectList (EDataCal *cal, const gchar *sexp, DBusGMethodInvocation *context);
+static void impl_Cal_getChanges (EDataCal *cal, const gchar *change_id, DBusGMethodInvocation *context);
+static void impl_Cal_getFreeBusy (EDataCal *cal, const char **user_list, const gulong start, const gulong end, DBusGMethodInvocation *context);
+static void impl_Cal_discardAlarm (EDataCal *cal, const gchar *uid, const gchar *auid, DBusGMethodInvocation *context);
+static void impl_Cal_createObject (EDataCal *cal, const gchar *calobj, DBusGMethodInvocation *context);
+static void impl_Cal_modifyObject (EDataCal *cal, const gchar *calobj, const EDataCalObjModType mod, DBusGMethodInvocation *context);
+static void impl_Cal_removeObject (EDataCal *cal, const gchar *uid, const gchar *rid, const EDataCalObjModType mod, DBusGMethodInvocation *context);
+static void impl_Cal_receiveObjects (EDataCal *cal, const gchar *calobj, DBusGMethodInvocation *context);
+static void impl_Cal_sendObjects (EDataCal *cal, const gchar *calobj, DBusGMethodInvocation *context);
+static void impl_Cal_getAttachmentList (EDataCal *cal, gchar *uid, gchar *rid, DBusGMethodInvocation *context);
+static void impl_Cal_getQuery (EDataCal *cal, const gchar *sexp, DBusGMethodInvocation *context);
+static void impl_Cal_getTimezone (EDataCal *cal, const gchar *tzid, DBusGMethodInvocation *context);
+static void impl_Cal_addTimezone (EDataCal *cal, const gchar *tz, DBusGMethodInvocation *context);
+static void impl_Cal_setDefaultTimezone (EDataCal *cal, const gchar *tz, DBusGMethodInvocation *context);
+#include "e-data-cal-glue.h"
+
+enum
+{
+  AUTH_REQUIRED,
+  BACKEND_ERROR,
+  READ_ONLY,
+  MODE,
+  LAST_SIGNAL
+};
 
-#define PARENT_TYPE         BONOBO_TYPE_OBJECT
+static guint signals[LAST_SIGNAL] = { 0 };
 
-static BonoboObjectClass *parent_class;
+G_DEFINE_TYPE (EDataCal, e_data_cal, G_TYPE_OBJECT);
+
+#define E_DATA_CAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_DATA_CAL, EDataCalPrivate))
 
-/* Private part of the Cal structure */
 struct _EDataCalPrivate {
-	/* Our backend */
 	ECalBackend *backend;
-
-	/* Listener on the client we notify */
-	GNOME_Evolution_Calendar_CalListener listener;
-
-	/* Cache of live queries */
+	ESource *source;
 	GHashTable *live_queries;
 };
 
-/* Cal::get_uri method */
-static CORBA_char *
-impl_Cal_get_uri (PortableServer_Servant servant,
-		  CORBA_Environment *ev)
+/* Create the EDataCal error quark */
+GQuark
+e_data_cal_error_quark (void)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-	const gchar *str_uri;
-	CORBA_char *str_uri_copy;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	str_uri = e_cal_backend_get_uri (priv->backend);
-	str_uri_copy = CORBA_string_dup (str_uri);
-
-	return str_uri_copy;
+  static GQuark quark = 0;
+  if (!quark)
+    quark = g_quark_from_static_string ("e_data_cal_error");
+  return quark;
 }
 
+/* Class init */
+static void
+e_data_cal_class_init (EDataCalClass *e_data_cal_class)
+{
+	/* TODO: finalise dispose */
+
+	g_type_class_add_private (e_data_cal_class, sizeof (EDataCalPrivate));
+
+	signals[AUTH_REQUIRED] =
+	  g_signal_new ("auth-required",
+						G_OBJECT_CLASS_TYPE (e_data_cal_class),
+						G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+						0,
+						NULL, NULL,
+						g_cclosure_marshal_VOID__VOID,
+						G_TYPE_NONE, 0);
+	signals[BACKEND_ERROR] =
+	  g_signal_new ("backend-error",
+						G_OBJECT_CLASS_TYPE (e_data_cal_class),
+						G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+						0,
+						NULL, NULL,
+						g_cclosure_marshal_VOID__STRING,
+						G_TYPE_NONE, 1, G_TYPE_STRING);
+	signals[READ_ONLY] =
+	  g_signal_new ("readonly",
+						G_OBJECT_CLASS_TYPE (e_data_cal_class),
+						G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+						0,
+						NULL, NULL,
+						g_cclosure_marshal_VOID__BOOLEAN,
+						G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+	signals[MODE] =
+	  g_signal_new ("mode",
+						G_OBJECT_CLASS_TYPE (e_data_cal_class),
+						G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+						0,
+						NULL, NULL,
+						g_cclosure_marshal_VOID__INT,
+						G_TYPE_NONE, 1, G_TYPE_INT);
+
+	dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (e_data_cal_class), &dbus_glib_e_data_cal_object_info);
+
+	dbus_g_error_domain_register (E_DATA_CAL_ERROR, NULL, E_TYPE_DATA_CAL_CALL_STATUS);
+}
+
+/* Instance init */
 static void
-impl_Cal_open (PortableServer_Servant servant,
-	       CORBA_boolean only_if_exists,
-	       const CORBA_char *username,
-	       const CORBA_char *password,
-	       CORBA_Environment *ev)
+e_data_cal_init (EDataCal *ecal)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_open (priv->backend, cal, only_if_exists, username, password);
+	ecal->priv = E_DATA_CAL_GET_PRIVATE (ecal);
 }
 
-static void
-impl_Cal_remove (PortableServer_Servant servant,
-		 CORBA_Environment *ev)
+EDataCal *
+e_data_cal_new (ECalBackend *backend, ESource *source)
 {
 	EDataCal *cal;
-	EDataCalPrivate *priv;
+	cal = g_object_new (E_TYPE_DATA_CAL, NULL);
+	cal->priv->backend = backend;
+	cal->priv->source = source;
+	return cal;
+}
 
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
+ESource*
+e_data_cal_get_source (EDataCal *cal)
+{
+  return cal->priv->source;
+}
 
-	e_cal_backend_remove (priv->backend, cal);
+ECalBackend*
+e_data_cal_get_backend (EDataCal *cal)
+{
+  return cal->priv->backend;
 }
 
-/* Cal::isReadOnly method */
+/* EDataCal::getUri method */
 static void
-impl_Cal_isReadOnly (PortableServer_Servant servant,
-		     CORBA_Environment *ev)
+impl_Cal_get_uri (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_is_read_only (priv->backend, cal);
+	dbus_g_method_return (context, g_strdup (e_cal_backend_get_uri (cal->priv->backend)));
 }
 
-/* Cal::getEmailAddress method */
+/* EDataCal::open method */
 static void
-impl_Cal_getCalAddress (PortableServer_Servant servant,
-			CORBA_Environment *ev)
+impl_Cal_open (EDataCal *cal,
+	       gboolean only_if_exists,
+	       gchar *username,
+	       gchar *password, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
+	e_cal_backend_open (cal->priv->backend, cal, context, only_if_exists, username, password);
+}
 
-	e_cal_backend_get_cal_address (priv->backend, cal);
+/* EDataCal::close method */
+static gboolean
+impl_Cal_close (EDataCal *cal, GError **error)
+{
+	g_object_unref (cal);
+	return TRUE;
 }
 
-/* Cal::get_alarm_email_address method */
+/* EDataCal::remove method */
 static void
-impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant,
-			       CORBA_Environment *ev)
+impl_Cal_remove (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_alarm_email_address (priv->backend, cal);
+	e_cal_backend_remove (cal->priv->backend, cal, context);
 }
 
-/* Cal::get_ldap_attribute method */
+/* EDataCal::isReadOnly method */
 static void
-impl_Cal_getLdapAttribute (PortableServer_Servant servant,
-			   CORBA_Environment *ev)
+impl_Cal_isReadOnly (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_ldap_attribute (priv->backend, cal);
+	e_cal_backend_is_read_only (cal->priv->backend, cal);
+	dbus_g_method_return (context);
 }
 
-/* Cal::getSchedulingInformation method */
+/* EDataCal::getCalAddress method */
 static void
-impl_Cal_getStaticCapabilities (PortableServer_Servant servant,
-				CORBA_Environment *ev)
+impl_Cal_getCalAddress (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_static_capabilities (priv->backend, cal);
+	e_cal_backend_get_cal_address (cal->priv->backend, cal, context);
 }
 
-/* Cal::setMode method */
+/* EDataCal::getAlarmEmailAddress method */
 static void
-impl_Cal_setMode (PortableServer_Servant servant,
-		  GNOME_Evolution_Calendar_CalMode mode,
-		  CORBA_Environment *ev)
+impl_Cal_getAlarmEmailAddress (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_set_mode (priv->backend, mode);
+	e_cal_backend_get_alarm_email_address (cal->priv->backend, cal, context);
 }
 
+/* EDataCal::getLdapAttribute method */
 static void
-impl_Cal_getDefaultObject (PortableServer_Servant servant,
-			   CORBA_Environment *ev)
+impl_Cal_getLdapAttribute (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_default_object (priv->backend, cal);
+	e_cal_backend_get_ldap_attribute (cal->priv->backend, cal, context);
 }
 
-/* Cal::getObject method */
+/* EDataCal::getSchedulingInformation method */
 static void
-impl_Cal_getObject (PortableServer_Servant servant,
-		    const CORBA_char *uid,
-		    const CORBA_char *rid,
-		    CORBA_Environment *ev)
+impl_Cal_getStaticCapabilities (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_object (priv->backend, cal, uid, rid);
+	e_cal_backend_get_static_capabilities (cal->priv->backend, cal, context);
 }
 
-/* Cal::getObjectList method */
+/* EDataCal::setMode method */
 static void
-impl_Cal_getObjectList (PortableServer_Servant servant,
-			const CORBA_char *sexp,
-			CORBA_Environment *ev)
+impl_Cal_setMode (EDataCal *cal,
+		  EDataCalMode mode,
+		  DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-	EDataCalView *query;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	query = g_hash_table_lookup (priv->live_queries, sexp);
-	if (query) {
-		GList *matched_objects;
-
-		matched_objects = e_data_cal_view_get_matched_objects (query);
-		e_data_cal_notify_object_list (
-			cal,
-			e_data_cal_view_is_done (query) ? e_data_cal_view_get_done_status (query) : GNOME_Evolution_Calendar_Success,
-			matched_objects);
-
-		g_list_free (matched_objects);
-	} else
-		e_cal_backend_get_object_list (priv->backend, cal, sexp);
+	e_cal_backend_set_mode (cal->priv->backend, mode);
+	dbus_g_method_return (context);
 }
 
-/* Cal::getAttachmentList method */
+/* EDataCal::getDefaultObject method */
 static void
-impl_Cal_getAttachmentList (PortableServer_Servant servant,
-		    const CORBA_char *uid,
-		    const CORBA_char *rid,
-		    CORBA_Environment *ev)
+impl_Cal_getDefaultObject (EDataCal *cal, DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_attachment_list (priv->backend, cal, uid, rid);
+ 	e_cal_backend_get_default_object (cal->priv->backend, cal, context);
 }
 
-/* Cal::getChanges method */
+/* EDataCal::getObject method */
 static void
-impl_Cal_getChanges (PortableServer_Servant servant,
-		     const CORBA_char *change_id,
-		     CORBA_Environment *ev)
+impl_Cal_getObject (EDataCal *cal,
+		    const gchar *uid,
+		    const gchar *rid,
+		    DBusGMethodInvocation *context)
 {
-       EDataCal *cal;
-       EDataCalPrivate *priv;
+	e_cal_backend_get_object (cal->priv->backend, cal, context, uid, rid);
+}
 
-       cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-       priv = cal->priv;
+/* EDataCal::getObjectList method */
+static void
+impl_Cal_getObjectList (EDataCal *cal,
+			const gchar *sexp,
+			DBusGMethodInvocation *context)
+{
+		e_cal_backend_get_object_list (cal->priv->backend, cal, context, sexp);
+}
 
-       e_cal_backend_get_changes (priv->backend, cal, change_id);
+/* EDataCal::getChanges method */
+static void
+impl_Cal_getChanges (EDataCal *cal,
+		     const gchar *change_id,
+		     DBusGMethodInvocation *context)
+{
+       e_cal_backend_get_changes (cal->priv->backend, cal, context, change_id);
 }
 
-/* Cal::getFreeBusy method */
+/* EDataCal::getFreeBusy method */
 static void
-impl_Cal_getFreeBusy (PortableServer_Servant servant,
-		      const GNOME_Evolution_Calendar_UserList *user_list,
-		      const GNOME_Evolution_Calendar_Time_t start,
-		      const GNOME_Evolution_Calendar_Time_t end,
-		      CORBA_Environment *ev)
+impl_Cal_getFreeBusy (EDataCal *cal,
+		      const char **user_list,
+		      const gulong start,
+		      const gulong end,
+		      DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
 	GList *users = NULL;
 
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	/* convert the CORBA user list to a GList */
 	if (user_list) {
-		gint i;
+		int i;
 
-		for (i = 0; i < user_list->_length; i++)
-			users = g_list_append (users, user_list->_buffer[i]);
+		for (i = 0; user_list[i]; i++)
+			users = g_list_append (users, (gpointer)user_list[i]);
 	}
 
 	/* call the backend's get_free_busy method */
-	e_cal_backend_get_free_busy (priv->backend, cal, users, start, end);
+	e_cal_backend_get_free_busy (cal->priv->backend, cal, context, users, (time_t)start, (time_t)end);
 }
 
-/* Cal::discardAlarm method */
+/* EDataCal::discardAlarm method */
 static void
-impl_Cal_discardAlarm (PortableServer_Servant servant,
-		       const CORBA_char *uid,
-		       const CORBA_char *auid,
-		       CORBA_Environment *ev)
+impl_Cal_discardAlarm (EDataCal *cal,
+		       const gchar *uid,
+		       const gchar *auid,
+		       DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_discard_alarm (priv->backend, cal, uid, auid);
+	e_cal_backend_discard_alarm (cal->priv->backend, cal, context, uid, auid);
 }
 
+/* EDataCal::createObject method */
 static void
-impl_Cal_createObject (PortableServer_Servant servant,
-		       const CORBA_char *calobj,
-		       CORBA_Environment *ev)
+impl_Cal_createObject (EDataCal *cal,
+		       const gchar *calobj,
+		       DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_create_object (priv->backend, cal, calobj);
+	e_cal_backend_create_object (cal->priv->backend, cal, context, calobj);
 }
 
+/* EDataCal::modifyObject method */
 static void
-impl_Cal_modifyObject (PortableServer_Servant servant,
-		       const CORBA_char *calobj,
-		       const GNOME_Evolution_Calendar_CalObjModType mod,
-		       CORBA_Environment *ev)
+impl_Cal_modifyObject (EDataCal *cal,
+		       const gchar *calobj,
+		       const EDataCalObjModType mod,
+		       DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_modify_object (priv->backend, cal, calobj, mod);
+	e_cal_backend_modify_object (cal->priv->backend, cal, context, calobj, mod);
 }
 
-/* Cal::removeObject method */
+/* EDataCal::removeObject method */
 static void
-impl_Cal_removeObject (PortableServer_Servant servant,
-		       const CORBA_char *uid,
-		       const CORBA_char *rid,
-		       const GNOME_Evolution_Calendar_CalObjModType mod,
-		       CORBA_Environment *ev)
+impl_Cal_removeObject (EDataCal *cal,
+		       const gchar *uid,
+		       const gchar *rid,
+		       const EDataCalObjModType mod,
+		       DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
+	if (rid[0] == '\0')
+		rid = NULL;
 
-	e_cal_backend_remove_object (priv->backend, cal, uid, rid, mod);
+	e_cal_backend_remove_object (cal->priv->backend, cal, context, uid, rid, mod);
 }
 
+/* EDataCal::receiveObjects method */
 static void
-impl_Cal_receiveObjects (PortableServer_Servant servant,
-			 const CORBA_char *calobj,
-			 CORBA_Environment *ev)
+impl_Cal_receiveObjects (EDataCal *cal,
+			 const gchar *calobj,
+			 DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_receive_objects (priv->backend, cal, calobj);
+	e_cal_backend_receive_objects (cal->priv->backend, cal, context, calobj);
 }
 
+/* EDataCal::sendObjects method */
 static void
-impl_Cal_sendObjects (PortableServer_Servant servant,
-		      const CORBA_char *calobj,
-		      CORBA_Environment *ev)
+impl_Cal_sendObjects (EDataCal *cal,
+		      const gchar *calobj,
+		      DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_send_objects (priv->backend, cal, calobj);
+	e_cal_backend_send_objects (cal->priv->backend, cal, context, calobj);
 }
 
+/* EDataCal::getAttachmentList method */
 static void
-disconnect_query (gpointer key, EDataCalView *query, EDataCal *cal)
+impl_Cal_getAttachmentList (EDataCal *cal,
+                   gchar *uid,
+                   gchar *rid,
+                   DBusGMethodInvocation *context)
 {
-	g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, cal);
-	e_cal_backend_remove_query (cal->priv->backend, query);
+	e_cal_backend_get_attachment_list (cal->priv->backend, cal, context, uid, rid);
 }
 
-static void
-query_last_listener_gone_cb (EDataCalView *query, EDataCal *cal)
+/* Function to get a new EDataCalView path, used by getQuery below */
+static gchar*
+construct_calview_path (void)
 {
-	EDataCalPrivate *priv;
-
-	g_return_if_fail (cal != NULL);
-
-	priv = cal->priv;
-
-	disconnect_query (NULL, query, cal);
-	g_hash_table_remove (priv->live_queries, e_data_cal_view_get_text (query));
+  static guint counter = 1;
+  return g_strdup_printf ("/org/gnome/evolution/dataserver/calendar/CalView/%d/%d", getpid(), counter++);
 }
 
-/* Cal::getQuery implementation */
+/* EDataCal::getQuery method */
 static void
-impl_Cal_getQuery (PortableServer_Servant servant,
-		   const CORBA_char *sexp,
-		   GNOME_Evolution_Calendar_CalViewListener ql,
-		   CORBA_Environment *ev)
+impl_Cal_getQuery (EDataCal *cal,
+		   const gchar *sexp,
+		   DBusGMethodInvocation *context)
 {
-
-	EDataCal *cal;
-	EDataCalPrivate *priv;
 	EDataCalView *query;
 	ECalBackendSExp *obj_sexp;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	/* first see if we already have the query in the cache */
-	query = g_hash_table_lookup (priv->live_queries, sexp);
-	if (query) {
-		e_data_cal_view_add_listener (query, ql);
-		e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
-		return;
-	}
+	char *path;
 
 	/* we handle this entirely here, since it doesn't require any
 	   backend involvement now that we have e_cal_view_start to
@@ -433,276 +403,54 @@ impl_Cal_getQuery (PortableServer_Servant servant,
 
 	obj_sexp = e_cal_backend_sexp_new (sexp);
 	if (!obj_sexp) {
-		e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL);
-
+		e_data_cal_notify_query (cal, context, InvalidQuery, NULL);
 		return;
 	}
 
-	query = e_data_cal_view_new (priv->backend, ql, obj_sexp);
+	path = construct_calview_path ();
+	query = e_data_cal_view_new (cal->priv->backend, path, obj_sexp);
 	if (!query) {
 		g_object_unref (obj_sexp);
-		e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL);
-
+		e_data_cal_notify_query (cal, context, OtherError, NULL);
 		return;
 	}
 
-	g_signal_connect (query, "last_listener_gone", G_CALLBACK (query_last_listener_gone_cb), cal);
+	e_cal_backend_add_query (cal->priv->backend, query);
 
-	g_hash_table_insert (priv->live_queries, g_strdup (sexp), query);
-	e_cal_backend_add_query (priv->backend, query);
+	e_data_cal_notify_query (cal, context, Success, path);
 
-	e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
+        g_free (path);
 }
 
-/* Cal::getTimezone method */
+/* EDataCal::getTimezone method */
 static void
-impl_Cal_getTimezone (PortableServer_Servant servant,
-		      const CORBA_char *tzid,
-		      CORBA_Environment *ev)
+impl_Cal_getTimezone (EDataCal *cal,
+		      const gchar *tzid,
+		      DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_get_timezone (priv->backend, cal, tzid);
+	e_cal_backend_get_timezone (cal->priv->backend, cal, context, tzid);
 }
 
-/* Cal::addTimezone method */
-static void
-impl_Cal_addTimezone (PortableServer_Servant servant,
-		      const CORBA_char *tz,
-		      CORBA_Environment *ev)
-{
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
 
-	e_cal_backend_add_timezone (priv->backend, cal, tz);
-}
 
-/* Cal::setDefaultTimezone method */
+/* EDataCal::addTimezone method */
 static void
-impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
-			     const CORBA_char *tz,
-			     CORBA_Environment *ev)
+impl_Cal_addTimezone (EDataCal *cal,
+		      const gchar *tz,
+		      DBusGMethodInvocation *context)
 {
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-
-	cal = E_DATA_CAL (bonobo_object_from_servant (servant));
-	priv = cal->priv;
-
-	e_cal_backend_set_default_zone (priv->backend, cal, tz);
+	e_cal_backend_add_timezone (cal->priv->backend, cal, context, tz);
 }
 
-/**
- * e_data_cal_construct:
- * @cal: A calendar client interface.
- * @backend: Calendar backend that this @cal presents an interface to.
- * @listener: Calendar listener for notification.
- *
- * Constructs a calendar client interface object by binding the corresponding
- * CORBA object to it.  The calendar interface is bound to the specified
- * @backend, and will notify the @listener about changes to the calendar.
- *
- * Return value: The same object as the @cal argument.
- **/
-EDataCal *
-e_data_cal_construct (EDataCal *cal,
-		      ECalBackend *backend,
-		      GNOME_Evolution_Calendar_CalListener listener)
-{
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_val_if_fail (cal != NULL, NULL);
-	g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
-	g_return_val_if_fail (backend != NULL, NULL);
-	g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
-
-	priv = cal->priv;
-
-	CORBA_exception_init (&ev);
-	priv->listener = CORBA_Object_duplicate (listener, &ev);
-	if (BONOBO_EX (&ev)) {
-		g_message ("cal_construct: could not duplicate the listener");
-		priv->listener = CORBA_OBJECT_NIL;
-		CORBA_exception_free (&ev);
-		return NULL;
-	}
-
-	CORBA_exception_free (&ev);
-
-	priv->backend = backend;
-
-	return cal;
-}
-
-/**
- * e_data_cal_new:
- * @backend: A calendar backend.
- * @listener: A calendar listener.
- *
- * Creates a new calendar client interface object and binds it to the
- * specified @backend and @listener objects.
- *
- * Return value: A newly-created #EDataCal calendar client interface
- * object, or %NULL if its corresponding CORBA object could not be
- * created.
- **/
-EDataCal *
-e_data_cal_new (ECalBackend *backend, GNOME_Evolution_Calendar_CalListener listener)
-{
-	EDataCal *cal, *retval;
-
-	g_return_val_if_fail (backend != NULL, NULL);
-	g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
-
-	cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
-				 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
-				 NULL));
-
-	retval = e_data_cal_construct (cal, backend, listener);
-	if (!retval) {
-		g_message (G_STRLOC ": could not construct the calendar client interface");
-		bonobo_object_unref (BONOBO_OBJECT (cal));
-		return NULL;
-	}
-
-	return retval;
-}
-
-/**
- * e_data_cal_get_backend:
- * @cal: A calendar client interface.
- *
- * Gets the associated backend.
- *
- * Return value: An #ECalBackend.
- */
-ECalBackend *
-e_data_cal_get_backend (EDataCal *cal)
-{
-	g_return_val_if_fail (cal != NULL, NULL);
-	g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
-
-	return cal->priv->backend;
-}
-
-/**
- * e_data_cal_get_listener:
- * @cal: A calendar client interface.
- *
- * Gets the listener associated with a calendar client interface.
- *
- * Return value: The listener.
- */
-GNOME_Evolution_Calendar_CalListener
-e_data_cal_get_listener (EDataCal *cal)
-{
-	g_return_val_if_fail (cal != NULL, NULL);
-	g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
-
-	return cal->priv->listener;
-}
-
-/* Destroy handler for the calendar */
-static void
-e_data_cal_finalize (GObject *object)
-{
-	EDataCal *cal;
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (object != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (object));
-
-	cal = E_DATA_CAL (object);
-	priv = cal->priv;
-
-	priv->backend = NULL;
-
-	CORBA_exception_init (&ev);
-	bonobo_object_release_unref (priv->listener, &ev);
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not release the listener");
-
-	priv->listener = NULL;
-	CORBA_exception_free (&ev);
-
-	g_hash_table_foreach (priv->live_queries, (GHFunc) disconnect_query, cal);
-	g_hash_table_destroy (priv->live_queries);
-	priv->live_queries = NULL;
-
-	g_free (priv);
-
-	if (G_OBJECT_CLASS (parent_class)->finalize)
-		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-/* Class initialization function for the calendar */
-static void
-e_data_cal_class_init (EDataCalClass *klass)
-{
-	GObjectClass *object_class = (GObjectClass *) klass;
-	POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv;
-
-	parent_class = g_type_class_peek_parent (klass);
-
-	/* Class method overrides */
-	object_class->finalize = e_data_cal_finalize;
-
-	/* Epv methods */
-	epv->_get_uri = impl_Cal_get_uri;
-	epv->open = impl_Cal_open;
-	epv->remove = impl_Cal_remove;
-	epv->isReadOnly = impl_Cal_isReadOnly;
-	epv->getCalAddress = impl_Cal_getCalAddress;
-	epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress;
-	epv->getLdapAttribute = impl_Cal_getLdapAttribute;
-	epv->getStaticCapabilities = impl_Cal_getStaticCapabilities;
-	epv->setMode = impl_Cal_setMode;
-	epv->getDefaultObject = impl_Cal_getDefaultObject;
-	epv->getObject = impl_Cal_getObject;
-	epv->getTimezone = impl_Cal_getTimezone;
-	epv->addTimezone = impl_Cal_addTimezone;
-	epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
-	epv->getObjectList = impl_Cal_getObjectList;
-	epv->getAttachmentList = impl_Cal_getAttachmentList;
-	epv->getChanges = impl_Cal_getChanges;
-	epv->getFreeBusy = impl_Cal_getFreeBusy;
-	epv->discardAlarm = impl_Cal_discardAlarm;
-	epv->createObject = impl_Cal_createObject;
-	epv->modifyObject = impl_Cal_modifyObject;
-	epv->removeObject = impl_Cal_removeObject;
-	epv->receiveObjects = impl_Cal_receiveObjects;
-	epv->sendObjects = impl_Cal_sendObjects;
-	epv->getQuery = impl_Cal_getQuery;
-}
-
-/* Object initialization function for the calendar */
+/* EDataCal::setDefaultTimezone method */
 static void
-e_data_cal_init (EDataCal *cal, EDataCalClass *klass)
+impl_Cal_setDefaultTimezone (EDataCal *cal,
+			     const gchar *tz,
+			     DBusGMethodInvocation *context)
 {
-	EDataCalPrivate *priv;
-
-	priv = g_new0 (EDataCalPrivate, 1);
-	cal->priv = priv;
-
-	priv->listener = CORBA_OBJECT_NIL;
-	priv->live_queries = g_hash_table_new_full (g_str_hash, g_str_equal,
-						    (GDestroyNotify) g_free,
-						    (GDestroyNotify) bonobo_object_unref);
+	e_cal_backend_set_default_zone (cal->priv->backend, cal, context, tz);
 }
 
-BONOBO_TYPE_FUNC_FULL (EDataCal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, e_data_cal)
-
 /**
  * e_data_cal_notify_read_only:
  * @cal: A calendar client interface.
@@ -712,24 +460,12 @@ BONOBO_TYPE_FUNC_FULL (EDataCal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, e_da
  * Notifies listeners of the completion of the is_read_only method call.
  */
 void
-e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only)
+e_data_cal_notify_read_only (EDataCal *cal, EDataCalCallStatus status, gboolean read_only)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
 	g_return_if_fail (cal != NULL);
 	g_return_if_fail (E_IS_DATA_CAL (cal));
 
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyReadOnly (priv->listener, status, read_only, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of read only");
-
-	CORBA_exception_free (&ev);
+	g_signal_emit (cal, signals[READ_ONLY], 0, read_only);
 }
 
 /**
@@ -741,24 +477,13 @@ e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus
  * Notifies listeners of the completion of the get_cal_address method call.
  */
 void
-e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *address)
+e_data_cal_notify_cal_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *address)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyCalAddress (priv->listener, status, address ? address : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of cal address");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar address")));
+	else
+		dbus_g_method_return (method, address ? address : "");
 }
 
 /**
@@ -770,24 +495,13 @@ e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatu
  * Notifies listeners of the completion of the get_alarm_email_address method call.
  */
 void
-e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *address)
+e_data_cal_notify_alarm_email_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *address)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of alarm address");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar alarm e-mail address")));
+	else
+		dbus_g_method_return (method, address ? address : "");
 }
 
 /**
@@ -799,24 +513,13 @@ e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_C
  * Notifies listeners of the completion of the get_ldap_attribute method call.
  */
 void
-e_data_cal_notify_ldap_attribute (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *attribute)
+e_data_cal_notify_ldap_attribute (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const char *attribute)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of ldap attribute");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar's ldap attribute")));
+	else
+		dbus_g_method_return (method, attribute ? attribute : "");
 }
 
 /**
@@ -828,25 +531,13 @@ e_data_cal_notify_ldap_attribute (EDataCal *cal, GNOME_Evolution_Calendar_CallSt
  * Notifies listeners of the completion of the get_static_capabilities method call.
  */
 void
-e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *capabilities)
+e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *capabilities)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyStaticCapabilities (priv->listener, status,
-								    capabilities ? capabilities : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of static capabilities");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar scheduling information")));
+	else
+		dbus_g_method_return (method, capabilities ? capabilities : "");
 }
 
 /**
@@ -857,24 +548,13 @@ e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_C
  * Notifies listeners of the completion of the open method call.
  */
 void
-e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_notify_open (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyCalOpened (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of open");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot open calendar")));
+	else
+		dbus_g_method_return (method);
 }
 
 /**
@@ -885,24 +565,13 @@ e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus statu
  * Notifies listeners of the completion of the remove method call.
  */
 void
-e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyCalRemoved (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of remove");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot remove calendar")));
+	else
+		dbus_g_method_return (method);
 }
 
 /**
@@ -913,32 +582,17 @@ e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus sta
  * @object: The object created as an iCalendar string.
  *
  * Notifies listeners of the completion of the create_object method call.
- */
-void
-e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+ */void
+e_data_cal_notify_object_created (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				  const gchar *uid, const gchar *object)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	/* If the object is NULL, it means the object has been created on the server sucessfully,
-	   but it is not shown in the UI if delay delivery is set */
-	if (status == GNOME_Evolution_Calendar_Success && object)
-		e_cal_backend_notify_object_created (priv->backend, object);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of object creation");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot create calendar object")));
+	} else {
+		e_cal_backend_notify_object_created (cal->priv->backend, object);
+		dbus_g_method_return (method, uid ? uid : "");
+	}
 }
 
 /**
@@ -951,28 +605,16 @@ e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallSt
  * Notifies listeners of the completion of the modify_object method call.
  */
 void
-e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				   const gchar *old_object, const gchar *object)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	if (status == GNOME_Evolution_Calendar_Success)
-		e_cal_backend_notify_object_modified (priv->backend, old_object, object);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyObjectModified (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of object creation");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot modify calender object")));
+	} else {
+		e_cal_backend_notify_object_modified (cal->priv->backend, old_object, object);
+		dbus_g_method_return (method);
+	}
 }
 
 /**
@@ -987,28 +629,16 @@ e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallS
  * Notifies listeners of the completion of the remove_object method call.
  */
 void
-e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+e_data_cal_notify_object_removed (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				  const ECalComponentId *id, const gchar *old_object, const gchar *object)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	if (status == GNOME_Evolution_Calendar_Success)
-		e_cal_backend_notify_object_removed (priv->backend, id, old_object, object);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of object removal");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot remove calendar object")));
+	} else {
+		e_cal_backend_notify_object_removed (cal->priv->backend, id, old_object, object);
+		dbus_g_method_return (method);
+	}
 }
 
 /**
@@ -1019,24 +649,13 @@ e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallSt
  * Notifies listeners of the completion of the receive_objects method call.
  */
 void
-e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_notify_objects_received (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyObjectsReceived (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of objects received");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot receive calendar objects")));
+	else
+		dbus_g_method_return (method);
 }
 
 /**
@@ -1047,24 +666,13 @@ e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_Call
  * Notifies listeners of the completion of the discard_alarm method call.
  */
 void
-e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_notify_alarm_discarded (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyAlarmDiscarded (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of alarm discarded");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot discard calendar alarm")));
+	else
+		dbus_g_method_return (method);
 }
 
 /**
@@ -1077,38 +685,30 @@ e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallS
  * Notifies listeners of the completion of the send_objects method call.
  */
 void
-e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, const gchar *calobj)
-{
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-	GNOME_Evolution_Calendar_UserList *corba_users;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	corba_users = GNOME_Evolution_Calendar_UserList__alloc ();
-	corba_users->_length = g_list_length (users);
-	if (users) {
-		GList *l;
-		gint n;
-
-		corba_users->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (corba_users->_length);
-		for (l = users, n = 0; l != NULL; l = l->next, n++)
-			corba_users->_buffer[n] = CORBA_string_dup (l->data);
+e_data_cal_notify_objects_sent (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *users, const gchar *calobj)
+{
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot send calendar objects")));
+	} else {
+		char **users_array = NULL;
+
+		if (users) {
+			GList *l;
+			char **user;
+
+			users_array = g_new0 (char *, g_list_length (users)+1);
+			if (users_array)
+				for (l = users, user = users_array; l != NULL; l = l->next, user++)
+					*user = g_strdup (l->data);
+		}
+		else
+			users_array = g_new0 (char *, 1);
+
+		dbus_g_method_return (method, users_array, calobj ? calobj : "");
+		if (users_array)
+			g_strfreev (users_array);
 	}
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, corba_users,
-								calobj ? calobj : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of objects sent");
-
-	CORBA_exception_free (&ev);
-	CORBA_free (corba_users);
 }
 
 /**
@@ -1120,26 +720,13 @@ e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStat
  * Notifies listeners of the completion of the get_default_object method call.
  */
 void
-e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *object)
+e_data_cal_notify_default_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *object)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-
-	GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
-									   object ? object : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of default object");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve default calendar object path")));
+	else
+		dbus_g_method_return (method, object ? object : "");
 }
 
 /**
@@ -1151,26 +738,13 @@ e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallSt
  * Notifies listeners of the completion of the get_object method call.
  */
 void
-e_data_cal_notify_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *object)
+e_data_cal_notify_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *object)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-
-	GNOME_Evolution_Calendar_CalListener_notifyObjectRequested (priv->listener, status,
-								    object ? object : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of object");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar object path")));
+	else
+		dbus_g_method_return (method, object ? object : "");
 }
 
 /**
@@ -1182,39 +756,25 @@ e_data_cal_notify_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus sta
  * Notifies listeners of the completion of the get_object_list method call.
  */
 void
-e_data_cal_notify_object_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects)
+e_data_cal_notify_object_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *objects)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-	GNOME_Evolution_Calendar_stringlist seq;
-	GList *l;
-	gint i;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar object list")));
+	} else {
+		char **seq = NULL;
+		GList *l;
+		int i;
 
-	CORBA_exception_init (&ev);
+		seq = g_new0 (char *, g_list_length (objects)+1);
+		for (l = objects, i = 0; l; l = l->next, i++) {
+			seq[i] = l->data;
+		}
 
-	seq._maximum = g_list_length (objects);
-	seq._length = 0;
-	seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
+		dbus_g_method_return (method, seq);
 
-	for (l = objects, i = 0; l; l = l->next, i++) {
-		seq._buffer[i] = CORBA_string_dup (l->data);
-		seq._length++;
+		g_free (seq);
 	}
-
-	GNOME_Evolution_Calendar_CalListener_notifyObjectListRequested (priv->listener, status, &seq, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of object list");
-
-	CORBA_exception_free (&ev);
-
-	CORBA_free(seq._buffer);
 }
 
 /**
@@ -1223,42 +783,24 @@ e_data_cal_notify_object_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatu
  * @status: Status code.
  * @attachments: List of retrieved attachment uri's.
  *
- * Notifies listeners of the completion of the get_attachment_list method call.
- */
+ * Notifies listeners of the completion of the get_attachment_list method call.+ */
 void
-e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GSList *attachments)
+e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GSList *attachments)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-	GNOME_Evolution_Calendar_stringlist seq;
+	DBusGMethodInvocation *method = context;
+	char **seq;
 	GSList *l;
-	gint i;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-
-	seq._maximum = g_slist_length (attachments);
-	seq._length = 0;
-	seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
+	int i;
 
+	seq = g_new0 (char *, g_slist_length (attachments));
 	for (l = attachments, i = 0; l; l = l->next, i++) {
-		seq._buffer[i] = CORBA_string_dup (l->data);
-		seq._length++;
+		seq[i] = g_strdup (l->data);
 	}
 
-	GNOME_Evolution_Calendar_CalListener_notifyAttachmentListRequested (priv->listener, status, &seq, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of object list");
-
-	CORBA_exception_free (&ev);
-
-	CORBA_free(seq._buffer);
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not retrieve attachment list")));
+	else
+		dbus_g_method_return (method, seq);
 }
 
 /**
@@ -1270,24 +812,17 @@ e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallS
  * Notifies listeners of the completion of the get_query method call.
  */
 void
-e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, EDataCalView *query)
+e_data_cal_notify_query (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *query)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (cal != NULL);
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message (G_STRLOC ": could not notify the listener of query");
-
-	CORBA_exception_free (&ev);
+	/*
+	 * Only have a seperate notify function to follow suit with the rest of this
+	 * file - it'd be much easier to just do the return in the above function
+	 */
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not complete calendar query")));
+	else
+		dbus_g_method_return (method, query);
 }
 
 /**
@@ -1299,23 +834,13 @@ e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus stat
  * Notifies listeners of the completion of the get_timezone method call.
  */
 void
-e_data_cal_notify_timezone_requested (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *object)
+e_data_cal_notify_timezone_requested (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *object)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_warning (G_STRLOC ": could not notify the listener of timezone requested");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not retrieve calendar time zone")));
+	else
+		dbus_g_method_return (method, object ? object : "");
 }
 
 /**
@@ -1327,23 +852,13 @@ e_data_cal_notify_timezone_requested (EDataCal *cal, GNOME_Evolution_Calendar_Ca
  * Notifies listeners of the completion of the add_timezone method call.
  */
 void
-e_data_cal_notify_timezone_added (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const gchar *tzid)
+e_data_cal_notify_timezone_added (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, const gchar *tzid)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev);
-
-	if (BONOBO_EX (&ev))
-		g_warning (G_STRLOC ": could not notify the listener of timezone added");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not add calendar time zone")));
+	else
+		dbus_g_method_return (method, tzid ? tzid : "");
 }
 
 /**
@@ -1354,23 +869,13 @@ e_data_cal_notify_timezone_added (EDataCal *cal, GNOME_Evolution_Calendar_CallSt
  * Notifies listeners of the completion of the set_default_timezone method call.
  */
 void
-e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
+e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyDefaultTimezoneSet (priv->listener, status, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_warning (G_STRLOC ": could not notify the listener of default timezone set");
-
-	CORBA_exception_free (&ev);
+	DBusGMethodInvocation *method = context;
+	if (status != Success)
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Could not set default calendar time zone")));
+	else
+		dbus_g_method_return (method);
 }
 
 /**
@@ -1384,56 +889,46 @@ e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_
  * Notifies listeners of the completion of the get_changes method call.
  */
 void
-e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+e_data_cal_notify_changes (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 			   GList *adds, GList *modifies, GList *deletes)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-	GNOME_Evolution_Calendar_CalObjChangeSeq seq;
-	GList *l;
-	gint n, i;
-
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes);
-	seq._maximum = n;
-	seq._length = n;
-	seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n);
-
-	i = 0;
-	for (l = adds; l; i++, l = l->next) {
-		GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
-
-		change->calobj = CORBA_string_dup (l->data);
-		change->type = GNOME_Evolution_Calendar_ADDED;
-	}
-
-	for (l = modifies; l; i++, l = l->next) {
-		GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
-
-		change->calobj = CORBA_string_dup (l->data);
-		change->type = GNOME_Evolution_Calendar_MODIFIED;
-	}
-
-	for (l = deletes; l; i++, l = l->next) {
-		GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
-
-		change->calobj = CORBA_string_dup (l->data);
-		change->type = GNOME_Evolution_Calendar_DELETED;
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar changes")));
+	} else {
+		char **additions, **modifications, **removals;
+		GList *l;
+		int i;
+
+		additions = NULL;
+		if (adds) {
+			additions = g_new0 (char *, g_list_length (adds) + 1);
+			if (additions)
+				for (i = 0, l = adds; l; i++, l = l->next)
+					additions[i] = g_strdup (l->data);
+		}
+
+		modifications = NULL;
+		if (modifies) {
+			modifications = g_new0 (char *, g_list_length (modifies) + 1);
+			if (modifications)
+				for (i = 0, l = modifies; l; i++, l = l->next)
+					modifications[i] = g_strdup (l->data);
+		}
+
+		removals = NULL;
+		if (deletes) {
+			removals = g_new0 (char *, g_list_length (deletes) + 1);
+			if (removals)
+				for (i = 0, l = deletes; l; i++, l = l->next)
+					removals[i] = g_strdup (l->data);
+		}
+
+		dbus_g_method_return (method, additions, modifications, removals);
+		if (additions) g_strfreev (additions);
+		if (modifications) g_strfreev (modifications);
+		if (removals) g_strfreev (removals);
 	}
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyChanges (priv->listener, status, &seq, &ev);
-
-	CORBA_free (seq._buffer);
-
-	if (BONOBO_EX (&ev))
-		g_warning (G_STRLOC ": could not notify the listener of default timezone set");
-
-	CORBA_exception_free (&ev);
 }
 
 /**
@@ -1445,36 +940,24 @@ e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus st
  * Notifies listeners of the completion of the get_free_busy method call.
  */
 void
-e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy)
+e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *freebusy)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-	GNOME_Evolution_Calendar_CalObjSeq seq;
-	GList *l;
-	gint n, i;
-
-	g_return_if_fail (E_IS_DATA_CAL (cal));
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	n = g_list_length (freebusy);
-	seq._maximum = n;
-	seq._length = n;
-	seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n);
-
-	for (i = 0, l = freebusy; l; i++, l = l->next)
-		seq._buffer[i] = CORBA_string_dup (l->data);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyFreeBusy (priv->listener, status, &seq, &ev);
-
-	CORBA_free (seq._buffer);
+	DBusGMethodInvocation *method = context;
+	if (status != Success) {
+		dbus_g_method_return_error (method, g_error_new (E_DATA_CAL_ERROR, status, _("Cannot retrieve calendar free/busy list")));
+	} else {
+		char **seq;
+		GList *l;
+		int i;
 
-	if (BONOBO_EX (&ev))
-		g_warning (G_STRLOC ": could not notify the listener of freebusy");
+		seq = g_new0 (char *, g_list_length (freebusy));
+		for (i = 0, l = freebusy; l; i++, l = l->next) {
+			seq[i] = g_strdup (l->data);
+		}
 
-	CORBA_exception_free (&ev);
+		dbus_g_method_return (method, seq);
+		g_strfreev (seq);
+	}
 }
 
 /**
@@ -1487,26 +970,13 @@ e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus
  **/
 void
 e_data_cal_notify_mode (EDataCal *cal,
-			GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
-			GNOME_Evolution_Calendar_CalMode mode)
+			EDataCalViewListenerSetModeStatus status,
+			EDataCalMode mode)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
 	g_return_if_fail (cal != NULL);
 	g_return_if_fail (E_IS_DATA_CAL (cal));
 
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyCalSetMode (priv->listener, status, mode, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message ("e_data_cal_notify_mode(): could not notify the listener "
-			   "about a mode change");
-
-	CORBA_exception_free (&ev);
+	g_signal_emit (cal, signals[MODE], 0, mode);
 }
 
 /**
@@ -1518,22 +988,10 @@ e_data_cal_notify_mode (EDataCal *cal,
 void
 e_data_cal_notify_auth_required (EDataCal *cal)
 {
-       EDataCalPrivate *priv;
-       CORBA_Environment ev;
-
-       g_return_if_fail (cal != NULL);
-       g_return_if_fail (E_IS_DATA_CAL (cal));
-
-       priv = cal->priv;
-       g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-       CORBA_exception_init (&ev);
-       GNOME_Evolution_Calendar_CalListener_notifyAuthRequired (priv->listener,  &ev);
-       if (BONOBO_EX (&ev))
-		g_message ("e_data_cal_notify_auth_required: could not notify the listener "
-			   "about auth required");
+	g_return_if_fail (cal != NULL);
+	g_return_if_fail (E_IS_DATA_CAL (cal));
 
-	CORBA_exception_free (&ev);
+	g_signal_emit (cal, signals[AUTH_REQUIRED], 0);
 }
 
 /**
@@ -1546,22 +1004,8 @@ e_data_cal_notify_auth_required (EDataCal *cal)
 void
 e_data_cal_notify_error (EDataCal *cal, const gchar *message)
 {
-	EDataCalPrivate *priv;
-	CORBA_Environment ev;
-
 	g_return_if_fail (cal != NULL);
 	g_return_if_fail (E_IS_DATA_CAL (cal));
-	g_return_if_fail (message != NULL);
-
-	priv = cal->priv;
-	g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
-
-	CORBA_exception_init (&ev);
-	GNOME_Evolution_Calendar_CalListener_notifyErrorOccurred (priv->listener, (gchar *) message, &ev);
-
-	if (BONOBO_EX (&ev))
-		g_message ("e_data_cal_notify_remove(): could not notify the listener "
-			   "about a removed object");
 
-	CORBA_exception_free (&ev);
+	g_signal_emit (cal, signals[BACKEND_ERROR], 0, message);
 }
diff --git a/calendar/libedata-cal/e-data-cal.h b/calendar/libedata-cal/e-data-cal.h
index 4d2af00..bae69e0 100644
--- a/calendar/libedata-cal/e-data-cal.h
+++ b/calendar/libedata-cal/e-data-cal.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /* Evolution calendar client interface object
  *
  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
@@ -22,10 +23,11 @@
 #ifndef E_DATA_CAL_H
 #define E_DATA_CAL_H
 
-#include <bonobo/bonobo-object.h>
-#include <libedata-cal/Evolution-DataServer-Calendar.h>
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
 #include <libedata-cal/e-data-cal-common.h>
 #include <libedata-cal/e-data-cal-view.h>
+#include <libedata-cal/e-data-cal-types.h>
 
 G_BEGIN_DECLS
 
@@ -37,88 +39,83 @@ G_BEGIN_DECLS
 #define E_IS_DATA_CAL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DATA_CAL))
 #define E_IS_DATA_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DATA_CAL))
 
+GQuark e_data_cal_error_quark (void);
+#define E_DATA_CAL_ERROR e_data_cal_error_quark ()
+
 typedef struct _EDataCalPrivate EDataCalPrivate;
 
 struct _EDataCal {
-	BonoboObject object;
-
-	/* Private data */
+	GObject parent;
 	EDataCalPrivate *priv;
 };
 
 struct _EDataCalClass {
-	BonoboObjectClass parent_class;
-
-	POA_GNOME_Evolution_Calendar_Cal__epv epv;
+	GObjectClass parent_class;
 };
 
 GType e_data_cal_get_type (void);
 
-EDataCal *e_data_cal_construct (EDataCal *cal,
-		    ECalBackend *backend,
-		    GNOME_Evolution_Calendar_CalListener listener);
-
-EDataCal *e_data_cal_new (ECalBackend *backend, GNOME_Evolution_Calendar_CalListener listener);
+EDataCal *e_data_cal_new (ECalBackend *backend, ESource *source);
 
 ECalBackend *e_data_cal_get_backend (EDataCal *cal);
-GNOME_Evolution_Calendar_CalListener e_data_cal_get_listener (EDataCal *cal);
+ESource* e_data_cal_get_source (EDataCal *cal);
 
-void e_data_cal_notify_read_only           (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_read_only           (EDataCal *cal, EDataCalCallStatus status,
 					    gboolean read_only);
-void e_data_cal_notify_cal_address         (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_cal_address         (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					    const gchar *address);
-void e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_alarm_email_address (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					    const gchar *address);
-void e_data_cal_notify_ldap_attribute      (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_ldap_attribute      (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					    const gchar *attribute);
-void e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_static_capabilities (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					    const gchar *capabilities);
 
-void e_data_cal_notify_open   (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
-void e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
+void e_data_cal_notify_open   (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
+void e_data_cal_notify_remove (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
 
-void e_data_cal_notify_object_created  (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object_created  (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					const gchar *uid, const gchar *object);
-void e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object_modified (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					const gchar *old_object, const gchar *object);
-void e_data_cal_notify_object_removed  (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object_removed  (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					const ECalComponentId *id, const gchar *old_object, const gchar *object);
-void e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
+void e_data_cal_notify_alarm_discarded (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
 
-void e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
-void e_data_cal_notify_objects_sent     (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users,
+void e_data_cal_notify_objects_received (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
+void e_data_cal_notify_objects_sent     (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GList *users,
 					 const gchar *calobj);
 
-void e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_default_object (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				       const gchar *object);
-void e_data_cal_notify_object         (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object         (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				       const gchar *object);
-void e_data_cal_notify_object_list    (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_object_list    (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				       GList *objects);
 
-void e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
-			      EDataCalView *query);
+void e_data_cal_notify_query (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
+			      const gchar *query_path);
 
-void e_data_cal_notify_timezone_requested   (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_timezone_requested   (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					     const gchar *object);
-void e_data_cal_notify_timezone_added       (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_timezone_added       (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 					     const gchar *tzid);
-void e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
+void e_data_cal_notify_default_timezone_set (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status);
 
-void e_data_cal_notify_changes   (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_changes   (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				  GList *adds, GList *modifies, GList *deletes);
-void e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
+void e_data_cal_notify_free_busy (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status,
 				  GList *freebusy);
 
 void e_data_cal_notify_mode  (EDataCal *cal,
-			      GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
-			      GNOME_Evolution_Calendar_CalMode mode);
+			      EDataCalViewListenerSetModeStatus status,
+			      EDataCalMode mode);
 
 void e_data_cal_notify_auth_required (EDataCal *cal);
 
 void e_data_cal_notify_error (EDataCal *cal, const gchar *message);
 
-void e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GSList *objects);
+void e_data_cal_notify_attachment_list (EDataCal *cal, EServerMethodContext context, EDataCalCallStatus status, GSList *objects);
 
 G_END_DECLS
 
diff --git a/calendar/libedata-cal/e-data-cal.xml b/calendar/libedata-cal/e-data-cal.xml
new file mode 100644
index 0000000..fad272b
--- /dev/null
+++ b/calendar/libedata-cal/e-data-cal.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node>
+	<interface name="org.gnome.evolution.dataserver.calendar.Cal">
+		<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EDataCal"/>
+		
+		<signal name="auth-required"/>
+
+		<signal name="backend-error">
+                  <arg name="error" type="s"/>
+                </signal>
+
+		<signal name="readonly">
+                  <arg name="is_readonly" type="b"/>
+                </signal>
+
+		<signal name="mode">
+                  <arg name="mode" type="i"/>
+                </signal>
+		
+		<method name="getUri">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_get_uri"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="str_uri_copy" type="s" direction="out"/>
+		</method>
+		
+		<method name="open">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_open"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="only_if_exists" type="b" direction="in"/>
+			<arg name="username" type="s" direction="in"/>
+			<arg name="password" type="s" direction="in"/>
+		</method>
+
+		<method name="close">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_close"/>
+		</method>
+		
+		<method name="remove">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_remove"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+		</method>		
+
+		<method name="isReadOnly">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_isReadOnly"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+		</method>		
+
+		<method name="getCalAddress">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getCalAddress"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="address" type="s" direction="out"/>
+		</method>
+		
+		<method name="getAlarmEmailAddress">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getAlarmEmailAddress"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="address" type="s" direction="out"/>
+		</method>
+
+		<method name="getLdapAttribute">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getLdapAttribute"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="address" type="s" direction="out"/>
+		</method>
+
+		<method name="getSchedulingInformation">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getStaticCapabilities"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="capabilities" type="s" direction="out"/>
+		</method>
+
+		<method name="setMode">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_setMode"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="mode" type="u" direction="in"/>
+			<!--FIXME: This method should return mode/status-->
+			<!--<arg name="mode" type="u" direction="out"/>-->
+		</method>
+
+		<method name="getDefaultObject">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getDefaultObject"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="object" type="s" direction="out"/>
+		</method>
+
+		<method name="getObject">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getObject"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="uid" type="s" direction="in"/>
+			<arg name="rid" type="s" direction="in"/>
+			<arg name="object" type="s" direction="out"/>
+		</method>
+
+		<method name="getObjectList">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getObjectList"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="sexp" type="s" direction="in"/>
+			<arg name="objects" type="as" direction="out"/>
+		</method>
+
+		<method name="getChanges">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getChanges"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="change_id" type="s" direction="in"/>
+			<arg name="additions" type="as" direction="out"/>
+			<arg name="modifications" type="as" direction="out"/>
+			<arg name="removals" type="as" direction="out"/>
+		</method>
+
+		<method name="getFreeBusy">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getFreeBusy"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="user_list" type="as" direction="in"/>
+			<arg name="start" type="u" direction="in"/>
+			<arg name="end" type="u" direction="in"/>
+			<arg name="freebusy" type="as" direction="out"/>
+		</method>
+
+		<method name="discardAlarm">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_discardAlarm"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="uid" type="s" direction="in"/>
+			<arg name="auid" type="s" direction="in"/>
+		</method>
+
+		<method name="createObject">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_createObject"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="calobj" type="s" direction="in"/>
+			<arg name="uid" type="s" direction="out"/>
+		</method>
+
+		<method name="modifyObject">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_modifyObject"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="calobj" type="s" direction="in"/>
+			<arg name="mod" type="u" direction="in"/>
+		</method>
+
+		<method name="removeObject">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_removeObject"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="uid" type="s" direction="in"/>
+			<arg name="rid" type="s" direction="in"/>
+			<arg name="mod" type="u" direction="in"/>
+		</method>
+
+		<method name="receiveObjects">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_receiveObjects"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="calobj" type="s" direction="in"/>
+		</method>
+
+		<method name="sendObjects">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_sendObjects"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="calobj" type="s" direction="in"/>
+			<arg name="users" type="as" direction="out"/>
+			<arg name="calobj" type="s" direction="out"/>
+		</method>
+
+		<method name="getAttachmentList">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getAttachmentList"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="uid" type="s" direction="in"/>
+			<arg name="rid" type="s" direction="in"/>
+			<arg name="attachments" type="as" direction="out"/>
+		</method>
+		
+		<method name="getQuery">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getQuery"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="sexp" type="s" direction="in"/>
+			<arg name="query" type="o" direction="out"/>
+		</method>
+
+		<method name="getTimezone">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getTimezone"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="tzid" type="s" direction="in"/>
+			<arg name="object" type="s" direction="out"/>
+		</method>
+
+		<method name="addTimezone">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_addTimezone"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="tz" type="s" direction="in"/>
+		</method>
+
+		<method name="setDefaultTimezone">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_setDefaultTimezone"/>
+			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+			<arg name="tz" type="s" direction="in"/>
+		</method>
+		
+	</interface>
+</node>
diff --git a/calendar/libedata-cal/libedata-cal.pc.in b/calendar/libedata-cal/libedata-cal.pc.in
index 94bfb37..d16017f 100644
--- a/calendar/libedata-cal/libedata-cal.pc.in
+++ b/calendar/libedata-cal/libedata-cal.pc.in
@@ -5,14 +5,11 @@ includedir= includedir@
 datarootdir= datarootdir@
 datadir= datadir@
 
-idldir= idldir@
-IDL_INCLUDES=-I${idldir} @IDL_INCLUDES@
-
 privincludedir= privincludedir@
 
 Name: libedata-cal
 Description: Backend library for evolution calendars
 Version: @VERSION@
-Requires: libbonobo-2.0 >= @LIBBONOBO_REQUIRED@ libical >= @LIBICAL_REQUIRED@ libedataserver-1.2 libebackend-1.2 libecal-1.2 gio-2.0
+Requires: dbus-glib-1 libical >= @LIBICAL_REQUIRED@ libedataserver-1.2 libecal-1.2
 Libs: -L${libdir} -ledata-cal-1.2 -lecal-1.2
 Cflags: -I${privincludedir}
diff --git a/calendar/libedata-cal/org.gnome.evolution.dataserver.Calendar.service.in b/calendar/libedata-cal/org.gnome.evolution.dataserver.Calendar.service.in
new file mode 100644
index 0000000..4d70a61
--- /dev/null
+++ b/calendar/libedata-cal/org.gnome.evolution.dataserver.Calendar.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.evolution.dataserver.Calendar
+Exec= LIBEXECDIR@/e-calendar-factory



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