[evolution-couchdb] calendar: Make backend build with latest e-d-s
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-couchdb] calendar: Make backend build with latest e-d-s
- Date: Fri, 17 Jun 2011 12:33:06 +0000 (UTC)
commit ab391bd9b105e7520e9cf279c45615b28f250392
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Fri Jun 17 14:32:59 2011 +0200
calendar: Make backend build with latest e-d-s
Makefile.am | 2 +-
calendar/e-cal-backend-couchdb.c | 449 ++++++++++++++------------------------
calendar/e-cal-backend-couchdb.h | 5 +-
configure.ac | 1 +
4 files changed, 166 insertions(+), 291 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 6128ecd..3ea08a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = addressbook plugins po
+SUBDIRS = addressbook calendar plugins po
EXTRA_DIST = LICENSE
diff --git a/calendar/e-cal-backend-couchdb.c b/calendar/e-cal-backend-couchdb.c
index f3497d5..316fa48 100644
--- a/calendar/e-cal-backend-couchdb.c
+++ b/calendar/e-cal-backend-couchdb.c
@@ -49,7 +49,7 @@ task_from_couch_document (CouchdbDocument *document)
return NULL;
/* Check if the task is marked for deletion */
- if ((app_annotations = desktopcouch_document_get_application_annotations (document))) {
+ if ((app_annotations = couchdb_document_get_application_annotations (document))) {
CouchdbStructField *u1_annotations;
u1_annotations = couchdb_struct_field_get_struct_field (
@@ -71,7 +71,7 @@ task_from_couch_document (CouchdbDocument *document)
// Fill in the ECalComponent with the data from the CouchDBDocument
task = e_cal_component_new ();
e_cal_component_set_new_vtype (task, E_CAL_COMPONENT_TODO);
- summary.value = (const gchar *)desktopcouch_document_task_get_summary (document);
+ summary.value = (const gchar *) couchdb_document_task_get_summary (COUCHDB_DOCUMENT_TASK (document));
summary.altrep = NULL;
uid = couchdb_document_get_id (document);
@@ -89,14 +89,14 @@ couch_document_from_task (ECalBackendCouchDB *couchdb_backend, ECalComponent *ta
const char *uid;
// create the CouchDBDocument to put on the database
- document = desktopcouch_document_task_new (couchdb_backend->couchdb);
+ document = COUCHDB_DOCUMENT (couchdb_document_task_new ());
e_cal_component_get_summary (task, &summary);
e_cal_component_get_uid (task, &uid);
summary.altrep = NULL;
- desktopcouch_document_task_set_summary (document, (const char *)summary.value);
+ couchdb_document_task_set_summary (COUCHDB_DOCUMENT_TASK (document), (const char *)summary.value);
if (uid)
couchdb_document_set_id (document, uid);
@@ -104,16 +104,13 @@ couch_document_from_task (ECalBackendCouchDB *couchdb_backend, ECalComponent *ta
}
static void
-document_updated_cb (CouchdbSession *couchdb, const char *dbname, CouchdbDocument *document, gpointer user_data)
+document_updated_cb (CouchdbDatabase *database, CouchdbDocument *document, gpointer user_data)
{
ECalComponent *task;
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (user_data);
const gchar *uid, *task_string;
- if (g_strcmp0 (dbname, couchdb_backend->dbname) != 0)
- return;
-
task = task_from_couch_document (document);
if (!task)
return;
@@ -138,7 +135,7 @@ document_updated_cb (CouchdbSession *couchdb, const char *dbname, CouchdbDocumen
static void
-document_deleted_cb (CouchdbSession *couchdb, const char *dbname, const char *docid, gpointer user_data)
+document_deleted_cb (CouchdbDatabase *database, const char *docid, gpointer user_data)
{
g_warning ("In document_deleted_cb");
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (user_data);
@@ -146,9 +143,6 @@ document_deleted_cb (CouchdbSession *couchdb, const char *dbname, const char *do
id.uid = (gchar *)docid;
- if (g_strcmp0 (dbname, couchdb_backend->dbname) != 0)
- return;
-
e_cal_backend_notify_object_removed (E_CAL_BACKEND (couchdb_backend), &id, NULL, NULL);
// Remove the task from the cache
@@ -156,11 +150,11 @@ document_deleted_cb (CouchdbSession *couchdb, const char *dbname, const char *do
}
static ECalComponent *
-put_document (ECalBackendCouchDB *couchdb_backend, CouchdbDocument *document)
+put_document (ECalBackendCouchDB *couchdb_backend, CouchdbDocument *document, GError **error)
{
- GError *error = NULL;
+ *error = NULL;
- if (couchdb_document_put (document, couchdb_backend->dbname, &error)) {
+ if (couchdb_database_put_document (couchdb_backend->database, document, error)) {
ECalComponent *new_task;
/* couchdb_document_put sets the ID for new documents, so need to send that back */
@@ -173,8 +167,7 @@ put_document (ECalBackendCouchDB *couchdb_backend, CouchdbDocument *document)
} else {
if (error != NULL) {
- g_warning ("Could not PUT document: %s\n", error->message);
- g_error_free (error);
+ g_warning ("Could not PUT document: %s\n", ((GError *) *error)->message);
}
}
@@ -184,65 +177,12 @@ put_document (ECalBackendCouchDB *couchdb_backend, CouchdbDocument *document)
/* Virtual methods */
-/* Is read only handler for the calendar backend */
-void
-e_cal_backend_couchdb_is_read_only (ECalBackend *backend, EDataCal *cal)
-{
- g_warning ("In _is_read_only");
- e_data_cal_notify_read_only (cal, GNOME_Evolution_Calendar_Success, FALSE);
-}
-
-/* Returns the email address of the person who opened the calendar */
-void
-e_cal_backend_couchdb_get_cal_address (ECalBackend *backend, EDataCal *cal)
-{
- g_warning ("In _get_cal_address");
- /* FIXME */
- const gchar *address;
- address = NULL;
- e_data_cal_notify_cal_address (cal, GNOME_Evolution_Calendar_Success, address);
-}
-
-/* Email based alarms */
-void
-e_cal_backend_couchdb_get_alarm_email_address (ECalBackend *backend, EDataCal *cal)
-{
- g_warning ("In _get_alarm_email_address");
- /* FIXME */
- const gchar *address;
- address = NULL;
- e_data_cal_notify_alarm_email_address (cal, GNOME_Evolution_Calendar_Success, address);
-}
-
-void
-e_cal_backend_couchdb_get_ldap_attribute (ECalBackend *backend, EDataCal *cal)
-{
- g_warning ("In _get_ldap_attribute");
- /* FIXME */
- const gchar *attribute;
- attribute = NULL;
- e_data_cal_notify_ldap_attribute (cal, GNOME_Evolution_Calendar_Success, attribute);
-}
-
-void
-e_cal_backend_couchdb_get_static_capabilities (ECalBackend *backend, EDataCal *cal)
-{
- g_warning ("In _get_static_capabilities");
- /* FIXME */
- const gchar *capabilities;
-
- capabilities = g_strdup ("local,do-initial-query,bulk-removes");
-
- e_data_cal_notify_static_capabilities(cal, GNOME_Evolution_Calendar_Success, capabilities);
-}
-
void
-e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const gchar *username, const gchar *password)
+e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, guint opid, GCancellable *cancellable, gboolean only_if_exists)
{
g_warning ("In _open");
- gchar *uri;
- const gchar *property;
- CouchdbDatabaseInfo *db_info;
+ gchar *uri, *cache_filename;
+ const gchar *property, *db_name, *cache_dir;
GError *error = NULL;
GSList *doc_list, *sl;
@@ -252,25 +192,26 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, gboolean only_i
source = e_cal_backend_get_source (backend);
if (!(E_IS_CAL_BACKEND_COUCHDB (couchdb_backend))) {
- e_data_cal_notify_open (cal, GNOME_Evolution_Calendar_OtherError);
+ e_data_cal_respond_open (cal, opid, e_data_cal_create_error (ObjectNotFound, "Invalid CouchDB backend"));
}
if (couchdb_backend->couchdb != NULL)
g_object_unref (G_OBJECT (couchdb_backend->couchdb));
- if (couchdb_backend->dbname != NULL)
- g_free (couchdb_backend->dbname);
+ if (couchdb_backend->database != NULL)
+ g_object_unref (couchdb_backend->database);
if (couchdb_backend->cache != NULL)
g_object_unref (G_OBJECT (couchdb_backend->cache));
/* create CouchDB main object */
- couchdb_backend->dbname = g_strdup ("tasks");
couchdb_backend->using_desktopcouch = FALSE;
property = e_source_get_property (source, "couchdb_instance");
if (g_strcmp0 (property, "user") == 0) {
if (! (couchdb_backend->couchdb = COUCHDB_SESSION (desktopcouch_session_new ()))) {
g_warning ("Could not create DesktopcouchSession object");
- e_data_cal_notify_open (cal, GNOME_Evolution_Calendar_NoSuchCal);
+ e_data_cal_respond_open (cal, opid, e_data_cal_create_error (NoSuchCal, "Could not create DesktopcouchSession object"));
+
+ return;
}
couchdb_backend->using_desktopcouch = TRUE;
@@ -282,69 +223,72 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, gboolean only_i
if (! (couchdb_backend->couchdb = couchdb_session_new (uri))) {
g_free (uri);
- e_data_cal_notify_open (cal, GNOME_Evolution_Calendar_NoSuchCal);
+ e_data_cal_respond_open (cal, opid, e_data_cal_create_error (NoSuchCal, "Could not create CouchdbSession object"));
+
+ return;
}
g_free (uri);
}
+ db_name = e_source_get_property (source, "couchdb_database");
+ if (db_name == NULL)
+ db_name = "tasks";
+
/* check if only_if_exists */
error = NULL;
- db_info = couchdb_session_get_database_info (couchdb_backend->couchdb,
- couchdb_backend->dbname,
- &error);
- if (!db_info) {
+ couchdb_backend->database = couchdb_session_get_database (couchdb_backend->couchdb,
+ db_name,
+ &error);
+ if (!couchdb_backend->database) {
if (error) {
g_warning ("Could not get CouchDB database info: %s", error->message);
+ e_data_cal_respond_open (cal, opid, e_data_cal_create_error (ObjectNotFound, error->message));
g_error_free (error);
}
if (only_if_exists)
- e_data_cal_notify_open (cal, GNOME_Evolution_Calendar_NoSuchCal);
+ e_data_cal_respond_open (cal, opid, e_data_cal_create_error_fmt (NoSuchCal, "Database %s does not exist", db_name));
/* if it does not exist, create it */
error = NULL;
if (!couchdb_session_create_database (couchdb_backend->couchdb,
- couchdb_backend->dbname,
+ db_name,
&error)) {
g_warning ("Could not create 'tasks' database: %s", error->message);
+
+ e_data_cal_respond_open (cal, opid, e_data_cal_create_error (PermissionDenied, error->message));
g_error_free (error);
- e_data_cal_notify_open (cal, GNOME_Evolution_Calendar_PermissionDenied);
+ return;
}
- } else
- couchdb_database_info_unref (db_info);
- g_warning ("CREATE CACHE BEGIN");
+ couchdb_backend->database = couchdb_session_get_database (couchdb_backend->couchdb,
+ db_name,
+ &error);
+ }
/* Create cache */
- // uri = e_source_get_uri (source);
- //couchdb_backend->cache = e_cal_backend_cache_new ((const gchar *) uri, E_CAL_SOURCE_TYPE_TODO);
- couchdb_backend->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (couchdb_backend)), E_CAL_SOURCE_TYPE_TODO);
- //g_free (uri);
-
- g_warning ("CREATE CACHE FINISH");
+ cache_dir = e_cal_backend_get_cache_dir (backend);
+ cache_filename = g_build_filename (cache_dir,
+ couchdb_session_get_uri (couchdb_backend->couchdb),
+ "cache.xml", NULL);
+ g_debug ("Creating cache at %s", cache_filename);
+ couchdb_backend->cache = e_cal_backend_cache_new ((const gchar *) cache_filename);
+ g_free (cache_filename);
/* Populate the cache */
e_file_cache_clean (E_FILE_CACHE (couchdb_backend->cache));
error = NULL;
- doc_list = couchdb_session_list_documents (couchdb_backend->couchdb,
- couchdb_backend->dbname,
- &error);
+ doc_list = couchdb_database_get_all_documents (couchdb_backend->database,
+ &error);
for (sl = doc_list; sl != NULL; sl = sl->next) {
ECalComponent *task;
CouchdbDocument *document;
CouchdbDocumentInfo *doc_info = (CouchdbDocumentInfo *) sl->data;
- /* Retrieve this document */
- error = NULL;
- document = couchdb_document_get (couchdb_backend->couchdb,
- couchdb_backend->dbname,
- couchdb_document_info_get_docid (doc_info),
- &error);
- if (!document)
- continue;
+ document = COUCHDB_DOCUMENT (sl->data);
task = task_from_couch_document (document);
if (task != NULL) {
@@ -352,32 +296,30 @@ e_cal_backend_couchdb_open (ECalBackend *backend, EDataCal *cal, gboolean only_i
g_object_unref (G_OBJECT (task));
}
- g_object_unref (G_OBJECT (document));
}
+ couchdb_session_free_document_list (doc_list);
+
/* Timezone */
// e_cal_backend_cache_put_default_timezone (couchdb_backend->cache, couchdb_backend->default_zone);
- couchdb_session_free_document_list (doc_list);
-
/* Listen for changes on database */
- g_signal_connect (G_OBJECT (couchdb_backend->couchdb), "document_created",
+ g_signal_connect (G_OBJECT (couchdb_backend->database), "document_created",
G_CALLBACK (document_updated_cb), couchdb_backend);
- g_signal_connect (G_OBJECT (couchdb_backend->couchdb), "document_updated",
+ g_signal_connect (G_OBJECT (couchdb_backend->database), "document_updated",
G_CALLBACK (document_updated_cb), couchdb_backend);
- g_signal_connect (G_OBJECT (couchdb_backend->couchdb), "document_deleted",
+ g_signal_connect (G_OBJECT (couchdb_backend->database), "document_deleted",
G_CALLBACK (document_deleted_cb), couchdb_backend);
- couchdb_session_listen_for_changes (couchdb_backend->couchdb, couchdb_backend->dbname);
+ couchdb_database_listen_for_changes (couchdb_backend->database);
- //e_cal_backend_set_is_loaded (backend, TRUE);
- //e_cal_backend_set_is_writable (backend, TRUE);
-
- e_data_cal_notify_open (cal, GNOME_Evolution_Calendar_Success);
+ e_cal_backend_notify_readonly (backend, FALSE);
+ e_cal_backend_notify_online (backend, TRUE);
+ e_data_cal_respond_open (cal, opid, NULL);
}
void
-e_cal_backend_couchdb_remove (ECalBackend *backend, EDataCal *cal)
+e_cal_backend_couchdb_remove (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable)
{
g_warning ("In _remove");
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
@@ -393,19 +335,20 @@ e_cal_backend_couchdb_remove (ECalBackend *backend, EDataCal *cal)
/* We don't remove data from CouchDB, since it would affect other apps,
so just report success */
- e_data_cal_notify_remove (cal, GNOME_Evolution_Calendar_Success);
+ e_data_cal_respond_remove (cal, opid, NULL);
}
/* Object related virtual methods */
void
-e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
{
g_warning ("In _create_object");
ECalComponent *task, *new_task;
CouchdbDocument *document;
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
const gchar *uid;
+ GError *error = NULL;
task = e_cal_component_new_from_string (calobj);
e_cal_component_get_uid (task, &uid);
@@ -413,24 +356,38 @@ e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, const
// g_warning("UID:%s", uid);
if (!task) {
- e_data_cal_notify_object_created (cal, GNOME_Evolution_Calendar_OtherError, uid, NULL);
+ e_data_cal_respond_create_object (cal, opid,
+ e_data_cal_create_error (InvalidObject, "Invalid object"),
+ uid, calobj);
return;
}
document = couch_document_from_task (couchdb_backend, task);
if (!document) {
- e_data_cal_notify_object_created (cal, GNOME_Evolution_Calendar_OtherError, uid, NULL);
+ e_data_cal_respond_create_object (cal, opid,
+ 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;
}
/* save the task into the DB */
- if ((new_task = put_document (couchdb_backend, document)) != NULL) {
- g_warning ("In _open: saving the task into the DB");
- e_data_cal_notify_object_created (cal, GNOME_Evolution_Calendar_Success, uid, calobj);
+ if ((new_task = put_document (couchdb_backend, document, &error)) != NULL) {
+ gchar *new_calobj;
+
+ e_cal_component_get_uid (new_task, &uid);
+ new_calobj = e_cal_component_get_as_string (new_task);
+ e_data_cal_respond_create_object (cal, opid, NULL, uid, new_calobj);
+
g_object_unref (new_task);
- } else
- e_data_cal_notify_object_created (cal, GNOME_Evolution_Calendar_OtherError, uid, NULL);
+ g_free (new_calobj);
+ } else {
+ e_data_cal_respond_create_object (cal, opid,
+ e_data_cal_create_error (OtherError, error->message),
+ uid, NULL);
+ g_error_free (error);
+ }
/* free memory */
g_object_unref (G_OBJECT (task));
@@ -438,42 +395,65 @@ e_cal_backend_couchdb_create_object (ECalBackend *backend, EDataCal *cal, const
}
void
-e_cal_backend_couchdb_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod)
+e_cal_backend_couchdb_modify_object (ECalBackend *backend,
+ EDataCal *cal,
+ guint32 opid,
+ GCancellable *cancellable,
+ const gchar *calobj,
+ CalObjModType mod)
{
- g_warning ("In _modify_object");
ECalComponent *task, *new_task;
CouchdbDocument *document;
+ GError *error = NULL;
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
task = e_cal_component_new_from_string (calobj);
if (!task) {
- e_data_cal_notify_object_modified (cal, GNOME_Evolution_Calendar_OtherError, NULL, NULL);
+ e_data_cal_respond_modify_object (cal, opid,
+ e_data_cal_create_error (OtherError, "Invalid object"),
+ NULL, NULL);
return;
}
document = couch_document_from_task (couchdb_backend, task);
if (!document) {
- e_data_cal_notify_object_modified (cal, GNOME_Evolution_Calendar_OtherError, NULL, NULL);
+ e_data_cal_respond_modify_object (cal, opid,
+ e_data_cal_create_error (OtherError, "Invalid object"),
+ NULL, NULL);
g_object_unref (G_OBJECT (document));
return;
}
/* save the task into the DB */
- if ((new_task = put_document (couchdb_backend, document)) != NULL) {
+ if ((new_task = put_document (couchdb_backend, document, &error)) != NULL) {
+ gchar *new_calobj;
+
e_cal_component_commit_sequence (new_task);
- e_data_cal_notify_object_modified (cal, GNOME_Evolution_Calendar_Success, calobj, e_cal_component_get_as_string (new_task));
+ new_calobj = e_cal_component_get_as_string (new_task);
+ e_data_cal_respond_modify_object (cal, opid, NULL, calobj, new_calobj);
+
g_object_unref (new_task);
- } else
- e_data_cal_notify_object_modified (cal, GNOME_Evolution_Calendar_OtherError, NULL, NULL);
+ g_free (new_calobj);
+ } else {
+ e_data_cal_respond_modify_object (cal, opid,
+ e_data_cal_create_error (OtherError, error->message),
+ NULL, NULL);
+ g_error_free (error);
+ }
/* free memory */
g_object_unref (G_OBJECT (task));
g_object_unref (G_OBJECT (document));
- e_data_cal_notify_object_modified (cal, GNOME_Evolution_Calendar_OtherError, NULL, NULL);
}
void
-e_cal_backend_couchdb_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod)
+e_cal_backend_couchdb_remove_object (ECalBackend *backend,
+ EDataCal *cal,
+ guint32 opid,
+ GCancellable *cancellable,
+ const gchar *uid,
+ const gchar *rid,
+ CalObjModType mod)
{
g_warning ("In _remove_object");
@@ -483,17 +463,17 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend, EDataCal *cal, const
ECalComponentId id;
gboolean deleted;
- id.uid = (gchar *)uid;
- id.rid = (gchar *)rid;
+ id.uid = (gchar *) uid;
+ id.rid = (gchar *) rid;
- document = couchdb_document_get (couchdb_backend->couchdb, couchdb_backend->dbname, uid, &error);
+ document = couchdb_database_get_document (couchdb_backend->database, uid, &error);
if (document) {
if (couchdb_backend->using_desktopcouch) {
CouchdbStructField *app_annotations, *u1_annotations, *private_annotations;
/* For desktopcouch, we don't remove tasks, we just
* mark them as deleted */
- app_annotations = desktopcouch_document_get_application_annotations (document);
+ app_annotations = couchdb_document_get_application_annotations (document);
if (app_annotations == NULL)
app_annotations = couchdb_struct_field_new ();
@@ -511,7 +491,7 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend, EDataCal *cal, const
desktopcouch_document_set_application_annotations (document, app_annotations);
/* Now put the new revision of the document */
- if (couchdb_document_put (document, couchdb_backend->dbname, &error)) {
+ if (put_document (couchdb_backend, document, &error)) {
deleted = TRUE;
e_cal_backend_cache_remove_component (couchdb_backend->cache, uid, rid);
} else {
@@ -534,7 +514,6 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend, EDataCal *cal, const
} else {
if (error != NULL) {
g_warning ("Error deleting document: %s", error->message);
- g_error_free (error);
} else
g_warning ("Error deleting document");
}
@@ -549,58 +528,39 @@ e_cal_backend_couchdb_remove_object (ECalBackend *backend, EDataCal *cal, const
if (deleted) {
g_warning ("In _remove_object: object removed successfully");
- e_data_cal_notify_object_removed (cal, GNOME_Evolution_Calendar_Success, &id, NULL, NULL);
+ e_data_cal_respond_remove_object (cal, opid, NULL, &id, NULL, NULL);
} else {
- g_warning ("In _remove_object: object not removed successfully");
- e_data_cal_notify_object_removed (cal, GNOME_Evolution_Calendar_OtherError, &id, NULL, NULL);
+ e_data_cal_respond_remove_object (cal, opid,
+ e_data_cal_create_error (OtherError, error->message),
+ &id, NULL, NULL);
+ g_error_free (error);
}
}
/* Discard_alarm handler for the calendar backend */
-void
-e_cal_backend_couchdb_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
+void
+e_cal_backend_couchdb_discard_alarm (ECalBackend *backend,
+ EDataCal *cal,
+ guint32 opid,
+ GCancellable *cancellable,
+ const gchar *uid,
+ const gchar *rid,
+ const gchar *auid)
{
- g_warning ("In _discard_alarm");
- e_data_cal_notify_alarm_discarded (cal, GNOME_Evolution_Calendar_Success);
}
void
-e_cal_backend_couchdb_receive_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+e_cal_backend_couchdb_receive_objects (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
{
- g_warning ("In _receive_objects");
- e_data_cal_notify_objects_received (cal, GNOME_Evolution_Calendar_OtherError);
}
void
-e_cal_backend_couchdb_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
+e_cal_backend_couchdb_send_objects (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
{
- g_warning ("In _send_objects");
- e_data_cal_notify_objects_sent (cal, GNOME_Evolution_Calendar_OtherError, NULL, NULL);
}
void
-e_cal_backend_couchdb_get_default_object (ECalBackend *backend, EDataCal *cal)
-{
- g_warning ("In _get_default_object");
- /*ECalComponent *task;
- const gchar *object;
-
- task = e_cal_component_new ();
- e_cal_component_set_new_vtype (task, E_CAL_COMPONENT_TODO);
-
- e_cal_component_commit_sequence (task);
- object = (const gchar *)e_cal_component_get_as_string (task);
-
- if (task)
- g_object_unref (task);
-
- e_data_cal_notify_default_object (cal, GNOME_Evolution_Calendar_Success, object);*/
- e_data_cal_notify_default_object (cal, GNOME_Evolution_Calendar_OtherError, NULL);
- //e_data_cal_notify_default_object (cal, GNOME_Evolution_Calendar_Success, NULL);
-}
-
-void
-e_cal_backend_couchdb_get_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
+e_cal_backend_couchdb_get_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *uid, const gchar *rid)
{
g_warning ("In _get_object");
GError *error = NULL;
@@ -614,20 +574,21 @@ e_cal_backend_couchdb_get_object (ECalBackend *backend, EDataCal *cal, const gch
g_object_unref (G_OBJECT (task));
if (task_string != NULL) {
- e_data_cal_notify_object (cal, GNOME_Evolution_Calendar_Success, task_string);
+ e_data_cal_respond_get_object (cal, opid, NULL, task_string);
g_free (task_string);
return;
}
}
- e_data_cal_notify_object (cal, GNOME_Evolution_Calendar_ObjectNotFound, "");
+ e_data_cal_respond_get_object (cal, opid, e_data_cal_create_error_fmt (ObjectNotFound, "Object %s not found", uid), NULL);
}
void
-e_cal_backend_couchdb_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar *sexp)
+e_cal_backend_couchdb_get_object_list (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *sexp)
{
g_warning ("In _get_object_list");
- GList *doc_list, *tasks = NULL;
+ GList *doc_list;
+ GSList *tasks = NULL;
GError *error = NULL;
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
@@ -638,87 +599,40 @@ e_cal_backend_couchdb_get_object_list (ECalBackend *backend, EDataCal *cal, cons
gchar *task_string;
ECalComponent *task = E_CAL_COMPONENT (doc_list->data);
- e_cal_component_commit_sequence (task);
+ e_cal_component_commit_sequence (task);
task_string = e_cal_component_get_as_string (task);
if (!task_string)
- tasks = g_list_prepend (tasks, task_string);
+ tasks = g_slist_prepend (tasks, task_string);
doc_list = g_list_remove (doc_list, task);
g_object_unref (G_OBJECT (task));
}
- e_data_cal_notify_object_list (cal, GNOME_Evolution_Calendar_Success, tasks);
-}
+ e_data_cal_respond_get_object_list (cal, opid, NULL, tasks);
-void
-e_cal_backend_couchdb_get_attachment_list (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
-{
- g_warning ("In _get_attachment_list");
- e_data_cal_notify_attachment_list (cal, GNOME_Evolution_Calendar_OtherError, NULL);
+ g_slist_foreach (tasks, (GFunc) g_free, NULL);
+ g_slist_free (tasks);
}
-/* Timezone related virtual methods */
void
-e_cal_backend_couchdb_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
+e_cal_backend_couchdb_get_attachment_uris (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *uid, const gchar *rid)
{
- g_warning ("In _get_timezone");
- e_data_cal_notify_timezone_requested (cal, GNOME_Evolution_Calendar_OtherError, NULL);
}
+/* Timezone related virtual methods */
void
-e_cal_backend_couchdb_add_timezone (ECalBackend *backend, EDataCal *cal, const gchar *object)
+e_cal_backend_couchdb_get_timezone (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *tzid)
{
- g_warning ("In _add_timezone");
- e_data_cal_notify_timezone_added (cal, GNOME_Evolution_Calendar_OtherError, NULL);
}
void
-e_cal_backend_couchdb_set_default_zone (ECalBackend *backend, EDataCal *cal, const gchar *tzobj)
+e_cal_backend_couchdb_add_timezone (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *object)
{
- g_warning ("In _set_default_zone");
- icalcomponent *tz_comp;
- ECalBackendCouchDB *couchdb_backend;
- icaltimezone *zone;
-
- couchdb_backend = (ECalBackendCouchDB *) backend;
-
- if (!(E_IS_CAL_BACKEND_COUCHDB(couchdb_backend)))
- e_data_cal_notify_default_timezone_set (cal, GNOME_Evolution_Calendar_OtherError);
- if (!(tzobj != NULL))
- e_data_cal_notify_default_timezone_set (cal, GNOME_Evolution_Calendar_OtherError);
-
- tz_comp = icalparser_parse_string (tzobj);
- if (!tz_comp)
- e_data_cal_notify_default_timezone_set (cal, GNOME_Evolution_Calendar_InvalidObject);
-
- zone = icaltimezone_new ();
- icaltimezone_set_component (zone, tz_comp);
-
- if (couchdb_backend->default_zone)
- icaltimezone_free (couchdb_backend->default_zone, 1);
-
- couchdb_backend->default_zone = zone;
- e_data_cal_notify_default_timezone_set (cal, GNOME_Evolution_Calendar_Success);
-}
-
-/*void
-e_cal_backend_couchdb_set_default_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
-{
- e_cal_backend_notify_error (backend, "No implemented");
-}*/
-
-static icaltimezone *
-e_cal_backend_couchdb_internal_get_default_timezone (ECalBackend *backend)
-{
- g_warning ("In _internal_get_default_timezone");
- ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
- return couchdb_backend->default_zone;
}
void
-e_cal_backend_couchdb_start_query (ECalBackend *backend, EDataCalView *query)
+e_cal_backend_couchdb_start_view (ECalBackend *backend, EDataCalView *query)
{
- g_warning ("In _start_query");
GList *doc_list;
ECalBackendCouchDB *couchdb_backend = E_CAL_BACKEND_COUCHDB (backend);
ECalBackendSExp *sexp;
@@ -746,40 +660,13 @@ e_cal_backend_couchdb_start_query (ECalBackend *backend, EDataCalView *query)
}
- e_data_cal_view_notify_done (query, GNOME_Evolution_Calendar_Success);
-
- //e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
+ e_data_cal_view_notify_complete (query, NULL);
}
-/* Mode relate virtual methods */
-CalMode
-e_cal_backend_couchdb_get_mode (ECalBackend *backend)
-{
- g_warning ("In _get_mode");
- //e_data_cal_notify_mode (NULL, GNOME_Evolution_Calendar_OtherError, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SET);
- return CAL_MODE_LOCAL;
-}
-
-void
-e_cal_backend_couchdb_set_mode (ECalBackend *backend, CalMode mode)
-{
- g_warning ("In _set_mode");
- //e_data_cal_notify_mode (NULL, GNOME_Evolution_Calendar_OtherError, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SET);
- e_cal_backend_notify_mode (backend, GNOME_Evolution_Calendar_CalListener_MODE_SET, GNOME_Evolution_Calendar_MODE_REMOTE);
-}
void
-e_cal_backend_couchdb_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end)
+e_cal_backend_couchdb_get_free_busy (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const GSList *users, time_t start, time_t end)
{
- g_warning ("In _get_free_busy");
- e_data_cal_notify_free_busy (cal, GNOME_Evolution_Calendar_OtherError, NULL);
-}
-
-void
-e_cal_backend_couchdb_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *change_id)
-{
- g_warning ("In _get_changes");
- e_data_cal_notify_changes (cal, GNOME_Evolution_Calendar_OtherError, NULL, NULL, NULL);
}
static void
@@ -802,9 +689,9 @@ e_cal_backend_couchdb_dispose (GObject *object)
couchdb_backend->cache = NULL;
}
- if (couchdb_backend->dbname) {
- g_free (couchdb_backend->dbname);
- couchdb_backend->dbname = NULL;
+ if (couchdb_backend->database) {
+ g_object_unref (couchdb_backend->database);
+ couchdb_backend->database = NULL;
}
}
@@ -820,12 +707,6 @@ e_cal_backend_couchdb_class_init (ECalBackendCouchDBClass *klass)
parent_class = E_CAL_BACKEND_CLASS (klass);
// Virtual methods
- parent_class->is_read_only = e_cal_backend_couchdb_is_read_only;
- parent_class->get_cal_address = e_cal_backend_couchdb_get_cal_address;
- parent_class->get_alarm_email_address = e_cal_backend_couchdb_get_alarm_email_address;
- parent_class->get_ldap_attribute = e_cal_backend_couchdb_get_ldap_attribute;
- parent_class->get_static_capabilities = e_cal_backend_couchdb_get_static_capabilities;
-
parent_class->open = e_cal_backend_couchdb_open;
parent_class->remove = e_cal_backend_couchdb_remove;
@@ -839,28 +720,20 @@ e_cal_backend_couchdb_class_init (ECalBackendCouchDBClass *klass)
parent_class->receive_objects = e_cal_backend_couchdb_receive_objects;
parent_class->send_objects = e_cal_backend_couchdb_send_objects;
- parent_class->get_default_object = e_cal_backend_couchdb_get_default_object;
parent_class->get_object = e_cal_backend_couchdb_get_object;
parent_class->get_object_list = e_cal_backend_couchdb_get_object_list;
- parent_class->get_attachment_list = e_cal_backend_couchdb_get_attachment_list;
+ parent_class->get_attachment_uris = e_cal_backend_couchdb_get_attachment_uris;
// Timezone related virtual methods
parent_class->get_timezone = e_cal_backend_couchdb_get_timezone;
parent_class->add_timezone = e_cal_backend_couchdb_add_timezone;
- parent_class->set_default_zone = e_cal_backend_couchdb_set_default_zone;
- //parent_class->set_default_timezone = e_cal_backend_couchdb_set_default_timezone;
- parent_class->internal_get_default_timezone = e_cal_backend_couchdb_internal_get_default_timezone;
- parent_class->start_query = e_cal_backend_couchdb_start_query;
+ parent_class->start_view = e_cal_backend_couchdb_start_view;
// Mode relate virtual methods
- parent_class->get_mode = e_cal_backend_couchdb_get_mode;
- parent_class->set_mode = e_cal_backend_couchdb_set_mode;
-
parent_class->get_free_busy = e_cal_backend_couchdb_get_free_busy;
- parent_class->get_changes = e_cal_backend_couchdb_get_changes;
object_class->dispose = e_cal_backend_couchdb_dispose;
@@ -871,6 +744,6 @@ static void
e_cal_backend_couchdb_init (ECalBackendCouchDB *backend)
{
backend->couchdb = NULL;
- backend->dbname = NULL;
+ backend->database = NULL;
backend->cache = NULL;
}
diff --git a/calendar/e-cal-backend-couchdb.h b/calendar/e-cal-backend-couchdb.h
index 3aa7d8d..ca45417 100644
--- a/calendar/e-cal-backend-couchdb.h
+++ b/calendar/e-cal-backend-couchdb.h
@@ -2,7 +2,7 @@
/* e-cal-backend-couchdb.h - CouchDB calendar backend factory.
*
- * Copyright (C) 2009 Canonical, Ltd. (www.canonical.com)
+ * Copyright (C) 2009-2011 Canonical, Ltd. (www.canonical.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Miguel Angel Rodelas Delgado <miguel rodelas gmail com>
+ * Rodrigo Moya <rodrigo moya canonical com>
*/
#ifndef __E_CAL_BACKEND_COUCHDB_H__
@@ -40,8 +41,8 @@ typedef struct {
ECalBackend parent_object;
CouchdbSession *couchdb;
+ CouchdbDatabase *database;
ECalBackendCache *cache;
- char *dbname;
gboolean using_desktopcouch;
icaltimezone *default_zone;
diff --git a/configure.ac b/configure.ac
index 0f25915..7cee6b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,7 @@ AC_OUTPUT([
Makefile
addressbook/Makefile
addressbook/GNOME_Evolution_CouchDB.server
+calendar/Makefile
plugins/Makefile
plugins/org-gnome-evolution-couchdb.eplug.xml
po/Makefile.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]