[evolution-groupwise] Bug #670457 - Add bulk methods to ECalClient
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-groupwise] Bug #670457 - Add bulk methods to ECalClient
- Date: Wed, 28 Mar 2012 12:53:52 +0000 (UTC)
commit 4208b68c7a3721235b0eb0b8dd1933f9850fc4c4
Author: Milan Crha <mcrha redhat com>
Date: Wed Mar 28 14:53:40 2012 +0200
Bug #670457 - Add bulk methods to ECalClient
src/calendar/e-cal-backend-groupwise.c | 151 +++++++++++++++++++-------------
1 files changed, 90 insertions(+), 61 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-groupwise.c b/src/calendar/e-cal-backend-groupwise.c
index 656985e..066d2fc 100644
--- a/src/calendar/e-cal-backend-groupwise.c
+++ b/src/calendar/e-cal-backend-groupwise.c
@@ -1760,7 +1760,7 @@ e_cal_backend_groupwise_internal_get_timezone (ECalBackend *backend,
static EGwConnectionStatus
update_from_server (ECalBackendGroupwise *cbgw,
GSList *uid_list,
- ECalComponent **new_ecalcomp,
+ GSList **new_components,
ECalComponent *comp)
{
EGwConnectionStatus stat;
@@ -1798,7 +1798,7 @@ update_from_server (ECalBackendGroupwise *cbgw,
put_component_to_store (cbgw, e_cal_comp);
if (i == 0) {
- *new_ecalcomp = e_cal_component_clone (e_cal_comp);
+ *new_components = g_slist_prepend (NULL, e_cal_component_clone (e_cal_comp));
}
if (i != 0) {
@@ -1813,27 +1813,37 @@ update_from_server (ECalBackendGroupwise *cbgw,
}
static void
-e_cal_backend_groupwise_create_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *in_calobj,
- gchar **uid,
- ECalComponent **new_ecalcomp,
- GError **error)
+e_cal_backend_groupwise_create_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ GSList **uids,
+ GSList **new_components,
+ GError **error)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
icalcomponent *icalcomp;
ECalComponent *comp;
EGwConnectionStatus status;
+ const gchar *calobj;
GSList *uid_list = NULL;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), InvalidArg);
- e_return_data_cal_error_if_fail (in_calobj != NULL, InvalidArg);
- e_return_data_cal_error_if_fail (new_ecalcomp != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (calobjs != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (uids != NULL, InvalidArg);
+ e_return_data_cal_error_if_fail (new_components != NULL, InvalidArg);
+
+ if (calobjs->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("GroupWise does not support bulk additions")));
+ return;
+ }
+
+ calobj = calobjs->data;
+ e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
if (!e_backend_get_online (E_BACKEND (backend))) {
in_offline (cbgw);
@@ -1842,7 +1852,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend,
}
/* check the component for validity */
- icalcomp = icalparser_parse_string (in_calobj);
+ icalcomp = icalparser_parse_string (calobj);
if (!icalcomp) {
g_propagate_error (error, EDC_ERROR (InvalidObject));
return;
@@ -1887,7 +1897,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend,
}
/* Get the item back from server to update the last-modified time */
- status = update_from_server (cbgw, uid_list, new_ecalcomp, comp);
+ status = update_from_server (cbgw, uid_list, new_components, comp);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
return;
@@ -1938,14 +1948,14 @@ get_retract_data (ECalComponent *comp,
}
static void
-e_cal_backend_groupwise_modify_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *calobj,
- CalObjModType mod,
- ECalComponent **old_ecalcomp,
- ECalComponent **new_ecalcomp,
- GError **error)
+e_cal_backend_groupwise_modify_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **error)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
@@ -1953,14 +1963,23 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend,
ECalComponent *comp, *cache_comp = NULL;
EGwConnectionStatus status;
EGwItem *item, *cache_item;
- const gchar *uid = NULL;
+ const gchar *uid = NULL, *calobj;
gchar *rid = NULL;
- *old_ecalcomp = NULL;
+ *old_components = NULL;
+
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), InvalidArg);
+ e_return_data_cal_error_if_fail (calobjs != NULL, InvalidArg);
+
+ if (calobjs->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("GroupWise does not support bulk modifications")));
+ return;
+ }
+
+ calobj = calobjs->data;
e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
if (!e_backend_get_online (E_BACKEND (backend))) {
@@ -2016,7 +2035,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend,
}
put_component_to_store (cbgw, comp);
- *new_ecalcomp = e_cal_component_clone (comp);
+ *new_components = g_slist_append (NULL, e_cal_component_clone (comp));
break;
}
@@ -2075,7 +2094,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend,
put_component_to_store (cbgw, comp);
}
- *old_ecalcomp = e_cal_component_clone (cache_comp);
+ *old_components = g_slist_append (NULL, e_cal_component_clone (cache_comp));
g_object_unref (cache_comp);
g_object_unref (comp);
g_free (rid);
@@ -2104,42 +2123,52 @@ get_gw_item_id (icalcomponent *icalcomp)
/* Remove_object handler for the file backend */
static void
-e_cal_backend_groupwise_remove_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *uid,
- const gchar *rid,
- CalObjModType mod,
- ECalComponent **old_ecalcomp,
- ECalComponent **new_ecalcomp,
- GError **perror)
+e_cal_backend_groupwise_remove_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *ids,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **error)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
+ const ECalComponentId *id;
EGwConnectionStatus status;
gchar *calobj = NULL;
GError *err = NULL;
+ e_return_data_cal_error_if_fail (ids != NULL, InvalidArg);
+
+ if (ids->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("GroupWise does not support bulk removals")));
+ return;
+ }
+
+ id = ids->data;
+ e_return_data_cal_error_if_fail (id != NULL, InvalidArg);
+
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
- *old_ecalcomp = *new_ecalcomp = NULL;
+ *old_components = *new_components = NULL;
/* if online, remove the item from the server */
if (e_backend_get_online (E_BACKEND (backend))) {
const gchar *id_to_remove = NULL;
icalcomponent *icalcomp;
- e_cal_backend_groupwise_get_object (backend, cal, NULL, uid, rid, &calobj, &err);
+ e_cal_backend_groupwise_get_object (backend, cal, NULL, id->uid, id->rid, &calobj, &err);
if (err) {
- g_propagate_error (perror, err);
+ g_propagate_error (error, err);
return;
}
icalcomp = icalparser_parse_string (calobj);
if (!icalcomp) {
g_free (calobj);
- g_propagate_error (perror, EDC_ERROR (InvalidObject));
+ g_propagate_error (error, EDC_ERROR (InvalidObject));
return;
}
@@ -2147,7 +2176,7 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend,
id_to_remove = get_gw_item_id (icalcomp);
if (!id_to_remove) {
/* use the iCalId to remove the object */
- id_to_remove = uid;
+ id_to_remove = id->uid;
}
/* remove the object */
@@ -2159,31 +2188,31 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend,
icalcomponent_free (icalcomp);
if (status == E_GW_CONNECTION_STATUS_OK) {
/* remove the component from the cache */
- if (!e_cal_backend_store_remove_component (priv->store, uid, rid)) {
+ if (!e_cal_backend_store_remove_component (priv->store, id->uid, id->rid)) {
g_free (calobj);
- g_propagate_error (perror, EDC_ERROR (ObjectNotFound));
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
return;
}
- *new_ecalcomp = NULL;
- *old_ecalcomp = e_cal_component_new_from_icalcomponent (icalparser_parse_string (calobj));
+ *new_components = NULL;
+ *old_components = g_slist_append (NULL, e_cal_component_new_from_icalcomponent (icalparser_parse_string (calobj)));
g_free (calobj);
return;
} else {
g_free (calobj);
- g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
return;
}
} else if (mod == CALOBJ_MOD_ALL) {
- GSList *l, *comp_list = e_cal_backend_store_get_components_by_uid (priv->store, uid);
+ GSList *l, *comp_list = e_cal_backend_store_get_components_by_uid (priv->store, id->uid);
if (e_cal_component_has_attendees (E_CAL_COMPONENT (comp_list->data))) {
/* get recurrence key and send it to
* e_gw_connection_remove_recurrence_item */
id_to_remove = get_gw_item_id (e_cal_component_get_icalcomponent (comp_list->data));
- status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, uid);
+ status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, id->uid);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, uid);
+ status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, id->uid);
} else {
GList *item_ids = NULL;
@@ -2203,14 +2232,14 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend,
for (l = comp_list; l; l = l->next) {
ECalComponent *comp = E_CAL_COMPONENT (l->data);
- ECalComponentId *id = e_cal_component_get_id (comp);
+ ECalComponentId *cid = e_cal_component_get_id (comp);
- e_cal_backend_store_remove_component (priv->store, id->uid,
- id->rid);
- if (!id->rid || !g_str_equal (id->rid, rid)) {
- e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbgw), id, comp, NULL);
+ e_cal_backend_store_remove_component (priv->store, cid->uid,
+ cid->rid);
+ if (!cid->rid || !g_str_equal (cid->rid, id->rid)) {
+ e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbgw), cid, comp, NULL);
}
- e_cal_component_free_id (id);
+ e_cal_component_free_id (cid);
g_object_unref (comp);
@@ -2218,22 +2247,22 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend,
/* Setting NULL would trigger another signal.
* We do not set the *object to NULL */
g_slist_free (comp_list);
- *old_ecalcomp = e_cal_component_new_from_icalcomponent (icalparser_parse_string (calobj));
- *new_ecalcomp = NULL;
+ *old_components = g_slist_append (NULL, e_cal_component_new_from_icalcomponent (icalparser_parse_string (calobj)));
+ *new_components = NULL;
g_free (calobj);
return;
} else {
g_free (calobj);
- g_propagate_error (perror, EDC_ERROR_FAILED_STATUS (OtherError, status));
+ g_propagate_error (error, EDC_ERROR_FAILED_STATUS (OtherError, status));
return;
}
} else {
- g_propagate_error (perror, EDC_ERROR (UnsupportedMethod));
+ g_propagate_error (error, EDC_ERROR (UnsupportedMethod));
return;
}
} else {
in_offline (cbgw);
- g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
+ g_propagate_error (error, EDC_ERROR (RepositoryOffline));
}
}
@@ -2701,9 +2730,9 @@ e_cal_backend_groupwise_class_init (ECalBackendGroupwiseClass *class)
sync_class->open_sync = e_cal_backend_groupwise_open;
sync_class->authenticate_user_sync = e_cal_backend_groupwise_authenticate_user;
sync_class->remove_sync = e_cal_backend_groupwise_remove;
- sync_class->create_object_sync = e_cal_backend_groupwise_create_object;
- sync_class->modify_object_sync = e_cal_backend_groupwise_modify_object;
- sync_class->remove_object_sync = e_cal_backend_groupwise_remove_object;
+ sync_class->create_objects_sync = e_cal_backend_groupwise_create_objects;
+ sync_class->modify_objects_sync = e_cal_backend_groupwise_modify_objects;
+ sync_class->remove_objects_sync = e_cal_backend_groupwise_remove_objects;
sync_class->receive_objects_sync = e_cal_backend_groupwise_receive_objects;
sync_class->send_objects_sync = e_cal_backend_groupwise_send_objects;
sync_class->get_object_sync = e_cal_backend_groupwise_get_object;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]