[evolution-kolab/ek-wip-porting: 10/10] ECalBackendKolab: ported old 2.30 code over to 3.3.x
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting: 10/10] ECalBackendKolab: ported old 2.30 code over to 3.3.x
- Date: Sat, 17 Mar 2012 22:30:26 +0000 (UTC)
commit 7e83d2dd9aa78688cea0f20d32db1bd7424b32e0
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Sat Mar 17 23:27:20 2012 +0100
ECalBackendKolab: ported old 2.30 code over to 3.3.x
* fixed the old calendar API code for building
with 3.3.x
* display of calendar objects works again
* more fixups needed
src/calendar/e-cal-backend-kolab.c | 804 +++++++++++++++++++-----------------
1 files changed, 435 insertions(+), 369 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-kolab.c b/src/calendar/e-cal-backend-kolab.c
index 6409609..0d3cb30 100644
--- a/src/calendar/e-cal-backend-kolab.c
+++ b/src/calendar/e-cal-backend-kolab.c
@@ -53,6 +53,16 @@
static GHashTable *koma_objects = NULL;
/*----------------------------------------------------------------------------*/
+/* forward declarations */
+
+static void
+e_cal_backend_kolab_add_timezone (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const gchar *tzobject,
+ GError **error);
+
+/*----------------------------------------------------------------------------*/
#define E_CAL_BACKEND_KOLAB_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_CAL_BACKEND_KOLAB, ECalBackendKolabPrivate))
@@ -461,7 +471,7 @@ e_cal_backend_kolab_remove (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
+ g_warning ("%s: FIXME implement me", __func__);
#if 0 /* FIXME old */
if (priv->already_opened != FALSE) {
@@ -631,46 +641,36 @@ e_cal_backend_kolab_get_object (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ ECalComponent *ecalcomp = NULL;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
e_return_data_cal_error_if_fail (E_IS_DATA_CAL (cal), InvalidArg);
/* cancellable may be NULL */
e_return_data_cal_error_if_fail (uid != NULL, InvalidArg);
- /* rid may be NULL */
+ (void)rid; /* FIXME */ /* rid may be NULL */
e_return_data_cal_error_if_fail (calobj != NULL && *calobj == NULL, InvalidArg);
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
- (void) rid;
ecalcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
priv->cal_koma,
priv->cal_uri,
uid,
FALSE,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: %s", __func__, __LINE__, error->message);
- g_error_free (error);
- return status;
+ cancellable,
+ &tmp_err);
+ if (tmp_err != NULL) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ return;
}
if (ecalcomp != NULL) {
- *object = (gchar *) e_cal_component_get_as_string (ecalcomp);
-
+ *calobj = (gchar *) e_cal_component_get_as_string (ecalcomp);
g_object_unref (ecalcomp);
}
- else {
- *object = NULL;
- }
-
- return GNOME_Evolution_Calendar_Success;
-#endif
}
static void
@@ -683,6 +683,11 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ GList *uid_list = NULL;
+ GList *it = NULL;
+ gchar *sourcename = NULL;
+ gboolean ok = FALSE;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -694,29 +699,31 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
+ ok = kolab_util_calendar_cache_update_on_query (priv->cal_cache,
+ priv->cal_koma,
+ sexp,
+ priv->cal_uri,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ return;
+ }
sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
-
- kolab_util_calendar_cache_update_on_query (priv->cal_cache,
- priv->cal_koma,
- query,
- priv->cal_uri);
uid_list = kolab_mail_access_query_uids (priv->cal_koma,
sourcename,
- query,
- &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
+ sexp,
+ &tmp_err);
+ g_free (sourcename);
+ if (tmp_err != NULL) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ return;
}
- for (it = g_list_first (uid_list); it != NULL; it = g_list_next (it)) {
+ for (it = uid_list; it != NULL; it = g_list_next (it)) {
gchar *uid = it->data;
ECalComponent *ecalcomp = NULL;
ecalcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
@@ -724,25 +731,36 @@ e_cal_backend_kolab_get_object_list (ECalBackendSync *backend,
priv->cal_uri,
uid,
TRUE,
- &error);
- if (error != NULL) {
+ cancellable,
+ &tmp_err);
+ /* have we been cancelled? */
+ if (g_cancellable_is_cancelled (cancellable)) {
+ kolab_util_glib_glist_free (uid_list);
+ if (ecalcomp != NULL)
+ g_object_unref (ecalcomp);
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ return;
+ }
+ /* not cancelled, other error */
+ if (tmp_err != NULL) {
+ /* TODO Can we sensibly propagate an error here?
+ * Failure for one does not necessarily imply
+ * failure for the others
+ */
g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
+ __func__, __LINE__, tmp_err->message);
+ g_error_free (tmp_err);
+ tmp_err = NULL;
}
if (ecalcomp != NULL) {
- *objects = g_list_append (*objects,
- e_cal_component_get_as_string (ecalcomp));
+ *calobjs = g_slist_append (*calobjs,
+ e_cal_component_get_as_string (ecalcomp));
g_object_unref (ecalcomp);
}
}
- g_free (sourcename);
kolab_util_glib_glist_free (uid_list);
-
- return GNOME_Evolution_Calendar_Success;
-#endif
}
static void
@@ -757,65 +775,75 @@ e_cal_backend_kolab_get_free_busy (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ KolabSettingsHandler *ksettings = NULL;
+ GSList *it = NULL;
+ gboolean internal_state = TRUE;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
e_return_data_cal_error_if_fail (E_IS_DATA_CAL (cal), InvalidArg);
/* cancellable may be NULL */
e_return_data_cal_error_if_fail (users != NULL, InvalidArg);
+ (void)start; /* FIXME */
+ (void)end; /* FIXME */
e_return_data_cal_error_if_fail (freebusyobjs != NULL && *freebusyobjs == NULL, InvalidArg);
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
- (void) start;
- (void) end;
-
ksettings = kolab_mail_access_get_settings_handler (priv->cal_koma);
- if (ksettings == NULL)
- return GNOME_Evolution_Calendar_OtherError;
+ if (ksettings == NULL) {
+ /* TODO add a translatable string as custom message */
+ tmp_err = e_data_cal_create_error (OtherError, NULL);
+ }
/* receive the xfb information */
- for (it = g_list_first(users); it != NULL; it = g_list_next (it)) {
- KolabHttpJob *job = NULL;
+ for (it = (GSList *) users; it != NULL; it = g_slist_next (it)) {
+ KolabUtilHttpJob *job = NULL;
ECalComponent *ecalcomp = NULL;
- job = kolab_util_calendar_retrieve_xfb (ksettings, (gchar *) it->data);
+ job = kolab_util_calendar_retrieve_xfb (ksettings, (gchar *) it->data, &tmp_err);
if (job != NULL) {
ecalcomp = kolabconv_cal_util_freebusy_ecalcomp_new_from_ics ((gchar *) (job->buffer->data),
job->nbytes,
- &error);
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- internal_state = FALSE;
- }
+ &tmp_err);
kolab_util_http_job_free (job);
}
+ if (tmp_err != NULL) {
+ /* TODO Can we sensibly propagate an error
+ * here? Failure for one does not
+ * necessarily imply failure for all
+ */
+ g_warning ("%s()[%u] %s", __func__, __LINE__, tmp_err->message);
+ g_error_free (tmp_err);
+ tmp_err = NULL;
+ internal_state = FALSE;
+ }
+
if (ecalcomp == NULL) {
/* this is not an error, but there's no F/B
* information available.
*/
g_object_unref (ksettings);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ tmp_err = e_data_cal_create_error (ObjectNotFound, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
}
else {
- *freebusy = g_list_append (*freebusy,
- g_strdup (e_cal_component_get_as_string (ecalcomp)));
+ *freebusyobjs = g_slist_append (*freebusyobjs,
+ g_strdup (e_cal_component_get_as_string (ecalcomp)));
g_object_unref (ecalcomp);
}
}
g_object_unref (ksettings);
- if (internal_state == TRUE)
- return GNOME_Evolution_Calendar_Success;
- else
- return GNOME_Evolution_Calendar_OtherError;
-#endif
+ if (! internal_state) {
+ /* TODO add a translatable string as custom message here,
+ * could use a saved tmp_err->message (e.g. latest)
+ */
+ tmp_err = e_data_cal_create_error (OtherError, NULL);
+ g_propagate_error (error, tmp_err);
+ }
}
/**
@@ -842,6 +870,11 @@ e_cal_backend_kolab_create_object (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ ECalComponent *ecalcomp = NULL;
+ ECalComponent *tzcomp = NULL;
+ const gchar *tmp_uid = NULL;
+ GError *tmp_err = NULL;
+ gboolean ok = FALSE;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -854,21 +887,19 @@ e_cal_backend_kolab_create_object (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
-
/* What do we have here? There is an ECalComponent, unable to hold
* timezone information and an calendar entry at the same time.
* So Kolab glue code expects two ECalComponents, one for the calendar entry
* one for the timezone.
*/
- ecalcomp = e_cal_component_new_from_string (*calobj);
+ ecalcomp = e_cal_component_new_from_string (calobj);
if (ecalcomp == NULL) {
g_warning (" + **calobj could not be parsed into ECalComponent: %s",
- *calobj);
- return GNOME_Evolution_Calendar_InvalidObject;
+ calobj);
+ /* TODO add translatable string as custom message */
+ tmp_err = e_data_cal_create_error (InvalidObject, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
}
tzcomp = kolab_util_calendar_cache_get_tz (priv->cal_cache,
ecalcomp);
@@ -889,53 +920,53 @@ e_cal_backend_kolab_create_object (ECalBackendSync *backend,
*/
g_free (tzid);
g_object_unref (ecalcomp);
- /* Don't ever expect to get to see the following message */
- e_data_cal_notify_error (cal, "TZID is set, but no timezone is available. "
- "Currently this may happen if an object is copied "
- "to an empty calendar.");
- return GNOME_Evolution_Calendar_InvalidObject;
+ /* FIXME mark this as a translatable string */
+ tmp_err = e_data_cal_create_error (InvalidObject,
+ "TZID is set, but no timezone is available. Currently this may happen if an object is copied to an empty calendar.");
+ g_propagate_error (error, tmp_err);
+ return;
}
}
- if (! kolab_util_calendar_cache_assure_uid_on_ecalcomponent (priv->cal_cache,
- priv->cal_koma,
- priv->cal_uri,
- ecalcomp,
- FALSE,
- &error)) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
+
+ ok = kolab_util_calendar_cache_assure_uid_on_ecalcomponent (priv->cal_cache,
+ priv->cal_koma,
+ ecalcomp,
+ priv->cal_uri,
+ FALSE,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
g_object_unref (ecalcomp);
if (tzcomp != NULL)
g_object_unref (tzcomp);
- return status;
+ return;
}
- kolab_util_calendar_store (ecalcomp,
- tzcomp,
- priv->default_zone,
- priv->cal_koma,
- priv->cal_uri,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- return status;
+ ok = kolab_util_calendar_store (ecalcomp,
+ tzcomp,
+ priv->default_zone,
+ priv->cal_koma,
+ priv->cal_uri,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ g_object_unref (ecalcomp);
+ if (tzcomp != NULL)
+ g_object_unref (tzcomp);
+ return;
}
+
e_cal_component_get_uid (ecalcomp, &tmp_uid);
*uid = g_strdup (tmp_uid);
- *calobj = e_cal_component_get_as_string (ecalcomp);
+ *new_component = ecalcomp;
if (tzcomp != NULL)
g_object_unref (tzcomp);
- g_object_unref (ecalcomp);
-
- return GNOME_Evolution_Calendar_Success;
-#endif
}
/**
@@ -966,6 +997,13 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ ECalComponent *ecalcomp = NULL;
+ ECalComponent *oldcomp = NULL;
+ ECalComponent *ecaltz = NULL;
+ const gchar *uid = NULL;
+ gboolean is_instance = FALSE;
+ gboolean ok = FALSE;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -978,12 +1016,6 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-# if 0 /* FIXME old */
- (void) mod;
- (void) cal;
-
/* calobj contains the modifications to be performed.
* ecalcomp is the ECalComponent created from calobj.
* scenarios:
@@ -998,8 +1030,12 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
*/
ecalcomp = e_cal_component_new_from_string (calobj);
- if (ecalcomp == NULL)
- return GNOME_Evolution_Calendar_InvalidObject;
+ if (ecalcomp == NULL) {
+ tmp_err = e_data_cal_create_error (InvalidObject, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
+ }
+
e_cal_component_get_uid (ecalcomp, &uid);
oldcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
@@ -1007,18 +1043,19 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
priv->cal_uri,
uid,
FALSE,
- &error);
- if (error != NULL) {
+ cancellable,
+ &tmp_err);
+ if (tmp_err != NULL) {
/* TODO: how to handle request to modify non existing objects? */
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
g_object_unref (ecalcomp);
- g_object_unref (oldcomp);
- return GNOME_Evolution_Calendar_ObjectNotFound;
+ if (oldcomp != NULL)
+ g_object_unref (oldcomp);
+ return;
}
- *old_object = e_cal_component_get_as_string (oldcomp);
+ *old_component = oldcomp;
/* Is this correct? Perhaps _get_tz (..., oldcomp) is needed.
* This depends on wether evolution sends the timezone, if modification
* to the timezone has been made. In any other case the timezone
@@ -1032,7 +1069,6 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
ECalComponent *newcomp = NULL;
ECalComponent *oldtz = NULL;
gchar *rid = NULL;
- gchar *notify_object = NULL;
oldtz = kolab_util_calendar_cache_get_tz (priv->cal_cache,
oldcomp);
@@ -1045,16 +1081,16 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
oldcomp,
uid,
rid);
- if (! kolab_util_calendar_cache_assure_uid_on_ecalcomponent (priv->cal_cache,
- priv->cal_koma,
- priv->cal_uri,
- ecalcomp,
- TRUE,
- &error)) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
+ ok = kolab_util_calendar_cache_assure_uid_on_ecalcomponent (priv->cal_cache,
+ priv->cal_koma,
+ ecalcomp,
+ priv->cal_uri,
+ TRUE,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
if (oldtz != NULL)
g_object_unref (oldtz);
g_object_unref (ecalcomp);
@@ -1062,22 +1098,20 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
g_object_unref (ecaltz);
g_object_unref (newcomp);
g_object_unref (oldcomp);
- g_free (*old_object);
- old_object = NULL;
- return status;
+ old_component = NULL;
+ return;
}
- kolab_util_calendar_store (newcomp,
- oldtz,
- priv->default_zone,
- priv->cal_koma,
- priv->cal_uri,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: error : %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
+ ok = kolab_util_calendar_store (newcomp,
+ oldtz,
+ priv->default_zone,
+ priv->cal_koma,
+ priv->cal_uri,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
if (oldtz != NULL)
g_object_unref (oldtz);
g_object_unref (ecalcomp);
@@ -1085,46 +1119,39 @@ e_cal_backend_kolab_modify_object (ECalBackendSync *backend,
g_object_unref (ecaltz);
g_object_unref (newcomp);
g_object_unref (oldcomp);
- g_free (*old_object);
- old_object = NULL;
- return status;
+ old_component = NULL;
+ return;
}
- notify_object = e_cal_component_get_as_string (newcomp);
- e_cal_backend_notify_object_modified (E_CAL_BACKEND (kolab),
- *old_object,
- notify_object);
- g_free (notify_object);
+ e_cal_backend_notify_component_modified (E_CAL_BACKEND (backend),
+ *old_component,
+ newcomp);
g_object_unref (newcomp);
if (oldtz != NULL)
g_object_unref (oldtz);
}
g_object_unref (oldcomp);
- kolab_util_calendar_store (ecalcomp,
- ecaltz,
- priv->default_zone,
- priv->cal_koma,
- priv->cal_uri,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
+ ok = kolab_util_calendar_store (ecalcomp,
+ ecaltz,
+ priv->default_zone,
+ priv->cal_koma,
+ priv->cal_uri,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
g_object_unref (ecalcomp);
- return status;
+ return;
}
- *new_object = g_strdup (e_cal_component_get_as_string (ecalcomp));
+
+ *new_component = ecalcomp;
if (is_instance) {
- e_cal_backend_notify_object_created (E_CAL_BACKEND (backend),
- *new_object);
+ e_cal_backend_notify_component_created (E_CAL_BACKEND (backend),
+ ecalcomp);
}
- g_object_unref (ecalcomp);
if (ecaltz != NULL)
g_object_unref (ecaltz);
-
- return GNOME_Evolution_Calendar_Success;
-#endif
}
/**
@@ -1159,6 +1186,15 @@ e_cal_backend_kolab_remove_object (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ ECalComponent *oldcomp = NULL;
+ ECalComponent *newcomp = NULL;
+ ECalComponent *oldtz = NULL;
+ ECalComponentId *id = NULL;
+ KolabSettingsHandler *ksettings = NULL;
+ gchar *sourcename = NULL;
+ GError *tmp_err = NULL;
+ gboolean trigger_needed = FALSE;
+ gboolean ok = FALSE;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -1172,11 +1208,6 @@ e_cal_backend_kolab_remove_object (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
-
if (rid == NULL)
mod = CALOBJ_MOD_ALL;
@@ -1185,35 +1216,34 @@ e_cal_backend_kolab_remove_object (ECalBackendSync *backend,
priv->cal_uri,
uid,
FALSE,
- &error);
- if (error != NULL) {
- switch (error->code) {
+ cancellable,
+ &tmp_err);
+ if (tmp_err != NULL) {
+ switch (tmp_err->code) {
case KOLAB_BACKEND_ERROR_NOTFOUND:
(void) e_cal_backend_cache_remove_component (priv->cal_cache,
uid,
NULL);
/* Don't bother if this worked */
id = g_new0 (ECalComponentId, 1);
- id->uid=g_strdup (uid);
- id->rid=g_strdup (rid);
+ id->uid = g_strdup (uid);
+ id->rid = g_strdup (rid);
e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend),
id,
NULL,
NULL);
g_free (id);
- status = GNOME_Evolution_Calendar_Success;
break;
default:
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: error (%s) code (%i)",
- __func__, __LINE__, error->message, error->code);
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
}
- g_error_free (error);
- return status;
+ g_error_free (tmp_err);
+ return;
}
- *old_object = e_cal_component_get_as_string (oldcomp);
+ *old_component = oldcomp;
id = e_cal_component_get_id (oldcomp);
+
switch (mod) {
case CALOBJ_MOD_THIS:
oldtz = kolab_util_calendar_cache_get_tz (priv->cal_cache,
@@ -1224,35 +1254,33 @@ e_cal_backend_kolab_remove_object (ECalBackendSync *backend,
uid,
rid);
/* newcomp now contains an exception rule for the rid */
- kolab_util_calendar_store (newcomp,
- oldtz,
- priv->default_zone,
- priv->cal_koma,
- priv->cal_uri,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: error %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
+ ok = kolab_util_calendar_store (newcomp,
+ oldtz,
+ priv->default_zone,
+ priv->cal_koma,
+ priv->cal_uri,
+ cancellable,
+ &tmp_err);
+ if (oldtz != NULL)
+ g_object_unref (oldtz);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ e_cal_component_free_id (id);
g_object_unref (newcomp);
g_object_unref (oldcomp);
- if (oldtz != NULL)
- g_object_unref (oldtz);
- return status;
+ *old_component = NULL;
+ return;
}
- *object = e_cal_component_get_as_string (newcomp);
- g_object_unref (newcomp);
+ *new_component = newcomp;
break;
- case CALOBJ_MOD_THISANDPRIOR: /* not supported by ui */
+ case CALOBJ_MOD_THISANDPRIOR: /* not supported by backend, should not be reached */
g_warning ("%s()[%u]: removing this and prior not supported.",
__func__, __LINE__);
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
break;
- case CALOBJ_MOD_THISANDFUTURE: /* not supported by ui */
+ case CALOBJ_MOD_THISANDFUTURE: /* not supported by backend, should not be reached */
g_warning ("%s()[%u]: removing this and future not supported.",
__func__, __LINE__);
- status = GNOME_Evolution_Calendar_UnsupportedMethod;
break;
case CALOBJ_MOD_ALL:
default:
@@ -1260,58 +1288,53 @@ e_cal_backend_kolab_remove_object (ECalBackendSync *backend,
ok = kolab_mail_access_delete_by_uid (priv->cal_koma,
uid,
sourcename,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: error %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- } else {
- /* Notification is not necessary. (?) */
- status = GNOME_Evolution_Calendar_Success;
- }
+ cancellable,
+ &tmp_err);
+ g_free (sourcename);
(void) e_cal_backend_cache_remove_component (priv->cal_cache,
uid,
NULL);
-
- ksettings = kolab_mail_access_get_settings_handler (priv->cal_koma);
- g_object_unref (ksettings);
- *object = NULL;
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ e_cal_component_free_id (id);
+ g_object_unref (oldcomp);
+ *old_component = NULL;
+ return;
+ }
}
- g_object_unref (oldcomp);
- /* Do we need this? */
- ok = kolab_mail_access_source_fbtrigger_needed (priv->cal_koma,
- sourcename,
- &error);
- if (error != NULL)
- {
- status = kolab_util_calendar_map_error (error);
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- goto cleanup;
- }
- if (ok) {
+ sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
+ trigger_needed = kolab_mail_access_source_fbtrigger_needed (priv->cal_koma,
+ sourcename,
+ &tmp_err);
+ if (tmp_err != NULL) {
+ kolab_util_calendar_err_to_edb_err (error, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ e_cal_component_free_id (id);
+ g_free (sourcename);
+ g_object_unref (oldcomp);
+ *old_component = NULL;
+ return;
+ }
+ if (trigger_needed) {
ksettings = kolab_mail_access_get_settings_handler (priv->cal_koma);
- kolab_util_calendar_toggle_pfb_trigger (ksettings,
- sourcename);
+ ok = kolab_util_calendar_toggle_pfb_trigger (ksettings,
+ sourcename,
+ &tmp_err);
g_object_unref (ksettings);
+ if (! ok) {
+ g_warning ("%s()[%u] %s", __func__, __LINE__, tmp_err->message);
+ g_error_free (tmp_err);
+ tmp_err = NULL;
+ }
}
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (kolab),
- id,
- *old_object,
- *object);
+ e_cal_backend_notify_component_removed (E_CAL_BACKEND (backend),
+ id,
+ *old_component,
+ *new_component);
e_cal_component_free_id (id);
-
- cleanup:
- g_free (sourcename);
-
- return status;
-#endif
}
/**
@@ -1333,6 +1356,12 @@ e_cal_backend_kolab_receive_objects (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ ECalComponent *ecalcomp = NULL;
+ ECalComponent *tzcomp = NULL;
+ icalcomponent *icalcomp = NULL;
+ gchar *tzstr = NULL;
+ gboolean ok = FALSE;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -1343,11 +1372,6 @@ e_cal_backend_kolab_receive_objects (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
-
/* Workflow:
* Incoming calobj is supposed to be a vcalendar string.
* KolabMailHandle is the data structure we want to
@@ -1361,61 +1385,74 @@ e_cal_backend_kolab_receive_objects (ECalBackendSync *backend,
icalcomp = icalparser_parse_string (calobj);
if (icalcomp == NULL) {
- g_warning (" + *calobj could not be parsed into an icalcomponent: %s",
- calobj);
- return GNOME_Evolution_Calendar_InvalidObject;
+ g_warning ("%s()[%u] calobj could not be parsed into an icalcomponent: %s",
+ __func__, __LINE__, calobj);
+ /* TODO add a translatable string as custom error message */
+ tmp_err = e_data_cal_create_error (InvalidObject, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
}
/* now this better should be an vcalendar entry */
if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) {
- g_warning (" + **calobj does not represent an vcalendar entry: %s",
- calobj);
+ g_warning ("%s()[%u] calobj does not represent a vcalendar entry: %s",
+ __func__, __LINE__, calobj);
icalcomponent_free (icalcomp);
- return GNOME_Evolution_Calendar_InvalidObject;
+ tmp_err = e_data_cal_create_error (InvalidObject, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
}
- status = kolab_util_calendar_extract (icalcomp,
- priv->source_type,
- &ecalcomp,
- &tzcomp);
- if (status != GNOME_Evolution_Calendar_Success) {
- icalcomponent_free (icalcomp);
- return status;
- }
+ ok = kolab_util_calendar_extract (icalcomp,
+ priv->source_type,
+ &ecalcomp,
+ &tzcomp,
+ &tmp_err);
icalcomponent_free (icalcomp);
+ if (! ok) {
+ g_propagate_error (error, tmp_err);
+ return;
+ }
- kolab_util_calendar_store (ecalcomp,
- tzcomp,
- priv->default_zone,
- priv->cal_koma,
- priv->cal_uri,
- &error);
- if (error != NULL) {
- status = kolab_util_calendar_map_error (error);
- g_warning ("Error during KolabMailHandle creation: %s",
- error->message);
- g_error_free (error);
+ ok = kolab_util_calendar_store (ecalcomp,
+ tzcomp,
+ priv->default_zone,
+ priv->cal_koma,
+ priv->cal_uri,
+ cancellable,
+ &tmp_err);
+ if (! ok) {
+ kolab_util_calendar_err_to_edb_err (error,
+ tmp_err,
+ __func__,
+ __LINE__);
+ g_error_free (tmp_err);
g_object_unref (ecalcomp);
if (tzcomp != NULL)
g_object_unref (tzcomp);
- return status;
+ return;
}
if (tzcomp != NULL) {
tzstr = e_cal_component_get_as_string (tzcomp);
- status = e_cal_backend_kolab_add_timezone (backend,
- cal,
- tzstr);
+ g_object_unref (tzcomp);
+ e_cal_backend_kolab_add_timezone (backend,
+ cal,
+ cancellable,
+ tzstr,
+ &tmp_err);
+ if (tmp_err != NULL) {
+ kolab_util_calendar_err_to_edb_err (error,
+ tmp_err,
+ __func__,
+ __LINE__);
+ g_error_free (tmp_err);
+ g_object_unref (ecalcomp);
+ return;
+ }
}
- if (status != GNOME_Evolution_Calendar_Success)
- return status;
- e_cal_backend_notify_object_created (E_CAL_BACKEND (kolab),
- e_cal_component_get_as_string (ecalcomp));
+ e_cal_backend_notify_component_created (E_CAL_BACKEND (backend),
+ ecalcomp);
g_object_unref (ecalcomp);
- if (tzcomp != NULL)
- g_object_unref (tzcomp);
-
- return status;
-#endif
}
static void
@@ -1441,17 +1478,8 @@ e_cal_backend_kolab_send_objects (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) backend;
- (void) cal;
-
*users = NULL;
*modified_calobj = g_strdup (calobj);
-
- return GNOME_Evolution_Calendar_Success;
-#endif
}
static void
@@ -1516,18 +1544,29 @@ e_cal_backend_kolab_get_timezone (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ ECalComponent *ecaltz = NULL;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
e_return_data_cal_error_if_fail (E_IS_DATA_CAL (cal), InvalidArg);
- /* cancellable may be NULL */
+ (void)cancellable; /* unused */ /* cancellable may be NULL */
e_return_data_cal_error_if_fail (tzid != NULL, InvalidArg);
e_return_data_cal_error_if_fail (tzobject != NULL && *tzobject == NULL, InvalidArg);
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
+ ecaltz = kolab_util_calendar_cache_get_tz_by_id (priv->cal_cache,
+ tzid);
+ if (ecaltz == NULL) {
+ tmp_err = e_data_cal_create_error (ObjectNotFound, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
+ }
+
+ *tzobject = e_cal_component_get_as_string (ecaltz);
+ g_object_unref (ecaltz);
}
/**
@@ -1549,6 +1588,9 @@ e_cal_backend_kolab_add_timezone (ECalBackendSync *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ icalcomponent *icalcomp = NULL;
+ icaltimezone *icaltz = NULL;
+ GError *tmp_err = NULL;
g_return_if_fail (error == NULL || *error == NULL);
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_KOLAB (backend), InvalidArg);
@@ -1559,14 +1601,12 @@ e_cal_backend_kolab_add_timezone (ECalBackendSync *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
-
-#if 0 /* FIXME old */
- (void) cal;
-
- icalcomp = icalparser_parse_string (tzobj);
- if (icalcomp == NULL)
- return GNOME_Evolution_Calendar_InvalidObject;
+ icalcomp = icalparser_parse_string (tzobject);
+ if (icalcomp == NULL) {
+ tmp_err = e_data_cal_create_error (InvalidObject, NULL);
+ g_propagate_error (error, tmp_err);
+ return;
+ }
if (icalcomponent_isa (icalcomp) == ICAL_VTIMEZONE_COMPONENT) {
@@ -1574,16 +1614,16 @@ e_cal_backend_kolab_add_timezone (ECalBackendSync *backend,
icaltimezone_set_component (icaltz,
icalcomp);
- if (e_cal_backend_cache_put_timezone (priv->cal_cache, icaltz) == FALSE) {
- g_warning ("%s()[%u]: Putting timezone in cache did not succeed.",
+ if (! e_cal_backend_cache_put_timezone (priv->cal_cache, icaltz)) {
+ g_warning ("%s()[%u]: Putting timezone in cache failed.",
__func__, __LINE__);
icaltimezone_free (icaltz, 1);
- return GNOME_Evolution_Calendar_OtherError;
+ /* TODO add a translatable string as custom message */
+ tmp_err = e_data_cal_create_error (OtherError, NULL);
+ return;
}
icaltimezone_free (icaltz, 1);
}
- return GNOME_Evolution_Calendar_Success;
-#endif
}
static void
@@ -1675,6 +1715,14 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
{
ECalBackendKolab *self = NULL;
ECalBackendKolabPrivate *priv = NULL;
+ GList *uid_list = NULL;
+ GList *it = NULL;
+ GSList *iCal_objects = NULL;
+ const gchar *query = NULL;
+ gchar *sourcename = NULL;
+ GError *tmp_err = NULL;
+ GError *view_err = NULL;
+ gboolean ok = FALSE;
g_return_if_fail (E_IS_CAL_BACKEND_KOLAB (backend));
g_return_if_fail (E_IS_DATA_CAL_VIEW (view));
@@ -1682,31 +1730,27 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_warning ("%s: FIXME implement me", __func__);
- e_data_cal_view_notify_complete (view, NULL);
-
-#if 0 /* FIXME old */
- query = e_data_cal_view_get_text (cal_view);
- ksexp = e_cal_backend_sexp_new (query);
+ query = e_data_cal_view_get_text (view);
sourcename = kolab_util_backend_get_relative_path_from_uri (priv->cal_uri);
- kolab_util_calendar_cache_update_on_query (priv->cal_cache,
- priv->cal_koma,
- query,
- priv->cal_uri);
+ ok = kolab_util_calendar_cache_update_on_query (priv->cal_cache,
+ priv->cal_koma,
+ query,
+ priv->cal_uri,
+ NULL, /* FIXME: GCancellable */
+ &tmp_err);
+ if (! ok)
+ goto exit;
+
uid_list = kolab_mail_access_query_uids (priv->cal_koma,
sourcename,
query,
- &error);
- if (error != NULL) {
- g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
- }
+ &tmp_err);
+ if (tmp_err != NULL)
+ goto exit;
- for (it = g_list_first (uid_list); it != NULL; it = g_list_next (it)) {
+ for (it = uid_list; it != NULL; it = g_list_next (it)) {
gchar *uid = it->data;
ECalComponent *ecalcomp = NULL;
ecalcomp = kolab_util_calendar_cache_get_object (priv->cal_cache,
@@ -1714,32 +1758,43 @@ e_cal_backend_kolab_start_view (ECalBackend *backend,
priv->cal_uri,
uid,
TRUE,
- &error);
- if (error != NULL) {
+ NULL, /* FIXME GCancellable */
+ &tmp_err);
+ if (tmp_err != NULL) {
+ /* TODO Can we sensibly report a view error here?
+ * Failure for one object does not necessarily
+ * mean the next one will also fail. May need
+ * to differentiate error types here
+ */
g_warning ("%s()[%u]: %s",
- __func__, __LINE__, error->message);
- g_error_free (error);
- error = NULL;
+ __func__, __LINE__, tmp_err->message);
+ g_error_free (tmp_err);
+ tmp_err = NULL;
}
if (ecalcomp != NULL) {
- iCal_objects = g_list_append (iCal_objects,
- e_cal_component_get_as_string (ecalcomp));
+ iCal_objects = g_slist_append (iCal_objects,
+ e_cal_component_get_as_string (ecalcomp));
g_object_unref (ecalcomp);
}
}
- e_data_cal_view_notify_objects_added (cal_view,
+ e_data_cal_view_notify_objects_added (view,
iCal_objects);
-
- g_list_foreach (iCal_objects, (GFunc) g_free, NULL);
- g_list_free (iCal_objects);
- g_object_unref (ksexp);
+ exit:
+ g_slist_foreach (iCal_objects, (GFunc) g_free, NULL);
+ g_slist_free (iCal_objects);
g_free (sourcename);
-
kolab_util_glib_glist_free (uid_list);
- e_data_cal_view_notify_done (cal_view, status);
-#endif
+ if (tmp_err != NULL) {
+ kolab_util_calendar_err_to_edb_err (&view_err, tmp_err, __func__, __LINE__);
+ g_error_free (tmp_err);
+ }
+
+ e_data_cal_view_notify_complete (view, view_err);
+
+ if (view_err != NULL)
+ g_error_free (view_err);
}
static void
@@ -1770,7 +1825,11 @@ e_cal_backend_kolab_last_client_gone (ECalBackend *backend)
self = E_CAL_BACKEND_KOLAB (backend);
priv = E_CAL_BACKEND_KOLAB_PRIVATE (self);
- g_error ("%s: FIXME implement me", __func__);
+ /* FIXME implement me
+ * This could be the place to clean
+ * up the KolabMailAccess tables
+ */
+ g_warning ("%s: FIXME implement me", __func__);
}
/*----------------------------------------------------------------------------*/
@@ -1814,10 +1873,17 @@ e_cal_backend_kolab_dispose (GObject *object)
if (priv->already_opened) {
priv->already_opened = FALSE;
- g_object_unref (priv->cal_koma);
- priv->cal_koma = NULL;
- g_hash_table_unref (koma_objects);
- priv->koma_table = NULL;
+ g_warning ("%s()[%u] FIXME KolabMailAccess (table) disposal", __func__, __LINE__);
+#if 0 /* FIXME (check g_object_toggle_ref cleanup callback) */
+ if (priv->cal_koma != NULL) {
+ g_object_unref (priv->cal_koma);
+ priv->cal_koma = NULL;
+ }
+ if (priv->koma_table != NULL) {
+ g_hash_table_unref (priv->koma_table);
+ priv->koma_table = NULL;
+ }
+#endif
}
if (priv->default_zone != NULL) {
g_object_unref (priv->default_zone);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]