[evolution-couchdb] calendar: Make it compile with both e-d-s 3.0 and 3.1



commit 089370cfdf533f77ce3ffb18bd3f8a05e1dd7712
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Jun 17 17:02:47 2011 +0200

    calendar: Make it compile with both e-d-s 3.0 and 3.1

 calendar/e-cal-backend-couchdb.c |  212 +++++++++++++++++++++++++++++++++++---
 1 files changed, 195 insertions(+), 17 deletions(-)
---
diff --git a/calendar/e-cal-backend-couchdb.c b/calendar/e-cal-backend-couchdb.c
index 316fa48..e43de7c 100644
--- a/calendar/e-cal-backend-couchdb.c
+++ b/calendar/e-cal-backend-couchdb.c
@@ -21,6 +21,7 @@
 
 #include <string.h>
 #include "e-cal-backend-couchdb.h"
+#include <libedataserver/eds-version.h>
 #include <libedata-cal/e-cal-backend-sexp.h>
 #include <libedata-cal/e-data-cal.h>
 #include <libedata-cal/e-data-cal-view.h>
@@ -177,8 +178,12 @@ put_document (ECalBackendCouchDB *couchdb_backend, CouchdbDocument *document, GE
 
 /* Virtual methods */
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCancellable *cancellable, gboolean only_if_exists)
+#else
+e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists, const gchar *username, const gchar *password)
+#endif
 {
 	g_warning ("In _open");
 	gchar *uri, *cache_filename;
@@ -192,7 +197,11 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCa
 
 	source = e_cal_backend_get_source (backend);
 	if (!(E_IS_CAL_BACKEND_COUCHDB (couchdb_backend))) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_open (cal, opid, e_data_cal_create_error (ObjectNotFound, "Invalid CouchDB backend"));
+#else
+		e_data_cal_notify_open (cal, context, e_data_cal_create_error (ObjectNotFound, "Invalid CouchDB backend"));
+#endif
 	}
 
 	if (couchdb_backend->couchdb != NULL)
