[evolution-exchange] Bug #670457 - Add bulk methods to ECalClient
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange] Bug #670457 - Add bulk methods to ECalClient
- Date: Wed, 28 Mar 2012 11:29:59 +0000 (UTC)
commit 06174e9a44e473e5043ff65b4fb09a45f75a1268
Author: Milan Crha <mcrha redhat com>
Date: Wed Mar 28 13:29:47 2012 +0200
Bug #670457 - Add bulk methods to ECalClient
calendar/e-cal-backend-exchange-calendar.c | 100 ++++++++++++++++++++++++----
calendar/e-cal-backend-exchange-tasks.c | 97 +++++++++++++++++++++++----
calendar/e-cal-backend-exchange.c | 46 ++++++++-----
calendar/e-cal-backend-exchange.h | 2 +
4 files changed, 199 insertions(+), 46 deletions(-)
---
diff --git a/calendar/e-cal-backend-exchange-calendar.c b/calendar/e-cal-backend-exchange-calendar.c
index 50eaa1a..1d60748 100644
--- a/calendar/e-cal-backend-exchange-calendar.c
+++ b/calendar/e-cal-backend-exchange-calendar.c
@@ -1017,6 +1017,38 @@ create_object (ECalBackendSync *backend,
e2k_properties_free (props);
}
+static void
+create_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ GSList **uids,
+ GSList **new_components,
+ GError **error)
+{
+ gchar *uid = NULL;
+ ECalComponent *new_ecalcomp = NULL;
+
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_EXCHANGE_CALENDAR (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (calobjs != NULL, InvalidArg);
+
+ if (calobjs->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("Exchange does not support bulk additions")));
+ return;
+ }
+
+ create_object (backend, cal, cancellable, calobjs->data, &uid, &new_ecalcomp, error);
+
+ if (uid) {
+ if (uids)
+ *uids = g_slist_append (NULL, uid);
+ else
+ g_free (uid);
+ }
+
+ propagate_comp_to_slist (new_ecalcomp, new_components);
+}
+
#define BUSYSTATUS 0x01
#define INSTTYPE 0x02
#define ALLDAY 0x04
@@ -1132,18 +1164,30 @@ update_x_properties (ECalBackendExchange *cbex,
}
static void
-modify_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *calobj,
- CalObjModType mod,
- ECalComponent **old_ecalcomp,
- ECalComponent **new_ecalcomp,
- GError **perror)
+modify_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **error)
{
- d(printf ("ecbexc_modify_object(%p, %p, %d, %s)", backend, cal, mod, calobj));
+ ECalComponent *old_ecalcomp = NULL, *new_ecalcomp = NULL;
+
+ d(printf ("ecbexc_modify_object(%p, %p, %d, %p)", backend, cal, mod, calobjs));
+
+ e_return_data_cal_error_if_fail (calobjs != NULL, InvalidArg);
+
+ if (calobjs->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("Exchange does not support bulk modifications")));
+ return;
+ }
+
+ modify_object_with_href (backend, cal, cancellable, calobjs->data, mod, &old_ecalcomp, &new_ecalcomp, NULL, NULL, error);
- modify_object_with_href (backend, cal, cancellable, calobj, mod, old_ecalcomp, new_ecalcomp, NULL, NULL, perror);
+ propagate_comp_to_slist (old_ecalcomp, old_components);
+ propagate_comp_to_slist (new_ecalcomp, new_components);
}
#define e_return_data_cal_error_and_val_if_fail(expr, _code, _val) \
@@ -1686,6 +1730,36 @@ remove_object (ECalBackendSync *backend,
}
static void
+remove_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *ids,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **error)
+{
+ ECalComponent *old_ecalcomp = NULL, *new_ecalcomp = NULL;
+ const ECalComponentId *ecid;
+
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_EXCHANGE_CALENDAR (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (ids != NULL, InvalidArg);
+
+ if (ids->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("Exchange does not support bulk removals")));
+ return;
+ }
+
+ ecid = ids->data;
+ e_return_data_cal_error_if_fail (ecid != NULL, InvalidArg);
+
+ remove_object (backend, cal, cancellable, ecid->uid, ecid->rid, mod, &old_ecalcomp, &new_ecalcomp, error);
+
+ propagate_comp_to_slist (old_ecalcomp, old_components);
+ propagate_comp_to_slist (new_ecalcomp, new_components);
+}
+
+static void
receive_objects (ECalBackendSync *backend,
EDataCal *cal,
GCancellable *cancellable,
@@ -2542,9 +2616,9 @@ e_cal_backend_exchange_calendar_class_init (ECalBackendExchangeCalendarClass *cl
sync_class = E_CAL_BACKEND_SYNC_CLASS (class);
sync_class->authenticate_user_sync = authenticate_user;
sync_class->refresh_sync = refresh_calendar;
- sync_class->create_object_sync = create_object;
- sync_class->modify_object_sync = modify_object;
- sync_class->remove_object_sync = remove_object;
+ sync_class->create_objects_sync = create_objects;
+ sync_class->modify_objects_sync = modify_objects;
+ sync_class->remove_objects_sync = remove_objects;
sync_class->receive_objects_sync = receive_objects;
sync_class->send_objects_sync = send_objects;
sync_class->get_free_busy_sync = get_free_busy;
diff --git a/calendar/e-cal-backend-exchange-tasks.c b/calendar/e-cal-backend-exchange-tasks.c
index 6529145..660c399 100644
--- a/calendar/e-cal-backend-exchange-tasks.c
+++ b/calendar/e-cal-backend-exchange-tasks.c
@@ -1256,6 +1256,38 @@ create_task_object (ECalBackendSync *backend,
}
static void
+create_task_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ GSList **uids,
+ GSList **new_components,
+ GError **error)
+{
+ gchar *uid = NULL;
+ ECalComponent *new_ecalcomp = NULL;
+
+ e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_EXCHANGE (backend), InvalidArg);
+ e_return_data_cal_error_if_fail (calobjs != NULL, InvalidArg);
+
+ if (calobjs->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("Exchange tasks do not support bulk additions")));
+ return;
+ }
+
+ create_task_object (backend, cal, cancellable, calobjs->data, &uid, &new_ecalcomp, error);
+
+ if (uid) {
+ if (uids)
+ *uids = g_slist_append (NULL, uid);
+ else
+ g_free (uid);
+ }
+
+ propagate_comp_to_slist (new_ecalcomp, new_components);
+}
+
+static void
modify_task_object (ECalBackendSync *backend,
EDataCal *cal,
GCancellable *cancellable,
@@ -1386,6 +1418,31 @@ modify_task_object (ECalBackendSync *backend,
}
static void
+modify_task_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **error)
+{
+ ECalComponent *old_ecalcomp = NULL, *new_ecalcomp = NULL;
+
+ e_return_data_cal_error_if_fail (calobjs != NULL, InvalidArg);
+
+ if (calobjs->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("Exchange tasks do not support bulk modifications")));
+ return;
+ }
+
+ modify_task_object (backend, cal, cancellable, calobjs->data, mod, &old_ecalcomp, &new_ecalcomp, error);
+
+ propagate_comp_to_slist (old_ecalcomp, old_components);
+ propagate_comp_to_slist (new_ecalcomp, new_components);
+}
+
+static void
receive_task_objects (ECalBackendSync *backend,
EDataCal *cal,
GCancellable *cancellable,
@@ -1480,22 +1537,31 @@ receive_task_objects (ECalBackendSync *backend,
}
static void
-remove_task_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *uid,
- const gchar *rid,
- CalObjModType mod,
- ECalComponent **old_ecalcomp,
- ECalComponent **new_ecalcomp,
- GError **error)
+remove_task_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *ids,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **error)
{
ECalBackendExchange *ecalbex = E_CAL_BACKEND_EXCHANGE (backend);
ECalBackendExchangeComponent *ecalbexcomp;
+ const ECalComponentId *ecid;
E2kContext *ctx;
E2kHTTPStatus status;
e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_EXCHANGE (ecalbex), InvalidArg);
+ e_return_data_cal_error_if_fail (ids != NULL, InvalidArg);
+
+ if (ids->next) {
+ g_propagate_error (error, EDC_ERROR_EX (UnsupportedMethod, _("Exchange tasks do not support bulk removals")));
+ return;
+ }
+
+ ecid = ids->data;
+ e_return_data_cal_error_if_fail (ecid != NULL, InvalidArg);
if (!e_backend_get_online (E_BACKEND (backend))) {
d(printf ("tasks are offline\n"));
@@ -1504,7 +1570,7 @@ remove_task_object (ECalBackendSync *backend,
}
e_cal_backend_exchange_cache_lock (ecalbex);
- ecalbexcomp = get_exchange_comp (ecalbex, uid);
+ ecalbexcomp = get_exchange_comp (ecalbex, ecid->uid);
if (!ecalbexcomp || !ecalbexcomp->href) {
e_cal_backend_exchange_cache_unlock (ecalbex);
@@ -1512,14 +1578,15 @@ remove_task_object (ECalBackendSync *backend,
return;
}
- *old_ecalcomp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (ecalbexcomp->icomp));
+ if (old_components)
+ *old_components = g_slist_append (NULL, e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (ecalbexcomp->icomp)));
e_cal_backend_exchange_cache_unlock (ecalbex);
ctx = exchange_account_get_context (ecalbex->account);
status = e2k_context_delete (ctx, NULL, ecalbexcomp->href);
if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) {
- if (e_cal_backend_exchange_remove_object (ecalbex, uid))
+ if (e_cal_backend_exchange_remove_object (ecalbex, ecid->uid))
return;
}
@@ -1554,9 +1621,9 @@ e_cal_backend_exchange_tasks_class_init (ECalBackendExchangeTasksClass *class)
sync_class = E_CAL_BACKEND_SYNC_CLASS (class);
sync_class->authenticate_user_sync = authenticate_user_task;
sync_class->refresh_sync = refresh_task;
- sync_class->create_object_sync = create_task_object;
- sync_class->modify_object_sync = modify_task_object;
- sync_class->remove_object_sync = remove_task_object;
+ sync_class->create_objects_sync = create_task_objects;
+ sync_class->modify_objects_sync = modify_task_objects;
+ sync_class->remove_objects_sync = remove_task_objects;
sync_class->receive_objects_sync = receive_task_objects;
}
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index f3c0fd2..d61a504 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -968,27 +968,27 @@ discard_alarm (ECalBackendSync *backend,
/*To be overriden by Calendar and Task classes*/
static void
-create_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *calobj,
- gchar **uid,
- ECalComponent **new_component,
- GError **perror)
+create_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ GSList **uids,
+ GSList **new_components,
+ GError **perror)
{
g_propagate_error (perror, EDC_ERROR (NotSupported));
}
/*To be overriden by Calendar and Task classes*/
static void
-modify_object (ECalBackendSync *backend,
- EDataCal *cal,
- GCancellable *cancellable,
- const gchar *calobj,
- CalObjModType mod,
- ECalComponent **old_component,
- ECalComponent **new_component,
- GError **perror)
+modify_objects (ECalBackendSync *backend,
+ EDataCal *cal,
+ GCancellable *cancellable,
+ const GSList *calobjs,
+ CalObjModType mod,
+ GSList **old_components,
+ GSList **new_components,
+ GError **perror)
{
g_propagate_error (perror, EDC_ERROR (NotSupported));
}
@@ -2096,6 +2096,17 @@ e_cal_backend_exchange_lookup_timezone (const gchar *tzid,
return zone;
}
+void
+propagate_comp_to_slist (ECalComponent *comp, GSList **lst)
+{
+ if (comp) {
+ if (lst)
+ *lst = g_slist_append (NULL, comp);
+ else
+ g_object_unref (comp);
+ }
+}
+
static void
free_exchange_comp (gpointer value)
{
@@ -2179,8 +2190,8 @@ e_cal_backend_exchange_class_init (ECalBackendExchangeClass *class)
sync_class->get_object_list_sync = get_object_list;
sync_class->add_timezone_sync = add_timezone;
sync_class->get_free_busy_sync = get_freebusy;
- sync_class->create_object_sync = create_object;
- sync_class->modify_object_sync = modify_object;
+ sync_class->create_objects_sync = create_objects;
+ sync_class->modify_objects_sync = modify_objects;
}
static void
@@ -2207,4 +2218,3 @@ e_cal_backend_exchange_init (ECalBackendExchange *cbex)
cbex, "notify::online",
G_CALLBACK (notify_online_cb), NULL);
}
-
diff --git a/calendar/e-cal-backend-exchange.h b/calendar/e-cal-backend-exchange.h
index 3862a52..bad696b 100644
--- a/calendar/e-cal-backend-exchange.h
+++ b/calendar/e-cal-backend-exchange.h
@@ -115,6 +115,8 @@ void e_cal_backend_exchange_cache_lock (ECalBackendExchange *cbex);
void e_cal_backend_exchange_cache_unlock (ECalBackendExchange *cbex);
void e_cal_backend_exchange_ensure_utc_zone (ECalBackend *cb, struct icaltimetype *itt);
+void propagate_comp_to_slist (ECalComponent *comp, GSList **lst);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]