@@ -209,7 +218,11 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCa
 	if (g_strcmp0 (property, "user") == 0) {
 		if (! (couchdb_backend->couchdb = COUCHDB_SESSION (desktopcouch_session_new ()))) {
 			g_warning ("Could not create DesktopcouchSession object");
+#if EDS_CHECK_VERSION(3, 1, 0)
 			e_data_cal_respond_open (cal, opid, e_data_cal_create_error (NoSuchCal, "Could not create DesktopcouchSession object"));
+#else
+			e_data_cal_notify_open (cal, context, e_data_cal_create_error (NoSuchCal, "Could not create DesktopcouchSession object"));
+#endif
 
 			return;
 		}
@@ -223,7 +236,12 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCa
 
 		if (! (couchdb_backend->couchdb = couchdb_session_new (uri))) {
 			g_free (uri);
+
+#if EDS_CHECK_VERSION(3, 1, 0)
 			e_data_cal_respond_open (cal, opid, e_data_cal_create_error (NoSuchCal, "Could not create CouchdbSession object"));
+#else
+			e_data_cal_notify_open (cal, context, e_data_cal_create_error (NoSuchCal, "Could not create CouchdbSession object"));
+#endif
 
 			return;
 		}
@@ -243,12 +261,21 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCa
 	if (!couchdb_backend->database) {
 		if (error) {
 			g_warning ("Could not get CouchDB database info: %s", error->message);
+#if EDS_CHECK_VERSION(3, 1, 0)
 			e_data_cal_respond_open (cal, opid, e_data_cal_create_error (ObjectNotFound, error->message));
+#else
+			e_data_cal_notify_open (cal, context, e_data_cal_create_error (ObjectNotFound, error->message));
+#endif
 			g_error_free (error);
 		}
 
-		if (only_if_exists)
+		if (only_if_exists) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 			e_data_cal_respond_open (cal, opid, e_data_cal_create_error_fmt (NoSuchCal, "Database %s does not exist", db_name));
+#else
+			e_data_cal_notify_open (cal, context, e_data_cal_create_error_fmt (NoSuchCal, "Database %s does not exist", db_name));
+#endif
+		}
 		
 		/* if it does not exist, create it */
 		error = NULL;
@@ -257,7 +284,11 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCa
 						      &error)) {
 			g_warning ("Could not create 'tasks' database: %s", error->message);
 
+#if EDS_CHECK_VERSION(3, 1, 0)
 			e_data_cal_respond_open (cal, opid, e_data_cal_create_error (PermissionDenied, error->message));
+#else
+			e_data_cal_notify_open (cal, context, e_data_cal_create_error (PermissionDenied, error->message));
+#endif
 			g_error_free (error);
 
 			return;
@@ -314,12 +345,20 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCa
 
 	e_cal_backend_notify_readonly (backend, FALSE);
 	e_cal_backend_notify_online (backend, TRUE);
+#if EDS_CHECK_VERSION(3, 1, 0)
 	e_data_cal_respond_open (cal, opid, NULL);
+#else
+	e_data_cal_notify_open (cal, context, NULL);
+#endif
 	
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_remove (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable)
+#else
+e_cal_backend_couchdb_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
+#endif
 {
 	g_warning ("In _remove");
 	ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
@@ -335,13 +374,21 @@ e_cal_backend_couchdb_remove (ECalBackend *backend, EDataCal *cal, guint32 opid,
 
 	/* We don't remove data from CouchDB, since it would affect other apps,
 	   so just report success */
+#if EDS_CHECK_VERSION(3, 1, 0)
 	e_data_cal_respond_remove (cal, opid, NULL);
+#else
+	e_data_cal_notify_remove (cal, context, NULL);
+#endif
 }
 
 /* Object related virtual methods */
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
+#else
+e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
+#endif
 {
 	g_warning ("In _create_object");
 	ECalComponent *task, *new_task;
@@ -356,17 +403,27 @@ e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, guint3
 	// g_warning("UID:%s", uid);
  
 	if (!task) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_create_object (cal, opid,
+#else
+		e_data_cal_notify_object_created (cal, context,
+#endif
 						  e_data_cal_create_error (InvalidObject, "Invalid object"),
 						  uid, calobj);
+
 		return;
 	}
 
 	document = couch_document_from_task (couchdb_backend, task);
 	if (!document) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_create_object (cal, opid,
+#else
+  		e_data_cal_notify_object_created (cal, context,
+#endif
 						  e_data_cal_create_error_fmt (OtherError, "Object %s cannot be converted to a CouchdbDocumentTask", uid),
 						  uid, calobj);
+						  
 		g_object_unref (G_OBJECT (task));
 
 		return;
@@ -378,12 +435,20 @@ e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, guint3
 
 		e_cal_component_get_uid (new_task, &uid);
 		new_calobj = e_cal_component_get_as_string (new_task);
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_create_object (cal, opid, NULL, uid, new_calobj);
+#else
+		e_data_cal_notify_object_created (cal, context, NULL, uid, new_calobj);
+#endif
 
 		g_object_unref (new_task);
 		g_free (new_calobj);
 	} else {
-		e_data_cal_respond_create_object (cal, opid, 
+#if EDS_CHECK_VERSION(3, 1, 0)
+		e_data_cal_respond_create_object (cal, opid,
+#else
+                e_data_cal_notify_object_created (cal, context,
+#endif
 						  e_data_cal_create_error (OtherError, error->message),
 						  uid, NULL);
 		g_error_free (error);
@@ -394,13 +459,21 @@ e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, guint3
 	g_object_unref (G_OBJECT (document));
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_modify_object (ECalBackend *backend,
 				     EDataCal *cal,
 				     guint32 opid,
 				     GCancellable *cancellable,
 				     const gchar *calobj,
 				     CalObjModType mod)
+#else
+e_cal_backend_couchdb_modify_object (ECalBackend *backend,
+				     EDataCal *cal,
+				     EServerMethodContext context,
+				     const gchar *calobj,
+				     CalObjModType mod)
+#endif
 {
 	ECalComponent *task, *new_task;
 	CouchdbDocument *document;
@@ -409,7 +482,11 @@ e_cal_backend_couchdb_modify_object (ECalBackend *backend,
 
 	task = e_cal_component_new_from_string (calobj);
 	if (!task) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_modify_object (cal, opid,
+#else
+                e_data_cal_notify_object_modified (cal, context,
+#endif
 						  e_data_cal_create_error (OtherError, "Invalid object"),
 						  NULL, NULL);
 		return;
@@ -417,7 +494,11 @@ e_cal_backend_couchdb_modify_object (ECalBackend *backend,
 
 	document = couch_document_from_task (couchdb_backend, task);
 	if (!document) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_modify_object (cal, opid,
+#else
+                e_data_cal_notify_object_modified (cal, context,
+#endif
 						  e_data_cal_create_error (OtherError, "Invalid object"),
 						  NULL, NULL);
 		g_object_unref (G_OBJECT (document));
@@ -430,12 +511,20 @@ e_cal_backend_couchdb_modify_object (ECalBackend *backend,
 
 		e_cal_component_commit_sequence (new_task);
 		new_calobj = e_cal_component_get_as_string (new_task);
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_modify_object (cal, opid, NULL, calobj, new_calobj);
+#else
+		e_data_cal_notify_object_modified (cal, context, NULL, calobj, new_calobj);
+#endif
 
 		g_object_unref (new_task);
 		g_free (new_calobj);
 	} else {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_modify_object (cal, opid,
+#else
+		e_data_cal_notify_object_modified (cal, context,
+#endif
 						  e_data_cal_create_error (OtherError, error->message),
 						  NULL, NULL);
 		g_error_free (error);
@@ -446,7 +535,8 @@ e_cal_backend_couchdb_modify_object (ECalBackend *backend,
 	g_object_unref (G_OBJECT (document));
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_remove_object (ECalBackend *backend,
 				     EDataCal *cal,
 				     guint32 opid,
@@ -454,6 +544,14 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend,
 				     const gchar *uid,
 				     const gchar *rid,
 				     CalObjModType mod)
+#else
+e_cal_backend_couchdb_remove_object (ECalBackend *backend,
+				     EDataCal *cal,
+				     EServerMethodContext context,
+				     const gchar *uid,
+				     const gchar *rid,
+				     CalObjModType mod)
+#endif
 {
 	g_warning ("In _remove_object");
 
@@ -528,9 +626,17 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend,
 
 	if (deleted) {
 		g_warning ("In _remove_object: object removed successfully");
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_remove_object (cal, opid, NULL, &id, NULL, NULL);
+#else
+		e_data_cal_notify_object_removed (cal, context, NULL, &id, NULL, NULL);
+#endif
 	} else {
+#if EDS_CHECK_VERSION(3, 1, 0)
 		e_data_cal_respond_remove_object (cal, opid,
+#else
+                e_data_cal_notify_object_removed (cal, context,
+#endif
 						  e_data_cal_create_error (OtherError, error->message),
 						  &id, NULL, NULL);
 		g_error_free (error);
@@ -539,6 +645,7 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend,
 
 /* Discard_alarm handler for the calendar backend */
 void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_discard_alarm (ECalBackend *backend,
 				     EDataCal *cal,
 				     guint32 opid,
@@ -546,21 +653,40 @@ e_cal_backend_couchdb_discard_alarm (ECalBackend *backend,
 				     const gchar *uid,
 				     const gchar *rid,
 				     const gchar *auid)
+#else
+e_cal_backend_couchdb_discard_alarm (ECalBackend *backend,
+				     EDataCal *cal,
+				     EServerMethodContext context,
+				     const gchar *uid,
+				     const gchar *auid)
+#endif
 {
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_receive_objects (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
+#else
+e_cal_backend_couchdb_receive_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
+#endif
 {
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_send_objects (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
+#else
+e_cal_backend_couchdb_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
+#endif
 {
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_get_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *uid, const gchar *rid)
+#else
+e_cal_backend_couchdb_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
+#endif
 {
 	g_warning ("In _get_object");
 	GError *error = NULL;
@@ -574,21 +700,38 @@ e_cal_backend_couchdb_get_object (ECalBackend *backend, EDataCal *cal, guint32 o
 
 		g_object_unref (G_OBJECT (task));
 		if (task_string != NULL) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 			e_data_cal_respond_get_object (cal, opid, NULL, task_string);
+#else
+			e_data_cal_notify_object (cal, context, NULL, task_string);
+#endif
+
 			g_free (task_string);
 			return;
 		}
 	}
 
+#if EDS_CHECK_VERSION(3, 1, 0)
 	e_data_cal_respond_get_object (cal, opid, e_data_cal_create_error_fmt (ObjectNotFound, "Object %s not found", uid), NULL);
+#else
+	e_data_cal_notify_object (cal, context,e_data_cal_create_error_fmt (ObjectNotFound, "Object %s not found", uid), NULL);
+#endif
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_get_object_list (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *sexp)
+#else
+e_cal_backend_couchdb_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp)
+#endif
 {
 	g_warning ("In _get_object_list");
 	GList *doc_list;
+#if EDS_CHECK_VERSION(3, 1, 0)
 	GSList *tasks = NULL;
+#else
+	GList *tasks = NULL;
+#endif
 	GError *error = NULL;
 	ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
 
@@ -601,32 +744,56 @@ e_cal_backend_couchdb_get_object_list (ECalBackend *backend, EDataCal *cal, guin
 
 		e_cal_component_commit_sequence (task);
 		task_string = e_cal_component_get_as_string (task);
-		if (!task_string)
+		if (!task_string) {
+#if EDS_CHECK_VERSION(3, 1, 0)
 			tasks = g_slist_prepend (tasks, task_string);
+#else
+			tasks = g_list_prepend (tasks, task_string);
+#endif
+		}
 
 		doc_list = g_list_remove (doc_list, task);
 		g_object_unref (G_OBJECT (task));
 	}
 
+#if EDS_CHECK_VERSION(3, 1, 0)
 	e_data_cal_respond_get_object_list (cal, opid, NULL, tasks);
 
 	g_slist_foreach (tasks, (GFunc) g_free, NULL);
 	g_slist_free (tasks);
+#else
+	e_data_cal_notify_object_list (cal, context, NULL, tasks);
+
+	g_list_foreach (tasks, (GFunc) g_free, NULL);
+	g_list_free (tasks);
+#endif
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_get_attachment_uris (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *uid, const gchar *rid)
+#else
+e_cal_backend_couchdb_get_attachment_uris (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
+#endif
 {
 }
 
 /* Timezone related virtual methods */
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_get_timezone (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *tzid)
+#else
+e_cal_backend_couchdb_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
+#endif
 {
 }
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_add_timezone (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *object)
+#else
+e_cal_backend_couchdb_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *object)
+#endif
 {
 }
 
@@ -664,8 +831,12 @@ e_cal_backend_couchdb_start_view (ECalBackend *backend, EDataCalView *query)
 }
 
 
-void 
+void
+#if EDS_CHECK_VERSION(3, 1, 0)
 e_cal_backend_couchdb_get_free_busy (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const GSList *users, time_t start, time_t end)
+#else
+e_cal_backend_couchdb_get_free_busy (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end)
+#endif
 {
 }
 
@@ -723,14 +894,21 @@ e_cal_backend_couchdb_class_init (ECalBackendCouchDBClass *klass)
 	parent_class->get_object	      = e_cal_backend_couchdb_get_object;
 	parent_class->get_object_list         = e_cal_backend_couchdb_get_object_list;
 
+#if EDS_CHECK_VERSION(3, 1, 0)
 	parent_class->get_attachment_uris     = e_cal_backend_couchdb_get_attachment_uris;
-
+#else
+	parent_class->get_attachment_list     = e_cal_backend_couchdb_get_attachment_uris;
+#endif
 
 	// Timezone related virtual methods 
 	parent_class->get_timezone            = e_cal_backend_couchdb_get_timezone;
 	parent_class->add_timezone            = e_cal_backend_couchdb_add_timezone;
 
+#if EDS_CHECK_VERSION(3, 1, 0)
 	parent_class->start_view             = e_cal_backend_couchdb_start_view;
+#else
+	parent_class->start_query            = e_cal_backend_couchdb_start_view;
+#endif
 
 	// Mode relate virtual methods 
 	parent_class->get_free_busy           = e_cal_backend_couchdb_get_free_busy;



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